@defisaver/positions-sdk 0.0.59 → 0.0.60

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 (66) hide show
  1. package/README.md +63 -63
  2. package/cjs/aaveV3/index.js +2 -1
  3. package/cjs/config/contracts.d.ts +9 -0
  4. package/cjs/config/contracts.js +10 -1
  5. package/cjs/llamaLend/index.js +0 -3
  6. package/esm/aaveV3/index.js +2 -1
  7. package/esm/config/contracts.d.ts +9 -0
  8. package/esm/config/contracts.js +10 -1
  9. package/esm/llamaLend/index.js +0 -3
  10. package/package.json +40 -40
  11. package/src/aaveV2/index.ts +227 -227
  12. package/src/aaveV3/index.ts +562 -561
  13. package/src/assets/index.ts +60 -60
  14. package/src/chickenBonds/index.ts +123 -123
  15. package/src/compoundV2/index.ts +219 -219
  16. package/src/compoundV3/index.ts +273 -273
  17. package/src/config/contracts.js +860 -851
  18. package/src/constants/index.ts +5 -5
  19. package/src/contracts.ts +126 -126
  20. package/src/curveUsd/index.ts +229 -229
  21. package/src/exchange/index.ts +17 -17
  22. package/src/helpers/aaveHelpers/index.ts +134 -134
  23. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  24. package/src/helpers/compoundHelpers/index.ts +181 -181
  25. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  26. package/src/helpers/index.ts +7 -7
  27. package/src/helpers/llamaLendHelpers/index.ts +45 -45
  28. package/src/helpers/makerHelpers/index.ts +94 -94
  29. package/src/helpers/morphoBlueHelpers/index.ts +56 -56
  30. package/src/helpers/sparkHelpers/index.ts +106 -106
  31. package/src/index.ts +46 -46
  32. package/src/liquity/index.ts +116 -116
  33. package/src/llamaLend/index.ts +276 -279
  34. package/src/maker/index.ts +117 -117
  35. package/src/markets/aave/index.ts +80 -80
  36. package/src/markets/aave/marketAssets.ts +24 -24
  37. package/src/markets/compound/index.ts +141 -141
  38. package/src/markets/compound/marketsAssets.ts +48 -48
  39. package/src/markets/curveUsd/index.ts +69 -69
  40. package/src/markets/index.ts +5 -5
  41. package/src/markets/llamaLend/index.ts +65 -65
  42. package/src/markets/morphoBlue/index.ts +262 -262
  43. package/src/markets/spark/index.ts +29 -29
  44. package/src/markets/spark/marketAssets.ts +10 -10
  45. package/src/moneymarket/moneymarketCommonService.ts +75 -75
  46. package/src/morphoAaveV2/index.ts +256 -256
  47. package/src/morphoAaveV3/index.ts +619 -619
  48. package/src/morphoBlue/index.ts +177 -177
  49. package/src/multicall/index.ts +22 -22
  50. package/src/services/dsrService.ts +15 -15
  51. package/src/services/priceService.ts +21 -21
  52. package/src/services/utils.ts +51 -51
  53. package/src/setup.ts +8 -8
  54. package/src/spark/index.ts +422 -422
  55. package/src/staking/staking.ts +174 -174
  56. package/src/types/aave.ts +256 -256
  57. package/src/types/chickenBonds.ts +45 -45
  58. package/src/types/common.ts +83 -83
  59. package/src/types/compound.ts +128 -128
  60. package/src/types/curveUsd.ts +118 -118
  61. package/src/types/index.ts +8 -8
  62. package/src/types/liquity.ts +30 -30
  63. package/src/types/llamaLend.ts +119 -119
  64. package/src/types/maker.ts +50 -50
  65. package/src/types/morphoBlue.ts +107 -107
  66. package/src/types/spark.ts +106 -106
package/README.md CHANGED
@@ -1,63 +1,63 @@
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)
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)
@@ -122,7 +122,8 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
122
122
  isBorrowAllowed = (0, utils_1.isLayer2Network)(network) ? isBorrowAllowed : true;
123
123
  const [{ 0: ghoDiscountedPerDiscountToken }, { 0: discountRate }, { 0: minDiscountTokenBalance }, { 0: minGhoBalanceForDiscount }, { 0: facilitatorsList },] = multiRes;
124
124
  let rewardInfo = null;
