Skip to content

Commit

Permalink
v1.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
linkielink committed Dec 4, 2023
1 parent 2a24ac5 commit 07d5ce1
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mars",
"homepage": "./",
"version": "1.7.3",
"version": "1.7.4",
"private": false,
"license": "SEE LICENSE IN LICENSE FILE",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/TxModal/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/components/redbank/DepositColumns/useDepositColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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',
Expand All @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/components/redbank/RedbankColumns.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
background-image: $colorGradientOSMO;
}

&.akt {
background-image: $colorGradientAKT;
}

&.atom {
background-image: $colorGradientATOM;
}
Expand All @@ -19,6 +23,10 @@
background-image: $colorGradientAXL;
}

&.dydx {
background-image: $colorGradientDYDX;
}

&.inj {
background-image: $colorGradientINJ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions src/configs/devnet.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 } = {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions src/configs/osmosis-1.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 } = {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion src/hooks/queries/useAssetParams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/queries/useDepositAndDebt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/mocks/redBankAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand All @@ -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: '',
Expand Down
7 changes: 5 additions & 2 deletions src/store/slices/redBank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down Expand Up @@ -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,
}
Expand Down
2 changes: 2 additions & 0 deletions src/styles/_assets.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
osmo: $colorTokenOSMO;
atom: $colorTokenATOM;
axl: $colorTokenAXL;
akt: $colorTokenAKT;
dydx: $colorTokenDYDX;
usdc: $colorTokenUSDC;
usdc: $colorTokenUSDT;
astro: $colorTokenASTRO;
Expand Down
4 changes: 4 additions & 0 deletions src/styles/_master.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ $colorInfoVoteAgainst: #eb9e49;
$colorTokenMARS: #a03b45;
$colorTokenOSMO: #9f1ab9;
$colorTokenATOM: #6f7390;
$colorTokenAKT: #f34c2d;
$colorTokenAXL: #ffffff;
$colorTokenDYDX: #6966ff;
$colorTokenUSDC: #478edc;
$colorTokenUSDT: #50af95;
$colorTokenINJ: #00f2fe;
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/types/generated/mars-params/MarsParams.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/types/interfaces/asset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ interface Asset {
symbol:
| 'OSMO'
| 'NTRN'
| 'AKT'
| 'ATOM'
| 'ASTRO'
| 'AXL'
| 'DYDX'
| 'INJ'
| 'USDC.axl'
| 'USDC'
Expand All @@ -20,7 +22,9 @@ interface Asset {
id:
| 'OSMO'
| 'NTRN'
| 'AKT'
| 'axlUSDC'
| 'DYDX'
| 'USDC'
| 'USDT'
| 'axlWBTC'
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/types/interfaces/redbank.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 07d5ce1

Please sign in to comment.