@defisaver/positions-sdk 1.0.11-fluid-dev10 → 1.0.11-fluid-dev12

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.
Files changed (80) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +69 -69
  4. package/cjs/fluid/index.js +60 -20
  5. package/cjs/helpers/fluidHelpers/index.js +21 -2
  6. package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
  7. package/cjs/types/fluid.d.ts +4 -0
  8. package/esm/fluid/index.js +60 -20
  9. package/esm/helpers/fluidHelpers/index.js +21 -2
  10. package/esm/helpers/morphoBlueHelpers/index.js +66 -66
  11. package/esm/types/fluid.d.ts +4 -0
  12. package/package.json +54 -54
  13. package/src/aaveV2/index.ts +227 -227
  14. package/src/aaveV3/index.ts +624 -624
  15. package/src/assets/index.ts +60 -60
  16. package/src/chickenBonds/index.ts +123 -123
  17. package/src/compoundV2/index.ts +220 -220
  18. package/src/compoundV3/index.ts +291 -291
  19. package/src/config/contracts.js +1155 -1155
  20. package/src/constants/index.ts +6 -6
  21. package/src/contracts.ts +135 -135
  22. package/src/curveUsd/index.ts +239 -239
  23. package/src/eulerV2/index.ts +303 -303
  24. package/src/exchange/index.ts +17 -17
  25. package/src/fluid/index.ts +1289 -1241
  26. package/src/helpers/aaveHelpers/index.ts +203 -203
  27. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  28. package/src/helpers/compoundHelpers/index.ts +248 -248
  29. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  30. package/src/helpers/eulerHelpers/index.ts +234 -234
  31. package/src/helpers/fluidHelpers/index.ts +325 -294
  32. package/src/helpers/index.ts +11 -11
  33. package/src/helpers/liquityV2Helpers/index.ts +80 -80
  34. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  35. package/src/helpers/makerHelpers/index.ts +94 -94
  36. package/src/helpers/morphoBlueHelpers/index.ts +367 -367
  37. package/src/helpers/sparkHelpers/index.ts +154 -154
  38. package/src/index.ts +52 -52
  39. package/src/liquity/index.ts +116 -116
  40. package/src/liquityV2/index.ts +295 -295
  41. package/src/llamaLend/index.ts +275 -275
  42. package/src/maker/index.ts +117 -117
  43. package/src/markets/aave/index.ts +152 -152
  44. package/src/markets/aave/marketAssets.ts +46 -46
  45. package/src/markets/compound/index.ts +213 -213
  46. package/src/markets/compound/marketsAssets.ts +82 -82
  47. package/src/markets/curveUsd/index.ts +69 -69
  48. package/src/markets/euler/index.ts +26 -26
  49. package/src/markets/fluid/index.ts +2454 -2454
  50. package/src/markets/index.ts +27 -27
  51. package/src/markets/liquityV2/index.ts +54 -54
  52. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  53. package/src/markets/llamaLend/index.ts +235 -235
  54. package/src/markets/morphoBlue/index.ts +895 -895
  55. package/src/markets/spark/index.ts +29 -29
  56. package/src/markets/spark/marketAssets.ts +10 -10
  57. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  58. package/src/morphoAaveV2/index.ts +256 -256
  59. package/src/morphoAaveV3/index.ts +630 -630
  60. package/src/morphoBlue/index.ts +202 -202
  61. package/src/multicall/index.ts +33 -33
  62. package/src/services/priceService.ts +130 -130
  63. package/src/services/utils.ts +59 -59
  64. package/src/setup.ts +8 -8
  65. package/src/spark/index.ts +460 -460
  66. package/src/staking/staking.ts +217 -217
  67. package/src/types/aave.ts +275 -275
  68. package/src/types/chickenBonds.ts +45 -45
  69. package/src/types/common.ts +84 -84
  70. package/src/types/compound.ts +133 -133
  71. package/src/types/curveUsd.ts +119 -119
  72. package/src/types/euler.ts +173 -173
  73. package/src/types/fluid.ts +330 -325
  74. package/src/types/index.ts +11 -11
  75. package/src/types/liquity.ts +30 -30
  76. package/src/types/liquityV2.ts +119 -119
  77. package/src/types/llamaLend.ts +155 -155
  78. package/src/types/maker.ts +50 -50
  79. package/src/types/morphoBlue.ts +194 -194
  80. package/src/types/spark.ts +135 -135
