@defisaver/positions-sdk 2.1.16 → 2.1.17
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/CLAUDE.md +32 -0
- package/cjs/config/contracts.d.ts +12 -0
- package/cjs/config/contracts.js +7 -3
- package/cjs/contracts.d.ts +100947 -134653
- package/cjs/fluid/index.js +116 -38
- package/cjs/markets/fluid/index.d.ts +46 -0
- package/cjs/markets/fluid/index.js +436 -1
- package/cjs/portfolio/index.js +4 -1
- package/cjs/services/priceService.d.ts +489 -0
- package/cjs/services/priceService.js +111 -2
- package/cjs/services/viem.d.ts +2 -3254
- package/cjs/types/fluid.d.ts +30 -1
- package/cjs/types/fluid.js +31 -1
- package/esm/config/contracts.d.ts +12 -0
- package/esm/config/contracts.js +7 -3
- package/esm/contracts.d.ts +100947 -134653
- package/esm/fluid/index.js +118 -40
- package/esm/markets/fluid/index.d.ts +46 -0
- package/esm/markets/fluid/index.js +415 -1
- package/esm/portfolio/index.js +4 -1
- package/esm/services/priceService.d.ts +489 -0
- package/esm/services/priceService.js +102 -2
- package/esm/services/viem.d.ts +2 -3254
- package/esm/types/fluid.d.ts +30 -1
- package/esm/types/fluid.js +30 -0
- package/package.json +2 -2
- package/src/config/contracts.ts +7 -3
- package/src/fluid/index.ts +153 -47
- package/src/markets/fluid/index.ts +442 -2
- package/src/portfolio/index.ts +3 -1
- package/src/services/priceService.ts +123 -4
- package/src/types/fluid.ts +32 -1
package/cjs/fluid/index.js
CHANGED
|
@@ -72,8 +72,14 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
|
|
|
72
72
|
const chainLinkFeedAddress = (0, priceService_1.getChainlinkAssetAddress)(assetInfo.symbol, network);
|
|
73
73
|
if (assetInfo.symbol === 'wstETH')
|
|
74
74
|
return (0, priceService_1.getWstETHChainLinkPriceCalls)(client, network);
|
|
75
|
-
if (assetInfo.symbol === 'weETH')
|
|
75
|
+
if (assetInfo.symbol === 'weETH' && network !== common_1.NetworkNumber.Plasma)
|
|
76
76
|
return (0, priceService_1.getWeETHChainLinkPriceCalls)(client, network);
|
|
77
|
+
if (assetInfo.symbol === 'wrsETH' && network === common_1.NetworkNumber.Plasma)
|
|
78
|
+
return (0, priceService_1.getWsrETHChainLinkPriceCalls)(client, network);
|
|
79
|
+
if (assetInfo.symbol === 'syrupUSDT')
|
|
80
|
+
return (0, priceService_1.getSyrupUSDTChainLinkPriceCalls)(client, network);
|
|
81
|
+
if (assetInfo.symbol === 'wstUSR')
|
|
82
|
+
return (0, priceService_1.getWstUSRChainLinkPriceCalls)(client, network);
|
|
77
83
|
if (isMainnet) {
|
|
78
84
|
const feedRegistryContract = (0, contracts_1.FeedRegistryContractViem)(client, common_1.NetworkNumber.Eth);
|
|
79
85
|
return ({
|
|
@@ -98,7 +104,7 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
|
|
|
98
104
|
const btcPriceChainlink = new decimal_js_1.default(results[1].result).div(1e8).toString();
|
|
99
105
|
let offset = 2; // wstETH and weETH has 3 calls, while others have only 1, so we need to keep track. First 2 are static calls for eth and btc prices
|
|
100
106
|
return noDuplicateTokens.reduce((acc, token, i) => {
|
|
101
|
-
var _a;
|
|
107
|
+
var _a, _b;
|
|
102
108
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(token, network);
|
|
103
109
|
switch (assetInfo.symbol) {
|
|
104
110
|
case 'USDA':
|
|
@@ -112,6 +118,36 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
|
|
|
112
118
|
acc[token] = new decimal_js_1.default(ethPrice).mul(wstETHRate).toString();
|
|
113
119
|
break;
|
|
114
120
|
}
|
|
121
|
+
case 'wrsETH': {
|
|
122
|
+
const { ethPrice, wrsETHRate, } = (0, priceService_1.parseWrsETHPriceCalls)(
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
results[i + offset].result[1].toString(),
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
results[i + offset + 1].result[1].toString());
|
|
127
|
+
offset += 1;
|
|
128
|
+
acc[token] = new decimal_js_1.default(ethPrice).mul(wrsETHRate).toString();
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case 'syrupUSDT': {
|
|
132
|
+
const { syrupUSDTRate, USDTRate, } = (0, priceService_1.parseSyrupUSDTPriceCalls)(
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
results[i + offset].result[1].toString(),
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
results[i + offset + 1].result[1].toString());
|
|
137
|
+
offset += 1;
|
|
138
|
+
acc[token] = new decimal_js_1.default(syrupUSDTRate).mul(USDTRate).toString();
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case 'wstUSR': {
|
|
142
|
+
const { wstUSRRate, USRRate, } = (0, priceService_1.parseWstUSRPriceCalls)(
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
results[i + offset].result[1].toString(),
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
results[i + offset + 1].result[1].toString());
|
|
147
|
+
offset += 1;
|
|
148
|
+
acc[token] = new decimal_js_1.default(wstUSRRate).mul(USRRate).toString();
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
115
151
|
// TODO: These addresses do not have chainlink feeds, so we need to handle them separately, this is hotfix
|
|
116
152
|
case 'ezETH': {
|
|
117
153
|
acc[token] = new decimal_js_1.default(ethPriceChainlink).mul(1.049).toString();
|
|
@@ -134,16 +170,31 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
|
|
|
134
170
|
break;
|
|
135
171
|
}
|
|
136
172
|
case 'weETH': {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
173
|
+
if (network !== common_1.NetworkNumber.Plasma) {
|
|
174
|
+
const { ethPrice, weETHRate, } = (0, priceService_1.parseWeETHPriceCalls)(results[i + offset].result.toString(),
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
results[i + offset + 1].result[1].toString(), results[i + offset + 2].result.toString());
|
|
177
|
+
offset += 2;
|
|
178
|
+
acc[token] = new decimal_js_1.default(ethPrice).mul(weETHRate).toString();
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
}
|
|
181
|
+
else if ((_a = results[i + offset].result) === null || _a === void 0 ? void 0 : _a[1]) {
|
|
182
|
+
// For Plasma, use default chainlink feed (latestRoundData format)
|
|
183
|
+
// @ts-ignore
|
|
184
|
+
acc[token] = new decimal_js_1.default(results[i + offset].result[1].toString()).div(1e8).toString();
|
|
185
|
+
}
|
|
186
|
+
else if (results[i + offset].result) {
|
|
187
|
+
// For Plasma, use default chainlink feed (latestAnswer format)
|
|
188
|
+
acc[token] = new decimal_js_1.default(results[i + offset].result.toString()).div(1e8).toString();
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
acc[token] = '0';
|
|
192
|
+
}
|
|
142
193
|
break;
|
|
143
194
|
}
|
|
144
195
|
default:
|
|
145
196
|
// @ts-ignore
|
|
146
|
-
if ((
|
|
197
|
+
if ((_b = results[i + offset].result) === null || _b === void 0 ? void 0 : _b[1]) {
|
|
147
198
|
// @ts-ignore
|
|
148
199
|
acc[token] = new decimal_js_1.default(results[i + offset].result[1].toString()).div(1e8).toString();
|
|
149
200
|
}
|
|
@@ -176,8 +227,14 @@ const getTokenPriceFromChainlink = (asset, network, provider) => __awaiter(void
|
|
|
176
227
|
else {
|
|
177
228
|
// Currently only base network is supported
|
|
178
229
|
const feedRegistryContract = (0, contracts_1.DFSFeedRegistryContractViem)(provider, network);
|
|
179
|
-
|
|
180
|
-
|
|
230
|
+
try {
|
|
231
|
+
const roundPriceData = isTokenUSDA ? [0, '100000000'] : yield feedRegistryContract.read.latestRoundData([loanTokenFeedAddress, constants_1.USD_QUOTE]);
|
|
232
|
+
loanTokenPrice = roundPriceData[1].toString();
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
console.error(`Error fetching price for ${asset.symbol} on ${network}: ${err}`);
|
|
236
|
+
loanTokenPrice = '0';
|
|
237
|
+
}
|
|
181
238
|
}
|
|
182
239
|
return new decimal_js_1.default(loanTokenPrice).div(1e8).toString();
|
|
183
240
|
});
|
|
@@ -214,8 +271,10 @@ const getTradingApy = (poolAddress) => __awaiter(void 0, void 0, void 0, functio
|
|
|
214
271
|
});
|
|
215
272
|
const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaiter(void 0, [provider_1, data_1, network_1, ...args_1], void 0, function* (provider, data, network, tokenPrices = null) {
|
|
216
273
|
var _a, _b;
|
|
217
|
-
const
|
|
218
|
-
const
|
|
274
|
+
const collAssetContract = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
275
|
+
const collAsset = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(collAssetContract.symbol), network);
|
|
276
|
+
const debtAssetContract = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
277
|
+
const debtAsset = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(debtAssetContract.symbol), network);
|
|
219
278
|
const supplyRate = new decimal_js_1.default(data.supplyRateVault).div(100).toString();
|
|
220
279
|
const borrowRate = new decimal_js_1.default(data.borrowRateVault).div(100).toString();
|
|
221
280
|
const oracleScaleFactor = new decimal_js_1.default(27).add(debtAsset.decimals).sub(collAsset.decimals).toString();
|
|
@@ -226,7 +285,7 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
226
285
|
debtPriceParsed = tokenPrices[debtAsset.symbol] || '0';
|
|
227
286
|
}
|
|
228
287
|
else {
|
|
229
|
-
debtPriceParsed = yield getTokenPriceFromChainlink(
|
|
288
|
+
debtPriceParsed = yield getTokenPriceFromChainlink(debtAssetContract, network, provider);
|
|
230
289
|
}
|
|
231
290
|
const collAssetData = {
|
|
232
291
|
symbol: collAsset.symbol,
|
|
@@ -324,9 +383,12 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
324
383
|
});
|
|
325
384
|
const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaiter(void 0, [provider_1, data_1, network_1, ...args_1], void 0, function* (provider, data, network, tokenPrices = null) {
|
|
326
385
|
var _a, _b, _c;
|
|
327
|
-
const
|
|
328
|
-
const
|
|
329
|
-
const
|
|
386
|
+
const collAsset0Contract = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
387
|
+
const collAsset0 = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(collAsset0Contract.symbol), network);
|
|
388
|
+
const collAsset1Contract = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken1, network);
|
|
389
|
+
const collAsset1 = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(collAsset1Contract.symbol), network);
|
|
390
|
+
const debtAssetContract = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
391
|
+
const debtAsset = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(debtAssetContract.symbol), network);
|
|
330
392
|
// 18 because collateral is represented in shares for which they use 18 decimals
|
|
331
393
|
const oracleScaleFactor = new decimal_js_1.default(27).add(debtAsset.decimals).sub(18).toString();
|
|
332
394
|
const oracleScale = new decimal_js_1.default(10).pow(oracleScaleFactor).toString();
|
|
@@ -336,13 +398,13 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
336
398
|
prices = tokenPrices;
|
|
337
399
|
}
|
|
338
400
|
else {
|
|
339
|
-
prices = yield getChainLinkPricesForTokens([
|
|
401
|
+
prices = yield getChainLinkPricesForTokens([collAsset0Contract.address, collAsset1Contract.address, debtAssetContract.address], network, provider);
|
|
340
402
|
}
|
|
341
403
|
const { supplyDexFee, totalSupplyShares, supplyRate1, totalSupplyToken1, token0PerSupplyShare, token1PerSupplyShare, totalSupplyToken0, maxSupplyShares, withdrawableToken0, withdrawable0, withdrawableToken1, withdrawable1, supplyRate0, utilizationSupply0, utilizationSupply1, withdrawableShares, reservesSupplyToken0, reservesSupplyToken1, } = (0, fluidHelpers_1.parseDexSupplyData)(data.dexSupplyData, collAsset0.symbol, collAsset1.symbol);
|
|
342
404
|
const collFirstAssetData = {
|
|
343
405
|
symbol: collAsset0.symbol,
|
|
344
406
|
address: collAsset0.address,
|
|
345
|
-
price: prices[tokenPrices ? collAsset0.symbol :
|
|
407
|
+
price: prices[tokenPrices ? collAsset0.symbol : collAsset0Contract.address],
|
|
346
408
|
totalSupply: new decimal_js_1.default(totalSupplyShares).mul(token0PerSupplyShare).toString(),
|
|
347
409
|
canBeSupplied: true,
|
|
348
410
|
supplyRate: supplyRate0,
|
|
@@ -364,7 +426,7 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
364
426
|
const collSecondAssetData = {
|
|
365
427
|
symbol: collAsset1.symbol,
|
|
366
428
|
address: collAsset1.address,
|
|
367
|
-
price: prices[tokenPrices ? collAsset1.symbol :
|
|
429
|
+
price: prices[tokenPrices ? collAsset1.symbol : collAsset1Contract.address],
|
|
368
430
|
totalSupply: new decimal_js_1.default(totalSupplyShares).mul(token1PerSupplyShare).toString(),
|
|
369
431
|
canBeSupplied: true,
|
|
370
432
|
supplyRate: supplyRate1,
|
|
@@ -389,7 +451,7 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
389
451
|
const borrowRate = new decimal_js_1.default(data.borrowRateVault).div(100).toString();
|
|
390
452
|
const debtAssetData = {
|
|
391
453
|
symbol: debtAsset.symbol,
|
|
392
|
-
price: prices[tokenPrices ? debtAsset.symbol :
|
|
454
|
+
price: prices[tokenPrices ? debtAsset.symbol : debtAssetContract.address],
|
|
393
455
|
address: debtAsset.address,
|
|
394
456
|
totalBorrow: data.totalBorrowVault.toString(),
|
|
395
457
|
canBeBorrowed: true,
|
|
@@ -418,7 +480,7 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
418
480
|
const liquidationMaxLimit = new decimal_js_1.default(data.liquidationMaxLimit).div(100).toString();
|
|
419
481
|
const liqFactor = new decimal_js_1.default(data.liquidationThreshold).div(10000).toString();
|
|
420
482
|
const totalSupplySharesInVault = (0, tokens_1.assetAmountInEth)(data.totalSupplyVault.toString());
|
|
421
|
-
const collSharePrice = new decimal_js_1.default(oraclePrice).mul(prices[tokenPrices ? debtAsset.symbol :
|
|
483
|
+
const collSharePrice = new decimal_js_1.default(oraclePrice).mul(prices[tokenPrices ? debtAsset.symbol : debtAssetContract.address]).toString();
|
|
422
484
|
const totalSupplyVaultUsd = new decimal_js_1.default(totalSupplySharesInVault).mul(collSharePrice).toString();
|
|
423
485
|
const maxSupplySharesUsd = new decimal_js_1.default(maxSupplyShares).mul(collSharePrice).toString();
|
|
424
486
|
const withdrawableUSD = new decimal_js_1.default(withdrawableShares).mul(collSharePrice).toString();
|
|
@@ -477,9 +539,12 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
477
539
|
});
|
|
478
540
|
const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaiter(void 0, [provider_1, data_1, network_1, ...args_1], void 0, function* (provider, data, network, tokenPrices = null) {
|
|
479
541
|
var _a, _b, _c, _d;
|
|
480
|
-
const
|
|
481
|
-
const
|
|
482
|
-
const
|
|
542
|
+
const collAssetContract = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
543
|
+
const collAsset = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(collAssetContract.symbol), network);
|
|
544
|
+
const debtAsset0Contract = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
545
|
+
const debtAsset0 = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(debtAsset0Contract.symbol), network);
|
|
546
|
+
const debtAsset1Contract = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken1, network);
|
|
547
|
+
const debtAsset1 = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(debtAsset1Contract.symbol), network);
|
|
483
548
|
const { borrowableShares, maxBorrowShares, borrowDexFee, utilizationBorrow0, utilizationBorrow1, borrowable0, borrowable1, borrowRate0, borrowRate1, totalBorrowShares, token0PerBorrowShare, token1PerBorrowShare, borrowableToken0, borrowableToken1, totalBorrowToken0, totalBorrowToken1, reservesBorrowToken0, reservesBorrowToken1, } = (0, fluidHelpers_1.parseDexBorrowData)(data.dexBorrowData, debtAsset0.symbol, debtAsset1.symbol);
|
|
484
549
|
// 18 because debt is represented in shares for which they use 18 decimals
|
|
485
550
|
const oracleScaleFactor = new decimal_js_1.default(27).add(18).sub(collAsset.decimals).toString();
|
|
@@ -490,13 +555,13 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
490
555
|
prices = tokenPrices;
|
|
491
556
|
}
|
|
492
557
|
else {
|
|
493
|
-
prices = yield getChainLinkPricesForTokens([
|
|
558
|
+
prices = yield getChainLinkPricesForTokens([collAssetContract.address, debtAsset0Contract.address, debtAsset1Contract.address], network, provider);
|
|
494
559
|
}
|
|
495
560
|
const supplyRate = new decimal_js_1.default(data.supplyRateVault).div(100).toString();
|
|
496
561
|
const collAssetData = {
|
|
497
562
|
symbol: collAsset.symbol,
|
|
498
563
|
address: collAsset.address,
|
|
499
|
-
price: prices[tokenPrices ? collAsset.symbol :
|
|
564
|
+
price: prices[tokenPrices ? collAsset.symbol : collAssetContract.address],
|
|
500
565
|
totalSupply: data.totalSupplyVault.toString(),
|
|
501
566
|
canBeSupplied: true,
|
|
502
567
|
supplyRate,
|
|
@@ -515,7 +580,7 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
515
580
|
const debtAsset0Data = {
|
|
516
581
|
symbol: debtAsset0.symbol,
|
|
517
582
|
address: debtAsset0.address,
|
|
518
|
-
price: prices[tokenPrices ? debtAsset0.symbol :
|
|
583
|
+
price: prices[tokenPrices ? debtAsset0.symbol : debtAsset0Contract.address],
|
|
519
584
|
totalBorrow: new decimal_js_1.default(totalBorrowShares).mul(token0PerBorrowShare).toString(),
|
|
520
585
|
canBeBorrowed: true,
|
|
521
586
|
borrowRate: borrowRate0,
|
|
@@ -537,7 +602,7 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
537
602
|
const debtAsset1Data = {
|
|
538
603
|
symbol: debtAsset1.symbol,
|
|
539
604
|
address: debtAsset1.address,
|
|
540
|
-
price: prices[tokenPrices ? debtAsset1.symbol :
|
|
605
|
+
price: prices[tokenPrices ? debtAsset1.symbol : debtAsset1Contract.address],
|
|
541
606
|
totalBorrow: new decimal_js_1.default(totalBorrowShares).mul(token1PerBorrowShare).toString(),
|
|
542
607
|
canBeBorrowed: true,
|
|
543
608
|
borrowRate: borrowRate1,
|
|
@@ -626,10 +691,14 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
626
691
|
});
|
|
627
692
|
const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaiter(void 0, [provider_1, data_1, network_1, ...args_1], void 0, function* (provider, data, network, tokenPrices = null) {
|
|
628
693
|
var _a, _b, _c, _d;
|
|
629
|
-
const
|
|
630
|
-
const
|
|
631
|
-
const
|
|
632
|
-
const
|
|
694
|
+
const collAsset0Contract = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
695
|
+
const collAsset0 = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(collAsset0Contract.symbol), network);
|
|
696
|
+
const collAsset1Contract = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken1, network);
|
|
697
|
+
const collAsset1 = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(collAsset1Contract.symbol), network);
|
|
698
|
+
const debtAsset0Contract = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
699
|
+
const debtAsset0 = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(debtAsset0Contract.symbol), network);
|
|
700
|
+
const debtAsset1Contract = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken1, network);
|
|
701
|
+
const debtAsset1 = (0, tokens_1.getAssetInfo)((0, utils_1.getNativeAssetFromWrapped)(debtAsset1Contract.symbol), network);
|
|
633
702
|
const quoteToken = (0, tokens_1.getAssetInfoByAddress)(data.dexBorrowData.quoteToken, network);
|
|
634
703
|
// 27 - 18 + 18
|
|
635
704
|
const oracleScaleFactor = new decimal_js_1.default(27).toString();
|
|
@@ -640,14 +709,14 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
640
709
|
prices = tokenPrices;
|
|
641
710
|
}
|
|
642
711
|
else {
|
|
643
|
-
prices = yield getChainLinkPricesForTokens([
|
|
712
|
+
prices = yield getChainLinkPricesForTokens([collAsset0Contract.address, collAsset1Contract.address, debtAsset0Contract.address, debtAsset1Contract.address], network, provider);
|
|
644
713
|
}
|
|
645
714
|
const { supplyDexFee, totalSupplyShares, supplyRate1, token0PerSupplyShare, token1PerSupplyShare, totalSupplyToken0, totalSupplyToken1, maxSupplyShares, withdrawableToken0, withdrawable0, withdrawableToken1, withdrawable1, supplyRate0, utilizationSupply0, utilizationSupply1, withdrawableShares, reservesSupplyToken0, reservesSupplyToken1, } = (0, fluidHelpers_1.parseDexSupplyData)(data.dexSupplyData, collAsset0.symbol, collAsset1.symbol);
|
|
646
715
|
const { borrowableShares, maxBorrowShares, borrowDexFee, utilizationBorrow0, utilizationBorrow1, borrowable0, borrowable1, borrowRate0, borrowRate1, totalBorrowShares, token0PerBorrowShare, token1PerBorrowShare, borrowableToken0, borrowableToken1, totalBorrowToken0, totalBorrowToken1, quoteTokensPerShare, reservesBorrowToken0, reservesBorrowToken1, } = (0, fluidHelpers_1.parseDexBorrowData)(data.dexBorrowData, debtAsset0.symbol, debtAsset1.symbol);
|
|
647
716
|
const collAsset0Data = {
|
|
648
717
|
symbol: collAsset0.symbol,
|
|
649
718
|
address: collAsset0.address,
|
|
650
|
-
price: prices[tokenPrices ? collAsset0.symbol :
|
|
719
|
+
price: prices[tokenPrices ? collAsset0.symbol : collAsset0Contract.address],
|
|
651
720
|
totalSupply: new decimal_js_1.default(totalSupplyShares).mul(token0PerSupplyShare).toString(),
|
|
652
721
|
canBeSupplied: true,
|
|
653
722
|
supplyRate: supplyRate0,
|
|
@@ -669,7 +738,7 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
669
738
|
const collAsset1Data = {
|
|
670
739
|
symbol: collAsset1.symbol,
|
|
671
740
|
address: collAsset1.address,
|
|
672
|
-
price: prices[tokenPrices ? collAsset1.symbol :
|
|
741
|
+
price: prices[tokenPrices ? collAsset1.symbol : collAsset1Contract.address],
|
|
673
742
|
totalSupply: new decimal_js_1.default(totalSupplyShares).mul(token1PerSupplyShare).toString(),
|
|
674
743
|
canBeSupplied: true,
|
|
675
744
|
supplyRate: supplyRate1,
|
|
@@ -691,7 +760,7 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
691
760
|
const debtAsset0Data = {
|
|
692
761
|
symbol: debtAsset0.symbol,
|
|
693
762
|
address: debtAsset0.address,
|
|
694
|
-
price: prices[tokenPrices ? debtAsset0.symbol :
|
|
763
|
+
price: prices[tokenPrices ? debtAsset0.symbol : debtAsset0Contract.address],
|
|
695
764
|
totalBorrow: new decimal_js_1.default(totalBorrowShares).mul(token0PerBorrowShare).toString(),
|
|
696
765
|
canBeBorrowed: true,
|
|
697
766
|
borrowRate: borrowRate0,
|
|
@@ -713,7 +782,7 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
713
782
|
const debtAsset1Data = {
|
|
714
783
|
symbol: debtAsset1.symbol,
|
|
715
784
|
address: debtAsset1.address,
|
|
716
|
-
price: prices[tokenPrices ? debtAsset1.symbol :
|
|
785
|
+
price: prices[tokenPrices ? debtAsset1.symbol : debtAsset1Contract.address],
|
|
717
786
|
totalBorrow: new decimal_js_1.default(totalBorrowShares).mul(token1PerBorrowShare).toString(),
|
|
718
787
|
canBeBorrowed: true,
|
|
719
788
|
borrowRate: borrowRate1,
|
|
@@ -1194,9 +1263,18 @@ const getTokenPricePortfolio = (token, provider, network) => __awaiter(void 0, v
|
|
|
1194
1263
|
if (token === 'wstETH') {
|
|
1195
1264
|
return (0, priceService_1.getWstETHPrice)(provider, network);
|
|
1196
1265
|
}
|
|
1197
|
-
if (token === 'weETH') {
|
|
1266
|
+
if (token === 'weETH' && network !== common_1.NetworkNumber.Plasma) {
|
|
1198
1267
|
return (0, priceService_1.getWeETHPrice)(provider, network);
|
|
1199
1268
|
}
|
|
1269
|
+
if (token === 'wrsETH') {
|
|
1270
|
+
return (0, priceService_1.getWsrETHPrice)(provider, network);
|
|
1271
|
+
}
|
|
1272
|
+
if (token === 'syrupUSDT') {
|
|
1273
|
+
return (0, priceService_1.getSyrupUSDTPrice)(provider, network);
|
|
1274
|
+
}
|
|
1275
|
+
if (token === 'wstUSR') {
|
|
1276
|
+
return (0, priceService_1.getWstUSRPrice)(provider, network);
|
|
1277
|
+
}
|
|
1200
1278
|
const isMainnet = (0, utils_1.isMainnetNetwork)(network);
|
|
1201
1279
|
const chainLinkFeedAddress = (0, priceService_1.getChainlinkAssetAddress)(token, network);
|
|
1202
1280
|
if (isMainnet) {
|
|
@@ -116,6 +116,27 @@ export declare const FLUID_WSTETH_SUSDS_18_BASE: (networkId?: NetworkNumber) =>
|
|
|
116
116
|
export declare const FLUID_CBBTC_SUSDS_19_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
117
117
|
export declare const FLUID_LBTC_USDC_21_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
118
118
|
export declare const FLUID_LBTC_SUSDS_22_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
119
|
+
export declare const FLUID_ETH_USDT_1_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
120
|
+
export declare const FLUID_ETH_USDE_2_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
121
|
+
export declare const FLUID_WEETH_ETH_3_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
122
|
+
export declare const FLUID_SUSDE_USDT_4_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
123
|
+
export declare const FLUID_WEETH_USDT_5_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
124
|
+
export declare const FLUID_WEETH_USDE_6_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
125
|
+
export declare const FLUID_XAUT_USDT_7_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
126
|
+
export declare const FLUID_XAUT_USDE_8_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
127
|
+
export declare const FLUID_USDE_USDT_9_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
128
|
+
export declare const FLUID_USDAI_USDT_10_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
129
|
+
export declare const FLUID_ETH_WEETH_ETH_11_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
130
|
+
export declare const FLUID_SUSDE_USDT_USDT_12_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
131
|
+
export declare const FLUID_USDE_USDT_USDT_13_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
132
|
+
export declare const FLUID_USDAI_USDT_USDT_14_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
133
|
+
export declare const FLUID_USDT_SYRUPUSDT_USDT_15_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
134
|
+
export declare const FLUID_XPL_USDT_16_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
135
|
+
export declare const FLUID_XPL_USDE_17_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
136
|
+
export declare const FLUID_WSTUSR_USDT_18_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
137
|
+
export declare const FLUID_WSTUSR_USDT_USDT_19_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
138
|
+
export declare const FLUID_SYRUPUSDT_USDT_20_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
139
|
+
export declare const FLUID_ETH_WRSETH_ETH_21_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
119
140
|
export declare const FluidMarkets: (networkId: NetworkNumber) => {
|
|
120
141
|
FLUID_ETH_USDC_1: FluidMarketInfo;
|
|
121
142
|
FLUID_ETH_USDT_2: FluidMarketInfo;
|
|
@@ -233,6 +254,27 @@ export declare const FluidMarkets: (networkId: NetworkNumber) => {
|
|
|
233
254
|
FLUID_CBBTC_SUSDS_19_BASE: FluidMarketInfo;
|
|
234
255
|
FLUID_LBTC_USDC_21_BASE: FluidMarketInfo;
|
|
235
256
|
FLUID_LBTC_SUSDS_22_BASE: FluidMarketInfo;
|
|
257
|
+
FLUID_ETH_USDT_1_PLASMA: FluidMarketInfo;
|
|
258
|
+
FLUID_ETH_USDE_2_PLASMA: FluidMarketInfo;
|
|
259
|
+
FLUID_WEETH_ETH_3_PLASMA: FluidMarketInfo;
|
|
260
|
+
FLUID_SUSDE_USDT_4_PLASMA: FluidMarketInfo;
|
|
261
|
+
FLUID_WEETH_USDT_5_PLASMA: FluidMarketInfo;
|
|
262
|
+
FLUID_WEETH_USDE_6_PLASMA: FluidMarketInfo;
|
|
263
|
+
FLUID_XAUT_USDT_7_PLASMA: FluidMarketInfo;
|
|
264
|
+
FLUID_XAUT_USDE_8_PLASMA: FluidMarketInfo;
|
|
265
|
+
FLUID_USDE_USDT_9_PLASMA: FluidMarketInfo;
|
|
266
|
+
FLUID_USDAI_USDT_10_PLASMA: FluidMarketInfo;
|
|
267
|
+
FLUID_ETH_WEETH_ETH_11_PLASMA: FluidMarketInfo;
|
|
268
|
+
FLUID_SUSDE_USDT_USDT_12_PLASMA: FluidMarketInfo;
|
|
269
|
+
FLUID_USDE_USDT_USDT_13_PLASMA: FluidMarketInfo;
|
|
270
|
+
FLUID_USDAI_USDT_USDT_14_PLASMA: FluidMarketInfo;
|
|
271
|
+
FLUID_USDT_SYRUPUSDT_USDT_15_PLASMA: FluidMarketInfo;
|
|
272
|
+
FLUID_XPL_USDT_16_PLASMA: FluidMarketInfo;
|
|
273
|
+
FLUID_XPL_USDE_17_PLASMA: FluidMarketInfo;
|
|
274
|
+
FLUID_WSTUSR_USDT_18_PLASMA: FluidMarketInfo;
|
|
275
|
+
FLUID_WSTUSR_USDT_USDT_19_PLASMA: FluidMarketInfo;
|
|
276
|
+
FLUID_SYRUPUSDT_USDT_20_PLASMA: FluidMarketInfo;
|
|
277
|
+
FLUID_ETH_WRSETH_ETH_21_PLASMA: FluidMarketInfo;
|
|
236
278
|
};
|
|
237
279
|
export declare const getFluidVersionsDataForNetwork: (network: NetworkNumber) => FluidMarketInfo[];
|
|
238
280
|
export declare const getFluidMarketInfoById: (vaultId: number, network?: NetworkNumber) => FluidMarketInfo | undefined;
|
|
@@ -260,5 +302,9 @@ export declare const FluidFTokens: (networkId: NetworkNumber) => {
|
|
|
260
302
|
wstETH: string;
|
|
261
303
|
sUSDS: string;
|
|
262
304
|
GHO: string;
|
|
305
|
+
} | {
|
|
306
|
+
ETH: string;
|
|
307
|
+
USDT: string;
|
|
308
|
+
USDe: string;
|
|
263
309
|
};
|
|
264
310
|
export declare const getFTokenAddress: (token: string, networkId: NetworkNumber) => any;
|