@defisaver/positions-sdk 1.0.20 → 1.0.21

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 (78) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +69 -69
  4. package/cjs/aaveV3/index.d.ts +2 -2
  5. package/cjs/aaveV3/index.js +7 -7
  6. package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
  7. package/esm/aaveV3/index.d.ts +2 -2
  8. package/esm/aaveV3/index.js +7 -7
  9. package/esm/helpers/morphoBlueHelpers/index.js +66 -66
  10. package/package.json +54 -54
  11. package/src/aaveV2/index.ts +227 -227
  12. package/src/aaveV3/index.ts +624 -624
  13. package/src/assets/index.ts +60 -60
  14. package/src/chickenBonds/index.ts +123 -123
  15. package/src/compoundV2/index.ts +220 -220
  16. package/src/compoundV3/index.ts +291 -291
  17. package/src/config/contracts.js +1173 -1173
  18. package/src/constants/index.ts +6 -6
  19. package/src/contracts.ts +138 -138
  20. package/src/curveUsd/index.ts +239 -239
  21. package/src/eulerV2/index.ts +303 -303
  22. package/src/exchange/index.ts +17 -17
  23. package/src/fluid/index.ts +1348 -1348
  24. package/src/helpers/aaveHelpers/index.ts +203 -203
  25. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  26. package/src/helpers/compoundHelpers/index.ts +248 -248
  27. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  28. package/src/helpers/eulerHelpers/index.ts +234 -234
  29. package/src/helpers/fluidHelpers/index.ts +325 -325
  30. package/src/helpers/index.ts +11 -11
  31. package/src/helpers/liquityV2Helpers/index.ts +80 -80
  32. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  33. package/src/helpers/makerHelpers/index.ts +94 -94
  34. package/src/helpers/morphoBlueHelpers/index.ts +367 -367
  35. package/src/helpers/sparkHelpers/index.ts +154 -154
  36. package/src/index.ts +52 -52
  37. package/src/liquity/index.ts +116 -116
  38. package/src/liquityV2/index.ts +317 -317
  39. package/src/llamaLend/index.ts +275 -275
  40. package/src/maker/index.ts +117 -117
  41. package/src/markets/aave/index.ts +152 -152
  42. package/src/markets/aave/marketAssets.ts +47 -47
  43. package/src/markets/compound/index.ts +213 -213
  44. package/src/markets/compound/marketsAssets.ts +82 -82
  45. package/src/markets/curveUsd/index.ts +69 -69
  46. package/src/markets/euler/index.ts +26 -26
  47. package/src/markets/fluid/index.ts +2456 -2456
  48. package/src/markets/index.ts +27 -27
  49. package/src/markets/liquityV2/index.ts +102 -102
  50. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  51. package/src/markets/llamaLend/index.ts +235 -235
  52. package/src/markets/morphoBlue/index.ts +895 -895
  53. package/src/markets/spark/index.ts +29 -29
  54. package/src/markets/spark/marketAssets.ts +10 -10
  55. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  56. package/src/morphoAaveV2/index.ts +256 -256
  57. package/src/morphoAaveV3/index.ts +630 -630
  58. package/src/morphoBlue/index.ts +202 -202
  59. package/src/multicall/index.ts +33 -33
  60. package/src/services/priceService.ts +143 -143
  61. package/src/services/utils.ts +59 -59
  62. package/src/setup.ts +8 -8
  63. package/src/spark/index.ts +460 -460
  64. package/src/staking/staking.ts +221 -221
  65. package/src/types/aave.ts +275 -275
  66. package/src/types/chickenBonds.ts +45 -45
  67. package/src/types/common.ts +84 -84
  68. package/src/types/compound.ts +133 -133
  69. package/src/types/curveUsd.ts +119 -119
  70. package/src/types/euler.ts +173 -173
  71. package/src/types/fluid.ts +330 -330
  72. package/src/types/index.ts +11 -11
  73. package/src/types/liquity.ts +30 -30
  74. package/src/types/liquityV2.ts +126 -126
  75. package/src/types/llamaLend.ts +155 -155
  76. package/src/types/maker.ts +50 -50
  77. package/src/types/morphoBlue.ts +194 -194
  78. package/src/types/spark.ts +135 -135
