@dhedge/v2-sdk 1.1.1 → 1.3.0

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 (59) hide show
  1. package/README.md +60 -3
  2. package/dist/config.d.ts +7 -0
  3. package/dist/entities/pool.d.ts +101 -5
  4. package/dist/entities/utils.d.ts +10 -0
  5. package/dist/services/claim-balancer/claim.service.d.ts +17 -0
  6. package/dist/services/claim-balancer/claim.worker.d.ts +4 -0
  7. package/dist/services/claim-balancer/ipfs.service.d.ts +4 -0
  8. package/dist/services/claim-balancer/types.d.ts +54 -0
  9. package/dist/services/uniswap/V3Liquidity.d.ts +9 -0
  10. package/dist/services/uniswap/V3Trade.d.ts +4 -0
  11. package/dist/services/uniswap/types.d.ts +3 -0
  12. package/dist/test/constants.d.ts +12 -0
  13. package/dist/test/txOptions.d.ts +1 -0
  14. package/dist/types.d.ts +20 -6
  15. package/dist/utils/contract.d.ts +14 -0
  16. package/dist/utils/index.d.ts +7 -0
  17. package/dist/utils/merkle.d.ts +22 -0
  18. package/dist/v2-sdk.cjs.development.js +6086 -918
  19. package/dist/v2-sdk.cjs.development.js.map +1 -1
  20. package/dist/v2-sdk.cjs.production.min.js +1 -1
  21. package/dist/v2-sdk.cjs.production.min.js.map +1 -1
  22. package/dist/v2-sdk.esm.js +6090 -922
  23. package/dist/v2-sdk.esm.js.map +1 -1
  24. package/package.json +12 -2
  25. package/src/abi/IAaveIncentivesController.json +50 -0
  26. package/src/abi/IBalancerMerkleOrchard.json +353 -0
  27. package/src/abi/IBalancertV2Vault.json +938 -0
  28. package/src/abi/IERC20.json +15 -1
  29. package/src/abi/INonfungiblePositionManager.json +1221 -0
  30. package/src/abi/ISynthetix.json +139 -0
  31. package/src/abi/IUniswapV3Quoter.json +195 -0
  32. package/src/abi/IUniswapV3Router.json +221 -0
  33. package/src/config.ts +48 -8
  34. package/src/entities/dhedge.ts +4 -2
  35. package/src/entities/pool.ts +398 -27
  36. package/src/entities/utils.ts +147 -0
  37. package/src/services/claim-balancer/MultiTokenClaim.json +115 -0
  38. package/src/services/claim-balancer/claim.service.ts +262 -0
  39. package/src/services/claim-balancer/claim.worker.ts +32 -0
  40. package/src/services/claim-balancer/ipfs.service.ts +12 -0
  41. package/src/services/claim-balancer/types.ts +66 -0
  42. package/src/services/uniswap/V3Liquidity.ts +134 -0
  43. package/src/services/uniswap/V3Trade.ts +47 -0
  44. package/src/services/uniswap/types.ts +16 -0
  45. package/src/test/aave.test.ts +73 -0
  46. package/src/test/balancer.test.ts +109 -0
  47. package/src/test/constants.ts +17 -0
  48. package/src/test/oneInch.test.ts +56 -0
  49. package/src/test/pool.test.ts +6 -250
  50. package/src/test/sushi.test.ts +173 -0
  51. package/src/test/synthetix.test.ts +34 -0
  52. package/src/test/txOptions.ts +15 -0
  53. package/src/test/uniswap.test.ts +127 -0
  54. package/src/test/utils.test.ts +41 -26
  55. package/src/test/wallet.ts +5 -1
  56. package/src/types.ts +17 -3
  57. package/src/utils/contract.ts +95 -0
  58. package/src/utils/index.ts +38 -0
  59. package/src/utils/merkle.ts +172 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
@@ -28,16 +28,26 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@size-limit/preset-small-lib": "^5.0.1",
31
+ "@types/lodash": "^4.14.178",
31
32
  "husky": "^7.0.1",
32
33
  "size-limit": "^5.0.1",
33
34
  "tsdx": "^0.14.1",
34
35
  "typescript": "^4.3.5"
35
36
  },
