@curvefi/api 2.41.2 → 2.42.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 +12 -8
- package/lib/boosting.d.ts +3 -2
- package/lib/boosting.js +26 -23
- package/lib/curve.d.ts +1 -0
- package/lib/curve.js +9 -3
- package/lib/index.d.ts +4 -2
- package/lib/index.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1169,10 +1169,8 @@ import curve from "@curvefi/api";
|
|
|
1169
1169
|
|
|
1170
1170
|
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
|
|
1171
1171
|
|
|
1172
|
-
await curve.boosting.sidechain.
|
|
1172
|
+
await curve.boosting.sidechain.lastEthBlock();
|
|
1173
1173
|
// 16931944
|
|
1174
|
-
await curve.boosting.sidechain.checkBlockhash(17377005);
|
|
1175
|
-
// false
|
|
1176
1174
|
|
|
1177
1175
|
await curve.boosting.sidechain.getAnycallBalance();
|
|
1178
1176
|
// 0.033837278711248954
|
|
@@ -1184,14 +1182,20 @@ import curve from "@curvefi/api";
|
|
|
1184
1182
|
// --- MAINNET (ETHEREUM) ---
|
|
1185
1183
|
|
|
1186
1184
|
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
|
|
1187
|
-
await curve.boosting.sidechain.
|
|
1185
|
+
await curve.boosting.sidechain.lastBlockSent(137); // Polygon
|
|
1186
|
+
// 17038505
|
|
1187
|
+
const blockToSend = await curve.boosting.sidechain.blockToSend(); // currentBlock - 128
|
|
1188
|
+
// 17377005
|
|
1189
|
+
await curve.boosting.sidechain.sendBlockhash(blockToSend, 137); // Polygon
|
|
1188
1190
|
|
|
1189
1191
|
// --- SIDECHAIN ---
|
|
1190
|
-
|
|
1192
|
+
|
|
1193
|
+
// Wait until blockhash is delivered
|
|
1194
|
+
|
|
1191
1195
|
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
|
|
1192
|
-
await curve.boosting.sidechain.
|
|
1193
|
-
//
|
|
1194
|
-
await curve.boosting.sidechain.submitProof(
|
|
1196
|
+
const lastEthBlock = await curve.boosting.sidechain.lastEthBlock();
|
|
1197
|
+
// 17377005
|
|
1198
|
+
await curve.boosting.sidechain.submitProof(lastEthBlock, "0x33A4622B82D4c04a53e170c638B944ce27cffce3");
|
|
1195
1199
|
})()
|
|
1196
1200
|
```
|
|
1197
1201
|
|
package/lib/boosting.d.ts
CHANGED
|
@@ -24,11 +24,12 @@ export declare const withdrawLockedCrv: () => Promise<string>;
|
|
|
24
24
|
export declare const claimableFees: (address?: string) => Promise<string>;
|
|
25
25
|
export declare const claimFeesEstimateGas: (address?: string) => Promise<number>;
|
|
26
26
|
export declare const claimFees: (address?: string) => Promise<string>;
|
|
27
|
-
export declare const
|
|
28
|
-
export declare const checkBlockhash: (block: number) => Promise<boolean>;
|
|
27
|
+
export declare const lastEthBlock: () => Promise<number>;
|
|
29
28
|
export declare const getAnycallBalance: () => Promise<string>;
|
|
30
29
|
export declare const topUpAnycallEstimateGas: (amount?: number | string) => Promise<number>;
|
|
31
30
|
export declare const topUpAnycall: (amount?: number | string) => Promise<string>;
|
|
31
|
+
export declare const lastBlockSent: (chainId: IChainId) => Promise<number>;
|
|
32
|
+
export declare const blockToSend: () => Promise<number>;
|
|
32
33
|
export declare const sendBlockhashEstimateGas: (block: number, chainId: IChainId) => Promise<number>;
|
|
33
34
|
export declare const sendBlockhash: (block: number, chainId: IChainId) => Promise<string>;
|
|
34
35
|
export declare const submitProofEstimateGas: (block: number, address?: string) => Promise<number>;
|
package/lib/boosting.js
CHANGED
|
@@ -402,7 +402,7 @@ export var claimFees = function (address) {
|
|
|
402
402
|
});
|
|
403
403
|
};
|
|
404
404
|
// ------------ SIDECHAIN ------------
|
|
405
|
-
export var
|
|
405
|
+
export var lastEthBlock = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
406
406
|
var veOracleContract, _a;
|
|
407
407
|
return __generator(this, function (_b) {
|
|
408
408
|
switch (_b.label) {
|
|
@@ -416,28 +416,6 @@ export var lastBlockhash = function () { return __awaiter(void 0, void 0, void 0
|
|
|
416
416
|
}
|
|
417
417
|
});
|
|
418
418
|
}); };
|
|
419
|
-
export var checkBlockhash = function (block) { return __awaiter(void 0, void 0, void 0, function () {
|
|
420
|
-
var veOracleContract, e_1;
|
|
421
|
-
return __generator(this, function (_a) {
|
|
422
|
-
switch (_a.label) {
|
|
423
|
-
case 0:
|
|
424
|
-
if (curve.chainId === 1)
|
|
425
|
-
throw Error("There is no checkBlockhash method on ethereum network");
|
|
426
|
-
veOracleContract = curve.contracts[curve.constants.ALIASES.voting_escrow_oracle].contract;
|
|
427
|
-
_a.label = 1;
|
|
428
|
-
case 1:
|
|
429
|
-
_a.trys.push([1, 3, , 4]);
|
|
430
|
-
return [4 /*yield*/, veOracleContract.get_eth_blockhash(block, curve.constantOptions)];
|
|
431
|
-
case 2:
|
|
432
|
-
_a.sent();
|
|
433
|
-
return [2 /*return*/, true];
|
|
434
|
-
case 3:
|
|
435
|
-
e_1 = _a.sent();
|
|
436
|
-
return [2 /*return*/, false];
|
|
437
|
-
case 4: return [2 /*return*/];
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
}); };
|
|
441
419
|
export var getAnycallBalance = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
442
420
|
var anycallContract, _balance;
|
|
443
421
|
return __generator(this, function (_a) {
|
|
@@ -499,6 +477,31 @@ export var topUpAnycall = function (amount) {
|
|
|
499
477
|
});
|
|
500
478
|
});
|
|
501
479
|
};
|
|
480
|
+
export var lastBlockSent = function (chainId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
481
|
+
var veOracleContract, _a;
|
|
482
|
+
return __generator(this, function (_b) {
|
|
483
|
+
switch (_b.label) {
|
|
484
|
+
case 0:
|
|
485
|
+
if (curve.chainId !== 1)
|
|
486
|
+
throw Error("lastBlockNumberSent method is on ethereum network only");
|
|
487
|
+
veOracleContract = curve.contracts[curve.constants.ALIASES.voting_escrow_oracle].contract;
|
|
488
|
+
_a = Number;
|
|
489
|
+
return [4 /*yield*/, veOracleContract.get_last_block_number_sent(chainId, curve.constantOptions)];
|
|
490
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
}); };
|
|
494
|
+
export var blockToSend = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
495
|
+
return __generator(this, function (_a) {
|
|
496
|
+
switch (_a.label) {
|
|
497
|
+
case 0:
|
|
498
|
+
if (curve.chainId !== 1)
|
|
499
|
+
throw Error("blockToSend method is on ethereum network only");
|
|
500
|
+
return [4 /*yield*/, curve.provider.getBlockNumber()];
|
|
501
|
+
case 1: return [2 /*return*/, (_a.sent()) - 128];
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
}); };
|
|
502
505
|
var _sendBlockhash = function (block, chainId, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
|
|
503
506
|
var veOracleContract, gas, gasLimit;
|
|
504
507
|
return __generator(this, function (_a) {
|
package/lib/curve.d.ts
CHANGED
package/lib/curve.js
CHANGED
|
@@ -655,7 +655,7 @@ var Curve = /** @class */ (function () {
|
|
|
655
655
|
var _a;
|
|
656
656
|
if (options === void 0) { options = {}; }
|
|
657
657
|
return __awaiter(this, void 0, void 0, function () {
|
|
658
|
-
var _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1, _i, _f, pool, _g, _h, coinAddr, _j, _k, coinAddr, _l, _m, coinAddr, _minterABI, addressProviderContract, _o, factoryContract, _p;
|
|
658
|
+
var jsonRpcApiProviderOptions, _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1, _i, _f, pool, _g, _h, coinAddr, _j, _k, coinAddr, _l, _m, coinAddr, _minterABI, addressProviderContract, _o, factoryContract, _p;
|
|
659
659
|
return __generator(this, function (_q) {
|
|
660
660
|
switch (_q.label) {
|
|
661
661
|
case 0:
|
|
@@ -690,11 +690,17 @@ var Curve = /** @class */ (function () {
|
|
|
690
690
|
};
|
|
691
691
|
if (!(providerType.toLowerCase() === 'JsonRpc'.toLowerCase())) return [3 /*break*/, 6];
|
|
692
692
|
providerSettings = providerSettings;
|
|
693
|
+
jsonRpcApiProviderOptions = void 0;
|
|
694
|
+
if (providerSettings.batchMaxCount) {
|
|
695
|
+
jsonRpcApiProviderOptions = {
|
|
696
|
+
batchMaxCount: providerSettings.batchMaxCount,
|
|
697
|
+
};
|
|
698
|
+
}
|
|
693
699
|
if (providerSettings.url) {
|
|
694
|
-
this.provider = new ethers.JsonRpcProvider(providerSettings.url);
|
|
700
|
+
this.provider = new ethers.JsonRpcProvider(providerSettings.url, undefined, jsonRpcApiProviderOptions);
|
|
695
701
|
}
|
|
696
702
|
else {
|
|
697
|
-
this.provider = new ethers.JsonRpcProvider('http://localhost:8545/');
|
|
703
|
+
this.provider = new ethers.JsonRpcProvider('http://localhost:8545/', undefined, jsonRpcApiProviderOptions);
|
|
698
704
|
}
|
|
699
705
|
if (!providerSettings.privateKey) return [3 /*break*/, 1];
|
|
700
706
|
this.signer = new ethers.Wallet(providerSettings.privateKey, this.provider);
|
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { PoolTemplate } from "./pools/index.js";
|
|
|
3
3
|
declare function init(providerType: 'JsonRpc' | 'Web3' | 'Infura' | 'Alchemy', providerSettings: {
|
|
4
4
|
url?: string;
|
|
5
5
|
privateKey?: string;
|
|
6
|
+
batchMaxCount?: number;
|
|
6
7
|
} | {
|
|
7
8
|
externalProvider: ethers.Eip1193Provider;
|
|
8
9
|
} | {
|
|
@@ -144,10 +145,11 @@ declare const curve: {
|
|
|
144
145
|
claimFees: (address?: string) => Promise<number>;
|
|
145
146
|
};
|
|
146
147
|
sidechain: {
|
|
147
|
-
|
|
148
|
-
checkBlockhash: (block: number) => Promise<boolean>;
|
|
148
|
+
lastEthBlock: () => Promise<number>;
|
|
149
149
|
getAnycallBalance: () => Promise<string>;
|
|
150
150
|
topUpAnycall: (amount?: string | number) => Promise<string>;
|
|
151
|
+
lastBlockSent: (chainId: import("./interfaces.js").IChainId) => Promise<number>;
|
|
152
|
+
blockToSend: () => Promise<number>;
|
|
151
153
|
sendBlockhash: (block: number, chainId: import("./interfaces.js").IChainId) => Promise<string>;
|
|
152
154
|
submitProof: (block: number, address?: string) => Promise<string>;
|
|
153
155
|
estimateGas: {
|
package/lib/index.js
CHANGED
|
@@ -38,7 +38,7 @@ import { PoolTemplate, getPool } from "./pools/index.js";
|
|
|
38
38
|
import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList, getUserLiquidityUSD, getUserClaimable, } from "./pools/utils.js";
|
|
39
39
|
import { getBestRouteAndOutput, swapExpected, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapEstimateGas, swap, getSwappedAmount, } from "./router.js";
|
|
40
40
|
import { curve as _curve } from "./curve.js";
|
|
41
|
-
import { getCrv, getLockedAmountAndUnlockTime, getVeCrv, getVeCrvPct, calcUnlockTime, createLockEstimateGas, createLock, isApproved, approveEstimateGas, approve, increaseAmountEstimateGas, increaseAmount, increaseUnlockTimeEstimateGas, increaseUnlockTime, withdrawLockedCrvEstimateGas, withdrawLockedCrv, claimableFees, claimFeesEstimateGas, claimFees,
|
|
41
|
+
import { getCrv, getLockedAmountAndUnlockTime, getVeCrv, getVeCrvPct, calcUnlockTime, createLockEstimateGas, createLock, isApproved, approveEstimateGas, approve, increaseAmountEstimateGas, increaseAmount, increaseUnlockTimeEstimateGas, increaseUnlockTime, withdrawLockedCrvEstimateGas, withdrawLockedCrv, claimableFees, claimFeesEstimateGas, claimFees, lastEthBlock, getAnycallBalance, topUpAnycall, topUpAnycallEstimateGas, lastBlockSent, blockToSend, sendBlockhash, sendBlockhashEstimateGas, submitProof, submitProofEstimateGas, } from "./boosting.js";
|
|
42
42
|
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getTVL, getCoinsData, getVolume, } from "./utils.js";
|
|
43
43
|
import { deployStablePlainPool, deployStablePlainPoolEstimateGas, getDeployedStablePlainPoolAddress, setOracle, setOracleEstimateGas, deployStableMetaPool, deployStableMetaPoolEstimateGas, getDeployedStableMetaPoolAddress, deployCryptoPool, deployCryptoPoolEstimateGas, getDeployedCryptoPoolAddress, deployTricryptoPool, deployTricryptoPoolEstimateGas, getDeployedTricryptoPoolAddress, deployGauge, deployGaugeEstimateGas, getDeployedGaugeAddress, } from './factory/deploy.js';
|
|
44
44
|
function init(providerType, providerSettings, options) {
|
|
@@ -179,10 +179,11 @@ var curve = {
|
|
|
179
179
|
claimFees: claimFeesEstimateGas,
|
|
180
180
|
},
|
|
181
181
|
sidechain: {
|
|
182
|
-
|
|
183
|
-
checkBlockhash: checkBlockhash,
|
|
182
|
+
lastEthBlock: lastEthBlock,
|
|
184
183
|
getAnycallBalance: getAnycallBalance,
|
|
185
184
|
topUpAnycall: topUpAnycall,
|
|
185
|
+
lastBlockSent: lastBlockSent,
|
|
186
|
+
blockToSend: blockToSend,
|
|
186
187
|
sendBlockhash: sendBlockhash,
|
|
187
188
|
submitProof: submitProof,
|
|
188
189
|
estimateGas: {
|