@defisaver/positions-sdk 0.0.59 → 0.0.61-dev

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 (105) hide show
  1. package/README.md +63 -63
  2. package/cjs/aaveV3/index.js +2 -1
  3. package/cjs/config/contracts.d.ts +20 -189
  4. package/cjs/config/contracts.js +16 -26
  5. package/cjs/llamaLend/index.js +28 -32
  6. package/cjs/markets/llamaLend/contractAddresses.d.ts +9 -0
  7. package/cjs/markets/llamaLend/contractAddresses.js +88 -0
  8. package/cjs/markets/llamaLend/index.d.ts +12 -10
  9. package/cjs/markets/llamaLend/index.js +41 -57
  10. package/cjs/types/contracts/generated/{LlamaLendCRVCrvUSDController.d.ts → LlamaLendControllerAbi.d.ts} +3 -3
  11. package/cjs/types/contracts/generated/LlamaLendView.d.ts +5 -0
  12. package/cjs/types/contracts/generated/index.d.ts +1 -4
  13. package/cjs/types/llamaLend.d.ts +35 -9
  14. package/cjs/types/llamaLend.js +26 -8
  15. package/esm/aaveV3/index.js +2 -1
  16. package/esm/config/contracts.d.ts +20 -189
  17. package/esm/config/contracts.js +16 -26
  18. package/esm/llamaLend/index.js +31 -35
  19. package/esm/markets/llamaLend/contractAddresses.d.ts +9 -0
  20. package/esm/markets/llamaLend/contractAddresses.js +84 -0
  21. package/esm/markets/llamaLend/index.d.ts +12 -10
  22. package/esm/markets/llamaLend/index.js +31 -55
  23. package/esm/types/contracts/generated/{LlamaLendCrvUSDCRVController.d.ts → LlamaLendControllerAbi.d.ts} +3 -3
  24. package/esm/types/contracts/generated/LlamaLendView.d.ts +5 -0
  25. package/esm/types/contracts/generated/index.d.ts +1 -4
  26. package/esm/types/llamaLend.d.ts +35 -9
  27. package/esm/types/llamaLend.js +25 -7
  28. package/package.json +40 -40
  29. package/src/aaveV2/index.ts +227 -227
  30. package/src/aaveV3/index.ts +562 -561
  31. package/src/assets/index.ts +60 -60
  32. package/src/chickenBonds/index.ts +123 -123
  33. package/src/compoundV2/index.ts +219 -219
  34. package/src/compoundV3/index.ts +273 -273
  35. package/src/config/contracts.js +841 -851
  36. package/src/constants/index.ts +5 -5
  37. package/src/contracts.ts +128 -127
  38. package/src/curveUsd/index.ts +229 -229
  39. package/src/exchange/index.ts +17 -17
  40. package/src/helpers/aaveHelpers/index.ts +134 -134
  41. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  42. package/src/helpers/compoundHelpers/index.ts +181 -181
  43. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  44. package/src/helpers/index.ts +7 -7
  45. package/src/helpers/llamaLendHelpers/index.ts +45 -45
  46. package/src/helpers/makerHelpers/index.ts +94 -94
  47. package/src/helpers/morphoBlueHelpers/index.ts +56 -56
  48. package/src/helpers/sparkHelpers/index.ts +106 -106
  49. package/src/index.ts +46 -46
  50. package/src/liquity/index.ts +116 -116
  51. package/src/llamaLend/index.ts +268 -279
  52. package/src/maker/index.ts +117 -117
  53. package/src/markets/aave/index.ts +80 -80
  54. package/src/markets/aave/marketAssets.ts +24 -24
  55. package/src/markets/compound/index.ts +141 -141
  56. package/src/markets/compound/marketsAssets.ts +48 -48
  57. package/src/markets/curveUsd/index.ts +69 -69
  58. package/src/markets/index.ts +5 -5
  59. package/src/markets/llamaLend/contractAddresses.ts +93 -0
  60. package/src/markets/llamaLend/index.ts +150 -65
  61. package/src/markets/morphoBlue/index.ts +262 -262
  62. package/src/markets/spark/index.ts +29 -29
  63. package/src/markets/spark/marketAssets.ts +10 -10
  64. package/src/moneymarket/moneymarketCommonService.ts +75 -75
  65. package/src/morphoAaveV2/index.ts +256 -256
  66. package/src/morphoAaveV3/index.ts +619 -619
  67. package/src/morphoBlue/index.ts +177 -177
  68. package/src/multicall/index.ts +22 -22
  69. package/src/services/dsrService.ts +15 -15
  70. package/src/services/priceService.ts +21 -21
  71. package/src/services/utils.ts +51 -51
  72. package/src/setup.ts +8 -8
  73. package/src/spark/index.ts +422 -422
  74. package/src/staking/staking.ts +174 -174
  75. package/src/types/aave.ts +256 -256
  76. package/src/types/chickenBonds.ts +45 -45
  77. package/src/types/common.ts +84 -84
  78. package/src/types/compound.ts +128 -128
  79. package/src/types/contracts/generated/{LlamaLendCRVCrvUSDController.ts → LlamaLendControllerAbi.ts} +3 -3
  80. package/src/types/contracts/generated/LlamaLendView.ts +9 -0
  81. package/src/types/contracts/generated/index.ts +1 -4
  82. package/src/types/curveUsd.ts +118 -118
  83. package/src/types/index.ts +8 -8
  84. package/src/types/liquity.ts +30 -30
  85. package/src/types/llamaLend.ts +143 -119
  86. package/src/types/maker.ts +50 -50
  87. package/src/types/morphoBlue.ts +107 -107
  88. package/src/types/spark.ts +106 -106
  89. package/cjs/types/contracts/generated/LlamaLendCrvUSDCRVController.d.ts +0 -209
  90. package/cjs/types/contracts/generated/LlamaLendCrvUSDCRVController.js +0 -5
  91. package/cjs/types/contracts/generated/LlamaLendTBTCCrvUSDController.d.ts +0 -209
  92. package/cjs/types/contracts/generated/LlamaLendTBTCCrvUSDController.js +0 -5
  93. package/cjs/types/contracts/generated/LlamaLendWstETHCrvUSDController.d.ts +0 -209
  94. package/cjs/types/contracts/generated/LlamaLendWstETHCrvUSDController.js +0 -5
  95. package/esm/types/contracts/generated/LlamaLendCRVCrvUSDController.d.ts +0 -209
  96. package/esm/types/contracts/generated/LlamaLendCrvUSDCRVController.js +0 -4
  97. package/esm/types/contracts/generated/LlamaLendTBTCCrvUSDController.d.ts +0 -209
  98. package/esm/types/contracts/generated/LlamaLendTBTCCrvUSDController.js +0 -4
  99. package/esm/types/contracts/generated/LlamaLendWstETHCrvUSDController.d.ts +0 -209
  100. package/esm/types/contracts/generated/LlamaLendWstETHCrvUSDController.js +0 -4
  101. package/src/types/contracts/generated/LlamaLendCrvUSDCRVController.ts +0 -416
  102. package/src/types/contracts/generated/LlamaLendTBTCCrvUSDController.ts +0 -416
  103. package/src/types/contracts/generated/LlamaLendWstETHCrvUSDController.ts +0 -416
  104. /package/cjs/types/contracts/generated/{LlamaLendCRVCrvUSDController.js → LlamaLendControllerAbi.js} +0 -0
  105. /package/esm/types/contracts/generated/{LlamaLendCRVCrvUSDController.js → LlamaLendControllerAbi.js} +0 -0
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
  }
