curvance 4.1.2 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -10
- package/dist/abis/OptimizerReader.json +43 -45
- package/dist/abis/ProtocolReader.json +279 -55
- package/dist/chains/arbitrum.js +3 -3
- package/dist/chains/arbitrum.js.map +1 -1
- package/dist/classes/Api.d.ts +2 -2
- package/dist/classes/Api.d.ts.map +1 -1
- package/dist/classes/Api.js +87 -14
- package/dist/classes/Api.js.map +1 -1
- package/dist/classes/BorrowableCToken.d.ts +9 -1
- package/dist/classes/BorrowableCToken.d.ts.map +1 -1
- package/dist/classes/BorrowableCToken.js +67 -12
- package/dist/classes/BorrowableCToken.js.map +1 -1
- package/dist/classes/CToken.d.ts +210 -21
- package/dist/classes/CToken.d.ts.map +1 -1
- package/dist/classes/CToken.js +692 -284
- package/dist/classes/CToken.js.map +1 -1
- package/dist/classes/Calldata.d.ts +2 -2
- package/dist/classes/Calldata.d.ts.map +1 -1
- package/dist/classes/Calldata.js +6 -2
- package/dist/classes/Calldata.js.map +1 -1
- package/dist/classes/DexAggregators/IDexAgg.d.ts +1 -1
- package/dist/classes/DexAggregators/Kuru.js +1 -1
- package/dist/classes/DexAggregators/Kuru.js.map +1 -1
- package/dist/classes/DexAggregators/KyberSwap.d.ts.map +1 -1
- package/dist/classes/DexAggregators/KyberSwap.js +112 -61
- package/dist/classes/DexAggregators/KyberSwap.js.map +1 -1
- package/dist/classes/DexAggregators/MultiDexAgg.d.ts +2 -2
- package/dist/classes/DexAggregators/MultiDexAgg.d.ts.map +1 -1
- package/dist/classes/DexAggregators/MultiDexAgg.js +30 -18
- package/dist/classes/DexAggregators/MultiDexAgg.js.map +1 -1
- package/dist/classes/DexAggregators/UnsupportedDexAgg.d.ts +19 -0
- package/dist/classes/DexAggregators/UnsupportedDexAgg.d.ts.map +1 -0
- package/dist/classes/DexAggregators/UnsupportedDexAgg.js +29 -0
- package/dist/classes/DexAggregators/UnsupportedDexAgg.js.map +1 -0
- package/dist/classes/DexAggregators/helpers.d.ts +30 -0
- package/dist/classes/DexAggregators/helpers.d.ts.map +1 -0
- package/dist/classes/DexAggregators/helpers.js +57 -0
- package/dist/classes/DexAggregators/helpers.js.map +1 -0
- package/dist/classes/DexAggregators/index.d.ts +2 -0
- package/dist/classes/DexAggregators/index.d.ts.map +1 -1
- package/dist/classes/DexAggregators/index.js +1 -0
- package/dist/classes/DexAggregators/index.js.map +1 -1
- package/dist/classes/ERC20.d.ts +3 -3
- package/dist/classes/ERC20.d.ts.map +1 -1
- package/dist/classes/ERC20.js +26 -10
- package/dist/classes/ERC20.js.map +1 -1
- package/dist/classes/FormatConverter.d.ts.map +1 -1
- package/dist/classes/FormatConverter.js +4 -1
- package/dist/classes/FormatConverter.js.map +1 -1
- package/dist/classes/Market.d.ts +46 -8
- package/dist/classes/Market.d.ts.map +1 -1
- package/dist/classes/Market.js +342 -111
- package/dist/classes/Market.js.map +1 -1
- package/dist/classes/NativeToken.d.ts +2 -2
- package/dist/classes/NativeToken.d.ts.map +1 -1
- package/dist/classes/NativeToken.js +21 -7
- package/dist/classes/NativeToken.js.map +1 -1
- package/dist/classes/OptimizerReader.d.ts +15 -7
- package/dist/classes/OptimizerReader.d.ts.map +1 -1
- package/dist/classes/OptimizerReader.js +108 -30
- package/dist/classes/OptimizerReader.js.map +1 -1
- package/dist/classes/OracleManager.d.ts.map +1 -1
- package/dist/classes/OracleManager.js +11 -4
- package/dist/classes/OracleManager.js.map +1 -1
- package/dist/classes/PositionManager.d.ts.map +1 -1
- package/dist/classes/PositionManager.js +1 -3
- package/dist/classes/PositionManager.js.map +1 -1
- package/dist/classes/ProtocolReader.d.ts +30 -9
- package/dist/classes/ProtocolReader.d.ts.map +1 -1
- package/dist/classes/ProtocolReader.js +158 -138
- package/dist/classes/ProtocolReader.js.map +1 -1
- package/dist/classes/Zapper.d.ts +5 -5
- package/dist/classes/Zapper.d.ts.map +1 -1
- package/dist/classes/Zapper.js +21 -18
- package/dist/classes/Zapper.js.map +1 -1
- package/dist/contracts/monad-mainnet.json +1 -1
- package/dist/feePolicy.d.ts +2 -0
- package/dist/feePolicy.d.ts.map +1 -1
- package/dist/feePolicy.js +19 -0
- package/dist/feePolicy.js.map +1 -1
- package/dist/format/borrow.d.ts.map +1 -1
- package/dist/format/borrow.js +7 -1
- package/dist/format/borrow.js.map +1 -1
- package/dist/format/health.d.ts +3 -2
- package/dist/format/health.d.ts.map +1 -1
- package/dist/format/health.js +10 -9
- package/dist/format/health.js.map +1 -1
- package/dist/format/leverage.js +5 -4
- package/dist/format/leverage.js.map +1 -1
- package/dist/helpers.d.ts +14 -11
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +171 -52
- package/dist/helpers.js.map +1 -1
- package/dist/integrations/merkl.d.ts +2 -1
- package/dist/integrations/merkl.d.ts.map +1 -1
- package/dist/integrations/merkl.js +199 -4
- package/dist/integrations/merkl.js.map +1 -1
- package/dist/integrations/snapshot.d.ts +28 -24
- package/dist/integrations/snapshot.d.ts.map +1 -1
- package/dist/integrations/snapshot.js +106 -42
- package/dist/integrations/snapshot.js.map +1 -1
- package/dist/retry-provider.d.ts +6 -0
- package/dist/retry-provider.d.ts.map +1 -1
- package/dist/retry-provider.js +103 -11
- package/dist/retry-provider.js.map +1 -1
- package/dist/setup.d.ts +8 -6
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +125 -45
- package/dist/setup.js.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +13 -7
- package/dist/validation.js.map +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -35,7 +35,6 @@ const { markets, reader, dexAgg, global_milestone } = await setupChain("monad-ma
|
|
|
35
35
|
setupChain(
|
|
36
36
|
chain: ChainRpcPrefix,
|
|
37
37
|
provider: curvance_provider | null = null, // signer (wallet) OR read-only provider; null → SDK default
|
|
38
|
-
approval_protection: boolean = false, // revoke-before-approve pattern
|
|
39
38
|
api_url: string = "https://api.curvance.com",
|
|
40
39
|
options: {
|
|
41
40
|
feePolicy?: FeePolicy; // zap/leverage fee routing (default: NO_FEE_POLICY)
|
|
@@ -57,11 +56,18 @@ setupChain(
|
|
|
57
56
|
- **Explicit `options.readProvider`** → wins over all of the above. Use when you want deterministic read transport (e.g. fork testing).
|
|
58
57
|
- **Writes** always route through the connected signer; they never use the chain RPC or fallbacks.
|
|
59
58
|
|
|
59
|
+
### Write approvals
|
|
60
|
+
|
|
61
|
+
- High-level write methods always preflight the approvals they need before submit.
|
|
62
|
+
- Missing ERC20 allowance throws a descriptive error instead of sending a revert-prone transaction.
|
|
63
|
+
- Missing zapper or position-manager delegate approval also throws before submit.
|
|
64
|
+
- There is no setup-time approval mode switch. Use `approveUnderlying`, `approveZapAsset`, and `approvePlugin` explicitly when the caller needs to satisfy approvals.
|
|
65
|
+
|
|
60
66
|
### Explore markets
|
|
61
67
|
|
|
62
68
|
```ts
|
|
63
69
|
for (const market of markets) {
|
|
64
|
-
console.log(`${market.name} |
|
|
70
|
+
console.log(`${market.name} | deposits: ${market.totalDeposits} | debt: ${market.totalDebt}`);
|
|
65
71
|
for (const token of market.tokens) {
|
|
66
72
|
console.log(` ${token.symbol} | price: ${token.getPrice()} | apy: ${token.getApy(true)}%`);
|
|
67
73
|
}
|
|
@@ -90,7 +96,7 @@ for (const market of markets) {
|
|
|
90
96
|
```ts
|
|
91
97
|
market.name // market name
|
|
92
98
|
market.address // market contract address
|
|
93
|
-
market.
|
|
99
|
+
market.totalDeposits // total market deposits (USD, Decimal)
|
|
94
100
|
market.totalDebt // total outstanding debt (USD, Decimal)
|
|
95
101
|
market.totalCollateral // total posted collateral (USD, Decimal)
|
|
96
102
|
market.cooldownLength // hold period between actions (20 min)
|
|
@@ -182,7 +188,7 @@ token.getUserDebt(inUSD) // outstanding debt (borrow tokens)
|
|
|
182
188
|
### Market totals & caps
|
|
183
189
|
|
|
184
190
|
```ts
|
|
185
|
-
token.
|
|
191
|
+
token.getDeposits(inUSD) // underlying assets held (USD or bigint)
|
|
186
192
|
token.getTotalCollateral(inUSD)
|
|
187
193
|
token.getCollateralCap(inUSD) // remaining collateral capacity
|
|
188
194
|
token.getDebtCap(inUSD) // remaining debt capacity
|
|
@@ -222,6 +228,7 @@ token.getMaxBorrowable() // max amount given credit
|
|
|
222
228
|
```ts
|
|
223
229
|
token.getSnapshot(account) // position snapshot for an account
|
|
224
230
|
token.maxRedemption(inShares, bufferTime) // max redeemable amount
|
|
231
|
+
token.maxRemovableCollateral(inShares, bufferTime) // max posted collateral removable without violating health
|
|
225
232
|
token.simulateDeposit(amount) // preview deposit without executing
|
|
226
233
|
token.simulateDepositAsCollateral(amount)
|
|
227
234
|
```
|
|
@@ -254,7 +261,8 @@ await token.redeemCollateral(amount, receiver?, owner?)
|
|
|
254
261
|
|
|
255
262
|
// Manage posted collateral
|
|
256
263
|
await token.postCollateral(amount) // post unposted balance as collateral
|
|
257
|
-
await token.
|
|
264
|
+
await token.removeCollateralExact(amount) // exact collateral removal, capped to the safe removable max
|
|
265
|
+
await token.removeMaxCollateral() // remove the maximum valid posted collateral
|
|
258
266
|
```
|
|
259
267
|
|
|
260
268
|
### Borrow & Repay (`BorrowableCToken` only)
|
|
@@ -292,6 +300,7 @@ if (!approved) await token.approvePlugin('simple', 'zapper')
|
|
|
292
300
|
// Plugin types
|
|
293
301
|
// ZapperTypes: 'none' | 'native-vault' | 'vault' | 'simple' | 'native-simple'
|
|
294
302
|
// PositionManagerTypes: 'native-vault' | 'simple' | 'vault'
|
|
303
|
+
// `leverageDown(...)` currently executes through the 'simple' position manager only.
|
|
295
304
|
|
|
296
305
|
const zapper = token.getZapper('simple')
|
|
297
306
|
const positionManager = token.getPositionManager('simple')
|
|
@@ -338,6 +347,7 @@ await collateralToken.depositAsCollateral(amount)
|
|
|
338
347
|
await collateralToken.leverageUp(borrowToken, new Decimal(3), 'simple', new Decimal(0.005))
|
|
339
348
|
|
|
340
349
|
// Reduce leverage
|
|
350
|
+
// Deleverage currently executes through the simple position manager path.
|
|
341
351
|
await collateralToken.leverageDown(borrowToken, currentLeverage, targetLeverage, 'simple', slippage)
|
|
342
352
|
|
|
343
353
|
// Check current leverage
|
|
@@ -522,7 +532,7 @@ const feePolicy = flatFeePolicy({
|
|
|
522
532
|
stableToStableBps: 2n, // optional lower fee for stable↔stable swaps
|
|
523
533
|
})
|
|
524
534
|
|
|
525
|
-
const { markets } = await setupChain("monad-mainnet", wallet,
|
|
535
|
+
const { markets } = await setupChain("monad-mainnet", wallet, undefined, { feePolicy })
|
|
526
536
|
```
|
|
527
537
|
|
|
528
538
|
The SDK automatically returns 0 bps for native ↔ wrapped-native swaps and same-token no-op zaps.
|
|
@@ -575,6 +585,8 @@ const snapshot = await takePortfolioSnapshot(account)
|
|
|
575
585
|
const marketSnapshot = snapshotMarket(market)
|
|
576
586
|
```
|
|
577
587
|
|
|
588
|
+
`snapshotMarket(...)` requires full user token data. `takePortfolioSnapshot(...)` will automatically promote summary-scoped markets back to full user data before reading token balances. If you previously called `refreshActiveUserMarketSummaries(...)` and need a direct single-market snapshot, run `market.reloadUserData(account)` or `Market.reloadUserMarkets(...)` first.
|
|
589
|
+
|
|
578
590
|
## ❯ Optimizer
|
|
579
591
|
|
|
580
592
|
The `OptimizerReader` reads yield-rebalancing vaults that allocate across markets.
|
|
@@ -582,7 +594,10 @@ The `OptimizerReader` reads yield-rebalancing vaults that allocate across market
|
|
|
582
594
|
```ts
|
|
583
595
|
import { OptimizerReader } from "curvance"
|
|
584
596
|
|
|
585
|
-
const optimizer = new OptimizerReader(provider)
|
|
597
|
+
const optimizer = new OptimizerReader(optimizerReaderAddress, provider)
|
|
598
|
+
|
|
599
|
+
await optimizer.getOptimizerAPY(optimizerAddress)
|
|
600
|
+
// Returns: weighted-average optimizer APY in WAD
|
|
586
601
|
|
|
587
602
|
await optimizer.getOptimizerMarketData(optimizerAddresses)
|
|
588
603
|
// Returns: { totalAssets, sharePrice, performanceFee, markets[] }
|
|
@@ -590,9 +605,8 @@ await optimizer.getOptimizerMarketData(optimizerAddresses)
|
|
|
590
605
|
await optimizer.getOptimizerUserData(optimizerAddresses, account)
|
|
591
606
|
// Returns: user balance and redeemable amounts
|
|
592
607
|
|
|
593
|
-
await optimizer.
|
|
594
|
-
|
|
595
|
-
await optimizer.optimalRebalance(optimizer) // suggested reallocations: { cToken, assets }[]
|
|
608
|
+
await optimizer.optimalRebalance(optimizer, 100n)
|
|
609
|
+
// Returns: { actions: { cToken, assetsOrBps }[], bounds: { cToken, minBps, maxBps }[] }
|
|
596
610
|
```
|
|
597
611
|
|
|
598
612
|
## ❯ TypeScript Types
|
|
@@ -617,6 +631,7 @@ type CollateralSource = "Renzo" | "Upshift" | "Yuzu" | "Native" | "Circle" | "Fa
|
|
|
617
631
|
// Operations
|
|
618
632
|
type ZapperTypes = 'none' | 'native-vault' | 'vault' | 'simple' | 'native-simple'
|
|
619
633
|
type PositionManagerTypes = 'native-vault' | 'simple' | 'vault'
|
|
634
|
+
// `leverageDown(...)` accepts 'simple' only.
|
|
620
635
|
type ChangeRate = 'year' | 'month' | 'week' | 'day'
|
|
621
636
|
|
|
622
637
|
// DEX
|
|
@@ -644,6 +659,46 @@ NATIVE_ADDRESS // canonical native token address
|
|
|
644
659
|
DEFAULT_SLIPPAGE_BPS // 100n (1%)
|
|
645
660
|
```
|
|
646
661
|
|
|
662
|
+
### Leverage tuning (`LEVERAGE`)
|
|
663
|
+
|
|
664
|
+
Exposed tuning block used by leverage preview / mutation paths. Values are considered tunable across releases — SDK consumers pinning against specific values opt into the coupling.
|
|
665
|
+
|
|
666
|
+
```ts
|
|
667
|
+
import { LEVERAGE } from 'curvance';
|
|
668
|
+
|
|
669
|
+
LEVERAGE.MAX_LEVERAGE_FACTOR // Decimal(0.98)
|
|
670
|
+
// Cap applied to the theoretical max leverage span. Reserves ~2% of the
|
|
671
|
+
// equity-fraction slippage budget for deterministic loss channels
|
|
672
|
+
// (CURVANCE_FEE_BPS, pool-fee variance, Redstone drift, share rounding)
|
|
673
|
+
// that would otherwise push post-op LTV above collRatio at the boundary.
|
|
674
|
+
|
|
675
|
+
LEVERAGE.LEVERAGE_UP_BUFFER_BPS // 10n
|
|
676
|
+
// Flat BPS buffer added to leverage-up slippage for share-rounding + fresh
|
|
677
|
+
// Redstone price drift between snapshot RPC and tx broadcast. NOT amplified
|
|
678
|
+
// by (L-1); the contract's equity-fraction denominator handles amplification.
|
|
679
|
+
|
|
680
|
+
LEVERAGE.DELEVERAGE_OVERHEAD_BPS // 20n
|
|
681
|
+
// BPS overhead added to full-deleverage swap sizing to absorb DEX impact
|
|
682
|
+
// and oracle drift without leaving dust debt. The contract returns any
|
|
683
|
+
// excess debt token to the user, so economic loss is zero — but
|
|
684
|
+
// `checkSlippage` treats the intentional overshoot as equity loss and
|
|
685
|
+
// amplifies it by (L-1), which the contract-slippage expansion compensates.
|
|
686
|
+
|
|
687
|
+
LEVERAGE.SHARES_BUFFER_BPS // 2n
|
|
688
|
+
// Downward BPS buffer on `virtualConvertToShares` and the inner
|
|
689
|
+
// `previewDeposit` step of `getVaultExpectedShares`. Covers exchange-rate
|
|
690
|
+
// drift from interest accrual since cache load so actual mint satisfies
|
|
691
|
+
// `shares >= expectedShares` at tx inclusion.
|
|
692
|
+
|
|
693
|
+
LEVERAGE.LEVERAGE_UP_VAULT_DRIFT_BPS // 30n
|
|
694
|
+
// Per-leverage-unit BPS buffer for `checkSlippage` on vault + native-vault
|
|
695
|
+
// leverage-up paths. Absorbs drift between the collateral vault's
|
|
696
|
+
// fundamental mint rate at tx time and the stored oracle price that
|
|
697
|
+
// `marketManager.statusOf` uses inside `checkSlippage`. Mirrors the
|
|
698
|
+
// `(L-1) × feeBps` amplification the simple branch uses for DEX-fee
|
|
699
|
+
// absorption, with a different K since vault paths have no DEX leg.
|
|
700
|
+
```
|
|
701
|
+
|
|
647
702
|
## ❯ Dependencies
|
|
648
703
|
|
|
649
704
|
| Package | Purpose |
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"type": "function",
|
|
4
|
+
"name": "getOptimizerAPY",
|
|
5
|
+
"inputs": [
|
|
6
|
+
{
|
|
7
|
+
"name": "optimizer",
|
|
8
|
+
"type": "address",
|
|
9
|
+
"internalType": "address"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"outputs": [
|
|
13
|
+
{
|
|
14
|
+
"name": "apy",
|
|
15
|
+
"type": "uint256",
|
|
16
|
+
"internalType": "uint256"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"stateMutability": "view"
|
|
20
|
+
},
|
|
2
21
|
{
|
|
3
22
|
"type": "function",
|
|
4
23
|
"name": "getOptimizerMarketData",
|
|
@@ -70,7 +89,7 @@
|
|
|
70
89
|
]
|
|
71
90
|
}
|
|
72
91
|
],
|
|
73
|
-
"stateMutability": "
|
|
92
|
+
"stateMutability": "nonpayable"
|
|
74
93
|
},
|
|
75
94
|
{
|
|
76
95
|
"type": "function",
|
|
@@ -115,7 +134,7 @@
|
|
|
115
134
|
},
|
|
116
135
|
{
|
|
117
136
|
"type": "function",
|
|
118
|
-
"name": "
|
|
137
|
+
"name": "optimalRebalance",
|
|
119
138
|
"inputs": [
|
|
120
139
|
{
|
|
121
140
|
"name": "optimizer",
|
|
@@ -123,30 +142,11 @@
|
|
|
123
142
|
"internalType": "address"
|
|
124
143
|
},
|
|
125
144
|
{
|
|
126
|
-
"name": "
|
|
145
|
+
"name": "slippageBps",
|
|
127
146
|
"type": "uint256",
|
|
128
147
|
"internalType": "uint256"
|
|
129
148
|
}
|
|
130
149
|
],
|
|
131
|
-
"outputs": [
|
|
132
|
-
{
|
|
133
|
-
"name": "market",
|
|
134
|
-
"type": "address",
|
|
135
|
-
"internalType": "address"
|
|
136
|
-
}
|
|
137
|
-
],
|
|
138
|
-
"stateMutability": "view"
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
"type": "function",
|
|
142
|
-
"name": "optimalRebalance",
|
|
143
|
-
"inputs": [
|
|
144
|
-
{
|
|
145
|
-
"name": "optimizer",
|
|
146
|
-
"type": "address",
|
|
147
|
-
"internalType": "address"
|
|
148
|
-
}
|
|
149
|
-
],
|
|
150
150
|
"outputs": [
|
|
151
151
|
{
|
|
152
152
|
"name": "actions",
|
|
@@ -159,35 +159,33 @@
|
|
|
159
159
|
"internalType": "contract IBorrowableCToken"
|
|
160
160
|
},
|
|
161
161
|
{
|
|
162
|
-
"name": "
|
|
162
|
+
"name": "assetsOrBps",
|
|
163
163
|
"type": "int256",
|
|
164
164
|
"internalType": "int256"
|
|
165
165
|
}
|
|
166
166
|
]
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
"stateMutability": "view"
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"type": "function",
|
|
173
|
-
"name": "optimalWithdrawal",
|
|
174
|
-
"inputs": [
|
|
175
|
-
{
|
|
176
|
-
"name": "optimizer",
|
|
177
|
-
"type": "address",
|
|
178
|
-
"internalType": "address"
|
|
179
167
|
},
|
|
180
168
|
{
|
|
181
|
-
"name": "
|
|
182
|
-
"type": "
|
|
183
|
-
"internalType": "
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
169
|
+
"name": "bounds",
|
|
170
|
+
"type": "tuple[]",
|
|
171
|
+
"internalType": "struct LendingOptimizer.AllocationBound[]",
|
|
172
|
+
"components": [
|
|
173
|
+
{
|
|
174
|
+
"name": "cToken",
|
|
175
|
+
"type": "address",
|
|
176
|
+
"internalType": "address"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "minBps",
|
|
180
|
+
"type": "uint256",
|
|
181
|
+
"internalType": "uint256"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "maxBps",
|
|
185
|
+
"type": "uint256",
|
|
186
|
+
"internalType": "uint256"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
191
189
|
}
|
|
192
190
|
],
|
|
193
191
|
"stateMutability": "view"
|
|
@@ -336,6 +336,108 @@
|
|
|
336
336
|
],
|
|
337
337
|
"stateMutability": "view"
|
|
338
338
|
},
|
|
339
|
+
{
|
|
340
|
+
"type": "function",
|
|
341
|
+
"name": "getDynamicMarketData",
|
|
342
|
+
"inputs": [],
|
|
343
|
+
"outputs": [
|
|
344
|
+
{
|
|
345
|
+
"name": "data",
|
|
346
|
+
"type": "tuple[]",
|
|
347
|
+
"internalType": "struct ProtocolReader.DynamicMarketData[]",
|
|
348
|
+
"components": [
|
|
349
|
+
{
|
|
350
|
+
"name": "_address",
|
|
351
|
+
"type": "address",
|
|
352
|
+
"internalType": "address"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"name": "tokens",
|
|
356
|
+
"type": "tuple[]",
|
|
357
|
+
"internalType": "struct ProtocolReader.DynamicMarketToken[]",
|
|
358
|
+
"components": [
|
|
359
|
+
{
|
|
360
|
+
"name": "_address",
|
|
361
|
+
"type": "address",
|
|
362
|
+
"internalType": "address"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "totalSupply",
|
|
366
|
+
"type": "uint256",
|
|
367
|
+
"internalType": "uint256"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"name": "exchangeRate",
|
|
371
|
+
"type": "uint256",
|
|
372
|
+
"internalType": "uint256"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"name": "totalAssets",
|
|
376
|
+
"type": "uint256",
|
|
377
|
+
"internalType": "uint256"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"name": "collateral",
|
|
381
|
+
"type": "uint256",
|
|
382
|
+
"internalType": "uint256"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"name": "debt",
|
|
386
|
+
"type": "uint256",
|
|
387
|
+
"internalType": "uint256"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"name": "sharePrice",
|
|
391
|
+
"type": "uint256",
|
|
392
|
+
"internalType": "uint256"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"name": "assetPrice",
|
|
396
|
+
"type": "uint256",
|
|
397
|
+
"internalType": "uint256"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"name": "sharePriceLower",
|
|
401
|
+
"type": "uint256",
|
|
402
|
+
"internalType": "uint256"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"name": "assetPriceLower",
|
|
406
|
+
"type": "uint256",
|
|
407
|
+
"internalType": "uint256"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"name": "borrowRate",
|
|
411
|
+
"type": "uint256",
|
|
412
|
+
"internalType": "uint256"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
"name": "predictedBorrowRate",
|
|
416
|
+
"type": "uint256",
|
|
417
|
+
"internalType": "uint256"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"name": "utilizationRate",
|
|
421
|
+
"type": "uint256",
|
|
422
|
+
"internalType": "uint256"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"name": "supplyRate",
|
|
426
|
+
"type": "uint256",
|
|
427
|
+
"internalType": "uint256"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"name": "liquidity",
|
|
431
|
+
"type": "uint256",
|
|
432
|
+
"internalType": "uint256"
|
|
433
|
+
}
|
|
434
|
+
]
|
|
435
|
+
}
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
],
|
|
439
|
+
"stateMutability": "view"
|
|
440
|
+
},
|
|
339
441
|
{
|
|
340
442
|
"type": "function",
|
|
341
443
|
"name": "getLeverageSnapshot",
|
|
@@ -402,11 +504,56 @@
|
|
|
402
504
|
},
|
|
403
505
|
{
|
|
404
506
|
"type": "function",
|
|
405
|
-
"name": "
|
|
406
|
-
"inputs": [
|
|
507
|
+
"name": "getLiquidationPrice",
|
|
508
|
+
"inputs": [
|
|
509
|
+
{
|
|
510
|
+
"name": "account",
|
|
511
|
+
"type": "address",
|
|
512
|
+
"internalType": "address"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
"name": "cToken",
|
|
516
|
+
"type": "address",
|
|
517
|
+
"internalType": "address"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"name": "long",
|
|
521
|
+
"type": "bool",
|
|
522
|
+
"internalType": "bool"
|
|
523
|
+
}
|
|
524
|
+
],
|
|
407
525
|
"outputs": [
|
|
408
526
|
{
|
|
409
|
-
"name": "
|
|
527
|
+
"name": "price",
|
|
528
|
+
"type": "uint256",
|
|
529
|
+
"internalType": "uint256"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"name": "errorHit",
|
|
533
|
+
"type": "bool",
|
|
534
|
+
"internalType": "bool"
|
|
535
|
+
}
|
|
536
|
+
],
|
|
537
|
+
"stateMutability": "view"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"type": "function",
|
|
541
|
+
"name": "getMarketStates",
|
|
542
|
+
"inputs": [
|
|
543
|
+
{
|
|
544
|
+
"name": "markets",
|
|
545
|
+
"type": "address[]",
|
|
546
|
+
"internalType": "address[]"
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
"name": "account",
|
|
550
|
+
"type": "address",
|
|
551
|
+
"internalType": "address"
|
|
552
|
+
}
|
|
553
|
+
],
|
|
554
|
+
"outputs": [
|
|
555
|
+
{
|
|
556
|
+
"name": "dynamicMarkets",
|
|
410
557
|
"type": "tuple[]",
|
|
411
558
|
"internalType": "struct ProtocolReader.DynamicMarketData[]",
|
|
412
559
|
"components": [
|
|
@@ -498,40 +645,151 @@
|
|
|
498
645
|
]
|
|
499
646
|
}
|
|
500
647
|
]
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"name": "userMarkets",
|
|
651
|
+
"type": "tuple[]",
|
|
652
|
+
"internalType": "struct ProtocolReader.UserMarket[]",
|
|
653
|
+
"components": [
|
|
654
|
+
{
|
|
655
|
+
"name": "_address",
|
|
656
|
+
"type": "address",
|
|
657
|
+
"internalType": "address"
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
"name": "collateral",
|
|
661
|
+
"type": "uint256",
|
|
662
|
+
"internalType": "uint256"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"name": "maxDebt",
|
|
666
|
+
"type": "uint256",
|
|
667
|
+
"internalType": "uint256"
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
"name": "debt",
|
|
671
|
+
"type": "uint256",
|
|
672
|
+
"internalType": "uint256"
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
"name": "positionHealth",
|
|
676
|
+
"type": "uint256",
|
|
677
|
+
"internalType": "uint256"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"name": "cooldown",
|
|
681
|
+
"type": "uint256",
|
|
682
|
+
"internalType": "uint256"
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
"name": "errorCodeHit",
|
|
686
|
+
"type": "bool",
|
|
687
|
+
"internalType": "bool"
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
"name": "tokens",
|
|
691
|
+
"type": "tuple[]",
|
|
692
|
+
"internalType": "struct ProtocolReader.UserMarketToken[]",
|
|
693
|
+
"components": [
|
|
694
|
+
{
|
|
695
|
+
"name": "_address",
|
|
696
|
+
"type": "address",
|
|
697
|
+
"internalType": "address"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
"name": "userAssetBalance",
|
|
701
|
+
"type": "uint256",
|
|
702
|
+
"internalType": "uint256"
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
"name": "userShareBalance",
|
|
706
|
+
"type": "uint256",
|
|
707
|
+
"internalType": "uint256"
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
"name": "userUnderlyingBalance",
|
|
711
|
+
"type": "uint256",
|
|
712
|
+
"internalType": "uint256"
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
"name": "userCollateral",
|
|
716
|
+
"type": "uint256",
|
|
717
|
+
"internalType": "uint256"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"name": "userDebt",
|
|
721
|
+
"type": "uint256",
|
|
722
|
+
"internalType": "uint256"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"name": "liquidationPrice",
|
|
726
|
+
"type": "uint256",
|
|
727
|
+
"internalType": "uint256"
|
|
728
|
+
}
|
|
729
|
+
]
|
|
730
|
+
}
|
|
731
|
+
]
|
|
501
732
|
}
|
|
502
733
|
],
|
|
503
734
|
"stateMutability": "view"
|
|
504
735
|
},
|
|
505
736
|
{
|
|
506
737
|
"type": "function",
|
|
507
|
-
"name": "
|
|
738
|
+
"name": "getMarketSummaries",
|
|
508
739
|
"inputs": [
|
|
509
740
|
{
|
|
510
|
-
"name": "
|
|
511
|
-
"type": "address",
|
|
512
|
-
"internalType": "address"
|
|
741
|
+
"name": "markets",
|
|
742
|
+
"type": "address[]",
|
|
743
|
+
"internalType": "address[]"
|
|
513
744
|
},
|
|
514
745
|
{
|
|
515
|
-
"name": "
|
|
746
|
+
"name": "account",
|
|
516
747
|
"type": "address",
|
|
517
748
|
"internalType": "address"
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
"name": "long",
|
|
521
|
-
"type": "bool",
|
|
522
|
-
"internalType": "bool"
|
|
523
749
|
}
|
|
524
750
|
],
|
|
525
751
|
"outputs": [
|
|
526
752
|
{
|
|
527
|
-
"name": "
|
|
528
|
-
"type": "
|
|
529
|
-
"internalType": "
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
753
|
+
"name": "userMarkets",
|
|
754
|
+
"type": "tuple[]",
|
|
755
|
+
"internalType": "struct ProtocolReader.UserMarketSummary[]",
|
|
756
|
+
"components": [
|
|
757
|
+
{
|
|
758
|
+
"name": "_address",
|
|
759
|
+
"type": "address",
|
|
760
|
+
"internalType": "address"
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
"name": "collateral",
|
|
764
|
+
"type": "uint256",
|
|
765
|
+
"internalType": "uint256"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
"name": "maxDebt",
|
|
769
|
+
"type": "uint256",
|
|
770
|
+
"internalType": "uint256"
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
"name": "debt",
|
|
774
|
+
"type": "uint256",
|
|
775
|
+
"internalType": "uint256"
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
"name": "positionHealth",
|
|
779
|
+
"type": "uint256",
|
|
780
|
+
"internalType": "uint256"
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
"name": "cooldown",
|
|
784
|
+
"type": "uint256",
|
|
785
|
+
"internalType": "uint256"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"name": "errorCodeHit",
|
|
789
|
+
"type": "bool",
|
|
790
|
+
"internalType": "bool"
|
|
791
|
+
}
|
|
792
|
+
]
|
|
535
793
|
}
|
|
536
794
|
],
|
|
537
795
|
"stateMutability": "view"
|
|
@@ -634,40 +892,6 @@
|
|
|
634
892
|
],
|
|
635
893
|
"stateMutability": "view"
|
|
636
894
|
},
|
|
637
|
-
{
|
|
638
|
-
"type": "function",
|
|
639
|
-
"name": "getPriceSafely",
|
|
640
|
-
"inputs": [
|
|
641
|
-
{
|
|
642
|
-
"name": "asset",
|
|
643
|
-
"type": "address",
|
|
644
|
-
"internalType": "address"
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
"name": "inUSD",
|
|
648
|
-
"type": "bool",
|
|
649
|
-
"internalType": "bool"
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
"name": "getLower",
|
|
653
|
-
"type": "bool",
|
|
654
|
-
"internalType": "bool"
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
"name": "errorCodeBreakpoint",
|
|
658
|
-
"type": "uint256",
|
|
659
|
-
"internalType": "uint256"
|
|
660
|
-
}
|
|
661
|
-
],
|
|
662
|
-
"outputs": [
|
|
663
|
-
{
|
|
664
|
-
"name": "",
|
|
665
|
-
"type": "uint256",
|
|
666
|
-
"internalType": "uint256"
|
|
667
|
-
}
|
|
668
|
-
],
|
|
669
|
-
"stateMutability": "view"
|
|
670
|
-
},
|
|
671
895
|
{
|
|
672
896
|
"type": "function",
|
|
673
897
|
"name": "getStaticMarketData",
|