Skip to content

Commit 51b70d4

Browse files
authored
Merge pull request #52 from mars-protocol/v1.7.4
v1.7.4
2 parents 2a24ac5 + 07d5ce1 commit 51b70d4

File tree

16 files changed

+112
-13
lines changed

16 files changed

+112
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mars",
33
"homepage": "./",
4-
"version": "1.7.3",
4+
"version": "1.7.4",
55
"private": false,
66
"license": "SEE LICENSE IN LICENSE FILE",
77
"scripts": {

src/components/common/TxModal/Action.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ export const Action = ({
310310

311311
if (!currentAsset) return <></>
312312

313-
const amountUntilDepositCap = currentAsset.depositCap - Number(currentAsset.depositLiquidity)
313+
const amountUntilDepositCap =
314+
Number(currentAsset.depositCap.amount) - Number(currentAsset.depositCap.used)
314315

315316
const onValueEntered = (microValue: number) => {
316317
if (microValue >= maxUsableAmount) microValue = maxUsableAmount

src/components/redbank/DepositColumns/useDepositColumns.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js'
33
import classNames from 'classnames'
44
import { AnimatedNumber, Apr, Button, CellAmount, SVG, TextTooltip } from 'components/common'
55
import { convertPercentage } from 'functions'
6-
import { formatValue } from 'libs/parse'
6+
import { demagnify, formatValue } from 'libs/parse'
77
import Image from 'next/image'
88
import { useMemo } from 'react'
99
import { isMobile, isTablet } from 'react-device-detect'
@@ -127,8 +127,12 @@ export const useDepositColumns = () => {
127127
/>
128128
),
129129
cell: ({ row }) => {
130-
const depositLiquidity = Number(row.original.depositLiquidity)
131-
const percent = convertPercentage((depositLiquidity / row.original.depositCap) * 100)
130+
const depositCap = new BigNumber(row.original.depositCap?.amount ?? 0)
131+
const depositCapUsed = new BigNumber(row.original.depositCap?.used ?? 0)
132+
const percent = depositCap.isZero()
133+
? 0
134+
: convertPercentage(depositCapUsed.dividedBy(depositCap).toNumber() * 100)
135+
132136
const percentClasses = classNames(
133137
's',
134138
'number',
@@ -139,7 +143,7 @@ export const useDepositColumns = () => {
139143
<>
140144
<p className='number'>
141145
{formatValue(
142-
row.original.depositCap / 10 ** row.original.decimals,
146+
demagnify(depositCap.toNumber(), row.original.decimals),
143147
2,
144148
2,
145149
true,

src/components/redbank/RedbankColumns.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
background-image: $colorGradientOSMO;
1212
}
1313

14+
&.akt {
15+
background-image: $colorGradientAKT;
16+
}
17+
1418
&.atom {
1519
background-image: $colorGradientATOM;
1620
}
@@ -19,6 +23,10 @@
1923
background-image: $colorGradientAXL;
2024
}
2125

26+
&.dydx {
27+
background-image: $colorGradientDYDX;
28+
}
29+
2230
&.inj {
2331
background-image: $colorGradientINJ;
2432
}

src/components/redbank/RedbankNotConnected/RedbankNotConnected.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const RedbankNotConnected = () => {
4040
isCollateral: true,
4141
borrowBalanceBaseCurrency: 0,
4242
depositBalanceBaseCurrency: 0,
43-
depositCap: 0,
43+
depositCap: { amount: '0', used: '0' },
4444
depositLiquidity: 0,
4545
borrowEnabled: true,
4646
depositEnabled: true,

src/configs/devnet.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import akt from 'images/akt.svg'
12
import atom from 'images/atom.svg'
23
import axl from 'images/axl.svg'
34
import axlusdc from 'images/axlusdc.svg'
45
import axlwbtc from 'images/axlwbtc.svg'
56
import axlweth from 'images/axlweth.svg'
7+
import dydx from 'images/dydx.svg'
68
import inj from 'images/inj.svg'
79
import mars from 'images/mars.svg'
810
import osmo from 'images/osmo.svg'
@@ -133,6 +135,26 @@ const ASSETS: NetworkAssets = {
133135
logo: stosmo,
134136
decimals: 6,
135137
},
138+
akt: {
139+
symbol: 'AKT',
140+
id: 'AKT',
141+
name: 'Akash',
142+
denom: 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4',
143+
logo: akt,
144+
color: colors.akt,
145+
decimals: 6,
146+
priceFeedId: '4ea5bb4d2f5900cc2e97ba534240950740b4d3b89fe712a94a7304fd2fd92702',
147+
},
148+
dydx: {
149+
symbol: 'DYDX',
150+
id: 'DYDX',
151+
name: 'DyDx',
152+
denom: 'ibc/831F0B1BBB1D08A2B75311892876D71565478C532967545476DF4C2D7492E48C',
153+
logo: dydx,
154+
color: colors.dydx,
155+
decimals: 18,
156+
priceFeedId: '6489800bb8974169adfe35937bf6736507097d13c190d760c557108c7e93a81b',
157+
},
136158
}
137159

138160
const OTHER_ASSETS: { [denom: string]: OtherAsset } = {
@@ -179,10 +201,12 @@ export const NETWORK_CONFIG: NetworkConfig = {
179201
whitelist: [
180202
ASSETS.osmo,
181203
ASSETS.atom,
204+
ASSETS.akt,
182205
ASSETS.axl,
183206
ASSETS.axlusdc,
184207
ASSETS.axlwbtc,
185208
ASSETS.axlweth,
209+
ASSETS.dydx,
186210
ASSETS.inj,
187211
ASSETS.statom,
188212
ASSETS.usdc,
@@ -198,9 +222,11 @@ export const NETWORK_CONFIG: NetworkConfig = {
198222
ASSETS.axlusdc,
199223
ASSETS.osmo,
200224
ASSETS.atom,
225+
ASSETS.akt,
201226
ASSETS.axl,
202227
ASSETS.axlweth,
203228
ASSETS.axlwbtc,
229+
ASSETS.dydx,
204230
ASSETS.statom,
205231
ASSETS.stosmo,
206232
ASSETS.tia,

src/configs/osmosis-1.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import akt from 'images/akt.svg'
12
import atom from 'images/atom.svg'
23
import axl from 'images/axl.svg'
34
import axlusdc from 'images/axlusdc.svg'
45
import axlwbtc from 'images/axlwbtc.svg'
56
import axlweth from 'images/axlweth.svg'
7+
import dydx from 'images/dydx.svg'
68
import inj from 'images/inj.svg'
79
import mars from 'images/mars.svg'
810
import osmo from 'images/osmo.svg'
@@ -133,6 +135,26 @@ const ASSETS: NetworkAssets = {
133135
logo: stosmo,
134136
decimals: 6,
135137
},
138+
akt: {
139+
symbol: 'AKT',
140+
id: 'AKT',
141+
name: 'Akash',
142+
denom: 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4',
143+
logo: akt,
144+
color: colors.akt,
145+
decimals: 6,
146+
priceFeedId: '4ea5bb4d2f5900cc2e97ba534240950740b4d3b89fe712a94a7304fd2fd92702',
147+
},
148+
dydx: {
149+
symbol: 'DYDX',
150+
id: 'DYDX',
151+
name: 'DyDx',
152+
denom: 'ibc/831F0B1BBB1D08A2B75311892876D71565478C532967545476DF4C2D7492E48C',
153+
logo: dydx,
154+
color: colors.dydx,
155+
decimals: 18,
156+
priceFeedId: '6489800bb8974169adfe35937bf6736507097d13c190d760c557108c7e93a81b',
157+
},
136158
}
137159

138160
const OTHER_ASSETS: { [denom: string]: OtherAsset } = {
@@ -181,10 +203,12 @@ export const NETWORK_CONFIG: NetworkConfig = {
181203
whitelist: [
182204
ASSETS.osmo,
183205
ASSETS.atom,
206+
ASSETS.akt,
184207
ASSETS.axl,
185208
ASSETS.axlusdc,
186209
ASSETS.axlwbtc,
187210
ASSETS.axlweth,
211+
ASSETS.dydx,
188212
ASSETS.inj,
189213
ASSETS.statom,
190214
ASSETS.usdc,
@@ -200,9 +224,11 @@ export const NETWORK_CONFIG: NetworkConfig = {
200224
ASSETS.axlusdc,
201225
ASSETS.osmo,
202226
ASSETS.atom,
227+
ASSETS.akt,
203228
ASSETS.axl,
204229
ASSETS.axlweth,
205230
ASSETS.axlwbtc,
231+
ASSETS.dydx,
206232
ASSETS.statom,
207233
ASSETS.stosmo,
208234
ASSETS.tia,

src/hooks/queries/useAssetParams.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@ import { QUERY_KEYS } from 'types/enums/queryKeys'
66
export const useAssetParams = () => {
77
const paramsContract = useStore((s) => s.networkConfig.contracts.params)
88
const paramsClient = useStore((s) => s.paramsClient)
9-
9+
const whitelistedAssets = useStore((s) => s.networkConfig.assets.whitelist)
1010
return useQuery(
1111
[QUERY_KEYS.ASSET_PARAMS],
1212
async () => {
1313
if (!paramsClient) return []
1414

1515
const params = await iterateContractQuery(paramsClient.allAssetParams)
16+
const capQueries = whitelistedAssets.map(
17+
async (assetParams) => await paramsClient.totalDeposit({ denom: assetParams.denom }),
18+
)
19+
const assetCaps = await Promise.all(capQueries)
20+
assetCaps.forEach((assetCap) => {
21+
const assetParams = params.find((param) => param.denom === assetCap.denom)
22+
if (!assetParams) return
23+
assetParams.cap = { amount: assetCap.cap, used: assetCap.amount }
24+
})
1625
useStore.setState({ assetParams: params })
1726
return params
1827
},

src/hooks/queries/useDepositAndDebt.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ export interface DepositAndDebtData {
99
mdwasmkey: {
1010
OSMODeposits: string
1111
OSMODebt: string
12+
AKTDeposits: string
13+
AKTDebt: string
1214
ATOMDeposits: string
1315
ATOMDebt: string
1416
ASTRODeposits: string
1517
ASTRODebt: string
1618
AXLDeposits: string
1719
AXLDebt: string
20+
DYDXDeposits: string
21+
DYDXDebt: string
1822
INJDeposits: string
1923
INJDebt: string
2024
axlUSDCDeposits: string

src/mocks/redBankAssets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const redBankAssets: RedBankAsset[] = [
99
denom: 'ATOM',
1010
depositBalance: '0',
1111
depositBalanceBaseCurrency: 0,
12-
depositCap: 1_000_000,
12+
depositCap: { amount: '1000000', used: '5000' },
1313
depositLiquidity: 5_000,
1414
isCollateral: true,
1515
logo: '',
@@ -31,7 +31,7 @@ export const redBankAssets: RedBankAsset[] = [
3131
denom: 'OSMO',
3232
depositBalance: '0',
3333
depositBalanceBaseCurrency: 0,
34-
depositCap: 1_000_000,
34+
depositCap: { amount: '1000000', used: '5000' },
3535
depositLiquidity: 5_000,
3636
isCollateral: true,
3737
logo: '',

src/store/slices/redBank.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): RedBankSlice
7979
// ------------------
8080
setRedBankAssets: () => {
8181
if (get().exchangeRatesState !== State.READY || get().userBalancesState !== State.READY) return
82+
const params = get().assetParams
8283
const redBankAssets: RedBankAsset[] = []
8384
const marketAssetLiquidity: Coin[] = []
8485
const whitelistedAssets = get().networkConfig.assets.whitelist
@@ -94,7 +95,7 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): RedBankSlice
9495
const depositBalance = get().findUserDeposit(asset.denom)
9596
const borrowBalance = get().findUserDebt(asset.denom)
9697
const marketInfo = get().marketInfo.find((info) => info.denom === asset.denom)
97-
const depositCap = Number(marketInfo?.deposit_cap) || 0
98+
const depositCap = params.find((param) => param.denom === asset.denom)?.cap
9899
const depositLiquidity =
99100
Number(get().marketDeposits.find((coin) => coin.denom === asset.denom)?.amount) || 0
100101
const debtLiquidity =
@@ -126,7 +127,9 @@ const redBankSlice = (set: NamedSet<Store>, get: GetState<Store>): RedBankSlice
126127
marketLiquidity: marketLiquidity,
127128
incentiveInfo,
128129
isCollateral: true,
129-
depositCap: depositCap,
130+
depositCap: depositCap
131+
? depositCap
132+
: { amount: marketInfo?.deposit_cap || '0', used: String(depositLiquidity) },
130133
borrowEnabled: !!marketInfo?.borrow_enabled,
131134
depositEnabled: !!marketInfo?.deposit_enabled,
132135
}

src/styles/_assets.module.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
osmo: $colorTokenOSMO;
77
atom: $colorTokenATOM;
88
axl: $colorTokenAXL;
9+
akt: $colorTokenAKT;
10+
dydx: $colorTokenDYDX;
911
usdc: $colorTokenUSDC;
1012
usdc: $colorTokenUSDT;
1113
astro: $colorTokenASTRO;

src/styles/_master.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ $colorInfoVoteAgainst: #eb9e49;
3232
$colorTokenMARS: #a03b45;
3333
$colorTokenOSMO: #9f1ab9;
3434
$colorTokenATOM: #6f7390;
35+
$colorTokenAKT: #f34c2d;
3536
$colorTokenAXL: #ffffff;
37+
$colorTokenDYDX: #6966ff;
3638
$colorTokenUSDC: #478edc;
3739
$colorTokenUSDT: #50af95;
3840
$colorTokenINJ: #00f2fe;
@@ -48,6 +50,8 @@ $colorGradientOSMO: linear-gradient(to bottom, #3a02e2, #e700ca);
4850
$colorGradientATOM: linear-gradient(to bottom, #2e3148, #6f7390);
4951
$colorGradientINJ: linear-gradient(to bottom, #0082fa, #00f2fe);
5052
$colorGradientAXL: linear-gradient(to bottom, #ffffff, #999999);
53+
$colorGradientAKT: linear-gradient(to bottom, #be312d, #f34c2d);
54+
$colorGradientDYDX: linear-gradient(to bottom, #1a1a27, #6966ff);
5155
$colorGradientUSDC: linear-gradient(to bottom, #1f5c9e, #478edc);
5256
$colorGradientAxlWBTC: linear-gradient(to bottom, #f09242, #f9d3b3);
5357
$colorGradientAxlWETH: linear-gradient(to bottom, #343434, #8c8c8c);

src/types/generated/mars-params/MarsParams.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ export interface AssetParamsBaseForAddr {
182182
max_loan_to_value: Decimal
183183
protocol_liquidation_fee: Decimal
184184
red_bank: RedBankSettings
185+
cap: {
186+
amount: string
187+
used: string
188+
}
185189
}
186190
export interface CmSettingsForAddr {
187191
hls?: HlsParamsBaseForAddr | null

src/types/interfaces/asset.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ interface Asset {
55
symbol:
66
| 'OSMO'
77
| 'NTRN'
8+
| 'AKT'
89
| 'ATOM'
910
| 'ASTRO'
1011
| 'AXL'
12+
| 'DYDX'
1113
| 'INJ'
1214
| 'USDC.axl'
1315
| 'USDC'
@@ -20,7 +22,9 @@ interface Asset {
2022
id:
2123
| 'OSMO'
2224
| 'NTRN'
25+
| 'AKT'
2326
| 'axlUSDC'
27+
| 'DYDX'
2428
| 'USDC'
2529
| 'USDT'
2630
| 'axlWBTC'
@@ -64,7 +68,7 @@ interface RedBankAsset extends Asset {
6468
marketLiquidity: string
6569
isCollateral: boolean
6670
incentiveInfo?: IncentiveInfo[]
67-
depositCap: number
71+
depositCap: { amount: string; used: string }
6872
depositLiquidity: numnber
6973
borrowEnabled: boolean
7074
depositEnabled: boolean

src/types/interfaces/redbank.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ interface RedBankData {
55
rbwasmkey: {
66
OSMOMarket: Market
77
OSMOMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
8+
AKTMarket: Market
9+
AKTMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
810
ATOMMarket: Market
911
ATOMMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
1012
AXLMarket: Market
1113
AXLMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
14+
DYDXMarket: Market
15+
DYDXMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
1216
INJMarket: Market
1317
INJMarketIncentive: MarketIncentive | MultiAssetMarketIncentive[]
1418
ASTROMarket: Market

0 commit comments

Comments
 (0)