@@ -114,6 +114,30 @@ const getTokenPriceFromChainlink = (asset, network, web3) => __awaiter(void 0, v
114
114
  }
115
115
  return new Dec(loanTokenPrice).div(1e8).toString();
116
116
  });
117
+ const getMarketRateForDex = (token1PerShare, token0PerShare, rate0, rate1, price0, price1) => {
118
+ const token0PerShareUsd = new Dec(token0PerShare).mul(price0).toString();
119
+ const token1PerShareUsd = new Dec(token1PerShare).mul(price1).toString();
120
+ const sharesCombinedUsd = new Dec(token0PerShareUsd).plus(token1PerShareUsd);
121
+ const rate0PerShare = new Dec(rate0).mul(token0PerShareUsd).div(sharesCombinedUsd).toString();
122
+ const rate1PerShare = new Dec(rate1).mul(token1PerShareUsd).div(sharesCombinedUsd).toString();
123
+ return new Dec(rate0PerShare).plus(rate1PerShare).toString();
124
+ };
125
+ const getAdditionalMarketRateForDex = (token1PerShare, token0PerShare, incentiveSupplyRate0, incentiveSupplyRate1, price0, price1) => {
126
+ const token0PerShareUsd = new Dec(token0PerShare).mul(price0).toString();
127
+ const token1PerShareUsd = new Dec(token1PerShare).mul(price1).toString();
128
+ const sharesCombinedUsd = new Dec(token0PerShareUsd).plus(token1PerShareUsd);
129
+ const rate0PerShare = incentiveSupplyRate0 ? new Dec(incentiveSupplyRate0).mul(token0PerShareUsd).div(sharesCombinedUsd).toString() : 0;
130
+ const rate1PerShare = incentiveSupplyRate1 ? new Dec(incentiveSupplyRate1).mul(token1PerShareUsd).div(sharesCombinedUsd).toString() : 0;
131
+ return new Dec(rate0PerShare).plus(rate1PerShare).toString();
132
+ };
133
+ const getTradingApy = (poolAddress) => __awaiter(void 0, void 0, void 0, function* () {
134
+ const res = yield fetch(`https://api.fluid.instadapp.io/v2/1/dexes/${poolAddress}/apy`);
135
+ if (!res.ok) {
136
+ return '0';
137
+ }
138
+ const data = yield res.json();
139
+ return new Dec(data.tradingApy).div(100).toString();
140
+ });
117
141
  const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
118
142
  const collAsset = getAssetInfoByAddress(data.supplyToken0, network);
119
143
  const debtAsset = getAssetInfoByAddress(data.borrowToken0, network);
@@ -138,6 +162,7 @@ const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
138
162
  collAssetData.incentiveSupplyApy = yield getStakingApy(collAsset.symbol, mainnetWeb3);
139
163
  collAssetData.incentiveSupplyToken = collAsset.symbol;
140
164
  }
165
+ const incentiveSupplyRate = collAssetData.incentiveSupplyApy;
141
166
  const debtAssetData = {
142
167
  symbol: debtAsset.symbol,
143
168
  address: debtAsset.address,
@@ -153,10 +178,7 @@ const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
153
178
  debtAssetData.incentiveBorrowApy = yield getStakingApy(debtAsset.symbol, mainnetWeb3);
154
179
  debtAssetData.incentiveBorrowToken = debtAsset.symbol;
155
180
  }
156
- if (STAKING_ASSETS.includes(debtAssetData.symbol)) {
157
- debtAssetData.incentiveBorrowApy = yield getStakingApy(debtAsset.symbol, mainnetWeb3);
158
- debtAssetData.incentiveBorrowToken = debtAsset.symbol;
159
- }
181
+ const incentiveBorrowRate = debtAssetData.incentiveBorrowApy;
160
182
  const assetsData = {
161
183
  [collAsset.symbol]: collAssetData,
162
184
  [debtAsset.symbol]: debtAssetData,
@@ -200,6 +222,8 @@ const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
200
222
  liquidationMaxLimit,
201
223
  borrowRate,
202
224
  supplyRate,
225
+ incentiveSupplyRate,
226
+ incentiveBorrowRate,
203
227
  oraclePrice,
204
228
  };
