@ichidao/ichi-vaults-sdk 0.0.112 → 0.1.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 (72) hide show
  1. package/README.md +163 -0
  2. package/dist/abis/types/MultiFeeDistributer.d.ts +475 -0
  3. package/dist/abis/types/MultiFeeDistributer.js +3 -0
  4. package/dist/abis/types/MultiFeeDistributer.js.map +1 -0
  5. package/dist/abis/types/factories/MultiFeeDistributer__factory.d.ts +451 -0
  6. package/dist/abis/types/factories/MultiFeeDistributer__factory.js +596 -0
  7. package/dist/abis/types/factories/MultiFeeDistributer__factory.js.map +1 -0
  8. package/dist/abis/types/factories/index.d.ts +1 -0
  9. package/dist/abis/types/factories/index.js +3 -1
  10. package/dist/abis/types/factories/index.js.map +1 -1
  11. package/dist/abis/types/index.d.ts +2 -0
  12. package/dist/abis/types/index.js +3 -1
  13. package/dist/abis/types/index.js.map +1 -1
  14. package/dist/src/__tests__/index.test.js +74 -1
  15. package/dist/src/__tests__/index.test.js.map +1 -1
  16. package/dist/src/abis/types/MultiFeeDistributer.d.ts +475 -0
  17. package/dist/src/abis/types/factories/MultiFeeDistributer__factory.d.ts +451 -0
  18. package/dist/src/abis/types/factories/index.d.ts +1 -0
  19. package/dist/src/abis/types/index.d.ts +2 -0
  20. package/dist/src/contracts/index.d.ts +2 -1
  21. package/dist/src/contracts/index.js +11 -1
  22. package/dist/src/contracts/index.js.map +1 -1
  23. package/dist/src/functions/claimRewards.d.ts +14 -0
  24. package/dist/src/functions/claimRewards.js +108 -0
  25. package/dist/src/functions/claimRewards.js.map +1 -0
  26. package/dist/src/functions/rewardInfo.d.ts +3 -0
  27. package/dist/src/functions/rewardInfo.js +176 -0
  28. package/dist/src/functions/rewardInfo.js.map +1 -0
  29. package/dist/src/functions/userBalances.d.ts +1 -1
  30. package/dist/src/functions/userBalances.js +64 -29
  31. package/dist/src/functions/userBalances.js.map +1 -1
  32. package/dist/src/functions/userRewards.d.ts +7 -0
  33. package/dist/src/functions/userRewards.js +132 -0
  34. package/dist/src/functions/userRewards.js.map +1 -0
  35. package/dist/src/functions/vault.d.ts +2 -1
  36. package/dist/src/functions/vault.js +75 -26
  37. package/dist/src/functions/vault.js.map +1 -1
  38. package/dist/src/graphql/constants.js +53 -46
  39. package/dist/src/graphql/constants.js.map +1 -1
  40. package/dist/src/graphql/queries.d.ts +14 -1
  41. package/dist/src/graphql/queries.js +57 -18
  42. package/dist/src/graphql/queries.js.map +1 -1
  43. package/dist/src/index.cjs.js +4 -1
  44. package/dist/src/index.d.ts +3 -0
  45. package/dist/src/index.esm.js +4 -1
  46. package/dist/src/index.js +3 -0
  47. package/dist/src/index.js.map +1 -1
  48. package/dist/src/src/contracts/index.d.ts +2 -1
  49. package/dist/src/src/functions/claimRewards.d.ts +14 -0
  50. package/dist/src/src/functions/rewardInfo.d.ts +3 -0
  51. package/dist/src/src/functions/userBalances.d.ts +1 -1
  52. package/dist/src/src/functions/userRewards.d.ts +7 -0
  53. package/dist/src/src/functions/vault.d.ts +2 -1
  54. package/dist/src/src/graphql/queries.d.ts +14 -1
  55. package/dist/src/src/index.d.ts +3 -0
  56. package/dist/src/src/types/index.d.ts +39 -0
  57. package/dist/src/src/types/vaultQueryData.d.ts +10 -1
  58. package/dist/src/src/utils/isVelodrome.d.ts +2 -0
  59. package/dist/src/src/utils/multicallUtils.d.ts +2 -0
  60. package/dist/src/types/index.d.ts +39 -0
  61. package/dist/src/types/index.js +2 -0
  62. package/dist/src/types/index.js.map +1 -1
  63. package/dist/src/types/vaultQueryData.d.ts +10 -1
  64. package/dist/src/utils/config/addresses.js +113 -101
  65. package/dist/src/utils/config/addresses.js.map +1 -1
  66. package/dist/src/utils/isVelodrome.d.ts +2 -0
  67. package/dist/src/utils/isVelodrome.js +11 -0
  68. package/dist/src/utils/isVelodrome.js.map +1 -0
  69. package/dist/src/utils/multicallUtils.d.ts +2 -0
  70. package/dist/src/utils/multicallUtils.js +19 -1
  71. package/dist/src/utils/multicallUtils.js.map +1 -1
  72. package/package.json +1 -1
