@defisaver/positions-sdk 0.0.201-fluid-dev-11 → 0.0.201-fluid-dev-13

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.d.ts +4 -4
  5. package/cjs/fluid/index.js +14 -9
  6. package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
  7. package/cjs/markets/fluid/index.js +1 -1
  8. package/esm/fluid/index.d.ts +4 -4
  9. package/esm/fluid/index.js +14 -9
  10. package/esm/helpers/morphoBlueHelpers/index.js +66 -66
  11. package/esm/markets/fluid/index.js +1 -1
  12. package/package.json +52 -52
  13. package/src/aaveV2/index.ts +227 -227
  14. package/src/aaveV3/index.ts +625 -625
  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 +1135 -1135
  20. package/src/constants/index.ts +6 -6
  21. package/src/contracts.ts +134 -134
  22. package/src/curveUsd/index.ts +229 -229
  23. package/src/eulerV2/index.ts +303 -303
  24. package/src/exchange/index.ts +17 -17
  25. package/src/fluid/index.ts +349 -343
  26. package/src/helpers/aaveHelpers/index.ts +198 -198
  27. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  28. package/src/helpers/compoundHelpers/index.ts +246 -246
  29. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  30. package/src/helpers/eulerHelpers/index.ts +232 -232
  31. package/src/helpers/fluidHelpers/index.ts +53 -53
  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 +365 -365
  37. package/src/helpers/sparkHelpers/index.ts +150 -150
  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 +44 -44
  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 +2010 -2010
  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 +91 -91
  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 +220 -220
  67. package/src/types/aave.ts +271 -271
  68. package/src/types/chickenBonds.ts +45 -45
  69. package/src/types/common.ts +84 -84
  70. package/src/types/compound.ts +131 -131
  71. package/src/types/curveUsd.ts +118 -118
  72. package/src/types/euler.ts +171 -171
  73. package/src/types/fluid.ts +264 -264
  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 +192 -192
  80. package/src/types/spark.ts +131 -131
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
@@ -26,17 +26,17 @@ export declare const EMPTY_FLUID_DATA: {
26
26
  automationResubscribeRequired: boolean;
27
27
  lastUpdated: number;
28
28
  };
29
- export declare const getFluidMarketData: (web3: Web3, network: NetworkNumber, market: FluidMarketInfo) => Promise<FluidMarketData>;
29
+ export declare const getFluidMarketData: (web3: Web3, network: NetworkNumber, market: FluidMarketInfo, mainnetWeb3: Web3) => Promise<FluidMarketData>;
30
30
  export declare const getFluidVaultIdsForUser: (web3: Web3, network: NetworkNumber, user: EthAddress) => Promise<string[]>;
31
31
  export declare const getFluidPosition: (web3: Web3, network: NetworkNumber, vaultId: string, extractedState: {
32
32
  assetsData: FluidAssetsData;
33
33
  marketData: InnerFluidMarketData;
34
34
  }) => Promise<FluidVaultData>;