205
229
  return {
@@ -207,12 +231,6 @@ const parseT1MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
207
231
  marketData,
208
232
  };
209
233
  });
210
- const getMarketRateForDex = (token1PerShare, token0PerShare, rate0, rate1) => {
211
- const sharesCombined = new Dec(token1PerShare).plus(token0PerShare);
212
- const rate0PerShare = new Dec(rate0).mul(token0PerShare).div(sharesCombined).toString();
213
- const rate1PerShare = new Dec(rate1).mul(token1PerShare).div(sharesCombined).toString();
214
- return new Dec(rate0PerShare).plus(rate1PerShare).toString();
215
- };
216
234
  const parseT2MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
217
235
  const collAsset0 = getAssetInfoByAddress(data.supplyToken0, network);
218
236
  const collAsset1 = getAssetInfoByAddress(data.supplyToken1, network);
@@ -251,11 +269,13 @@ const parseT2MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
251
269
  tokenPerSupplyShare: token1PerSupplyShare,
252
270
  supplyReserves: reservesSupplyToken1,
253
271
  };
254
- if (STAKING_ASSETS.includes(collFirstAssetData.symbol)) {
255
- collFirstAssetData.incentiveSupplyApy = yield getStakingApy(collAsset1.symbol, mainnetWeb3);
256
- collFirstAssetData.incentiveSupplyToken = collAsset1.symbol;
272
+ if (STAKING_ASSETS.includes(collSecondAssetData.symbol)) {
273
+ collSecondAssetData.incentiveSupplyApy = yield getStakingApy(collAsset1.symbol, mainnetWeb3);
274
+ collSecondAssetData.incentiveSupplyToken = collAsset1.symbol;
257
275
  }
258
- const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1);
276
+ const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1, collFirstAssetData.price, collSecondAssetData.price);
277
+ const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collFirstAssetData.incentiveSupplyApy, collSecondAssetData.incentiveSupplyApy, collFirstAssetData.price, collSecondAssetData.price);
278
+ const tradingSupplyRate = yield getTradingApy(data.dexSupplyData.dexPool);
259
279
  const borrowRate = new Dec(data.borrowRateVault).div(100).toString();
260
280
  const debtAssetData = {
261
281
  symbol: debtAsset.symbol,
@@ -269,6 +289,7 @@ const parseT2MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
269
289
  debtAssetData.incentiveBorrowApy = yield getStakingApy(debtAsset.symbol, mainnetWeb3);
270
290
  debtAssetData.incentiveBorrowToken = debtAsset.symbol;
271
291
  }
292
+ const incentiveBorrowRate = debtAssetData.incentiveBorrowApy;
272
293
  const assetsData = [
273
294
  [collAsset0.symbol, collFirstAssetData],
274
295
  [collAsset1.symbol, collSecondAssetData],
@@ -317,17 +338,21 @@ const parseT2MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
317
338
  liquidationMaxLimit,
318
339
  borrowRate,
319
340
  supplyRate: marketSupplyRate,
341
+ incentiveSupplyRate,
342
+ incentiveBorrowRate,
320
343
  totalSupplyToken0,
321
344
  totalSupplyToken1,
322
345
  withdrawableToken0,
323
346
  withdrawableToken1,
324
347
  withdrawableUSD,
325
348
  withdrawable: withdrawableShares,
326
- widthdrawableDex: new Dec(maxSupplyShares).minus(totalSupplyShares).toString(),
349
+ withdrawableDex: new Dec(maxSupplyShares).minus(totalSupplyShares).toString(),
327
350
  maxSupplyShares,
328
351
  maxSupplySharesUsd,
329
352
  collDexFee: supplyDexFee,
330
353
  oraclePrice,
354
+ tradingSupplyRate,
355
+ tradingBorrowRate: '0',
331
356
  };
332
357
  return {
333
358
  assetsData,
@@ -357,6 +382,7 @@ const parseT3MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
357
382
  collAssetData.incentiveSupplyApy = yield getStakingApy(collAsset.symbol, mainnetWeb3);
358
383
  collAssetData.incentiveSupplyToken = collAsset.symbol;
359
384
  }