@@ -0,0 +1,451 @@
1
+ import { Signer } from "ethers";
2
+ import type { Provider } from "@ethersproject/providers";
3
+ import type { MultiFeeDistributer, MultiFeeDistributerInterface } from "../MultiFeeDistributer";
4
+ export declare class MultiFeeDistributer__factory {
5
+ static readonly abi: readonly [{
6
+ readonly inputs: readonly [];
7
+ readonly stateMutability: "nonpayable";
8
+ readonly type: "constructor";
9
+ }, {
10
+ readonly inputs: readonly [];
11
+ readonly name: "ActiveReward";
12
+ readonly type: "error";
13
+ }, {
14
+ readonly inputs: readonly [];
15
+ readonly name: "AddressZero";
16
+ readonly type: "error";
17
+ }, {
18
+ readonly inputs: readonly [];
19
+ readonly name: "InsufficientPermission";
20
+ readonly type: "error";
21
+ }, {
22
+ readonly inputs: readonly [];
23
+ readonly name: "InvalidAmount";
24
+ readonly type: "error";
25
+ }, {
26
+ readonly inputs: readonly [];
27
+ readonly name: "InvalidBurn";
28
+ readonly type: "error";
29
+ }, {
30
+ readonly inputs: readonly [];
31
+ readonly name: "IsStakingToken";
32
+ readonly type: "error";
33
+ }, {
34
+ readonly anonymous: false;
35
+ readonly inputs: readonly [{
36
+ readonly indexed: true;
37
+ readonly internalType: "address";
38
+ readonly name: "previousOwner";
39
+ readonly type: "address";
40
+ }, {
41
+ readonly indexed: true;
42
+ readonly internalType: "address";
43
+ readonly name: "newOwner";
44
+ readonly type: "address";
45
+ }];
46
+ readonly name: "OwnershipTransferred";
47
+ readonly type: "event";
48
+ }, {
49
+ readonly anonymous: false;
50
+ readonly inputs: readonly [{
51
+ readonly indexed: false;
52
+ readonly internalType: "address";
53
+ readonly name: "account";
54
+ readonly type: "address";
55
+ }];
56
+ readonly name: "Paused";
57
+ readonly type: "event";
58
+ }, {
59
+ readonly anonymous: false;
60
+ readonly inputs: readonly [{
61
+ readonly indexed: true;
62
+ readonly internalType: "address";
63
+ readonly name: "token";
64
+ readonly type: "address";
65
+ }, {
66
+ readonly indexed: false;
67
+ readonly internalType: "uint256";
68
+ readonly name: "amount";
69
+ readonly type: "uint256";
70
+ }];
71
+ readonly name: "Recovered";
72
+ readonly type: "event";
73
+ }, {
74
+ readonly anonymous: false;
75
+ readonly inputs: readonly [{
76
+ readonly indexed: true;
77
+ readonly internalType: "address";
78
+ readonly name: "user";
79
+ readonly type: "address";
80
+ }, {
81
+ readonly indexed: true;
82
+ readonly internalType: "address";
83
+ readonly name: "rewardToken";
84
+ readonly type: "address";
85
+ }, {
86
+ readonly indexed: false;
87
+ readonly internalType: "uint256";
88
+ readonly name: "reward";
89
+ readonly type: "uint256";
90
+ }];
91
+ readonly name: "RewardPaid";
92
+ readonly type: "event";
93
+ }, {
94
+ readonly anonymous: false;
95
+ readonly inputs: readonly [];
96
+ readonly name: "RewardsUpdated";
97
+ readonly type: "event";
98
+ }, {
99
+ readonly anonymous: false;
100
+ readonly inputs: readonly [{
101
+ readonly indexed: true;
102
+ readonly internalType: "address";
103
+ readonly name: "user";
104
+ readonly type: "address";
105
+ }, {
106
+ readonly indexed: false;
107
+ readonly internalType: "uint256";
108
+ readonly name: "amount";
109
+ readonly type: "uint256";
110
+ }];
111
+ readonly name: "Stake";
112
+ readonly type: "event";
113
+ }, {
114
+ readonly anonymous: false;
115
+ readonly inputs: readonly [{
116
+ readonly indexed: false;
117
+ readonly internalType: "address";
118
+ readonly name: "account";
119
+ readonly type: "address";
120
+ }];
121
+ readonly name: "Unpaused";
122
+ readonly type: "event";
123
+ }, {
124
+ readonly anonymous: false;
125
+ readonly inputs: readonly [{
126
+ readonly indexed: true;
127
+ readonly internalType: "address";
128
+ readonly name: "user";
129
+ readonly type: "address";
130
+ }, {
131
+ readonly indexed: false;
132
+ readonly internalType: "uint256";
133
+ readonly name: "receivedAmount";
134
+ readonly type: "uint256";
135
+ }];
136
+ readonly name: "Unstake";
137
+ readonly type: "event";
138
+ }, {
139
+ readonly inputs: readonly [{
140
+ readonly internalType: "address";
141
+ readonly name: "_rewardToken";
142
+ readonly type: "address";
143
+ }];
144
+ readonly name: "addReward";
145
+ readonly outputs: readonly [];
146
+ readonly stateMutability: "nonpayable";
147
+ readonly type: "function";
148
+ }, {
149
+ readonly inputs: readonly [{
150
+ readonly internalType: "address";
151
+ readonly name: "";
152
+ readonly type: "address";
153
+ }, {
154
+ readonly internalType: "address";
155
+ readonly name: "";
156
+ readonly type: "address";
157
+ }];
158
+ readonly name: "claimable";
159
+ readonly outputs: readonly [{
160
+ readonly internalType: "uint256";
161
+ readonly name: "";
162
+ readonly type: "uint256";
163
+ }];
164
+ readonly stateMutability: "view";
165
+ readonly type: "function";
166
+ }, {
167
+ readonly inputs: readonly [{
168
+ readonly internalType: "address";
169
+ readonly name: "account";
170
+ readonly type: "address";
171
+ }];
172
+ readonly name: "claimableRewards";
173
+ readonly outputs: readonly [{
174
+ readonly internalType: "address[]";
175
+ readonly name: "";
176
+ readonly type: "address[]";
177
+ }, {
178
+ readonly internalType: "uint256[]";
179
+ readonly name: "";
180
+ readonly type: "uint256[]";
181
+ }];
182
+ readonly stateMutability: "view";
183
+ readonly type: "function";
184
+ }, {
185
+ readonly inputs: readonly [];
186
+ readonly name: "getAllRewards";
187
+ readonly outputs: readonly [{
188
+ readonly internalType: "uint256[]";
189
+ readonly name: "claimableAmounts";
190
+ readonly type: "uint256[]";
191
+ }];
192
+ readonly stateMutability: "nonpayable";
193
+ readonly type: "function";
194
+ }, {
195
+ readonly inputs: readonly [{
196
+ readonly internalType: "address";
197
+ readonly name: "_onBehalfOf";
198
+ readonly type: "address";
199
+ }, {
200
+ readonly internalType: "address[]";
201
+ readonly name: "_rewardTokens";
202
+ readonly type: "address[]";
203
+ }];
204
+ readonly name: "getReward";
205
+ readonly outputs: readonly [{
206
+ readonly internalType: "uint256[]";
207
+ readonly name: "claimableAmounts";
208
+ readonly type: "uint256[]";
209
+ }];
210
+ readonly stateMutability: "nonpayable";
211
+ readonly type: "function";
212
+ }, {
213
+ readonly inputs: readonly [{
214
+ readonly internalType: "address";
215
+ readonly name: "user";
216
+ readonly type: "address";
217
+ }, {
218
+ readonly internalType: "address";
219
+ readonly name: "rewardToken";
220
+ readonly type: "address";
221
+ }];
222
+ readonly name: "getUserRewardPerToken";
223
+ readonly outputs: readonly [{
224
+ readonly internalType: "uint256";
225
+ readonly name: "";
226
+ readonly type: "uint256";
227
+ }];
228
+ readonly stateMutability: "view";
229
+ readonly type: "function";
230
+ }, {
231
+ readonly inputs: readonly [{
232
+ readonly internalType: "address";
233
+ readonly name: "";
234
+ readonly type: "address";
235
+ }];
236
+ readonly name: "managers";
237
+ readonly outputs: readonly [{
238
+ readonly internalType: "bool";
239
+ readonly name: "";
240
+ readonly type: "bool";
241
+ }];
242
+ readonly stateMutability: "view";
243
+ readonly type: "function";
244
+ }, {
245
+ readonly inputs: readonly [];
246
+ readonly name: "owner";
247
+ readonly outputs: readonly [{
248
+ readonly internalType: "address";
249
+ readonly name: "";
250
+ readonly type: "address";
251
+ }];
252
+ readonly stateMutability: "view";
253
+ readonly type: "function";
254
+ }, {
255
+ readonly inputs: readonly [];
256
+ readonly name: "pause";
257
+ readonly outputs: readonly [];
258
+ readonly stateMutability: "nonpayable";
259
+ readonly type: "function";
260
+ }, {
261
+ readonly inputs: readonly [];
262
+ readonly name: "paused";
263
+ readonly outputs: readonly [{
264
+ readonly internalType: "bool";
265
+ readonly name: "";
266
+ readonly type: "bool";
267
+ }];
268
+ readonly stateMutability: "view";
269
+ readonly type: "function";
270
+ }, {
271
+ readonly inputs: readonly [{
272
+ readonly internalType: "address";
273
+ readonly name: "tokenAddress";
274
+ readonly type: "address";
275
+ }, {
276
+ readonly internalType: "uint256";
277
+ readonly name: "tokenAmount";
278
+ readonly type: "uint256";
279
+ }];
280
+ readonly name: "recoverERC20";
281
+ readonly outputs: readonly [];
282
+ readonly stateMutability: "nonpayable";
283
+ readonly type: "function";
284
+ }, {
285
+ readonly inputs: readonly [{
286
+ readonly internalType: "address[]";
287
+ readonly name: "_managers";
288
+ readonly type: "address[]";
289
+ }];
290
+ readonly name: "removeManagers";
291
+ readonly outputs: readonly [];
292
+ readonly stateMutability: "nonpayable";
293
+ readonly type: "function";
294
+ }, {
295
+ readonly inputs: readonly [];
296
+ readonly name: "renounceOwnership";
297
+ readonly outputs: readonly [];
298
+ readonly stateMutability: "nonpayable";
299
+ readonly type: "function";
300
+ }, {
301
+ readonly inputs: readonly [{
302
+ readonly internalType: "address";
303
+ readonly name: "";
304
+ readonly type: "address";
305
+ }];
306
+ readonly name: "rewardData";
307
+ readonly outputs: readonly [{
308
+ readonly internalType: "uint256";
309
+ readonly name: "amount";
310
+ readonly type: "uint256";
311
+ }, {
312
+ readonly internalType: "uint256";
313
+ readonly name: "lastTimeUpdated";
314
+ readonly type: "uint256";
315
+ }, {
316
+ readonly internalType: "uint256";
317
+ readonly name: "rewardPerToken";
318
+ readonly type: "uint256";
319
+ }];
320
+ readonly stateMutability: "view";
321
+ readonly type: "function";
322
+ }, {
323
+ readonly inputs: readonly [{
324
+ readonly internalType: "uint256";
325
+ readonly name: "";
326
+ readonly type: "uint256";
327
+ }];
328
+ readonly name: "rewardTokens";
329
+ readonly outputs: readonly [{
330
+ readonly internalType: "address";
331
+ readonly name: "";
332
+ readonly type: "address";
333
+ }];
334
+ readonly stateMutability: "view";
335
+ readonly type: "function";
336
+ }, {
337
+ readonly inputs: readonly [{
338
+ readonly internalType: "address[]";
339
+ readonly name: "_managers";
340
+ readonly type: "address[]";
341
+ }];
342
+ readonly name: "setManagers";
343
+ readonly outputs: readonly [];
344
+ readonly stateMutability: "nonpayable";
345
+ readonly type: "function";
346
+ }, {
347
+ readonly inputs: readonly [{
348
+ readonly internalType: "uint256";
349
+ readonly name: "amount";
350
+ readonly type: "uint256";
351
+ }, {
352
+ readonly internalType: "address";
353
+ readonly name: "onBehalfOf";
354
+ readonly type: "address";
355
+ }];
356
+ readonly name: "stake";
357
+ readonly outputs: readonly [];
358
+ readonly stateMutability: "nonpayable";
359
+ readonly type: "function";
360
+ }, {
361
+ readonly inputs: readonly [];
362
+ readonly name: "stakingToken";
363
+ readonly outputs: readonly [{
364
+ readonly internalType: "address";
365
+ readonly name: "";
366
+ readonly type: "address";
367
+ }];
368
+ readonly stateMutability: "view";
369
+ readonly type: "function";
370
+ }, {
371
+ readonly inputs: readonly [{
372
+ readonly internalType: "address";
373
+ readonly name: "user";
374
+ readonly type: "address";
375
+ }];
376
+ readonly name: "totalBalance";
377
+ readonly outputs: readonly [{
378
+ readonly internalType: "uint256";
379
+ readonly name: "";
380
+ readonly type: "uint256";
381
+ }];
382
+ readonly stateMutability: "view";
383
+ readonly type: "function";
384
+ }, {
385
+ readonly inputs: readonly [];
386
+ readonly name: "totalStakes";
387
+ readonly outputs: readonly [{
388
+ readonly internalType: "uint256";
389
+ readonly name: "";
390
+ readonly type: "uint256";
391
+ }];
392
+ readonly stateMutability: "view";
393
+ readonly type: "function";
394
+ }, {
395
+ readonly inputs: readonly [{
396
+ readonly internalType: "address";
397
+ readonly name: "newOwner";
398
+ readonly type: "address";
399
+ }];
400
+ readonly name: "transferOwnership";
401
+ readonly outputs: readonly [];
402
+ readonly stateMutability: "nonpayable";
403
+ readonly type: "function";
404
+ }, {
405
+ readonly inputs: readonly [];
406
+ readonly name: "unpause";
407
+ readonly outputs: readonly [];
408
+ readonly stateMutability: "nonpayable";
409
+ readonly type: "function";
410
+ }, {
411
+ readonly inputs: readonly [{
412
+ readonly internalType: "uint256";
413
+ readonly name: "amount";
414
+ readonly type: "uint256";
415
+ }];
416
+ readonly name: "unstake";
417
+ readonly outputs: readonly [];
418
+ readonly stateMutability: "nonpayable";
419
+ readonly type: "function";
420
+ }, {
421
+ readonly inputs: readonly [];
422
+ readonly name: "updateReward";
423
+ readonly outputs: readonly [];
424
+ readonly stateMutability: "nonpayable";
425
+ readonly type: "function";
426
+ }, {
427
+ readonly inputs: readonly [{
428
+ readonly internalType: "address";
429
+ readonly name: "";
430
+ readonly type: "address";
431
+ }];
432
+ readonly name: "userData";
433
+ readonly outputs: readonly [{
434
+ readonly internalType: "uint256";
435
+ readonly name: "tokenAmount";
436
+ readonly type: "uint256";
437
+ }, {
438
+ readonly internalType: "uint256";
439
+ readonly name: "lastTimeUpdated";
440
+ readonly type: "uint256";
441
+ }, {
442
+ readonly internalType: "uint256";
443
+ readonly name: "tokenClaimable";
444
+ readonly type: "uint256";
445
+ }];
446
+ readonly stateMutability: "view";
447
+ readonly type: "function";
448
+ }];
449
+ static createInterface(): MultiFeeDistributerInterface;
450
+ static connect(address: string, signerOrProvider: Signer | Provider): MultiFeeDistributer;
451
+ }
@@ -4,5 +4,6 @@ export { IchiVault__factory } from "./IchiVault__factory";
4
4
  export { AlgebraIntegralPool__factory } from "./AlgebraIntegralPool__factory";
