From 07d5ce1999b4518f98d663587504c1c0544e8a61 Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Mon, 4 Dec 2023 14:58:37 +0100 Subject: [PATCH] v1.7.4 --- package.json | 2 +- src/components/common/TxModal/Action.tsx | 3 ++- .../DepositColumns/useDepositColumns.tsx | 12 ++++++--- .../redbank/RedbankColumns.module.scss | 8 ++++++ .../RedbankNotConnected.tsx | 2 +- src/configs/devnet.ts | 26 +++++++++++++++++++ src/configs/osmosis-1.ts | 26 +++++++++++++++++++ src/hooks/queries/useAssetParams.tsx | 11 +++++++- src/hooks/queries/useDepositAndDebt.tsx | 4 +++ src/mocks/redBankAssets.ts | 4 +-- src/store/slices/redBank.ts | 7 +++-- src/styles/_assets.module.scss | 2 ++ src/styles/_master.scss | 4 +++ .../generated/mars-params/MarsParams.types.ts | 4 +++ src/types/interfaces/asset.d.ts | 6 ++++- src/types/interfaces/redbank.d.ts | 4 +++ 16 files changed, 112 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 57c4f0c..7993150 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mars", "homepage": "./", - "version": "1.7.3", + "version": "1.7.4", "private": false, "license": "SEE LICENSE IN LICENSE FILE", "scripts": { diff --git a/src/components/common/TxModal/Action.tsx b/src/components/common/TxModal/Action.tsx index a220df0..56f2751 100644 --- a/src/components/common/TxModal/Action.tsx +++ b/src/components/common/TxModal/Action.tsx @@ -310,7 +310,8 @@ export const Action = ({ if (!currentAsset) return <> - const amountUntilDepositCap = currentAsset.depositCap - Number(currentAsset.depositLiquidity) + const amountUntilDepositCap = + Number(currentAsset.depositCap.amount) - Number(currentAsset.depositCap.used) const onValueEntered = (microValue: number) => { if (microValue >= maxUsableAmount) microValue = maxUsableAmount diff --git a/src/components/redbank/DepositColumns/useDepositColumns.tsx b/src/components/redbank/DepositColumns/useDepositColumns.tsx index b8d7421..209766c 100644 --- a/src/components/redbank/DepositColumns/useDepositColumns.tsx +++ b/src/components/redbank/DepositColumns/useDepositColumns.tsx @@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js' import classNames from 'classnames' import { AnimatedNumber, Apr, Button, CellAmount, SVG, TextTooltip } from 'components/common' import { convertPercentage } from 'functions' -import { formatValue } from 'libs/parse' +import { demagnify, formatValue } from 'libs/parse' import Image from 'next/image' import { useMemo } from 'react' import { isMobile, isTablet } from 'react-device-detect' @@ -127,8 +127,12 @@ export const useDepositColumns = () => { /> ), cell: ({ row }) => { - const depositLiquidity = Number(row.original.depositLiquidity) - const percent = convertPercentage((depositLiquidity / row.original.depositCap) * 100) + const depositCap = new BigNumber(row.original.depositCap?.amount ?? 0) + const depositCapUsed = new BigNumber(row.original.depositCap?.used ?? 0) + const percent = depositCap.isZero() + ? 0 + : convertPercentage(depositCapUsed.dividedBy(depositCap).toNumber() * 100) + const percentClasses = classNames( 's', 'number', @@ -139,7 +143,7 @@ export const useDepositColumns = () => { <>

