Skip to content

Commit

Permalink
Merge branch 'hide-lp-token' into repay-more-for-dust
Browse files Browse the repository at this point in the history
  • Loading branch information
xieqiancaosissi committed Jan 14, 2024
2 parents b54822a + 140040f commit 67c1c35
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions redux/assetsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export const assetSlice = createSlice({
builder.addCase(fetchRefPrices.fulfilled, (state, action) => {
missingPriceTokens.forEach((missingToken) => {
const missingTokenId = missingToken[defaultNetwork];

if (missingTokenId && state.data[missingTokenId]) {
if (missingTokenId && state.data[missingTokenId] && !state.data[missingTokenId]["price"]) {
state.data[missingTokenId]["price"] = {
decimals: action.payload[missingToken.mainnet].decimal,
usd: Number(action.payload[missingToken.mainnet].price),
Expand Down
6 changes: 5 additions & 1 deletion redux/selectors/recomputeHealthFactorRepayFromDeposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export const recomputeHealthFactorRepayFromDeposits = (tokenId: string, amount:
}
}

const adjustedCollateralSum = getAdjustedSum("collateral", account.portfolio, assets.data);
const adjustedCollateralSum = getAdjustedSum(
"collateral",
clonedAccount.portfolio,
assets.data,
);
const adjustedBorrowedSum = getAdjustedSum("borrowed", clonedAccount.portfolio, assets.data);

const healthFactor = adjustedCollateralSum.div(adjustedBorrowedSum).mul(100).toNumber();
Expand Down
3 changes: 2 additions & 1 deletion store/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Decimal from "decimal.js";
import { IAssetEntry, IAssetDetailed, AssetEntry, ViewMethodsLogic } from "../interfaces";
import { getBurrow } from "../utils";
import { DEFAULT_PRECISION } from "./constants";
import { lpTokenPrefix } from "../utils/config";

Decimal.set({ precision: DEFAULT_PRECISION });

Expand Down Expand Up @@ -33,5 +34,5 @@ export const getAssetDetailed = async (token_id: string): Promise<IAssetDetailed
export const getAssetsDetailed = async (): Promise<IAssetDetailed[]> => {
const assets: IAssetEntry[] = await getAssets();
const detailedAssets = await Promise.all(assets.map((asset) => getAssetDetailed(asset.token_id)));
return detailedAssets;
return detailedAssets.filter((asset) => !asset.token_id.includes(lpTokenPrefix));
};
1 change: 1 addition & 0 deletions utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const LOGIC_CONTRACT_NAME = process.env.NEXT_PUBLIC_CONTRACT_NAME as stri
export const DUST_THRESHOLD = 0.001;

export const hiddenAssets = ["meta-token.near", "usn"];
export const lpTokenPrefix = "shadow_ref_v1";

export const defaultNetwork = (process.env.NEXT_PUBLIC_DEFAULT_NETWORK ||
process.env.NODE_ENV ||
Expand Down

0 comments on commit 67c1c35

Please sign in to comment.