@curvefi/api 2.63.10 → 2.64.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/lib/constants/coins/arbitrum.d.ts +0 -4
- package/lib/constants/coins/arbitrum.js +0 -4
- package/lib/constants/coins/aurora.d.ts +0 -4
- package/lib/constants/coins/aurora.js +0 -4
- package/lib/constants/coins/avalanche.d.ts +0 -3
- package/lib/constants/coins/avalanche.js +0 -3
- package/lib/constants/coins/base.d.ts +0 -4
- package/lib/constants/coins/base.js +0 -4
- package/lib/constants/coins/bsc.d.ts +0 -4
- package/lib/constants/coins/bsc.js +0 -4
- package/lib/constants/coins/celo.d.ts +0 -4
- package/lib/constants/coins/celo.js +0 -4
- package/lib/constants/coins/fantom.d.ts +0 -2
- package/lib/constants/coins/fantom.js +0 -2
- package/lib/constants/coins/fraxtal.d.ts +0 -4
- package/lib/constants/coins/fraxtal.js +0 -4
- package/lib/constants/coins/index.d.ts +18 -0
- package/lib/constants/coins/index.js +18 -0
- package/lib/constants/coins/kava.d.ts +0 -4
- package/lib/constants/coins/kava.js +0 -4
- package/lib/constants/coins/mantle.d.ts +0 -4
- package/lib/constants/coins/mantle.js +0 -4
- package/lib/constants/coins/moonbeam.d.ts +0 -4
- package/lib/constants/coins/moonbeam.js +0 -4
- package/lib/constants/coins/optimism.d.ts +0 -4
- package/lib/constants/coins/optimism.js +0 -4
- package/lib/constants/coins/polygon.d.ts +0 -3
- package/lib/constants/coins/polygon.js +0 -3
- package/lib/constants/coins/xdai.d.ts +0 -4
- package/lib/constants/coins/xdai.js +0 -4
- package/lib/constants/coins/xlayer.d.ts +0 -4
- package/lib/constants/coins/xlayer.js +0 -4
- package/lib/constants/coins/zksync.d.ts +0 -4
- package/lib/constants/coins/zksync.js +0 -4
- package/lib/constants/{tricryptoDeployImplementations.d.ts → factory/crypto.d.ts} +21 -0
- package/lib/constants/{tricryptoDeployImplementations.js → factory/crypto.js} +85 -0
- package/lib/constants/factory/index.d.ts +3 -0
- package/lib/constants/factory/index.js +3 -0
- package/lib/{factory/constants.d.ts → constants/factory/stable.d.ts} +6 -52
- package/lib/{factory/constants.js → constants/factory/stable.js} +41 -151
- package/lib/constants/network_constants.d.ts +3 -0
- package/lib/constants/{aliases.js → network_constants.js} +253 -96
- package/lib/curve.d.ts +22 -16
- package/lib/curve.js +94 -362
- package/lib/external-api.d.ts +5 -3
- package/lib/external-api.js +86 -12
- package/lib/factory/common.js +2 -3
- package/lib/factory/deploy.js +5 -4
- package/lib/factory/factory-api.js +53 -61
- package/lib/factory/factory-crypto.js +3 -3
- package/lib/factory/factory-tricrypto.js +2 -2
- package/lib/factory/factory.js +22 -11
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/interfaces.d.ts +26 -1
- package/lib/pools/PoolTemplate.d.ts +9 -82
- package/lib/pools/PoolTemplate.js +37 -379
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +3 -3
- package/lib/pools/mixins/poolBalancesMixin.d.ts +3 -3
- package/lib/pools/mixins/poolBalancesMixin.js +11 -11
- package/lib/pools/poolConstructor.js +14 -7
- package/lib/pools/subClasses/corePool.d.ts +68 -0
- package/lib/pools/subClasses/corePool.js +39 -0
- package/lib/pools/{gaugePool.d.ts → subClasses/gaugePool.d.ts} +1 -1
- package/lib/pools/{gaugePool.js → subClasses/gaugePool.js} +2 -2
- package/lib/pools/subClasses/statsPool.d.ts +45 -0
- package/lib/pools/subClasses/statsPool.js +227 -0
- package/lib/pools/subClasses/walletPool.d.ts +19 -0
- package/lib/pools/subClasses/walletPool.js +72 -0
- package/lib/pools/utils.d.ts +1 -0
- package/lib/pools/utils.js +36 -0
- package/lib/utils.d.ts +10 -1
- package/lib/utils.js +45 -7
- package/package.json +1 -1
- package/lib/constants/aliases.d.ts +0 -17
- package/lib/factory/constants-crypto.d.ts +0 -90
- package/lib/factory/constants-crypto.js +0 -122
package/lib/external-api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import memoize from "memoizee";
|
|
2
|
-
import { IExtendedPoolDataFromApi, IDict, INetworkName, IPoolType, IGaugesDataFromApi, IDaoProposal, IDaoProposalListItem, IVolumeAndAPYs } from "./interfaces";
|
|
3
|
-
export declare const _getPoolsFromApi: ((network: INetworkName, poolType: IPoolType) => Promise<IExtendedPoolDataFromApi>) & memoize.Memoized<(network: INetworkName, poolType: IPoolType) => Promise<IExtendedPoolDataFromApi>>;
|
|
4
|
-
export declare const _getAllPoolsFromApi: (network: INetworkName) => Promise<IExtendedPoolDataFromApi[]>;
|
|
2
|
+
import { IExtendedPoolDataFromApi, IDict, INetworkName, IPoolType, IGaugesDataFromApi, IDaoProposal, IDaoProposalListItem, IVolumeAndAPYs, ICurveLiteNetwork } from "./interfaces";
|
|
3
|
+
export declare const _getPoolsFromApi: ((network: INetworkName, poolType: IPoolType, isLiteChain?: any) => Promise<IExtendedPoolDataFromApi>) & memoize.Memoized<(network: INetworkName, poolType: IPoolType, isLiteChain?: any) => Promise<IExtendedPoolDataFromApi>>;
|
|
4
|
+
export declare const _getAllPoolsFromApi: (network: INetworkName, isLiteChain?: boolean) => Promise<IExtendedPoolDataFromApi[]>;
|
|
5
5
|
export declare const _getSubgraphData: ((network: INetworkName) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: INetworkName) => Promise<IVolumeAndAPYs>>;
|
|
6
6
|
export declare const _getVolumes: ((network: string) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: string) => Promise<IVolumeAndAPYs>>;
|
|
7
7
|
export declare const _getFactoryAPYs: ((network: string) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: string) => Promise<IVolumeAndAPYs>>;
|
|
@@ -26,3 +26,5 @@ export declare const _generateBoostingProof: ((block: number, address: string) =
|
|
|
26
26
|
}>>;
|
|
27
27
|
export declare const _getDaoProposalList: (() => Promise<IDaoProposalListItem[]>) & memoize.Memoized<() => Promise<IDaoProposalListItem[]>>;
|
|
28
28
|
export declare const _getDaoProposal: ((type: "PARAMETER" | "OWNERSHIP", id: number) => Promise<IDaoProposal>) & memoize.Memoized<(type: "PARAMETER" | "OWNERSHIP", id: number) => Promise<IDaoProposal>>;
|
|
29
|
+
export declare const _getLiteNetworksData: ((networkName: string) => Promise<any>) & memoize.Memoized<(networkName: string) => Promise<any>>;
|
|
30
|
+
export declare const _getCurveLiteNetworks: (() => Promise<ICurveLiteNetwork[]>) & memoize.Memoized<() => Promise<ICurveLiteNetwork[]>>;
|
package/lib/external-api.js
CHANGED
|
@@ -9,26 +9,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import axios from "axios";
|
|
11
11
|
import memoize from "memoizee";
|
|
12
|
-
export const _getPoolsFromApi = memoize((network, poolType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
export const _getPoolsFromApi = memoize((network, poolType, isLiteChain = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
13
|
var _a;
|
|
14
|
-
const
|
|
14
|
+
const api = isLiteChain ? "https://api-core.curve.fi/v1/" : "https://api.curve.fi/api";
|
|
15
|
+
const url = `${api}/getPools/${network}/${poolType}`;
|
|
15
16
|
const response = yield axios.get(url, { validateStatus: () => true });
|
|
16
17
|
return (_a = response.data.data) !== null && _a !== void 0 ? _a : { poolData: [], tvl: 0, tvlAll: 0 };
|
|
17
18
|
}), {
|
|
18
19
|
promise: true,
|
|
19
20
|
maxAge: 5 * 60 * 1000, // 5m
|
|
20
21
|
});
|
|
21
|
-
export const _getAllPoolsFromApi = (network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
export const _getAllPoolsFromApi = (network, isLiteChain = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
23
|
return yield Promise.all([
|
|
23
|
-
_getPoolsFromApi(network, "main"),
|
|
24
|
-
_getPoolsFromApi(network, "crypto"),
|
|
25
|
-
_getPoolsFromApi(network, "factory"),
|
|
26
|
-
_getPoolsFromApi(network, "factory-crvusd"),
|
|
27
|
-
_getPoolsFromApi(network, "factory-eywa"),
|
|
28
|
-
_getPoolsFromApi(network, "factory-crypto"),
|
|
29
|
-
_getPoolsFromApi(network, "factory-twocrypto"),
|
|
30
|
-
_getPoolsFromApi(network, "factory-tricrypto"),
|
|
31
|
-
_getPoolsFromApi(network, "factory-stable-ng"),
|
|
24
|
+
_getPoolsFromApi(network, "main", isLiteChain),
|
|
25
|
+
_getPoolsFromApi(network, "crypto", isLiteChain),
|
|
26
|
+
_getPoolsFromApi(network, "factory", isLiteChain),
|
|
27
|
+
_getPoolsFromApi(network, "factory-crvusd", isLiteChain),
|
|
28
|
+
_getPoolsFromApi(network, "factory-eywa", isLiteChain),
|
|
29
|
+
_getPoolsFromApi(network, "factory-crypto", isLiteChain),
|
|
30
|
+
_getPoolsFromApi(network, "factory-twocrypto", isLiteChain),
|
|
31
|
+
_getPoolsFromApi(network, "factory-tricrypto", isLiteChain),
|
|
32
|
+
_getPoolsFromApi(network, "factory-stable-ng", isLiteChain),
|
|
32
33
|
]);
|
|
33
34
|
});
|
|
34
35
|
export const _getSubgraphData = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -176,3 +177,76 @@ export const _getDaoProposal = memoize((type, id) => __awaiter(void 0, void 0, v
|
|
|
176
177
|
promise: true,
|
|
177
178
|
maxAge: 5 * 60 * 1000, // 5m
|
|
178
179
|
});
|
|
180
|
+
// --- CURVE LITE ---
|
|
181
|
+
export const _getLiteNetworksData = memoize((networkName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
182
|
+
var _j, _k;
|
|
183
|
+
try {
|
|
184
|
+
const url = `https://api-core.curve.fi/v1/getDeployment/${networkName}`;
|
|
185
|
+
const response = yield axios.get(url, { validateStatus: () => true });
|
|
186
|
+
if (response.status !== 200 || !((_j = response.data) === null || _j === void 0 ? void 0 : _j.data)) {
|
|
187
|
+
console.error('Failed to fetch network data:', response);
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const { config, contracts } = response.data.data;
|
|
191
|
+
const network_name = config.network_name || 'Unknown Network';
|
|
192
|
+
const native_currency_symbol = config.native_currency_symbol || 'N/A';
|
|
193
|
+
const wrapped_native_token = ((_k = config.wrapped_native_token) === null || _k === void 0 ? void 0 : _k.toLowerCase()) || '';
|
|
194
|
+
return {
|
|
195
|
+
NAME: network_name,
|
|
196
|
+
ALIASES: {
|
|
197
|
+
stable_ng_factory: contracts.amm.stableswap.factory.address.toLowerCase(),
|
|
198
|
+
twocrypto_factory: contracts.amm.twocryptoswap.factory.address.toLowerCase(),
|
|
199
|
+
tricrypto_factory: contracts.amm.tricryptoswap.factory.address.toLowerCase(),
|
|
200
|
+
child_gauge_factory: contracts.gauge.child_gauge.factory.address.toLowerCase(),
|
|
201
|
+
root_gauge_factory: contracts.gauge.child_gauge.factory.address.toLowerCase(),
|
|
202
|
+
router: contracts.helpers.router.address.toLowerCase(),
|
|
203
|
+
deposit_and_stake: contracts.helpers.deposit_and_stake_zap.address.toLowerCase(),
|
|
204
|
+
stable_ng_meta_zap: contracts.helpers.stable_swap_meta_zap.address.toLowerCase(),
|
|
205
|
+
crv: config.dao.crv.toLowerCase(),
|
|
206
|
+
},
|
|
207
|
+
NATIVE_COIN: {
|
|
208
|
+
symbol: native_currency_symbol,
|
|
209
|
+
address: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
210
|
+
wrappedSymbol: native_currency_symbol[0].toLowerCase() === native_currency_symbol[0]
|
|
211
|
+
? `w${native_currency_symbol}`
|
|
212
|
+
: `W${native_currency_symbol}`,
|
|
213
|
+
wrappedAddress: wrapped_native_token,
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
console.error('Error fetching network data:', error);
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}), {
|
|
222
|
+
promise: true,
|
|
223
|
+
maxAge: 5 * 60 * 1000, // 5 minutes
|
|
224
|
+
});
|
|
225
|
+
export const _getCurveLiteNetworks = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
226
|
+
var _l, _m;
|
|
227
|
+
const url = `https://api-core.curve.fi/v1/getPlatforms`;
|
|
228
|
+
const response = yield axios.get(url, { validateStatus: () => true });
|
|
229
|
+
if (response.status !== 200 || !((_m = (_l = response.data) === null || _l === void 0 ? void 0 : _l.data) === null || _m === void 0 ? void 0 : _m.platforms)) {
|
|
230
|
+
console.error('Failed to fetch Curve platforms:', response);
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
const { platforms, platformsMetadata } = response.data.data;
|
|
234
|
+
const networks = Object.entries(platforms)
|
|
235
|
+
.map(([platformId, _factories]) => {
|
|
236
|
+
const metadata = platformsMetadata[platformId];
|
|
237
|
+
if (!metadata)
|
|
238
|
+
return null;
|
|
239
|
+
return {
|
|
240
|
+
id: platformId,
|
|
241
|
+
name: metadata.name,
|
|
242
|
+
rpcUrl: metadata.rpcUrl,
|
|
243
|
+
chainId: metadata.chainId,
|
|
244
|
+
explorerUrl: metadata.explorerBaseUrl,
|
|
245
|
+
};
|
|
246
|
+
})
|
|
247
|
+
.filter((network) => network !== null);
|
|
248
|
+
return networks;
|
|
249
|
+
}), {
|
|
250
|
+
promise: true,
|
|
251
|
+
maxAge: 5 * 60 * 1000, // 5 minutes
|
|
252
|
+
});
|
package/lib/factory/common.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { FACTORY_CONSTANTS } from "./constants.js";
|
|
2
|
-
import { CRYPTO_FACTORY_CONSTANTS } from "./constants-crypto.js";
|
|
3
1
|
import { getPoolIdBySwapAddress } from "../utils.js";
|
|
4
2
|
export function setFactoryZapContracts(isCrypto) {
|
|
5
|
-
|
|
3
|
+
var _a;
|
|
4
|
+
const basePoolIdZapDict = (_a = (isCrypto ? this.constants.CRYPTO_FACTORY_CONSTANTS : this.constants.STABLE_FACTORY_CONSTANTS).basePoolIdZapDict) !== null && _a !== void 0 ? _a : {};
|
|
6
5
|
for (const basePoolId in basePoolIdZapDict) {
|
|
7
6
|
if (!Object.prototype.hasOwnProperty.call(basePoolIdZapDict, basePoolId))
|
|
8
7
|
continue;
|
package/lib/factory/deploy.js
CHANGED
|
@@ -8,12 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { ethers, Contract, Typed } from "ethers";
|
|
11
|
-
import { curve
|
|
11
|
+
import { curve } from "../curve.js";
|
|
12
|
+
import { NETWORK_CONSTANTS } from "../constants/network_constants.js";
|
|
12
13
|
import { getPool } from "../pools/index.js";
|
|
13
14
|
import { parseUnits, BN, mulBy1_3, getPoolIdBySwapAddress, DIGas, smartNumber } from '../utils.js';
|
|
14
15
|
import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" assert { type: 'json' };
|
|
15
16
|
import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" assert { type: 'json' };
|
|
16
|
-
import { tricryptoDeployImplementations } from "../constants/tricryptoDeployImplementations.js";
|
|
17
17
|
// ------- STABLE PLAIN POOLS -------
|
|
18
18
|
const _deployStablePlainPool = (name, symbol, coins, A, fee, // %
|
|
19
19
|
assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
|
|
@@ -441,6 +441,7 @@ const _deployTricryptoPool = (name, symbol, coins, A, gamma, midFee, // %
|
|
|
441
441
|
outFee, // %
|
|
442
442
|
allowedExtraProfit, feeGamma, adjustmentStep, emaTime, // Seconds
|
|
443
443
|
initialPrices, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
|
|
444
|
+
var _a, _b, _c, _d;
|
|
444
445
|
if (name.length > 64)
|
|
445
446
|
throw Error("Max name length = 64");
|
|
446
447
|
if (symbol.length > 32)
|
|
@@ -501,12 +502,12 @@ initialPrices, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
501
502
|
const _emaTime = parseUnits(Math.floor(emaTime / Math.log(2)), 0);
|
|
502
503
|
const _initialPrices = [parseUnits(initialPrices[0]), parseUnits(initialPrices[1])];
|
|
503
504
|
const contract = curve.contracts[curve.constants.ALIASES.tricrypto_factory].contract;
|
|
504
|
-
const gas = yield contract.deploy_pool.estimateGas(name, symbol, coins, curve.constants.ZERO_ADDRESS,
|
|
505
|
+
const gas = yield contract.deploy_pool.estimateGas(name, symbol, coins, curve.constants.ZERO_ADDRESS, (_b = (_a = curve.constants.CRYPTO_FACTORY_CONSTANTS.tricryptoDeployImplementations) === null || _a === void 0 ? void 0 : _a.implementationIdx) !== null && _b !== void 0 ? _b : 0, _A, _gamma, _midFee, _outFee, _feeGamma, _allowedExtraProfit, _adjustmentStep, _emaTime, _initialPrices, curve.constantOptions);
|
|
505
506
|
if (estimateGas)
|
|
506
507
|
return smartNumber(gas);
|
|
507
508
|
const gasLimit = mulBy1_3(DIGas(gas));
|
|
508
509
|
yield curve.updateFeeData();
|
|
509
|
-
return yield contract.deploy_pool(name, symbol, coins, curve.constants.NATIVE_TOKEN.wrappedAddress,
|
|
510
|
+
return yield contract.deploy_pool(name, symbol, coins, curve.constants.NATIVE_TOKEN.wrappedAddress, (_d = (_c = curve.constants.CRYPTO_FACTORY_CONSTANTS.tricryptoDeployImplementations) === null || _c === void 0 ? void 0 : _c.implementationIdx) !== null && _d !== void 0 ? _d : 0, _A, _gamma, _midFee, _outFee, _feeGamma, _allowedExtraProfit, _adjustmentStep, _emaTime, _initialPrices, Object.assign(Object.assign({}, curve.options), { gasLimit }));
|
|
510
511
|
});
|
|
511
512
|
export const deployTricryptoPoolEstimateGas = (name, symbol, coins, A, gamma, midFee, // %
|
|
512
513
|
outFee, // %
|
|
@@ -15,12 +15,12 @@ import cryptoFactorySwapABI from "../constants/abis/factory-crypto/factory-crypt
|
|
|
15
15
|
import twocryptoFactorySwapABI from "../constants/abis/factory-twocrypto/factory-twocrypto-pool.json" assert { type: 'json' };
|
|
16
16
|
import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool.json" assert { type: 'json' };
|
|
17
17
|
import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" assert { type: 'json' };
|
|
18
|
-
import { FACTORY_CONSTANTS } from "./constants.js";
|
|
19
|
-
import { CRYPTO_FACTORY_CONSTANTS } from "./constants-crypto.js";
|
|
20
18
|
import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
|
|
21
19
|
import { _getPoolsFromApi } from "../external-api.js";
|
|
22
20
|
import { assetTypeNameHandler, getPoolName, isStableNgPool } from "../utils.js";
|
|
23
|
-
import
|
|
21
|
+
import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" assert { type: 'json' };
|
|
22
|
+
import MetaStableSwapNGABI from "../constants/abis/factory-stable-ng/meta-stableswap-ng.json" assert { type: 'json' };
|
|
23
|
+
import PlainStableSwapNGABI from "../constants/abis/factory-stable-ng/plain-stableswap-ng.json" assert { type: 'json' };
|
|
24
24
|
export const lowerCasePoolDataAddresses = (poolsData) => {
|
|
25
25
|
var _a;
|
|
26
26
|
for (const poolData of poolsData) {
|
|
@@ -41,31 +41,25 @@ export const lowerCasePoolDataAddresses = (poolsData) => {
|
|
|
41
41
|
}
|
|
42
42
|
return poolsData;
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
const getSwapAbiByFactoryType = (factoryType, pool) => {
|
|
45
|
+
var _a;
|
|
46
|
+
const isETHEnabled = pool.implementationAddress === ((_a = curve.constants.CRYPTO_FACTORY_CONSTANTS.tricryptoDeployImplementations) === null || _a === void 0 ? void 0 : _a.amm_native_transfers_enabled);
|
|
47
|
+
const map = {
|
|
48
|
+
"factory-crypto": cryptoFactorySwapABI,
|
|
49
|
+
"factory-twocrypto": twocryptoFactorySwapABI,
|
|
50
|
+
"factory-tricrypto": isETHEnabled ? tricryptoFactorySwapABI : tricryptoFactoryEthDisabledSwapABI,
|
|
51
|
+
};
|
|
52
|
+
return map[factoryType];
|
|
53
|
+
};
|
|
54
|
+
function setFactorySwapContracts(rawPoolList, swapABIs, factoryType) {
|
|
55
|
+
if (["factory-crypto", "factory-twocrypto", "factory-tricrypto"].includes(factoryType)) {
|
|
56
56
|
rawPoolList.forEach((pool) => {
|
|
57
|
-
|
|
58
|
-
this.setContract(pool.address, tricryptoFactoryEthDisabledSwapABI);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.setContract(pool.address, tricryptoFactorySwapABI);
|
|
62
|
-
}
|
|
57
|
+
this.setContract(pool.address, getSwapAbiByFactoryType(factoryType, pool));
|
|
63
58
|
});
|
|
64
59
|
}
|
|
65
60
|
else {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.setContract(pool.address, implementationABIDict[pool.implementationAddress]);
|
|
61
|
+
rawPoolList.forEach((pool, i) => {
|
|
62
|
+
this.setContract(pool.address, swapABIs[i]);
|
|
69
63
|
});
|
|
70
64
|
}
|
|
71
65
|
}
|
|
@@ -90,36 +84,33 @@ function setFactoryCoinsContracts(rawPoolList) {
|
|
|
90
84
|
}
|
|
91
85
|
}
|
|
92
86
|
}
|
|
93
|
-
const getSwapAbiByFactoryType = (factoryType, pool) => {
|
|
94
|
-
const isETHDisabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_disabled;
|
|
95
|
-
const map = {
|
|
96
|
-
"factory-crypto": cryptoFactorySwapABI,
|
|
97
|
-
"factory-twocrypto": twocryptoFactorySwapABI,
|
|
98
|
-
"factory-tricrypto": isETHDisabled ? tricryptoFactoryEthDisabledSwapABI : tricryptoFactorySwapABI,
|
|
99
|
-
};
|
|
100
|
-
return map[factoryType];
|
|
101
|
-
};
|
|
102
87
|
export function getFactoryPoolsDataFromApi(factoryType) {
|
|
88
|
+
var _a;
|
|
103
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
90
|
const network = this.constants.NETWORK_NAME;
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
const is_ng = ["factory-stable-ng", "factory-twocrypto", "factory-tricrypto"].includes(factoryType);
|
|
92
|
+
const isCrypto = ["factory-crypto", "factory-twocrypto", "factory-tricrypto"].includes(factoryType);
|
|
93
|
+
const implementationABIDict = (_a = this.constants.STABLE_FACTORY_CONSTANTS.implementationABIDict) !== null && _a !== void 0 ? _a : {};
|
|
94
|
+
let rawPoolList = lowerCasePoolDataAddresses((yield _getPoolsFromApi(network, factoryType, this.isLiteChain)).poolData);
|
|
95
|
+
if (!isCrypto)
|
|
96
|
+
rawPoolList = rawPoolList.filter((p) => is_ng || p.implementationAddress in implementationABIDict);
|
|
110
97
|
// Filter duplications
|
|
111
98
|
const mainAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address);
|
|
112
99
|
rawPoolList = rawPoolList.filter((p) => !mainAddresses.includes(p.address));
|
|
113
|
-
|
|
100
|
+
const swapABIs = isCrypto ? [] : rawPoolList.map((pool) => is_ng ?
|
|
101
|
+
(pool.isMetaPool ? MetaStableSwapNGABI : PlainStableSwapNGABI) :
|
|
102
|
+
implementationABIDict[pool.implementationAddress]);
|
|
103
|
+
setFactorySwapContracts.call(this, rawPoolList, swapABIs, factoryType);
|
|
114
104
|
if (factoryType === "factory-crypto")
|
|
115
105
|
setCryptoFactoryTokenContracts.call(this, rawPoolList);
|
|
116
106
|
setFactoryGaugeContracts.call(this, rawPoolList);
|
|
117
107
|
setFactoryCoinsContracts.call(this, rawPoolList);
|
|
118
108
|
setFactoryZapContracts.call(this, isCrypto);
|
|
119
109
|
const FACTORY_POOLS_DATA = {};
|
|
120
|
-
rawPoolList.forEach((pool) => {
|
|
121
|
-
var _a, _b, _c;
|
|
110
|
+
rawPoolList.forEach((pool, i) => {
|
|
111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
122
112
|
const nativeToken = this.constants.NATIVE_TOKEN;
|
|
113
|
+
const isETHEnabled = pool.implementationAddress === ((_a = curve.constants.CRYPTO_FACTORY_CONSTANTS.tricryptoDeployImplementations) === null || _a === void 0 ? void 0 : _a.amm_native_transfers_enabled);
|
|
123
114
|
let coinAddresses = pool.coins.map((c) => c.address);
|
|
124
115
|
if (this.chainId === 137) {
|
|
125
116
|
coinAddresses = coinAddresses.map((a) => a === "0x0000000000000000000000000000000000001010" ? nativeToken.wrappedAddress : a);
|
|
@@ -133,7 +124,6 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
133
124
|
return c.symbol;
|
|
134
125
|
}
|
|
135
126
|
else if (factoryType === 'factory-tricrypto') {
|
|
136
|
-
const isETHEnabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
|
|
137
127
|
if (isETHEnabled) {
|
|
138
128
|
return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol;
|
|
139
129
|
}
|
|
@@ -150,7 +140,6 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
150
140
|
return addr;
|
|
151
141
|
}
|
|
152
142
|
else if (factoryType === 'factory-tricrypto') {
|
|
153
|
-
const isETHEnabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
|
|
154
143
|
if (isETHEnabled) {
|
|
155
144
|
return addr === nativeToken.wrappedAddress ? nativeToken.address : addr;
|
|
156
145
|
}
|
|
@@ -163,8 +152,8 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
163
152
|
}
|
|
164
153
|
});
|
|
165
154
|
const isPlain = underlyingCoinNames.toString() === wrappedCoinNames.toString();
|
|
166
|
-
const lpTokenBasePoolIdDict =
|
|
167
|
-
const basePoolIdZapDict =
|
|
155
|
+
const lpTokenBasePoolIdDict = (_b = this.constants.CRYPTO_FACTORY_CONSTANTS.lpTokenBasePoolIdDict) !== null && _b !== void 0 ? _b : {};
|
|
156
|
+
const basePoolIdZapDict = (_c = this.constants.CRYPTO_FACTORY_CONSTANTS.basePoolIdZapDict) !== null && _c !== void 0 ? _c : {};
|
|
168
157
|
const basePoolId = lpTokenBasePoolIdDict[coinAddresses[1]];
|
|
169
158
|
if (factoryType !== "factory-tricrypto" && factoryType !== "factory-twocrypto" && basePoolId) { // isMeta
|
|
170
159
|
const allPoolsData = Object.assign(Object.assign({}, this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
|
|
@@ -196,7 +185,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
196
185
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
197
186
|
deposit_abi: basePoolZap.ABI,
|
|
198
187
|
in_api: true,
|
|
199
|
-
is_ng
|
|
188
|
+
is_ng,
|
|
200
189
|
};
|
|
201
190
|
}
|
|
202
191
|
else {
|
|
@@ -220,22 +209,26 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
220
209
|
swap_abi: getSwapAbiByFactoryType(factoryType, pool),
|
|
221
210
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
222
211
|
in_api: true,
|
|
223
|
-
is_ng
|
|
212
|
+
is_ng,
|
|
224
213
|
};
|
|
225
214
|
}
|
|
226
215
|
}
|
|
227
216
|
else if (pool.isMetaPool) {
|
|
228
|
-
const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
229
217
|
const allPoolsData = Object.assign(Object.assign({}, this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
|
|
230
218
|
const basePoolId = getPoolIdByAddress(rawPoolList, pool.basePoolAddress);
|
|
231
219
|
this.constants.BASE_POOLS[basePoolId] = this.constants.BASE_POOLS[basePoolId] ? this.constants.BASE_POOLS[basePoolId] + 1 : 1;
|
|
232
|
-
const basePoolCoinNames = (
|
|
233
|
-
const basePoolCoinAddresses = (
|
|
234
|
-
const basePoolDecimals = (
|
|
235
|
-
const basePoolIdZapDict =
|
|
236
|
-
|
|
220
|
+
const basePoolCoinNames = (_d = allPoolsData[basePoolId]) === null || _d === void 0 ? void 0 : _d.underlying_coins;
|
|
221
|
+
const basePoolCoinAddresses = (_e = allPoolsData[basePoolId]) === null || _e === void 0 ? void 0 : _e.underlying_coin_addresses;
|
|
222
|
+
const basePoolDecimals = (_f = allPoolsData[basePoolId]) === null || _f === void 0 ? void 0 : _f.underlying_decimals;
|
|
223
|
+
const basePoolIdZapDict = (_g = this.constants.STABLE_FACTORY_CONSTANTS.basePoolIdZapDict) !== null && _g !== void 0 ? _g : {};
|
|
224
|
+
let deposit_address = (_h = this.constants.STABLE_FACTORY_CONSTANTS.stableNgBasePoolZap) !== null && _h !== void 0 ? _h : curve.constants.ZERO_ADDRESS;
|
|
225
|
+
let deposit_abi = StableNgBasePoolZapABI;
|
|
237
226
|
if (isStableNgPool(basePoolId)) {
|
|
238
|
-
this.setContract(
|
|
227
|
+
this.setContract(deposit_address, StableNgBasePoolZapABI);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
deposit_address = basePoolIdZapDict[basePoolId].address;
|
|
231
|
+
deposit_abi = basePoolIdZapDict[basePoolId].ABI;
|
|
239
232
|
}
|
|
240
233
|
FACTORY_POOLS_DATA[pool.id] = {
|
|
241
234
|
name: getPoolName(pool.name),
|
|
@@ -245,7 +238,7 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
245
238
|
swap_address: pool.address,
|
|
246
239
|
token_address: pool.address,
|
|
247
240
|
gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
|
|
248
|
-
deposit_address
|
|
241
|
+
deposit_address,
|
|
249
242
|
implementation_address: pool.implementationAddress,
|
|
250
243
|
is_meta: true,
|
|
251
244
|
is_factory: true,
|
|
@@ -256,15 +249,14 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
256
249
|
wrapped_coin_addresses: coinAddresses,
|
|
257
250
|
underlying_decimals: [coinDecimals[0], ...basePoolDecimals],
|
|
258
251
|
wrapped_decimals: coinDecimals,
|
|
259
|
-
swap_abi:
|
|
252
|
+
swap_abi: swapABIs[i],
|
|
260
253
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
261
|
-
deposit_abi
|
|
254
|
+
deposit_abi,
|
|
262
255
|
in_api: true,
|
|
263
|
-
is_ng
|
|
256
|
+
is_ng,
|
|
264
257
|
};
|
|
265
258
|
}
|
|
266
259
|
else {
|
|
267
|
-
const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
268
260
|
FACTORY_POOLS_DATA[pool.id] = {
|
|
269
261
|
name: getPoolName(pool.name),
|
|
270
262
|
full_name: pool.name,
|
|
@@ -282,10 +274,10 @@ export function getFactoryPoolsDataFromApi(factoryType) {
|
|
|
282
274
|
wrapped_coin_addresses: coinAddresses,
|
|
283
275
|
underlying_decimals: coinDecimals,
|
|
284
276
|
wrapped_decimals: coinDecimals,
|
|
285
|
-
swap_abi:
|
|
277
|
+
swap_abi: swapABIs[i],
|
|
286
278
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
287
279
|
in_api: true,
|
|
288
|
-
is_ng
|
|
280
|
+
is_ng,
|
|
289
281
|
};
|
|
290
282
|
}
|
|
291
283
|
});
|
|
@@ -13,7 +13,6 @@ import cryptoFactorySwapABI from "../constants/abis/factory-crypto/factory-crypt
|
|
|
13
13
|
import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
|
|
14
14
|
import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
|
|
15
15
|
import { setFactoryZapContracts } from "./common.js";
|
|
16
|
-
import { CRYPTO_FACTORY_CONSTANTS } from "./constants-crypto.js";
|
|
17
16
|
const deepFlatten = (arr) => [].concat(...arr.map((v) => (Array.isArray(v) ? deepFlatten(v) : v)));
|
|
18
17
|
function getRecentlyCreatedCryptoPoolId(swapAddress) {
|
|
19
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -197,6 +196,7 @@ function getCoinsData(tokenAddresses, coinAddresses, existingCoinAddrNameDict, e
|
|
|
197
196
|
});
|
|
198
197
|
}
|
|
199
198
|
export function getCryptoFactoryPoolData(fromIdx = 0, swapAddress) {
|
|
199
|
+
var _a, _b;
|
|
200
200
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
201
|
const [poolIds, swapAddresses] = swapAddress ?
|
|
202
202
|
[[yield getRecentlyCreatedCryptoPoolId.call(this, swapAddress)], [swapAddress.toLowerCase()]]
|
|
@@ -218,8 +218,8 @@ export function getCryptoFactoryPoolData(fromIdx = 0, swapAddress) {
|
|
|
218
218
|
const [poolSymbols, poolNames, coinAddressNameDict, coinAddressDecimalsDict] = yield getCoinsData.call(this, tokenAddresses, coinAddresses, existingCoinAddressNameDict, this.constants.DECIMALS);
|
|
219
219
|
const CRYPTO_FACTORY_POOLS_DATA = {};
|
|
220
220
|
for (let i = 0; i < poolIds.length; i++) {
|
|
221
|
-
const lpTokenBasePoolIdDict =
|
|
222
|
-
const basePoolIdZapDict =
|
|
221
|
+
const lpTokenBasePoolIdDict = (_a = this.constants.CRYPTO_FACTORY_CONSTANTS.lpTokenBasePoolIdDict) !== null && _a !== void 0 ? _a : {};
|
|
222
|
+
const basePoolIdZapDict = (_b = this.constants.CRYPTO_FACTORY_CONSTANTS.basePoolIdZapDict) !== null && _b !== void 0 ? _b : {};
|
|
223
223
|
const basePoolId = lpTokenBasePoolIdDict[coinAddresses[i][1].toLowerCase()];
|
|
224
224
|
if (basePoolId) { // isMeta
|
|
225
225
|
const allPoolsData = Object.assign(Object.assign({}, this.constants.POOLS_DATA), CRYPTO_FACTORY_POOLS_DATA);
|
|
@@ -13,7 +13,6 @@ import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory
|
|
|
13
13
|
import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" assert { type: 'json' };
|
|
14
14
|
import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
|
|
15
15
|
import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
|
|
16
|
-
import { tricryptoDeployImplementations } from "../constants/tricryptoDeployImplementations.js";
|
|
17
16
|
const deepFlatten = (arr) => [].concat(...arr.map((v) => (Array.isArray(v) ? deepFlatten(v) : v)));
|
|
18
17
|
function getRecentlyCreatedCryptoPoolId(swapAddress) {
|
|
19
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -168,6 +167,7 @@ function getCoinsData(tokenAddresses, coinAddresses, existingCoinAddrNameDict, e
|
|
|
168
167
|
});
|
|
169
168
|
}
|
|
170
169
|
export function getTricryptoFactoryPoolData(fromIdx = 0, swapAddress) {
|
|
170
|
+
var _a;
|
|
171
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
172
|
const [poolIds, swapAddresses] = swapAddress ?
|
|
173
173
|
[[yield getRecentlyCreatedCryptoPoolId.call(this, swapAddress)], [swapAddress.toLowerCase()]]
|
|
@@ -187,7 +187,7 @@ export function getTricryptoFactoryPoolData(fromIdx = 0, swapAddress) {
|
|
|
187
187
|
const TRICRYPTO_FACTORY_POOLS_DATA = {};
|
|
188
188
|
const nativeToken = this.constants.NATIVE_TOKEN;
|
|
189
189
|
for (let i = 0; i < poolIds.length; i++) {
|
|
190
|
-
const isETHEnabled = this.chainId === 1 || implementationAddresses[i] === tricryptoDeployImplementations
|
|
190
|
+
const isETHEnabled = this.chainId === 1 || implementationAddresses[i] === ((_a = this.constants.CRYPTO_FACTORY_CONSTANTS.tricryptoDeployImplementations) === null || _a === void 0 ? void 0 : _a.amm_native_transfers_enabled);
|
|
191
191
|
const underlyingCoinAddresses = coinAddresses[i].map((addr) => {
|
|
192
192
|
if (isETHEnabled) {
|
|
193
193
|
return addr === nativeToken.wrappedAddress ? nativeToken.address : addr;
|
package/lib/factory/factory.js
CHANGED
|
@@ -10,10 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { Contract as MulticallContract } from "@curvefi/ethcall";
|
|
11
11
|
import { curve } from "../curve.js";
|
|
12
12
|
import ERC20ABI from "../constants/abis/ERC20.json" assert { type: 'json' };
|
|
13
|
+
import PlainStableSwapNGABI from "../constants/abis/factory-stable-ng/plain-stableswap-ng.json" assert { type: 'json' };
|
|
14
|
+
import MetaStableSwapNGABI from "../constants/abis/factory-stable-ng/meta-stableswap-ng.json" assert { type: 'json' };
|
|
13
15
|
import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
|
|
14
16
|
import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
|
|
17
|
+
import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" assert { type: 'json' };
|
|
15
18
|
import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
|
|
16
|
-
import { FACTORY_CONSTANTS } from "./constants.js";
|
|
17
19
|
import { getPoolName, isStableNgPool } from "../utils.js";
|
|
18
20
|
export const BLACK_LIST = {
|
|
19
21
|
1: [
|
|
@@ -221,12 +223,14 @@ function getCoinsData(coinAddresses, existingCoinAddrNameDict, existingCoinAddrD
|
|
|
221
223
|
});
|
|
222
224
|
}
|
|
223
225
|
export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = curve.constants.ALIASES.factory) {
|
|
226
|
+
var _a, _b, _c;
|
|
224
227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
225
228
|
const [rawPoolIds, rawSwapAddresses] = swapAddress ?
|
|
226
229
|
[[yield getRecentlyCreatedPoolId.call(this, swapAddress, factoryAddress)], [swapAddress.toLowerCase()]]
|
|
227
230
|
: yield getFactoryIdsAndSwapAddresses.call(this, fromIdx, factoryAddress);
|
|
228
231
|
if (rawPoolIds.length === 0)
|
|
229
232
|
return {};
|
|
233
|
+
const is_ng = factoryAddress === curve.constants.ALIASES.stable_ng_factory;
|
|
230
234
|
const [rawImplementations, rawGauges, rawOldGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses] = yield getPoolsData.call(this, rawSwapAddresses, factoryAddress);
|
|
231
235
|
const poolIds = [];
|
|
232
236
|
const swapAddresses = [];
|
|
@@ -237,9 +241,9 @@ export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = cu
|
|
|
237
241
|
const poolNames = [];
|
|
238
242
|
const isMeta = [];
|
|
239
243
|
const coinAddresses = [];
|
|
240
|
-
const implementationABIDict =
|
|
244
|
+
const implementationABIDict = (_a = this.constants.STABLE_FACTORY_CONSTANTS.implementationABIDict) !== null && _a !== void 0 ? _a : {};
|
|
241
245
|
for (let i = 0; i < rawPoolIds.length; i++) {
|
|
242
|
-
if (rawImplementations[i] in implementationABIDict) {
|
|
246
|
+
if (is_ng || (rawImplementations[i] in implementationABIDict)) {
|
|
243
247
|
poolIds.push(rawPoolIds[i]);
|
|
244
248
|
swapAddresses.push(rawSwapAddresses[i]);
|
|
245
249
|
implementations.push(rawImplementations[i]);
|
|
@@ -251,7 +255,9 @@ export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = cu
|
|
|
251
255
|
coinAddresses.push(rawCoinAddresses[i]);
|
|
252
256
|
}
|
|
253
257
|
}
|
|
254
|
-
const swapABIs = implementations.map((addr) =>
|
|
258
|
+
const swapABIs = implementations.map((addr, i) => is_ng ?
|
|
259
|
+
(isMeta[i] ? MetaStableSwapNGABI : PlainStableSwapNGABI) :
|
|
260
|
+
implementationABIDict[addr]);
|
|
255
261
|
setFactorySwapContracts.call(this, swapAddresses, swapABIs);
|
|
256
262
|
setFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
257
263
|
setFactoryCoinsContracts.call(this, coinAddresses);
|
|
@@ -287,7 +293,7 @@ export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = cu
|
|
|
287
293
|
wrapped_decimals: [...coinAddresses[i].map((addr) => coinAddressDecimalsDict[addr])],
|
|
288
294
|
swap_abi: swapABIs[i],
|
|
289
295
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
290
|
-
is_ng
|
|
296
|
+
is_ng,
|
|
291
297
|
};
|
|
292
298
|
}
|
|
293
299
|
else {
|
|
@@ -298,11 +304,16 @@ export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = cu
|
|
|
298
304
|
const basePoolIdCoinAddressesDict = Object.fromEntries(basePools.ids.map((poolId) => { var _a; return [poolId, (_a = allPoolsData[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coin_addresses]; }));
|
|
299
305
|
// @ts-ignore
|
|
300
306
|
const basePoolIdDecimalsDict = Object.fromEntries(basePools.ids.map((poolId) => { var _a; return [poolId, (_a = allPoolsData[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_decimals]; }));
|
|
301
|
-
const basePoolIdZapDict =
|
|
307
|
+
const basePoolIdZapDict = (_b = this.constants.STABLE_FACTORY_CONSTANTS.basePoolIdZapDict) !== null && _b !== void 0 ? _b : {};
|
|
302
308
|
this.constants.BASE_POOLS[basePools.ids[i]] = this.constants.BASE_POOLS[basePools.ids[i]] ? this.constants.BASE_POOLS[basePools.ids[i]] + 1 : 1;
|
|
303
|
-
|
|
309
|
+
let deposit_address = (_c = this.constants.STABLE_FACTORY_CONSTANTS.stableNgBasePoolZap) !== null && _c !== void 0 ? _c : curve.constants.ZERO_ADDRESS;
|
|
310
|
+
let deposit_abi = StableNgBasePoolZapABI;
|
|
304
311
|
if (isStableNgPool(basePools.ids[i])) {
|
|
305
|
-
this.setContract(
|
|
312
|
+
this.setContract(deposit_address, StableNgBasePoolZapABI);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
deposit_address = basePoolIdZapDict[basePools.ids[i]].address;
|
|
316
|
+
deposit_abi = basePoolIdZapDict[basePools.ids[i]].ABI;
|
|
306
317
|
}
|
|
307
318
|
FACTORY_POOLS_DATA[poolIds[i]] = {
|
|
308
319
|
name: getPoolName(poolNames[i]),
|
|
@@ -312,7 +323,7 @@ export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = cu
|
|
|
312
323
|
swap_address: swapAddresses[i],
|
|
313
324
|
token_address: swapAddresses[i],
|
|
314
325
|
gauge_address: gaugeAddresses[i],
|
|
315
|
-
deposit_address
|
|
326
|
+
deposit_address,
|
|
316
327
|
implementation_address: implementations[i],
|
|
317
328
|
is_meta: true,
|
|
318
329
|
is_factory: true,
|
|
@@ -325,8 +336,8 @@ export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = cu
|
|
|
325
336
|
wrapped_decimals: [...coinAddresses[i].map((addr) => coinAddressDecimalsDict[addr])],
|
|
326
337
|
swap_abi: swapABIs[i],
|
|
327
338
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
328
|
-
deposit_abi
|
|
329
|
-
is_ng
|
|
339
|
+
deposit_abi,
|
|
340
|
+
is_ng,
|
|
330
341
|
};
|
|
331
342
|
}
|
|
332
343
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ declare const curve: {
|
|
|
62
62
|
}>;
|
|
63
63
|
hasDepositAndStake: () => boolean;
|
|
64
64
|
hasRouter: () => boolean;
|
|
65
|
+
getCurveLiteNetworks: () => Promise<import("./interfaces.js").ICurveLiteNetwork[]>;
|
|
65
66
|
factory: {
|
|
66
67
|
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
67
68
|
fetchNewPools: () => Promise<string[]>;
|
package/lib/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList
|
|
|
12
12
|
import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapEstimateGas, swap, getSwappedAmount, } from "./router.js";
|
|
13
13
|
import { curve as _curve } from "./curve.js";
|
|
14
14
|
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, claimFeesCrvUSDEstimateGas, claimableFeesCrvUSD, claimFeesCrvUSD, } from "./boosting.js";
|
|
15
|
-
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, getGasPrice, } from "./utils.js";
|
|
15
|
+
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, getGasPrice, getCurveLiteNetworks, } from "./utils.js";
|
|
16
16
|
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';
|
|
17
17
|
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, executeVote, executeVoteEstimateGas, isCanVoteExecute, } from "./dao.js";
|
|
18
18
|
function init(providerType, providerSettings, options = {}) {
|
|
@@ -56,6 +56,7 @@ const curve = {
|
|
|
56
56
|
getVolume,
|
|
57
57
|
hasDepositAndStake,
|
|
58
58
|
hasRouter,
|
|
59
|
+
getCurveLiteNetworks,
|
|
59
60
|
factory: {
|
|
60
61
|
fetchPools: _curve.fetchFactoryPools,
|
|
61
62
|
fetchNewPools: _curve.fetchNewFactoryPools,
|