@defisaver/positions-sdk 1.0.3-dev → 1.0.3
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +69 -69
- package/cjs/curveUsd/index.js +1 -8
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/markets/compound/marketsAssets.js +1 -1
- package/cjs/markets/spark/marketAssets.js +1 -1
- package/cjs/types/curveUsd.d.ts +0 -1
- package/esm/curveUsd/index.js +3 -10
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/markets/compound/marketsAssets.js +1 -1
- package/esm/markets/spark/marketAssets.js +1 -1
- package/esm/types/curveUsd.d.ts +0 -1
- package/package.json +52 -52
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +625 -625
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +220 -220
- package/src/compoundV3/index.ts +291 -291
- package/src/config/contracts.js +1147 -1147
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +134 -134
- package/src/curveUsd/index.ts +230 -239
- package/src/eulerV2/index.ts +303 -303
- package/src/exchange/index.ts +17 -17
- package/src/fluid/index.ts +354 -354
- package/src/helpers/aaveHelpers/index.ts +198 -198
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +246 -246
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +232 -232
- package/src/helpers/fluidHelpers/index.ts +53 -53
- package/src/helpers/index.ts +11 -11
- package/src/helpers/liquityV2Helpers/index.ts +80 -80
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +365 -365
- package/src/helpers/sparkHelpers/index.ts +150 -150
- package/src/index.ts +52 -52
- package/src/liquity/index.ts +116 -116
- package/src/liquityV2/index.ts +295 -295
- package/src/llamaLend/index.ts +275 -275
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +152 -152
- package/src/markets/aave/marketAssets.ts +44 -44
- package/src/markets/compound/index.ts +213 -213
- package/src/markets/compound/marketsAssets.ts +82 -82
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2012 -2012
- package/src/markets/index.ts +27 -27
- package/src/markets/liquityV2/index.ts +54 -54
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +895 -895
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoAaveV2/index.ts +256 -256
- package/src/morphoAaveV3/index.ts +630 -630
- package/src/morphoBlue/index.ts +202 -202
- package/src/multicall/index.ts +33 -33
- package/src/services/priceService.ts +91 -91
- package/src/services/utils.ts +59 -59
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +460 -460
- package/src/staking/staking.ts +220 -220
- package/src/types/aave.ts +271 -271
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +131 -131
- package/src/types/curveUsd.ts +118 -119
- package/src/types/euler.ts +171 -171
- package/src/types/fluid.ts +266 -266
- package/src/types/index.ts +11 -11
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +119 -119
- package/src/types/llamaLend.ts +155 -155
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +192 -192
- package/src/types/spark.ts +131 -131
package/.mocharc.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"require": "ts-node/register",
|
|
3
|
-
"extension": ["ts"]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"require": "ts-node/register",
|
|
3
|
+
"extension": ["ts"]
|
|
4
|
+
}
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v20.17.0
|
|
1
|
+
v20.17.0
|
package/README.md
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
# DeFi Saver Positions SDK
|
|
2
|
-
|
|
3
|
-
Supported protocols:
|
|
4
|
-
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
-
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
-
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
-
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
-
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
-
- [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
|
|
10
|
-
- [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
|
|
11
|
-
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
12
|
-
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
13
|
-
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
14
|
-
- [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
|
|
15
|
-
|
|
16
|
-
## Setup
|
|
17
|
-
Supported Node version is v10.
|
|
18
|
-
|
|
19
|
-
- run `npm install` (first time)
|
|
20
|
-
- run `npm run build`
|
|
21
|
-
|
|
22
|
-
`build` command will generate contracts and build ejs and esm folders
|
|
23
|
-
|
|
24
|
-
## How to use
|
|
25
|
-
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
26
|
-
|
|
27
|
-
This is a Compound V3 example, and every other protocol is similar
|
|
28
|
-
```js
|
|
29
|
-
import Web3 from 'web3';
|
|
30
|
-
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// every protocol has market data and user data getters
|
|
34
|
-
const {
|
|
35
|
-
getCompoundV3MarketsData,
|
|
36
|
-
getCompoundV3AccountData,
|
|
37
|
-
} = compoundV3;
|
|
38
|
-
|
|
39
|
-
const provider = 'Your RPC provider';
|
|
40
|
-
const web3 = new Web3(provider);
|
|
41
|
-
|
|
42
|
-
const user = '0x123...';
|
|
43
|
-
|
|
44
|
-
const { assetsData } = await getCompoundV3MarketsData(
|
|
45
|
-
web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
46
|
-
1, // network
|
|
47
|
-
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
48
|
-
web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const userData = await getCompoundV3AccountData(
|
|
52
|
-
web3,
|
|
53
|
-
1, // network
|
|
54
|
-
userAddress, // EOA or DSProxy
|
|
55
|
-
'', // proxy address of the user, or just empty string if checking for EOA
|
|
56
|
-
{
|
|
57
|
-
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
58
|
-
assetsData,
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
64
|
-
|
|
65
|
-
## Testing
|
|
66
|
-
|
|
67
|
-
`npm run test` - Run all tests
|
|
68
|
-
|
|
69
|
-
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
|
1
|
+
# DeFi Saver Positions SDK
|
|
2
|
+
|
|
3
|
+
Supported protocols:
|
|
4
|
+
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
+
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
+
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
+
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
+
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
+
- [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
|
|
10
|
+
- [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
|
|
11
|
+
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
12
|
+
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
13
|
+
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
14
|
+
- [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
Supported Node version is v10.
|
|
18
|
+
|
|
19
|
+
- run `npm install` (first time)
|
|
20
|
+
- run `npm run build`
|
|
21
|
+
|
|
22
|
+
`build` command will generate contracts and build ejs and esm folders
|
|
23
|
+
|
|
24
|
+
## How to use
|
|
25
|
+
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
26
|
+
|
|
27
|
+
This is a Compound V3 example, and every other protocol is similar
|
|
28
|
+
```js
|
|
29
|
+
import Web3 from 'web3';
|
|
30
|
+
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// every protocol has market data and user data getters
|
|
34
|
+
const {
|
|
35
|
+
getCompoundV3MarketsData,
|
|
36
|
+
getCompoundV3AccountData,
|
|
37
|
+
} = compoundV3;
|
|
38
|
+
|
|
39
|
+
const provider = 'Your RPC provider';
|
|
40
|
+
const web3 = new Web3(provider);
|
|
41
|
+
|
|
42
|
+
const user = '0x123...';
|
|
43
|
+
|
|
44
|
+
const { assetsData } = await getCompoundV3MarketsData(
|
|
45
|
+
web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
46
|
+
1, // network
|
|
47
|
+
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
48
|
+
web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const userData = await getCompoundV3AccountData(
|
|
52
|
+
web3,
|
|
53
|
+
1, // network
|
|
54
|
+
userAddress, // EOA or DSProxy
|
|
55
|
+
'', // proxy address of the user, or just empty string if checking for EOA
|
|
56
|
+
{
|
|
57
|
+
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
58
|
+
assetsData,
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
64
|
+
|
|
65
|
+
## Testing
|
|
66
|
+
|
|
67
|
+
`npm run test` - Run all tests
|
|
68
|
+
|
|
69
|
+
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
package/cjs/curveUsd/index.js
CHANGED
|
@@ -79,11 +79,6 @@ const getCurveUsdGlobalData = (web3, network, selectedMarket) => __awaiter(void
|
|
|
79
79
|
abiItem: contract.options.jsonInterface.find(({ name }) => name === 'globalData'),
|
|
80
80
|
params: [selectedMarket.controllerAddress],
|
|
81
81
|
},
|
|
82
|
-
{
|
|
83
|
-
target: selectedMarket.controllerAddress,
|
|
84
|
-
abiItem: (0, utils_1.getAbiItem)((0, contracts_1.getConfigContractAbi)('crvUSDwstETHController'), 'loan_discount'),
|
|
85
|
-
params: [],
|
|
86
|
-
},
|
|
87
82
|
];
|
|
88
83
|
const multiRes = yield (0, multicall_1.multicall)(multicallData, web3, network);
|
|
89
84
|
const data = multiRes[2][0];
|
|
@@ -101,12 +96,10 @@ const getCurveUsdGlobalData = (web3, network, selectedMarket) => __awaiter(void
|
|
|
101
96
|
.toString();
|
|
102
97
|
const bandsData = yield getAndFormatBands(web3, network, selectedMarket, data.minBand, data.maxBand);
|
|
103
98
|
const leftToBorrow = new decimal_js_1.default(debtCeiling).minus(totalDebt).toString();
|
|
104
|
-
const loanDiscount = (0, tokens_1.assetAmountInEth)(multiRes[3][0], debtAsset);
|
|
105
99
|
return Object.assign(Object.assign({}, data), { debtCeiling,
|
|
106
100
|
totalDebt,
|
|
107
101
|
ammPrice, oraclePrice: (0, tokens_1.assetAmountInEth)(data.oraclePrice, debtAsset), basePrice: (0, tokens_1.assetAmountInEth)(data.basePrice, debtAsset), minted: (0, tokens_1.assetAmountInEth)(data.minted, debtAsset), redeemed: (0, tokens_1.assetAmountInEth)(data.redeemed, debtAsset), borrowRate,
|
|
108
|
-
futureBorrowRate, bands: bandsData, leftToBorrow
|
|
109
|
-
loanDiscount });
|
|
102
|
+
futureBorrowRate, bands: bandsData, leftToBorrow });
|
|
110
103
|
});
|
|
111
104
|
exports.getCurveUsdGlobalData = getCurveUsdGlobalData;
|
|
112
105
|
const getStatusForUser = (bandRange, activeBand, crvUSDSupplied, collSupplied, healthPercent) => {
|
|
@@ -115,73 +115,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, web3, network) =>
|
|
|
115
115
|
});
|
|
116
116
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
117
117
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
118
|
-
const MARKET_QUERY = `
|
|
119
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
120
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
121
|
-
reallocatableLiquidityAssets
|
|
122
|
-
targetBorrowUtilization
|
|
123
|
-
loanAsset {
|
|
124
|
-
address
|
|
125
|
-
decimals
|
|
126
|
-
priceUsd
|
|
127
|
-
}
|
|
128
|
-
state {
|
|
129
|
-
liquidityAssets
|
|
130
|
-
borrowAssets
|
|
131
|
-
supplyAssets
|
|
132
|
-
}
|
|
133
|
-
publicAllocatorSharedLiquidity {
|
|
134
|
-
assets
|
|
135
|
-
vault {
|
|
136
|
-
address
|
|
137
|
-
name
|
|
138
|
-
}
|
|
139
|
-
allocationMarket {
|
|
140
|
-
uniqueKey
|
|
141
|
-
loanAsset {
|
|
142
|
-
address
|
|
143
|
-
}
|
|
144
|
-
collateralAsset {
|
|
145
|
-
address
|
|
146
|
-
}
|
|
147
|
-
irmAddress
|
|
148
|
-
oracle {
|
|
149
|
-
address
|
|
150
|
-
}
|
|
151
|
-
lltv
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
loanAsset {
|
|
155
|
-
address
|
|
156
|
-
}
|
|
157
|
-
collateralAsset {
|
|
158
|
-
address
|
|
159
|
-
}
|
|
160
|
-
oracle {
|
|
161
|
-
address
|
|
162
|
-
}
|
|
163
|
-
irmAddress
|
|
164
|
-
lltv
|
|
165
|
-
}
|
|
166
|
-
}
|
|
118
|
+
const MARKET_QUERY = `
|
|
119
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
120
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
121
|
+
reallocatableLiquidityAssets
|
|
122
|
+
targetBorrowUtilization
|
|
123
|
+
loanAsset {
|
|
124
|
+
address
|
|
125
|
+
decimals
|
|
126
|
+
priceUsd
|
|
127
|
+
}
|
|
128
|
+
state {
|
|
129
|
+
liquidityAssets
|
|
130
|
+
borrowAssets
|
|
131
|
+
supplyAssets
|
|
132
|
+
}
|
|
133
|
+
publicAllocatorSharedLiquidity {
|
|
134
|
+
assets
|
|
135
|
+
vault {
|
|
136
|
+
address
|
|
137
|
+
name
|
|
138
|
+
}
|
|
139
|
+
allocationMarket {
|
|
140
|
+
uniqueKey
|
|
141
|
+
loanAsset {
|
|
142
|
+
address
|
|
143
|
+
}
|
|
144
|
+
collateralAsset {
|
|
145
|
+
address
|
|
146
|
+
}
|
|
147
|
+
irmAddress
|
|
148
|
+
oracle {
|
|
149
|
+
address
|
|
150
|
+
}
|
|
151
|
+
lltv
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
loanAsset {
|
|
155
|
+
address
|
|
156
|
+
}
|
|
157
|
+
collateralAsset {
|
|
158
|
+
address
|
|
159
|
+
}
|
|
160
|
+
oracle {
|
|
161
|
+
address
|
|
162
|
+
}
|
|
163
|
+
irmAddress
|
|
164
|
+
lltv
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
167
|
`;
|
|
168
|
-
const REWARDS_QUERY = `
|
|
169
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
170
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
171
|
-
uniqueKey
|
|
172
|
-
state {
|
|
173
|
-
rewards {
|
|
174
|
-
amountPerSuppliedToken
|
|
175
|
-
supplyApr
|
|
176
|
-
amountPerBorrowedToken
|
|
177
|
-
borrowApr
|
|
178
|
-
asset {
|
|
179
|
-
address
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
168
|
+
const REWARDS_QUERY = `
|
|
169
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
170
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
171
|
+
uniqueKey
|
|
172
|
+
state {
|
|
173
|
+
rewards {
|
|
174
|
+
amountPerSuppliedToken
|
|
175
|
+
supplyApr
|
|
176
|
+
amountPerBorrowedToken
|
|
177
|
+
borrowApr
|
|
178
|
+
asset {
|
|
179
|
+
address
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
185
|
`;
|
|
186
186
|
/**
|
|
187
187
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -27,7 +27,7 @@ exports.v3USDCeCollAssets = {
|
|
|
27
27
|
[common_1.NetworkNumber.Base]: [],
|
|
28
28
|
};
|
|
29
29
|
exports.v3ETHCollAssetsEth = ['cbETH', 'wstETH', 'rETH', 'rsETH', 'weETH', 'osETH', 'WBTC', 'ezETH', 'cbBTC', 'rswETH', 'tBTC', 'ETHx'];
|
|
30
|
-
exports.v3ETHCollAssetsBase = ['cbETH', 'ezETH', 'wstETH', 'USDC', 'weETH', 'wrsETH', 'cbBTC'];
|
|
30
|
+
exports.v3ETHCollAssetsBase = ['cbETH', 'ezETH', 'wstETH', 'USDC', 'weETH', 'wrsETH', 'cbBTC', 'wsuperOETHb'];
|
|
31
31
|
exports.v3ETHCollAssetsArb = ['weETH', 'rETH', 'wstETH', 'WBTC', 'rsETH', 'ezETH', 'USDC', 'USDT'];
|
|
32
32
|
exports.v3ETHCollAssetsOpt = ['rETH', 'wstETH', 'WBTC', 'ezETH', 'USDC', 'USDT', 'weETH', 'wrsETH'];
|
|
33
33
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sparkAssetsDefaultMarket = exports.sparkAssetsDefaultMarketEth = void 0;
|
|
4
4
|
const common_1 = require("../../types/common");
|
|
5
|
-
exports.sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS', 'USDS'];
|
|
5
|
+
exports.sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS', 'USDS', 'LBTC', 'tBTC', 'ezETH', 'rsETH'];
|
|
6
6
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
7
7
|
exports.sparkAssetsDefaultMarket = {
|
|
8
8
|
[common_1.NetworkNumber.Eth]: exports.sparkAssetsDefaultMarketEth,
|
package/cjs/types/curveUsd.d.ts
CHANGED
package/esm/curveUsd/index.js
CHANGED
|
@@ -12,10 +12,10 @@ import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
|
12
12
|
import { CrvUSDStatus, } from '../types';
|
|
13
13
|
import { multicall } from '../multicall';
|
|
14
14
|
import { NetworkNumber, } from '../types/common';
|
|
15
|
-
import { CrvUSDFactoryContract, CrvUSDViewContract
|
|
15
|
+
import { CrvUSDFactoryContract, CrvUSDViewContract } from '../contracts';
|
|
16
16
|
import { getCrvUsdAggregatedData } from '../helpers/curveUsdHelpers';
|
|
17
17
|
import { CrvUsdMarkets } from '../markets';
|
|
18
|
-
import {
|
|
18
|
+
import { wethToEth } from '../services/utils';
|
|
19
19
|
const getAndFormatBands = (web3, network, selectedMarket, _minBand, _maxBand) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
const contract = CrvUSDViewContract(web3, network);
|
|
21
21
|
const minBand = parseInt(_minBand, 10);
|
|
@@ -73,11 +73,6 @@ export const getCurveUsdGlobalData = (web3, network, selectedMarket) => __awaite
|
|
|
73
73
|
abiItem: contract.options.jsonInterface.find(({ name }) => name === 'globalData'),
|
|
74
74
|
params: [selectedMarket.controllerAddress],
|
|
75
75
|
},
|
|
76
|
-
{
|
|
77
|
-
target: selectedMarket.controllerAddress,
|
|
78
|
-
abiItem: getAbiItem(getConfigContractAbi('crvUSDwstETHController'), 'loan_discount'),
|
|
79
|
-
params: [],
|
|
80
|
-
},
|
|
81
76
|
];
|
|
82
77
|
const multiRes = yield multicall(multicallData, web3, network);
|
|
83
78
|
const data = multiRes[2][0];
|
|
@@ -95,12 +90,10 @@ export const getCurveUsdGlobalData = (web3, network, selectedMarket) => __awaite
|
|
|
95
90
|
.toString();
|
|
96
91
|
const bandsData = yield getAndFormatBands(web3, network, selectedMarket, data.minBand, data.maxBand);
|
|
97
92
|
const leftToBorrow = new Dec(debtCeiling).minus(totalDebt).toString();
|
|
98
|
-
const loanDiscount = assetAmountInEth(multiRes[3][0], debtAsset);
|
|
99
93
|
return Object.assign(Object.assign({}, data), { debtCeiling,
|
|
100
94
|
totalDebt,
|
|
101
95
|
ammPrice, oraclePrice: assetAmountInEth(data.oraclePrice, debtAsset), basePrice: assetAmountInEth(data.basePrice, debtAsset), minted: assetAmountInEth(data.minted, debtAsset), redeemed: assetAmountInEth(data.redeemed, debtAsset), borrowRate,
|
|
102
|
-
futureBorrowRate, bands: bandsData, leftToBorrow
|
|
103
|
-
loanDiscount });
|
|
96
|
+
futureBorrowRate, bands: bandsData, leftToBorrow });
|
|
104
97
|
});
|
|
105
98
|
const getStatusForUser = (bandRange, activeBand, crvUSDSupplied, collSupplied, healthPercent) => {
|
|
106
99
|
// if bands are equal, that can only be [0,0] which means user doesn't have loan (min number of bands is 4)
|
|
@@ -105,73 +105,73 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, web3, netwo
|
|
|
105
105
|
return { borrowRate, supplyRate };
|
|
106
106
|
});
|
|
107
107
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
108
|
-
const MARKET_QUERY = `
|
|
109
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
110
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
111
|
-
reallocatableLiquidityAssets
|
|
112
|
-
targetBorrowUtilization
|
|
113
|
-
loanAsset {
|
|
114
|
-
address
|
|
115
|
-
decimals
|
|
116
|
-
priceUsd
|
|
117
|
-
}
|
|
118
|
-
state {
|
|
119
|
-
liquidityAssets
|
|
120
|
-
borrowAssets
|
|
121
|
-
supplyAssets
|
|
122
|
-
}
|
|
123
|
-
publicAllocatorSharedLiquidity {
|
|
124
|
-
assets
|
|
125
|
-
vault {
|
|
126
|
-
address
|
|
127
|
-
name
|
|
128
|
-
}
|
|
129
|
-
allocationMarket {
|
|
130
|
-
uniqueKey
|
|
131
|
-
loanAsset {
|
|
132
|
-
address
|
|
133
|
-
}
|
|
134
|
-
collateralAsset {
|
|
135
|
-
address
|
|
136
|
-
}
|
|
137
|
-
irmAddress
|
|
138
|
-
oracle {
|
|
139
|
-
address
|
|
140
|
-
}
|
|
141
|
-
lltv
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
loanAsset {
|
|
145
|
-
address
|
|
146
|
-
}
|
|
147
|
-
collateralAsset {
|
|
148
|
-
address
|
|
149
|
-
}
|
|
150
|
-
oracle {
|
|
151
|
-
address
|
|
152
|
-
}
|
|
153
|
-
irmAddress
|
|
154
|
-
lltv
|
|
155
|
-
}
|
|
156
|
-
}
|
|
108
|
+
const MARKET_QUERY = `
|
|
109
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
110
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
111
|
+
reallocatableLiquidityAssets
|
|
112
|
+
targetBorrowUtilization
|
|
113
|
+
loanAsset {
|
|
114
|
+
address
|
|
115
|
+
decimals
|
|
116
|
+
priceUsd
|
|
117
|
+
}
|
|
118
|
+
state {
|
|
119
|
+
liquidityAssets
|
|
120
|
+
borrowAssets
|
|
121
|
+
supplyAssets
|
|
122
|
+
}
|
|
123
|
+
publicAllocatorSharedLiquidity {
|
|
124
|
+
assets
|
|
125
|
+
vault {
|
|
126
|
+
address
|
|
127
|
+
name
|
|
128
|
+
}
|
|
129
|
+
allocationMarket {
|
|
130
|
+
uniqueKey
|
|
131
|
+
loanAsset {
|
|
132
|
+
address
|
|
133
|
+
}
|
|
134
|
+
collateralAsset {
|
|
135
|
+
address
|
|
136
|
+
}
|
|
137
|
+
irmAddress
|
|
138
|
+
oracle {
|
|
139
|
+
address
|
|
140
|
+
}
|
|
141
|
+
lltv
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
loanAsset {
|
|
145
|
+
address
|
|
146
|
+
}
|
|
147
|
+
collateralAsset {
|
|
148
|
+
address
|
|
149
|
+
}
|
|
150
|
+
oracle {
|
|
151
|
+
address
|
|
152
|
+
}
|
|
153
|
+
irmAddress
|
|
154
|
+
lltv
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
157
|
`;
|
|
158
|
-
const REWARDS_QUERY = `
|
|
159
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
160
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
161
|
-
uniqueKey
|
|
162
|
-
state {
|
|
163
|
-
rewards {
|
|
164
|
-
amountPerSuppliedToken
|
|
165
|
-
supplyApr
|
|
166
|
-
amountPerBorrowedToken
|
|
167
|
-
borrowApr
|
|
168
|
-
asset {
|
|
169
|
-
address
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
158
|
+
const REWARDS_QUERY = `
|
|
159
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
160
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
161
|
+
uniqueKey
|
|
162
|
+
state {
|
|
163
|
+
rewards {
|
|
164
|
+
amountPerSuppliedToken
|
|
165
|
+
supplyApr
|
|
166
|
+
amountPerBorrowedToken
|
|
167
|
+
borrowApr
|
|
168
|
+
asset {
|
|
169
|
+
address
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
175
|
`;
|
|
176
176
|
/**
|
|
177
177
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -24,7 +24,7 @@ export const v3USDCeCollAssets = {
|
|
|
24
24
|
[NetworkNumber.Base]: [],
|
|
25
25
|
};
|
|
26
26
|
export const v3ETHCollAssetsEth = ['cbETH', 'wstETH', 'rETH', 'rsETH', 'weETH', 'osETH', 'WBTC', 'ezETH', 'cbBTC', 'rswETH', 'tBTC', 'ETHx'];
|
|
27
|
-
export const v3ETHCollAssetsBase = ['cbETH', 'ezETH', 'wstETH', 'USDC', 'weETH', 'wrsETH', 'cbBTC'];
|
|
27
|
+
export const v3ETHCollAssetsBase = ['cbETH', 'ezETH', 'wstETH', 'USDC', 'weETH', 'wrsETH', 'cbBTC', 'wsuperOETHb'];
|
|
28
28
|
export const v3ETHCollAssetsArb = ['weETH', 'rETH', 'wstETH', 'WBTC', 'rsETH', 'ezETH', 'USDC', 'USDT'];
|
|
29
29
|
export const v3ETHCollAssetsOpt = ['rETH', 'wstETH', 'WBTC', 'ezETH', 'USDC', 'USDT', 'weETH', 'wrsETH'];
|
|
30
30
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NetworkNumber } from '../../types/common';
|
|
2
|
-
export const sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS', 'USDS'];
|
|
2
|
+
export const sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS', 'USDS', 'LBTC', 'tBTC', 'ezETH', 'rsETH'];
|
|
3
3
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
4
4
|
export const sparkAssetsDefaultMarket = {
|
|
5
5
|
[NetworkNumber.Eth]: sparkAssetsDefaultMarketEth,
|