385
+ const incentiveSupplyRate = collAssetData.incentiveSupplyApy;
360
386
  const debtAsset0Data = {
361
387
  symbol: debtAsset0.symbol,
362
388
  address: debtAsset0.address,
@@ -389,7 +415,9 @@ const parseT3MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
389
415
  debtAsset1Data.incentiveSupplyApy = yield getStakingApy(debtAsset1.symbol, mainnetWeb3);
390
416
  debtAsset1Data.incentiveSupplyToken = debtAsset1.symbol;
391
417
  }
392
- const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1);
418
+ const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1, debtAsset0Data.price, debtAsset1Data.price);
419
+ const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.incentiveSupplyApy, debtAsset1Data.incentiveSupplyApy, debtAsset0Data.price, debtAsset1Data.price);
420
+ const tradingBorrowRate = yield getTradingApy(data.dexBorrowData.dexPool);
393
421
  const assetsData = [
394
422
  [collAsset.symbol, collAssetData],
395
423
  [debtAsset0.symbol, debtAsset0Data],
@@ -433,6 +461,10 @@ const parseT3MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
433
461
  liquidationMaxLimit,
434
462
  borrowRate: marketBorrowRate,
435
463
  supplyRate,
464
+ incentiveBorrowRate,
465
+ incentiveSupplyRate,
466
+ tradingBorrowRate,
467
+ tradingSupplyRate: '0',
436
468
  borrowableToken0,
437
469
  borrowableToken1,
438
470
  totalBorrowToken0,
@@ -528,8 +560,13 @@ const parseT4MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
528
560
  debtAsset1Data.incentiveSupplyApy = yield getStakingApy(debtAsset1.symbol, mainnetWeb3);
529
561
  debtAsset1Data.incentiveSupplyToken = debtAsset1.symbol;
530
562
  }
531
- const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1);
532
- const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1);
563
+ const marketInfo = getFluidMarketInfoById(+data.vaultId, network);
564
+ const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1, debtAsset0Data.price, debtAsset1Data.price);
565
+ const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.incentiveSupplyApy, debtAsset1Data.incentiveSupplyApy, debtAsset0Data.price, debtAsset1Data.price);
566
+ const tradingBorrowRate = yield getTradingApy(data.dexBorrowData.dexPool);
567
+ const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1, collAsset0Data.price, collAsset1Data.price);
568
+ const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collAsset0Data.incentiveSupplyApy, collAsset1Data.incentiveSupplyApy, collAsset0Data.price, collAsset1Data.price);
569
+ const tradingSupplyRate = yield getTradingApy(data.dexSupplyData.dexPool);
533
570
  const assetsData = [
534
571
  [collAsset0.symbol, collAsset0Data],
535
572
  [collAsset1.symbol, collAsset1Data],
@@ -537,7 +574,6 @@ const parseT4MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
537
574
  [debtAsset1.symbol, debtAsset1Data],
538
575
  ]
539
576
  .reduce((acc, [symbol, partialData]) => (Object.assign(Object.assign({}, acc), { [symbol]: mergeAssetData(acc[symbol], partialData) })), {});
540
- const marketInfo = getFluidMarketInfoById(+data.vaultId, network);
541
577
  const liqRatio = new Dec(data.liquidationThreshold).div(100).toString();
542
578
  const liquidationMaxLimit = new Dec(data.liquidationMaxLimit).div(100).toString();
543
579
  const liqFactor = new Dec(data.liquidationThreshold).div(10000).toString();
@@ -575,7 +611,9 @@ const parseT4MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
575
611
  totalBorrowVaultUsd,
576
612
  liquidationMaxLimit,
577
613
  borrowRate: marketBorrowRate,
614
+ incentiveBorrowRate,
578
615
  supplyRate: marketSupplyRate,
616
+ incentiveSupplyRate,
579
617
  borrowableToken0,
580
618
  borrowableToken1,
581
619
  totalBorrowToken0,
@@ -592,13 +630,15 @@ const parseT4MarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0
592
630
  withdrawableToken1,
593
631
  withdrawableUSD,
594
632
  withdrawable: withdrawableShares,
