@curvefi/api 2.65.8 → 2.65.10
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.
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"stateMutability": "payable",
|
|
4
|
+
"type": "function",
|
|
5
|
+
"name": "deposit_and_stake",
|
|
6
|
+
"inputs": [
|
|
7
|
+
{
|
|
8
|
+
"name": "deposit",
|
|
9
|
+
"type": "address"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "lp_token",
|
|
13
|
+
"type": "address"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "gauge",
|
|
17
|
+
"type": "address"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "n_coins",
|
|
21
|
+
"type": "uint256"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "coins",
|
|
25
|
+
"type": "address[]"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "amounts",
|
|
29
|
+
"type": "uint256[]"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "min_mint_amount",
|
|
33
|
+
"type": "uint256"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "use_dynarray",
|
|
37
|
+
"type": "bool"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "pool",
|
|
41
|
+
"type": "address"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"outputs": []
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"stateMutability": "payable",
|
|
48
|
+
"type": "fallback"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
@@ -269,7 +269,7 @@ const ALIASES_FRAXTAL = lowerCaseValues({
|
|
|
269
269
|
"gauge_controller": "0x0000000000000000000000000000000000000000",
|
|
270
270
|
"address_provider": "0x0000000000000000000000000000000000000000",
|
|
271
271
|
"router": "0x9f2Fa7709B30c75047980a0d70A106728f0Ef2db",
|
|
272
|
-
"deposit_and_stake": "
|
|
272
|
+
"deposit_and_stake": "0xF0d4c12A5768D806021F80a262B4d39d26C58b8D",
|
|
273
273
|
"stable_ng_factory": '0xd2002373543Ce3527023C75e7518C274A51ce712',
|
|
274
274
|
"twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
|
|
275
275
|
"tricrypto_factory": '0xc9Fe0C63Af9A39402e8a5514f9c43Af0322b665F',
|
|
@@ -299,7 +299,7 @@ const ALIASES_MANTLE = lowerCaseValues({
|
|
|
299
299
|
"gauge_controller": "0x0000000000000000000000000000000000000000",
|
|
300
300
|
"address_provider": "0x0000000000000000000000000000000000000000",
|
|
301
301
|
"router": "0x4f37A9d177470499A2dD084621020b023fcffc1F",
|
|
302
|
-
"deposit_and_stake": "
|
|
302
|
+
"deposit_and_stake": "0xF0d4c12A5768D806021F80a262B4d39d26C58b8D",
|
|
303
303
|
"stable_ng_factory": '0x5eeE3091f747E60a045a2E715a4c71e600e31F6E',
|
|
304
304
|
"twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
|
|
305
305
|
"tricrypto_factory": '0x0C9D8c7e486e822C29488Ff51BFf0167B4650953',
|
package/lib/curve.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ethers, Contract, Networkish, BigNumberish, Numeric, BrowserProvider, JsonRpcProvider, Signer } from "ethers";
|
|
2
2
|
import { Provider as MulticallProvider, Contract as MulticallContract } from "@curvefi/ethcall";
|
|
3
3
|
import { IPoolData, IDict, ICurve, IChainId, IFactoryPoolType, Abi, INetworkConstants } from "./interfaces";
|
|
4
|
+
export declare const OLD_CHAINS: number[];
|
|
4
5
|
export declare const memoizedContract: () => (address: string, abi: any, provider: BrowserProvider | JsonRpcProvider | Signer) => Contract;
|
|
5
6
|
export declare const memoizedMulticallContract: () => (address: string, abi: any) => MulticallContract;
|
|
6
7
|
export type ContractItem = {
|
package/lib/curve.js
CHANGED
|
@@ -28,6 +28,7 @@ import feeDistributorABI from './constants/abis/fee_distributor.json' assert { t
|
|
|
28
28
|
import feeDistributorCrvUSDABI from './constants/abis/fee_distributor_crvusd.json' assert { type: 'json' };
|
|
29
29
|
import gaugeControllerABI from './constants/abis/gaugecontroller.json' assert { type: 'json' };
|
|
30
30
|
import depositAndStakeABI from './constants/abis/deposit_and_stake.json' assert { type: 'json' };
|
|
31
|
+
import depositAndStakeNgOnlyABI from './constants/abis/deposit_and_stake_ng_only.json' assert { type: 'json' };
|
|
31
32
|
import cryptoCalcZapABI from './constants/abis/crypto_calc.json' assert { type: 'json' };
|
|
32
33
|
import StableCalcZapABI from './constants/abis/stable_calc.json' assert { type: 'json' };
|
|
33
34
|
import routerABI from './constants/abis/router.json' assert { type: 'json' };
|
|
@@ -52,6 +53,7 @@ import { _getHiddenPools } from "./external-api.js";
|
|
|
52
53
|
import { L2Networks } from "./constants/L2Networks.js";
|
|
53
54
|
import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto.js";
|
|
54
55
|
import { getNetworkConstants } from "./utils.js";
|
|
56
|
+
export const OLD_CHAINS = [1, 10, 56, 100, 137, 250, 1284, 2222, 8453, 42161, 42220, 43114, 1313161554]; // these chains have non-ng pools
|
|
55
57
|
export const memoizedContract = () => {
|
|
56
58
|
const cache = {};
|
|
57
59
|
return (address, abi, provider) => {
|
|
@@ -549,7 +551,12 @@ class Curve {
|
|
|
549
551
|
else {
|
|
550
552
|
this.setContract(this.constants.ALIASES.router, routerNgPoolsOnlyABI);
|
|
551
553
|
}
|
|
552
|
-
|
|
554
|
+
if (OLD_CHAINS.includes(this.chainId)) {
|
|
555
|
+
this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStakeABI);
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStakeNgOnlyABI);
|
|
559
|
+
}
|
|
553
560
|
this.setContract(this.constants.ALIASES.crypto_calc, cryptoCalcZapABI);
|
|
554
561
|
this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
|
|
555
562
|
// --------- POOL FACTORY ---------
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import memoize from "memoizee";
|
|
11
11
|
import { _getAllGaugesFormatted } from '../external-api.js';
|
|
12
12
|
import { _getCoinAddresses, _ensureAllowance, _getUsdRate, hasAllowance, ensureAllowance, ensureAllowanceEstimateGas, BN, toBN, toStringFromBN, parseUnits, getEthIndex, fromBN, _cutZeros, _setContracts, _get_small_x, _get_price_impact, checkNumber, _getRewardsFromApi, mulBy1_3, smartNumber, DIGas, _getAddress, findAbiFunction, PERIODS, } from '../utils.js';
|
|
13
|
-
import { curve } from "../curve.js";
|
|
13
|
+
import { curve, OLD_CHAINS } from "../curve.js";
|
|
14
14
|
import ERC20Abi from '../constants/abis/ERC20.json' assert { type: 'json' };
|
|
15
15
|
import { CorePool } from "./subClasses/corePool.js";
|
|
16
16
|
import { StatsPool } from "./subClasses/statsPool.js";
|
|
@@ -1222,6 +1222,7 @@ export class PoolTemplate extends CorePool {
|
|
|
1222
1222
|
const _amounts = amounts.map((amount, i) => parseUnits(amount, decimals[i]));
|
|
1223
1223
|
const contract = curve.contracts[curve.constants.ALIASES.deposit_and_stake].contract;
|
|
1224
1224
|
const useUnderlying = isUnderlying && (this.isLending || (this.isCrypto && !this.isPlain)) && (!this.zap || this.id == 'avaxcrypto');
|
|
1225
|
+
const useDynarray = (!this.isCrypto && this.isNg && this.isPlain) || (isUnderlying && this.isMeta && (new PoolTemplate(this.basePool)).isNg);
|
|
1225
1226
|
const _expectedLpTokenAmount = isUnderlying ?
|
|
1226
1227
|
curve.parseUnits(yield this.depositAndStakeExpected(amounts)) :
|
|
1227
1228
|
curve.parseUnits(yield this.depositAndStakeWrappedExpected(amounts));
|
|
@@ -1229,12 +1230,25 @@ export class PoolTemplate extends CorePool {
|
|
|
1229
1230
|
const _minMintAmount = fromBN(minAmountBN);
|
|
1230
1231
|
const ethIndex = getEthIndex(coinAddresses);
|
|
1231
1232
|
const value = _amounts[ethIndex] || curve.parseUnits("0");
|
|
1232
|
-
|
|
1233
|
+
let _gas = BigInt(0);
|
|
1234
|
+
if (OLD_CHAINS.includes(curve.chainId)) {
|
|
1235
|
+
_gas = (yield contract.deposit_and_stake.estimateGas(depositAddress, this.lpToken, this.gauge.address, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, // <--- DIFFERENCE
|
|
1236
|
+
useDynarray, this.isMetaFactory && isUnderlying ? this.address : curve.constants.ZERO_ADDRESS, Object.assign(Object.assign({}, curve.constantOptions), { value })));
|
|
1237
|
+
}
|
|
1238
|
+
else {
|
|
1239
|
+
_gas = (yield contract.deposit_and_stake.estimateGas(depositAddress, this.lpToken, this.gauge.address, coins.length, coinAddresses, _amounts, _minMintAmount, useDynarray, this.isMetaFactory && isUnderlying ? this.address : curve.constants.ZERO_ADDRESS, Object.assign(Object.assign({}, curve.constantOptions), { value })));
|
|
1240
|
+
}
|
|
1233
1241
|
if (estimateGas)
|
|
1234
1242
|
return smartNumber(_gas);
|
|
1235
1243
|
yield curve.updateFeeData();
|
|
1236
1244
|
const gasLimit = DIGas(_gas) * curve.parseUnits("200", 0) / curve.parseUnits("100", 0);
|
|
1237
|
-
|
|
1245
|
+
if (OLD_CHAINS.includes(curve.chainId)) {
|
|
1246
|
+
return (yield contract.deposit_and_stake(depositAddress, this.lpToken, this.gauge.address, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, // <--- DIFFERENCE
|
|
1247
|
+
useDynarray, this.isMetaFactory && isUnderlying ? this.address : curve.constants.ZERO_ADDRESS, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
|
|
1248
|
+
}
|
|
1249
|
+
else {
|
|
1250
|
+
return (yield contract.deposit_and_stake(depositAddress, this.lpToken, this.gauge.address, coins.length, coinAddresses, _amounts, _minMintAmount, useDynarray, this.isMetaFactory && isUnderlying ? this.address : curve.constants.ZERO_ADDRESS, Object.assign(Object.assign({}, curve.options), { gasLimit, value }))).hash;
|
|
1251
|
+
}
|
|
1238
1252
|
});
|
|
1239
1253
|
}
|
|
1240
1254
|
// ---------------- WITHDRAW ----------------
|
package/lib/router.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import axios from "axios";
|
|
11
11
|
import memoize from "memoizee";
|
|
12
12
|
import { ethers } from "ethers";
|
|
13
|
-
import { curve } from "./curve.js";
|
|
13
|
+
import { curve, OLD_CHAINS } from "./curve.js";
|
|
14
14
|
import { _cutZeros, _get_price_impact, _get_small_x, _getCoinAddresses, _getCoinDecimals, _getUsdRate, BN, DIGas, ensureAllowance, ensureAllowanceEstimateGas, ETH_ADDRESS, fromBN, getGasPriceFromL1, getTxCostsUsd, hasAllowance, isEth, parseUnits, runWorker, smartNumber, toBN, } from "./utils.js";
|
|
15
15
|
import { getPool } from "./pools/index.js";
|
|
16
16
|
import { _getAmplificationCoefficientsFromApi } from "./pools/utils.js";
|
|
@@ -19,7 +19,6 @@ import { routeFinderWorker, routeFinderWorkerCode } from "./route-finder.worker.
|
|
|
19
19
|
import { routeGraphWorker, routeGraphWorkerCode } from "./route-graph.worker.js";
|
|
20
20
|
const MAX_STEPS = 5;
|
|
21
21
|
const ROUTE_LENGTH = (MAX_STEPS * 2) + 1;
|
|
22
|
-
const OLD_CHAINS = [1, 10, 56, 100, 137, 250, 1284, 2222, 8453, 42161, 42220, 43114, 1313161554]; // these chains have non-ng pools
|
|
23
22
|
const _getTVL = memoize((poolId) => __awaiter(void 0, void 0, void 0, function* () { return Number(yield (getPool(poolId)).stats.totalLiquidity()); }), {
|
|
24
23
|
promise: true,
|
|
25
24
|
maxAge: 5 * 60 * 1000, // 5m
|