@defisaver/positions-sdk 0.0.181 → 0.0.182

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 (71) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/.vscode/launch.json +17 -0
  4. package/.vscode/settings.json +37 -0
  5. package/README.md +69 -69
  6. package/cjs/aaveV3/index.js +4 -0
  7. package/cjs/types/aave.d.ts +1 -0
  8. package/esm/aaveV3/index.js +4 -0
  9. package/esm/types/aave.d.ts +1 -0
  10. package/package.json +49 -49
  11. package/src/aaveV2/index.ts +227 -227
  12. package/src/aaveV3/index.ts +628 -624
  13. package/src/assets/index.ts +60 -60
  14. package/src/chickenBonds/index.ts +123 -123
  15. package/src/compoundV2/index.ts +220 -220
  16. package/src/compoundV3/index.ts +282 -282
  17. package/src/config/contracts.js +1040 -1040
  18. package/src/constants/index.ts +6 -6
  19. package/src/contracts.ts +130 -130
  20. package/src/curveUsd/index.ts +229 -229
  21. package/src/eulerV2/index.ts +303 -303
  22. package/src/exchange/index.ts +17 -17
  23. package/src/helpers/aaveHelpers/index.ts +199 -199
  24. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  25. package/src/helpers/compoundHelpers/index.ts +246 -246
  26. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  27. package/src/helpers/eulerHelpers/index.ts +232 -232
  28. package/src/helpers/index.ts +8 -8
  29. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  30. package/src/helpers/makerHelpers/index.ts +94 -94
  31. package/src/helpers/morphoBlueHelpers/index.ts +115 -115
  32. package/src/helpers/sparkHelpers/index.ts +150 -150
  33. package/src/index.ts +48 -48
  34. package/src/liquity/index.ts +116 -116
  35. package/src/llamaLend/index.ts +275 -275
  36. package/src/maker/index.ts +117 -117
  37. package/src/markets/aave/index.ts +152 -152
  38. package/src/markets/aave/marketAssets.ts +46 -46
  39. package/src/markets/compound/index.ts +173 -173
  40. package/src/markets/compound/marketsAssets.ts +64 -64
  41. package/src/markets/curveUsd/index.ts +69 -69
  42. package/src/markets/euler/index.ts +26 -26
  43. package/src/markets/index.ts +23 -23
  44. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  45. package/src/markets/llamaLend/index.ts +235 -235
  46. package/src/markets/morphoBlue/index.ts +809 -809
  47. package/src/markets/spark/index.ts +29 -29
  48. package/src/markets/spark/marketAssets.ts +10 -10
  49. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  50. package/src/morphoAaveV2/index.ts +256 -256
  51. package/src/morphoAaveV3/index.ts +630 -630
  52. package/src/morphoBlue/index.ts +171 -171
  53. package/src/multicall/index.ts +22 -22
  54. package/src/services/dsrService.ts +15 -15
  55. package/src/services/priceService.ts +21 -21
  56. package/src/services/utils.ts +56 -56
  57. package/src/setup.ts +8 -8
  58. package/src/spark/index.ts +461 -461
  59. package/src/staking/staking.ts +222 -222
  60. package/src/types/aave.ts +270 -269
  61. package/src/types/chickenBonds.ts +45 -45
  62. package/src/types/common.ts +84 -84
  63. package/src/types/compound.ts +129 -129
  64. package/src/types/curveUsd.ts +118 -118
  65. package/src/types/euler.ts +171 -171
  66. package/src/types/index.ts +9 -9
  67. package/src/types/liquity.ts +30 -30
  68. package/src/types/llamaLend.ts +155 -155
  69. package/src/types/maker.ts +50 -50
  70. package/src/types/morphoBlue.ts +154 -154
  71. 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