package/.mocharc.json CHANGED
@@ -1,4 +1,4 @@
1
- {
2
- "require": "ts-node/register",
3
- "extension": ["ts"]
4
- }
1
+ {
2
+ "require": "ts-node/register",
3
+ "extension": ["ts"]
4
+ }
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v20.17.0
1
+ v20.17.0
package/README.md CHANGED
@@ -1,69 +1,69 @@
1
- # DeFi Saver Positions SDK
2
-
3
- Supported protocols:
4
- - [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
5
- - [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
6
- - [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
7
- - [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
8
- - [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
9
- - [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
10
- - [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
11
- - [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
12
- - [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
13
- - [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
14
- - [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
15
-
16
- ## Setup
17
- Supported Node version is v10.
18
-
19
- - run `npm install` (first time)
20
- - run `npm run build`
21
-
22
- `build` command will generate contracts and build ejs and esm folders
23
-
24
- ## How to use
25
- [All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
26
-
27
- This is a Compound V3 example, and every other protocol is similar
28
- ```js
29
- import Web3 from 'web3';
30
- import { compoundV3 } from '@defisaver/positions-sdk';
31
-
32
-
33
- // every protocol has market data and user data getters
34
- const {
35
- getCompoundV3MarketsData,
36
- getCompoundV3AccountData,
37
- } = compoundV3;
38
-
39
- const provider = 'Your RPC provider';
40
- const web3 = new Web3(provider);
41
-
42
- const user = '0x123...';
43
-
44
- const { assetsData } = await getCompoundV3MarketsData(
45
- web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
46
- 1, // network
47
- selectedMarket, // market object like in /src/markets/compound/index.ts
48
- web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
49
- );
50
-
51
- const userData = await getCompoundV3AccountData(
52
- web3,
53
- 1, // network
54
- userAddress, // EOA or DSProxy
55
- '', // proxy address of the user, or just empty string if checking for EOA
56
- {
57
- selectedMarket, // market object as in /src/markets/compound/index.ts
58
- assetsData,
59
- }
60
- );
61
- ```
62
-
63
- More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
64
-
65
- ## Testing
66
-
67
- `npm run test` - Run all tests
68
-
69
- `npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
1
+ # DeFi Saver Positions SDK
2
+
3
+ Supported protocols:
4
+ - [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
5
+ - [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
6
+ - [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
7
+ - [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
8
+ - [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
9
+ - [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
10
+ - [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
11
+ - [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
12
+ - [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
13
+ - [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
14
+ - [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
15
+
16
+ ## Setup
17
+ Supported Node version is v10.
18
+
19
+ - run `npm install` (first time)
20
+ - run `npm run build`
21
+
22
+ `build` command will generate contracts and build ejs and esm folders
23
+
24
+ ## How to use
25
+ [All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
26
+
27
+ This is a Compound V3 example, and every other protocol is similar
28
+ ```js
29
+ import Web3 from 'web3';
30
+ import { compoundV3 } from '@defisaver/positions-sdk';
31
+
32
+
33
+ // every protocol has market data and user data getters
34
+ const {
35
+ getCompoundV3MarketsData,
36
+ getCompoundV3AccountData,
37
+ } = compoundV3;
38
+
39
+ const provider = 'Your RPC provider';
40
+ const web3 = new Web3(provider);
41
+
42
+ const user = '0x123...';
43
+
44
+ const { assetsData } = await getCompoundV3MarketsData(
45
+ web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
46
+ 1, // network
47
+ selectedMarket, // market object like in /src/markets/compound/index.ts
48
+ web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
49
+ );
50
+
51
+ const userData = await getCompoundV3AccountData(
52
+ web3,
53
+ 1, // network
54
+ userAddress, // EOA or DSProxy
55
+ '', // proxy address of the user, or just empty string if checking for EOA
56
+ {
57
+ selectedMarket, // market object as in /src/markets/compound/index.ts
58
+ assetsData,
59
+ }
60
+ );
61
+ ```
62
+
63
+ More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
64
+
65
+ ## Testing
66
+
67
+ `npm run test` - Run all tests
68
+
69
+ `npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
@@ -6,7 +6,7 @@ export declare const aaveV3CalculateDiscountRate: (debtBalance: string, discount
6
6
  export declare const aaveV3EmodeCategoriesMapping: (extractedState: any, usedAssets: AaveV3UsedAssets) => {
7
7
  [key: number]: EModeCategoryDataMapping;
8
8
  };
9
- export declare function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3): Promise<AaveV3MarketData>;
9
+ export declare function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3, blockNumber?: 'latest' | number): Promise<AaveV3MarketData>;
10
10
  export declare const EMPTY_AAVE_DATA: {
11
11
  usedAssets: {};
12
12
  suppliedUsd: string;
@@ -29,5 +29,5 @@ export declare const EMPTY_AAVE_DATA: {
29
29
  suppliedCollateralUsd: string;
30
30
  };
31
31
  export declare const getAaveV3AccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
32
- export declare const getAaveV3AccountData: (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any) => Promise<AaveV3PositionData>;
32
+ export declare const getAaveV3AccountData: (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any, blockNumber?: 'latest' | number) => Promise<AaveV3PositionData>;
33
33
  export declare const getAaveV3FullPositionData: (web3: Web3, network: NetworkNumber, address: string, market: AaveMarketInfo, mainnetWeb3: Web3) => Promise<AaveV3PositionData>;
@@ -72,7 +72,7 @@ const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
72
72
  return categoriesMapping;
73
73
  };
74
74
  exports.aaveV3EmodeCategoriesMapping = aaveV3EmodeCategoriesMapping;
75
- function getAaveV3MarketData(web3, network, market, defaultWeb3) {
75
+ function getAaveV3MarketData(web3, network, market, defaultWeb3, blockNumber = 'latest') {
76
76
  return __awaiter(this, void 0, void 0, function* () {
77
77
  const _addresses = market.assets.map(a => (0, tokens_1.getAssetInfo)((0, utils_1.ethToWeth)(a), network).address);
78
78
  const isL2 = (0, utils_1.isLayer2Network)(network);
@@ -112,10 +112,10 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
112
112
  const ghoContract = (0, contracts_1.GhoTokenContract)(web3, network);
113
113
  // eslint-disable-next-line prefer-const
114
114
  let [loanInfo, eModesInfo, isBorrowAllowed, multiRes] = yield Promise.all([
115
- loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(),
116
- loanInfoContract.methods.getAllEmodes(marketAddress).call(),
117
- loanInfoContract.methods.isBorrowAllowed(marketAddress).call(),
118
- isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : (0, multicall_1.multicall)(multicallCallsObject, web3, network),
115
+ loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call({}, blockNumber),
116
+ loanInfoContract.methods.getAllEmodes(marketAddress).call({}, blockNumber),
117
+ loanInfoContract.methods.isBorrowAllowed(marketAddress).call({}, blockNumber),
118
+ isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : (0, multicall_1.multicall)(multicallCallsObject, web3, network, blockNumber),
119
119
  ]);
120
120
  isBorrowAllowed = (0, utils_1.isLayer2Network)(network) ? isBorrowAllowed : true;
121
121
  const eModeCategoriesData = {};
@@ -361,7 +361,7 @@ const getAaveV3AccountBalances = (web3, network, block, addressMapping, address)
361
361
  return balances;
362
362
  });
363
363
  exports.getAaveV3AccountBalances = getAaveV3AccountBalances;
364
- const getAaveV3AccountData = (web3, network, address, extractedState) => __awaiter(void 0, void 0, void 0, function* () {
364
+ const getAaveV3AccountData = (web3, network, address, extractedState, blockNumber = 'latest') => __awaiter(void 0, void 0, void 0, function* () {
365
365
  const { selectedMarket: market, assetsData, eModeCategoriesData, } = extractedState;
366
366
  let payload = Object.assign(Object.assign({}, exports.EMPTY_AAVE_DATA), { lastUpdated: Date.now() });
367
367
  if (!address) {
@@ -395,7 +395,7 @@ const getAaveV3AccountData = (web3, network, address, extractedState) => __await
395
395
  },
396
396
  ];
397
397
  const [multicallRes, { 0: stkAaveBalance }] = yield Promise.all([
398
- (0, multicall_1.multicall)(multicallData, web3, network),
398
+ (0, multicall_1.multicall)(multicallData, web3, network, blockNumber),
399
399
  isL2 ? { 0: '0' } : (0, assets_1.getAssetsBalances)(['stkAAVE'], address, network, web3),
400
400
  { 0: '0' },
401
401
  ]);
@@ -117,73 +117,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, web3, network) =>
117
117
  });
118
118
  exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
119
119
  const API_URL = 'https://blue-api.morpho.org/graphql';
120
- const MARKET_QUERY = `
121
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
122
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
123
- reallocatableLiquidityAssets
124
- targetBorrowUtilization
125
- loanAsset {
126
- address
127
- decimals
128
- priceUsd
129
- }
130
- state {
131
- liquidityAssets
132
- borrowAssets
133
- supplyAssets
134
- }
135
- publicAllocatorSharedLiquidity {
136
- assets
137
- vault {
138
- address
139
- name
140
- }
141
- allocationMarket {
142
- uniqueKey
143
- loanAsset {
144
- address
145
- }
146
- collateralAsset {
147
- address
148
- }
149
- irmAddress
150
- oracle {
151
- address
152
- }
153
- lltv
154
- }
155
- }
156
- loanAsset {
157
- address
158
- }
159
- collateralAsset {
160
- address
161
- }
162
- oracle {
163
- address
164
- }
165
- irmAddress
166
- lltv
167
- }
168
- }
120
+ const MARKET_QUERY = `
121
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
122
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
123
+ reallocatableLiquidityAssets
124
+ targetBorrowUtilization
125
+ loanAsset {
126
+ address
127
+ decimals
128
+ priceUsd
129
+ }
130
+ state {
131
+ liquidityAssets
132
+ borrowAssets
133
+ supplyAssets
134
+ }
135
+ publicAllocatorSharedLiquidity {
136
+ assets
137
+ vault {
138
+ address
139
+ name
140
+ }
141
+ allocationMarket {
142
+ uniqueKey
143
+ loanAsset {
144
+ address
145
+ }
146
+ collateralAsset {
147
+ address
148
+ }
149
+ irmAddress
150
+ oracle {
151
+ address
152
+ }
153
+ lltv
154
+ }
155
+ }
156
+ loanAsset {
157
+ address
158
+ }
159
+ collateralAsset {
160
+ address
161
+ }
162
+ oracle {
163
+ address
164
+ }
165
+ irmAddress
166
+ lltv
167
+ }
168
+ }
169
169
  `;
170
- const REWARDS_QUERY = `
171
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
172
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
173
- uniqueKey
174
- state {
175
- rewards {
176
- amountPerSuppliedToken
177
- supplyApr
178
- amountPerBorrowedToken
179
- borrowApr
180
- asset {
181
- address
182
- }
183
- }
184
- }
185
- }
186
- }
170
+ const REWARDS_QUERY = `
171
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
172
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
173
+ uniqueKey
174
+ state {
175
+ rewards {
176
+ amountPerSuppliedToken
177
+ supplyApr
178
+ amountPerBorrowedToken
179
+ borrowApr
180
+ asset {
181
+ address
182
+ }
183
+ }
184
+ }
185
+ }
186
+ }
187
187
  `;
188
188
  /**
189
189
  * Get reallocatable liquidity to a given market and target borrow utilization
@@ -6,7 +6,7 @@ export declare const aaveV3CalculateDiscountRate: (debtBalance: string, discount
6
6
  export declare const aaveV3EmodeCategoriesMapping: (extractedState: any, usedAssets: AaveV3UsedAssets) => {
7
7
  [key: number]: EModeCategoryDataMapping;
8
8
  };
9
- export declare function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3): Promise<AaveV3MarketData>;
9
+ export declare function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3, blockNumber?: 'latest' | number): Promise<AaveV3MarketData>;
10
10
  export declare const EMPTY_AAVE_DATA: {
11
11
  usedAssets: {};
12
12
  suppliedUsd: string;
@@ -29,5 +29,5 @@ export declare const EMPTY_AAVE_DATA: {
29
29
  suppliedCollateralUsd: string;
30
30
  };
31
31
  export declare const getAaveV3AccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
32
- export declare const getAaveV3AccountData: (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any) => Promise<AaveV3PositionData>;
32
+ export declare const getAaveV3AccountData: (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any, blockNumber?: 'latest' | number) => Promise<AaveV3PositionData>;
33
33
  export declare const getAaveV3FullPositionData: (web3: Web3, network: NetworkNumber, address: string, market: AaveMarketInfo, mainnetWeb3: Web3) => Promise<AaveV3PositionData>;
@@ -63,7 +63,7 @@ export const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
63
63
  });
64
64
  return categoriesMapping;
65
65
  };
66
- export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
66
+ export function getAaveV3MarketData(web3, network, market, defaultWeb3, blockNumber = 'latest') {
67
67
  return __awaiter(this, void 0, void 0, function* () {
68
68
  const _addresses = market.assets.map(a => getAssetInfo(ethToWeth(a), network).address);
69
69
  const isL2 = isLayer2Network(network);
@@ -103,10 +103,10 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
103
103
  const ghoContract = GhoTokenContract(web3, network);
104
104
  // eslint-disable-next-line prefer-const
105
105
  let [loanInfo, eModesInfo, isBorrowAllowed, multiRes] = yield Promise.all([
106
- loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(),
107
- loanInfoContract.methods.getAllEmodes(marketAddress).call(),
108
- loanInfoContract.methods.isBorrowAllowed(marketAddress).call(),
109
- isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : multicall(multicallCallsObject, web3, network),
106
+ loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call({}, blockNumber),
107
+ loanInfoContract.methods.getAllEmodes(marketAddress).call({}, blockNumber),
108
+ loanInfoContract.methods.isBorrowAllowed(marketAddress).call({}, blockNumber),
109
+ isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : multicall(multicallCallsObject, web3, network, blockNumber),
110
110
  ]);
111
111
  isBorrowAllowed = isLayer2Network(network) ? isBorrowAllowed : true;
112
112
  const eModeCategoriesData = {};
@@ -350,7 +350,7 @@ export const getAaveV3AccountBalances = (web3, network, block, addressMapping, a
350
350
  });
351
351
  return balances;
352
352
  });
353
- export const getAaveV3AccountData = (web3, network, address, extractedState) => __awaiter(void 0, void 0, void 0, function* () {
353
+ export const getAaveV3AccountData = (web3, network, address, extractedState, blockNumber = 'latest') => __awaiter(void 0, void 0, void 0, function* () {
354
354
  const { selectedMarket: market, assetsData, eModeCategoriesData, } = extractedState;
355
355
  let payload = Object.assign(Object.assign({}, EMPTY_AAVE_DATA), { lastUpdated: Date.now() });
356
356
  if (!address) {
@@ -384,7 +384,7 @@ export const getAaveV3AccountData = (web3, network, address, extractedState) =>
384
384
  },
385
385
  ];
386
386
  const [multicallRes, { 0: stkAaveBalance }] = yield Promise.all([
387
- multicall(multicallData, web3, network),
387
+ multicall(multicallData, web3, network, blockNumber),
388
388
  isL2 ? { 0: '0' } : getAssetsBalances(['stkAAVE'], address, network, web3),
389
389
  { 0: '0' },
390
390
  ]);
@@ -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
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
- {
2
- "name": "@defisaver/positions-sdk",
3
- "version": "1.0.20",
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.7",
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.21",
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.7",
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
+ }