35
- export declare const getFluidPositionWithMarket: (web3: Web3, network: NetworkNumber, vaultId: string) => Promise<{
35
+ export declare const getFluidPositionWithMarket: (web3: Web3, network: NetworkNumber, vaultId: string, mainnetWeb3: Web3) => Promise<{
36
36
  userData: FluidVaultData;
37
37
  marketData: FluidMarketData;
38
38
  }>;
39
- export declare const getAllFluidMarketDataChunked: (network: NetworkNumber, web3: Web3) => Promise<FluidMarketData[]>;
39
+ export declare const getAllFluidMarketDataChunked: (network: NetworkNumber, web3: Web3, mainnetWeb3: Web3) => Promise<FluidMarketData[]>;
40
40
  export declare const getFluidTokenData: (web3: Web3, network: NetworkNumber, token: string) => Promise<{
41
41
  fTokenAddress: any;
42
42
  fTokenSymbol: string;
@@ -59,7 +59,7 @@ export declare const getFluidDepositData: (web3: Web3, network: NetworkNumber, t
59
59
  deposited: string;
60
60
  depositedShares: string;
61
61
  }>;
62
- export declare const getUserPositions: (web3: Web3, network: NetworkNumber, user: EthAddress) => Promise<{
62
+ export declare const getUserPositions: (web3: Web3, network: NetworkNumber, user: EthAddress, mainnetWeb3: Web3) => Promise<{
63
63
  marketData: FluidMarketData;
64
64
  userData: {
65
65
  nftId: string;
@@ -24,6 +24,7 @@ const multicall_1 = require("../multicall");
24
24
  const markets_1 = require("../markets");
25
25
  const constants_1 = require("../constants");
26
26
  const priceService_1 = require("../services/priceService");
27
+ const staking_1 = require("../staking");
27
28
  exports.EMPTY_USED_ASSET = {
28
29
  isSupplied: false,
29
30
  isBorrowed: false,
@@ -43,7 +44,7 @@ const parseVaultType = (vaultType) => {
43
44
  default: return types_1.FluidVaultType.Unknown;
44
45
  }
45
46
  };
46
- const parseMarketData = (web3, data, network) => __awaiter(void 0, void 0, void 0, function* () {
47
+ const parseMarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
47
48
  const collAsset = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
48
49
  const debtAsset = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
49
50
  const supplyRate = new decimal_js_1.default(data.supplyRateVault).div(100).toString();
@@ -81,6 +82,10 @@ const parseMarketData = (web3, data, network) => __awaiter(void 0, void 0, void
81
82
  supplyRate,
82
83
  borrowRate: '0',
83
84
  };
85
+ if (staking_1.STAKING_ASSETS.includes(collAsset.symbol)) {
86
+ collAssetData.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(collAsset.symbol, mainnetWeb3);
87
+ collAssetData.incentiveSupplyToken = collAsset.symbol;
88
+ }
84
89
  const debtAssetData = {
85
90
  symbol: debtAsset.symbol,
86
91
  address: debtAsset.address,
@@ -175,10 +180,10 @@ const parseUserData = (userPositionData, vaultData) => {
175
180
  marketData,
176
181
  }));
177
182
  };
178
- const getFluidMarketData = (web3, network, market) => __awaiter(void 0, void 0, void 0, function* () {
183
+ const getFluidMarketData = (web3, network, market, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
179
184
  const view = (0, contracts_1.FluidViewContract)(web3, network);
180
185
  const data = yield view.methods.getVaultData(market.marketAddress).call();
181
- return parseMarketData(web3, data, network);
186
+ return parseMarketData(web3, data, network, mainnetWeb3);
182
187
  });
183
188
  exports.getFluidMarketData = getFluidMarketData;
184
189
  const getFluidVaultIdsForUser = (web3, network, user) => __awaiter(void 0, void 0, void 0, function* () {
@@ -193,10 +198,10 @@ const getFluidPosition = (web3, network, vaultId, extractedState) => __awaiter(v
193
198
  return parseUserData(userPositionData, extractedState);
194
199
  });
195
200
  exports.getFluidPosition = getFluidPosition;
196
- const getFluidPositionWithMarket = (web3, network, vaultId) => __awaiter(void 0, void 0, void 0, function* () {
201
+ const getFluidPositionWithMarket = (web3, network, vaultId, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
197
202
  const view = (0, contracts_1.FluidViewContract)(web3, network);
198
203
  const data = yield view.methods.getPositionByNftId(vaultId).call();
199
- const marketData = yield parseMarketData(web3, data.vault, network);
204
+ const marketData = yield parseMarketData(web3, data.vault, network, mainnetWeb3);
200
205
  const userData = parseUserData(data.position, marketData);
201
206
  return {
202
207
  userData,
@@ -204,7 +209,7 @@ const getFluidPositionWithMarket = (web3, network, vaultId) => __awaiter(void 0,
204
209
  };
205
210
  });
206
211
  exports.getFluidPositionWithMarket = getFluidPositionWithMarket;
207
- const getAllFluidMarketDataChunked = (network, web3) => __awaiter(void 0, void 0, void 0, function* () {
212
+ const getAllFluidMarketDataChunked = (network, web3, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
208
213
  const versions = (0, markets_1.getFluidVersionsDataForNetwork)(network);
209
214
  const view = (0, contracts_1.FluidViewContract)(web3, network);
210
215
  const calls = versions.map((version) => ({
@@ -214,7 +219,7 @@ const getAllFluidMarketDataChunked = (network, web3) => __awaiter(void 0, void 0
214
219
  }));
215
220
  const data = yield (0, multicall_1.chunkAndMulticall)(calls, 10, 'latest', web3, network);
216
221
  // @ts-ignore
217
- return Promise.all(data.map((item, i) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, item.vaultData, network); })));
222
+ return Promise.all(data.map((item, i) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, item.vaultData, network, mainnetWeb3); })));
218
223
  });
219
224
  exports.getAllFluidMarketDataChunked = getAllFluidMarketDataChunked;
220
225
  const getFluidTokenData = (web3, network, token) => __awaiter(void 0, void 0, void 0, function* () {
@@ -261,10 +266,10 @@ const getFluidDepositData = (web3, network, token, address) => __awaiter(void 0,
261
266
  };
262
267
  });
263
268
  exports.getFluidDepositData = getFluidDepositData;
264
- const getUserPositions = (web3, network, user) => __awaiter(void 0, void 0, void 0, function* () {
269
+ const getUserPositions = (web3, network, user, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
265
270
  const view = (0, contracts_1.FluidViewContract)(web3, network);
266
271
  const data = yield view.methods.getUserPositions(user).call();
267
- const parsedMarketData = yield Promise.all(data.vaults.map((vaultData) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, vaultData, network); })));
272
+ const parsedMarketData = yield Promise.all(data.vaults.map((vaultData) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, vaultData, network, mainnetWeb3); })));
268
273
  const userData = data.positions.map((position, i) => (Object.assign(Object.assign({}, parseUserData(position, parsedMarketData[i])), { nftId: position.nftId })));
269
274
  return parsedMarketData.map((market, i) => ({
270
275
  marketData: market,
@@ -115,73 +115,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, web3, network) =>
115
115
  });
116
116
  exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
117
117
  const API_URL = 'https://blue-api.morpho.org/graphql';
118
- const MARKET_QUERY = `
119
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
120
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
121
- reallocatableLiquidityAssets
122
- targetBorrowUtilization
123
- loanAsset {
124
- address
125
- decimals
126
- priceUsd
127
- }
128
- state {
129
- liquidityAssets
130
- borrowAssets
131
- supplyAssets
132
- }
133
- publicAllocatorSharedLiquidity {
134
- assets
135
- vault {
136
- address
137
- name
138
- }
139
- allocationMarket {
140
- uniqueKey
141
- loanAsset {
142
- address
143
- }
144
- collateralAsset {
145
- address
146
- }
147
- irmAddress
148
- oracle {
149
- address
150
- }
151
- lltv
152
- }
153
- }
154
- loanAsset {
155
- address
156
- }
157
- collateralAsset {
158
- address
159
- }
160
- oracle {
161
- address
162
- }
163
- irmAddress
164
- lltv
165
- }
166
- }
118
+ const MARKET_QUERY = `
119
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
120
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
121
+ reallocatableLiquidityAssets
122
+ targetBorrowUtilization
123
+ loanAsset {
124
+ address
125
+ decimals
126
+ priceUsd
127
+ }
128
+ state {
129
+ liquidityAssets
130
+ borrowAssets
131
+ supplyAssets
132
+ }
133
+ publicAllocatorSharedLiquidity {
134
+ assets
135
+ vault {
136
+ address
137
+ name
138
+ }
139
+ allocationMarket {
140
+ uniqueKey
141
+ loanAsset {
142
+ address
143
+ }
144
+ collateralAsset {
145
+ address
146
+ }
147
+ irmAddress
148
+ oracle {
149
+ address
150
+ }
151
+ lltv
152
+ }
153
+ }
154
+ loanAsset {
155
+ address
156
+ }
157
+ collateralAsset {
158
+ address
159
+ }
160
+ oracle {
161
+ address
162
+ }
163
+ irmAddress
164
+ lltv
165
+ }
166
+ }
167
167
  `;
168
- const REWARDS_QUERY = `
169
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
170
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
171
- uniqueKey
172
- state {
173
- rewards {
174
- amountPerSuppliedToken
175
- supplyApr
176
- amountPerBorrowedToken
177
- borrowApr
178
- asset {
179
- address
180
- }
181
- }
182
- }
183
- }
184
- }
168
+ const REWARDS_QUERY = `
169
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
170
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
171
+ uniqueKey
172
+ state {
173
+ rewards {
174
+ amountPerSuppliedToken
175
+ supplyApr
176
+ amountPerBorrowedToken
177
+ borrowApr
178
+ asset {
179
+ address
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
185
  `;
