@dhedge/v2-sdk 1.1.1 → 1.2.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.
- package/README.md +60 -3
- package/dist/config.d.ts +2 -0
- package/dist/entities/pool.d.ts +32 -0
- package/dist/entities/utils.d.ts +4 -0
- package/dist/services/claim-balancer/claim.service.d.ts +21 -0
- package/dist/services/claim-balancer/claim.worker.d.ts +4 -0
- package/dist/services/claim-balancer/ipfs.service.d.ts +4 -0
- package/dist/services/claim-balancer/types.d.ts +54 -0
- package/dist/test/constants.d.ts +12 -0
- package/dist/types.d.ts +5 -2
- package/dist/utils/contract.d.ts +14 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/merkle.d.ts +22 -0
- package/dist/v2-sdk.cjs.development.js +3623 -672
- package/dist/v2-sdk.cjs.development.js.map +1 -1
- package/dist/v2-sdk.cjs.production.min.js +1 -1
- package/dist/v2-sdk.cjs.production.min.js.map +1 -1
- package/dist/v2-sdk.esm.js +3623 -672
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +9 -2
- package/src/abi/IAaveIncentivesController.json +50 -0
- package/src/abi/IBalancerMerkleOrchard.json +353 -0
- package/src/abi/IBalancertV2Vault.json +938 -0
- package/src/config.ts +16 -3
- package/src/entities/pool.ts +140 -1
- package/src/entities/utils.ts +135 -0
- package/src/services/claim-balancer/MultiTokenClaim.json +115 -0
- package/src/services/claim-balancer/claim.service.ts +324 -0
- package/src/services/claim-balancer/claim.worker.ts +32 -0
- package/src/services/claim-balancer/ipfs.service.ts +12 -0
- package/src/services/claim-balancer/types.ts +66 -0
- package/src/test/aave.test.ts +73 -0
- package/src/test/balancer.test.ts +109 -0
- package/src/test/constants.ts +13 -0
- package/src/test/oneInch.test.ts +56 -0
- package/src/test/pool.test.ts +5 -249
- package/src/test/sushi.test.ts +173 -0
- package/src/test/utils.test.ts +41 -26
- package/src/types.ts +6 -3
- package/src/utils/contract.ts +95 -0
- package/src/utils/index.ts +38 -0
- 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.
|
|
3
|
+
"version": "1.2.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,23 @@
|
|
|
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",
|
|
37
42
|
"axios": "^0.21.4",
|
|
43
|
+
"bignumber.js": "^9.0.2",
|
|
38
44
|
"dotenv": "^10.0.0",
|
|
39
45
|
"ethers": "^5.4.1",
|
|
40
|
-
"
|
|
46
|
+
"lodash": "^4.17.21",
|
|
47
|
+
"web3-utils": "^1.7.0"
|
|
41
48
|
},
|
|
42
49
|
"resolutions": {
|
|
43
50
|
"**/@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
|
+
}
|