5
5
  export { AlgebraPool__factory } from "./AlgebraPool__factory";
6
6
  export { ClPool__factory } from "./ClPool__factory";
7
+ export { MultiFeeDistributer__factory } from "./MultiFeeDistributer__factory";
7
8
  export { Multicall__factory } from "./Multicall__factory";
8
9
  export { UniswapV3Pool__factory } from "./UniswapV3Pool__factory";
@@ -4,6 +4,7 @@ export type { IchiVault } from "./IchiVault";
4
4
  export type { AlgebraIntegralPool } from "./AlgebraIntegralPool";
5
5
  export type { AlgebraPool } from "./AlgebraPool";
6
6
  export type { ClPool } from "./ClPool";
7
+ export type { MultiFeeDistributer } from "./MultiFeeDistributer";
7
8
  export type { Multicall } from "./Multicall";
8
9
  export type { UniswapV3Pool } from "./UniswapV3Pool";
9
10
  export * as factories from "./factories";
@@ -14,4 +15,5 @@ export { DepositGuard__factory } from "./factories/DepositGuard__factory";
14
15
  export { ERC20__factory } from "./factories/ERC20__factory";
15
16
  export { IchiVault__factory } from "./factories/IchiVault__factory";
16
17
  export { Multicall__factory } from "./factories/Multicall__factory";
