@curvefi/api 2.59.1 → 2.60.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.
@@ -875,5 +875,29 @@
875
875
  }
876
876
  ],
877
877
  "gas": "3648"
878
+ },
879
+ {
880
+ "stateMutability": "view",
881
+ "type": "function",
882
+ "name": "manager",
883
+ "inputs": [],
884
+ "outputs": [
885
+ {
886
+ "name": "",
887
+ "type": "address"
888
+ }
889
+ ]
890
+ },
891
+ {
892
+ "stateMutability": "view",
893
+ "type": "function",
894
+ "name": "version",
895
+ "inputs": [],
896
+ "outputs": [
897
+ {
898
+ "name": "",
899
+ "type": "string"
900
+ }
901
+ ]
878
902
  }
879
903
  ]
@@ -34,16 +34,22 @@ export declare class PoolTemplate {
34
34
  inApi: boolean;
35
35
  isGaugeKilled: () => Promise<boolean>;
36
36
  gaugeStatus: () => Promise<any>;
37
+ gaugeManager: () => Promise<string>;
38
+ gaugeDistributors: () => Promise<IDict<string>>;
39
+ gaugeVersion: () => Promise<string | null>;
37
40
  estimateGas: {
38
41
  depositApprove: (amounts: (number | string)[]) => Promise<number | number[]>;
39
42
  deposit: (amounts: (number | string)[]) => Promise<number | number[]>;
43
+ depositRewardApprove: (rewardToken: string, amount: number | string) => Promise<number | number[]>;
40
44
  depositWrappedApprove: (amounts: (number | string)[]) => Promise<number | number[]>;
45
+ depositReward: (rewardToken: string, amount: string | number, epoch: number) => Promise<number | number[]>;
41
46
  depositWrapped: (amounts: (number | string)[]) => Promise<number | number[]>;
42
47
  stakeApprove: (lpTokenAmount: number | string) => Promise<number | number[]>;
43
48
  stake: (lpTokenAmount: number | string) => Promise<number | number[]>;
44
49
  unstake: (lpTokenAmount: number | string) => Promise<number | number[]>;
45
50
  claimCrv: () => Promise<number | number[]>;
46
51
  claimRewards: () => Promise<number | number[]>;
52
+ addReward: (rewardToken: string, distributor: string) => Promise<number | number[]>;
47
53
  depositAndStakeApprove: (amounts: (number | string)[]) => Promise<number | number[]>;
48
54
  depositAndStake: (amounts: (number | string)[]) => Promise<number>;
49
55
  depositAndStakeWrappedApprove: (amounts: (number | string)[]) => Promise<number | number[]>;
@@ -263,5 +269,18 @@ export declare class PoolTemplate {
263
269
  private _underlyingPrices;
264
270
  private _wrappedPrices;
265
271
  private getGaugeStatus;
272
+ private _addReward;
273
+ addRewardEstimateGas(rewardToken: string, distributor: string): Promise<number | number[]>;
274
+ addReward(rewardToken: string, distributor: string): Promise<string>;
275
+ private getGaugeManager;
276
+ private getGaugeVersion;
277
+ isDepositRewardAvailable(): Promise<boolean>;
278
+ getGaugeDistributors(): Promise<IDict<string>>;
279
+ depositRewardIsApproved(rewardToken: string, amount: number | string): Promise<boolean>;
280
+ private depositRewardApproveEstimateGas;
281
+ depositRewardApprove(rewardToken: string, amount: number | string): Promise<string[]>;
282
+ private _depositReward;
283
+ depositRewardEstimateGas(rewardToken: string, amount: string | number, epoch: number): Promise<number | number[]>;
284
+ depositReward(rewardToken: string, amount: string | number, epoch: number): Promise<string>;
266
285
  private getIsGaugeKilled;
267
286
  }
@@ -1182,16 +1182,23 @@ var PoolTemplate = /** @class */ (function () {
1182
1182
  this.inApi = (_d = poolData.in_api) !== null && _d !== void 0 ? _d : false;
1183
1183
  this.isGaugeKilled = this.getIsGaugeKilled.bind(this);
1184
1184
  this.gaugeStatus = this.getGaugeStatus.bind(this);
1185
+ this.gaugeManager = this.getGaugeManager.bind(this);
1186
+ this.gaugeDistributors = this.getGaugeDistributors.bind(this);
1187
+ this.gaugeVersion = this.getGaugeVersion.bind(this);
1188
+ this.addReward = this.addReward.bind(this);
1185
1189
  this.estimateGas = {
1186
1190
  depositApprove: this.depositApproveEstimateGas.bind(this),
1187
1191
  deposit: this.depositEstimateGas.bind(this),
1188
1192
  depositWrappedApprove: this.depositWrappedApproveEstimateGas.bind(this),
1193
+ depositReward: this.depositRewardEstimateGas.bind(this),
1189
1194
  depositWrapped: this.depositWrappedEstimateGas.bind(this),
1195
+ depositRewardApprove: this.depositRewardApproveEstimateGas.bind(this),
1190
1196
  stakeApprove: this.stakeApproveEstimateGas.bind(this),
1191
1197
  stake: this.stakeEstimateGas.bind(this),
1192
1198
  unstake: this.unstakeEstimateGas.bind(this),
1193
1199
  claimCrv: this.claimCrvEstimateGas.bind(this),
1194
1200
  claimRewards: this.claimRewardsEstimateGas.bind(this),
1201
+ addReward: this.addRewardEstimateGas.bind(this),
1195
1202
  depositAndStakeApprove: this.depositAndStakeApproveEstimateGas.bind(this),
1196
1203
  depositAndStake: this.depositAndStakeEstimateGas.bind(this),
1197
1204
  depositAndStakeWrappedApprove: this.depositAndStakeWrappedApproveEstimateGas.bind(this),
@@ -3367,6 +3374,224 @@ var PoolTemplate = /** @class */ (function () {
3367
3374
  });
3368
3375
  });
3369
3376
  };
3377
+ PoolTemplate.prototype._addReward = function (_reward_token, _distributor, estimateGas) {
3378
+ if (estimateGas === void 0) { estimateGas = false; }
3379
+ return __awaiter(this, void 0, void 0, function () {
3380
+ var gas, gasLimit;
3381
+ return __generator(this, function (_c) {
3382
+ switch (_c.label) {
3383
+ case 0:
3384
+ if (!(this.gauge !== curve.constants.ZERO_ADDRESS && this.gauge)) return [3 /*break*/, 3];
3385
+ return [4 /*yield*/, curve.contracts[this.gauge].contract.add_reward.estimateGas(_reward_token, _distributor, __assign({}, curve.constantOptions))];
3386
+ case 1:
3387
+ gas = _c.sent();
3388
+ if (estimateGas)
3389
+ return [2 /*return*/, smartNumber(gas)];
3390
+ gasLimit = mulBy1_3(DIGas(gas));
3391
+ return [4 /*yield*/, curve.contracts[this.gauge].contract.add_reward(_reward_token, _distributor, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
3392
+ case 2: return [2 /*return*/, (_c.sent()).hash];
3393
+ case 3: throw Error("Pool ".concat(this.name, " does not have gauge"));
3394
+ }
3395
+ });
3396
+ });
3397
+ };
3398
+ PoolTemplate.prototype.addRewardEstimateGas = function (rewardToken, distributor) {
3399
+ return __awaiter(this, void 0, void 0, function () {
3400
+ return __generator(this, function (_c) {
3401
+ switch (_c.label) {
3402
+ case 0: return [4 /*yield*/, this._addReward(rewardToken, distributor, true)];
3403
+ case 1:
3404
+ // @ts-ignore
3405
+ return [2 /*return*/, _c.sent()];
3406
+ }
3407
+ });
3408
+ });
3409
+ };
3410
+ PoolTemplate.prototype.addReward = function (rewardToken, distributor) {
3411
+ return __awaiter(this, void 0, void 0, function () {
3412
+ return __generator(this, function (_c) {
3413
+ switch (_c.label) {
3414
+ case 0: return [4 /*yield*/, this._addReward(rewardToken, distributor)];
3415
+ case 1:
3416
+ // @ts-ignore
3417
+ return [2 /*return*/, _c.sent()];
3418
+ }
3419
+ });
3420
+ });
3421
+ };
3422
+ PoolTemplate.prototype.getGaugeManager = function () {
3423
+ return __awaiter(this, void 0, void 0, function () {
3424
+ var e_4;
3425
+ return __generator(this, function (_c) {
3426
+ switch (_c.label) {
3427
+ case 0:
3428
+ if (!(!this.gauge || this.gauge === curve.constants.ZERO_ADDRESS)) return [3 /*break*/, 1];
3429
+ return [2 /*return*/, curve.constants.ZERO_ADDRESS];
3430
+ case 1:
3431
+ _c.trys.push([1, 3, , 4]);
3432
+ return [4 /*yield*/, curve.contracts[this.gauge].contract.manager()];
3433
+ case 2: return [2 /*return*/, _c.sent()];
3434
+ case 3:
3435
+ e_4 = _c.sent();
3436
+ return [2 /*return*/, curve.constants.ZERO_ADDRESS];
3437
+ case 4: return [2 /*return*/];
3438
+ }
3439
+ });
3440
+ });
3441
+ };
3442
+ PoolTemplate.prototype.getGaugeVersion = function () {
3443
+ return __awaiter(this, void 0, void 0, function () {
3444
+ var e_5;
3445
+ return __generator(this, function (_c) {
3446
+ switch (_c.label) {
3447
+ case 0:
3448
+ if (!(!this.gauge || this.gauge === curve.constants.ZERO_ADDRESS)) return [3 /*break*/, 1];
3449
+ return [2 /*return*/, null];
3450
+ case 1:
3451
+ _c.trys.push([1, 3, , 4]);
3452
+ return [4 /*yield*/, curve.contracts[this.gauge].contract.version()];
3453
+ case 2: return [2 /*return*/, _c.sent()];
3454
+ case 3:
3455
+ e_5 = _c.sent();
3456
+ return [2 /*return*/, null];
3457
+ case 4: return [2 /*return*/];
3458
+ }
3459
+ });
3460
+ });
3461
+ };
3462
+ PoolTemplate.prototype.isDepositRewardAvailable = function () {
3463
+ return __awaiter(this, void 0, void 0, function () {
3464
+ var versionsWithDepositReward, version;
3465
+ return __generator(this, function (_c) {
3466
+ switch (_c.label) {
3467
+ case 0:
3468
+ versionsWithDepositReward = ['v6.1.0'];
3469
+ return [4 /*yield*/, this.getGaugeVersion()];
3470
+ case 1:
3471
+ version = _c.sent();
3472
+ return [2 /*return*/, version ? versionsWithDepositReward.includes(version) : Boolean(version)];
3473
+ }
3474
+ });
3475
+ });
3476
+ };
3477
+ PoolTemplate.prototype.getGaugeDistributors = function () {
3478
+ return __awaiter(this, void 0, void 0, function () {
3479
+ var gaugeContract, gaugeMulticallContract, rewardCount, _c, _d, _e, calls, i, rewardTokens, i, rewardData, gaugeDistributors, i;
3480
+ return __generator(this, function (_f) {
3481
+ switch (_f.label) {
3482
+ case 0: return [4 /*yield*/, curve.contracts[this.gauge].contract];
3483
+ case 1:
3484
+ gaugeContract = _f.sent();
3485
+ return [4 /*yield*/, curve.contracts[this.gauge].multicallContract];
3486
+ case 2:
3487
+ gaugeMulticallContract = _f.sent();
3488
+ _c = Number;
3489
+ _e = (_d = curve).formatUnits;
3490
+ return [4 /*yield*/, gaugeContract.reward_count(curve.constantOptions)];
3491
+ case 3:
3492
+ rewardCount = _c.apply(void 0, [_e.apply(_d, [_f.sent(), 0])]);
3493
+ calls = [];
3494
+ for (i = 0; i < rewardCount; i++) {
3495
+ calls.push(gaugeMulticallContract.reward_tokens(i));
3496
+ }
3497
+ return [4 /*yield*/, curve.multicallProvider.all(calls)];
3498
+ case 4:
3499
+ rewardTokens = _f.sent();
3500
+ for (i = 0; i < rewardCount; i++) {
3501
+ calls.push(gaugeMulticallContract.reward_data(rewardTokens[i]));
3502
+ }
3503
+ return [4 /*yield*/, curve.multicallProvider.all(calls)];
3504
+ case 5:
3505
+ rewardData = _f.sent();
3506
+ gaugeDistributors = {};
3507
+ for (i = 0; i < rewardCount; i++) {
3508
+ gaugeDistributors[rewardTokens[i]] = rewardData[i];
3509
+ }
3510
+ return [2 /*return*/, gaugeDistributors];
3511
+ }
3512
+ });
3513
+ });
3514
+ };
3515
+ PoolTemplate.prototype.depositRewardIsApproved = function (rewardToken, amount) {
3516
+ return __awaiter(this, void 0, void 0, function () {
3517
+ return __generator(this, function (_c) {
3518
+ switch (_c.label) {
3519
+ case 0: return [4 /*yield*/, hasAllowance([rewardToken], [amount], curve.signerAddress, this.gauge)];
3520
+ case 1: return [2 /*return*/, _c.sent()];
3521
+ }
3522
+ });
3523
+ });
3524
+ };
3525
+ PoolTemplate.prototype.depositRewardApproveEstimateGas = function (rewardToken, amount) {
3526
+ return __awaiter(this, void 0, void 0, function () {
3527
+ return __generator(this, function (_c) {
3528
+ switch (_c.label) {
3529
+ case 0: return [4 /*yield*/, ensureAllowanceEstimateGas([rewardToken], [amount], this.gauge)];
3530
+ case 1: return [2 /*return*/, _c.sent()];
3531
+ }
3532
+ });
3533
+ });
3534
+ };
3535
+ PoolTemplate.prototype.depositRewardApprove = function (rewardToken, amount) {
3536
+ return __awaiter(this, void 0, void 0, function () {
3537
+ return __generator(this, function (_c) {
3538
+ switch (_c.label) {
3539
+ case 0: return [4 /*yield*/, ensureAllowance([rewardToken], [amount], this.gauge)];
3540
+ case 1: return [2 /*return*/, _c.sent()];
3541
+ }
3542
+ });
3543
+ });
3544
+ };
3545
+ PoolTemplate.prototype._depositReward = function (rewardToken, amount, epoch, estimateGas) {
3546
+ if (estimateGas === void 0) { estimateGas = false; }
3547
+ return __awaiter(this, void 0, void 0, function () {
3548
+ var contract, gas, gasLimit;
3549
+ return __generator(this, function (_c) {
3550
+ switch (_c.label) {
3551
+ case 0:
3552
+ if (!!estimateGas) return [3 /*break*/, 2];
3553
+ return [4 /*yield*/, ensureAllowance([rewardToken], [amount], this.gauge)];
3554
+ case 1:
3555
+ _c.sent();
3556
+ _c.label = 2;
3557
+ case 2:
3558
+ contract = curve.contracts[this.gauge].contract;
3559
+ return [4 /*yield*/, contract.deposit_reward_token.estimateGas(rewardToken, amount, __assign({}, curve.constantOptions))];
3560
+ case 3:
3561
+ gas = _c.sent();
3562
+ if (estimateGas)
3563
+ return [2 /*return*/, smartNumber(gas)];
3564
+ gasLimit = mulBy1_3(DIGas(gas));
3565
+ return [4 /*yield*/, contract.deposit_reward_token(rewardToken, amount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
3566
+ case 4: return [2 /*return*/, (_c.sent()).hash];
3567
+ }
3568
+ });
3569
+ });
3570
+ };
3571
+ PoolTemplate.prototype.depositRewardEstimateGas = function (rewardToken, amount, epoch) {
3572
+ return __awaiter(this, void 0, void 0, function () {
3573
+ return __generator(this, function (_c) {
3574
+ switch (_c.label) {
3575
+ case 0: return [4 /*yield*/, this._depositReward(rewardToken, amount, epoch, true)];
3576
+ case 1:
3577
+ // @ts-ignore
3578
+ return [2 /*return*/, _c.sent()];
3579
+ }
3580
+ });
3581
+ });
3582
+ };
3583
+ PoolTemplate.prototype.depositReward = function (rewardToken, amount, epoch) {
3584
+ return __awaiter(this, void 0, void 0, function () {
3585
+ return __generator(this, function (_c) {
3586
+ switch (_c.label) {
3587
+ case 0: return [4 /*yield*/, this._depositReward(rewardToken, amount, epoch)];
3588
+ case 1:
3589
+ // @ts-ignore
3590
+ return [2 /*return*/, _c.sent()];
3591
+ }
3592
+ });
3593
+ });
3594
+ };
3370
3595
  PoolTemplate.prototype.getIsGaugeKilled = function () {
3371
3596
  return __awaiter(this, void 0, void 0, function () {
3372
3597
  var gaugeData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.59.1",
3
+ "version": "2.60.0",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",