@curvefi/api 2.13.1 → 2.15.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 CHANGED
@@ -1027,6 +1027,8 @@ import curve from "@curvefi/api";
1027
1027
  ```
1028
1028
 
1029
1029
  ## Boosting
1030
+
1031
+ ### Lock
1030
1032
  ```ts
1031
1033
  import curve from "@curvefi/api";
1032
1034
 
@@ -1068,6 +1070,26 @@ import curve from "@curvefi/api";
1068
1070
  // 0.000018613852077810 veCRV %
1069
1071
  })()
1070
1072
  ```
1073
+ ### Claim fees
1074
+ ```ts
1075
+ import curve from "@curvefi/api";
1076
+
1077
+ (async () => {
1078
+ await curve.init('JsonRpc', {});
1079
+
1080
+ await curve.getBalances(['3crv']);
1081
+ // ['0.0']
1082
+ await curve.boosting.claimableFees();
1083
+ // 1.30699696445248888
1084
+
1085
+ await curve.boosting.claimFees();
1086
+
1087
+ await curve.getBalances(['3crv']);
1088
+ // ['1.30699696445248888']
1089
+ await curve.boosting.claimableFees();
1090
+ // 0.0
1091
+ })()
1092
+ ```
1071
1093
 
1072
1094
  ## CRV. Profit, claim, boosting
1073
1095
  ```ts
package/lib/boosting.d.ts CHANGED
@@ -20,3 +20,6 @@ export declare const increaseUnlockTimeEstimateGas: (days: number) => Promise<nu
20
20
  export declare const increaseUnlockTime: (days: number) => Promise<string>;
21
21
  export declare const withdrawLockedCrvEstimateGas: () => Promise<number>;
22
22
  export declare const withdrawLockedCrv: () => Promise<string>;
23
+ export declare const claimableFees: (address?: string) => Promise<string>;
24
+ export declare const claimFeesEstimateGas: (address?: string) => Promise<number>;
25
+ export declare const claimFees: (address?: string) => Promise<string>;
package/lib/boosting.js CHANGED
@@ -46,12 +46,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
47
  }
48
48
  };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
49
52
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.withdrawLockedCrv = exports.withdrawLockedCrvEstimateGas = exports.increaseUnlockTime = exports.increaseUnlockTimeEstimateGas = exports.increaseAmount = exports.increaseAmountEstimateGas = exports.createLock = exports.createLockEstimateGas = exports.approve = exports.approveEstimateGas = exports.isApproved = exports.getVeCrvPct = exports.getVeCrv = exports.getLockedAmountAndUnlockTime = exports.getCrv = void 0;
53
+ exports.claimFees = exports.claimFeesEstimateGas = exports.claimableFees = exports.withdrawLockedCrv = exports.withdrawLockedCrvEstimateGas = exports.increaseUnlockTime = exports.increaseUnlockTimeEstimateGas = exports.increaseAmount = exports.increaseAmountEstimateGas = exports.createLock = exports.createLockEstimateGas = exports.approve = exports.approveEstimateGas = exports.isApproved = exports.getVeCrvPct = exports.getVeCrv = exports.getLockedAmountAndUnlockTime = exports.getCrv = void 0;
51
54
  var ethers_1 = require("ethers");
55
+ var curve_1 = require("./curve");
56
+ var fee_distributor_view_json_1 = __importDefault(require("./constants/abis/fee_distributor_view.json"));
52
57
  var utils_1 = require("./utils");
53
58
  var utils_2 = require("./utils");
54
- var curve_1 = require("./curve");
55
59
  var getCrv = function () {
56
60
  var addresses = [];
57
61
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -348,3 +352,58 @@ var withdrawLockedCrv = function () { return __awaiter(void 0, void 0, void 0, f
348
352
  });
349
353
  }); };
350
354
  exports.withdrawLockedCrv = withdrawLockedCrv;