18
+ export { MultiFeeDistributer__factory } from "./factories/MultiFeeDistributer__factory";
17
19
  export { UniswapV3Pool__factory } from "./factories/UniswapV3Pool__factory";
@@ -1,6 +1,6 @@
1
1
  import { JsonRpcProvider } from '@ethersproject/providers';
2
2
  import { SignerOrProvider } from '../types';
3
- import { ERC20, IchiVault, DepositGuard, UniswapV3Pool, AlgebraPool, AlgebraIntegralPool, ClPool } from '../../abis/types';
3
+ import { ERC20, IchiVault, DepositGuard, UniswapV3Pool, AlgebraPool, AlgebraIntegralPool, ClPool, MultiFeeDistributer } from '../../abis/types';
4
4
  export declare function getERC20Contract(address: string, signerOrProvider: SignerOrProvider): ERC20;
5
5
  export declare function getDepositGuardContract(address: string, signerOrProvider: SignerOrProvider): DepositGuard;
6
6
  export declare function getIchiVaultContract(address: string, signerOrProvider: SignerOrProvider): IchiVault;
@@ -8,3 +8,4 @@ export declare function getUniswapV3PoolContract(address: string, provider: Json
8
8
  export declare function getAlgebraPoolContract(address: string, provider: JsonRpcProvider): AlgebraPool;
9
9
  export declare function getAlgebraIntegralPoolContract(address: string, provider: JsonRpcProvider): AlgebraIntegralPool;
10
10
  export declare function getClPoolContract(address: string, provider: JsonRpcProvider): ClPool;
11
+ export declare function getMultiFeeDistributorContract(address: string, signerOrProvider: SignerOrProvider): MultiFeeDistributer;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getClPoolContract = exports.getAlgebraIntegralPoolContract = exports.getAlgebraPoolContract = exports.getUniswapV3PoolContract = exports.getIchiVaultContract = exports.getDepositGuardContract = exports.getERC20Contract = void 0;
3
+ exports.getMultiFeeDistributorContract = exports.getClPoolContract = exports.getAlgebraIntegralPoolContract = exports.getAlgebraPoolContract = exports.getUniswapV3PoolContract = exports.getIchiVaultContract = exports.getDepositGuardContract = exports.getERC20Contract = void 0;
4
4
  /* eslint-disable camelcase */
5
5
  var address_1 = require("@ethersproject/address");
6
6
  var types_1 = require("../../abis/types");
@@ -59,4 +59,14 @@ function getClPoolContract(address, provider) {
59
59
  }
60
60
  }
