Skip to content

Commit e1c5051

Browse files
authored
feat: preview, user position updates (#335)
* feat: preview reserve rates * chore: changeset * chore: bump cli
1 parent 8476f6e commit e1c5051

9 files changed

Lines changed: 152 additions & 10 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@aave/graphql": minor
3+
"@aave/client": minor
4+
"@aave/react": minor
5+
"@aave/cli": minor
6+
---
7+
8+
**feat:** add `reserveRates`, `maxBorrowingPower`, and `remainingBorrowingPower` to `PreviewUserPosition`; rename `borrowingPower` to `maxBorrowingPower` on `UserPosition`; add `suppliable` and `borrowable` to `ReserveSummary`

packages/client/src/cache.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ export const exchange = cacheExchange({
492492
PreviewBorrowPointsReward: () => null,
493493
PreviewMerklBorrowReward: () => null,
494494
PreviewMerklSupplyReward: () => null,
495+
PreviewReserveRates: () => null,
495496
PreviewRewardOutcome: () => null,
496497
PreviewSupplyPointsReward: () => null,
497498
PreviewUserPosition: () => null,

packages/graphql/schema.graphql

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,11 @@ input PreviewRequest {
13411341
action: PreviewAction!
13421342
}
13431343

1344+
type PreviewReserveRates {
1345+
supplyApy: PercentNumberVariation
1346+
borrowApy: PercentNumberVariation
1347+
}
1348+
13441349
union PreviewReward = PreviewMerklSupplyReward | PreviewMerklBorrowReward | PreviewSupplyPointsReward | PreviewBorrowPointsReward
13451350

13461351
type PreviewRewardOutcome {
@@ -1366,10 +1371,17 @@ type PreviewUserPosition {
13661371

13671372
"""The net apy for one user position on a current spoke"""
13681373
netApy: PercentNumberVariation!
1374+
1375+
"""
1376+
Reserve rates after the action.
1377+
Only populated for supply and borrow actions.
1378+
"""
1379+
reserveRates: PreviewReserveRates!
13691380
netCollateral(currency: Currency! = USD): ExchangeAmountVariation!
13701381
netBalance(currency: Currency! = USD): ExchangeAmountVariation!
13711382
projectedEarnings: ExchangeAmountVariation!
1372-
borrowingPower: ExchangeAmountVariation!
1383+
maxBorrowingPower: ExchangeAmountVariation!
1384+
remainingBorrowingPower: ExchangeAmountVariation!
13731385
rewards: PreviewRewardOutcome!
13741386
otherConditions: [UserPositionConditionVariation!]!
13751387
}
@@ -1720,6 +1732,8 @@ type ReserveStatus {
17201732
type ReserveSummary {
17211733
supplied: Erc20Amount!
17221734
borrowed: Erc20Amount!
1735+
suppliable: Erc20Amount!
1736+
borrowable: Erc20Amount!
17231737
supplyApy: PercentNumber!
17241738
borrowApy: PercentNumber!
17251739
rewards: [Reward!]!
@@ -2917,7 +2931,8 @@ type UserPosition {
29172931
1 collateral you should render health factor
29182932
"""
29192933
liquidationPrice(currency: Currency! = USD): ExchangeAmount
2920-
borrowingPower(currency: Currency! = USD): ExchangeAmount!
2934+
maxBorrowingPower(currency: Currency! = USD): ExchangeAmount!
2935+
remainingBorrowingPower(currency: Currency! = USD): ExchangeAmount!
29212936
canUpdateDynamicConfig: Boolean!
29222937
netBalancePercentChange(window: TimeWindow! = LAST_DAY): PercentNumber!
29232938
spoke: Spoke!

packages/graphql/src/fragments/reserve.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ export const ReserveSummaryFragment = graphql(
5959
borrowed {
6060
...Erc20Amount
6161
}
62+
suppliable {
63+
...Erc20Amount
64+
}
65+
borrowable {
66+
...Erc20Amount
67+
}
6268
supplyApy {
6369
...PercentNumber
6470
}

packages/graphql/src/fragments/user.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ export const UserPositionFragment = graphql(
175175
liquidationPrice(currency: $currency) {
176176
...ExchangeAmount
177177
}
178-
borrowingPower(currency: $currency) {
178+
maxBorrowingPower(currency: $currency) {
179+
...ExchangeAmount
180+
}
181+
remainingBorrowingPower(currency: $currency) {
179182
...ExchangeAmount
180183
}
181184
canUpdateDynamicConfig

packages/graphql/src/graphql-env.d.ts

Lines changed: 4 additions & 3 deletions
Large diffs are not rendered by default.

packages/graphql/src/schema.json

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4327,6 +4327,31 @@
43274327
],
43284328
"interfaces": []
43294329
},
4330+
{
4331+
"kind": "OBJECT",
4332+
"name": "PreviewReserveRates",
4333+
"fields": [
4334+
{
4335+
"name": "supplyApy",
4336+
"type": {
4337+
"kind": "OBJECT",
4338+
"name": "PercentNumberVariation",
4339+
"ofType": null
4340+
},
4341+
"args": []
4342+
},
4343+
{
4344+
"name": "borrowApy",
4345+
"type": {
4346+
"kind": "OBJECT",
4347+
"name": "PercentNumberVariation",
4348+
"ofType": null
4349+
},
4350+
"args": []
4351+
}
4352+
],
4353+
"interfaces": []
4354+
},
43304355
{
43314356
"kind": "UNION",
43324357
"name": "PreviewReward",
@@ -4541,6 +4566,18 @@
45414566
},
45424567
"args": []
45434568
},
4569+
{
4570+
"name": "reserveRates",
4571+
"type": {
4572+
"kind": "NON_NULL",
4573+
"ofType": {
4574+
"kind": "OBJECT",
4575+
"name": "PreviewReserveRates",
4576+
"ofType": null
4577+
}
4578+
},
4579+
"args": []
4580+
},
45444581
{
45454582
"name": "netCollateral",
45464583
"type": {
@@ -4600,7 +4637,19 @@
46004637
"args": []
46014638
},
46024639
{
4603-
"name": "borrowingPower",
4640+
"name": "maxBorrowingPower",
4641+
"type": {
4642+
"kind": "NON_NULL",
4643+
"ofType": {
4644+
"kind": "OBJECT",
4645+
"name": "ExchangeAmountVariation",
4646+
"ofType": null
4647+
}
4648+
},
4649+
"args": []
4650+
},
4651+
{
4652+
"name": "remainingBorrowingPower",
46044653
"type": {
46054654
"kind": "NON_NULL",
46064655
"ofType": {
@@ -6985,6 +7034,30 @@
69857034
},
69867035
"args": []
69877036
},
7037+
{
7038+
"name": "suppliable",
7039+
"type": {
7040+
"kind": "NON_NULL",
7041+
"ofType": {
7042+
"kind": "OBJECT",
7043+
"name": "Erc20Amount",
7044+
"ofType": null
7045+
}
7046+
},
7047+
"args": []
7048+
},
7049+
{
7050+
"name": "borrowable",
7051+
"type": {
7052+
"kind": "NON_NULL",
7053+
"ofType": {
7054+
"kind": "OBJECT",
7055+
"name": "Erc20Amount",
7056+
"ofType": null
7057+
}
7058+
},
7059+
"args": []
7060+
},
69887061
{
69897062
"name": "supplyApy",
69907063
"type": {
@@ -10355,7 +10428,30 @@
1035510428
]
1035610429
},
1035710430
{
10358-
"name": "borrowingPower",
10431+
"name": "maxBorrowingPower",
10432+
"type": {
10433+
"kind": "NON_NULL",
10434+
"ofType": {
10435+
"kind": "OBJECT",
10436+
"name": "ExchangeAmount",
10437+
"ofType": null
10438+
}
10439+
},
10440+
"args": [
10441+
{
10442+
"name": "currency",
10443+
"type": {
10444+
"kind": "NON_NULL",
10445+
"ofType": {
10446+
"kind": "SCALAR",
10447+
"name": "Any"
10448+
}
10449+
}
10450+
}
10451+
]
10452+
},
10453+
{
10454+
"name": "remainingBorrowingPower",
1035910455
"type": {
1036010456
"kind": "NON_NULL",
1036110457
"ofType": {

packages/graphql/src/testing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ export function makeUserPosition({
367367
healthFactor: makeHealthFactorWithChange(),
368368
riskPremium: makeUserPositionRiskPremium(),
369369
liquidationPrice: makeExchangeAmount(0),
370-
borrowingPower: makeExchangeAmount(0),
370+
maxBorrowingPower: makeExchangeAmount(0),
371+
remainingBorrowingPower: makeExchangeAmount(0),
371372
canUpdateDynamicConfig: false,
372373
netBalancePercentChange: makePercentNumber(0),
373374
averageCollateralFactor: makePercentNumber(0),

packages/graphql/src/transactions.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,20 @@ export const PreviewUserPositionFragment = graphql(
446446
projectedEarnings {
447447
...ExchangeAmountVariation
448448
}
449-
borrowingPower {
449+
maxBorrowingPower {
450450
...ExchangeAmountVariation
451451
}
452+
remainingBorrowingPower {
453+
...ExchangeAmountVariation
454+
}
455+
reserveRates {
456+
supplyApy {
457+
...PercentNumberVariation
458+
}
459+
borrowApy {
460+
...PercentNumberVariation
461+
}
462+
}
452463
rewards {
453464
...PreviewRewardOutcome
454465
}

0 commit comments

Comments
 (0)