This commit is contained in:
Linkie Link 2023-12-04 14:58:37 +01:00
parent 2a24ac5594
commit 07d5ce1999
No known key found for this signature in database
GPG Key ID: 5318B0F2564D38EA
16 changed files with 112 additions and 13 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "mars", "name": "mars",
"homepage": "./", "homepage": "./",
"version": "1.7.3", "version": "1.7.4",
"private": false, "private": false,
"license": "SEE LICENSE IN LICENSE FILE", "license": "SEE LICENSE IN LICENSE FILE",
"scripts": { "scripts": {

View File

@ -310,7 +310,8 @@ export const Action = ({
if (!currentAsset) return <></> if (!currentAsset) return <></>
const amountUntilDepositCap = currentAsset.depositCap - Number(currentAsset.depositLiquidity) const amountUntilDepositCap =
Number(currentAsset.depositCap.amount) - Number(currentAsset.depositCap.used)
const onValueEntered = (microValue: number) => { const onValueEntered = (microValue: number) => {
if (microValue >= maxUsableAmount) microValue = maxUsableAmount if (microValue >= maxUsableAmount) microValue = maxUsableAmount

View File

@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js'
import classNames from 'classnames' import classNames from 'classnames'
import { AnimatedNumber, Apr, Button, CellAmount, SVG, TextTooltip } from 'components/common' import { AnimatedNumber, Apr, Button, CellAmount, SVG, TextTooltip } from 'components/common'
import { convertPercentage } from 'functions' import { convertPercentage } from 'functions'
import { formatValue } from 'libs/parse' import { demagnify, formatValue } from 'libs/parse'
import Image from 'next/image' import Image from 'next/image'
import { useMemo } from 'react' import { useMemo } from 'react'
import { isMobile, isTablet } from 'react-device-detect' import { isMobile, isTablet } from 'react-device-detect'
@ -127,8 +127,12 @@ export const useDepositColumns = () => {
/> />
), ),
cell: ({ row }) => { cell: ({ row }) => {
const depositLiquidity = Number(row.original.depositLiquidity) const depositCap = new BigNumber(row.original.depositCap?.amount ?? 0)
const percent = convertPercentage((depositLiquidity / row.original.depositCap) * 100) const depositCapUsed = new BigNumber(row.original.depositCap?.used ?? 0)
const percent = depositCap.isZero()
? 0
: convertPercentage(depositCapUsed.dividedBy(depositCap).toNumber() * 100)
const percentClasses = classNames( const percentClasses = classNames(
's', 's',
'number', 'number',
@ -139,7 +143,7 @@ export const useDepositColumns = () => {
<> <>
<p className='number'> <p className='number'>
{formatValue( {formatValue(
row.original.depositCap / 10 ** row.original.decimals, demagnify(depositCap.toNumber(), row.original.decimals),
2, 2,
2, 2,
true, true,

View File

@ -11,6 +11,10 @@
background-image: $colorGradientOSMO; background-image: $colorGradientOSMO;
} }
&.akt {
background-image: $colorGradientAKT;
}
&.atom { &.atom {
background-image: $colorGradientATOM; background-image: $colorGradientATOM;
} }
@ -19,6 +23,10 @@
background-image: $colorGradientAXL; background-image: $colorGradientAXL;
} }
&.dydx {
background-image: $colorGradientDYDX;
}
&.inj { &.inj {
background-image: $colorGradientINJ; background-image: $colorGradientINJ;
} }

View File

@ -40,7 +40,7 @@ export const RedbankNotConnected = () => {
isCollateral: true, isCollateral: true,
borrowBalanceBaseCurrency: 0, borrowBalanceBaseCurrency: 0,
depositBalanceBaseCurrency: 0, depositBalanceBaseCurrency: 0,
depositCap: 0, depositCap: { amount: '0', used: '0' },
depositLiquidity: 0, depositLiquidity: 0,
borrowEnabled: true, borrowEnabled: true,
depositEnabled: true, depositEnabled: true,

View File

@ -1,8 +1,10 @@
import akt from 'images/akt.svg'
import atom from 'images/atom.svg' import atom from 'images/atom.svg'
import axl from 'images/axl.svg' import axl from 'images/axl.svg'
import axlusdc from 'images/axlusdc.svg' import axlusdc from 'images/axlusdc.svg'
import axlwbtc from 'images/axlwbtc.svg' import axlwbtc from 'images/axlwbtc.svg'
import axlweth from 'images/axlweth.svg' import axlweth from 'images/axlweth.svg'
import dydx from 'images/dydx.svg'
import inj from 'images/inj.svg' import inj from 'images/inj.svg'
import mars from 'images/mars.svg' import mars from 'images/mars.svg'
import osmo from 'images/osmo.svg' import osmo from 'images/osmo.svg'
@ -133,6 +135,26 @@ const ASSETS: NetworkAssets = {
logo: stosmo, logo: stosmo,
decimals: 6, 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 } = { const OTHER_ASSETS: { [denom: string]: OtherAsset } = {
@ -179,10 +201,12 @@ export const NETWORK_CONFIG: NetworkConfig = {
whitelist: [ whitelist: [
ASSETS.osmo, ASSETS.osmo,
ASSETS.atom, ASSETS.atom,
ASSETS.akt,
ASSETS.axl, ASSETS.axl,
ASSETS.axlusdc, ASSETS.axlusdc,
ASSETS.axlwbtc, ASSETS.axlwbtc,
ASSETS.axlweth, ASSETS.axlweth,
ASSETS.dydx,
ASSETS.inj, ASSETS.inj,
ASSETS.statom, ASSETS.statom,
ASSETS.usdc, ASSETS.usdc,
@ -198,9 +222,11 @@ export const NETWORK_CONFIG: NetworkConfig = {
ASSETS.axlusdc, ASSETS.axlusdc,
ASSETS.osmo, ASSETS.osmo,
ASSETS.atom, ASSETS.atom,
ASSETS.akt,
ASSETS.axl, ASSETS.axl,
ASSETS.axlweth, ASSETS.axlweth,
ASSETS.axlwbtc, ASSETS.axlwbtc,
ASSETS.dydx,
ASSETS.statom, ASSETS.statom,
ASSETS.stosmo, ASSETS.stosmo,
ASSETS.tia, ASSETS.tia,

View File

@ -1,8 +1,10 @@
import akt from 'images/akt.svg'
import atom from 'images/atom.svg' import atom from 'images/atom.svg'
import axl from 'images/axl.svg' import axl from 'images/axl.svg'
import axlusdc from 'images/axlusdc.svg' import axlusdc from 'images/axlusdc.svg'
import axlwbtc from 'images/axlwbtc.svg' import axlwbtc from 'images/axlwbtc.svg'
import axlweth from 'images/axlweth.svg' import axlweth from 'images/axlweth.svg'
import dydx from 'images/dydx.svg'
import inj from 'images/inj.svg' import inj from 'images/inj.svg'
import mars from 'images/mars.svg' import mars from 'images/mars.svg'
import osmo from 'images/osmo.svg' import osmo from 'images/osmo.svg'
@ -133,6 +135,26 @@ const ASSETS: NetworkAssets = {
logo: stosmo, logo: stosmo,
decimals: 6, 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 } = { const OTHER_ASSETS: { [denom: string]: OtherAsset } = {
@ -181,10 +203,12 @@ export const NETWORK_CONFIG: NetworkConfig = {
whitelist: [ whitelist: [
ASSETS.osmo, ASSETS.osmo,
ASSETS.atom, ASSETS.atom,
ASSETS.akt,
ASSETS.axl, ASSETS.axl,
ASSETS.axlusdc, ASSETS.axlusdc,
ASSETS.axlwbtc, ASSETS.axlwbtc,
ASSETS.axlweth, ASSETS.axlweth,
ASSETS.dydx,
ASSETS.inj, ASSETS.inj,
ASSETS.statom, ASSETS.statom,
ASSETS.usdc, ASSETS.usdc,
@ -200,9 +224,11 @@ export const NETWORK_CONFIG: NetworkConfig = {
ASSETS.axlusdc, ASSETS.axlusdc,
ASSETS.osmo, ASSETS.osmo,
ASSETS.atom, ASSETS.atom,
ASSETS.akt,
ASSETS.axl, ASSETS.axl,
ASSETS.axlweth, ASSETS.axlweth,
ASSETS.axlwbtc, ASSETS.axlwbtc,
ASSETS.dydx,
ASSETS.statom, ASSETS.statom,
ASSETS.stosmo, ASSETS.stosmo,
ASSETS.tia, ASSETS.tia,

View File

@ -6,13 +6,22 @@ import { QUERY_KEYS } from 'types/enums/queryKeys'
export const useAssetParams = () => { export const useAssetParams = () => {
const paramsContract = useStore((s) => s.networkConfig.contracts.params) const paramsContract = useStore((s) => s.networkConfig.contracts.params)
const paramsClient = useStore((s) => s.paramsClient) const paramsClient = useStore((s) => s.paramsClient)
const whitelistedAssets = useStore((s) => s.networkConfig.assets.whitelist)
return useQuery( return useQuery(
[QUERY_KEYS.ASSET_PARAMS], [QUERY_KEYS.ASSET_PARAMS],
async () => { async () => {
if (!paramsClient) return [] if (!paramsClient) return []
const params = await iterateContractQuery(paramsClient.allAssetParams) 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 }) useStore.setState({ assetParams: params })
return params return params
}, },

View File

@ -9,12 +9,16 @@ export interface DepositAndDebtData {
mdwasmkey: { mdwasmkey: {
OSMODeposits: string OSMODeposits: string
OSMODebt: string OSMODebt: string
AKTDeposits: string
AKTDebt: string
ATOMDeposits: string ATOMDeposits: string
ATOMDebt: string ATOMDebt: string
ASTRODeposits: string ASTRODeposits: string
ASTRODebt: string ASTRODebt: string
AXLDeposits: string AXLDeposits: string
AXLDebt: string AXLDebt: string
DYDXDeposits: string
DYDXDebt: string
INJDeposits: string INJDeposits: string
INJDebt: string INJDebt: string
axlUSDCDeposits: string axlUSDCDeposits: string

View File

@ -9,7 +9,7 @@ export const redBankAssets: RedBankAsset[] = [
denom: 'ATOM', denom: 'ATOM',
depositBalance: '0', depositBalance: '0',
depositBalanceBaseCurrency: 0, depositBalanceBaseCurrency: 0,
depositCap: 1_000_000, depositCap: { amount: '1000000', used: '5000' },
depositLiquidity: 5_000, depositLiquidity: 5_000,
isCollateral: true, isCollateral: true,
logo: '', logo: '',
@ -31,7 +31,7 @@ export const redBankAssets: RedBankAsset[] = [
denom: 'OSMO', denom: 'OSMO',
depositBalance: '0', depositBalance: '0',
depositBalanceBaseCurrency: 0, depositBalanceBaseCurrency: 0,
depositCap: 1_000_000, depositCap: { amount: '1000000', used: '5000' },
depositLiquidity: 5_000, depositLiquidity: 5_000,
isCollateral: true, isCollateral: true,
logo: '', logo: '',

View File

@ -79,6 +79,7 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): RedBankSlice
// ------------------ // ------------------
setRedBankAssets: () => { setRedBankAssets: () => {
if (get().exchangeRatesState !== State.READY || get().userBalancesState !== State.READY) return if (get().exchangeRatesState !== State.READY || get().userBalancesState !== State.READY) return
const params = get().assetParams
const redBankAssets: RedBankAsset[] = [] const redBankAssets: RedBankAsset[] = []
const marketAssetLiquidity: Coin[] = [] const marketAssetLiquidity: Coin[] = []
const whitelistedAssets = get().networkConfig.assets.whitelist const whitelistedAssets = get().networkConfig.assets.whitelist
@ -94,7 +95,7 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): RedBankSlice
const depositBalance = get().findUserDeposit(asset.denom) const depositBalance = get().findUserDeposit(asset.denom)
const borrowBalance = get().findUserDebt(asset.denom) const borrowBalance = get().findUserDebt(asset.denom)
const marketInfo = get().marketInfo.find((info) => info.denom === 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 = const depositLiquidity =
Number(get().marketDeposits.find((coin) => coin.denom === asset.denom)?.amount) || 0 Number(get().marketDeposits.find((coin) => coin.denom === asset.denom)?.amount) || 0
const debtLiquidity = const debtLiquidity =
@ -126,7 +127,9 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): RedBankSlice
marketLiquidity: marketLiquidity, marketLiquidity: marketLiquidity,
incentiveInfo, incentiveInfo,
isCollateral: true, isCollateral: true,
depositCap: depositCap, depositCap: depositCap
? depositCap
: { amount: marketInfo?.deposit_cap || '0', used: String(depositLiquidity) },
borrowEnabled: !!marketInfo?.borrow_enabled, borrowEnabled: !!marketInfo?.borrow_enabled,
depositEnabled: !!marketInfo?.deposit_enabled, depositEnabled: !!marketInfo?.deposit_enabled,
} }

View File

@ -6,6 +6,8 @@
osmo: $colorTokenOSMO; osmo: $colorTokenOSMO;
atom: $colorTokenATOM; atom: $colorTokenATOM;
axl: $colorTokenAXL; axl: $colorTokenAXL;
akt: $colorTokenAKT;
dydx: $colorTokenDYDX;
usdc: $colorTokenUSDC; usdc: $colorTokenUSDC;
usdc: $colorTokenUSDT; usdc: $colorTokenUSDT;
astro: $colorTokenASTRO; astro: $colorTokenASTRO;

View File

@ -32,7 +32,9 @@ $colorInfoVoteAgainst: #eb9e49;
$colorTokenMARS: #a03b45; $colorTokenMARS: #a03b45;
$colorTokenOSMO: #9f1ab9; $colorTokenOSMO: #9f1ab9;
$colorTokenATOM: #6f7390; $colorTokenATOM: #6f7390;
$colorTokenAKT: #f34c2d;
$colorTokenAXL: #ffffff; $colorTokenAXL: #ffffff;
$colorTokenDYDX: #6966ff;
$colorTokenUSDC: #478edc; $colorTokenUSDC: #478edc;
$colorTokenUSDT: #50af95; $colorTokenUSDT: #50af95;
$colorTokenINJ: #00f2fe; $colorTokenINJ: #00f2fe;
@ -48,6 +50,8 @@ $colorGradientOSMO: linear-gradient(to bottom, #3a02e2, #e700ca);
$colorGradientATOM: linear-gradient(to bottom, #2e3148, #6f7390); $colorGradientATOM: linear-gradient(to bottom, #2e3148, #6f7390);
$colorGradientINJ: linear-gradient(to bottom, #0082fa, #00f2fe); $colorGradientINJ: linear-gradient(to bottom, #0082fa, #00f2fe);
$colorGradientAXL: linear-gradient(to bottom, #ffffff, #999999); $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); $colorGradientUSDC: linear-gradient(to bottom, #1f5c9e, #478edc);
$colorGradientAxlWBTC: linear-gradient(to bottom, #f09242, #f9d3b3); $colorGradientAxlWBTC: linear-gradient(to bottom, #f09242, #f9d3b3);
$colorGradientAxlWETH: linear-gradient(to bottom, #343434, #8c8c8c); $colorGradientAxlWETH: linear-gradient(to bottom, #343434, #8c8c8c);

View File

@ -182,6 +182,10 @@ export interface AssetParamsBaseForAddr {
max_loan_to_value: Decimal max_loan_to_value: Decimal
protocol_liquidation_fee: Decimal protocol_liquidation_fee: Decimal
red_bank: RedBankSettings red_bank: RedBankSettings
cap: {
amount: string
used: string
}
} }
export interface CmSettingsForAddr { export interface CmSettingsForAddr {
hls?: HlsParamsBaseForAddr | null hls?: HlsParamsBaseForAddr | null

View File

@ -5,9 +5,11 @@ interface Asset {
symbol: symbol:
| 'OSMO' | 'OSMO'
| 'NTRN' | 'NTRN'
| 'AKT'
| 'ATOM' | 'ATOM'
| 'ASTRO' | 'ASTRO'
| 'AXL' | 'AXL'
| 'DYDX'
| 'INJ' | 'INJ'
| 'USDC.axl' | 'USDC.axl'
| 'USDC' | 'USDC'
@ -20,7 +22,9 @@ interface Asset {
id: id:
| 'OSMO' | 'OSMO'
| 'NTRN' | 'NTRN'
| 'AKT'
| 'axlUSDC' | 'axlUSDC'
| 'DYDX'
| 'USDC' | 'USDC'
| 'USDT' | 'USDT'
| 'axlWBTC' | 'axlWBTC'
@ -64,7 +68,7 @@ interface RedBankAsset extends Asset {
marketLiquidity: string marketLiquidity: string
isCollateral: boolean isCollateral: boolean
incentiveInfo?: IncentiveInfo[] incentiveInfo?: IncentiveInfo[]
depositCap: number depositCap: { amount: string; used: string }
depositLiquidity: numnber depositLiquidity: numnber
borrowEnabled: boolean borrowEnabled: boolean
depositEnabled: boolean depositEnabled: boolean

View File

@ -5,10 +5,14 @@ interface RedBankData {
rbwasmkey: { rbwasmkey: {
OSMOMarket: Market OSMOMarket: Market
OSMOMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] OSMOMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
AKTMarket: Market
AKTMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
ATOMMarket: Market ATOMMarket: Market
ATOMMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] ATOMMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
AXLMarket: Market AXLMarket: Market
AXLMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] AXLMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
DYDXMarket: Market
DYDXMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
INJMarket: Market INJMarket: Market
INJMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[] INJMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
ASTROMarket: Market ASTROMarket: Market