595
- widthdrawableDex: new Dec(maxSupplyShares).minus(totalSupplyShares).toString(),
633
+ withdrawableDex: new Dec(maxSupplyShares).minus(totalSupplyShares).toString(),
596
634
  maxSupplyShares,
597
635
  maxSupplySharesUsd,
598
636
  collDexFee: supplyDexFee,
599
637
  collSharePrice,
600
638
  debtSharePrice,
601
639
  oraclePrice,
640
+ tradingBorrowRate,
641
+ tradingSupplyRate,
602
642
  };
603
643
  return {
604
644
  assetsData,
@@ -4,6 +4,24 @@ import { FluidVaultType, } from '../../types';
4
4
  import { calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos } from '../../moneymarket';
5
5
  import { calculateNetApy } from '../../staking';
6
6
  import { getEthAmountForDecimals } from '../../services/utils';
7
+ const calculateNetApyDex = ({ marketData, suppliedUsd, borrowedUsd }) => {
8
+ const { borrowRate, supplyRate, incentiveBorrowRate, incentiveSupplyRate, tradingBorrowRate, tradingSupplyRate, } = marketData;
9
+ const totalBorrowRate = new Dec(borrowRate).minus(tradingBorrowRate || '0').toString();
10
+ const totalSupplyRate = new Dec(supplyRate).add(tradingSupplyRate || '0').toString();
11
+ const borrowIncentive = new Dec(incentiveBorrowRate || '0').mul(borrowedUsd).div(100).toString();
12
+ const supplyIncentive = new Dec(incentiveSupplyRate || '0').mul(suppliedUsd).div(100).toString();
13
+ const incentiveUsd = new Dec(supplyIncentive).minus(borrowIncentive).toString();
14
+ const borrowInterest = new Dec(totalBorrowRate).mul(borrowedUsd).div(100).toString();
15
+ const supplyInterest = new Dec(totalSupplyRate).mul(suppliedUsd).div(100).toString();
16
+ const totalInterestUsd = new Dec(supplyInterest).add(incentiveUsd).minus(borrowInterest).toString();
17
+ const balance = new Dec(suppliedUsd).sub(borrowedUsd).toString();
18
+ const netApy = new Dec(totalInterestUsd).div(balance).times(100).toString();
19
+ return {
20
+ netApy,
21
+ incentiveUsd,
22
+ totalInterestUsd,
23
+ };
24
+ };
7
25
  export const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, }, supplyShares, borrowShares) => {
8
26
  const payload = {};
9
27
  payload.suppliedUsd = [FluidVaultType.T1, FluidVaultType.T3].includes(marketData.vaultType)
@@ -12,7 +30,8 @@ export const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, },
12
30
  payload.borrowedUsd = [FluidVaultType.T1, FluidVaultType.T2].includes(marketData.vaultType)
13
31
  ? getAssetsTotal(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd)
14
32
  : new Dec(marketData.debtSharePrice).mul(borrowShares).toString();
15
- const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy({ usedAssets, assetsData: assetsData });
33
+ const isDex = [FluidVaultType.T2, FluidVaultType.T3, FluidVaultType.T4].includes(marketData.vaultType);
34
+ const { netApy, incentiveUsd, totalInterestUsd } = isDex ? calculateNetApyDex({ marketData, suppliedUsd: payload.suppliedUsd, borrowedUsd: payload.borrowedUsd }) : calculateNetApy({ usedAssets, assetsData: assetsData });
16
35
  payload.netApy = netApy;
17
36
  payload.incentiveUsd = incentiveUsd;
18
37
  payload.totalInterestUsd = totalInterestUsd;
@@ -44,7 +63,7 @@ export const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, },
44
63
  export const parseDexSupplyData = (dexSupplyData, collAsset0, collAsset1) => {
45
64
  const { dexPool, // address of the dex pool
46
65
  dexId, // id of the dex pool
47
- fee: _fee, // fee of the dex pool TODO videti sa Rajkom
66
+ fee: _fee, // fee of the dex pool (Only used as swap fees)
48
67
  lastStoredPrice, // last stored price of the dex pool
49
68
  centerPrice, // center price of the dex pool
50
69
  token0Utilization, // token0 utilization
@@ -107,73 +107,73 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, web3, netwo
107
107
  return { borrowRate, supplyRate };
108
108
  });
