@defisaver/positions-sdk 1.0.11-fluid-dev11 → 1.0.11-fluid-dev13
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/config/contracts.d.ts +113 -53
- package/cjs/config/contracts.js +10 -0
- package/cjs/contracts.d.ts +1 -0
- package/cjs/contracts.js +2 -1
- package/cjs/fluid/index.js +80 -28
- package/cjs/helpers/fluidHelpers/index.js +21 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/markets/fluid/index.d.ts +0 -2
- package/cjs/markets/fluid/index.js +26 -24
- package/cjs/services/priceService.d.ts +2 -0
- package/cjs/services/priceService.js +13 -1
- package/cjs/types/contracts/generated/BTCPriceFeed.d.ts +135 -0
- package/cjs/types/contracts/generated/BTCPriceFeed.js +5 -0
- package/cjs/types/contracts/generated/index.d.ts +1 -0
- package/cjs/types/fluid.d.ts +4 -0
- package/esm/config/contracts.d.ts +113 -53
- package/esm/config/contracts.js +10 -0
- package/esm/contracts.d.ts +1 -0
- package/esm/contracts.js +1 -0
- package/esm/fluid/index.js +81 -29
- package/esm/helpers/fluidHelpers/index.js +21 -2
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/markets/fluid/index.d.ts +0 -2
- package/esm/markets/fluid/index.js +24 -21
- package/esm/services/priceService.d.ts +2 -0
- package/esm/services/priceService.js +11 -1
- package/esm/types/contracts/generated/BTCPriceFeed.d.ts +135 -0
- package/esm/types/contracts/generated/BTCPriceFeed.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +1 -0
- package/esm/types/fluid.d.ts +4 -0
- package/package.json +54 -54
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +624 -624
- 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 +1165 -1155
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +136 -135
- package/src/curveUsd/index.ts +239 -239
- package/src/eulerV2/index.ts +303 -303
- package/src/exchange/index.ts +17 -17
- package/src/fluid/index.ts +1320 -1261
- package/src/helpers/aaveHelpers/index.ts +203 -203
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +248 -248
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +234 -234
- package/src/helpers/fluidHelpers/index.ts +325 -294
- 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 +367 -367
- package/src/helpers/sparkHelpers/index.ts +154 -154
- 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 +46 -46
- 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 +2456 -2454
- 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 +143 -130
- 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 +217 -217
- package/src/types/aave.ts +275 -275
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +133 -133
- package/src/types/contracts/generated/BTCPriceFeed.ts +202 -0
- package/src/types/contracts/generated/index.ts +1 -0
- package/src/types/curveUsd.ts +119 -119
- package/src/types/euler.ts +173 -173
- package/src/types/fluid.ts +330 -325
- 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 +194 -194
- package/src/types/spark.ts +135 -135
package/cjs/fluid/index.js
CHANGED
|
@@ -47,6 +47,9 @@ const parseVaultType = (vaultType) => {
|
|
|
47
47
|
const getChainLinkPricesForTokens = (tokens, network, web3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
48
|
const isMainnet = (0, utils_1.isMainnetNetwork)(network);
|
|
49
49
|
const noDuplicateTokens = new Array(...new Set(tokens));
|
|
50
|
+
// TODO: this needs to be refactored
|
|
51
|
+
const ethPriceChainlink = yield (0, priceService_1.getEthPriceForFluid)(web3, network);
|
|
52
|
+
const btcPriceChainlink = yield (0, priceService_1.getBTCPriceForFluid)(web3, network);
|
|
50
53
|
const calls = noDuplicateTokens.flatMap((address) => {
|
|
51
54
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(address, network);
|
|
52
55
|
const isTokenUSDA = assetInfo.symbol === 'USDA';
|
|
@@ -86,6 +89,27 @@ const getChainLinkPricesForTokens = (tokens, network, web3) => __awaiter(void 0,
|
|
|
86
89
|
acc[token] = new decimal_js_1.default(ethPrice).mul(wstETHRate).toString();
|
|
87
90
|
break;
|
|
88
91
|
}
|
|
92
|
+
// TODO: These addresses do not have chainlink feeds, so we need to handle them separately, this is hotfix
|
|
93
|
+
case 'ezETH': {
|
|
94
|
+
acc[token] = new decimal_js_1.default(ethPriceChainlink).mul(1.049).toString();
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case 'rsETH': {
|
|
98
|
+
acc[token] = new decimal_js_1.default(ethPriceChainlink).mul(1.0454).toString();
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'weETHs': {
|
|
102
|
+
acc[token] = new decimal_js_1.default(ethPriceChainlink).mul(1.026).toString();
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case 'LBTC': {
|
|
106
|
+
acc[token] = new decimal_js_1.default(btcPriceChainlink).toString();
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'sUSDS': {
|
|
110
|
+
acc[token] = new decimal_js_1.default('105276929').toString();
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
89
113
|
case 'weETH': {
|
|
90
114
|
const { ethPrice, weETHRate, } = (0, priceService_1.parseWeETHPriceCalls)(prices[i + offset][0], prices[i + offset + 1], prices[i + offset + 2][0]);
|
|
91
115
|
offset += 2;
|
|
@@ -100,6 +124,9 @@ const getChainLinkPricesForTokens = (tokens, network, web3) => __awaiter(void 0,
|
|
|
100
124
|
}, {});
|
|
101
125
|
});
|
|
102
126
|
const getTokenPriceFromChainlink = (asset, network, web3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
+
if (asset.symbol === 'sUSDS') {
|
|
128
|
+
return new decimal_js_1.default('105276929').div(1e8).toString();
|
|
129
|
+
}
|
|
103
130
|
const isTokenUSDA = asset.symbol === 'USDA';
|
|
104
131
|
const isMainnet = (0, utils_1.isMainnetNetwork)(network);
|
|
105
132
|
const loanTokenFeedAddress = (0, priceService_1.getChainlinkAssetAddress)(asset.symbol, network);
|
|
@@ -120,6 +147,30 @@ const getTokenPriceFromChainlink = (asset, network, web3) => __awaiter(void 0, v
|
|
|
120
147
|
}
|
|
121
148
|
return new decimal_js_1.default(loanTokenPrice).div(1e8).toString();
|
|
122
149
|
});
|
|
150
|
+
const getMarketRateForDex = (token1PerShare, token0PerShare, rate0, rate1, price0, price1) => {
|
|
151
|
+
const token0PerShareUsd = new decimal_js_1.default(token0PerShare).mul(price0).toString();
|
|
152
|
+
const token1PerShareUsd = new decimal_js_1.default(token1PerShare).mul(price1).toString();
|
|
153
|
+
const sharesCombinedUsd = new decimal_js_1.default(token0PerShareUsd).plus(token1PerShareUsd);
|
|
154
|
+
const rate0PerShare = new decimal_js_1.default(rate0).mul(token0PerShareUsd).div(sharesCombinedUsd).toString();
|
|
155
|
+
const rate1PerShare = new decimal_js_1.default(rate1).mul(token1PerShareUsd).div(sharesCombinedUsd).toString();
|
|
156
|
+
return new decimal_js_1.default(rate0PerShare).plus(rate1PerShare).toString();
|
|
157
|
+
};
|
|
158
|
+
const getAdditionalMarketRateForDex = (token1PerShare, token0PerShare, incentiveSupplyRate0, incentiveSupplyRate1, price0, price1) => {
|
|
159
|
+
const token0PerShareUsd = new decimal_js_1.default(token0PerShare).mul(price0).toString();
|
|
160
|
+
const token1PerShareUsd = new decimal_js_1.default(token1PerShare).mul(price1).toString();
|
|
161
|
+
const sharesCombinedUsd = new decimal_js_1.default(token0PerShareUsd).plus(token1PerShareUsd);
|
|
162
|
+
const rate0PerShare = incentiveSupplyRate0 ? new decimal_js_1.default(incentiveSupplyRate0).mul(token0PerShareUsd).div(sharesCombinedUsd).toString() : 0;
|
|
163
|
+
const rate1PerShare = incentiveSupplyRate1 ? new decimal_js_1.default(incentiveSupplyRate1).mul(token1PerShareUsd).div(sharesCombinedUsd).toString() : 0;
|
|
164
|
+
return new decimal_js_1.default(rate0PerShare).plus(rate1PerShare).toString();
|
|
165
|
+
};
|
|
166
|
+
const getTradingApy = (poolAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
167
|
+
const res = yield fetch(`https://api.fluid.instadapp.io/v2/1/dexes/${poolAddress}/apy`);
|
|
168
|
+
if (!res.ok) {
|
|
169
|
+
return '0';
|
|
170
|
+
}
|
|
171
|
+
const data = yield res.json();
|
|
172
|
+
return new decimal_js_1.default(data.tradingApy).div(100).toString();
|
|
173
|
+
});
|
|
123
174
|
const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
175
|
const collAsset = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
125
176
|
const debtAsset = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
@@ -144,6 +195,7 @@ const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
144
195
|
collAssetData.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(collAsset.symbol, mainnetWeb3);
|
|
145
196
|
collAssetData.incentiveSupplyToken = collAsset.symbol;
|
|
146
197
|
}
|
|
198
|
+
const incentiveSupplyRate = collAssetData.incentiveSupplyApy;
|
|
147
199
|
const debtAssetData = {
|
|
148
200
|
symbol: debtAsset.symbol,
|
|
149
201
|
address: debtAsset.address,
|
|
@@ -159,10 +211,7 @@ const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
159
211
|
debtAssetData.incentiveBorrowApy = yield (0, staking_1.getStakingApy)(debtAsset.symbol, mainnetWeb3);
|
|
160
212
|
debtAssetData.incentiveBorrowToken = debtAsset.symbol;
|
|
161
213
|
}
|
|
162
|
-
|
|
163
|
-
debtAssetData.incentiveBorrowApy = yield (0, staking_1.getStakingApy)(debtAsset.symbol, mainnetWeb3);
|
|
164
|
-
debtAssetData.incentiveBorrowToken = debtAsset.symbol;
|
|
165
|
-
}
|
|
214
|
+
const incentiveBorrowRate = debtAssetData.incentiveBorrowApy;
|
|
166
215
|
const assetsData = {
|
|
167
216
|
[collAsset.symbol]: collAssetData,
|
|
168
217
|
[debtAsset.symbol]: debtAssetData,
|
|
@@ -206,6 +255,8 @@ const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
206
255
|
liquidationMaxLimit,
|
|
207
256
|
borrowRate,
|
|
208
257
|
supplyRate,
|
|
258
|
+
incentiveSupplyRate,
|
|
259
|
+
incentiveBorrowRate,
|
|
209
260
|
oraclePrice,
|
|
210
261
|
};
|
|
211
262
|
return {
|
|
@@ -213,19 +264,6 @@ const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
213
264
|
marketData,
|
|
214
265
|
};
|
|
215
266
|
});
|
|
216
|
-
const getMarketRateForDex = (token1PerShare, token0PerShare, rate0, rate1) => {
|
|
217
|
-
const sharesCombined = new decimal_js_1.default(token1PerShare).plus(token0PerShare);
|
|
218
|
-
const rate0PerShare = new decimal_js_1.default(rate0).mul(token0PerShare).div(sharesCombined).toString();
|
|
219
|
-
const rate1PerShare = new decimal_js_1.default(rate1).mul(token1PerShare).div(sharesCombined).toString();
|
|
220
|
-
return new decimal_js_1.default(rate0PerShare).plus(rate1PerShare).toString();
|
|
221
|
-
};
|
|
222
|
-
const getAdditionalMarketRateForDex = (token1PerShare, token0PerShare, incentiveSupplyRate0, incentiveSupplyRate1) => {
|
|
223
|
-
console.log(incentiveSupplyRate0, incentiveSupplyRate1);
|
|
224
|
-
const sharesCombined = new decimal_js_1.default(token1PerShare).plus(token0PerShare);
|
|
225
|
-
const rate0PerShare = incentiveSupplyRate0 ? new decimal_js_1.default(incentiveSupplyRate0).mul(token0PerShare).div(sharesCombined).toString() : 0;
|
|
226
|
-
const rate1PerShare = incentiveSupplyRate1 ? new decimal_js_1.default(incentiveSupplyRate1).mul(token1PerShare).div(sharesCombined).toString() : 0;
|
|
227
|
-
return new decimal_js_1.default(rate0PerShare).plus(rate1PerShare).toString();
|
|
228
|
-
};
|
|
229
267
|
const parseT2MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
230
268
|
const collAsset0 = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
231
269
|
const collAsset1 = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken1, network);
|
|
@@ -268,8 +306,9 @@ const parseT2MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
268
306
|
collSecondAssetData.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(collAsset1.symbol, mainnetWeb3);
|
|
269
307
|
collSecondAssetData.incentiveSupplyToken = collAsset1.symbol;
|
|
270
308
|
}
|
|
271
|
-
const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1);
|
|
272
|
-
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collFirstAssetData.incentiveSupplyApy, collSecondAssetData.incentiveSupplyApy);
|
|
309
|
+
const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1, collFirstAssetData.price, collSecondAssetData.price);
|
|
310
|
+
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collFirstAssetData.incentiveSupplyApy, collSecondAssetData.incentiveSupplyApy, collFirstAssetData.price, collSecondAssetData.price);
|
|
311
|
+
const tradingSupplyRate = yield getTradingApy(data.dexSupplyData.dexPool);
|
|
273
312
|
const borrowRate = new decimal_js_1.default(data.borrowRateVault).div(100).toString();
|
|
274
313
|
const debtAssetData = {
|
|
275
314
|
symbol: debtAsset.symbol,
|
|
@@ -283,6 +322,7 @@ const parseT2MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
283
322
|
debtAssetData.incentiveBorrowApy = yield (0, staking_1.getStakingApy)(debtAsset.symbol, mainnetWeb3);
|
|
284
323
|
debtAssetData.incentiveBorrowToken = debtAsset.symbol;
|
|
285
324
|
}
|
|
325
|
+
const incentiveBorrowRate = debtAssetData.incentiveBorrowApy;
|
|
286
326
|
const assetsData = [
|
|
287
327
|
[collAsset0.symbol, collFirstAssetData],
|
|
288
328
|
[collAsset1.symbol, collSecondAssetData],
|
|
@@ -332,17 +372,20 @@ const parseT2MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
332
372
|
borrowRate,
|
|
333
373
|
supplyRate: marketSupplyRate,
|
|
334
374
|
incentiveSupplyRate,
|
|
375
|
+
incentiveBorrowRate,
|
|
335
376
|
totalSupplyToken0,
|
|
336
377
|
totalSupplyToken1,
|
|
337
378
|
withdrawableToken0,
|
|
338
379
|
withdrawableToken1,
|
|
339
380
|
withdrawableUSD,
|
|
340
381
|
withdrawable: withdrawableShares,
|
|
341
|
-
|
|
382
|
+
withdrawableDex: new decimal_js_1.default(maxSupplyShares).minus(totalSupplyShares).toString(),
|
|
342
383
|
maxSupplyShares,
|
|
343
384
|
maxSupplySharesUsd,
|
|
344
385
|
collDexFee: supplyDexFee,
|
|
345
386
|
oraclePrice,
|
|
387
|
+
tradingSupplyRate,
|
|
388
|
+
tradingBorrowRate: '0',
|
|
346
389
|
};
|
|
347
390
|
return {
|
|
348
391
|
assetsData,
|
|
@@ -372,6 +415,7 @@ const parseT3MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
372
415
|
collAssetData.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(collAsset.symbol, mainnetWeb3);
|
|
373
416
|
collAssetData.incentiveSupplyToken = collAsset.symbol;
|
|
374
417
|
}
|
|
418
|
+
const incentiveSupplyRate = collAssetData.incentiveSupplyApy;
|
|
375
419
|
const debtAsset0Data = {
|
|
376
420
|
symbol: debtAsset0.symbol,
|
|
377
421
|
address: debtAsset0.address,
|
|
@@ -404,8 +448,9 @@ const parseT3MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
404
448
|
debtAsset1Data.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(debtAsset1.symbol, mainnetWeb3);
|
|
405
449
|
debtAsset1Data.incentiveSupplyToken = debtAsset1.symbol;
|
|
406
450
|
}
|
|
407
|
-
const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1);
|
|
408
|
-
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.incentiveSupplyApy, debtAsset1Data.incentiveSupplyApy);
|
|
451
|
+
const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1, debtAsset0Data.price, debtAsset1Data.price);
|
|
452
|
+
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.incentiveSupplyApy, debtAsset1Data.incentiveSupplyApy, debtAsset0Data.price, debtAsset1Data.price);
|
|
453
|
+
const tradingBorrowRate = yield getTradingApy(data.dexBorrowData.dexPool);
|
|
409
454
|
const assetsData = [
|
|
410
455
|
[collAsset.symbol, collAssetData],
|
|
411
456
|
[debtAsset0.symbol, debtAsset0Data],
|
|
@@ -450,6 +495,9 @@ const parseT3MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
450
495
|
borrowRate: marketBorrowRate,
|
|
451
496
|
supplyRate,
|
|
452
497
|
incentiveBorrowRate,
|
|
498
|
+
incentiveSupplyRate,
|
|
499
|
+
tradingBorrowRate,
|
|
500
|
+
tradingSupplyRate: '0',
|
|
453
501
|
borrowableToken0,
|
|
454
502
|
borrowableToken1,
|
|
455
503
|
totalBorrowToken0,
|
|
@@ -545,10 +593,13 @@ const parseT4MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
545
593
|
debtAsset1Data.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(debtAsset1.symbol, mainnetWeb3);
|
|
546
594
|
debtAsset1Data.incentiveSupplyToken = debtAsset1.symbol;
|
|
547
595
|
}
|
|
548
|
-
const
|
|
549
|
-
const
|
|
550
|
-
const
|
|
551
|
-
const
|
|
596
|
+
const marketInfo = (0, markets_1.getFluidMarketInfoById)(+data.vaultId, network);
|
|
597
|
+
const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1, debtAsset0Data.price, debtAsset1Data.price);
|
|
598
|
+
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.incentiveSupplyApy, debtAsset1Data.incentiveSupplyApy, debtAsset0Data.price, debtAsset1Data.price);
|
|
599
|
+
const tradingBorrowRate = yield getTradingApy(data.dexBorrowData.dexPool);
|
|
600
|
+
const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1, collAsset0Data.price, collAsset1Data.price);
|
|
601
|
+
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collAsset0Data.incentiveSupplyApy, collAsset1Data.incentiveSupplyApy, collAsset0Data.price, collAsset1Data.price);
|
|
602
|
+
const tradingSupplyRate = yield getTradingApy(data.dexSupplyData.dexPool);
|
|
552
603
|
const assetsData = [
|
|
553
604
|
[collAsset0.symbol, collAsset0Data],
|
|
554
605
|
[collAsset1.symbol, collAsset1Data],
|
|
@@ -556,7 +607,6 @@ const parseT4MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
556
607
|
[debtAsset1.symbol, debtAsset1Data],
|
|
557
608
|
]
|
|
558
609
|
.reduce((acc, [symbol, partialData]) => (Object.assign(Object.assign({}, acc), { [symbol]: (0, fluidHelpers_1.mergeAssetData)(acc[symbol], partialData) })), {});
|
|
559
|
-
const marketInfo = (0, markets_1.getFluidMarketInfoById)(+data.vaultId, network);
|
|
560
610
|
const liqRatio = new decimal_js_1.default(data.liquidationThreshold).div(100).toString();
|
|
561
611
|
const liquidationMaxLimit = new decimal_js_1.default(data.liquidationMaxLimit).div(100).toString();
|
|
562
612
|
const liqFactor = new decimal_js_1.default(data.liquidationThreshold).div(10000).toString();
|
|
@@ -613,13 +663,15 @@ const parseT4MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
|
|
|
613
663
|
withdrawableToken1,
|
|
614
664
|
withdrawableUSD,
|
|
615
665
|
withdrawable: withdrawableShares,
|
|
616
|
-
|
|
666
|
+
withdrawableDex: new decimal_js_1.default(maxSupplyShares).minus(totalSupplyShares).toString(),
|
|
617
667
|
maxSupplyShares,
|
|
618
668
|
maxSupplySharesUsd,
|
|
619
669
|
collDexFee: supplyDexFee,
|
|
620
670
|
collSharePrice,
|
|
621
671
|
debtSharePrice,
|
|
622
672
|
oraclePrice,
|
|
673
|
+
tradingBorrowRate,
|
|
674
|
+
tradingSupplyRate,
|
|
623
675
|
};
|
|
624
676
|
return {
|
|
625
677
|
assetsData,
|
|
@@ -10,6 +10,24 @@ const types_1 = require("../../types");
|
|
|
10
10
|
const moneymarket_1 = require("../../moneymarket");
|
|
11
11
|
const staking_1 = require("../../staking");
|
|
12
12
|
const utils_1 = require("../../services/utils");
|
|
13
|
+
const calculateNetApyDex = ({ marketData, suppliedUsd, borrowedUsd }) => {
|
|
14
|
+
const { borrowRate, supplyRate, incentiveBorrowRate, incentiveSupplyRate, tradingBorrowRate, tradingSupplyRate, } = marketData;
|
|
15
|
+
const totalBorrowRate = new decimal_js_1.default(borrowRate).minus(tradingBorrowRate || '0').toString();
|
|
16
|
+
const totalSupplyRate = new decimal_js_1.default(supplyRate).add(tradingSupplyRate || '0').toString();
|
|
17
|
+
const borrowIncentive = new decimal_js_1.default(incentiveBorrowRate || '0').mul(borrowedUsd).div(100).toString();
|
|
18
|
+
const supplyIncentive = new decimal_js_1.default(incentiveSupplyRate || '0').mul(suppliedUsd).div(100).toString();
|
|
19
|
+
const incentiveUsd = new decimal_js_1.default(supplyIncentive).minus(borrowIncentive).toString();
|
|
20
|
+
const borrowInterest = new decimal_js_1.default(totalBorrowRate).mul(borrowedUsd).div(100).toString();
|
|
21
|
+
const supplyInterest = new decimal_js_1.default(totalSupplyRate).mul(suppliedUsd).div(100).toString();
|
|
22
|
+
const totalInterestUsd = new decimal_js_1.default(supplyInterest).add(incentiveUsd).minus(borrowInterest).toString();
|
|
23
|
+
const balance = new decimal_js_1.default(suppliedUsd).sub(borrowedUsd).toString();
|
|
24
|
+
const netApy = new decimal_js_1.default(totalInterestUsd).div(balance).times(100).toString();
|
|
25
|
+
return {
|
|
26
|
+
netApy,
|
|
27
|
+
incentiveUsd,
|
|
28
|
+
totalInterestUsd,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
13
31
|
const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, }, supplyShares, borrowShares) => {
|
|
14
32
|
const payload = {};
|
|
15
33
|
payload.suppliedUsd = [types_1.FluidVaultType.T1, types_1.FluidVaultType.T3].includes(marketData.vaultType)
|
|
@@ -18,7 +36,8 @@ const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, }, supplyS
|
|
|
18
36
|
payload.borrowedUsd = [types_1.FluidVaultType.T1, types_1.FluidVaultType.T2].includes(marketData.vaultType)
|
|
19
37
|
? (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd)
|
|
20
38
|
: new decimal_js_1.default(marketData.debtSharePrice).mul(borrowShares).toString();
|
|
21
|
-
const
|
|
39
|
+
const isDex = [types_1.FluidVaultType.T2, types_1.FluidVaultType.T3, types_1.FluidVaultType.T4].includes(marketData.vaultType);
|
|
40
|
+
const { netApy, incentiveUsd, totalInterestUsd } = isDex ? calculateNetApyDex({ marketData, suppliedUsd: payload.suppliedUsd, borrowedUsd: payload.borrowedUsd }) : (0, staking_1.calculateNetApy)({ usedAssets, assetsData: assetsData });
|
|
22
41
|
payload.netApy = netApy;
|
|
23
42
|
payload.incentiveUsd = incentiveUsd;
|
|
24
43
|
payload.totalInterestUsd = totalInterestUsd;
|
|
@@ -51,7 +70,7 @@ exports.getFluidAggregatedData = getFluidAggregatedData;
|
|
|
51
70
|
const parseDexSupplyData = (dexSupplyData, collAsset0, collAsset1) => {
|
|
52
71
|
const { dexPool, // address of the dex pool
|
|
53
72
|
dexId, // id of the dex pool
|
|
54
|
-
fee: _fee, // fee of the dex pool
|
|
73
|
+
fee: _fee, // fee of the dex pool (Only used as swap fees)
|
|
55
74
|
lastStoredPrice, // last stored price of the dex pool
|
|
56
75
|
centerPrice, // center price of the dex pool
|
|
57
76
|
token0Utilization, // token0 utilization
|
|
@@ -117,73 +117,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, web3, network) =>
|
|
|
117
117
|
});
|
|
118
118
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
119
119
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
120
|
-
const MARKET_QUERY = `
|
|
121
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
122
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
123
|
-
reallocatableLiquidityAssets
|
|
124
|
-
targetBorrowUtilization
|
|
125
|
-
loanAsset {
|
|
126
|
-
address
|
|
127
|
-
decimals
|
|
128
|
-
priceUsd
|
|
129
|
-
}
|
|
130
|
-
state {
|
|
131
|
-
liquidityAssets
|
|
132
|
-
borrowAssets
|
|
133
|
-
supplyAssets
|
|
134
|
-
}
|
|
135
|
-
publicAllocatorSharedLiquidity {
|
|
136
|
-
assets
|
|
137
|
-
vault {
|
|
138
|
-
address
|
|
139
|
-
name
|
|
140
|
-
}
|
|
141
|
-
allocationMarket {
|
|
142
|
-
uniqueKey
|
|
143
|
-
loanAsset {
|
|
144
|
-
address
|
|
145
|
-
}
|
|
146
|
-
collateralAsset {
|
|
147
|
-
address
|
|
148
|
-
}
|
|
149
|
-
irmAddress
|
|
150
|
-
oracle {
|
|
151
|
-
address
|
|
152
|
-
}
|
|
153
|
-
lltv
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
loanAsset {
|
|
157
|
-
address
|
|
158
|
-
}
|
|
159
|
-
collateralAsset {
|
|
160
|
-
address
|
|
161
|
-
}
|
|
162
|
-
oracle {
|
|
163
|
-
address
|
|
164
|
-
}
|
|
165
|
-
irmAddress
|
|
166
|
-
lltv
|
|
167
|
-
}
|
|
168
|
-
}
|
|
120
|
+
const MARKET_QUERY = `
|
|
121
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
122
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
123
|
+
reallocatableLiquidityAssets
|
|
124
|
+
targetBorrowUtilization
|
|
125
|
+
loanAsset {
|
|
126
|
+
address
|
|
127
|
+
decimals
|
|
128
|
+
priceUsd
|
|
129
|
+
}
|
|
130
|
+
state {
|
|
131
|
+
liquidityAssets
|
|
132
|
+
borrowAssets
|
|
133
|
+
supplyAssets
|
|
134
|
+
}
|
|
135
|
+
publicAllocatorSharedLiquidity {
|
|
136
|
+
assets
|
|
137
|
+
vault {
|
|
138
|
+
address
|
|
139
|
+
name
|
|
140
|
+
}
|
|
141
|
+
allocationMarket {
|
|
142
|
+
uniqueKey
|
|
143
|
+
loanAsset {
|
|
144
|
+
address
|
|
145
|
+
}
|
|
146
|
+
collateralAsset {
|
|
147
|
+
address
|
|
148
|
+
}
|
|
149
|
+
irmAddress
|
|
150
|
+
oracle {
|
|
151
|
+
address
|
|
152
|
+
}
|
|
153
|
+
lltv
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
loanAsset {
|
|
157
|
+
address
|
|
158
|
+
}
|
|
159
|
+
collateralAsset {
|
|
160
|
+
address
|
|
161
|
+
}
|
|
162
|
+
oracle {
|
|
163
|
+
address
|
|
164
|
+
}
|
|
165
|
+
irmAddress
|
|
166
|
+
lltv
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
169
|
`;
|
|
170
|
-
const REWARDS_QUERY = `
|
|
171
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
172
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
173
|
-
uniqueKey
|
|
174
|
-
state {
|
|
175
|
-
rewards {
|
|
176
|
-
amountPerSuppliedToken
|
|
177
|
-
supplyApr
|
|
178
|
-
amountPerBorrowedToken
|
|
179
|
-
borrowApr
|
|
180
|
-
asset {
|
|
181
|
-
address
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
170
|
+
const REWARDS_QUERY = `
|
|
171
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
172
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
173
|
+
uniqueKey
|
|
174
|
+
state {
|
|
175
|
+
rewards {
|
|
176
|
+
amountPerSuppliedToken
|
|
177
|
+
supplyApr
|
|
178
|
+
amountPerBorrowedToken
|
|
179
|
+
borrowApr
|
|
180
|
+
asset {
|
|
181
|
+
address
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
187
|
`;
|
|
188
188
|
/**
|
|
189
189
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -95,7 +95,6 @@ export declare const FLUID_ETH_USDC_USDT_23_ARB: (networkId?: NetworkNumber) =>
|
|
|
95
95
|
export declare const FLUID_WSTETH_USDC_USDT_24_ARB: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
96
96
|
export declare const FLUID_WEETH_USDC_USDT_25_ARB: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
97
97
|
export declare const FLUID_WBTC_USDC_USDT_26_ARB: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
98
|
-
export declare const FLUID_SUSDS_USDC_USDT_30_ARB: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
99
98
|
export declare const FLUID_ETH_USDC_1_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
100
99
|
export declare const FLUID_WSTETH_USDC_2_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
101
100
|
export declare const FLUID_WSTETH_ETH_3_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
@@ -213,7 +212,6 @@ export declare const FluidMarkets: (networkId: NetworkNumber) => {
|
|
|
213
212
|
FLUID_WSTETH_USDC_USDT_24_ARB: FluidMarketInfo;
|
|
214
213
|
FLUID_WEETH_USDC_USDT_25_ARB: FluidMarketInfo;
|
|
215
214
|
FLUID_WBTC_USDC_USDT_26_ARB: FluidMarketInfo;
|
|
216
|
-
FLUID_SUSDS_USDC_USDT_30_ARB: FluidMarketInfo;
|
|
217
215
|
FLUID_ETH_USDC_1_BASE: FluidMarketInfo;
|
|
218
216
|
FLUID_WSTETH_USDC_2_BASE: FluidMarketInfo;
|
|
219
217
|
FLUID_WSTETH_ETH_3_BASE: FluidMarketInfo;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FLUID_CBBTC_GHO_60 = exports.FLUID_WBTC_GHO_59 = exports.FLUID_SUSDS_GHO_58 = exports.FLUID_WEETH_GHO_57 = exports.FLUID_SUSDE_GHO_56 = exports.FLUID_WSTETH_GHO_55 = exports.FLUID_ETH_GHO_54 = exports.FLUID_WBTC_CBBTC_USDT_53 = exports.FLUID_WBTC_CBBTC_USDC_52 = exports.FLUID_WBTC_CBBTC_WBTC_CBBTC_51 = exports.FLUID_SUSDE_USDC_USDT_50 = exports.FLUID_CBBTC_USDC_USDT_49 = exports.FLUID_WBTC_USDC_USDT_48 = exports.FLUID_WEETH_USDC_USDT_47 = exports.FLUID_WSTETH_USDC_USDT_46 = exports.FLUID_ETH_USDC_USDT_45 = exports.FLUID_WSTETH_ETH_WSTETH_ETH_44 = exports.FLUID_WEETH_CBBTC_32 = exports.FLUID_WSTETH_CBBTC_33 = exports.FLUID_ETH_CBBTC_31 = exports.FLUID_CBBTC_USDT_30 = exports.FLUID_CBBTC_USDC_29 = exports.FLUID_CBBTC_ETH_28 = exports.FLUID_WEETHS_WSTETH_27 = exports.FLUID_WEETH_WBTC_26 = exports.FLUID_WSTETH_WBTC_25 = exports.FLUID_ETH_WBTC_24 = exports.FLUID_WBTC_ETH_23 = exports.FLUID_WBTC_USDT_22 = exports.FLUID_WBTC_USDC_21 = exports.FLUID_WEETH_USDT_20 = exports.FLUID_WEETH_USDC_19 = exports.FLUID_SUSDE_USDT_18 = exports.FLUID_SUSDE_USDC_17 = exports.FLUID_WEETH_WSTETH_16 = exports.FLUID_WSTETH_USDT_15 = exports.FLUID_WSTETH_USDC_14 = exports.FLUID_WSTETH_ETH_13 = exports.FLUID_ETH_USDT_12 = exports.FLUID_ETH_USDC_11 = exports.FLUID_WEETH_USDT_10 = exports.FLUID_WEETH_USDC_9 = exports.FLUID_SUSDE_USDT_8 = exports.FLUID_SUSDE_USDC_7 = exports.FLUID_WEETH_WSTETH_6 = exports.FLUID_WSTETH_USDT_5 = exports.FLUID_WSTETH_USDC_4 = exports.FLUID_WSTETH_ETH_3 = exports.FLUID_ETH_USDT_2 = exports.FLUID_ETH_USDC_1 = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.getFTokenAddress = exports.FluidFTokens = exports.getFluidMarketInfoByAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.FLUID_LBTC_SUSDS_22_BASE = exports.FLUID_LBTC_USDC_21_BASE = exports.FLUID_CBBTC_SUSDS_19_BASE = exports.FLUID_WSTETH_SUSDS_18_BASE = exports.FLUID_ETH_SUSDS_17_BASE = exports.FLUID_WSTETH_CBBTC_16_BASE = exports.FLUID_WEETH_CBBTC_15_BASE = exports.FLUID_ETH_CBBTC_14_BASE = exports.FLUID_CBBTC_ETH_13_BASE = exports.FLUID_WSTETH_EURC_12_BASE = exports.FLUID_WEETH_EURC_11_BASE = exports.FLUID_ETH_EURC_10_BASE = exports.FLUID_CBETH_EURC_9_BASE = exports.FLUID_CBBTC_EURC_8_BASE = exports.FLUID_CBBTC_USDC_7_BASE = exports.FLUID_CBETH_USDC_6_BASE =
|
|
4
|
+
exports.FLUID_WEETH_USDC_5_BASE = exports.FLUID_WEETH_WSTETH_4_BASE = exports.FLUID_WSTETH_ETH_3_BASE = exports.FLUID_WSTETH_USDC_2_BASE = exports.FLUID_ETH_USDC_1_BASE = exports.FLUID_WBTC_USDC_USDT_26_ARB = exports.FLUID_WEETH_USDC_USDT_25_ARB = exports.FLUID_WSTETH_USDC_USDT_24_ARB = exports.FLUID_ETH_USDC_USDT_23_ARB = exports.FLUID_USDC_ETH_USDC_ETH_22_ARB = exports.FLUID_WEETH_WBTC_21_ARB = exports.FLUID_WSTETH_WBTC_20_ARB = exports.FLUID_ETH_WBTC_19_ARB = exports.FLUID_WBTC_ETH_18_ARB = exports.FLUID_WEETH_ETH_WSTETH_17_ARB = exports.FLUID_WSTETH_ETH_WSTETH_ETH_16_ARB = exports.FLUID_WBTC_USDT_13_ARB = exports.FLUID_WBTC_USDC_12_ARB = exports.FLUID_ARB_USDT_11_ARB = exports.FLUID_ARB_USDC_10_ARB = exports.FLUID_ETH_ARB_9_ARB = exports.FLUID_WEETH_USDT_8_ARB = exports.FLUID_WEETH_USDC_7_ARB = exports.FLUID_WEETH_WSTETH_6_ARB = exports.FLUID_WSTETH_ETH_5_ARB = exports.FLUID_WSTETH_USDT_4_ARB = exports.FLUID_WSTETH_USDC_3_ARB = exports.FLUID_ETH_USDT_2_ARB = exports.FLUID_ETH_USDC_1_ARB = exports.FLUID_WBTC_LBTC_WBTC_115 = exports.FLUID_LBTC_CBBTC_CBBTC_114 = exports.FLUID_LBTC_GHO_109 = exports.FLUID_LBTC_USDT_108 = exports.FLUID_LBTC_USDC_107 = exports.FLUID_EZETH_ETH_WSTETH_104 = exports.FLUID_EZETH_WSTETH_103 = exports.FLUID_USDC_CBBTC_102 = exports.FLUID_USDC_WBTC_101 = exports.FLUID_USDC_ETH_100 = exports.FLUID_USDE_USDT_USDC_USDT_99 = exports.FLUID_SUSDE_USDT_USDC_USDT_98 = exports.FLUID_LBTC_CBBTC_WBTC_97 = exports.FLUID_USDE_USDT_USDT_93 = exports.FLUID_SUSDE_USDT_USDT_92 = exports.FLUID_WEETHS_ETH_WSTETH_80 = exports.FLUID_RSETH_WSTETH_79 = exports.FLUID_RSETH_ETH_WSTETH_78 = exports.FLUID_USDC_ETH_USDC_ETH_77 = exports.FLUID_WEETH_ETH_WSTETH_74 = exports.FLUID_GHO_USDC_GHO_USDC_61 = void 0;
|
|
5
|
+
exports.getFTokenAddress = exports.FluidFTokens = exports.getFluidMarketInfoByAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.FLUID_LBTC_SUSDS_22_BASE = exports.FLUID_LBTC_USDC_21_BASE = exports.FLUID_CBBTC_SUSDS_19_BASE = exports.FLUID_WSTETH_SUSDS_18_BASE = exports.FLUID_ETH_SUSDS_17_BASE = exports.FLUID_WSTETH_CBBTC_16_BASE = exports.FLUID_WEETH_CBBTC_15_BASE = exports.FLUID_ETH_CBBTC_14_BASE = exports.FLUID_CBBTC_ETH_13_BASE = exports.FLUID_WSTETH_EURC_12_BASE = exports.FLUID_WEETH_EURC_11_BASE = exports.FLUID_ETH_EURC_10_BASE = exports.FLUID_CBETH_EURC_9_BASE = exports.FLUID_CBBTC_EURC_8_BASE = exports.FLUID_CBBTC_USDC_7_BASE = exports.FLUID_CBETH_USDC_6_BASE = void 0;
|
|
6
6
|
const common_1 = require("../../types/common");
|
|
7
7
|
const types_1 = require("../../types");
|
|
8
8
|
const utils_1 = require("../../services/utils");
|
|
@@ -1859,26 +1859,28 @@ const FLUID_WBTC_USDC_USDT_26_ARB = (networkId = common_1.NetworkNumber.Eth) =>
|
|
|
1859
1859
|
debtAsset1: 'USDT',
|
|
1860
1860
|
});
|
|
1861
1861
|
exports.FLUID_WBTC_USDC_USDT_26_ARB = FLUID_WBTC_USDC_USDT_26_ARB;
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1862
|
+
// TODO: This issue is due to sUSDS price fetching via multicall on arbi fails and it's not handled correctly
|
|
1863
|
+
/*
|
|
1864
|
+
export const FLUID_SUSDS_USDC_USDT_30_ARB = (networkId: NetworkNumber = NetworkNumber.Eth): FluidMarketInfo => ({
|
|
1865
|
+
stableBased: true,
|
|
1866
|
+
btcBased: false,
|
|
1867
|
+
wstETHBased: false,
|
|
1868
|
+
ethBased: false,
|
|
1869
|
+
type: FluidVaultType.T3,
|
|
1870
|
+
id: 30,
|
|
1871
|
+
chainIds: [NetworkNumber.Arb],
|
|
1872
|
+
label: '#30 (sUSDS / USDC-USDT)',
|
|
1873
|
+
shortLabel: 'sUSDS/USDC-USDT',
|
|
1874
|
+
value: FluidArbitrumVersion.FLUID_SUSDS_USDC_USDT_30_ARB,
|
|
1875
|
+
url: 'susds_usdc_usdt_30_arb',
|
|
1876
|
+
marketAddress: '0xE6b5D1CdC4935295c84772C4700932b4BFC93274',
|
|
1877
|
+
hasSmartCollateral: false,
|
|
1878
|
+
hasSmartDebt: true,
|
|
1879
|
+
collateralAsset0: 'sUSDS',
|
|
1880
|
+
debtAsset0: 'USDC',
|
|
1881
|
+
debtAsset1: 'USDT',
|
|
1882
|
+
});
|
|
1883
|
+
*/
|
|
1882
1884
|
const FLUID_ETH_USDC_1_BASE = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
1883
1885
|
stableBased: true,
|
|
1884
1886
|
btcBased: false,
|
|
@@ -2199,7 +2201,7 @@ const FLUID_ETH_SUSDS_17_BASE = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
2199
2201
|
hasSmartCollateral: false,
|
|
2200
2202
|
hasSmartDebt: false,
|
|
2201
2203
|
collateralAsset0: 'ETH',
|
|
2202
|
-
debtAsset0: '
|
|
2204
|
+
debtAsset0: 'sUSDS',
|
|
2203
2205
|
});
|
|
2204
2206
|
exports.FLUID_ETH_SUSDS_17_BASE = FLUID_ETH_SUSDS_17_BASE;
|
|
2205
2207
|
const FLUID_WSTETH_SUSDS_18_BASE = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
@@ -2375,7 +2377,7 @@ const FluidMarkets = (networkId) => ({
|
|
|
2375
2377
|
[types_1.FluidArbitrumVersion.FLUID_WSTETH_USDC_USDT_24_ARB]: (0, exports.FLUID_WSTETH_USDC_USDT_24_ARB)(networkId),
|
|
2376
2378
|
[types_1.FluidArbitrumVersion.FLUID_WEETH_USDC_USDT_25_ARB]: (0, exports.FLUID_WEETH_USDC_USDT_25_ARB)(networkId),
|
|
2377
2379
|
[types_1.FluidArbitrumVersion.FLUID_WBTC_USDC_USDT_26_ARB]: (0, exports.FLUID_WBTC_USDC_USDT_26_ARB)(networkId),
|
|
2378
|
-
[
|
|
2380
|
+
// [FluidArbitrumVersion.FLUID_SUSDS_USDC_USDT_30_ARB]: FLUID_SUSDS_USDC_USDT_30_ARB(networkId),
|
|
2379
2381
|
// base
|
|
2380
2382
|
[types_1.FluidBaseVersions.FLUID_ETH_USDC_1_BASE]: (0, exports.FLUID_ETH_USDC_1_BASE)(networkId),
|
|
2381
2383
|
[types_1.FluidBaseVersions.FLUID_WSTETH_USDC_2_BASE]: (0, exports.FLUID_WSTETH_USDC_2_BASE)(networkId),
|
|
@@ -28,4 +28,6 @@ export declare const parseWeETHPriceCalls: (_ethPrice: string, weETHrate: {
|
|
|
28
28
|
weETHRate: string;
|
|
29
29
|
};
|
|
30
30
|
export declare const getWstETHPriceFluid: (web3: Web3, network: NetworkNumber) => Promise<string>;
|
|
31
|
+
export declare const getBTCPriceForFluid: (web3: Web3, network: NetworkNumber) => Promise<string>;
|
|
32
|
+
export declare const getEthPriceForFluid: (web3: Web3, network: NetworkNumber) => Promise<string>;
|
|
31
33
|
export declare const getChainlinkAssetAddress: (symbol: string, network: NetworkNumber) => string;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getChainlinkAssetAddress = exports.getWstETHPriceFluid = exports.parseWeETHPriceCalls = exports.parseWstETHPriceCalls = exports.getWeETHChainLinkPriceCalls = exports.getWstETHChainLinkPriceCalls = exports.getWstETHPrice = exports.getCompPrice = exports.getUSDCPrice = exports.getEthPrice = void 0;
|
|
15
|
+
exports.getChainlinkAssetAddress = exports.getEthPriceForFluid = exports.getBTCPriceForFluid = exports.getWstETHPriceFluid = exports.parseWeETHPriceCalls = exports.parseWstETHPriceCalls = exports.getWeETHChainLinkPriceCalls = exports.getWstETHChainLinkPriceCalls = exports.getWstETHPrice = exports.getCompPrice = exports.getUSDCPrice = exports.getEthPrice = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const contracts_1 = require("../contracts");
|
|
@@ -124,6 +124,18 @@ const getWstETHPriceFluid = (web3, network) => __awaiter(void 0, void 0, void 0,
|
|
|
124
124
|
return new decimal_js_1.default(ethPrice).mul(wstETHRate).toString();
|
|
125
125
|
});
|
|
126
126
|
exports.getWstETHPriceFluid = getWstETHPriceFluid;
|
|
127
|
+
const getBTCPriceForFluid = (web3, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
const contract = (0, contracts_1.BTCPriceFeedContract)(web3, network);
|
|
129
|
+
const price = yield contract.methods.latestAnswer().call();
|
|
130
|
+
return new decimal_js_1.default(price).div(1e8).toString();
|
|
131
|
+
});
|
|
132
|
+
exports.getBTCPriceForFluid = getBTCPriceForFluid;
|
|
133
|
+
const getEthPriceForFluid = (web3, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
|
+
const contract = (0, contracts_1.ETHPriceFeedContract)(web3, network);
|
|
135
|
+
const price = yield contract.methods.latestAnswer().call();
|
|
136
|
+
return new decimal_js_1.default(price).div(1e8).toString();
|
|
137
|
+
});
|
|
138
|
+
exports.getEthPriceForFluid = getEthPriceForFluid;
|
|
127
139
|
// chainlink price feed available only on mainnet
|
|
128
140
|
const getChainlinkAssetAddress = (symbol, network) => {
|
|
129
141
|
// Chainlink only has BTC/USD feed so we use that for BTC derivatives
|