@@ -0,0 +1,17 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Attach by Process ID",
9
+ "processId": "${command:PickProcess}",
10
+ "request": "attach",
11
+ "skipFiles": [
12
+ "<node_internals>/**"
13
+ ],
14
+ "type": "node"
15
+ }
16
+ ]
17
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "workbench.colorCustomizations": {
3
+ "activityBar.activeBackground": "#f2255a",
4
+ "activityBar.background": "#f2255a",
5
+ "activityBar.foreground": "#e7e7e7",
6
+ "activityBar.inactiveForeground": "#e7e7e799",
7
+ "activityBarBadge.background": "#40d30d",
8
+ "activityBarBadge.foreground": "#15202b",
9
+ "commandCenter.border": "#e7e7e799",
10
+ "sash.hoverBorder": "#f2255a",
11
+ "statusBar.background": "#d70d41",
12
+ "statusBar.foreground": "#e7e7e7",
13
+ "statusBarItem.hoverBackground": "#f2255a",
14
+ "statusBarItem.remoteBackground": "#d70d41",
15
+ "statusBarItem.remoteForeground": "#e7e7e7",
16
+ "titleBar.activeBackground": "#d70d41",
17
+ "titleBar.activeForeground": "#e7e7e7",
18
+ "titleBar.inactiveBackground": "#d70d4199",
19
+ "titleBar.inactiveForeground": "#e7e7e799"
20
+ },
21
+ "peacock.color": "#d70d41",
22
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint",
23
+ "eslint.format.enable": true,
24
+
25
+ "[javascript]": {
26
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint"
27
+ },
28
+ "[typescript]": {
29
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint"
30
+ },
31
+ "[vue]": {
32
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint"
33
+ },
34
+ "[typescriptreact]": {
35
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint"
36
+ }
37
+ }
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
@@ -198,6 +198,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
198
198
  _market.supplyIncentives.push({
199
199
  apy: _market.incentiveSupplyApy || '0',
200
200
  token: _market.symbol,
201
+ incentiveKind: 'staking',
201
202
  });
202
203
  }
203
204
  if (_market.canBeBorrowed && _market.incentiveSupplyApy) {
@@ -209,6 +210,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
209
210
  _market.borrowIncentives.push({
210
211
  apy: _market.incentiveBorrowApy,
211
212
  token: _market.incentiveBorrowToken,
213
+ incentiveKind: 'reward',
212
214
  });
213
215
  }
214
216
  if (!rewardForMarket)
@@ -238,6 +240,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
238
240
  _market.supplyIncentives.push({
239
241
  token: supplyRewardData.rewardTokenSymbol,
240
242
  apy: rewardApy,
243
+ incentiveKind: 'reward',
241
244
  });
242
245
  }
243
246
  });
@@ -265,6 +268,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
265
268
  _market.borrowIncentives.push({
266
269
  token: borrowRewardData.rewardTokenSymbol,
267
270
  apy: rewardApy,
271
+ incentiveKind: 'reward',
268
272
  });
269
273
  }
270
274
  });
@@ -76,6 +76,7 @@ export interface MorphoAaveV2AssetData extends AaveV2AssetData {
76
76
  export interface IncentiveData {
77
77
  token: string;
78
78
  apy: string;
79
+ incentiveKind?: 'staking' | 'reward';
79
80
  }
80
81
  export interface AaveV3AssetData extends AaveAssetData {
81
82
  isIsolated: boolean;
@@ -189,6 +189,7 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
189
189
  _market.supplyIncentives.push({
190
190
  apy: _market.incentiveSupplyApy || '0',
191
191
  token: _market.symbol,
192
+ incentiveKind: 'staking',
192
193
  });
193
194
  }
194
195
  if (_market.canBeBorrowed && _market.incentiveSupplyApy) {
@@ -200,6 +201,7 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
200
201
  _market.borrowIncentives.push({
201
202
  apy: _market.incentiveBorrowApy,
202
203
  token: _market.incentiveBorrowToken,
204
+ incentiveKind: 'reward',
203
205
  });
204
206
  }
205
207
  if (!rewardForMarket)
@@ -229,6 +231,7 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
229
231
  _market.supplyIncentives.push({
230
232
  token: supplyRewardData.rewardTokenSymbol,
231
233
  apy: rewardApy,
234
+ incentiveKind: 'reward',
232
235
  });
233
236
  }
234
237
  });
@@ -256,6 +259,7 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
256
259
  _market.borrowIncentives.push({
257
260
  token: borrowRewardData.rewardTokenSymbol,
258
261
  apy: rewardApy,
262
+ incentiveKind: 'reward',
259
263
  });
260
264
  }
261
265
  });