355
+ var claimableFees = function (address) {
356
+ if (address === void 0) { address = ""; }
357
+ return __awaiter(void 0, void 0, void 0, function () {
358
+ var contract, _a, _b;
359
+ return __generator(this, function (_c) {
360
+ switch (_c.label) {
361
+ case 0:
362
+ address = address || curve_1.curve.signerAddress;
363
+ contract = new ethers_1.Contract(curve_1.curve.constants.ALIASES.fee_distributor, fee_distributor_view_json_1.default, curve_1.curve.provider);
364
+ _b = (_a = ethers_1.ethers.utils).formatUnits;
365
+ return [4 /*yield*/, contract.claim(address, curve_1.curve.constantOptions)];
366
+ case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
367
+ }
368
+ });
369
+ });
370
+ };
371
+ exports.claimableFees = claimableFees;
372
+ var claimFeesEstimateGas = function (address) {
373
+ if (address === void 0) { address = ""; }
374
+ return __awaiter(void 0, void 0, void 0, function () {
375
+ var contract;
376
+ return __generator(this, function (_a) {
377
+ switch (_a.label) {
378
+ case 0:
379
+ address = address || curve_1.curve.signerAddress;
380
+ contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.fee_distributor].contract;
381
+ return [4 /*yield*/, contract.estimateGas.claim(address, curve_1.curve.constantOptions)];
382
+ case 1: return [2 /*return*/, (_a.sent()).toNumber()];
383
+ }
384
+ });
385
+ });
386
+ };
387
+ exports.claimFeesEstimateGas = claimFeesEstimateGas;
388
+ var claimFees = function (address) {
389
+ if (address === void 0) { address = ""; }
390
+ return __awaiter(void 0, void 0, void 0, function () {
391
+ var contract, gasLimit;
392
+ return __generator(this, function (_a) {
393
+ switch (_a.label) {
394
+ case 0:
395
+ address = address || curve_1.curve.signerAddress;
396
+ contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.fee_distributor].contract;
397
+ return [4 /*yield*/, curve_1.curve.updateFeeData()];
398
+ case 1:
399
+ _a.sent();
400
+ return [4 /*yield*/, contract.estimateGas.claim(address, curve_1.curve.constantOptions)];
401
+ case 2:
402
+ gasLimit = (_a.sent()).mul(130).div(100);
403
+ return [4 /*yield*/, contract.claim(address, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
404
+ case 3: return [2 /*return*/, (_a.sent()).hash];
405
+ }
406
+ });
407
+ });
408
+ };
409
+ exports.claimFees = claimFees;
@@ -0,0 +1,483 @@
1
+ [
2
+ {
3
+ "name": "CommitAdmin",
4
+ "inputs": [
5
+ {
6
+ "type": "address",
7
+ "name": "admin",
8
+ "indexed": false
9
+ }
10
+ ],
11
+ "anonymous": false,
12
+ "type": "event"
13
+ },
14
+ {
15
+ "name": "ApplyAdmin",
16
+ "inputs": [
17
+ {
18
+ "type": "address",
19
+ "name": "admin",
20
+ "indexed": false
21
+ }
22
+ ],
23
+ "anonymous": false,
24
+ "type": "event"
25
+ },
26
+ {
27
+ "name": "ToggleAllowCheckpointToken",
28
+ "inputs": [
29
+ {
30
+ "type": "bool",
31
+ "name": "toggle_flag",
32
+ "indexed": false
33
+ }
34
+ ],
35
+ "anonymous": false,
36
+ "type": "event"
37
+ },
38
+ {
39
+ "name": "CheckpointToken",
40
+ "inputs": [
41
+ {
42
+ "type": "uint256",
43
+ "name": "time",
44
+ "indexed": false
45
+ },
46
+ {
47
+ "type": "uint256",
48
+ "name": "tokens",
49
+ "indexed": false
50
+ }
51
+ ],
52
+ "anonymous": false,
53
+ "type": "event"
54
+ },
55
+ {
56
+ "name": "Claimed",
57
+ "inputs": [
58
+ {
59
+ "type": "address",
60
+ "name": "recipient",
61
+ "indexed": true
62
+ },
63
+ {
64
+ "type": "uint256",
65
+ "name": "amount",
66
+ "indexed": false
67
+ },
68
+ {
69
+ "type": "uint256",
70
+ "name": "claim_epoch",
71
+ "indexed": false
72
+ },
73
+ {
74
+ "type": "uint256",
75
+ "name": "max_epoch",
76
+ "indexed": false
77
+ }
78
+ ],
79
+ "anonymous": false,
80
+ "type": "event"
81
+ },
82
+ {
83
+ "outputs": [],
84
+ "inputs": [
85
+ {
86
+ "type": "address",
87
+ "name": "_voting_escrow"
88
+ },
89
+ {
90
+ "type": "uint256",
91
+ "name": "_start_time"
92
+ },
93
+ {
94
+ "type": "address",
95
+ "name": "_token"
96
+ },
97
+ {
98
+ "type": "address",
99
+ "name": "_admin"
100
+ },
101
+ {
102
+ "type": "address",
103
+ "name": "_emergency_return"
104
+ }
105
+ ],
106
+ "stateMutability": "nonpayable",
107
+ "type": "constructor"
108
+ },
109
+ {
110
+ "name": "checkpoint_token",
111
+ "outputs": [],
112
+ "inputs": [],
113
+ "stateMutability": "nonpayable",
114
+ "type": "function",
115
+ "gas": "820723"
116
+ },
117
+ {
118
+ "name": "ve_for_at",
119
+ "outputs": [
120
+ {
121
+ "type": "uint256",
122
+ "name": ""
123
+ }
124
+ ],
125
+ "inputs": [
126
+ {
127
+ "type": "address",
128
+ "name": "_user"
129
+ },
130
+ {
131
+ "type": "uint256",
132
+ "name": "_timestamp"
133
+ }
134
+ ],
135
+ "stateMutability": "view",
136
+ "type": "function",
137
+ "gas": "249417"
138
+ },
139
+ {
140
+ "name": "checkpoint_total_supply",
141
+ "outputs": [],
142
+ "inputs": [],
143
+ "stateMutability": "nonpayable",
144
+ "type": "function",
145
+ "gas": "10592405"
146
+ },
147
+ {
148
+ "name": "claim",
149
+ "outputs": [
150
+ {
151
+ "type": "uint256",
152
+ "name": ""
153
+ }
154
+ ],
155
+ "inputs": [
156
+ {
157
+ "type": "address",
158
+ "name": "_addr"
159
+ }
160
+ ],
161
+ "stateMutability": "nonpayable",
162
+ "type": "function"
163
+ },
164
+ {
165
+ "name": "claim_many",
166
+ "outputs": [
167
+ {
168
+ "type": "bool",
169
+ "name": ""
170
+ }
171
+ ],
172
+ "inputs": [
173
+ {
174
+ "type": "address[20]",
175
+ "name": "_receivers"
176
+ }
177
+ ],
178
+ "stateMutability": "nonpayable",
179
+ "type": "function",
180
+ "gas": "26281905"
181
+ },
182
+ {
183
+ "name": "burn",
184
+ "outputs": [
185
+ {
186
+ "type": "bool",
187
+ "name": ""
188
+ }
189
+ ],
190
+ "inputs": [
191
+ {
192
+ "type": "address",
193
+ "name": "_coin"
194
+ }
195
+ ],
196
+ "stateMutability": "nonpayable",
197
+ "type": "function",
198
+ "gas": "823450"
199
+ },
200
+ {
201
+ "name": "commit_admin",
202
+ "outputs": [],
203
+ "inputs": [
204
+ {
205
+ "type": "address",
206
+ "name": "_addr"
207
+ }
208
+ ],
209
+ "stateMutability": "nonpayable",
210
+ "type": "function",
211
+ "gas": "37898"
212
+ },
213
+ {
214
+ "name": "apply_admin",
215
+ "outputs": [],
216
+ "inputs": [],
217
+ "stateMutability": "nonpayable",
218
+ "type": "function",
219
+ "gas": "39534"
220
+ },
221
+ {
222
+ "name": "toggle_allow_checkpoint_token",
223
+ "outputs": [],
224
+ "inputs": [],
225
+ "stateMutability": "nonpayable",
226
+ "type": "function",
227
+ "gas": "38673"
228
+ },
229
+ {
230
+ "name": "kill_me",
231
+ "outputs": [],
232
+ "inputs": [],
233
+ "stateMutability": "nonpayable",
234
+ "type": "function",
235
+ "gas": "39587"
236
+ },
237
+ {
238
+ "name": "recover_balance",
239
+ "outputs": [
240
+ {
241
+ "type": "bool",
242
+ "name": ""
243
+ }
244
+ ],
245
+ "inputs": [
246
+ {
247
+ "type": "address",
248
+ "name": "_coin"
249
+ }
250
+ ],
251
+ "stateMutability": "nonpayable",
252
+ "type": "function",
253
+ "gas": "7778"
254
+ },
255
+ {
256
+ "name": "start_time",
257
+ "outputs": [
258
+ {
259
+ "type": "uint256",
260
+ "name": ""
261
+ }
262
+ ],
263
+ "inputs": [],
264
+ "stateMutability": "view",
265
+ "type": "function",
266
+ "gas": "1541"
267
+ },
268
+ {
269
+ "name": "time_cursor",
270
+ "outputs": [
271
+ {
272
+ "type": "uint256",
273
+ "name": ""
274
+ }
275
+ ],
276
+ "inputs": [],
277
+ "stateMutability": "view",
278
+ "type": "function",
279
+ "gas": "1571"
280
+ },
281
+ {
282
+ "name": "time_cursor_of",
283
+ "outputs": [
284
+ {
285
+ "type": "uint256",
286
+ "name": ""
287
+ }
288
+ ],
289
+ "inputs": [
290
+ {
291
+ "type": "address",
292
+ "name": "arg0"
293
+ }
294
+ ],
295
+ "stateMutability": "view",
296
+ "type": "function",
297
+ "gas": "1816"
298
+ },
299
+ {
300
+ "name": "user_epoch_of",
301
+ "outputs": [
302
+ {
303
+ "type": "uint256",
304
+ "name": ""
305
+ }
306
+ ],
307
+ "inputs": [
308
+ {
309
+ "type": "address",
310
+ "name": "arg0"
311
+ }
312
+ ],
313
+ "stateMutability": "view",
314
+ "type": "function",
315
+ "gas": "1846"
316
+ },
317
+ {
318
+ "name": "last_token_time",
319
+ "outputs": [
320
+ {
321
+ "type": "uint256",
322
+ "name": ""
323
+ }
324
+ ],
325
+ "inputs": [],
326
+ "stateMutability": "view",
327
+ "type": "function",
328
+ "gas": "1661"
329
+ },
330
+ {
331
+ "name": "tokens_per_week",
332
+ "outputs": [
333
+ {
334
+ "type": "uint256",
335
+ "name": ""
336
+ }
337
+ ],
338
+ "inputs": [
339
+ {
340
+ "type": "uint256",
341
+ "name": "arg0"
342
+ }
343
+ ],
344
+ "stateMutability": "view",
345
+ "type": "function",
346
+ "gas": "1800"
347
+ },
348
+ {
349
+ "name": "voting_escrow",
350
+ "outputs": [
351
+ {
352
+ "type": "address",
353
+ "name": ""
354
+ }
355
+ ],
356
+ "inputs": [],
357
+ "stateMutability": "view",
358
+ "type": "function",
359
+ "gas": "1721"
360
+ },
361
+ {
362
+ "name": "token",
363
+ "outputs": [
364
+ {
365
+ "type": "address",
366
+ "name": ""
367
+ }
368
+ ],
369
+ "inputs": [],
370
+ "stateMutability": "view",
371
+ "type": "function",
372
+ "gas": "1751"
373
+ },
374
+ {
375
+ "name": "total_received",
376
+ "outputs": [
377
+ {
378
+ "type": "uint256",
379
+ "name": ""
380
+ }
381
+ ],
382
+ "inputs": [],
383
+ "stateMutability": "view",
384
+ "type": "function",
385
+ "gas": "1781"
386
+ },
387
+ {
388
+ "name": "token_last_balance",
389
+ "outputs": [
390
+ {
391
+ "type": "uint256",
392
+ "name": ""
393
+ }
394
+ ],
395
+ "inputs": [],
396
+ "stateMutability": "view",
397
+ "type": "function",
398
+ "gas": "1811"
399
+ },
400
+ {
401
+ "name": "ve_supply",
402
+ "outputs": [
403
+ {
404
+ "type": "uint256",
405
+ "name": ""
406
+ }
407
+ ],
408
+ "inputs": [
409
+ {
410
+ "type": "uint256",
411
+ "name": "arg0"
412
+ }
413
+ ],
414
+ "stateMutability": "view",
415
+ "type": "function",
416
+ "gas": "1950"
417
+ },
418
+ {
419
+ "name": "admin",
420
+ "outputs": [
421
+ {
422
+ "type": "address",
423
+ "name": ""
424
+ }
425
+ ],
426
+ "inputs": [],
427
+ "stateMutability": "view",
428
+ "type": "function",
429
+ "gas": "1871"
430
+ },
431
+ {
432
+ "name": "future_admin",
433
+ "outputs": [
434
+ {
435
+ "type": "address",
436
+ "name": ""
437
+ }
438
+ ],
439
+ "inputs": [],
440
+ "stateMutability": "view",
441
+ "type": "function",
442
+ "gas": "1901"
443
+ },
444
+ {
445
+ "name": "can_checkpoint_token",
446
+ "outputs": [
447
+ {
448
+ "type": "bool",
449
+ "name": ""
450
+ }
451
+ ],
452
+ "inputs": [],
453
+ "stateMutability": "view",
454
+ "type": "function",
455
+ "gas": "1931"
456
+ },
457
+ {
458
+ "name": "emergency_return",
459
+ "outputs": [
460
+ {
461
+ "type": "address",
462
+ "name": ""
463
+ }
464
+ ],
465
+ "inputs": [],
466
+ "stateMutability": "view",
467
+ "type": "function",
468
+ "gas": "1961"
469
+ },
470
+ {
471
+ "name": "is_killed",
472
+ "outputs": [
473
+ {
474
+ "type": "bool",
475
+ "name": ""
476
+ }
477
+ ],
478
+ "inputs": [],
479
+ "stateMutability": "view",
480
+ "type": "function",
481
+ "gas": "1991"
482
+ }
483
+ ]