mirror of
https://github.com/cerc-io/mars-interface.git
synced 2024-11-17 03:09:20 +00:00
commit
51b70d4928
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "mars",
|
||||
"homepage": "./",
|
||||
"version": "1.7.3",
|
||||
"version": "1.7.4",
|
||||
"private": false,
|
||||
"license": "SEE LICENSE IN LICENSE FILE",
|
||||
"scripts": {
|
||||
|
@ -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
|
||||
|
@ -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 = () => {
|
||||
<>
|
||||
<p className='number'>
|
||||
{formatValue(
|
||||
row.original.depositCap / 10 ** row.original.decimals,
|
||||
demagnify(depositCap.toNumber(), row.original.decimals),
|
||||
2,
|
||||
2,
|
||||
true,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -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: '',
|
||||
|
@ -79,6 +79,7 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): 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<Store>, get: GetState<Store>): 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<Store>, get: GetState<Store>): 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,
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
osmo: $colorTokenOSMO;
|
||||
atom: $colorTokenATOM;
|
||||
axl: $colorTokenAXL;
|
||||
akt: $colorTokenAKT;
|
||||
dydx: $colorTokenDYDX;
|
||||
usdc: $colorTokenUSDC;
|
||||
usdc: $colorTokenUSDT;
|
||||
astro: $colorTokenASTRO;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
6
src/types/interfaces/asset.d.ts
vendored
6
src/types/interfaces/asset.d.ts
vendored
@ -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
|
||||
|
4
src/types/interfaces/redbank.d.ts
vendored
4
src/types/interfaces/redbank.d.ts
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user