109
109
  const API_URL = 'https://blue-api.morpho.org/graphql';
110
- const MARKET_QUERY = `
111
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
112
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
113
- reallocatableLiquidityAssets
114
- targetBorrowUtilization
115
- loanAsset {
116
- address
117
- decimals
118
- priceUsd
119
- }
120
- state {
121
- liquidityAssets
122
- borrowAssets
123
- supplyAssets
124
- }
125
- publicAllocatorSharedLiquidity {
126
- assets
127
- vault {
128
- address
129
- name
130
- }
131
- allocationMarket {
132
- uniqueKey
133
- loanAsset {
134
- address
135
- }
136
- collateralAsset {
137
- address
138
- }
139
- irmAddress
140
- oracle {
141
- address
142
- }
143
- lltv
144
- }
145
- }
146
- loanAsset {
147
- address
148
- }
149
- collateralAsset {
150
- address
151
- }
152
- oracle {
153
- address
154
- }
155
- irmAddress
156
- lltv
157
- }
158
- }
110
+ const MARKET_QUERY = `
111
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
112
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
113
+ reallocatableLiquidityAssets
114
+ targetBorrowUtilization
115
+ loanAsset {
116
+ address
117
+ decimals
118
+ priceUsd
119
+ }
120
+ state {
121
+ liquidityAssets
122
+ borrowAssets
123
+ supplyAssets
124
+ }
125
+ publicAllocatorSharedLiquidity {
126
+ assets
127
+ vault {
128
+ address
129
+ name
130
+ }
131
+ allocationMarket {
132
+ uniqueKey
133
+ loanAsset {
134
+ address
135
+ }
136
+ collateralAsset {
137
+ address
138
+ }
139
+ irmAddress
140
+ oracle {
141
+ address
142
+ }
143
+ lltv
144
+ }
145
+ }
146
+ loanAsset {
147
+ address
148
+ }
149
+ collateralAsset {
150
+ address
151
+ }
152
+ oracle {
153
+ address
154
+ }
155
+ irmAddress
156
+ lltv
157
+ }
158
+ }
159
159
  `;
160
- const REWARDS_QUERY = `
161
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
162
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
163
- uniqueKey
164
- state {
165
- rewards {
166
- amountPerSuppliedToken
167
- supplyApr
168
- amountPerBorrowedToken
169
- borrowApr
170
- asset {
171
- address
172
- }
173
- }
174
- }
175
- }
176
- }
160
+ const REWARDS_QUERY = `
161
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
162
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
163
+ uniqueKey
164
+ state {
165
+ rewards {
166
+ amountPerSuppliedToken
167
+ supplyApr
168
+ amountPerBorrowedToken
169
+ borrowApr
170
+ asset {
171
+ address
172
+ }
173
+ }
174
+ }
175
+ }
176
+ }
177
177
  `;