36
37
  "dependencies": {
38
+ "@balancer-labs/sor": "^2.0.0-beta.3",
39
+ "@ethersproject/bignumber": "^5.5.0",
40
+ "@ethersproject/providers": "5.0.12",
41
+ "@sushiswap/sdk": "5.0.0-canary.7",
42
+ "@uniswap/sdk-core": "^3.0.1",
43
+ "@uniswap/v3-sdk": "^3.8.2",
37
44
  "axios": "^0.21.4",
45
+ "bignumber.js": "^9.0.2",
38
46
  "dotenv": "^10.0.0",
39
47
  "ethers": "^5.4.1",
40
- "@sushiswap/sdk": "5.0.0-canary.7"
48
+ "jsbi": "^3.1.4",
49
+ "lodash": "^4.17.21",
50
+ "web3-utils": "^1.7.0"
41
51
  },
42
52
  "resolutions": {
43
53
  "**/@typescript-eslint/eslint-plugin": "^4.1.1",
@@ -0,0 +1,50 @@
1
+ {
2
+ "abi": [
3
+ {
4
+ "inputs": [
5
+ {
6
+ "internalType": "address[]",
7
+ "name": "assets",
8
+ "type": "address[]"
9
+ },
10
+ {
11
+ "internalType": "uint256",
12
+ "name": "amount",
13
+ "type": "uint256"
14
+ },
15
+ {
16
+ "internalType": "address",
17
+ "name": "to",
18
+ "type": "address"
19
+ }
20
+ ],
21
+ "name": "claimRewards",
22
+ "outputs": [],
23
+ "stateMutability": "nonpayable",
24
+ "type": "function"
25
+ },
26
+ {
27
+ "inputs": [
28
+ {
29
+ "internalType": "address",
30
+ "name": "user",
31
+ "type": "address"
32
+ }
33
+ ],
34
+ "name": "getUserUnclaimedRewards",
35
+ "outputs": [
36
+ {
37
+ "internalType": "uint256",
38
+ "name": "rewards",
39
+ "type": "uint256"
40
+ }
41
+ ],
42
+ "stateMutability": "view",
43
+ "type": "function"
44
+ }
45
+ ],
46
+ "bytecode": "0x",
47
+ "deployedBytecode": "0x",
48
+ "linkReferences": {},
49
+ "deployedLinkReferences": {}
50
+ }
@@ -0,0 +1,353 @@
1
+ {
2
+ "abi": [
3
+ {
4
+ "inputs": [
5
+ {
6
+ "internalType": "contract IVault",
7
+ "name": "vault",
8
+ "type": "address"
9
+ }
10
+ ],
11
+ "stateMutability": "nonpayable",
12
+ "type": "constructor"
13
+ },
14
+ {
15
+ "anonymous": false,
16
+ "inputs": [
17
+ {
18
+ "indexed": true,
19
+ "internalType": "address",
20
+ "name": "distributor",
21
+ "type": "address"
22
+ },
23
+ {
24
+ "indexed": true,
25
+ "internalType": "contract IERC20",
26
+ "name": "token",
27
+ "type": "address"
28
+ },
29
+ {
30
+ "indexed": false,
31
+ "internalType": "uint256",
32
+ "name": "distributionId",
33
+ "type": "uint256"
34
+ },
35
+ {
36
+ "indexed": false,
37
+ "internalType": "bytes32",
38
+ "name": "merkleRoot",
39
+ "type": "bytes32"
40
+ },
41
+ {
42
+ "indexed": false,
43
+ "internalType": "uint256",
44
+ "name": "amount",
45
+ "type": "uint256"
46
+ }
47
+ ],
48
+ "name": "DistributionAdded",
49
+ "type": "event"
50
+ },
51
+ {
52
+ "anonymous": false,
53
+ "inputs": [
54
+ {
55
+ "indexed": true,
56
+ "internalType": "address",
57
+ "name": "distributor",
58
+ "type": "address"
59
+ },
60
+ {
61
+ "indexed": true,
62
+ "internalType": "contract IERC20",
63
+ "name": "token",
64
+ "type": "address"
65
+ },
66
+ {
67
+ "indexed": false,
68
+ "internalType": "uint256",
69
+ "name": "distributionId",
70
+ "type": "uint256"
71
+ },
72
+ {
73
+ "indexed": true,
74
+ "internalType": "address",
75
+ "name": "claimer",
76
+ "type": "address"
77
+ },
78
+ {
79
+ "indexed": false,
80
+ "internalType": "address",
81
+ "name": "recipient",
82
+ "type": "address"
83
+ },
84
+ {
85
+ "indexed": false,
86
+ "internalType": "uint256",
87
+ "name": "amount",
88
+ "type": "uint256"
89
+ }
90
+ ],
91
+ "name": "DistributionClaimed",
92
+ "type": "event"
93
+ },
94
+ {
95
+ "inputs": [
96
+ { "internalType": "address", "name": "claimer", "type": "address" },
97
+ {
98
+ "components": [
99
+ {
100
+ "internalType": "uint256",
101
+ "name": "distributionId",
102
+ "type": "uint256"
103
+ },
104
+ { "internalType": "uint256", "name": "balance", "type": "uint256" },
105
+ {
106
+ "internalType": "address",
107
+ "name": "distributor",
108
+ "type": "address"
109
+ },
110
+ {
111
+ "internalType": "uint256",
112
+ "name": "tokenIndex",
113
+ "type": "uint256"
114
+ },
115
+ {
116
+ "internalType": "bytes32[]",
117
+ "name": "merkleProof",
118
+ "type": "bytes32[]"
119
+ }
120
+ ],
121
+ "internalType": "struct MerkleOrchard.Claim[]",
122
+ "name": "claims",
123
+ "type": "tuple[]"
124
+ },
125
+ {
126
+ "internalType": "contract IERC20[]",
127
+ "name": "tokens",
128
+ "type": "address[]"
129
+ }
130
+ ],
131
+ "name": "claimDistributions",
132
+ "outputs": [],
133
+ "stateMutability": "nonpayable",
134
+ "type": "function"
135
+ },
136
+ {
137
+ "inputs": [
138
+ { "internalType": "address", "name": "claimer", "type": "address" },
139
+ {
140
+ "components": [
141
+ {
142
+ "internalType": "uint256",
143
+ "name": "distributionId",
144
+ "type": "uint256"
145
+ },
146
+ { "internalType": "uint256", "name": "balance", "type": "uint256" },
147
+ {
148
+ "internalType": "address",
149
+ "name": "distributor",
150
+ "type": "address"
151
+ },
152
+ {
153
+ "internalType": "uint256",
154
+ "name": "tokenIndex",
155
+ "type": "uint256"
156
+ },
157
+ {
158
+ "internalType": "bytes32[]",
159
+ "name": "merkleProof",
160
+ "type": "bytes32[]"
161
+ }
162
+ ],
163
+ "internalType": "struct MerkleOrchard.Claim[]",
164
+ "name": "claims",
165
+ "type": "tuple[]"
166
+ },
167
+ {
168
+ "internalType": "contract IERC20[]",
169
+ "name": "tokens",
170
+ "type": "address[]"
171
+ }
172
+ ],
173
+ "name": "claimDistributionsToInternalBalance",
174
+ "outputs": [],
175
+ "stateMutability": "nonpayable",
176
+ "type": "function"
177
+ },
178
+ {
179
+ "inputs": [
180
+ { "internalType": "address", "name": "claimer", "type": "address" },
181
+ {
182
+ "components": [
183
+ {
184
+ "internalType": "uint256",
185
+ "name": "distributionId",
186
+ "type": "uint256"
187
+ },
188
+ { "internalType": "uint256", "name": "balance", "type": "uint256" },
189
+ {
190
+ "internalType": "address",
191
+ "name": "distributor",
192
+ "type": "address"
193
+ },
194
+ {
195
+ "internalType": "uint256",
196
+ "name": "tokenIndex",
197
+ "type": "uint256"
198
+ },
199
+ {
200
+ "internalType": "bytes32[]",
201
+ "name": "merkleProof",
202
+ "type": "bytes32[]"
203
+ }
204
+ ],
205
+ "internalType": "struct MerkleOrchard.Claim[]",
206
+ "name": "claims",
207
+ "type": "tuple[]"
208
+ },
209
+ {
210
+ "internalType": "contract IERC20[]",
211
+ "name": "tokens",
212
+ "type": "address[]"
213
+ },
214
+ {
215
+ "internalType": "contract IDistributorCallback",
216
+ "name": "callbackContract",
217
+ "type": "address"
218
+ },
219
+ { "internalType": "bytes", "name": "callbackData", "type": "bytes" }
220
+ ],
221
+ "name": "claimDistributionsWithCallback",
222
+ "outputs": [],
223
+ "stateMutability": "nonpayable",
224
+ "type": "function"
225
+ },
226
+ {
227
+ "inputs": [
228
+ {
229
+ "internalType": "contract IERC20",
230
+ "name": "token",
231
+ "type": "address"
232
+ },
233
+ { "internalType": "bytes32", "name": "merkleRoot", "type": "bytes32" },
234
+ { "internalType": "uint256", "name": "amount", "type": "uint256" },
235
+ {
236
+ "internalType": "uint256",
237
+ "name": "distributionId",
238
+ "type": "uint256"
239
+ }
240
+ ],
241
+ "name": "createDistribution",
242
+ "outputs": [],
243
+ "stateMutability": "nonpayable",
244
+ "type": "function"
245
+ },
246
+ {
247
+ "inputs": [
248
+ {
249
+ "internalType": "contract IERC20",
250
+ "name": "token",
251
+ "type": "address"
252
+ },
253
+ { "internalType": "address", "name": "distributor", "type": "address" },
254
+ {
255
+ "internalType": "uint256",
256
+ "name": "distributionId",
257
+ "type": "uint256"
258
+ }
259
+ ],
260
+ "name": "getDistributionRoot",
261
+ "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
262
+ "stateMutability": "view",
263
+ "type": "function"
264
+ },
265
+ {
266
+ "inputs": [
267
+ {
268
+ "internalType": "contract IERC20",
269
+ "name": "token",
270
+ "type": "address"
271
+ },
272
+ { "internalType": "address", "name": "distributor", "type": "address" }
273
+ ],
274
+ "name": "getNextDistributionId",
275
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
276
+ "stateMutability": "view",
277
+ "type": "function"
278
+ },
279
+ {
280
+ "inputs": [
281
+ {
282
+ "internalType": "contract IERC20",
283
+ "name": "token",
284
+ "type": "address"
285
+ },
286
+ { "internalType": "address", "name": "distributor", "type": "address" }
287
+ ],
288
+ "name": "getRemainingBalance",
289
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
290
+ "stateMutability": "view",
291
+ "type": "function"
292
+ },
293
+ {
294
+ "inputs": [],
295
+ "name": "getVault",
296
+ "outputs": [
297
+ { "internalType": "contract IVault", "name": "", "type": "address" }
298
+ ],
299
+ "stateMutability": "view",
300
+ "type": "function"
301
+ },
302
+ {
303
+ "inputs": [
304
+ {
305
+ "internalType": "contract IERC20",
306
+ "name": "token",
307
+ "type": "address"
308
+ },
309
+ { "internalType": "address", "name": "distributor", "type": "address" },
310
+ {
311
+ "internalType": "uint256",
312
+ "name": "distributionId",
313
+ "type": "uint256"
314
+ },
315
+ { "internalType": "address", "name": "claimer", "type": "address" }
316
+ ],
317
+ "name": "isClaimed",
318
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
319
+ "stateMutability": "view",
320
+ "type": "function"
321
+ },
322
+ {
323
+ "inputs": [
324
+ {
325
+ "internalType": "contract IERC20",
326
+ "name": "token",
327
+ "type": "address"
328
+ },
329
+ { "internalType": "address", "name": "distributor", "type": "address" },
330
+ {
331
+ "internalType": "uint256",
332
+ "name": "distributionId",
333
+ "type": "uint256"
334
+ },
335
+ { "internalType": "address", "name": "claimer", "type": "address" },
336
+ {
337
+ "internalType": "uint256",
338
+ "name": "claimedBalance",
339
+ "type": "uint256"
340
+ },
341
+ {
342
+ "internalType": "bytes32[]",
343
+ "name": "merkleProof",
344
+ "type": "bytes32[]"
345
+ }
346
+ ],
347
+ "name": "verifyClaim",
348
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
349
+ "stateMutability": "view",
350
+ "type": "function"
351
+ }
352
+ ]
353
+ }