@defisaver/positions-sdk 2.1.6-dev-debt-in-front → 2.1.6-dev-plasma-1

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 (134) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +64 -64
  4. package/cjs/aaveV3/index.js +3 -3
  5. package/cjs/aaveV3/merit.js +3 -0
  6. package/cjs/aaveV3/merkl.d.ts +1 -1
  7. package/cjs/config/contracts.d.ts +17 -0
  8. package/cjs/config/contracts.js +17 -0
  9. package/cjs/helpers/aaveHelpers/index.d.ts +1 -1
  10. package/cjs/helpers/aaveHelpers/index.js +6 -4
  11. package/cjs/helpers/morphoBlueHelpers/index.d.ts +1 -1
  12. package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
  13. package/cjs/liquityV2/index.d.ts +0 -2
  14. package/cjs/liquityV2/index.js +9 -52
  15. package/cjs/markets/aave/index.js +1 -1
  16. package/cjs/markets/aave/marketAssets.d.ts +4 -0
  17. package/cjs/markets/aave/marketAssets.js +5 -1
  18. package/cjs/markets/compound/index.js +11 -0
  19. package/cjs/markets/compound/marketsAssets.d.ts +7 -0
  20. package/cjs/markets/compound/marketsAssets.js +7 -0
  21. package/cjs/markets/spark/marketAssets.d.ts +1 -0
  22. package/cjs/markets/spark/marketAssets.js +1 -0
  23. package/cjs/services/utils.d.ts +8 -4
  24. package/cjs/services/utils.js +30 -10
  25. package/cjs/services/viem.d.ts +54 -15
  26. package/cjs/services/viem.js +2 -0
  27. package/cjs/types/common.d.ts +2 -1
  28. package/cjs/types/common.js +1 -0
  29. package/esm/aaveV3/index.js +4 -4
  30. package/esm/aaveV3/merit.js +3 -0
  31. package/esm/aaveV3/merkl.d.ts +1 -1
  32. package/esm/config/contracts.d.ts +17 -0
  33. package/esm/config/contracts.js +17 -0
  34. package/esm/helpers/aaveHelpers/index.d.ts +1 -1
  35. package/esm/helpers/aaveHelpers/index.js +7 -5
  36. package/esm/helpers/morphoBlueHelpers/index.d.ts +1 -1
  37. package/esm/helpers/morphoBlueHelpers/index.js +66 -66
  38. package/esm/liquityV2/index.d.ts +0 -2
  39. package/esm/liquityV2/index.js +7 -48
  40. package/esm/markets/aave/index.js +1 -1
  41. package/esm/markets/aave/marketAssets.d.ts +4 -0
  42. package/esm/markets/aave/marketAssets.js +4 -0
  43. package/esm/markets/compound/index.js +11 -0
  44. package/esm/markets/compound/marketsAssets.d.ts +7 -0
  45. package/esm/markets/compound/marketsAssets.js +7 -0
  46. package/esm/markets/spark/marketAssets.d.ts +1 -0
  47. package/esm/markets/spark/marketAssets.js +1 -0
  48. package/esm/services/utils.d.ts +8 -4
  49. package/esm/services/utils.js +21 -5
  50. package/esm/services/viem.d.ts +54 -15
  51. package/esm/services/viem.js +3 -1
  52. package/esm/types/common.d.ts +2 -1
  53. package/esm/types/common.js +1 -0
  54. package/package.json +47 -47
  55. package/src/aaveV2/index.ts +240 -240
  56. package/src/aaveV3/index.ts +614 -614
  57. package/src/aaveV3/merit.ts +97 -94
  58. package/src/aaveV3/merkl.ts +74 -74
  59. package/src/claiming/aaveV3.ts +154 -154
  60. package/src/claiming/compV3.ts +22 -22
  61. package/src/claiming/index.ts +12 -12
  62. package/src/claiming/king.ts +66 -66
  63. package/src/claiming/morphoBlue.ts +118 -118
  64. package/src/claiming/spark.ts +225 -225
  65. package/src/compoundV2/index.ts +244 -244
  66. package/src/compoundV3/index.ts +274 -274
  67. package/src/config/contracts.ts +1245 -1228
  68. package/src/constants/index.ts +10 -10
  69. package/src/contracts.ts +120 -120
  70. package/src/curveUsd/index.ts +254 -254
  71. package/src/eulerV2/index.ts +324 -324
  72. package/src/exchange/index.ts +25 -25
  73. package/src/fluid/index.ts +1638 -1638
  74. package/src/helpers/aaveHelpers/index.ts +187 -185
  75. package/src/helpers/compoundHelpers/index.ts +283 -283
  76. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  77. package/src/helpers/eulerHelpers/index.ts +222 -222
  78. package/src/helpers/fluidHelpers/index.ts +326 -326
  79. package/src/helpers/index.ts +10 -10
  80. package/src/helpers/liquityV2Helpers/index.ts +82 -82
  81. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  82. package/src/helpers/makerHelpers/index.ts +52 -52
  83. package/src/helpers/morphoBlueHelpers/index.ts +396 -396
  84. package/src/helpers/sparkHelpers/index.ts +155 -155
  85. package/src/index.ts +47 -47
  86. package/src/liquity/index.ts +159 -159
  87. package/src/liquityV2/index.ts +657 -703
  88. package/src/llamaLend/index.ts +305 -305
  89. package/src/maker/index.ts +223 -223
  90. package/src/markets/aave/index.ts +116 -116
  91. package/src/markets/aave/marketAssets.ts +54 -49
  92. package/src/markets/compound/index.ts +238 -227
  93. package/src/markets/compound/marketsAssets.ts +97 -90
  94. package/src/markets/curveUsd/index.ts +69 -69
  95. package/src/markets/euler/index.ts +26 -26
  96. package/src/markets/fluid/index.ts +2456 -2456
  97. package/src/markets/index.ts +25 -25
  98. package/src/markets/liquityV2/index.ts +102 -102
  99. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  100. package/src/markets/llamaLend/index.ts +235 -235
  101. package/src/markets/morphoBlue/index.ts +895 -895
  102. package/src/markets/spark/index.ts +29 -29
  103. package/src/markets/spark/marketAssets.ts +12 -11
  104. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  105. package/src/morphoBlue/index.ts +274 -274
  106. package/src/portfolio/index.ts +570 -570
  107. package/src/services/priceService.ts +159 -159
  108. package/src/services/utils.ts +115 -99
  109. package/src/services/viem.ts +34 -32
  110. package/src/setup.ts +8 -8
  111. package/src/spark/index.ts +445 -445
  112. package/src/staking/eligibility.ts +59 -59
  113. package/src/staking/index.ts +1 -1
  114. package/src/staking/staking.ts +170 -170
  115. package/src/types/aave.ts +189 -189
  116. package/src/types/claiming.ts +109 -109
  117. package/src/types/common.ts +106 -105
  118. package/src/types/compound.ts +136 -136
  119. package/src/types/curveUsd.ts +123 -123
  120. package/src/types/euler.ts +175 -175
  121. package/src/types/fluid.ts +448 -448
  122. package/src/types/index.ts +13 -13
  123. package/src/types/liquity.ts +30 -30
  124. package/src/types/liquityV2.ts +126 -126
  125. package/src/types/llamaLend.ts +159 -159
  126. package/src/types/maker.ts +63 -63
  127. package/src/types/merit.ts +1 -1
  128. package/src/types/merkl.ts +70 -70
  129. package/src/types/morphoBlue.ts +194 -194
  130. package/src/types/portfolio.ts +60 -60
  131. package/src/types/spark.ts +135 -135
  132. package/src/umbrella/index.ts +69 -69
  133. package/src/umbrella/umbrellaUtils.ts +29 -29
  134. package/CLAUDE.md +0 -32
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  import Dec from 'decimal.js';
22
22
  import { assetAmountInWei, getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
23
23
  import { AaveVersions, } from '../../types';
24
- import { ethToWeth, wethToEth } from '../../services/utils';
24
+ import { getNativeAssetFromWrapped, getWrappedNativeAssetFromUnwrapped } from '../../services/utils';
25
25
  import { aprToApy, calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos, } from '../../moneymarket';
26
26
  import { calculateNetApy } from '../../staking';
27
27
  import { borrowOperations } from '../../constants';
@@ -52,7 +52,7 @@ export const aaveAnyGetSuppliableAsCollAssets = (_a) => {
52
52
  return aaveAnyGetSuppliableAssets(Object.assign({ usedAssets, eModeCategory, assetsData, selectedMarket, network }, rest)).filter(({ canBeCollateral }) => canBeCollateral);
53
53
  };
54
54
  export const aaveAnyGetEmodeMutableProps = ({ eModeCategory, eModeCategoriesData, assetsData, }, _asset) => {
55
- const asset = wethToEth(_asset);
55
+ const asset = getNativeAssetFromWrapped(_asset);
56
56
  const assetData = assetsData[asset];
57
57
  const eModeCategoryData = (eModeCategoriesData === null || eModeCategoriesData === void 0 ? void 0 : eModeCategoriesData[eModeCategory]) || { collateralAssets: [], collateralFactor: '0', liquidationRatio: '0' };
58
58
  if (eModeCategory === 0
@@ -110,7 +110,7 @@ const getApyAfterValuesEstimationInner = (selectedMarket, actions, client, netwo
110
110
  const params = actions.map(({ action, asset, amount }) => {
111
111
  const isDebtAsset = borrowOperations.includes(action);
112
112
  const amountInWei = assetAmountInWei(amount, asset);
113
- const assetInfo = getAssetInfo(ethToWeth(asset), network);
113
+ const assetInfo = getAssetInfo(getWrappedNativeAssetFromUnwrapped(asset), network);
114
114
  let liquidityAdded;
115
115
  let liquidityTaken;
116
116
  if (isDebtAsset) {
@@ -132,7 +132,7 @@ const getApyAfterValuesEstimationInner = (selectedMarket, actions, client, netwo
132
132
  const data = yield viewContract.read.getApyAfterValuesEstimation([selectedMarket.providerAddress, params]);
133
133
  const rates = {};
134
134
  data.forEach((d) => {
135
- const asset = wethToEth(getAssetInfoByAddress(d.reserveAddress, network).symbol);
135
+ const asset = getNativeAssetFromWrapped(getAssetInfoByAddress(d.reserveAddress, network).symbol);
136
136
  rates[asset] = {
137
137
  supplyRate: aprToApy(new Dec(d.supplyRate.toString()).div(1e25).toString()),
138
138
  borrowRate: aprToApy(new Dec(d.variableBorrowRate.toString()).div(1e25).toString()),
@@ -151,8 +151,10 @@ export const getAaveUnderlyingSymbol = (_symbol = '') => {
151
151
  .replace(/^aEth/, '')
152
152
  .replace(/^aArb/, '')
153
153
  .replace(/^aOpt/, '')
154
+ .replace(/^aLin/, '')
155
+ .replace(/^aPla/, '')
154
156
  .replace(/^aBas/, '');
155
157
  if (symbol.startsWith('a'))
156
158
  symbol = symbol.slice(1);
157
- return wethToEth(symbol);
159
+ return getNativeAssetFromWrapped(symbol);
158
160
  };
@@ -56,4 +56,4 @@ export declare const getRewardsForMarket: (marketId: string, network?: NetworkNu
56
56
  supplyApy: string;
57
57
  borrowApy: string;
58
58
  }>;
59
- export declare const getMorphoUnderlyingSymbol: (_symbol: string) => any;
59
+ export declare const getMorphoUnderlyingSymbol: (_symbol: string) => string;
@@ -118,73 +118,73 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, provider, n
118
118
  return { borrowRate, supplyRate };
119
119
  });
120
120
  const API_URL = 'https://blue-api.morpho.org/graphql';
121
- const MARKET_QUERY = `
122
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
123
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
124
- reallocatableLiquidityAssets
125
- targetBorrowUtilization
126
- loanAsset {
127
- address
128
- decimals
129
- priceUsd
130
- }
131
- state {
132
- liquidityAssets
133
- borrowAssets
134
- supplyAssets
135
- }
136
- publicAllocatorSharedLiquidity {
137
- assets
138
- vault {
139
- address
140
- name
141
- }
142
- allocationMarket {
143
- uniqueKey
144
- loanAsset {
145
- address
146
- }
147
- collateralAsset {
148
- address
149
- }
150
- irmAddress
151
- oracle {
152
- address
153
- }
154
- lltv
155
- }
156
- }
157
- loanAsset {
158
- address
159
- }
160
- collateralAsset {
161
- address
162
- }
163
- oracle {
164
- address
165
- }
166
- irmAddress
167
- lltv
168
- }
169
- }
121
+ const MARKET_QUERY = `
122
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
123
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
124
+ reallocatableLiquidityAssets
125
+ targetBorrowUtilization
126
+ loanAsset {
127
+ address
128
+ decimals
129
+ priceUsd
130
+ }
131
+ state {
132
+ liquidityAssets
133
+ borrowAssets
134
+ supplyAssets
135
+ }
136
+ publicAllocatorSharedLiquidity {
137
+ assets
138
+ vault {
139
+ address
140
+ name
141
+ }
142
+ allocationMarket {
143
+ uniqueKey
144
+ loanAsset {
145
+ address
146
+ }
147
+ collateralAsset {
148
+ address
149
+ }
150
+ irmAddress
151
+ oracle {
152
+ address
153
+ }
154
+ lltv
155
+ }
156
+ }
157
+ loanAsset {
158
+ address
159
+ }
160
+ collateralAsset {
161
+ address
162
+ }
163
+ oracle {
164
+ address
165
+ }
166
+ irmAddress
167
+ lltv
168
+ }
169
+ }
170
170
  `;
171
- const REWARDS_QUERY = `
172
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
173
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
174
- uniqueKey
175
- state {
176
- rewards {
177
- amountPerSuppliedToken
178
- supplyApr
179
- amountPerBorrowedToken
180
- borrowApr
181
- asset {
182
- address
183
- }
184
- }
185
- }
186
- }
187
- }
171
+ const REWARDS_QUERY = `
172
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
173
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
174
+ uniqueKey
175
+ state {
176
+ rewards {
177
+ amountPerSuppliedToken
178
+ supplyApr
179
+ amountPerBorrowedToken
180
+ borrowApr
181
+ asset {
182
+ address
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
188
  `;
189
189
  /**
190
190
  * Get reallocatable liquidity to a given market and target borrow utilization
@@ -23,8 +23,6 @@ export declare const getLiquityV2UserTroveIds: (provider: EthereumProvider, netw
23
23
  }[];
24
24
  nextFreeTroveIndex: string;
25
25
  }>;
26
- export declare const calculateDebtInFrontLiquityV2: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, allMarketsUnbackedDebts: Record<LiquityV2Versions, string>, interestRateDebtInFront: string) => string;
27
- export declare const getDebtInFrontForInterestRateIncludingNewDebtLiquityV2: (newDebt: string, markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, provider: Client, network: NetworkNumber, interestRate: string) => Promise<string>;
28
26
  export declare const getDebtInFrontForInterestRateLiquityV2: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, provider: EthereumProvider, network: NetworkNumber, isLegacy: boolean, interestRate: string, debtInFrontBeingMoved?: string) => Promise<string>;
29
27
  export declare const _getLiquityV2TroveData: (provider: Client, network: NetworkNumber, { selectedMarket, assetsData, troveId, allMarketsData, }: {
30
28
  selectedMarket: LiquityV2MarketInfo;
@@ -190,40 +190,12 @@ const getAllMarketsUnbackedDebts = (markets, isLegacy, provider, network) => __a
190
190
  })));
191
191
  return Object.fromEntries(allMarketsUnbackedDebt);
192
192
  });
193
- export const calculateDebtInFrontLiquityV2 = (markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront) => {
194
- // Sanity check to avoid division by 0. Very unlikely to ever happen.
195
- const selectedMarketTotalBorrow = new Dec(markets[selectedMarket].assetsData[LiquityV2Markets(NetworkNumber.Eth)[selectedMarket].debtToken].totalBorrow);
196
- if (selectedMarketTotalBorrow.eq(0))
197
- return new Dec(0).toString();
193
+ const calculateDebtInFrontLiquityV2 = (markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront) => {
198
194
  const selectedMarketUnbackedDebt = new Dec(allMarketsUnbackedDebts[selectedMarket]);
199
195
  const { isLegacy } = LiquityV2Markets(NetworkNumber.Eth)[selectedMarket];
200
- const totalUnbackedDebt = Object.values(allMarketsUnbackedDebts).reduce((acc, val) => acc.plus(new Dec(val)), new Dec(0));
201
- // When totalUnbackedDebt is 0, redemptions will be proportional with the branch size and not to unbacked debt.
202
- // When unbacked debt is 0 for branch, next redemption call won't touch that branch, so in order to estimate total debt in front we will:
203
- // - First add up all the unbacked debt from other branches, as that will be the only debt that will be redeemed on the fist redemption call
204
- // - Perform split the same way as we would do when totalUnbackedDebt == 0, this would represent the second call to the redemption function
205
- if (selectedMarketUnbackedDebt.eq(0)) {
206
- // Special case if the branch debt in front is 0, it means that all debt in front is unbacked debt from other branches.
207
- if (new Dec(interestRateDebtInFront).eq(0))
208
- return totalUnbackedDebt.toString();
209
- // Then calculate how much of that estimated amount would go to each branch
210
- // Second redemption call - calculate proportional redemption based on updated total debt
211
- const amountBeingRedeemedOnEachMarketByTotalBorrow = Object.entries(markets).map(([version, market]) => {
212
- const { isLegacy: isLegacyMarket } = LiquityV2Markets(NetworkNumber.Eth)[version];
213
- if (version === selectedMarket && isLegacyMarket !== isLegacy)
214
- return new Dec(interestRateDebtInFront);
215
- const { assetsData } = market;
216
- const { debtToken } = LiquityV2Markets(NetworkNumber.Eth)[version];
217
- // For other markets, subtract their unbacked debt as it will be cleared in first redemption call
218
- const marketUnbackedDebt = new Dec(allMarketsUnbackedDebts[version]);
219
- const totalBorrow = new Dec(assetsData[debtToken].totalBorrow).sub(marketUnbackedDebt);
220
- const amountToRedeem = new Dec(interestRateDebtInFront).mul(totalBorrow).div(selectedMarketTotalBorrow);
221
- return Dec.min(amountToRedeem, totalBorrow);
222
- });
223
- const redemptionAmount = amountBeingRedeemedOnEachMarketByTotalBorrow.reduce((acc, val) => acc.plus(val), new Dec(0));
224
- return totalUnbackedDebt.plus(redemptionAmount).toString();
225
- }
226
- const amountBeingRedeemedOnEachMarketByUnbackedDebt = Object.entries(markets).map(([version, market]) => {
196
+ if (selectedMarketUnbackedDebt.eq(0))
197
+ return interestRateDebtInFront;
198
+ const amountBeingReedemedOnEachMarket = Object.entries(markets).map(([version, market]) => {
227
199
  const { isLegacy: isLegacyMarket } = LiquityV2Markets(NetworkNumber.Eth)[version];
228
200
  if (version === selectedMarket && isLegacyMarket !== isLegacy)
229
201
  return new Dec(interestRateDebtInFront);
@@ -231,24 +203,11 @@ export const calculateDebtInFrontLiquityV2 = (markets, selectedMarket, allMarket
231
203
  const { debtToken } = LiquityV2Markets(NetworkNumber.Eth)[version];
232
204
  const unbackedDebt = new Dec(allMarketsUnbackedDebts[version]);
233
205
  const totalBorrow = new Dec(assetsData[debtToken].totalBorrow);
234
- const amountToRedeem = new Dec(interestRateDebtInFront).mul(unbackedDebt).div(selectedMarketUnbackedDebt);
235
- return Dec.min(amountToRedeem, totalBorrow);
206
+ const amountToReedem = new Dec(interestRateDebtInFront).mul(unbackedDebt).div(selectedMarketUnbackedDebt);
207
+ return Dec.min(amountToReedem, totalBorrow);
236
208
  });
237
- return amountBeingRedeemedOnEachMarketByUnbackedDebt.reduce((acc, val) => acc.plus(val), new Dec(0)).toString();
209
+ return amountBeingReedemedOnEachMarket.reduce((acc, val) => acc.plus(val), new Dec(0)).toString();
238
210
  };
239
- // @dev The amount redeemed on each branch depends on the unbacked debt of every branch (the difference between total borrow and stability pool deposits).
240
- // When new debt is generated on the selected market, the unbacked debt will increase, resulting in a higher redemption amount on that branch.
241
- // This function accepts the new debt that's about to be generated (e.g., trove creation) and estimates the debt in front based on the new state.
242
- export const getDebtInFrontForInterestRateIncludingNewDebtLiquityV2 = (newDebt, markets, selectedMarket, provider, network, interestRate) => __awaiter(void 0, void 0, void 0, function* () {
243
- const marketsWithNewDebt = structuredClone(markets);
244
- const selectedMarketDebtToken = LiquityV2Markets(network)[selectedMarket].debtToken;
245
- const currentTotalBorrow = new Dec(marketsWithNewDebt[selectedMarket].assetsData[selectedMarketDebtToken].totalBorrow);
246
- marketsWithNewDebt[selectedMarket].assetsData[selectedMarketDebtToken].totalBorrow = currentTotalBorrow.add(newDebt).toString();
247
- const { isLegacy } = LiquityV2Markets(NetworkNumber.Eth)[selectedMarket];
248
- const allMarketsUnbackedDebts = yield getAllMarketsUnbackedDebts(marketsWithNewDebt, isLegacy, provider, network);
249
- const interestRateDebtInFront = new Dec(yield getDebtInFrontForInterestRateSingleMarketLiquityV2(provider, network, isLegacy, LiquityV2Markets(network)[selectedMarket].marketAddress, interestRate));
250
- return calculateDebtInFrontLiquityV2(marketsWithNewDebt, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront.toString());
251
- });
252
211
  const getDebtInFrontLiquityV2 = (markets, selectedMarket, provider, network, viewContract, troveId) => __awaiter(void 0, void 0, void 0, function* () {
253
212
  const { isLegacy } = LiquityV2Markets(NetworkNumber.Eth)[selectedMarket];
254
213
  const allMarketsUnbackedDebts = yield getAllMarketsUnbackedDebts(markets, isLegacy, provider, network);
@@ -39,7 +39,7 @@ export const AAVE_V2 = {
39
39
  protocolName: 'aave',
40
40
  };
41
41
  export const AAVE_V3 = (networkId) => ({
42
- chainIds: [NetworkNumber.Eth, NetworkNumber.Opt, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Linea],
42
+ chainIds: [NetworkNumber.Eth, NetworkNumber.Opt, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Linea, NetworkNumber.Plasma],
43
43
  label: networkId === NetworkNumber.Eth ? 'Aave v3 Core' : 'Aave v3',
44
44
  shortLabel: 'v3',
45
45
  value: AaveVersions.AaveV3,
@@ -6,12 +6,14 @@ export declare const aaveV3AssetsDefaultMarketOpt: string[];
6
6
  export declare const aaveV3AssetsDefaultMarketArb: string[];
7
7
  export declare const aaveV3AssetsDefaultMarketBase: string[];
8
8
  export declare const aaveV3AssetsDefaultMarketLinea: string[];
9
+ export declare const aaveV3AssetsDefaultMarketPlasma: string[];
9
10
  export declare const aaveV3AssetsDefaultMarket: {
10
11
  readonly 1: string[];
11
12
  readonly 10: string[];
12
13
  readonly 42161: string[];
13
14
  readonly 8453: string[];
14
15
  readonly 59144: string[];
16
+ readonly 9745: string[];
15
17
  };
16
18
  export declare const aaveV3AssetsLidoMarketEth: string[];
17
19
  export declare const aaveV3AssetsLidoMarket: {
@@ -20,6 +22,7 @@ export declare const aaveV3AssetsLidoMarket: {
20
22
  readonly 42161: readonly [];
21
23
  readonly 8453: readonly [];
22
24
  readonly 59144: readonly [];
25
+ readonly 9745: readonly [];
23
26
  };
24
27
  export declare const aaveV3AssetsEtherfiMarketEth: string[];
25
28
  export declare const aaveV3AssetsEtherfiMarket: {
@@ -28,4 +31,5 @@ export declare const aaveV3AssetsEtherfiMarket: {
28
31
  readonly 42161: readonly [];
29
32
  readonly 8453: readonly [];
30
33
  readonly 59144: readonly [];
34
+ readonly 9745: readonly [];
31
35
  };
@@ -15,6 +15,7 @@ export const aaveV3AssetsDefaultMarketOpt = [
15
15
  export const aaveV3AssetsDefaultMarketArb = ['DAI', 'LINK', 'USDC.e', 'WBTC', 'ETH', 'USDT', 'AAVE', 'EURS', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC', 'FRAX', 'ARB', 'weETH', 'GHO', 'ezETH', 'rsETH', 'tBTC'];
16
16
  export const aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH', 'USDC', 'weETH', 'cbBTC', 'ezETH', 'GHO', 'wrsETH', 'LBTC', 'EURC', 'AAVE', 'tBTC'];
17
17
  export const aaveV3AssetsDefaultMarketLinea = ['ETH', 'USDC', 'weETH', 'ezETH', 'USDT', 'wstETH', 'wrsETH', 'WBTC'];
18
+ export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt'];
18
19
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
19
20
  export const aaveV3AssetsDefaultMarket = {
20
21
  [NetworkNumber.Eth]: aaveV3AssetsDefaultMarketEth,
@@ -22,6 +23,7 @@ export const aaveV3AssetsDefaultMarket = {
22
23
  [NetworkNumber.Arb]: aaveV3AssetsDefaultMarketArb,
23
24
  [NetworkNumber.Base]: aaveV3AssetsDefaultMarketBase,
24
25
  [NetworkNumber.Linea]: aaveV3AssetsDefaultMarketLinea,
26
+ [NetworkNumber.Plasma]: aaveV3AssetsDefaultMarketPlasma,
25
27
  };
26
28
  export const aaveV3AssetsLidoMarketEth = ['ETH', 'wstETH', 'USDS', 'USDC', 'ezETH', 'sUSDe', 'GHO', 'rsETH', 'tETH'];
27
29
  export const aaveV3AssetsLidoMarket = {
@@ -30,6 +32,7 @@ export const aaveV3AssetsLidoMarket = {
30
32
  [NetworkNumber.Arb]: [],
31
33
  [NetworkNumber.Base]: [],
32
34
  [NetworkNumber.Linea]: [],
35
+ [NetworkNumber.Plasma]: [],
33
36
  };
34
37
  export const aaveV3AssetsEtherfiMarketEth = ['weETH', 'USDC', 'PYUSD', 'FRAX'];
35
38
  export const aaveV3AssetsEtherfiMarket = {
@@ -38,4 +41,5 @@ export const aaveV3AssetsEtherfiMarket = {
38
41
  [NetworkNumber.Arb]: [],
39
42
  [NetworkNumber.Base]: [],
40
43
  [NetworkNumber.Linea]: [],
44
+ [NetworkNumber.Plasma]: [],
41
45
  };
@@ -65,6 +65,17 @@ const BULKER_OPTIONS = {
65
65
  [CompoundVersions.CompoundV3wstETH]: EMPTY_BULKER_OPTIONS,
66
66
  [CompoundVersions.CompoundV3USDS]: EMPTY_BULKER_OPTIONS,
67
67
  },
68
+ [NetworkNumber.Plasma]: {
69
+ // Non-existing markets, keeping it because of typescript
70
+ [CompoundVersions.CompoundV3USDC]: EMPTY_BULKER_OPTIONS,
71
+ [CompoundVersions.CompoundV3USDT]: EMPTY_BULKER_OPTIONS,
72
+ [CompoundVersions.CompoundV3ETH]: EMPTY_BULKER_OPTIONS,
73
+ [CompoundVersions.CompoundV3USDbC]: EMPTY_BULKER_OPTIONS,
74
+ [CompoundVersions.CompoundV2]: EMPTY_BULKER_OPTIONS,
75
+ [CompoundVersions.CompoundV3USDCe]: EMPTY_BULKER_OPTIONS,
76
+ [CompoundVersions.CompoundV3wstETH]: EMPTY_BULKER_OPTIONS,
77
+ [CompoundVersions.CompoundV3USDS]: EMPTY_BULKER_OPTIONS,
78
+ },
68
79
  };
69
80
  export const COMPOUND_V2 = {
70
81
  chainIds: [NetworkNumber.Eth],
@@ -10,6 +10,7 @@ export declare const v3USDCCollAssets: {
10
10
  readonly 42161: string[];
11
11
  readonly 8453: string[];
12
12
  readonly 59144: readonly [];
13
+ readonly 9745: readonly [];
13
14
  };
14
15
  export declare const v3USDCeCollAssetsArb: string[];
15
16
  export declare const v3USDCeCollAssets: {
@@ -18,6 +19,7 @@ export declare const v3USDCeCollAssets: {
18
19
  readonly 42161: string[];
19
20
  readonly 8453: readonly [];
20
21
  readonly 59144: readonly [];
22
+ readonly 9745: readonly [];
21
23
  };
22
24
  export declare const v3ETHCollAssetsEth: string[];
23
25
  export declare const v3ETHCollAssetsBase: string[];
@@ -29,6 +31,7 @@ export declare const v3ETHCollAssets: {
29
31
  readonly 42161: string[];
30
32
  readonly 8453: string[];
31
33
  readonly 59144: readonly [];
34
+ readonly 9745: readonly [];
32
35
  };
33
36
  export declare const v3USDbCCollAssetsBase: string[];
34
37
  export declare const v3USDbCCollAssets: {
@@ -37,6 +40,7 @@ export declare const v3USDbCCollAssets: {
37
40
  42161: never[];
38
41
  8453: string[];
39
42
  59144: never[];
43
+ 9745: never[];
40
44
  };
41
45
  export declare const v3USDTCollAssetsEth: string[];
42
46
  export declare const v3USDTCollAssetsArb: string[];
@@ -47,6 +51,7 @@ export declare const v3USDTCollAssets: {
47
51
  42161: string[];
48
52
  8453: never[];
49
53
  59144: never[];
54
+ 9745: never[];
50
55
  };
51
56
  export declare const v3USDSCollAssetsEth: string[];
52
57
  export declare const v3USDSCollAssetsBase: string[];
@@ -56,6 +61,7 @@ export declare const v3USDSCollAssets: {
56
61
  42161: never[];
57
62
  8453: string[];
58
63
  59144: never[];
64
+ 9745: never[];
59
65
  };
60
66
  export declare const v3wstETHCollAssetsEth: string[];
61
67
  export declare const v3wstETHCollAssets: {
@@ -64,4 +70,5 @@ export declare const v3wstETHCollAssets: {
64
70
  42161: never[];
65
71
  8453: never[];
66
72
  59144: never[];
73
+ 9745: never[];
67
74
  };
@@ -15,6 +15,7 @@ export const v3USDCCollAssets = {
15
15
  [NetworkNumber.Arb]: v3USDCCollAssetsArb,
16
16
  [NetworkNumber.Base]: v3USDCCollAssetsBase,
17
17
  [NetworkNumber.Linea]: [],
18
+ [NetworkNumber.Plasma]: [],
18
19
  };
19
20
  export const v3USDCeCollAssetsArb = ['ARB', 'ETH', 'GMX', 'WBTC'];
20
21
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
@@ -24,6 +25,7 @@ export const v3USDCeCollAssets = {
24
25
  [NetworkNumber.Arb]: v3USDCeCollAssetsArb,
25
26
  [NetworkNumber.Base]: [],
26
27
  [NetworkNumber.Linea]: [],
28
+ [NetworkNumber.Plasma]: [],
27
29
  };
28
30
  export const v3ETHCollAssetsEth = ['cbETH', 'wstETH', 'rETH', 'rsETH', 'weETH', 'osETH', 'WBTC', 'ezETH', 'cbBTC', 'rswETH', 'tBTC', 'ETHx', 'tETH', 'pufETH', 'wOETH'];
29
31
  export const v3ETHCollAssetsBase = ['cbETH', 'ezETH', 'wstETH', 'USDC', 'weETH', 'wrsETH', 'cbBTC', 'wsuperOETHb'];
@@ -36,6 +38,7 @@ export const v3ETHCollAssets = {
36
38
  [NetworkNumber.Arb]: v3ETHCollAssetsArb,
37
39
  [NetworkNumber.Base]: v3ETHCollAssetsBase,
38
40
  [NetworkNumber.Linea]: [],
41
+ [NetworkNumber.Plasma]: [],
39
42
  };
40
43
  export const v3USDbCCollAssetsBase = ['ETH', 'cbETH'];
41
44
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
@@ -45,6 +48,7 @@ export const v3USDbCCollAssets = {
45
48
  [NetworkNumber.Arb]: [],
46
49
  [NetworkNumber.Base]: v3USDbCCollAssetsBase,
47
50
  [NetworkNumber.Linea]: [],
51
+ [NetworkNumber.Plasma]: [],
48
52
  };
49
53
  export const v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'wUSDM', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
50
54
  export const v3USDTCollAssetsArb = ['ETH', 'WBTC', 'wstETH', 'ARB', 'GMX'];
@@ -56,6 +60,7 @@ export const v3USDTCollAssets = {
56
60
  [NetworkNumber.Arb]: v3USDTCollAssetsArb,
57
61
  [NetworkNumber.Base]: [],
58
62
  [NetworkNumber.Linea]: [],
63
+ [NetworkNumber.Plasma]: [],
59
64
  };
60
65
  export const v3USDSCollAssetsEth = ['wstETH', 'ETH', 'sUSDS', 'cbETH', 'tBTC', 'USDe'];
61
66
  export const v3USDSCollAssetsBase = ['sUSDS', 'cbBTC'];
@@ -65,6 +70,7 @@ export const v3USDSCollAssets = {
65
70
  [NetworkNumber.Arb]: [],
66
71
  [NetworkNumber.Base]: v3USDSCollAssetsBase,
67
72
  [NetworkNumber.Linea]: [],
73
+ [NetworkNumber.Plasma]: [],
68
74
  };
69
75
  export const v3wstETHCollAssetsEth = ['rsETH', 'ezETH'];
70
76
  export const v3wstETHCollAssets = {
@@ -73,4 +79,5 @@ export const v3wstETHCollAssets = {
73
79
  [NetworkNumber.Arb]: [],
74
80
  [NetworkNumber.Base]: [],
75
81
  [NetworkNumber.Linea]: [],
82
+ [NetworkNumber.Plasma]: [],
76
83
  };
@@ -5,4 +5,5 @@ export declare const sparkAssetsDefaultMarket: {
5
5
  readonly 8453: readonly [];
6
6
  readonly 42161: readonly [];
7
7
  readonly 59144: readonly [];
8
+ readonly 9745: readonly [];
8
9
  };
@@ -7,4 +7,5 @@ export const sparkAssetsDefaultMarket = {
7
7
  [NetworkNumber.Base]: [],
8
8
  [NetworkNumber.Arb]: [],
9
9
  [NetworkNumber.Linea]: [],
10
+ [NetworkNumber.Plasma]: [],
10
11
  };
@@ -2,8 +2,6 @@ import { NetworkNumber } from '../types/common';
2
2
  export declare const isLayer2Network: (networkId: NetworkNumber) => boolean;
3
3
  export declare const addToObjectIf: (condition: any, item: any) => any;
4
4
  export declare const addToArrayIf: (condition: any, ...items: any[]) => any[];
5
- export declare const ethToWeth: (maybeEth: any) => any;
6
- export declare const wethToEth: (maybeWeth: any) => any;
7
5
  export declare const stEthToWstEth: (maybeStEth: any) => any;
8
6
  export declare const wstEthToStEth: (maybeStEth: any) => any;
9
7
  export declare const getAbiItem: (abi: any, methodName: string) => any;
@@ -13,8 +11,6 @@ export declare const compareAddresses: (addr1?: string, addr2?: string) => boole
13
11
  export declare const getWeiAmountForDecimals: (amount: string | number, decimals: number) => string;
14
12
  export declare const getEthAmountForDecimals: (amount: string | number, decimals: string | number) => string;
15
13
  export declare const handleWbtcLegacy: (asset: string) => string;
16
- export declare const wethToEthByAddress: (maybeWethAddr: string, chainId?: NetworkNumber) => string;
17
- export declare const ethToWethByAddress: (maybeEthAddr: string, chainId?: NetworkNumber) => string;
18
14
  export declare const bytesToString: (hex: string) => string;
19
15
  /**
20
16
  * Map an input value from one range (minInput, maxInput) to a value in another range (minOutput, maxOutput)
@@ -30,3 +26,11 @@ export declare const DEFAULT_TIMEOUT = 2000;
30
26
  * @param value
31
27
  */
32
28
  export declare const convertHybridArraysToObjects: (value: any) => any;
29
+ export declare const ethToWeth: (maybeEth: string) => string;
30
+ export declare const wethToEth: (maybeWeth: string) => string;
31
+ export declare const wethToEthByAddress: (maybeWethAddr: string, chainId?: NetworkNumber) => string;
32
+ export declare const ethToWethByAddress: (maybeEthAddr: string, chainId?: NetworkNumber) => string;
33
+ export declare const xplToWxpl: (maybeXpl: string) => string;
34
+ export declare const wxplToXpl: (maybeWxpl: string) => string;
35
+ export declare const getWrappedNativeAssetFromUnwrapped: (symbol: string) => string;
36
+ export declare const getNativeAssetFromWrapped: (symbol: string) => string;
@@ -1,11 +1,9 @@
1
1
  import Dec from 'decimal.js';
2
2
  import { getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
3
3
  import { NetworkNumber } from '../types/common';
4
- export const isLayer2Network = (networkId) => [NetworkNumber.Opt, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Linea].includes(+networkId);
4
+ export const isLayer2Network = (networkId) => [NetworkNumber.Opt, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Linea, NetworkNumber.Plasma].includes(+networkId);
5
5
  export const addToObjectIf = (condition, item) => (condition ? item : {});
6
6
  export const addToArrayIf = (condition, ...items) => (condition ? items : []);
7
- export const ethToWeth = (maybeEth) => maybeEth === null || maybeEth === void 0 ? void 0 : maybeEth.replace(/^ETH$/, 'WETH');
8
- export const wethToEth = (maybeWeth) => maybeWeth === null || maybeWeth === void 0 ? void 0 : maybeWeth.replace(/^WETH$/, 'ETH');
9
7
  export const stEthToWstEth = (maybeStEth) => maybeStEth === null || maybeStEth === void 0 ? void 0 : maybeStEth.replace(/^stETH$/, 'wstETH');
10
8
  export const wstEthToStEth = (maybeStEth) => maybeStEth === null || maybeStEth === void 0 ? void 0 : maybeStEth.replace(/^wstETH$/, 'stETH');
11
9
  export const getAbiItem = (abi, methodName) => abi.find((i) => i.name === methodName);
@@ -15,8 +13,6 @@ export const compareAddresses = (addr1 = '', addr2 = '') => addr1.toLowerCase()
15
13
  export const getWeiAmountForDecimals = (amount, decimals) => new Dec(amount).mul(Math.pow(10, decimals)).floor().toString();
16
14
  export const getEthAmountForDecimals = (amount, decimals) => new Dec(amount).div(Math.pow(10, +decimals)).toString();
17
15
  export const handleWbtcLegacy = (asset) => (asset === 'WBTC Legacy' ? 'WBTC' : asset);
18
- export const wethToEthByAddress = (maybeWethAddr, chainId = NetworkNumber.Eth) => getAssetInfo(wethToEth(getAssetInfoByAddress(maybeWethAddr, chainId).symbol), chainId).address;
19
- export const ethToWethByAddress = (maybeEthAddr, chainId = NetworkNumber.Eth) => getAssetInfo(ethToWeth(getAssetInfoByAddress(maybeEthAddr, chainId).symbol), chainId).address;
20
16
  export const bytesToString = (hex) => Buffer.from(hex.replace(/^0x/, ''), 'hex')
21
17
  .toString()
22
18
  // eslint-disable-next-line no-control-regex
@@ -69,3 +65,23 @@ export const convertHybridArraysToObjects = (value) => {
69
65
  }
70
66
  return value;
71
67
  };
68
+ export const ethToWeth = (maybeEth) => maybeEth === null || maybeEth === void 0 ? void 0 : maybeEth.replace(/^ETH$/, 'WETH');
69
+ export const wethToEth = (maybeWeth) => maybeWeth === null || maybeWeth === void 0 ? void 0 : maybeWeth.replace(/^WETH$/, 'ETH');
70
+ export const wethToEthByAddress = (maybeWethAddr, chainId = NetworkNumber.Eth) => getAssetInfo(wethToEth(getAssetInfoByAddress(maybeWethAddr, chainId).symbol), chainId).address;
71
+ export const ethToWethByAddress = (maybeEthAddr, chainId = NetworkNumber.Eth) => getAssetInfo(ethToWeth(getAssetInfoByAddress(maybeEthAddr, chainId).symbol), chainId).address;
72
+ export const xplToWxpl = (maybeXpl) => maybeXpl === null || maybeXpl === void 0 ? void 0 : maybeXpl.replace(/^XPL$/, 'WXPL');
73
+ export const wxplToXpl = (maybeWxpl) => maybeWxpl === null || maybeWxpl === void 0 ? void 0 : maybeWxpl.replace(/^WXPL$/, 'XPL');
74
+ export const getWrappedNativeAssetFromUnwrapped = (symbol) => {
75
+ if (symbol === 'ETH')
76
+ return 'WETH';
77
+ if (symbol === 'XPL')
78
+ return 'WXPL';
79
+ return symbol;
80
+ };
81
+ export const getNativeAssetFromWrapped = (symbol) => {
82
+ if (symbol === 'WETH')
83
+ return 'ETH';
84
+ if (symbol === 'WXPL')
85
+ return 'XPL';
86
+ return symbol;
87
+ };