@@ -4619,6 +4628,12 @@ export namespace FeedRegistry {
4619
4628
  }
4620
4629
  export namespace LlamaLendView {
4621
4630
  let abi_69: ({
4631
+ inputs: never[];
4632
+ name: string;
4633
+ type: string;
4634
+ outputs?: undefined;
4635
+ stateMutability?: undefined;
4636
+ } | {
4622
4637
  inputs: {
4623
4638
  internalType: string;
4624
4639
  name: string;
@@ -4667,10 +4682,13 @@ export namespace LlamaLendView {
4667
4682
  "1": {
4668
4683
  address: string;
4669
4684
  };
4685
+ "42161": {
4686
+ address: string;
4687
+ };
4670
4688
  };
4671
4689
  export { networks_69 as networks };
4672
4690
  }
4673
- export namespace LlamaLendWstETHCrvUSDController {
4691
+ export namespace LlamaLendControllerAbi {
4674
4692
  let abi_70: ({
4675
4693
  name: string;
4676
4694
  inputs: {
@@ -4724,193 +4742,6 @@ export namespace LlamaLendWstETHCrvUSDController {
4724
4742
  anonymous?: undefined;
4725
4743
  })[];
4726
4744
  export { abi_70 as abi };
4727
- let networks_70: {
4728
- "1": {
4729
- address: string;
4730
- };
4731
- };
4745
+ let networks_70: {};
4732
4746
  export { networks_70 as networks };
4733
4747
  }
4734
- export namespace LlamaLendCRVCrvUSDController {
4735
- let abi_71: ({
4736
- name: string;
4737
- inputs: {
4738
- name: string;
4739
- type: string;
4740
- indexed: boolean;
4741
- }[];
4742
- anonymous: boolean;
4743
- type: string;
4744
- stateMutability?: undefined;
4745
- outputs?: undefined;
4746
- } | {
4747
- stateMutability: string;
4748
- type: string;
4749
- inputs: {
4750
- name: string;
4751
- type: string;
4752
- }[];
4753
- outputs: never[];
4754
- name?: undefined;
4755
- anonymous?: undefined;
4756
- } | {
4757
- stateMutability: string;
4758
- type: string;
4759
- name: string;
4760
- inputs: {
4761
- name: string;
4762
- type: string;
4763
- }[];
4764
- outputs: {
4765
- name: string;
4766
- type: string;
4767
- }[];
4768
- anonymous?: undefined;
4769
- } | {
4770
- stateMutability: string;
4771
- type: string;
4772
- name: string;
4773
- inputs: {
4774
- name: string;
4775
- type: string;
4776
- }[];
4777
- outputs: {
4778
- name: string;
4779
- type: string;
4780
- components: {
4781
- name: string;
4782
- type: string;
4783
- }[];
4784
- }[];
4785
- anonymous?: undefined;
4786
- })[];
4787
- export { abi_71 as abi };
4788
- let networks_71: {
4789
- "1": {
4790
- address: string;
4791
- };
4792
- };
4793
- export { networks_71 as networks };
4794
- }
4795
- export namespace LlamaLendCrvUSDCRVController {
4796
- let abi_72: ({
4797
- name: string;
4798
- inputs: {
4799
- name: string;
4800
- type: string;
4801
- indexed: boolean;
4802
- }[];
4803
- anonymous: boolean;
4804
- type: string;
4805
- stateMutability?: undefined;
4806
- outputs?: undefined;
4807
- } | {
4808
- stateMutability: string;
4809
- type: string;
4810
- inputs: {
4811
- name: string;
4812
- type: string;
4813
- }[];
4814
- outputs: never[];
4815
- name?: undefined;
4816
- anonymous?: undefined;
4817
- } | {
4818
- stateMutability: string;
4819
- type: string;
4820
- name: string;
4821
- inputs: {
4822
- name: string;
4823
- type: string;
4824
- }[];
4825
- outputs: {
4826
- name: string;
4827
- type: string;
4828
- }[];
4829
- anonymous?: undefined;
4830
- } | {
4831
- stateMutability: string;
4832
- type: string;
4833
- name: string;
4834
- inputs: {
4835
- name: string;
4836
- type: string;
4837
- }[];
4838
- outputs: {
4839
- name: string;
4840
- type: string;
4841
- components: {
4842
- name: string;
4843
- type: string;
4844
- }[];
4845
- }[];
4846
- anonymous?: undefined;
4847
- })[];
4848
- export { abi_72 as abi };
4849
- let networks_72: {
4850
- "1": {
4851
- address: string;
4852
- };
4853
- };
4854
- export { networks_72 as networks };
4855
- }
4856
- export namespace LlamaLendTBTCCrvUSDController {
4857
- let abi_73: ({
4858
- name: string;
4859
- inputs: {
4860
- name: string;
4861
- type: string;
4862
- indexed: boolean;
4863
- }[];
4864
- anonymous: boolean;
4865
- type: string;
4866
- stateMutability?: undefined;
4867
- outputs?: undefined;
4868
- } | {
4869
- stateMutability: string;
4870
- type: string;
4871
- inputs: {
4872
- name: string;
4873
- type: string;
4874
- }[];
4875
- outputs: never[];
4876
- name?: undefined;
4877
- anonymous?: undefined;
4878
- } | {
4879
- stateMutability: string;
4880
- type: string;
4881
- name: string;
4882
- inputs: {
4883
- name: string;
4884
- type: string;
4885
- }[];
4886
- outputs: {
4887
- name: string;
4888
- type: string;
4889
- }[];
4890
- anonymous?: undefined;
4891
- } | {
4892
- stateMutability: string;
4893
- type: string;
4894
- name: string;
4895
- inputs: {
4896
- name: string;
4897
- type: string;
4898
- }[];
4899
- outputs: {
4900
- name: string;
4901
- type: string;
4902
- components: {
4903
- name: string;
4904
- type: string;
4905
- }[];
4906
- }[];
4907
- anonymous?: undefined;
4908
- })[];
4909
- export { abi_73 as abi };
4910
- let networks_73: {
4911
- "1": {
4912
- address: string;
4913
- };
4914
- };
4915
- export { networks_73 as networks };
4916
- }