@@ -76,6 +76,7 @@ export interface MorphoAaveV2AssetData extends AaveV2AssetData {
76
76
  export interface IncentiveData {
77
77
  token: string;
78
78
  apy: string;
79
+ incentiveKind?: 'staking' | 'reward';
79
80
  }
80
81
  export interface AaveV3AssetData extends AaveAssetData {
81
82
  isIsolated: boolean;
package/package.json CHANGED
@@ -1,49 +1,49 @@
1
- {
2
- "name": "@defisaver/positions-sdk",
3
- "version": "0.0.181",
4
- "description": "",
5
- "main": "./cjs/index.js",
6
- "module": "./esm/index.js",
7
- "types": "./esm/index.d.ts",
8
- "scripts": {
9
- "build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
10
- "build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
11
- "build": "npm run lint && npm run generate-contracts && npm run build:cjs && npm run build:esm",
12
- "dev": "npm run generate-contracts && tsc -p tsconfig.json --watch",
13
- "lint": "eslint src/ --fix",
14
- "lint-check": "eslint src/",
15
- "generate-contracts": "node scripts/generateContracts.js",
16
- "test": "mocha tests/*",
17
- "test-single": "mocha ./tests/$npm_config_name.ts",
18
- "test:debugger": "mocha --inspect-brk tests/*",
19
- "build-test": "npm run build && npm run test",
20
- "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
21
- },
22
- "keywords": [],
23
- "author": "",
24
- "license": "ISC",
25
- "dependencies": {
26
- "@defisaver/tokens": "^1.5.50",
27
- "@ethersproject/bignumber": "^5.7.0",
28
- "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
29
- "decimal.js": "^10.4.3"
30
- },
31
- "devDependencies": {
32
- "@defisaver/eslint-config": "^1.0.1",
33
- "@types/chai": "^5.0.0",
34
- "@types/mocha": "^10.0.9",
35
- "@types/web3": "^1.0.20",
36
- "chai": "^4.3.8",
37
- "dotenv": "^16.3.1",
38
- "eslint": "^8.49.0",
39
- "eslint-plugin-import": "^2.31.0",
40
- "mocha": "^10.2.0",
41
- "ts-node": "^10.9.2",
42
- "typechain": "^8.3.1",
43
- "typechain-target-web3-v1-3mihai3": "^6.0.2",
44
- "typescript": "^5.2.2"
45
- },
46
- "peerDependencies": {
47
- "web3": "^1.10.2"
48
- }
49
- }
1
+ {
2
+ "name": "@defisaver/positions-sdk",
3
+ "version": "0.0.182",
4
+ "description": "",
5
+ "main": "./cjs/index.js",
6
+ "module": "./esm/index.js",
7
+ "types": "./esm/index.d.ts",
8
+ "scripts": {
9
+ "build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
10
+ "build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
11
+ "build": "npm run lint && npm run generate-contracts && npm run build:cjs && npm run build:esm",
12
+ "dev": "npm run generate-contracts && tsc -p tsconfig.json --watch",
13
+ "lint": "eslint src/ --fix",
14
+ "lint-check": "eslint src/",
15
+ "generate-contracts": "node scripts/generateContracts.js",
16
+ "test": "mocha tests/*",
17
+ "test-single": "mocha ./tests/$npm_config_name.ts",
18
+ "test:debugger": "mocha --inspect-brk tests/*",
19
+ "build-test": "npm run build && npm run test",
20
+ "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
21
+ },
22
+ "keywords": [],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "dependencies": {
26
+ "@defisaver/tokens": "^1.5.50",
27
+ "@ethersproject/bignumber": "^5.7.0",
28
+ "@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
29
+ "decimal.js": "^10.4.3"
30
+ },
31
+ "devDependencies": {
32
+ "@defisaver/eslint-config": "^1.0.1",
33
+ "@types/chai": "^5.0.0",
34
+ "@types/mocha": "^10.0.9",
35
+ "@types/web3": "^1.0.20",
36
+ "chai": "^4.3.8",
37
+ "dotenv": "^16.3.1",
38
+ "eslint": "^8.49.0",
39
+ "eslint-plugin-import": "^2.31.0",
40
+ "mocha": "^10.2.0",
41
+ "ts-node": "^10.9.2",
42
+ "typechain": "^8.3.1",
43
+ "typechain-target-web3-v1-3mihai3": "^6.0.2",
44
+ "typescript": "^5.2.2"
45
+ },
46
+ "peerDependencies": {
47
+ "web3": "^1.10.2"
48
+ }
49
+ }