61
61
  exports.getClPoolContract = getClPoolContract;
62
+ function getMultiFeeDistributorContract(address, signerOrProvider) {
63
+ try {
64
+ return types_1.MultiFeeDistributer__factory.connect(address, signerOrProvider);
65
+ }
66
+ catch (e) {
67
+ console.error("Couldn't create MultiFeeDistributer contract with address: ".concat(address));
68
+ throw e;
69
+ }
70
+ }
71
+ exports.getMultiFeeDistributorContract = getMultiFeeDistributorContract;
62
72
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contracts/index.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kDAAoD;AAGpD,0CAe0B;AAE1B,SAAgB,gBAAgB,CAAC,OAAe,EAAE,gBAAkC;IAClF,IAAA,oBAAU,EAAC,OAAO,CAAC,CAAC;IACpB,OAAO,sBAAY,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACzD,CAAC;AAHD,4CAGC;AAED,SAAgB,uBAAuB,CAAC,OAAe,EAAE,gBAAkC;IACzF,IAAA,oBAAU,EAAC,OAAO,CAAC,CAAC;IACpB,OAAO,6BAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAClE,CAAC;AAHD,0DAGC;AAED,SAAgB,oBAAoB,CAAC,OAAe,EAAE,gBAAkC;IACtF,IAAA,oBAAU,EAAC,OAAO,CAAC,CAAC;IACpB,OAAO,0BAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAC/D,CAAC;AAHD,oDAGC;AAED,SAAgB,wBAAwB,CAAC,OAAe,EAAE,QAAyB;IACjF,IAAI;QACF,OAAO,8BAAsB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;KAC1D;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,+DAAwD,OAAO,CAAE,CAAC,CAAC;QACjF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AAPD,4DAOC;AACD,SAAgB,sBAAsB,CAAC,OAAe,EAAE,QAAyB;IAC/E,IAAI;QACF,OAAO,4BAAoB,CAAC,OAAO,CAAC,OA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ACH,CAAC;AAPD,8CAOC;AACD,SAAgB,8BAA8B,CAC5C,OAAe,EACf,gBAAkC;IAElC,IAAI;QACF,OAAO,oCAA4B,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;KACxE;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,qEAA8D,OAAO,CAAE,CAAC,CAAC;QACvF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AAVD,wEAUC"}
@@ -0,0 +1,14 @@
1
+ import { JsonRpcProvider } from '@ethersproject/providers';
2
+ import { ContractTransaction, Overrides } from 'ethers';
3
+ import { SupportedDex } from '../types';
4
+ /**
5
+ * Claims rewards from the farming contract associated with a vault
6
+ *
7
+ * @param accountAddress - The address of the account claiming rewards
8
+ * @param vaultAddress - The address of the vault
9
+ * @param jsonProvider - The JSON RPC provider
10
+ * @param dex - The DEX to use
11
+ * @param overrides - Optional transaction overrides
12
+ * @returns The transaction
13
+ */
14
+ export declare function claimRewards(accountAddress: string, vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex, overrides?: Overrides): Promise<ContractTransaction>;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.claimRewards = void 0;
51
+ var isVelodrome_1 = require("../utils/isVelodrome");
52
+ // eslint-disable-next-line import/no-cycle
53
+ var vault_1 = require("./vault");
54
+ var contracts_1 = require("../contracts");
55
+ var calculateGasMargin_1 = require("../types/calculateGasMargin");
56
+ /**
57
+ * Claims rewards from the farming contract associated with a vault
58
+ *
59
+ * @param accountAddress - The address of the account claiming rewards
60
+ * @param vaultAddress - The address of the vault
61
+ * @param jsonProvider - The JSON RPC provider
62
+ * @param dex - The DEX to use
63
+ * @param overrides - Optional transaction overrides
64
+ * @returns The transaction
65
+ */
66
+ // eslint-disable-next-line import/prefer-default-export
67
+ function claimRewards(accountAddress, vaultAddress, jsonProvider, dex, overrides) {
68
+ var _a;
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var chainId, isVelodrome, vault, signer, farmingContract, gasLimit, _b, _c, tx;
71
+ return __generator(this, function (_d) {
72
+ switch (_d.label) {
73
+ case 0: return [4 /*yield*/, jsonProvider.getNetwork()];
74
+ case 1:
75
+ chainId = (_d.sent()).chainId;
76
+ isVelodrome = (0, isVelodrome_1.isVelodromeDex)(chainId, dex);
77
+ if (!isVelodrome) {
78
+ throw new Error("This function is not supported on chain ".concat(chainId, " and dex ").concat(dex));
79
+ }
80
+ return [4 /*yield*/, (0, vault_1.validateVaultData)(vaultAddress, jsonProvider, dex)];
81
+ case 2:
82
+ vault = (_d.sent()).vault;
83
+ if (!vault.farmingContract || !vault.rewardToken) {
84
+ throw new Error("Vault ".concat(vaultAddress, " does not have an associated farming contract"));
85
+ }
86
+ signer = jsonProvider.getSigner(accountAddress);
87
+ farmingContract = (0, contracts_1.getMultiFeeDistributorContract)(vault.farmingContract, signer);
88
+ if (!((_a = overrides === null || overrides === void 0 ? void 0 : overrides.gasLimit) !== null && _a !== void 0)) return [3 /*break*/, 3];
89
+ _b = _a;
90
+ return [3 /*break*/, 5];
91
+ case 3:
92
+ _c = calculateGasMargin_1.calculateGasMargin;
93
+ return [4 /*yield*/, farmingContract.estimateGas.getReward(accountAddress, [vault.rewardToken])];
94
+ case 4:
95
+ _b = _c.apply(void 0, [_d.sent()]);
96
+ _d.label = 5;
97
+ case 5:
98
+ gasLimit = _b;
99
+ return [4 /*yield*/, farmingContract.getReward(accountAddress, [vault.rewardToken], __assign(__assign({}, overrides), { gasLimit: gasLimit }))];
100
+ case 6:
101
+ tx = _d.sent();
102
+ return [2 /*return*/, tx];
103
+ }
104
+ });
105
+ });
106
+ }
107
+ exports.claimRewards = claimRewards;
108
+ //# sourceMappingURL=claimRewards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claimRewards.js","sourceRoot":"","sources":["../../../src/functions/claimRewards.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,oDAAsD;AACtD,2CAA2C;AAC3C,iCAA4C;AAC5C,0CAA8D;AAC9D,kEAAiE;AAEjE;;;;;;;;;GASG;AACH,wDAAwD;AACxD,SAAsB,YAAY,CAChC,cAAsB,EACtB,YAAoB,EACpB,YAA6B,EAC7B,GAAiB,EACjB,SAAqB;;;;;;wBAED,qBAAM,YAAY,CAAC,UAAU,EAAE,EAAA;;oBAA3C,OAAO,GAAK,CAAA,SAA+B,CAAA,QAApC;oBACT,WAAW,GAAG,IAAA,4BAAc,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;oBACjD,IAAI,CAAC,WAAW,EAAE;wBAChB,MAAM,IAAI,KAAK,CAAC,kDAA2C,OAAO,sBAAY,GAAG,CAAE,CAAC,CAAC;qBACtF;oBAGiB,qBAAM,IAAA,yBAAiB,EAAC,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,EAAA;;oBAAlE,KAAK,GAAK,CAAA,SAAwD,CAAA,MAA7D;oBAEb,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;wBAChD,MAAM,IAAI,KAAK,CAAC,gBAAS,YAAY,kDAA+C,CAAC,CAAC;qBACvF;oBAEK,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;oBAChD,eAAe,GAAG,IAAA,0CAA8B,EAAC,KAAK,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;gCAIpF,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ;;;;oBACnB,KAAA,uCAAkB,CAAA;oBAAC,qBAAM,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAA;;oBAAnG,KAAA,kBAAmB,SAAgF,EAAC,CAAA;;;oBAFhG,QAAQ,KAEwF;oBAG3F,qBAAM,eAAe,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,wBAAO,SAAS,KAAE,QAAQ,UAAA,IAAG,EAAA;;oBAArG,EAAE,GAAG,SAAgG;oBAE3G,sBAAO,EAAE,EAAC;;;;CACX;AAhCD,oCAgCC"}
@@ -0,0 +1,3 @@
1
+ import { RewardInfo, SupportedChainId, SupportedDex } from '../types';
2
+ export declare function getRewardInfo(chainId: SupportedChainId, dex: SupportedDex, vaultAddress: string): Promise<RewardInfo>;
3
+ export declare function getAllRewardInfo(chainId: SupportedChainId, dex: SupportedDex): Promise<RewardInfo[]>;