{formatValue( - row.original.depositCap / 10 ** row.original.decimals, + demagnify(depositCap.toNumber(), row.original.decimals), 2, 2, true, diff --git a/src/components/redbank/RedbankColumns.module.scss b/src/components/redbank/RedbankColumns.module.scss index d053d90..cdc82ce 100644 --- a/src/components/redbank/RedbankColumns.module.scss +++ b/src/components/redbank/RedbankColumns.module.scss @@ -11,6 +11,10 @@ background-image: $colorGradientOSMO; } + &.akt { + background-image: $colorGradientAKT; + } + &.atom { background-image: $colorGradientATOM; } @@ -19,6 +23,10 @@ background-image: $colorGradientAXL; } + &.dydx { + background-image: $colorGradientDYDX; + } + &.inj { background-image: $colorGradientINJ; } diff --git a/src/components/redbank/RedbankNotConnected/RedbankNotConnected.tsx b/src/components/redbank/RedbankNotConnected/RedbankNotConnected.tsx index 52a96d3..660fa70 100644 --- a/src/components/redbank/RedbankNotConnected/RedbankNotConnected.tsx +++ b/src/components/redbank/RedbankNotConnected/RedbankNotConnected.tsx @@ -40,7 +40,7 @@ export const RedbankNotConnected = () => { isCollateral: true, borrowBalanceBaseCurrency: 0, depositBalanceBaseCurrency: 0, - depositCap: 0, + depositCap: { amount: '0', used: '0' }, depositLiquidity: 0, borrowEnabled: true, depositEnabled: true, diff --git a/src/configs/devnet.ts b/src/configs/devnet.ts index b1eaf1f..015f6ec 100644 --- a/src/configs/devnet.ts +++ b/src/configs/devnet.ts @@ -1,8 +1,10 @@ +import akt from 'images/akt.svg' import atom from 'images/atom.svg' import axl from 'images/axl.svg' import axlusdc from 'images/axlusdc.svg' import axlwbtc from 'images/axlwbtc.svg' import axlweth from 'images/axlweth.svg' +import dydx from 'images/dydx.svg' import inj from 'images/inj.svg' import mars from 'images/mars.svg' import osmo from 'images/osmo.svg' @@ -133,6 +135,26 @@ const ASSETS: NetworkAssets = { logo: stosmo, decimals: 6, }, + akt: { + symbol: 'AKT', + id: 'AKT', + name: 'Akash', + denom: 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4', + logo: akt, + color: colors.akt, + decimals: 6, + priceFeedId: '4ea5bb4d2f5900cc2e97ba534240950740b4d3b89fe712a94a7304fd2fd92702', + }, + dydx: { + symbol: 'DYDX', + id: 'DYDX', + name: 'DyDx', + denom: 'ibc/831F0B1BBB1D08A2B75311892876D71565478C532967545476DF4C2D7492E48C', + logo: dydx, + color: colors.dydx, + decimals: 18, + priceFeedId: '6489800bb8974169adfe35937bf6736507097d13c190d760c557108c7e93a81b', + }, } const OTHER_ASSETS: { [denom: string]: OtherAsset } = { @@ -179,10 +201,12 @@ export const NETWORK_CONFIG: NetworkConfig = { whitelist: [ ASSETS.osmo, ASSETS.atom, + ASSETS.akt, ASSETS.axl, ASSETS.axlusdc, ASSETS.axlwbtc, ASSETS.axlweth, + ASSETS.dydx, ASSETS.inj, ASSETS.statom, ASSETS.usdc, @@ -198,9 +222,11 @@ export const NETWORK_CONFIG: NetworkConfig = { ASSETS.axlusdc, ASSETS.osmo, ASSETS.atom, + ASSETS.akt, ASSETS.axl, ASSETS.axlweth, ASSETS.axlwbtc, + ASSETS.dydx, ASSETS.statom, ASSETS.stosmo, ASSETS.tia, diff --git a/src/configs/osmosis-1.ts b/src/configs/osmosis-1.ts index 32fc2d9..dde3920 100644 --- a/src/configs/osmosis-1.ts +++ b/src/configs/osmosis-1.ts @@ -1,8 +1,10 @@ +import akt from 'images/akt.svg' import atom from 'images/atom.svg' import axl from 'images/axl.svg' import axlusdc from 'images/axlusdc.svg' import axlwbtc from 'images/axlwbtc.svg' import axlweth from 'images/axlweth.svg' +import dydx from 'images/dydx.svg' import inj from 'images/inj.svg' import mars from 'images/mars.svg' import osmo from 'images/osmo.svg' @@ -133,6 +135,26 @@ const ASSETS: NetworkAssets = { logo: stosmo, decimals: 6, }, + akt: { + symbol: 'AKT', + id: 'AKT', + name: 'Akash', + denom: 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4', + logo: akt, + color: colors.akt, + decimals: 6, + priceFeedId: '4ea5bb4d2f5900cc2e97ba534240950740b4d3b89fe712a94a7304fd2fd92702', + }, + dydx: { + symbol: 'DYDX', + id: 'DYDX', + name: 'DyDx', + denom: 'ibc/831F0B1BBB1D08A2B75311892876D71565478C532967545476DF4C2D7492E48C', + logo: dydx, + color: colors.dydx, + decimals: 18, + priceFeedId: '6489800bb8974169adfe35937bf6736507097d13c190d760c557108c7e93a81b', + }, } const OTHER_ASSETS: { [denom: string]: OtherAsset } = { @@ -181,10 +203,12 @@ export const NETWORK_CONFIG: NetworkConfig = { whitelist: [ ASSETS.osmo, ASSETS.atom, + ASSETS.akt, ASSETS.axl, ASSETS.axlusdc, ASSETS.axlwbtc, ASSETS.axlweth, + ASSETS.dydx, ASSETS.inj, ASSETS.statom, ASSETS.usdc, @@ -200,9 +224,11 @@ export const NETWORK_CONFIG: NetworkConfig = { ASSETS.axlusdc, ASSETS.osmo, ASSETS.atom, + ASSETS.akt, ASSETS.axl, ASSETS.axlweth, ASSETS.axlwbtc, + ASSETS.dydx, ASSETS.statom, ASSETS.stosmo, ASSETS.tia, diff --git a/src/hooks/queries/useAssetParams.tsx b/src/hooks/queries/useAssetParams.tsx index 6b7f625..0255cf6 100644 --- a/src/hooks/queries/useAssetParams.tsx +++ b/src/hooks/queries/useAssetParams.tsx @@ -6,13 +6,22 @@ import { QUERY_KEYS } from 'types/enums/queryKeys' export const useAssetParams = () => { const paramsContract = useStore((s) => s.networkConfig.contracts.params) const paramsClient = useStore((s) => s.paramsClient) - + const whitelistedAssets = useStore((s) => s.networkConfig.assets.whitelist) return useQuery( [QUERY_KEYS.ASSET_PARAMS], async () => { if (!paramsClient) return [] const params = await iterateContractQuery(paramsClient.allAssetParams) + const capQueries = whitelistedAssets.map( + async (assetParams) => await paramsClient.totalDeposit({ denom: assetParams.denom }), + ) + const assetCaps = await Promise.all(capQueries) + assetCaps.forEach((assetCap) => { + const assetParams = params.find((param) => param.denom === assetCap.denom) + if (!assetParams) return + assetParams.cap = { amount: assetCap.cap, used: assetCap.amount } + }) useStore.setState({ assetParams: params }) return params }, diff --git a/src/hooks/queries/useDepositAndDebt.tsx b/src/hooks/queries/useDepositAndDebt.tsx index 90ff2fb..be3e04b 100644 --- a/src/hooks/queries/useDepositAndDebt.tsx +++ b/src/hooks/queries/useDepositAndDebt.tsx @@ -9,12 +9,16 @@ export interface DepositAndDebtData { mdwasmkey: { OSMODeposits: string OSMODebt: string + AKTDeposits: string + AKTDebt: string ATOMDeposits: string ATOMDebt: string ASTRODeposits: string ASTRODebt: string AXLDeposits: string AXLDebt: string + DYDXDeposits: string + DYDXDebt: string INJDeposits: string INJDebt: string axlUSDCDeposits: string diff --git a/src/mocks/redBankAssets.ts b/src/mocks/redBankAssets.ts index 8a290b4..3ba7481 100644 --- a/src/mocks/redBankAssets.ts +++ b/src/mocks/redBankAssets.ts @@ -9,7 +9,7 @@ export const redBankAssets: RedBankAsset[] = [ denom: 'ATOM', depositBalance: '0', depositBalanceBaseCurrency: 0, - depositCap: 1_000_000, + depositCap: { amount: '1000000', used: '5000' }, depositLiquidity: 5_000, isCollateral: true, logo: '', @@ -31,7 +31,7 @@ export const redBankAssets: RedBankAsset[] = [ denom: 'OSMO', depositBalance: '0', depositBalanceBaseCurrency: 0, - depositCap: 1_000_000, + depositCap: { amount: '1000000', used: '5000' }, depositLiquidity: 5_000, isCollateral: true, logo: '', diff --git a/src/store/slices/redBank.ts b/src/store/slices/redBank.ts index c245711..df4078c 100644 --- a/src/store/slices/redBank.ts +++ b/src/store/slices/redBank.ts @@ -79,6 +79,7 @@ const redBankSlice = (set: NamedSet, get: GetState): RedBankSlice // ------------------ setRedBankAssets: () => { if (get().exchangeRatesState !== State.READY || get().userBalancesState !== State.READY) return + const params = get().assetParams const redBankAssets: RedBankAsset[] = [] const marketAssetLiquidity: Coin[] = [] const whitelistedAssets = get().networkConfig.assets.whitelist @@ -94,7 +95,7 @@ const redBankSlice = (set: NamedSet, get: GetState): RedBankSlice const depositBalance = get().findUserDeposit(asset.denom) const borrowBalance = get().findUserDebt(asset.denom) const marketInfo = get().marketInfo.find((info) => info.denom === asset.denom) - const depositCap = Number(marketInfo?.deposit_cap) || 0 + const depositCap = params.find((param) => param.denom === asset.denom)?.cap const depositLiquidity = Number(get().marketDeposits.find((coin) => coin.denom === asset.denom)?.amount) || 0 const debtLiquidity = @@ -126,7 +127,9 @@ const redBankSlice = (set: NamedSet, get: GetState): RedBankSlice marketLiquidity: marketLiquidity, incentiveInfo, isCollateral: true, - depositCap: depositCap, + depositCap: depositCap + ? depositCap + : { amount: marketInfo?.deposit_cap || '0', used: String(depositLiquidity) }, borrowEnabled: !!marketInfo?.borrow_enabled, depositEnabled: !!marketInfo?.deposit_enabled, } diff --git a/src/styles/_assets.module.scss b/src/styles/_assets.module.scss index 748aa97..5da60e2 100644 --- a/src/styles/_assets.module.scss +++ b/src/styles/_assets.module.scss @@ -6,6 +6,8 @@ osmo: $colorTokenOSMO; atom: $colorTokenATOM; axl: $colorTokenAXL; + akt: $colorTokenAKT; + dydx: $colorTokenDYDX; usdc: $colorTokenUSDC; usdc: $colorTokenUSDT; astro: $colorTokenASTRO; diff --git a/src/styles/_master.scss b/src/styles/_master.scss index 775fc42..40c2085 100644 --- a/src/styles/_master.scss +++ b/src/styles/_master.scss @@ -32,7 +32,9 @@ $colorInfoVoteAgainst: #eb9e49; $colorTokenMARS: #a03b45; $colorTokenOSMO: #9f1ab9; $colorTokenATOM: #6f7390; +$colorTokenAKT: #f34c2d; $colorTokenAXL: #ffffff; +$colorTokenDYDX: #6966ff; $colorTokenUSDC: #478edc; $colorTokenUSDT: #50af95; $colorTokenINJ: #00f2fe; @@ -48,6 +50,8 @@ $colorGradientOSMO: linear-gradient(to bottom, #3a02e2, #e700ca); $colorGradientATOM: linear-gradient(to bottom, #2e3148, #6f7390); $colorGradientINJ: linear-gradient(to bottom, #0082fa, #00f2fe); $colorGradientAXL: linear-gradient(to bottom, #ffffff, #999999); +$colorGradientAKT: linear-gradient(to bottom, #be312d, #f34c2d); +$colorGradientDYDX: linear-gradient(to bottom, #1a1a27, #6966ff); $colorGradientUSDC: linear-gradient(to bottom, #1f5c9e, #478edc); $colorGradientAxlWBTC: linear-gradient(to bottom, #f09242, #f9d3b3); $colorGradientAxlWETH: linear-gradient(to bottom, #343434, #8c8c8c); diff --git a/src/types/generated/mars-params/MarsParams.types.ts b/src/types/generated/mars-params/MarsParams.types.ts index 04005ce..8e9b811 100644 --- a/src/types/generated/mars-params/MarsParams.types.ts +++ b/src/types/generated/mars-params/MarsParams.types.ts @@ -182,6 +182,10 @@ export interface AssetParamsBaseForAddr { max_loan_to_value: Decimal protocol_liquidation_fee: Decimal red_bank: RedBankSettings + cap: { + amount: string + used: string + } } export interface CmSettingsForAddr { hls?: HlsParamsBaseForAddr | null diff --git a/src/types/interfaces/asset.d.ts b/src/types/interfaces/asset.d.ts index 1832a91..40e7a53 100644 --- a/src/types/interfaces/asset.d.ts +++ b/src/types/interfaces/asset.d.ts @@ -5,9 +5,11 @@ interface Asset { symbol: | 'OSMO' | 'NTRN' + | 'AKT' | 'ATOM' | 'ASTRO' | 'AXL' + | 'DYDX' | 'INJ' | 'USDC.axl' | 'USDC' @@ -20,7 +22,9 @@ interface Asset { id: | 'OSMO' | 'NTRN' + | 'AKT' | 'axlUSDC' + | 'DYDX' | 'USDC' | 'USDT' | 'axlWBTC' @@ -64,7 +68,7 @@ interface RedBankAsset extends Asset { marketLiquidity: string isCollateral: boolean incentiveInfo?: IncentiveInfo[] - depositCap: number + depositCap: { amount: string; used: string } depositLiquidity: numnber borrowEnabled: boolean depositEnabled: boolean diff --git a/src/types/interfaces/redbank.d.ts b/src/types/interfaces/redbank.d.ts index 19d8c66..1ffca19 100644 --- a/src/types/interfaces/redbank.d.ts +++ b/src/types/interfaces/redbank.d.ts @@ -5,10 +5,14 @@ interface RedBankData { rbwasmkey: { OSMOMarket: Market OSMOMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] + AKTMarket: Market + AKTMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] ATOMMarket: Market ATOMMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] AXLMarket: Market AXLMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] + DYDXMarket: Market + DYDXMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] INJMarket: Market INJMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] ASTROMarket: Market