186
186
  /**
187
187
  * Get reallocatable liquidity to a given market and target borrow utilization
@@ -1953,7 +1953,7 @@ const FluidMarkets = (networkId) => ({
1953
1953
  [types_1.FluidBaseVersions.WSTETH_CBBTC_16_BASE]: (0, exports.WSTETH_CBBTC_16_BASE)(networkId),
1954
1954
  });
1955
1955
  exports.FluidMarkets = FluidMarkets;
1956
- const getFluidVersionsDataForNetwork = (network) => (Object.values((0, exports.FluidMarkets)(network)).filter(({ chainIds, marketAddress, type }) => !!marketAddress && chainIds.includes(network) && type === types_1.FluidVaultType.T1));
1956
+ const getFluidVersionsDataForNetwork = (network) => (Object.values((0, exports.FluidMarkets)(network)).filter(({ chainIds, marketAddress }) => !!marketAddress && chainIds.includes(network)));
1957
1957
  exports.getFluidVersionsDataForNetwork = getFluidVersionsDataForNetwork;
1958
1958
  const getFluidMarketInfoById = (vaultId, network = 1) => (0, exports.getFluidVersionsDataForNetwork)(network).find(({ id }) => id === vaultId);
1959
1959
  exports.getFluidMarketInfoById = getFluidMarketInfoById;
@@ -26,17 +26,17 @@ export declare const EMPTY_FLUID_DATA: {
26
26
  automationResubscribeRequired: boolean;
27
27
  lastUpdated: number;
28
28
  };
29
- export declare const getFluidMarketData: (web3: Web3, network: NetworkNumber, market: FluidMarketInfo) => Promise<FluidMarketData>;
29
+ export declare const getFluidMarketData: (web3: Web3, network: NetworkNumber, market: FluidMarketInfo, mainnetWeb3: Web3) => Promise<FluidMarketData>;
30
30
  export declare const getFluidVaultIdsForUser: (web3: Web3, network: NetworkNumber, user: EthAddress) => Promise<string[]>;
31
31
  export declare const getFluidPosition: (web3: Web3, network: NetworkNumber, vaultId: string, extractedState: {
32
32
  assetsData: FluidAssetsData;
33
33
  marketData: InnerFluidMarketData;
34
34
  }) => Promise<FluidVaultData>;
35
- export declare const getFluidPositionWithMarket: (web3: Web3, network: NetworkNumber, vaultId: string) => Promise<{
35
+ export declare const getFluidPositionWithMarket: (web3: Web3, network: NetworkNumber, vaultId: string, mainnetWeb3: Web3) => Promise<{
36
36
  userData: FluidVaultData;
37
37
  marketData: FluidMarketData;
38
38
  }>;
39
- export declare const getAllFluidMarketDataChunked: (network: NetworkNumber, web3: Web3) => Promise<FluidMarketData[]>;
39
+ export declare const getAllFluidMarketDataChunked: (network: NetworkNumber, web3: Web3, mainnetWeb3: Web3) => Promise<FluidMarketData[]>;
40
40
  export declare const getFluidTokenData: (web3: Web3, network: NetworkNumber, token: string) => Promise<{
41
41
  fTokenAddress: any;
42
42
  fTokenSymbol: string;
@@ -59,7 +59,7 @@ export declare const getFluidDepositData: (web3: Web3, network: NetworkNumber, t
59
59
  deposited: string;
60
60
  depositedShares: string;
61
61
  }>;
62
- export declare const getUserPositions: (web3: Web3, network: NetworkNumber, user: EthAddress) => Promise<{
62
+ export declare const getUserPositions: (web3: Web3, network: NetworkNumber, user: EthAddress, mainnetWeb3: Web3) => Promise<{
63
63
  marketData: FluidMarketData;
64
64
  userData: {
65
65
  nftId: string;
@@ -18,6 +18,7 @@ import { chunkAndMulticall } from '../multicall';
18
18
  import { getFluidMarketInfoById, getFluidVersionsDataForNetwork, getFTokenAddress } from '../markets';
19
19
  import { USD_QUOTE } from '../constants';
20
20
  import { getChainlinkAssetAddress, getWstETHPriceFluid } from '../services/priceService';
21
+ import { getStakingApy, STAKING_ASSETS } from '../staking';
21
22
  export const EMPTY_USED_ASSET = {
22
23
  isSupplied: false,
23
24
  isBorrowed: false,
@@ -37,7 +38,7 @@ const parseVaultType = (vaultType) => {
37
38
  default: return FluidVaultType.Unknown;
38
39
  }
39
40
  };
40
- const parseMarketData = (web3, data, network) => __awaiter(void 0, void 0, void 0, function* () {
41
+ const parseMarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
41
42
  const collAsset = getAssetInfoByAddress(data.supplyToken0, network);
42
43
  const debtAsset = getAssetInfoByAddress(data.borrowToken0, network);
43
44
  const supplyRate = new Dec(data.supplyRateVault).div(100).toString();
@@ -75,6 +76,10 @@ const parseMarketData = (web3, data, network) => __awaiter(void 0, void 0, void
75
76
  supplyRate,
76
77
  borrowRate: '0',
77
78
  };
79
+ if (STAKING_ASSETS.includes(collAsset.symbol)) {
80
+ collAssetData.incentiveSupplyApy = yield getStakingApy(collAsset.symbol, mainnetWeb3);
81
+ collAssetData.incentiveSupplyToken = collAsset.symbol;
82
+ }
78
83
  const debtAssetData = {
79
84
  symbol: debtAsset.symbol,
80
85
  address: debtAsset.address,
@@ -169,10 +174,10 @@ const parseUserData = (userPositionData, vaultData) => {
169
174
  marketData,
170
175
  }));
171
176
  };
172
- export const getFluidMarketData = (web3, network, market) => __awaiter(void 0, void 0, void 0, function* () {
177
+ export const getFluidMarketData = (web3, network, market, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
173
178
  const view = FluidViewContract(web3, network);
174
179
  const data = yield view.methods.getVaultData(market.marketAddress).call();
175
- return parseMarketData(web3, data, network);
180
+ return parseMarketData(web3, data, network, mainnetWeb3);
176
181
  });
177
182
  export const getFluidVaultIdsForUser = (web3, network, user) => __awaiter(void 0, void 0, void 0, function* () {
178
183
  const view = FluidViewContract(web3, network);
@@ -184,17 +189,17 @@ export const getFluidPosition = (web3, network, vaultId, extractedState) => __aw
184
189
  const userPositionData = data[0];
185
190
  return parseUserData(userPositionData, extractedState);
186
191
  });
187
- export const getFluidPositionWithMarket = (web3, network, vaultId) => __awaiter(void 0, void 0, void 0, function* () {
192
+ export const getFluidPositionWithMarket = (web3, network, vaultId, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
188
193
  const view = FluidViewContract(web3, network);
189
194
  const data = yield view.methods.getPositionByNftId(vaultId).call();
190
- const marketData = yield parseMarketData(web3, data.vault, network);
195
+ const marketData = yield parseMarketData(web3, data.vault, network, mainnetWeb3);
191
196
  const userData = parseUserData(data.position, marketData);
192
197
  return {
193
198
  userData,
194
199
  marketData,
195
200
  };
196
201
  });
197
- export const getAllFluidMarketDataChunked = (network, web3) => __awaiter(void 0, void 0, void 0, function* () {
202
+ export const getAllFluidMarketDataChunked = (network, web3, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
198
203
  const versions = getFluidVersionsDataForNetwork(network);
199
204
  const view = FluidViewContract(web3, network);
200
205
  const calls = versions.map((version) => ({
@@ -204,7 +209,7 @@ export const getAllFluidMarketDataChunked = (network, web3) => __awaiter(void 0,
204
209
  }));
205
210
  const data = yield chunkAndMulticall(calls, 10, 'latest', web3, network);
206
211
  // @ts-ignore
207
- return Promise.all(data.map((item, i) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, item.vaultData, network); })));
212
+ return Promise.all(data.map((item, i) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, item.vaultData, network, mainnetWeb3); })));
208
213
  });
209
214
  export const getFluidTokenData = (web3, network, token) => __awaiter(void 0, void 0, void 0, function* () {
210
215
  const view = FluidViewContract(web3, network);
@@ -248,10 +253,10 @@ export const getFluidDepositData = (web3, network, token, address) => __awaiter(
248
253
  depositedShares: getEthAmountForDecimals(userPosition.fTokenShares, decimals),
249
254
  };
250
255
  });
251
- export const getUserPositions = (web3, network, user) => __awaiter(void 0, void 0, void 0, function* () {
256
+ export const getUserPositions = (web3, network, user, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
252
257
  const view = FluidViewContract(web3, network);
253
258
  const data = yield view.methods.getUserPositions(user).call();
254
- const parsedMarketData = yield Promise.all(data.vaults.map((vaultData) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, vaultData, network); })));
259
+ const parsedMarketData = yield Promise.all(data.vaults.map((vaultData) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, vaultData, network, mainnetWeb3); })));
255
260
  const userData = data.positions.map((position, i) => (Object.assign(Object.assign({}, parseUserData(position, parsedMarketData[i])), { nftId: position.nftId })));
256
261
  return parsedMarketData.map((market, i) => ({
257
262
  marketData: market,