@defisaver/positions-sdk 0.0.24 → 0.0.25

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 (56) hide show
  1. package/README.md +63 -63
  2. package/cjs/spark/index.js +1 -0
  3. package/esm/spark/index.js +1 -0
  4. package/package.json +40 -40
  5. package/src/aaveV2/index.ts +226 -226
  6. package/src/aaveV3/index.ts +561 -561
  7. package/src/assets/index.ts +60 -60
  8. package/src/chickenBonds/index.ts +123 -123
  9. package/src/compoundV2/index.ts +219 -219
  10. package/src/compoundV3/index.ts +275 -275
  11. package/src/config/contracts.js +673 -673
  12. package/src/constants/index.ts +3 -3
  13. package/src/contracts.ts +100 -100
  14. package/src/curveUsd/index.ts +228 -228
  15. package/src/exchange/index.ts +17 -17
  16. package/src/helpers/aaveHelpers/index.ts +134 -134
  17. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  18. package/src/helpers/compoundHelpers/index.ts +181 -181
  19. package/src/helpers/curveUsdHelpers/index.ts +32 -32
  20. package/src/helpers/index.ts +5 -5
  21. package/src/helpers/makerHelpers/index.ts +94 -94
  22. package/src/helpers/sparkHelpers/index.ts +106 -106
  23. package/src/index.ts +40 -40
  24. package/src/liquity/index.ts +116 -116
  25. package/src/maker/index.ts +101 -101
  26. package/src/markets/aave/index.ts +80 -80
  27. package/src/markets/aave/marketAssets.ts +32 -32
  28. package/src/markets/compound/index.ts +141 -141
  29. package/src/markets/compound/marketsAssets.ts +46 -46
  30. package/src/markets/curveUsd/index.ts +69 -69
  31. package/src/markets/index.ts +3 -3
  32. package/src/markets/spark/index.ts +29 -29
  33. package/src/markets/spark/marketAssets.ts +9 -9
  34. package/src/moneymarket/moneymarketCommonService.ts +75 -75
  35. package/src/morpho/markets.ts +39 -39
  36. package/src/morphoAaveV2/index.ts +255 -255
  37. package/src/morphoAaveV3/index.ts +619 -619
  38. package/src/multicall/index.ts +22 -22
  39. package/src/services/dsrService.ts +15 -15
  40. package/src/services/priceService.ts +21 -21
  41. package/src/services/utils.ts +34 -34
  42. package/src/spark/index.ts +422 -421
  43. package/src/staking/staking.ts +167 -167
  44. package/src/types/aave.ts +256 -256
  45. package/src/types/chickenBonds.ts +45 -45
  46. package/src/types/common.ts +83 -83
  47. package/src/types/compound.ts +128 -128
  48. package/src/types/curveUsd.ts +112 -112
  49. package/src/types/index.ts +6 -6
  50. package/src/types/liquity.ts +30 -30
  51. package/src/types/maker.ts +50 -50
  52. package/src/types/spark.ts +106 -106
  53. package/.yarn/releases/yarn-1.22.1.cjs +0 -147386
  54. package/.yarn/releases/yarn-1.22.1.js +0 -147386
  55. package/.yarnrc.yml +0 -1
  56. package/package-lock.json +0 -12896
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)
@@ -105,6 +105,7 @@ const getSparkMarketsData = (web3, network, selectedMarket, mainnetWeb3) => __aw
105
105
  price: new decimal_js_1.default(market.price.toString()).div(1e8).toString(),
106
106
  isolationModeBorrowingEnabled: market.isolationModeBorrowingEnabled,
107
107
  isFlashLoanEnabled: market.isFlashLoanEnabled,
108
+ aTokenAddress: market.aTokenAddress,
108
109
  eModeCategoryData: {
109
110
  label: market.label,
110
111
  liquidationBonus: new decimal_js_1.default(market.liquidationBonus).div(10000).toString(),
@@ -98,6 +98,7 @@ export const getSparkMarketsData = (web3, network, selectedMarket, mainnetWeb3)
98
98
  price: new Dec(market.price.toString()).div(1e8).toString(),
99
99
  isolationModeBorrowingEnabled: market.isolationModeBorrowingEnabled,
100
100
  isFlashLoanEnabled: market.isFlashLoanEnabled,
101
+ aTokenAddress: market.aTokenAddress,
101
102
  eModeCategoryData: {
102
103
  label: market.label,
103
104
  liquidationBonus: new Dec(market.liquidationBonus).div(10000).toString(),
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
- {
2
- "name": "@defisaver/positions-sdk",
3
- "version": "0.0.24",
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.5",
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.25",
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.5",
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
+ }