From c53a36687b01890c4bb5fa290a3816461e1be89b Mon Sep 17 00:00:00 2001 From: naturexie <786281870@qq.com> Date: Wed, 29 Jan 2025 19:25:00 +0800 Subject: [PATCH 1/3] feat: The maximum amount of debt that can be borrowed is logically adjusted --- screens/Trading/components/TradingOperate.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/screens/Trading/components/TradingOperate.tsx b/screens/Trading/components/TradingOperate.tsx index 35190cc5..c38033d0 100644 --- a/screens/Trading/components/TradingOperate.tsx +++ b/screens/Trading/components/TradingOperate.tsx @@ -27,6 +27,7 @@ import { useRegisterTokenType } from "../../../hooks/useRegisterTokenType"; import { MARGIN_MIN_COLLATERAL_USD } from "../../../utils/config"; import type { Asset } from "../../../redux/assetState"; import { expandToken, shrinkToken } from "../../../store"; +import type { IMarginConfigState } from "../../../redux/marginConfigState"; interface TradingOperateProps { onMobileClose?: () => void; @@ -272,7 +273,7 @@ const TradingOperate: React.FC = ({ onMobileClose, id }) => } else if (new Decimal(longInput || 0).gt(ReduxcategoryCurrentBalance2 || 0)) { setWarnTip(insufficient_balance); } else { - const borrowLimit = getBorrowLimit(ReduxcategoryAssets2, tokenInAmount); + const borrowLimit = getBorrowLimit(ReduxcategoryAssets2, tokenInAmount, config); const price_1 = getAssetPrice(ReduxcategoryAssets1); const price_2 = getAssetPrice(ReduxcategoryAssets2); if (borrowLimit?.isExceed) { @@ -311,7 +312,7 @@ const TradingOperate: React.FC = ({ onMobileClose, id }) => } else if (new Decimal(shortInput || 0).gt(ReduxcategoryCurrentBalance2 || 0)) { setWarnTip(insufficient_balance); } else { - const borrowLimit = getBorrowLimit(ReduxcategoryAssets1, tokenInAmount); + const borrowLimit = getBorrowLimit(ReduxcategoryAssets1, tokenInAmount, config); if (borrowLimit?.isExceed) { setWarnTip( <> @@ -351,6 +352,7 @@ const TradingOperate: React.FC = ({ onMobileClose, id }) => ReduxcategoryCurrentBalance2, longInput, shortInput, + config, ], ); const setMaxInputBanlance = (key: string) => { @@ -530,7 +532,7 @@ const TradingOperate: React.FC = ({ onMobileClose, id }) => if (!value) return "0"; return value.toFixed(6).replace(/\.?0+$/, ""); }; - function getBorrowLimit(assetDebt: Asset, debt_amount: number) { + function getBorrowLimit(assetDebt: Asset, debt_amount: number, marginConfig: IMarginConfigState) { const assetsMap = isMainStream ? assets.data : assetsMEME.data; const asset = assetsMap[assetDebt.token_id]; const temp1 = new Decimal(asset.supplied.balance) @@ -543,8 +545,10 @@ const TradingOperate: React.FC = ({ onMobileClose, id }) => const availableLiquidity = Number( shrinkToken(temp2, asset.metadata.decimals + asset.config.extra_decimals), ); + const scale = marginConfig.pending_debt_scale / 10000; + const availableLiquidityForMargin = availableLiquidity * scale; // asset.config.min_borrowed_amount; - if (new Decimal(debt_amount || 0).gte(availableLiquidity || 0)) { + if (new Decimal(debt_amount || 0).gte(availableLiquidityForMargin || 0)) { return { isExceed: true, availableLiquidity, From b474a921e3f5dbb62bf2c8c014f26e938326fc90 Mon Sep 17 00:00:00 2001 From: naturexie <786281870@qq.com> Date: Wed, 29 Jan 2025 20:09:24 +0800 Subject: [PATCH 2/3] feat: update dust assets logic --- components/Header/Menu.tsx | 140 -------------------------- components/Header/MenuMobile.tsx | 4 +- components/Header/Set.tsx | 4 +- components/Table/common/cells.tsx | 3 +- redux/appSelectors.ts | 5 - redux/appSlice.ts | 6 -- redux/appSliceMEME.ts | 6 -- redux/categorySelectors.ts | 4 + redux/marginTrading.ts | 7 ++ redux/selectors/getAccountRewards.ts | 10 +- redux/selectors/getPortfolioAssets.ts | 6 +- 11 files changed, 25 insertions(+), 170 deletions(-) delete mode 100644 components/Header/Menu.tsx diff --git a/components/Header/Menu.tsx b/components/Header/Menu.tsx deleted file mode 100644 index 13d4b206..00000000 --- a/components/Header/Menu.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { Menu, Divider, Typography, useTheme, useMediaQuery } from "@mui/material"; - -import ClaimAllRewards from "../ClaimAllRewards"; -import { getBurrow, getLocalAppVersion } from "../../utils"; -import { useAppSelector, useAppDispatch } from "../../redux/hooks"; -import { getAccountId } from "../../redux/accountSelectors"; -import { toggleDisplayValues, toggleShowDust } from "../../redux/appSlice"; -import { getDisplayAsTokenValue, getShowDust } from "../../redux/appSelectors"; -import { useFullDigits } from "../../hooks/useFullDigits"; -import { useDegenMode } from "../../hooks/hooks"; - -import { - trackDisplayAsUsd, - trackLogout, - trackShowDust, - trackToggleAmountDigits, -} from "../../utils/telemetry"; -import { useTicker } from "../../hooks/useTicker"; -import { useDisclaimer } from "../../hooks/useDisclaimer"; -import { isTestnet } from "../../utils/config"; -import { StyledMenuItem } from "./style"; -import { DarkModeMenuItem } from "../DarkSwitch"; - -interface Props { - anchorEl: null | HTMLElement; - setAnchorEl: React.Dispatch>; -} - -export const HamburgerMenu = ({ anchorEl, setAnchorEl }: Props) => { - const theme = useTheme(); - const dispatch = useAppDispatch(); - const open = Boolean(anchorEl); - const accountId = useAppSelector(getAccountId); - const displayAsTokenValue = useAppSelector(getDisplayAsTokenValue); - const showDust = useAppSelector(getShowDust); - const { fullDigits, setDigits } = useFullDigits(); - const isCompact = fullDigits?.table; - const appVersion = getLocalAppVersion(); - const { degenMode, setDegenMode } = useDegenMode(); - const { hasTicker, toggleTicker } = useTicker(); - const { setDisclaimer } = useDisclaimer(); - const isMobile = useMediaQuery(theme.breakpoints.down("sm")); - - const handleClose = () => { - setAnchorEl(null); - }; - - const handleToggleDisplayValues = () => { - trackDisplayAsUsd(); - dispatch(toggleDisplayValues()); - }; - - const handleToggleShowDust = () => { - trackShowDust(); - dispatch(toggleShowDust()); - }; - - const handleSwitchWallet = async () => { - await handleSignOut(); - window.modal.show(); - }; - - const handleSignOut = async () => { - const { signOut } = await getBurrow(); - signOut(); - trackLogout(); - handleClose(); - setDisclaimer(false); - }; - - const handleToggleAmountDigits = () => { - const digits = { table: !fullDigits?.table }; - trackToggleAmountDigits(digits); - setDigits(digits); - }; - - const handleToggleTicker = () => { - if (isTestnet) return; - toggleTicker(); - }; - - return ( - - {isMobile && } - {accountId && [ - , - - Degen Mode: {degenMode.enabled ? "On" : "Off"} - , - , - ]} - - Display Values As {displayAsTokenValue ? "USD" : "Token"} - - - Display {isCompact ? "Full" : "Compact"} Amounts - - - {showDust ? "Hide" : "Show"} Dust - - {!isTestnet && ( - - {hasTicker ? "Hide" : "Show"} Ticker - - )} - {accountId && [ - , - - Switch Wallet - , - , - - Sign Out - , - ]} - - - App Build Id: {appVersion} - - - ); -}; - -const ClaimMenuItem = (props) => ( - - Claim All Rewards - -); diff --git a/components/Header/MenuMobile.tsx b/components/Header/MenuMobile.tsx index 22244226..0c9504e2 100644 --- a/components/Header/MenuMobile.tsx +++ b/components/Header/MenuMobile.tsx @@ -6,8 +6,8 @@ import { MenuButton, CloseIcon, ArrowRightIcon, ArrowTopRightIcon, ArrowDownIcon import { WrapperMenuMobile } from "./style"; import { bridgeList } from "./Bridge"; import { mainMenuList, helpMenu, Imenu } from "./menuData"; -import { toggleShowDust } from "../../redux/appSlice"; -import { getShowDust } from "../../redux/appSelectors"; +import { toggleShowDust } from "../../redux/marginTrading"; +import { getShowDust } from "../../redux/categorySelectors"; import { useAppSelector, useAppDispatch } from "../../redux/hooks"; import { DiscordIcon, MediumIcon, TwitterIcon } from "../Footer/svg"; diff --git a/components/Header/Set.tsx b/components/Header/Set.tsx index 2333563a..e21797da 100644 --- a/components/Header/Set.tsx +++ b/components/Header/Set.tsx @@ -1,8 +1,8 @@ import { useState } from "react"; import { twMerge } from "tailwind-merge"; import { SetIcon } from "./svg"; -import { toggleShowDust } from "../../redux/appSlice"; -import { getShowDust } from "../../redux/appSelectors"; +import { toggleShowDust } from "../../redux/marginTrading"; +import { getShowDust } from "../../redux/categorySelectors"; import { useAppSelector, useAppDispatch } from "../../redux/hooks"; const Set = () => { diff --git a/components/Table/common/cells.tsx b/components/Table/common/cells.tsx index b41ae30b..04873ca6 100644 --- a/components/Table/common/cells.tsx +++ b/components/Table/common/cells.tsx @@ -5,7 +5,8 @@ import { Box, Tooltip, Skeleton } from "@mui/material"; import { USD_FORMAT, TOKEN_FORMAT, APY_FORMAT, DUST_FORMAT, NUMBER_FORMAT } from "../../../store"; import type { IReward, UIAsset } from "../../../interfaces"; import { useAppSelector } from "../../../redux/hooks"; -import { getDisplayAsTokenValue, getShowDust } from "../../../redux/appSelectors"; +import { getDisplayAsTokenValue } from "../../../redux/appSelectors"; +import { getShowDust } from "../../../redux/categorySelectors"; import { Rewards } from "../../index"; import { useFullDigits } from "../../../hooks/useFullDigits"; diff --git a/redux/appSelectors.ts b/redux/appSelectors.ts index 20658c35..7d2542d3 100644 --- a/redux/appSelectors.ts +++ b/redux/appSelectors.ts @@ -114,11 +114,6 @@ export const getAppState = (memeCategory?) => { ); }; -export const getShowDust = createSelector( - (state: RootState) => state.app, - (app) => app.showDust, -); - export const getShowTicker = createSelector( (state: RootState) => state.app, (app) => app.showTicker, diff --git a/redux/appSlice.ts b/redux/appSlice.ts index d659143a..e2de51d0 100644 --- a/redux/appSlice.ts +++ b/redux/appSlice.ts @@ -30,7 +30,6 @@ export interface AppState { protocolStats: boolean; displayAsTokenValue: boolean; showTicker: boolean; - showDust: boolean; slimStats: boolean; showDailyReturns: boolean; fullDigits: { @@ -80,7 +79,6 @@ export const initialState: AppState = { showInfo: true, protocolStats: true, displayAsTokenValue: true, - showDust: false, showTicker: false, slimStats: false, showDailyReturns: false, @@ -174,9 +172,6 @@ export const appSlice = createSlice({ toggleDisplayValues(state) { state.displayAsTokenValue = !state.displayAsTokenValue; }, - toggleShowDust(state) { - state.showDust = !state.showDust; - }, toggleSlimStats(state) { state.slimStats = !state.slimStats; }, @@ -245,7 +240,6 @@ export const { updateAmount, toggleUseAsCollateral, toggleDisplayValues, - toggleShowDust, toggleSlimStats, setFullDigits, toggleShowTicker, diff --git a/redux/appSliceMEME.ts b/redux/appSliceMEME.ts index 903deec5..275db402 100644 --- a/redux/appSliceMEME.ts +++ b/redux/appSliceMEME.ts @@ -30,7 +30,6 @@ export interface AppState { protocolStats: boolean; displayAsTokenValue: boolean; showTicker: boolean; - showDust: boolean; slimStats: boolean; showDailyReturns: boolean; fullDigits: { @@ -80,7 +79,6 @@ export const initialState: AppState = { showInfo: true, protocolStats: true, displayAsTokenValue: true, - showDust: false, showTicker: false, slimStats: false, showDailyReturns: false, @@ -174,9 +172,6 @@ export const appSliceMEME = createSlice({ toggleDisplayValues(state) { state.displayAsTokenValue = !state.displayAsTokenValue; }, - toggleShowDust(state) { - state.showDust = !state.showDust; - }, toggleSlimStats(state) { state.slimStats = !state.slimStats; }, @@ -245,7 +240,6 @@ export const { updateAmount, toggleUseAsCollateral, toggleDisplayValues, - toggleShowDust, toggleSlimStats, setFullDigits, toggleShowTicker, diff --git a/redux/categorySelectors.ts b/redux/categorySelectors.ts index 72e78cea..e0ee31c9 100644 --- a/redux/categorySelectors.ts +++ b/redux/categorySelectors.ts @@ -14,3 +14,7 @@ export const getActiveCategory = createSelector( return category.activeCategory; }, ); +export const getShowDust = createSelector( + (state: RootState) => state.category, + (app) => app.showDust, +); diff --git a/redux/marginTrading.ts b/redux/marginTrading.ts index 0e11baae..10fefe4a 100644 --- a/redux/marginTrading.ts +++ b/redux/marginTrading.ts @@ -10,6 +10,7 @@ interface commonAssets { ReduxTotalPLN: any; ReduxRangeMount: any; ReduxActiveTab: string; + showDust: boolean; } const initialState: commonAssets = { @@ -22,6 +23,7 @@ const initialState: commonAssets = { ReduxTotalPLN: 0, ReduxRangeMount: 1, ReduxActiveTab: "long", + showDust: false, }; const marginCategory = createSlice({ @@ -55,6 +57,9 @@ const marginCategory = createSlice({ setReduxActiveTab(state, action) { state.ReduxActiveTab = action.payload; }, + toggleShowDust(state) { + state.showDust = !state.showDust; + }, }, }); @@ -68,6 +73,7 @@ const { setReduxTotalPLN, setReduxRangeMount, setReduxActiveTab, + toggleShowDust, } = marginCategory.actions; const marginCategoryReducer = marginCategory.reducer; export { @@ -80,5 +86,6 @@ export { setReduxTotalPLN, setReduxRangeMount, setReduxActiveTab, + toggleShowDust, }; export default marginCategoryReducer; diff --git a/redux/selectors/getAccountRewards.ts b/redux/selectors/getAccountRewards.ts index e2bd40c3..9a0fec00 100644 --- a/redux/selectors/getAccountRewards.ts +++ b/redux/selectors/getAccountRewards.ts @@ -813,7 +813,7 @@ export const getAccountDailyRewards = (memeCategory?: boolean) => { const accountDustProcess = dustProcess({ accountSource: account, assets, - app, + showDust: category.showDust, }); const baseCollateralUsdDaily = getGainsArr(accountDustProcess.portfolio.collaterals, assets)[0] / 365; @@ -959,11 +959,11 @@ export function filterAccountEndedFarms(userFarms, allFarms): IAccountFarms { function dustProcess({ accountSource, assets, - app, + showDust, }: { accountSource: AccountState; assets: AssetsState; - app: AppState; + showDust: boolean; }) { const account = Copy(accountSource); const portfolioAssets = { @@ -987,7 +987,7 @@ function dustProcess({ supplied: suppliedToken, }; }) - .filter(app.showDust ? Boolean : emptySuppliedAsset) + .filter(showDust ? Boolean : emptySuppliedAsset) .reduce((acc, cur) => [...acc, cur.tokenId], [] as any); const borrowed = Object.keys(account.portfolio.borrowed) @@ -1002,7 +1002,7 @@ function dustProcess({ borrowed: borrowedToken, }; }) - .filter(app.showDust ? Boolean : emptyBorrowedAsset) + .filter(showDust ? Boolean : emptyBorrowedAsset) .reduce((acc, cur) => [...acc, cur.tokenId], [] as any); const newSupplied = {}; const newCollateral = {}; diff --git a/redux/selectors/getPortfolioAssets.ts b/redux/selectors/getPortfolioAssets.ts index aea66159..353bf16f 100644 --- a/redux/selectors/getPortfolioAssets.ts +++ b/redux/selectors/getPortfolioAssets.ts @@ -140,7 +140,7 @@ export const getPortfolioAssets = (memeCategory?: boolean) => { totalSupplyMoney: toUsd(totalSupplyD, asset), }); }) - .filter(app.showDust ? Boolean : emptySuppliedAsset); + .filter(category.showDust ? Boolean : emptySuppliedAsset); // borrow from regular position const borrowed = Object.keys(account.portfolio.borrowed || {}) .map((tokenId) => { @@ -180,7 +180,7 @@ export const getPortfolioAssets = (memeCategory?: boolean) => { totalSupplyMoney: toUsd(totalSupplyD, asset), }); }) - .filter(app.showDust ? Boolean : emptyBorrowedAsset); + .filter(category.showDust ? Boolean : emptyBorrowedAsset); // borrow from lp position const borrowed_LP = Object.keys(lpPositions).reduce((acc, shadow_id: string) => { const b = Object.keys(lpPositions[shadow_id].borrowed) @@ -223,7 +223,7 @@ export const getPortfolioAssets = (memeCategory?: boolean) => { totalSupplyMoney: toUsd(totalSupplyD, asset), }); }) - .filter(app.showDust ? Boolean : emptyBorrowedAsset); + .filter(category.showDust ? Boolean : emptyBorrowedAsset); return { ...acc, [shadow_id]: b }; }, {}); const borrowedAll = Array.from(borrowed); From 38f39c74268de12c9d0261e64ee76cc10b666ec1 Mon Sep 17 00:00:00 2001 From: naturexie <786281870@qq.com> Date: Wed, 29 Jan 2025 21:31:03 +0800 Subject: [PATCH 3/3] feat: replace get_assets_paged to get_assets_paged_detailed --- api/get-account-meme.ts | 4 +-- api/get-account.ts | 4 +-- api/get-assets-meme.ts | 4 +-- api/get-assets.ts | 4 +-- interfaces/burrow.ts | 3 ++- interfaces/contract-methods.ts | 1 + next.config.js | 4 +-- store/accounts.ts | 38 --------------------------- store/assets.ts | 48 ++++++++-------------------------- 9 files changed, 24 insertions(+), 86 deletions(-) diff --git a/api/get-account-meme.ts b/api/get-account-meme.ts index d189968d..f136e45a 100644 --- a/api/get-account-meme.ts +++ b/api/get-account-meme.ts @@ -1,4 +1,4 @@ -import { getAssetsMEMEDetailed } from "../store"; +import { getAssetsMEMEDetail } from "../store"; import getBalance from "./get-balance"; import getPortfolioMEME from "./get-portfolio-meme"; @@ -9,7 +9,7 @@ const getAccountMEME = async () => { const account = await getAccountWallet(); const { accountId } = account; if (accountId) { - const assets = await getAssetsMEMEDetailed(); + const assets = await getAssetsMEMEDetail(); const tokenIds = assets.map((asset) => asset.token_id); const shadowRecords = await getShadowRecords(); const accountBalance = (await account.getAccountBalance()).available; diff --git a/api/get-account.ts b/api/get-account.ts index c3278822..0706f072 100644 --- a/api/get-account.ts +++ b/api/get-account.ts @@ -1,4 +1,4 @@ -import { getAssetsDetailed } from "../store"; +import { getAssetsDetail } from "../store"; import getBalance from "./get-balance"; import getPortfolio from "./get-portfolio"; @@ -10,7 +10,7 @@ const getAccount = async () => { const account = await getAccountWallet(); const { accountId } = account; if (accountId) { - const assets = await getAssetsDetailed(); + const assets = await getAssetsDetail(); const tokenIds = assets.map((asset) => asset.token_id); const shadowRecords = await getShadowRecords(); const accountBalance = (await account.getAccountBalance()).available; diff --git a/api/get-assets-meme.ts b/api/get-assets-meme.ts index 7e31ee20..37540374 100644 --- a/api/get-assets-meme.ts +++ b/api/get-assets-meme.ts @@ -1,5 +1,5 @@ import Decimal from "decimal.js"; -import { getAllMetadata, getAssetsMEMEDetailed, getPrices, getUnitLptAssets } from "../store"; +import { getAllMetadata, getAssetsMEMEDetail, getPrices, getUnitLptAssets } from "../store"; import { shrinkToken } from "../store/helper"; import { lpTokenPrefix } from "../utils/config"; import { IToken, IUnitLptAssetDetail, IMetadata } from "../interfaces/asset"; @@ -40,7 +40,7 @@ const getLptMetadata = (lp_token_details: IUnitLptAssetDetail, priceMap, metadat }; const getAssetsMEME = async () => { - const assets = await getAssetsMEMEDetailed(); + const assets = await getAssetsMEMEDetail(); const token_ids_from_regular = assets .filter((asset) => asset.token_id.indexOf(lpTokenPrefix) === -1) .map((asset) => asset.token_id); diff --git a/api/get-assets.ts b/api/get-assets.ts index 33b31709..48d33b3f 100644 --- a/api/get-assets.ts +++ b/api/get-assets.ts @@ -1,5 +1,5 @@ import Decimal from "decimal.js"; -import { getAllMetadata, getAssetsDetailed, getPrices, getUnitLptAssets } from "../store"; +import { getAllMetadata, getAssetsDetail, getPrices, getUnitLptAssets } from "../store"; import { shrinkToken } from "../store/helper"; import { lpTokenPrefix, blackAssets } from "../utils/config"; import { IToken, IUnitLptAssetDetail, IMetadata } from "../interfaces/asset"; @@ -40,7 +40,7 @@ const getLptMetadata = (lp_token_details: IUnitLptAssetDetail, priceMap, metadat }; const getAssets = async () => { - const assets_pending = await getAssetsDetailed(); + const assets_pending = await getAssetsDetail(); const assets = assets_pending.filter((asset) => !blackAssets.includes(asset.token_id)); const token_ids_from_regular = assets .filter((asset) => asset.token_id.indexOf(lpTokenPrefix) === -1) diff --git a/interfaces/burrow.ts b/interfaces/burrow.ts index 763e9005..d51ea1a0 100644 --- a/interfaces/burrow.ts +++ b/interfaces/burrow.ts @@ -52,7 +52,8 @@ export type IViewReturnType = | IMarginConfig | IMarginAccountDetailedView | IPoolDcl[] - | IQuoteResult; + | IQuoteResult + | IAssetDetailed[]; export interface IBurrow { selector: WalletSelector; diff --git a/interfaces/contract-methods.ts b/interfaces/contract-methods.ts index 9df4dcc6..6278f818 100644 --- a/interfaces/contract-methods.ts +++ b/interfaces/contract-methods.ts @@ -8,6 +8,7 @@ export enum ViewMethodsLogic { get_asset, get_assets, get_assets_paged, + get_assets_paged_detailed, // config get_config, get_margin_config, diff --git a/next.config.js b/next.config.js index 3adc3e67..e6e7ffd0 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,7 @@ /** @type {import('next').NextConfig} */ module.exports = { - reactStrictMode: true, - trailingSlash: true, + reactStrictMode: false, + trailingSlash: false, eslint: { ignoreDuringBuilds: true, }, diff --git a/store/accounts.ts b/store/accounts.ts index cf3ad936..c3db2e2c 100644 --- a/store/accounts.ts +++ b/store/accounts.ts @@ -1,43 +1,5 @@ -import { IAccount, IAccountDetailed, ViewMethodsLogic } from "../interfaces"; import { getBurrow } from "../utils"; -export const getAccounts = async (): Promise => { - const { view, logicContract } = await getBurrow(); - - const accounts: IAccount[] = (await view( - logicContract, - ViewMethodsLogic[ViewMethodsLogic.get_accounts_paged], - )) as IAccount[]; - - return accounts; -}; - -export const getAccountDetailed = async (account_id: string): Promise => { - if (!account_id) return null; - - const { view, logicContract } = await getBurrow(); - - const accountDetailed: IAccountDetailed = (await view( - logicContract, - ViewMethodsLogic[ViewMethodsLogic.get_account], - { - account_id, - }, - )) as IAccountDetailed; - - return accountDetailed; -}; - -export const getAccountsDetailed = async (): Promise => { - const accounts: IAccount[] = await getAccounts(); - - const result: IAccountDetailed[] = ( - await Promise.all(accounts.map((account) => getAccountDetailed(account.account_id))) - ).filter((account): account is IAccountDetailed => !!account); - - return result; -}; - export const getAccount = async () => { const { account } = await getBurrow(); return account; diff --git a/store/assets.ts b/store/assets.ts index a125e24b..60084880 100644 --- a/store/assets.ts +++ b/store/assets.ts @@ -22,6 +22,13 @@ export const getAssets = async (): Promise => { token_id, })); }; +export const getAssetsDetail = async (): Promise => { + const { view, logicContract } = await getBurrow(); + return (await view( + logicContract, + ViewMethodsLogic[ViewMethodsLogic.get_assets_paged_detailed], + )) as IAssetDetailed[]; +}; export const getAssetsMEME = async (): Promise => { const { view, logicMEMEContract, pythContract } = await getBurrow(); @@ -35,45 +42,12 @@ export const getAssetsMEME = async (): Promise => { token_id, })); }; - -export const getAssetDetailed = async (token_id: string): Promise => { - const { view, logicContract } = await getBurrow(); - const assetDetails: IAssetDetailed = (await view( - logicContract, - ViewMethodsLogic[ViewMethodsLogic.get_asset], - { - token_id, - }, - )) as IAssetDetailed; - - return assetDetails; -}; - -export const getAssetMEMEDetailed = async (token_id: string): Promise => { +export const getAssetsMEMEDetail = async (): Promise => { const { view, logicMEMEContract } = await getBurrow(); - const assetDetails: IAssetDetailed = (await view( + return (await view( logicMEMEContract, - ViewMethodsLogic[ViewMethodsLogic.get_asset], - { - token_id, - }, - )) as IAssetDetailed; - - return assetDetails; -}; - -export const getAssetsDetailed = async (): Promise => { - const assets: IAssetEntry[] = await getAssets(); - const detailedAssets = await Promise.all(assets.map((asset) => getAssetDetailed(asset.token_id))); - return detailedAssets; -}; - -export const getAssetsMEMEDetailed = async (): Promise => { - const assets: IAssetEntry[] = await getAssetsMEME(); - const detailedAssets = await Promise.all( - assets.map((asset) => getAssetMEMEDetailed(asset.token_id)), - ); - return detailedAssets; + ViewMethodsLogic[ViewMethodsLogic.get_assets_paged_detailed], + )) as IAssetDetailed[]; }; export const getUnitLptAssets = async (pool_ids: number[]): Promise => {