Skip to content

Commit e863986

Browse files
authored
feat: add group logic to E-mode tab (#4765)
* feat: add isBorrowable prop to Asset and EModeAssetSettings types * feat: show borrowable state of assets * feat: add logic to E-mode tab * chore: add changeset
1 parent 12cb19b commit e863986

File tree

30 files changed

+888
-236
lines changed

30 files changed

+888
-236
lines changed

.changeset/thin-groups-dig.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@venusprotocol/evm": minor
3+
---
4+
5+
add group logic to E-mode

apps/evm/src/__mocks__/models/asset.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const assetData: Asset[] = [
2323
badDebtMantissa: 6789000000000000000n,
2424
supplierCount: 100,
2525
borrowerCount: 10,
26+
isBorrowable: true,
27+
isBorrowableByUser: true,
2628
exchangeRateVTokens: new BigNumber(49.589181233),
2729
userWalletBalanceTokens: new BigNumber('100'),
2830
userWalletBalanceCents: new BigNumber('12786'),
@@ -92,6 +94,8 @@ export const assetData: Asset[] = [
9294
badDebtMantissa: 0n,
9395
supplierCount: 100,
9496
borrowerCount: 10,
97+
isBorrowable: false,
98+
isBorrowableByUser: false,
9599
exchangeRateVTokens: new BigNumber(1),
96100
userWalletBalanceTokens: new BigNumber('0'),
97101
userWalletBalanceCents: new BigNumber('0'),
@@ -179,6 +183,8 @@ export const assetData: Asset[] = [
179183
badDebtMantissa: 0n,
180184
supplierCount: 100,
181185
borrowerCount: 10,
186+
isBorrowable: true,
187+
isBorrowableByUser: true,
182188
exchangeRateVTokens: new BigNumber(0.981982),
183189
userWalletBalanceTokens: new BigNumber('900'),
184190
userWalletBalanceCents: new BigNumber('90000'),
@@ -262,6 +268,8 @@ export const assetData: Asset[] = [
262268
badDebtMantissa: 0n,
263269
supplierCount: 100,
264270
borrowerCount: 10,
271+
isBorrowable: true,
272+
isBorrowableByUser: true,
265273
exchangeRateVTokens: new BigNumber(1.000003),
266274
userWalletBalanceTokens: new BigNumber('110'),
267275
userWalletBalanceCents: new BigNumber('11000'),

apps/evm/src/__mocks__/models/eModeGroup.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,34 @@ const generateEModeGroup = ({
55
groupAssets,
66
id,
77
name,
8-
description,
9-
}: { groupAssets: Asset[]; id: number; name: string; description: string }) => ({
8+
}: { groupAssets: Asset[]; id: number; name: string }): EModeGroup => ({
109
id,
1110
name,
12-
description,
1311
assetSettings: groupAssets.map(a => ({
1412
vToken: a.vToken,
1513
collateralFactor: a.userCollateralFactor + 0.1,
1614
liquidationThresholdPercentage: a.userLiquidationThresholdPercentage + 12,
1715
liquidationPenaltyPercentage: a.userLiquidationThresholdPercentage - 50,
1816
liquidityCents: a.liquidityCents.toNumber(),
1917
liquidityTokens: a.cashTokens,
18+
isBorrowable: a.isBorrowable,
2019
})),
2120
});
2221

2322
export const eModeGroups: EModeGroup[] = [
2423
generateEModeGroup({
2524
id: 0,
2625
name: 'Stablecoins',
27-
description: 'This block contains the assets of this category',
2826
groupAssets: assetData.slice(0, 3),
2927
}),
3028
generateEModeGroup({
3129
id: 1,
3230
name: 'DeFi',
33-
description: 'This block contains the assets of this category',
3431
groupAssets: assetData.slice(2, 4),
3532
}),
3633
generateEModeGroup({
3734
id: 2,
3835
name: '#ToTheMoon',
39-
description: 'This block contains the assets of this category',
4036
groupAssets: assetData.slice(5, 8),
4137
}),
4238
];

apps/evm/src/clients/api/queries/useGetAsset/__snapshots__/index.spec.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ exports[`useGetAsset > returns the correct asset 1`] = `
3636
"collateralFactor": 0.5,
3737
"disabledTokenActions": [],
3838
"exchangeRateVTokens": "49.589181233",
39+
"isBorrowable": true,
40+
"isBorrowableByUser": true,
3941
"isCollateralOfUser": true,
4042
"liquidationThresholdPercentage": 50,
4143
"liquidityCents": "8036465875",

apps/evm/src/clients/api/queries/useGetPool/__snapshots__/index.spec.tsx.snap

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ exports[`useGetPool > returns the correct asset 1`] = `
3838
"collateralFactor": 0.5,
3939
"disabledTokenActions": [],
4040
"exchangeRateVTokens": "49.589181233",
41+
"isBorrowable": true,
42+
"isBorrowableByUser": true,
4143
"isCollateralOfUser": true,
4244
"liquidationThresholdPercentage": 50,
4345
"liquidityCents": "8036465875",
@@ -149,6 +151,8 @@ exports[`useGetPool > returns the correct asset 1`] = `
149151
"supply",
150152
],
151153
"exchangeRateVTokens": "1",
154+
"isBorrowable": false,
155+
"isBorrowableByUser": false,
152156
"isCollateralOfUser": false,
153157
"liquidationThresholdPercentage": 80,
154158
"liquidityCents": "1702951959",
@@ -275,6 +279,8 @@ exports[`useGetPool > returns the correct asset 1`] = `
275279
"swapAndSupply",
276280
],
277281
"exchangeRateVTokens": "0.981982",
282+
"isBorrowable": true,
283+
"isBorrowableByUser": true,
278284
"isCollateralOfUser": false,
279285
"liquidationThresholdPercentage": 80,
280286
"liquidityCents": "5534102886",
@@ -393,6 +399,8 @@ exports[`useGetPool > returns the correct asset 1`] = `
393399
"supply",
394400
],
395401
"exchangeRateVTokens": "1.000003",
402+
"isBorrowable": true,
403+
"isBorrowableByUser": true,
396404
"isCollateralOfUser": false,
397405
"liquidationThresholdPercentage": 80,
398406
"liquidityCents": "3654492935",
@@ -482,6 +490,7 @@ exports[`useGetPool > returns the correct asset 1`] = `
482490
"assetSettings": [
483491
{
484492
"collateralFactor": 0.6,
493+
"isBorrowable": true,
485494
"liquidationPenaltyPercentage": 0,
486495
"liquidationThresholdPercentage": 62,
487496
"liquidityCents": 8036465875,
@@ -500,6 +509,7 @@ exports[`useGetPool > returns the correct asset 1`] = `
500509
},
501510
{
502511
"collateralFactor": 0.9,
512+
"isBorrowable": false,
503513
"liquidationPenaltyPercentage": 30,
504514
"liquidationThresholdPercentage": 92,
505515
"liquidityCents": 1702951959,
@@ -518,6 +528,7 @@ exports[`useGetPool > returns the correct asset 1`] = `
518528
},
519529
{
520530
"collateralFactor": 0.9,
531+
"isBorrowable": true,
521532
"liquidationPenaltyPercentage": 30,
522533
"liquidationThresholdPercentage": 92,
523534
"liquidityCents": 5534102886,
@@ -535,14 +546,14 @@ exports[`useGetPool > returns the correct asset 1`] = `
535546
},
536547
},
537548
],
538-
"description": "This block contains the assets of this category",
539549
"id": 0,
540550
"name": "Stablecoins",
541551
},
542552
{
543553
"assetSettings": [
544554
{
545555
"collateralFactor": 0.9,
556+
"isBorrowable": true,
546557
"liquidationPenaltyPercentage": 30,
547558
"liquidationThresholdPercentage": 92,
548559
"liquidityCents": 5534102886,
@@ -561,6 +572,7 @@ exports[`useGetPool > returns the correct asset 1`] = `
561572
},
562573
{
563574
"collateralFactor": 0.9,
575+
"isBorrowable": true,
564576
"liquidationPenaltyPercentage": 30,
565577
"liquidationThresholdPercentage": 92,
566578
"liquidityCents": 3654492935,
@@ -578,13 +590,11 @@ exports[`useGetPool > returns the correct asset 1`] = `
578590
},
579591
},
580592
],
581-
"description": "This block contains the assets of this category",
582593
"id": 1,
583594
"name": "DeFi",
584595
},
585596
{
586597
"assetSettings": [],
587-
"description": "This block contains the assets of this category",
588598
"id": 2,
589599
"name": "#ToTheMoon",
590600
},

0 commit comments

Comments
 (0)