125
- if (network === 10) {
125
+ const networksWithIncentives = [10, 42161];
126
+ if (networksWithIncentives.includes(network)) {
126
127
  rewardInfo = yield aaveIncentivesContract.methods.getReservesIncentivesData(marketAddress).call();
127
128
  rewardInfo = rewardInfo.reduce((all, _market) => {
128
129
  // eslint-disable-next-line no-param-reassign
@@ -723,9 +723,18 @@ export namespace AaveUiIncentiveDataProviderV3 {
723
723
  }[];
724
724
  export { abi_4 as abi };
725
725
  let networks_4: {
726
+ "1": {
727
+ address: string;
728
+ };
726
729
  "10": {
727
730
  address: string;
728
731
  };
732
+ "8453": {
733
+ address: string;
734
+ };
735
+ "42161": {
736
+ address: string;
737
+ };
729
738
  };
730
739
  export { networks_4 as networks };
731
740
  }
@@ -151,8 +151,17 @@ module.exports = {
151
151
  "AaveUiIncentiveDataProviderV3": {
152
152
  "abi": [{ "inputs": [{ "internalType": "contract IPoolAddressesProvider", "name": "provider", "type": "address" }], "name": "getReservesIncentivesData", "outputs": [{ "components": [{ "internalType": "address", "name": "underlyingAsset", "type": "address" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "aIncentiveData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "vIncentiveData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "sIncentiveData", "type": "tuple" }], "internalType": "struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract IPoolAddressesProvider", "name": "provider", "type": "address" }, { "internalType": "address", "name": "user", "type": "address" }], "name": "getUserReservesIncentivesData", "outputs": [{ "components": [{ "internalType": "address", "name": "underlyingAsset", "type": "address" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "aTokenIncentivesUserData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "vTokenIncentivesUserData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "sTokenIncentivesUserData", "type": "tuple" }], "internalType": "struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }],
153
153
  "networks": {
154
+ "1": {
155
+ "address": "0x162A7AC02f547ad796CA549f757e2b8d1D9b10a6"
156
+ },
154
157
  "10": {
155
- "address": "0x6dD4b295B457A26CC2646aAf2519436681afb5d4"
158
+ "address": "0x6F143FE2F7B02424ad3CaD1593D6f36c0Aab69d7"
159
+ },
160
+ "8453": {
161
+ "address": "0xEdD3b4737C1a0011626631a977b91Cf3E944982d"
162
+ },
163
+ "42161": {
164
+ "address": "0xDA67AF3403555Ce0AE3ffC22fDb7354458277358"
156
165
  }
157
166
  }
158
167
  },
@@ -65,7 +65,6 @@ const getLlamaLendGlobalData = (web3, network, selectedMarket) => __awaiter(void
65
65
  const FeedRegistryAbi = (0, contracts_1.getConfigContractAbi)('FeedRegistry');
66
66
  const collAsset = selectedMarket.collAsset;
67
67
  const debtAsset = selectedMarket.baseAsset;
68
- console.log(selectedMarket.controllerAddress);
69
68
  // if something else is needed
70
69
  const multicallData = [
71
70
  {
@@ -80,10 +79,8 @@ const getLlamaLendGlobalData = (web3, network, selectedMarket) => __awaiter(void
80
79
  },
81
80
  ];
82
81
  const multiRes = yield (0, multicall_1.multicall)(multicallData, web3, network);
83
- console.log(multiRes);
84
82
  const data = multiRes[1][0];
85
83
  const debtUsdPrice = (0, utils_1.getEthAmountForDecimals)(multiRes[0][0], 8);
86
- console.log('here');
87
84
  // all prices are in 18 decimals
88
85
  const totalDebt = (0, tokens_1.assetAmountInEth)(data.totalDebt, debtAsset);
89
86
  const totalDebtSupplied = (0, tokens_1.assetAmountInEth)(data.debtTokenTotalSupply, debtAsset);
@@ -113,7 +113,8 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
113
113
  isBorrowAllowed = isLayer2Network(network) ? isBorrowAllowed : true;
114
114
  const [{ 0: ghoDiscountedPerDiscountToken }, { 0: discountRate }, { 0: minDiscountTokenBalance }, { 0: minGhoBalanceForDiscount }, { 0: facilitatorsList },] = multiRes;
115
115
  let rewardInfo = null;
116
- if (network === 10) {
116
+ const networksWithIncentives = [10, 42161];
117
+ if (networksWithIncentives.includes(network)) {
117
118
  rewardInfo = yield aaveIncentivesContract.methods.getReservesIncentivesData(marketAddress).call();
118
119
  rewardInfo = rewardInfo.reduce((all, _market) => {
119
120
  // eslint-disable-next-line no-param-reassign
@@ -723,9 +723,18 @@ export namespace AaveUiIncentiveDataProviderV3 {
723
723
  }[];
724
724
  export { abi_4 as abi };
725
725
  let networks_4: {
726
+ "1": {
727
+ address: string;
728
+ };
726
729
  "10": {
727
730
  address: string;
728
731
  };
732
+ "8453": {
733
+ address: string;
734
+ };
735
+ "42161": {
736
+ address: string;
737
+ };
729
738
  };
730
739
  export { networks_4 as networks };
731
740
  }
@@ -150,8 +150,17 @@ module.exports = {
150
150
  "AaveUiIncentiveDataProviderV3": {
151
151
  "abi": [{ "inputs": [{ "internalType": "contract IPoolAddressesProvider", "name": "provider", "type": "address" }], "name": "getReservesIncentivesData", "outputs": [{ "components": [{ "internalType": "address", "name": "underlyingAsset", "type": "address" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "aIncentiveData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "vIncentiveData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "sIncentiveData", "type": "tuple" }], "internalType": "struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract IPoolAddressesProvider", "name": "provider", "type": "address" }, { "internalType": "address", "name": "user", "type": "address" }], "name": "getUserReservesIncentivesData", "outputs": [{ "components": [{ "internalType": "address", "name": "underlyingAsset", "type": "address" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "aTokenIncentivesUserData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "vTokenIncentivesUserData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "sTokenIncentivesUserData", "type": "tuple" }], "internalType": "struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }],
152
152
  "networks": {
153
+ "1": {
154
+ "address": "0x162A7AC02f547ad796CA549f757e2b8d1D9b10a6"
155
+ },
153
156
  "10": {
154
- "address": "0x6dD4b295B457A26CC2646aAf2519436681afb5d4"
157
+ "address": "0x6F143FE2F7B02424ad3CaD1593D6f36c0Aab69d7"
158
+ },
159
+ "8453": {
160
+ "address": "0xEdD3b4737C1a0011626631a977b91Cf3E944982d"
161
+ },
162
+ "42161": {
163
+ "address": "0xDA67AF3403555Ce0AE3ffC22fDb7354458277358"
155
164
  }
156
165
  }
157
166
  },
@@ -59,7 +59,6 @@ export const getLlamaLendGlobalData = (web3, network, selectedMarket) => __await
59
59
  const FeedRegistryAbi = getConfigContractAbi('FeedRegistry');
60
60
  const collAsset = selectedMarket.collAsset;
61
61
  const debtAsset = selectedMarket.baseAsset;
62
- console.log(selectedMarket.controllerAddress);
63
62
  // if something else is needed
64
63
  const multicallData = [
65
64
  {
@@ -74,10 +73,8 @@ export const getLlamaLendGlobalData = (web3, network, selectedMarket) => __await
74
73
  },
75
74
  ];
76
75
  const multiRes = yield multicall(multicallData, web3, network);
77
- console.log(multiRes);
78
76
  const data = multiRes[1][0];
79
77
  const debtUsdPrice = getEthAmountForDecimals(multiRes[0][0], 8);
80
- console.log('here');
81
78
  // all prices are in 18 decimals
82
79
  const totalDebt = assetAmountInEth(data.totalDebt, debtAsset);
83
80
  const totalDebtSupplied = assetAmountInEth(data.debtTokenTotalSupply, debtAsset);
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
- {
2
- "name": "@defisaver/positions-sdk",
3
- "version": "0.0.59",
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.json",
10
- "build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
11
- "build": "npm run generate-contracts && npm run build:cjs && npm run build:esm",
12
- "dev": "npm run generate-contracts && tsc -p tsconfig.cjs.json --watch",
13
- "lint": "eslint src/ --fix",
14
- "generate-contracts": "node scripts/generateContracts.js",
15
- "test": "mocha tests/*",
16
- "build-test": "npm run build && mocha tests/*"
17
- },
18
- "keywords": [],
19
- "author": "",
20
- "license": "ISC",
21
- "dependencies": {
22
- "@defisaver/tokens": "^1.5.9",
23
- "@ethersproject/bignumber": "^5.7.0",
24
- "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
25
- "decimal.js": "^10.4.3"
26
- },
27
- "devDependencies": {
28
- "@defisaver/eslint-config": "^1.0.1",
29
- "chai": "^4.3.8",
30
- "dotenv": "^16.3.1",
31
- "eslint": "^8.49.0",
32
- "mocha": "^10.2.0",
33
- "typechain": "^8.3.1",
34
- "typechain-target-web3-v1-3mihai3": "^6.0.2",
35
- "typescript": "^5.2.2"
36
- },
37
- "peerDependencies": {
38
- "web3": "^1.10.2"
39
- }
40
- }
1
+ {
2
+ "name": "@defisaver/positions-sdk",
3
+ "version": "0.0.60",
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.json",
10
+ "build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
11
+ "build": "npm run generate-contracts && npm run build:cjs && npm run build:esm",
12
+ "dev": "npm run generate-contracts && tsc -p tsconfig.cjs.json --watch",
13
+ "lint": "eslint src/ --fix",
14
+ "generate-contracts": "node scripts/generateContracts.js",
15
+ "test": "mocha tests/*",
16
+ "build-test": "npm run build && mocha tests/*"
17
+ },
18
+ "keywords": [],
19
+ "author": "",
20
+ "license": "ISC",
21
+ "dependencies": {
22
+ "@defisaver/tokens": "^1.5.9",
23
+ "@ethersproject/bignumber": "^5.7.0",
24
+ "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
25
+ "decimal.js": "^10.4.3"
26
+ },
27
+ "devDependencies": {
28
+ "@defisaver/eslint-config": "^1.0.1",
29
+ "chai": "^4.3.8",
30
+ "dotenv": "^16.3.1",
31
+ "eslint": "^8.49.0",
32
+ "mocha": "^10.2.0",
33
+ "typechain": "^8.3.1",
34
+ "typechain-target-web3-v1-3mihai3": "^6.0.2",
35
+ "typescript": "^5.2.2"
36
+ },
37
+ "peerDependencies": {
38
+ "web3": "^1.10.2"
39
+ }
40
+ }