@curvefi/api 2.56.11 → 2.56.13
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/lib/constants/abis/factory-tricrypto.json +17 -92
- package/lib/factory/factory-tricrypto.js +36 -21
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +46 -5
- package/package.json +1 -1
|
@@ -71,23 +71,6 @@
|
|
|
71
71
|
"anonymous": false,
|
|
72
72
|
"type": "event"
|
|
73
73
|
},
|
|
74
|
-
{
|
|
75
|
-
"name": "LiquidityGaugeDeployed",
|
|
76
|
-
"inputs": [
|
|
77
|
-
{
|
|
78
|
-
"name": "pool",
|
|
79
|
-
"type": "address",
|
|
80
|
-
"indexed": false
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"name": "gauge",
|
|
84
|
-
"type": "address",
|
|
85
|
-
"indexed": false
|
|
86
|
-
}
|
|
87
|
-
],
|
|
88
|
-
"anonymous": false,
|
|
89
|
-
"type": "event"
|
|
90
|
-
},
|
|
91
74
|
{
|
|
92
75
|
"name": "UpdateFeeReceiver",
|
|
93
76
|
"inputs": [
|
|
@@ -127,23 +110,6 @@
|
|
|
127
110
|
"anonymous": false,
|
|
128
111
|
"type": "event"
|
|
129
112
|
},
|
|
130
|
-
{
|
|
131
|
-
"name": "UpdateGaugeImplementation",
|
|
132
|
-
"inputs": [
|
|
133
|
-
{
|
|
134
|
-
"name": "_old_gauge_implementation",
|
|
135
|
-
"type": "address",
|
|
136
|
-
"indexed": false
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"name": "_new_gauge_implementation",
|
|
140
|
-
"type": "address",
|
|
141
|
-
"indexed": false
|
|
142
|
-
}
|
|
143
|
-
],
|
|
144
|
-
"anonymous": false,
|
|
145
|
-
"type": "event"
|
|
146
|
-
},
|
|
147
113
|
{
|
|
148
114
|
"name": "UpdateMathImplementation",
|
|
149
115
|
"inputs": [
|
|
@@ -279,23 +245,6 @@
|
|
|
279
245
|
}
|
|
280
246
|
]
|
|
281
247
|
},
|
|
282
|
-
{
|
|
283
|
-
"stateMutability": "nonpayable",
|
|
284
|
-
"type": "function",
|
|
285
|
-
"name": "deploy_gauge",
|
|
286
|
-
"inputs": [
|
|
287
|
-
{
|
|
288
|
-
"name": "_pool",
|
|
289
|
-
"type": "address"
|
|
290
|
-
}
|
|
291
|
-
],
|
|
292
|
-
"outputs": [
|
|
293
|
-
{
|
|
294
|
-
"name": "",
|
|
295
|
-
"type": "address"
|
|
296
|
-
}
|
|
297
|
-
]
|
|
298
|
-
},
|
|
299
248
|
{
|
|
300
249
|
"stateMutability": "nonpayable",
|
|
301
250
|
"type": "function",
|
|
@@ -324,18 +273,6 @@
|
|
|
324
273
|
],
|
|
325
274
|
"outputs": []
|
|
326
275
|
},
|
|
327
|
-
{
|
|
328
|
-
"stateMutability": "nonpayable",
|
|
329
|
-
"type": "function",
|
|
330
|
-
"name": "set_gauge_implementation",
|
|
331
|
-
"inputs": [
|
|
332
|
-
{
|
|
333
|
-
"name": "_gauge_implementation",
|
|
334
|
-
"type": "address"
|
|
335
|
-
}
|
|
336
|
-
],
|
|
337
|
-
"outputs": []
|
|
338
|
-
},
|
|
339
276
|
{
|
|
340
277
|
"stateMutability": "nonpayable",
|
|
341
278
|
"type": "function",
|
|
@@ -379,6 +316,23 @@
|
|
|
379
316
|
"inputs": [],
|
|
380
317
|
"outputs": []
|
|
381
318
|
},
|
|
319
|
+
{
|
|
320
|
+
"stateMutability": "view",
|
|
321
|
+
"type": "function",
|
|
322
|
+
"name": "get_implementation_address",
|
|
323
|
+
"inputs": [
|
|
324
|
+
{
|
|
325
|
+
"name": "_pool",
|
|
326
|
+
"type": "address"
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
"outputs": [
|
|
330
|
+
{
|
|
331
|
+
"name": "",
|
|
332
|
+
"type": "address"
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
},
|
|
382
336
|
{
|
|
383
337
|
"stateMutability": "view",
|
|
384
338
|
"type": "function",
|
|
@@ -505,23 +459,6 @@
|
|
|
505
459
|
}
|
|
506
460
|
]
|
|
507
461
|
},
|
|
508
|
-
{
|
|
509
|
-
"stateMutability": "view",
|
|
510
|
-
"type": "function",
|
|
511
|
-
"name": "get_gauge",
|
|
512
|
-
"inputs": [
|
|
513
|
-
{
|
|
514
|
-
"name": "_pool",
|
|
515
|
-
"type": "address"
|
|
516
|
-
}
|
|
517
|
-
],
|
|
518
|
-
"outputs": [
|
|
519
|
-
{
|
|
520
|
-
"name": "",
|
|
521
|
-
"type": "address"
|
|
522
|
-
}
|
|
523
|
-
]
|
|
524
|
-
},
|
|
525
462
|
{
|
|
526
463
|
"stateMutability": "view",
|
|
527
464
|
"type": "function",
|
|
@@ -596,18 +533,6 @@
|
|
|
596
533
|
}
|
|
597
534
|
]
|
|
598
535
|
},
|
|
599
|
-
{
|
|
600
|
-
"stateMutability": "view",
|
|
601
|
-
"type": "function",
|
|
602
|
-
"name": "gauge_implementation",
|
|
603
|
-
"inputs": [],
|
|
604
|
-
"outputs": [
|
|
605
|
-
{
|
|
606
|
-
"name": "",
|
|
607
|
-
"type": "address"
|
|
608
|
-
}
|
|
609
|
-
]
|
|
610
|
-
},
|
|
611
536
|
{
|
|
612
537
|
"stateMutability": "view",
|
|
613
538
|
"type": "function",
|
|
@@ -48,6 +48,7 @@ import ERC20ABI from "../constants/abis/ERC20.json" assert { type: 'json' };
|
|
|
48
48
|
import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool.json" assert { type: 'json' };
|
|
49
49
|
import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
|
|
50
50
|
import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
|
|
51
|
+
import { tricryptoDeployImplementations } from "../constants/tricryptoDeployImplementations.js";
|
|
51
52
|
var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
|
|
52
53
|
function getRecentlyCreatedCryptoPoolId(swapAddress) {
|
|
53
54
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -115,7 +116,7 @@ function _handleCoinAddresses(coinAddresses) {
|
|
|
115
116
|
}
|
|
116
117
|
function getPoolsData(factorySwapAddresses) {
|
|
117
118
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
var factoryMulticallContract, calls, _i, factorySwapAddresses_1, addr, res, gaugeAddresses, coinAddresses, factoryMulticallContract, isFactoryGaugeNull, factoryMulticallGaugeContract, calls, _a, factorySwapAddresses_2, addr, res, gaugeAddresses, coinAddresses, coinAddresses, gaugeAddresses;
|
|
119
|
+
var factoryMulticallContract, calls, _i, factorySwapAddresses_1, addr, res, gaugeAddresses, coinAddresses, implementationAddresses, factoryMulticallContract, isFactoryGaugeNull, factoryMulticallGaugeContract, calls, _a, factorySwapAddresses_2, addr, res, gaugeAddresses, coinAddresses, implementationAddresses, coinAddresses, gaugeAddresses, implementationAddresses;
|
|
119
120
|
return __generator(this, function (_b) {
|
|
120
121
|
switch (_b.label) {
|
|
121
122
|
case 0:
|
|
@@ -126,13 +127,15 @@ function getPoolsData(factorySwapAddresses) {
|
|
|
126
127
|
addr = factorySwapAddresses_1[_i];
|
|
127
128
|
calls.push(factoryMulticallContract.get_gauge(addr));
|
|
128
129
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
130
|
+
calls.push(factoryMulticallContract.get_implementation_address(addr));
|
|
129
131
|
}
|
|
130
132
|
return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
131
133
|
case 1:
|
|
132
134
|
res = _b.sent();
|
|
133
|
-
gaugeAddresses = res.filter(function (a, i) { return i %
|
|
134
|
-
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i %
|
|
135
|
-
return
|
|
135
|
+
gaugeAddresses = res.filter(function (a, i) { return i % 3 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
136
|
+
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 3 == 1; }));
|
|
137
|
+
implementationAddresses = res.filter(function (a, i) { return i % 3 == 2; }).map(function (a) { return a.toLowerCase(); });
|
|
138
|
+
return [2 /*return*/, [gaugeAddresses, coinAddresses, implementationAddresses]];
|
|
136
139
|
case 2:
|
|
137
140
|
factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
|
|
138
141
|
isFactoryGaugeNull = this.constants.ALIASES.gauge_factory === '0x0000000000000000000000000000000000000000';
|
|
@@ -144,19 +147,22 @@ function getPoolsData(factorySwapAddresses) {
|
|
|
144
147
|
calls.push(factoryMulticallGaugeContract.get_gauge_from_lp_token(addr));
|
|
145
148
|
}
|
|
146
149
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
150
|
+
calls.push(factoryMulticallContract.get_implementation_address(addr));
|
|
147
151
|
}
|
|
148
152
|
return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
149
153
|
case 3:
|
|
150
154
|
res = _b.sent();
|
|
151
155
|
if (!isFactoryGaugeNull) {
|
|
152
|
-
gaugeAddresses = res.filter(function (a, i) { return i %
|
|
153
|
-
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i %
|
|
154
|
-
return
|
|
156
|
+
gaugeAddresses = res.filter(function (a, i) { return i % 3 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
157
|
+
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 3 == 1; }));
|
|
158
|
+
implementationAddresses = res.filter(function (a, i) { return i % 3 == 2; }).map(function (a) { return a.toLowerCase(); });
|
|
159
|
+
return [2 /*return*/, [gaugeAddresses, coinAddresses, implementationAddresses]];
|
|
155
160
|
}
|
|
156
161
|
else {
|
|
157
162
|
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 2 == 0; }));
|
|
158
163
|
gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(function () { return '0x0000000000000000000000000000000000000000'; });
|
|
159
|
-
return
|
|
164
|
+
implementationAddresses = res.filter(function (a, i) { return i % 2 == 1; }).map(function (a) { return a.toLowerCase(); });
|
|
165
|
+
return [2 /*return*/, [gaugeAddresses, coinAddresses, implementationAddresses]];
|
|
160
166
|
}
|
|
161
167
|
_b.label = 4;
|
|
162
168
|
case 4: return [2 /*return*/];
|
|
@@ -191,10 +197,6 @@ function setCryptoFactoryCoinsContracts(coinAddresses) {
|
|
|
191
197
|
this.setContract(addr, ERC20ABI);
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
|
-
function getCryptoFactoryUnderlyingCoinAddresses(coinAddresses) {
|
|
195
|
-
var _this = this;
|
|
196
|
-
return __spreadArray([], coinAddresses.map(function (coins) { return coins.map(function (c) { return c === _this.constants.NATIVE_TOKEN.wrappedAddress ? _this.constants.NATIVE_TOKEN.address : c; }); }), true);
|
|
197
|
-
}
|
|
198
200
|
function getExistingCoinAddressNameDict() {
|
|
199
201
|
var dict = {};
|
|
200
202
|
var _loop_1 = function (poolData) {
|
|
@@ -273,7 +275,7 @@ function getCoinsData(tokenAddresses, coinAddresses, existingCoinAddrNameDict, e
|
|
|
273
275
|
export function getTricryptoFactoryPoolData(fromIdx, swapAddress) {
|
|
274
276
|
if (fromIdx === void 0) { fromIdx = 0; }
|
|
275
277
|
return __awaiter(this, void 0, void 0, function () {
|
|
276
|
-
var _a, poolIds, swapAddresses, _b, _c, gaugeAddresses, coinAddresses,
|
|
278
|
+
var _a, poolIds, swapAddresses, _b, _c, gaugeAddresses, coinAddresses, implementationAddresses, existingCoinAddressNameDict, _e, poolSymbols, poolNames, coinAddressNameDict, coinAddressDecimalsDict, TRICRYPTO_FACTORY_POOLS_DATA, nativeToken, _loop_2, this_1, i;
|
|
277
279
|
return __generator(this, function (_f) {
|
|
278
280
|
switch (_f.label) {
|
|
279
281
|
case 0:
|
|
@@ -292,17 +294,26 @@ export function getTricryptoFactoryPoolData(fromIdx, swapAddress) {
|
|
|
292
294
|
return [2 /*return*/, {}];
|
|
293
295
|
return [4 /*yield*/, getPoolsData.call(this, swapAddresses)];
|
|
294
296
|
case 5:
|
|
295
|
-
_c = _f.sent(), gaugeAddresses = _c[0], coinAddresses = _c[1];
|
|
297
|
+
_c = _f.sent(), gaugeAddresses = _c[0], coinAddresses = _c[1], implementationAddresses = _c[2];
|
|
296
298
|
setCryptoFactorySwapContracts.call(this, swapAddresses);
|
|
297
299
|
setCryptoFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
298
300
|
setCryptoFactoryCoinsContracts.call(this, coinAddresses);
|
|
299
|
-
underlyingCoinAddresses = getCryptoFactoryUnderlyingCoinAddresses.call(this, coinAddresses);
|
|
300
301
|
existingCoinAddressNameDict = getExistingCoinAddressNameDict.call(this);
|
|
301
302
|
return [4 /*yield*/, getCoinsData.call(this, swapAddresses, coinAddresses, existingCoinAddressNameDict, this.constants.DECIMALS)];
|
|
302
303
|
case 6:
|
|
303
304
|
_e = _f.sent(), poolSymbols = _e[0], poolNames = _e[1], coinAddressNameDict = _e[2], coinAddressDecimalsDict = _e[3];
|
|
304
305
|
TRICRYPTO_FACTORY_POOLS_DATA = {};
|
|
305
|
-
|
|
306
|
+
nativeToken = this.constants.NATIVE_TOKEN;
|
|
307
|
+
_loop_2 = function (i) {
|
|
308
|
+
var underlyingCoinAddresses = coinAddresses[i].map(function (addr) {
|
|
309
|
+
var isETHEnabled = implementationAddresses[i] === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
|
|
310
|
+
if (isETHEnabled) {
|
|
311
|
+
return addr === nativeToken.wrappedAddress ? nativeToken.address : addr;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
return addr;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
306
317
|
TRICRYPTO_FACTORY_POOLS_DATA[poolIds[i]] = {
|
|
307
318
|
name: poolNames[i],
|
|
308
319
|
full_name: poolNames[i],
|
|
@@ -312,17 +323,21 @@ export function getTricryptoFactoryPoolData(fromIdx, swapAddress) {
|
|
|
312
323
|
token_address: swapAddresses[i],
|
|
313
324
|
gauge_address: gaugeAddresses[i],
|
|
314
325
|
is_crypto: true,
|
|
315
|
-
is_plain: underlyingCoinAddresses
|
|
326
|
+
is_plain: underlyingCoinAddresses.toString() === coinAddresses[i].toString(),
|
|
316
327
|
is_factory: true,
|
|
317
|
-
underlying_coins: __spreadArray([], underlyingCoinAddresses
|
|
328
|
+
underlying_coins: __spreadArray([], underlyingCoinAddresses.map(function (addr) { return coinAddressNameDict[addr]; }), true),
|
|
318
329
|
wrapped_coins: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }), true),
|
|
319
|
-
underlying_coin_addresses: underlyingCoinAddresses
|
|
330
|
+
underlying_coin_addresses: underlyingCoinAddresses,
|
|
320
331
|
wrapped_coin_addresses: coinAddresses[i],
|
|
321
|
-
underlying_decimals: __spreadArray([], underlyingCoinAddresses
|
|
332
|
+
underlying_decimals: __spreadArray([], underlyingCoinAddresses.map(function (addr) { return coinAddressDecimalsDict[addr]; }), true),
|
|
322
333
|
wrapped_decimals: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }), true),
|
|
323
334
|
swap_abi: tricryptoFactorySwapABI,
|
|
324
|
-
gauge_abi:
|
|
335
|
+
gauge_abi: this_1.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
325
336
|
};
|
|
337
|
+
};
|
|
338
|
+
this_1 = this;
|
|
339
|
+
for (i = 0; i < poolIds.length; i++) {
|
|
340
|
+
_loop_2(i);
|
|
326
341
|
}
|
|
327
342
|
return [2 /*return*/, TRICRYPTO_FACTORY_POOLS_DATA];
|
|
328
343
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ declare const curve: {
|
|
|
43
43
|
getUsdRate: (coin: string) => Promise<number>;
|
|
44
44
|
getGasPriceFromL1: () => Promise<number>;
|
|
45
45
|
getGasPriceFromL2: () => Promise<number>;
|
|
46
|
+
getGasInfoForL2: () => Promise<Record<string, number>>;
|
|
46
47
|
getTVL: (network?: import("./interfaces.js").INetworkName | import("./interfaces.js").IChainId) => Promise<number>;
|
|
47
48
|
getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<string[] | import("./interfaces.js").IDict<string[]>>;
|
|
48
49
|
getAllowance: (coins: string[], address: string, spender: string) => Promise<string[]>;
|
package/lib/index.js
CHANGED
|
@@ -39,7 +39,7 @@ import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList
|
|
|
39
39
|
import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapEstimateGas, swap, getSwappedAmount, } from "./router.js";
|
|
40
40
|
import { curve as _curve } from "./curve.js";
|
|
41
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
|
-
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, } from "./utils.js";
|
|
42
|
+
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, } from "./utils.js";
|
|
43
43
|
import { deployStablePlainPool, deployStablePlainPoolEstimateGas, getDeployedStablePlainPoolAddress, setOracle, setOracleEstimateGas, deployStableMetaPool, deployStableMetaPoolEstimateGas, getDeployedStableMetaPoolAddress, deployCryptoPool, deployCryptoPoolEstimateGas, getDeployedCryptoPoolAddress, deployTricryptoPool, deployTricryptoPoolEstimateGas, getDeployedTricryptoPoolAddress, deployGauge, deployGaugeEstimateGas, getDeployedGaugeAddress, deployGaugeSidechain, deployGaugeSidechainEstimateGas, deployGaugeMirror, deployGaugeMirrorEstimateGas, getDeployedGaugeMirrorAddress, getDeployedGaugeMirrorAddressByTx, deployStableNgPlainPool, deployStableNgPlainPoolEstimateGas, deployStableNgMetaPool, deployStableNgMetaPoolEstimateGas, deployTwocryptoPool, deployTwocryptoPoolEstimateGas, getDeployedTwocryptoPoolAddress, } from './factory/deploy.js';
|
|
44
44
|
import { crvSupplyStats, userCrv, userVeCrv, crvLockIsApproved, crvLockApproveEstimateGas, crvLockApprove, calcCrvUnlockTime, createCrvLockEstimateGas, createCrvLock, increaseCrvLockedAmountEstimateGas, increaseCrvLockedAmount, increaseCrvUnlockTimeEstimateGas, increaseCrvUnlockTime, withdrawLockedCrvEstimateGas as daoWithdrawLockedCrvEstimateGas, withdrawLockedCrv as daoWithdrawLockedCrv, claimableFees as daoClaimableFees, claimFeesEstimateGas as daoClaimFeesEstimateGas, claimFees as daoClaimFees, getVotingGaugeList, userGaugeVotes, voteForGaugeNextTime, voteForGaugeEstimateGas, voteForGauge, getProposalList, getProposal, userProposalVotes, voteForProposalEstimateGas, voteForProposal, } from "./dao.js";
|
|
45
45
|
function init(providerType, providerSettings, options) {
|
|
@@ -80,6 +80,7 @@ var curve = {
|
|
|
80
80
|
getUsdRate: getUsdRate,
|
|
81
81
|
getGasPriceFromL1: getGasPriceFromL1,
|
|
82
82
|
getGasPriceFromL2: getGasPriceFromL2,
|
|
83
|
+
getGasInfoForL2: getGasInfoForL2,
|
|
83
84
|
getTVL: getTVL,
|
|
84
85
|
getBalances: getBalances,
|
|
85
86
|
getAllowance: getAllowance,
|
package/lib/utils.d.ts
CHANGED
|
@@ -37,8 +37,10 @@ export declare const _getCrvApyFromApi: () => Promise<IDict<[number, number]>>;
|
|
|
37
37
|
export declare const _getRewardsFromApi: () => Promise<IDict<IRewardFromApi[]>>;
|
|
38
38
|
export declare const _getUsdRate: (assetId: string) => Promise<number>;
|
|
39
39
|
export declare const getUsdRate: (coin: string) => Promise<number>;
|
|
40
|
+
export declare const getBaseFeeByLastBlock: () => Promise<number>;
|
|
40
41
|
export declare const getGasPriceFromL1: () => Promise<number>;
|
|
41
42
|
export declare const getGasPriceFromL2: () => Promise<number>;
|
|
43
|
+
export declare const getGasInfoForL2: () => Promise<Record<string, number>>;
|
|
42
44
|
export declare const getTxCostsUsd: (ethUsdRate: number, gasPrice: number, gas: number | number[], gasPriceL1?: number) => number;
|
|
43
45
|
export declare const getTVL: (network?: INetworkName | IChainId) => Promise<number>;
|
|
44
46
|
export declare const getVolumeApiController: (network: INetworkName) => Promise<IVolumeAndAPYs>;
|
package/lib/utils.js
CHANGED
|
@@ -704,6 +704,29 @@ export var getUsdRate = function (coin) { return __awaiter(void 0, void 0, void
|
|
|
704
704
|
}
|
|
705
705
|
});
|
|
706
706
|
}); };
|
|
707
|
+
export var getBaseFeeByLastBlock = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
708
|
+
var provider, block, error_1;
|
|
709
|
+
return __generator(this, function (_a) {
|
|
710
|
+
switch (_a.label) {
|
|
711
|
+
case 0:
|
|
712
|
+
provider = curve.provider;
|
|
713
|
+
_a.label = 1;
|
|
714
|
+
case 1:
|
|
715
|
+
_a.trys.push([1, 3, , 4]);
|
|
716
|
+
return [4 /*yield*/, provider.getBlock('latest')];
|
|
717
|
+
case 2:
|
|
718
|
+
block = _a.sent();
|
|
719
|
+
if (!block) {
|
|
720
|
+
return [2 /*return*/, 0.01];
|
|
721
|
+
}
|
|
722
|
+
return [2 /*return*/, Number(block.baseFeePerGas) / (Math.pow(10, 9))];
|
|
723
|
+
case 3:
|
|
724
|
+
error_1 = _a.sent();
|
|
725
|
+
throw new Error(error_1);
|
|
726
|
+
case 4: return [2 /*return*/];
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
}); };
|
|
707
730
|
export var getGasPriceFromL1 = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
708
731
|
return __generator(this, function (_a) {
|
|
709
732
|
if (L2Networks.includes(curve.chainId) && curve.L1WeightedGasPrice) {
|
|
@@ -720,14 +743,32 @@ export var getGasPriceFromL2 = function () { return __awaiter(void 0, void 0, vo
|
|
|
720
743
|
return __generator(this, function (_a) {
|
|
721
744
|
switch (_a.label) {
|
|
722
745
|
case 0:
|
|
723
|
-
if (curve.chainId === 42161)
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
746
|
+
if (!(curve.chainId === 42161)) return [3 /*break*/, 2];
|
|
747
|
+
return [4 /*yield*/, getBaseFeeByLastBlock()];
|
|
748
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
749
|
+
case 2:
|
|
750
|
+
if (!L2Networks.includes(curve.chainId)) return [3 /*break*/, 4];
|
|
727
751
|
return [4 /*yield*/, curve.contracts[curve.constants.ALIASES.gas_oracle_blob].contract.gasPrice({ "gasPrice": "0x2000000" })];
|
|
728
|
-
case
|
|
752
|
+
case 3:
|
|
729
753
|
gasPrice = _a.sent();
|
|
730
754
|
return [2 /*return*/, Number(gasPrice)];
|
|
755
|
+
case 4: throw Error("This method exists only for L2 networks");
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
}); };
|
|
759
|
+
export var getGasInfoForL2 = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
760
|
+
var baseFee;
|
|
761
|
+
return __generator(this, function (_a) {
|
|
762
|
+
switch (_a.label) {
|
|
763
|
+
case 0:
|
|
764
|
+
if (!(curve.chainId === 42161)) return [3 /*break*/, 2];
|
|
765
|
+
return [4 /*yield*/, getBaseFeeByLastBlock()];
|
|
766
|
+
case 1:
|
|
767
|
+
baseFee = _a.sent();
|
|
768
|
+
return [2 /*return*/, {
|
|
769
|
+
maxFeePerGas: (baseFee * 1.1) + 0.01,
|
|
770
|
+
maxPriorityFeePerGas: 0.01,
|
|
771
|
+
}];
|
|
731
772
|
case 2: throw Error("This method exists only for L2 networks");
|
|
732
773
|
}
|
|
733
774
|
});
|