178
178
  /**
179
179
  * Get reallocatable liquidity to a given market and target borrow utilization
@@ -241,6 +241,8 @@ export interface InnerFluidMarketData {
241
241
  borrowRate: string;
242
242
  liquidationMaxLimit: string;
243
243
  oraclePrice: string;
244
+ incentiveBorrowRate?: string;
245
+ incentiveSupplyRate?: string;
244
246
  collSharePrice?: string;
245
247
  maxSupplyShares?: string;
246
248
  maxSupplySharesUsd?: string;
@@ -259,6 +261,8 @@ export interface InnerFluidMarketData {
259
261
  totalBorrowToken0?: string;
260
262
  totalBorrowToken1?: string;
261
263
  borrowDexFee?: string;
264
+ tradingBorrowRate?: string;
265
+ tradingSupplyRate?: string;
262
266
  }
263
267
  export interface FluidMarketData {
264
268
  assetsData: FluidAssetsData;
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
- {
2
- "name": "@defisaver/positions-sdk",
3
- "version": "1.0.11-fluid-dev10",
4
- "description": "",
5
- "main": "./cjs/index.js",
6
- "module": "./esm/index.js",
7
- "types": "./esm/index.d.ts",
8
- "scripts": {
9
- "build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
10
- "build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
11
- "build": "npm run lint && npm run generate-contracts && npm run build:cjs && npm run build:esm",
12
- "dev": "npm run generate-contracts && tsc -p tsconfig.json --watch",
13
- "lint": "eslint src/ --fix",
14
- "lint-check": "eslint src/",
15
- "generate-contracts": "node scripts/generateContracts.js",
16
- "test": "mocha tests/*",
17
- "test-single": "mocha ./tests/$npm_config_name.ts",
18
- "test:debugger": "mocha --inspect-brk tests/*",
19
- "build-test": "npm run build && npm run test",
20
- "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
21
- },
22
- "keywords": [],
23
- "author": "",
24
- "license": "ISC",
25
- "dependencies": {
26
- "@defisaver/tokens": "^1.6.2",
27
- "@ethersproject/bignumber": "^5.7.0",
28
- "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
29
- "@types/lodash": "^4.17.15",
30
- "@types/memoizee": "^0.4.12",
31
- "decimal.js": "^10.4.3",
32
- "lodash": "^4.17.21",
33
- "memoizee": "^0.4.17"
34
- },
35
- "devDependencies": {
36
- "@defisaver/eslint-config": "^1.0.1",
37
- "@types/chai": "^5.0.0",
38
- "@types/mocha": "^10.0.9",
39
- "@types/web3": "^1.0.20",
40
- "chai": "^4.3.8",
41
- "dotenv": "^16.3.1",
42
- "eslint": "^8.49.0",
43
- "eslint-plugin-import": "^2.31.0",
44
- "mocha": "^10.2.0",
45
- "nock": "^14.0.0",
46
- "ts-node": "^10.9.2",
47
- "typechain": "^8.3.1",
48
- "typechain-target-web3-v1-3mihai3": "^6.0.2",
49
- "typescript": "^5.2.2"
50
- },
51
- "peerDependencies": {
52
- "web3": "^1.10.2"
53
- }
54
- }
1
+ {
2
+ "name": "@defisaver/positions-sdk",
3
+ "version": "1.0.11-fluid-dev12",
4
+ "description": "",
5
+ "main": "./cjs/index.js",
6
+ "module": "./esm/index.js",
7
+ "types": "./esm/index.d.ts",
8
+ "scripts": {
9
+ "build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
10
+ "build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
11
+ "build": "npm run lint && npm run generate-contracts && npm run build:cjs && npm run build:esm",
12
+ "dev": "npm run generate-contracts && tsc -p tsconfig.json --watch",
13
+ "lint": "eslint src/ --fix",
14
+ "lint-check": "eslint src/",
15
+ "generate-contracts": "node scripts/generateContracts.js",
16
+ "test": "mocha tests/*",
17
+ "test-single": "mocha ./tests/$npm_config_name.ts",
18
+ "test:debugger": "mocha --inspect-brk tests/*",
19
+ "build-test": "npm run build && npm run test",
20
+ "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
21
+ },
22
+ "keywords": [],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "dependencies": {
26
+ "@defisaver/tokens": "^1.6.2",
27
+ "@ethersproject/bignumber": "^5.7.0",
28
+ "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
29
+ "@types/lodash": "^4.17.15",
30
+ "@types/memoizee": "^0.4.12",
31
+ "decimal.js": "^10.4.3",
32
+ "lodash": "^4.17.21",
33
+ "memoizee": "^0.4.17"
34
+ },
35
+ "devDependencies": {
36
+ "@defisaver/eslint-config": "^1.0.1",
37
+ "@types/chai": "^5.0.0",
38
+ "@types/mocha": "^10.0.9",
39
+ "@types/web3": "^1.0.20",
40
+ "chai": "^4.3.8",
41
+ "dotenv": "^16.3.1",
42
+ "eslint": "^8.49.0",
43
+ "eslint-plugin-import": "^2.31.0",
44
+ "mocha": "^10.2.0",
45
+ "nock": "^14.0.0",
46
+ "ts-node": "^10.9.2",
47
+ "typechain": "^8.3.1",
48
+ "typechain-target-web3-v1-3mihai3": "^6.0.2",
49
+ "typescript": "^5.2.2"
50
+ },
51
+ "peerDependencies": {
52
+ "web3": "^1.10.2"
53
+ }
54
+ }