@curvefi/api 2.71.0 → 2.71.2
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/cached.d.ts +1 -1
- package/lib/cached.js +10 -7
- package/lib/constants/factory/stable.js +2 -2
- package/lib/constants/pools/arbitrum.js +24 -0
- package/lib/constants/pools/avalanche.js +1 -1
- package/lib/constants/pools/optimism.js +25 -0
- package/lib/curve.js +21 -20
- package/lib/external-api.js +1 -1
- package/lib/factory/common.d.ts +1 -0
- package/lib/factory/common.js +16 -0
- package/lib/factory/factory-api.js +7 -37
- package/lib/factory/factory-crypto.js +4 -2
- package/lib/factory/factory-tricrypto.js +3 -2
- package/lib/factory/factory-twocrypto.js +3 -2
- package/lib/factory/factory.js +9 -8
- package/lib/interfaces.d.ts +1 -0
- package/lib/lite-api.js +3 -3
- package/lib/pools/PoolTemplate.js +3 -3
- package/lib/pools/subClasses/corePool.d.ts +3 -1
- package/lib/pools/subClasses/corePool.js +1 -0
- package/lib/pools/subClasses/statsPool.js +1 -1
- package/lib/prices-api.js +3 -14
- package/lib/router.js +2 -2
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +0 -1
- package/package.json +1 -1
package/lib/cached.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IDict, IExtendedPoolDataFromApi, INetworkName, IPoolType } from "./interfaces.js";
|
|
2
2
|
export declare const _getPoolsFromApi: (network: INetworkName, poolType: IPoolType, isLiteChain?: boolean) => Promise<IExtendedPoolDataFromApi>;
|
|
3
|
-
export declare const _getPoolTotalLiquidityFromApi: (network: INetworkName, poolId: string, address: string, isCrypto: boolean, isLiteChain: boolean) => Promise<string | undefined>;
|
|
4
3
|
export declare const _setPoolsFromApi: (network: INetworkName, isLiteChain: boolean, data: Record<IPoolType, IExtendedPoolDataFromApi>) => void;
|
|
5
4
|
export declare const _getAllPoolsFromApi: (network: INetworkName, isLiteChain: boolean) => Promise<IExtendedPoolDataFromApi[]>;
|
|
5
|
+
export declare const _getPoolTotalLiquidityFromApi: (network: INetworkName, address: string, isLiteChain: boolean) => Promise<string | undefined>;
|
|
6
6
|
export declare const _getUsdPricesFromApi: (network: INetworkName, isLiteChain: boolean) => Promise<IDict<number>>;
|
|
7
7
|
export declare const _getCrvApyFromApi: (network: INetworkName, isLiteChain: boolean) => Promise<IDict<[number, number]>>;
|
package/lib/cached.js
CHANGED
|
@@ -74,18 +74,21 @@ export const _getPoolsFromApi = (network_1, poolType_1, ...args_1) => __awaiter(
|
|
|
74
74
|
const { poolsDict } = yield _getCachedData(network, isLiteChain);
|
|
75
75
|
return poolsDict[poolType];
|
|
76
76
|
});
|
|
77
|
-
export const _getPoolTotalLiquidityFromApi = (network, poolId, address, isCrypto, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
-
const poolType = poolId.startsWith("factory") ? poolId.replace(/-\d+$/, '').replace(/-v2$/, '') : isCrypto ? "crypto" : "main";
|
|
79
|
-
const { poolData } = yield _getPoolsFromApi(network, poolType, isLiteChain);
|
|
80
|
-
const poolAddress = address.toLowerCase();
|
|
81
|
-
const poolEntry = poolData.find((data) => data.address.toLowerCase() === poolAddress);
|
|
82
|
-
return poolEntry ? String(poolEntry.usdTotal) : undefined;
|
|
83
|
-
});
|
|
84
77
|
export const _setPoolsFromApi = (network, isLiteChain, data) => _getCachedData.set(createCache(data), network, isLiteChain);
|
|
85
78
|
export const _getAllPoolsFromApi = (network, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
79
|
const { poolLists } = yield _getCachedData(network, isLiteChain);
|
|
87
80
|
return poolLists;
|
|
88
81
|
});
|
|
82
|
+
export const _getPoolTotalLiquidityFromApi = (network, address, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
const poolAddress = address.toLowerCase();
|
|
84
|
+
const poolLists = yield _getAllPoolsFromApi(network, isLiteChain);
|
|
85
|
+
for (const { poolData } of poolLists) {
|
|
86
|
+
const poolEntry = poolData.find((data) => data.address.toLowerCase() === poolAddress);
|
|
87
|
+
if (poolEntry)
|
|
88
|
+
return String(poolEntry.usdTotal);
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
});
|
|
89
92
|
export const _getUsdPricesFromApi = (network, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
93
|
const { usdPrices } = yield _getCachedData(network, isLiteChain);
|
|
91
94
|
return usdPrices;
|
|
@@ -322,7 +322,7 @@ export const basePoolIdZapDictArbitrum = {
|
|
|
322
322
|
address: "0x803A2B40c5a9BB2B86DD630B274Fa2A9202874C2".toLowerCase(),
|
|
323
323
|
ABI: MetaZapFantomABI,
|
|
324
324
|
},
|
|
325
|
-
|
|
325
|
+
fraxbp: {
|
|
326
326
|
address: "0x58AC91f5BE7dC0c35b24B96B19BAc55FBB8E705e".toLowerCase(),
|
|
327
327
|
ABI: MetaZapFantomABI,
|
|
328
328
|
},
|
|
@@ -332,7 +332,7 @@ export const basePoolIdZapDictOptimism = {
|
|
|
332
332
|
address: "0x167e42a1c7ab4be03764a2222aac57f5f6754411".toLowerCase(),
|
|
333
333
|
ABI: factoryDepositABI,
|
|
334
334
|
},
|
|
335
|
-
|
|
335
|
+
fraxbp: {
|
|
336
336
|
address: "0x4244eB811D6e0Ef302326675207A95113dB4E1F8".toLowerCase(),
|
|
337
337
|
ABI: MetaZapFantomABI,
|
|
338
338
|
},
|
|
@@ -32,6 +32,30 @@ export const POOLS_DATA_ARBITRUM = lowerCasePoolDataAddresses({
|
|
|
32
32
|
swap_abi: twopoolSwapABI,
|
|
33
33
|
gauge_abi: gaugeChildABI,
|
|
34
34
|
},
|
|
35
|
+
fraxbp: {
|
|
36
|
+
name: "fraxbp",
|
|
37
|
+
full_name: "fraxbp",
|
|
38
|
+
symbol: "fraxbp",
|
|
39
|
+
reference_asset: "USD",
|
|
40
|
+
swap_address: '0xC9B8a3FDECB9D5b218d02555a8Baf332E5B740d5',
|
|
41
|
+
token_address: '0xC9B8a3FDECB9D5b218d02555a8Baf332E5B740d5',
|
|
42
|
+
gauge_address: '0x95285Ea6fF14F80A2fD3989a6bAb993Bd6b5fA13',
|
|
43
|
+
is_plain: true,
|
|
44
|
+
underlying_coins: ['FRAX', 'USDC.e'],
|
|
45
|
+
wrapped_coins: ['FRAX', 'USDC.e'],
|
|
46
|
+
underlying_coin_addresses: [
|
|
47
|
+
'0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F',
|
|
48
|
+
'0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8',
|
|
49
|
+
],
|
|
50
|
+
wrapped_coin_addresses: [
|
|
51
|
+
'0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F',
|
|
52
|
+
'0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8',
|
|
53
|
+
],
|
|
54
|
+
underlying_decimals: [18, 6],
|
|
55
|
+
wrapped_decimals: [18, 6],
|
|
56
|
+
swap_abi: twopoolSwapABI,
|
|
57
|
+
gauge_abi: gaugeChildABI,
|
|
58
|
+
},
|
|
35
59
|
tricrypto: {
|
|
36
60
|
name: "tricrypto",
|
|
37
61
|
full_name: "tricrypto",
|
|
@@ -142,7 +142,7 @@ export const POOLS_DATA_AVALANCHE = lowerCasePoolDataAddresses({
|
|
|
142
142
|
deposit_address: '0x9f2Fa7709B30c75047980a0d70A106728f0Ef2db',
|
|
143
143
|
is_meta: true,
|
|
144
144
|
is_crypto: true,
|
|
145
|
-
base_pool: '
|
|
145
|
+
base_pool: '0x0974d9d3bc463fa17497aafc3a87535553298fbe',
|
|
146
146
|
meta_coin_idx: 0,
|
|
147
147
|
underlying_coins: ['USDC', 'USDt', 'BTC.b', 'AVAX'],
|
|
148
148
|
wrapped_coins: ['2CRV', 'BTC.b', 'WAVAX'],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { lowerCasePoolDataAddresses } from "../utils.js";
|
|
2
2
|
import tripoolSwapABI from '../abis/3pool-optimism/swap.json' with { type: 'json' };
|
|
3
|
+
import twopoolSwapABI from '../abis/2pool/swap.json' with { type: 'json' };
|
|
3
4
|
import wstETHSwapABI from '../abis/wsteth/swap.json' with { type: 'json' };
|
|
4
5
|
import gaugeChildABI from '../abis/gauge_child.json' with { type: 'json' };
|
|
5
6
|
export const POOLS_DATA_OPTIMISM = lowerCasePoolDataAddresses({
|
|
@@ -29,6 +30,30 @@ export const POOLS_DATA_OPTIMISM = lowerCasePoolDataAddresses({
|
|
|
29
30
|
swap_abi: tripoolSwapABI,
|
|
30
31
|
gauge_abi: gaugeChildABI,
|
|
31
32
|
},
|
|
33
|
+
fraxbp: {
|
|
34
|
+
name: "fraxbp",
|
|
35
|
+
full_name: "fraxbp",
|
|
36
|
+
symbol: "fraxbp",
|
|
37
|
+
reference_asset: 'USD',
|
|
38
|
+
is_plain: true,
|
|
39
|
+
swap_address: '0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7',
|
|
40
|
+
token_address: '0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7',
|
|
41
|
+
gauge_address: '0x4B960396011A914B4ccCC3b33DFEE83A97A9D766',
|
|
42
|
+
underlying_coins: ['FRAX', 'USDC.e'],
|
|
43
|
+
wrapped_coins: ['FRAX', 'USDC.e'],
|
|
44
|
+
underlying_coin_addresses: [
|
|
45
|
+
'0x2E3D870790dC77A83DD1d18184Acc7439A53f475',
|
|
46
|
+
'0x7F5c764cBc14f9669B88837ca1490cCa17c31607',
|
|
47
|
+
],
|
|
48
|
+
wrapped_coin_addresses: [
|
|
49
|
+
'0x2E3D870790dC77A83DD1d18184Acc7439A53f475',
|
|
50
|
+
'0x7F5c764cBc14f9669B88837ca1490cCa17c31607',
|
|
51
|
+
],
|
|
52
|
+
underlying_decimals: [18, 6],
|
|
53
|
+
wrapped_decimals: [18, 6],
|
|
54
|
+
swap_abi: twopoolSwapABI,
|
|
55
|
+
gauge_abi: gaugeChildABI,
|
|
56
|
+
},
|
|
32
57
|
wsteth: {
|
|
33
58
|
name: "wsteth",
|
|
34
59
|
full_name: "wsteth",
|
package/lib/curve.js
CHANGED
|
@@ -12,6 +12,7 @@ import { Contract as MulticallContract, Provider as MulticallProvider } from "@c
|
|
|
12
12
|
import { NETWORK_CONSTANTS } from "./constants/network_constants.js";
|
|
13
13
|
import { CRYPTO_FACTORY_CONSTANTS, STABLE_FACTORY_CONSTANTS } from "./constants/factory/index.js";
|
|
14
14
|
import { getFactoryPoolData } from "./factory/factory.js";
|
|
15
|
+
import { getLastFactoryPoolIndex } from "./factory/common.js";
|
|
15
16
|
import { getFactoryPoolsDataFromApi } from "./factory/factory-api.js";
|
|
16
17
|
import { getCryptoFactoryPoolData } from "./factory/factory-crypto.js";
|
|
17
18
|
import { getTricryptoFactoryPoolData } from "./factory/factory-tricrypto.js";
|
|
@@ -193,52 +194,52 @@ export class Curve {
|
|
|
193
194
|
this.fetchNewFactoryPools = () => __awaiter(this, void 0, void 0, function* () {
|
|
194
195
|
if (!("factory" in this.constants.ALIASES))
|
|
195
196
|
return [];
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
const
|
|
197
|
+
const fromIdx = yield getLastFactoryPoolIndex.call(this, this.constants.ALIASES.factory);
|
|
198
|
+
const poolData = lowerCasePoolDataAddresses(yield getFactoryPoolData.call(this, fromIdx));
|
|
199
|
+
const newPoolIds = Object.keys(poolData).filter((id) => !(id in this.constants.FACTORY_POOLS_DATA));
|
|
199
200
|
this.constants.FACTORY_POOLS_DATA = Object.assign(Object.assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
|
|
200
201
|
this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
|
|
201
|
-
return
|
|
202
|
+
return newPoolIds;
|
|
202
203
|
});
|
|
203
204
|
this.fetchNewCryptoFactoryPools = () => __awaiter(this, void 0, void 0, function* () {
|
|
204
205
|
if (!("crypto_factory" in this.constants.ALIASES))
|
|
205
206
|
return [];
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
const
|
|
207
|
+
const fromIdx = yield getLastFactoryPoolIndex.call(this, this.constants.ALIASES.crypto_factory);
|
|
208
|
+
const poolData = lowerCasePoolDataAddresses(yield getCryptoFactoryPoolData.call(this, fromIdx));
|
|
209
|
+
const newPoolIds = Object.keys(poolData).filter((id) => !(id in this.constants.CRYPTO_FACTORY_POOLS_DATA));
|
|
209
210
|
this.constants.CRYPTO_FACTORY_POOLS_DATA = Object.assign(Object.assign({}, this.constants.CRYPTO_FACTORY_POOLS_DATA), poolData);
|
|
210
211
|
this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
211
|
-
return
|
|
212
|
+
return newPoolIds;
|
|
212
213
|
});
|
|
213
214
|
this.fetchNewStableNgFactoryPools = () => __awaiter(this, void 0, void 0, function* () {
|
|
214
215
|
if (!("stable_ng_factory" in this.constants.ALIASES))
|
|
215
216
|
return [];
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
const
|
|
217
|
+
const fromIdx = yield getLastFactoryPoolIndex.call(this, this.constants.ALIASES.stable_ng_factory);
|
|
218
|
+
const poolData = lowerCasePoolDataAddresses(yield getFactoryPoolData.call(this, fromIdx, undefined, this.constants.ALIASES.stable_ng_factory));
|
|
219
|
+
const newPoolIds = Object.keys(poolData).filter((id) => !(id in this.constants.STABLE_NG_FACTORY_POOLS_DATA));
|
|
219
220
|
this.constants.STABLE_NG_FACTORY_POOLS_DATA = Object.assign(Object.assign({}, this.constants.STABLE_NG_FACTORY_POOLS_DATA), poolData);
|
|
220
221
|
this._updateDecimalsAndGauges(this.constants.STABLE_NG_FACTORY_POOLS_DATA);
|
|
221
|
-
return
|
|
222
|
+
return newPoolIds;
|
|
222
223
|
});
|
|
223
224
|
this.fetchNewTwocryptoFactoryPools = () => __awaiter(this, void 0, void 0, function* () {
|
|
224
225
|
if (!("twocrypto_factory" in this.constants.ALIASES))
|
|
225
226
|
return [];
|
|
226
|
-
const
|
|
227
|
-
const
|
|
228
|
-
const
|
|
227
|
+
const fromIdx = yield getLastFactoryPoolIndex.call(this, this.constants.ALIASES.twocrypto_factory);
|
|
228
|
+
const poolData = lowerCasePoolDataAddresses(yield getTwocryptoFactoryPoolData.call(this, fromIdx));
|
|
229
|
+
const newPoolIds = Object.keys(poolData).filter((id) => !(id in this.constants.TWOCRYPTO_FACTORY_POOLS_DATA));
|
|
229
230
|
this.constants.TWOCRYPTO_FACTORY_POOLS_DATA = Object.assign(Object.assign({}, this.constants.TWOCRYPTO_FACTORY_POOLS_DATA), poolData);
|
|
230
231
|
this._updateDecimalsAndGauges(this.constants.TWOCRYPTO_FACTORY_POOLS_DATA);
|
|
231
|
-
return
|
|
232
|
+
return newPoolIds;
|
|
232
233
|
});
|
|
233
234
|
this.fetchNewTricryptoFactoryPools = () => __awaiter(this, void 0, void 0, function* () {
|
|
234
235
|
if (!("tricrypto_factory" in this.constants.ALIASES))
|
|
235
236
|
return [];
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
const
|
|
237
|
+
const fromIdx = yield getLastFactoryPoolIndex.call(this, this.constants.ALIASES.tricrypto_factory);
|
|
238
|
+
const poolData = lowerCasePoolDataAddresses(yield getTricryptoFactoryPoolData.call(this, fromIdx));
|
|
239
|
+
const newPoolIds = Object.keys(poolData).filter((id) => !(id in this.constants.TRICRYPTO_FACTORY_POOLS_DATA));
|
|
239
240
|
this.constants.TRICRYPTO_FACTORY_POOLS_DATA = Object.assign(Object.assign({}, this.constants.TRICRYPTO_FACTORY_POOLS_DATA), poolData);
|
|
240
241
|
this._updateDecimalsAndGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
241
|
-
return
|
|
242
|
+
return newPoolIds;
|
|
242
243
|
});
|
|
243
244
|
this.fetchRecentlyDeployedFactoryPool = (poolAddress) => __awaiter(this, void 0, void 0, function* () {
|
|
244
245
|
if (!("factory" in this.constants.ALIASES))
|
package/lib/external-api.js
CHANGED
|
@@ -13,7 +13,7 @@ import { getLiteDeploymentFromApi2, getLiteNetworksFromApi2, getLitePoolsFromApi
|
|
|
13
13
|
// Core chains that ARE fully configured in the library (static POOLS_DATA / ALIASES /
|
|
14
14
|
// implementationABIDict) but whose live pool data is NOT indexed by prices.curve.finance.
|
|
15
15
|
// Their factory pools live in api2 instead, so we fetch from there while keeping them core
|
|
16
|
-
// (static main/crypto pools +
|
|
16
|
+
// (static main/crypto pools + impl-ABI dict all keep working).
|
|
17
17
|
const API2_BACKED_CORE_CHAINS = ["avalanche"];
|
|
18
18
|
const uncached_getPoolsFromApi = (network, poolType, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
if (isLiteChain || API2_BACKED_CORE_CHAINS.includes(network))
|
package/lib/factory/common.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import { ICurve, IPoolDataShort } from "../interfaces";
|
|
|
2
2
|
import { type Curve } from "../curve.js";
|
|
3
3
|
export declare function setFactoryZapContracts(this: ICurve, isCrypto: boolean): void;
|
|
4
4
|
export declare function getPoolIdByAddress(this: Curve, poolList: IPoolDataShort[], address: string): string;
|
|
5
|
+
export declare function getLastFactoryPoolIndex(this: Curve, factoryAddress: string): Promise<number>;
|
package/lib/factory/common.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { getPoolIdBySwapAddress } from "../utils.js";
|
|
2
11
|
export function setFactoryZapContracts(isCrypto) {
|
|
3
12
|
var _a;
|
|
@@ -20,3 +29,10 @@ export function getPoolIdByAddress(poolList, address) {
|
|
|
20
29
|
return getPoolIdBySwapAddress.call(this, address.toLowerCase());
|
|
21
30
|
}
|
|
22
31
|
}
|
|
32
|
+
export function getLastFactoryPoolIndex(factoryAddress) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const factoryContract = this.contracts[factoryAddress].contract;
|
|
35
|
+
const poolCount = Number(this.formatUnits(yield factoryContract.pool_count(this.constantOptions), 0));
|
|
36
|
+
return poolCount === 0 ? 0 : poolCount - 1;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -17,44 +17,11 @@ import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory
|
|
|
17
17
|
import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" with { type: "json" };
|
|
18
18
|
import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
|
|
19
19
|
import { _getPoolsFromApi } from "../cached.js";
|
|
20
|
-
import { assetTypeNameHandler, getPoolName
|
|
20
|
+
import { assetTypeNameHandler, getPoolName } from "../utils.js";
|
|
21
21
|
import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" with { type: "json" };
|
|
22
22
|
import MetaStableSwapNGABI from "../constants/abis/factory-stable-ng/meta-stableswap-ng.json" with { type: "json" };
|
|
23
23
|
import PlainStableSwapNGABI from "../constants/abis/factory-stable-ng/plain-stableswap-ng.json" with { type: "json" };
|
|
24
24
|
import { isYBPool } from "../constants/ybPools.js";
|
|
25
|
-
const FACTORY_ALIAS_BY_TYPE = {
|
|
26
|
-
"factory": "factory",
|
|
27
|
-
"factory-crvusd": "crvusd_factory",
|
|
28
|
-
"factory-crypto": "crypto_factory",
|
|
29
|
-
"factory-twocrypto": "twocrypto_factory",
|
|
30
|
-
"factory-tricrypto": "tricrypto_factory",
|
|
31
|
-
"factory-stable-ng": "stable_ng_factory",
|
|
32
|
-
};
|
|
33
|
-
const ID_PREFIX_BY_FACTORY_TYPE = {
|
|
34
|
-
"factory": "factory-v2",
|
|
35
|
-
"factory-crvusd": "factory-crvusd",
|
|
36
|
-
"factory-crypto": "factory-crypto",
|
|
37
|
-
"factory-twocrypto": "factory-twocrypto",
|
|
38
|
-
"factory-tricrypto": "factory-tricrypto",
|
|
39
|
-
"factory-stable-ng": "factory-stable-ng",
|
|
40
|
-
};
|
|
41
|
-
function reconcilePoolIdsWithChain(poolList, factoryType) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const factoryAddress = this.constants.ALIASES[FACTORY_ALIAS_BY_TYPE[factoryType]];
|
|
44
|
-
const factoryMulticallContract = this.contracts[factoryAddress].multicallContract;
|
|
45
|
-
const poolCount = Number(this.formatUnits(yield this.contracts[factoryAddress].contract.pool_count(this.constantOptions), 0));
|
|
46
|
-
const calls = [];
|
|
47
|
-
for (let i = 0; i < poolCount; i++)
|
|
48
|
-
calls.push(factoryMulticallContract.pool_list(i));
|
|
49
|
-
const addresses = (yield this.multicallProvider.all(calls));
|
|
50
|
-
const indexByAddress = new Map();
|
|
51
|
-
addresses.forEach((address, i) => indexByAddress.set(address.toLowerCase(), i));
|
|
52
|
-
const prefix = ID_PREFIX_BY_FACTORY_TYPE[factoryType];
|
|
53
|
-
return poolList
|
|
54
|
-
.filter((pool) => indexByAddress.has(pool.address))
|
|
55
|
-
.map((pool) => (Object.assign(Object.assign({}, pool), { id: `${prefix}-${indexByAddress.get(pool.address)}` })));
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
25
|
export const lowerCasePoolDataAddresses = (poolsData) => {
|
|
59
26
|
var _a;
|
|
60
27
|
for (const poolData of poolsData) {
|
|
@@ -124,8 +91,7 @@ function setFactoryCoinsContracts(rawPoolList) {
|
|
|
124
91
|
export function getFactoryPoolsDataFromApi(factoryType) {
|
|
125
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
93
|
const network = this.constants.NETWORK_NAME;
|
|
127
|
-
|
|
128
|
-
rawPoolList = yield reconcilePoolIdsWithChain.call(this, rawPoolList, factoryType);
|
|
94
|
+
const rawPoolList = lowerCasePoolDataAddresses((yield _getPoolsFromApi(network, factoryType, this.isLiteChain)).poolData);
|
|
129
95
|
return buildFactoryPoolsData.call(this, factoryType, rawPoolList);
|
|
130
96
|
});
|
|
131
97
|
}
|
|
@@ -231,6 +197,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
231
197
|
deposit_abi: basePoolZap.ABI,
|
|
232
198
|
in_api: true,
|
|
233
199
|
is_ng,
|
|
200
|
+
factory_type: factoryType,
|
|
234
201
|
};
|
|
235
202
|
}
|
|
236
203
|
else {
|
|
@@ -255,6 +222,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
255
222
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
256
223
|
in_api: true,
|
|
257
224
|
is_ng,
|
|
225
|
+
factory_type: factoryType,
|
|
258
226
|
};
|
|
259
227
|
}
|
|
260
228
|
}
|
|
@@ -270,7 +238,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
270
238
|
const basePoolIdZapDict = (_g = this.constants.STABLE_FACTORY_CONSTANTS.basePoolIdZapDict) !== null && _g !== void 0 ? _g : {};
|
|
271
239
|
let deposit_address = (_h = this.constants.STABLE_FACTORY_CONSTANTS.stableNgBasePoolZap) !== null && _h !== void 0 ? _h : this.constants.ZERO_ADDRESS;
|
|
272
240
|
let deposit_abi = StableNgBasePoolZapABI;
|
|
273
|
-
if (
|
|
241
|
+
if (allPoolsData[basePoolId].is_ng) {
|
|
274
242
|
this.setContract(deposit_address, StableNgBasePoolZapABI);
|
|
275
243
|
}
|
|
276
244
|
else {
|
|
@@ -301,6 +269,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
301
269
|
deposit_abi,
|
|
302
270
|
in_api: true,
|
|
303
271
|
is_ng,
|
|
272
|
+
factory_type: factoryType,
|
|
304
273
|
};
|
|
305
274
|
}
|
|
306
275
|
else {
|
|
@@ -325,6 +294,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
325
294
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
326
295
|
in_api: true,
|
|
327
296
|
is_ng,
|
|
297
|
+
factory_type: factoryType,
|
|
328
298
|
};
|
|
329
299
|
}
|
|
330
300
|
});
|
|
@@ -20,7 +20,7 @@ function getRecentlyCreatedCryptoPoolId(swapAddress) {
|
|
|
20
20
|
for (let i = 1; i <= poolCount; i++) {
|
|
21
21
|
const address = yield factoryContract.pool_list(poolCount - i);
|
|
22
22
|
if (address.toLowerCase() === swapAddress.toLowerCase())
|
|
23
|
-
return
|
|
23
|
+
return address.toLowerCase();
|
|
24
24
|
}
|
|
25
25
|
throw Error("Unknown pool");
|
|
26
26
|
});
|
|
@@ -36,7 +36,7 @@ function getCryptoFactoryIdsAndSwapAddresses() {
|
|
|
36
36
|
}
|
|
37
37
|
if (calls.length === 0)
|
|
38
38
|
return [[], []];
|
|
39
|
-
let factories = (yield this.multicallProvider.all(calls)).map((addr
|
|
39
|
+
let factories = (yield this.multicallProvider.all(calls)).map((addr) => ({ id: addr.toLowerCase(), address: addr.toLowerCase() }));
|
|
40
40
|
const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
|
|
41
41
|
factories = factories.filter((f) => !swapAddresses.includes(f.address));
|
|
42
42
|
return [factories.map((f) => f.id), factories.map((f) => f.address)];
|
|
@@ -247,6 +247,7 @@ export function getCryptoFactoryPoolData() {
|
|
|
247
247
|
swap_abi: cryptoFactorySwapABI,
|
|
248
248
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
249
249
|
deposit_abi: basePoolZap.ABI,
|
|
250
|
+
factory_type: "factory-crypto",
|
|
250
251
|
};
|
|
251
252
|
}
|
|
252
253
|
else {
|
|
@@ -269,6 +270,7 @@ export function getCryptoFactoryPoolData() {
|
|
|
269
270
|
wrapped_decimals: [...coinAddresses[i].map((addr) => coinAddressDecimalsDict[addr])],
|
|
270
271
|
swap_abi: cryptoFactorySwapABI,
|
|
271
272
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
273
|
+
factory_type: "factory-crypto",
|
|
272
274
|
};
|
|
273
275
|
}
|
|
274
276
|
}
|
|
@@ -20,7 +20,7 @@ function getRecentlyCreatedCryptoPoolId(swapAddress) {
|
|
|
20
20
|
for (let i = 1; i <= poolCount; i++) {
|
|
21
21
|
const address = yield factoryContract.pool_list(poolCount - i);
|
|
22
22
|
if (address.toLowerCase() === swapAddress.toLowerCase())
|
|
23
|
-
return
|
|
23
|
+
return address.toLowerCase();
|
|
24
24
|
}
|
|
25
25
|
throw Error("Unknown pool");
|
|
26
26
|
});
|
|
@@ -36,7 +36,7 @@ function getCryptoFactoryIdsAndSwapAddresses() {
|
|
|
36
36
|
}
|
|
37
37
|
if (calls.length === 0)
|
|
38
38
|
return [[], []];
|
|
39
|
-
let factories = (yield this.multicallProvider.all(calls)).map((addr
|
|
39
|
+
let factories = (yield this.multicallProvider.all(calls)).map((addr) => ({ id: addr.toLowerCase(), address: addr.toLowerCase() }));
|
|
40
40
|
const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
|
|
41
41
|
factories = factories.filter((f) => !swapAddresses.includes(f.address));
|
|
42
42
|
return [factories.map((f) => f.id), factories.map((f) => f.address)];
|
|
@@ -215,6 +215,7 @@ export function getTricryptoFactoryPoolData() {
|
|
|
215
215
|
swap_abi: isETHEnabled ? tricryptoFactorySwapABI : tricryptoFactoryEthDisabledSwapABI,
|
|
216
216
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
217
217
|
is_ng: true,
|
|
218
|
+
factory_type: "factory-tricrypto",
|
|
218
219
|
};
|
|
219
220
|
}
|
|
220
221
|
return TRICRYPTO_FACTORY_POOLS_DATA;
|
|
@@ -21,7 +21,7 @@ function getRecentlyCreatedCryptoPoolId(swapAddress) {
|
|
|
21
21
|
for (let i = 1; i <= poolCount; i++) {
|
|
22
22
|
const address = yield factoryContract.pool_list(poolCount - i);
|
|
23
23
|
if (address.toLowerCase() === swapAddress.toLowerCase())
|
|
24
|
-
return
|
|
24
|
+
return address.toLowerCase();
|
|
25
25
|
}
|
|
26
26
|
throw Error("Unknown pool");
|
|
27
27
|
});
|
|
@@ -37,7 +37,7 @@ function getTwocryptoFactoryIdsAndSwapAddresses() {
|
|
|
37
37
|
}
|
|
38
38
|
if (calls.length === 0)
|
|
39
39
|
return [[], []];
|
|
40
|
-
let factories = (yield this.multicallProvider.all(calls)).map((addr
|
|
40
|
+
let factories = (yield this.multicallProvider.all(calls)).map((addr) => ({ id: addr.toLowerCase(), address: addr.toLowerCase() }));
|
|
41
41
|
const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
|
|
42
42
|
factories = factories.filter((f) => !swapAddresses.includes(f.address));
|
|
43
43
|
return [factories.map((f) => f.id), factories.map((f) => f.address)];
|
|
@@ -207,6 +207,7 @@ export function getTwocryptoFactoryPoolData() {
|
|
|
207
207
|
swap_abi: twocryptoFactorySwapABI,
|
|
208
208
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
209
209
|
is_ng: true,
|
|
210
|
+
factory_type: "factory-twocrypto",
|
|
210
211
|
};
|
|
211
212
|
}
|
|
212
213
|
return TWOCRYPTO_FACTORY_POOLS_DATA;
|
package/lib/factory/factory.js
CHANGED
|
@@ -15,7 +15,7 @@ import factoryGaugeABI from "../constants/abis/gauge_factory.json" with { type:
|
|
|
15
15
|
import gaugeChildABI from "../constants/abis/gauge_child.json" with { type: "json" };
|
|
16
16
|
import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" with { type: "json" };
|
|
17
17
|
import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
|
|
18
|
-
import { getPoolName
|
|
18
|
+
import { getPoolName } from "../utils.js";
|
|
19
19
|
import { formatUnits } from "../constants/utils.js";
|
|
20
20
|
export const BLACK_LIST = {
|
|
21
21
|
1: [
|
|
@@ -61,12 +61,11 @@ export function getBasePools(factoryAddress, rawSwapAddresses, tmpPools) {
|
|
|
61
61
|
function getRecentlyCreatedPoolId(swapAddress, factoryAddress) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
const factoryContract = this.contracts[factoryAddress].contract;
|
|
64
|
-
const prefix = factoryAddress === this.constants.ALIASES.factory ? 'factory-v2' : 'factory-stable-ng';
|
|
65
64
|
const poolCount = Number(this.formatUnits(yield factoryContract.pool_count(this.constantOptions), 0));
|
|
66
65
|
for (let i = 1; i <= poolCount; i++) {
|
|
67
66
|
const address = yield factoryContract.pool_list(poolCount - i);
|
|
68
67
|
if (address.toLowerCase() === swapAddress.toLowerCase())
|
|
69
|
-
return
|
|
68
|
+
return address.toLowerCase();
|
|
70
69
|
}
|
|
71
70
|
throw Error("Unknown pool");
|
|
72
71
|
});
|
|
@@ -84,9 +83,7 @@ function getFactoryIdsAndSwapAddresses() {
|
|
|
84
83
|
}
|
|
85
84
|
if (calls.length === 0)
|
|
86
85
|
return [[], []];
|
|
87
|
-
|
|
88
|
-
factoryAddress === this.constants.ALIASES.crvusd_factory ? "factory-crvusd-" : "factory-stable-ng-";
|
|
89
|
-
let factories = (yield this.multicallProvider.all(calls)).map((addr, i) => ({ id: prefix + (fromIdx + i), address: addr.toLowerCase() }));
|
|
86
|
+
let factories = (yield this.multicallProvider.all(calls)).map((addr) => ({ id: addr.toLowerCase(), address: addr.toLowerCase() }));
|
|
90
87
|
const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
|
|
91
88
|
const blacklist = (_a = BLACK_LIST[this.chainId]) !== null && _a !== void 0 ? _a : [];
|
|
92
89
|
factories = factories.filter((f) => !swapAddresses.includes(f.address) && !blacklist.includes(f.address));
|
|
@@ -228,13 +225,15 @@ function getCoinsData(coinAddresses, existingCoinAddrNameDict, existingCoinAddrD
|
|
|
228
225
|
}
|
|
229
226
|
export function getFactoryPoolData() {
|
|
230
227
|
return __awaiter(this, arguments, void 0, function* (fromIdx = 0, swapAddress, factoryAddress = this.constants.ALIASES.factory) {
|
|
231
|
-
var _a, _b, _c;
|
|
228
|
+
var _a, _b, _c, _e;
|
|
232
229
|
const [rawPoolIds, rawSwapAddresses] = swapAddress ?
|
|
233
230
|
[[yield getRecentlyCreatedPoolId.call(this, swapAddress, factoryAddress)], [swapAddress.toLowerCase()]]
|
|
234
231
|
: yield getFactoryIdsAndSwapAddresses.call(this, fromIdx, factoryAddress);
|
|
235
232
|
if (rawPoolIds.length === 0)
|
|
236
233
|
return {};
|
|
237
234
|
const is_ng = factoryAddress === this.constants.ALIASES.stable_ng_factory;
|
|
235
|
+
const factory_type = factoryAddress === this.constants.ALIASES.crvusd_factory ? "factory-crvusd" :
|
|
236
|
+
is_ng ? "factory-stable-ng" : "factory";
|
|
238
237
|
const [rawImplementations, rawGauges, rawOldGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses] = yield getPoolsData.call(this, rawSwapAddresses, factoryAddress);
|
|
239
238
|
const poolIds = [];
|
|
240
239
|
const swapAddresses = [];
|
|
@@ -298,6 +297,7 @@ export function getFactoryPoolData() {
|
|
|
298
297
|
swap_abi: swapABIs[i],
|
|
299
298
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
300
299
|
is_ng,
|
|
300
|
+
factory_type,
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
303
|
else {
|
|
@@ -309,7 +309,7 @@ export function getFactoryPoolData() {
|
|
|
309
309
|
this.constants.BASE_POOLS[basePools.ids[i]] = this.constants.BASE_POOLS[basePools.ids[i]] ? this.constants.BASE_POOLS[basePools.ids[i]] + 1 : 1;
|
|
310
310
|
let deposit_address = (_c = this.constants.STABLE_FACTORY_CONSTANTS.stableNgBasePoolZap) !== null && _c !== void 0 ? _c : this.constants.ZERO_ADDRESS;
|
|
311
311
|
let deposit_abi = StableNgBasePoolZapABI;
|
|
312
|
-
if (
|
|
312
|
+
if ((_e = allPoolsData[basePools.ids[i]]) === null || _e === void 0 ? void 0 : _e.is_ng) {
|
|
313
313
|
this.setContract(deposit_address, StableNgBasePoolZapABI);
|
|
314
314
|
}
|
|
315
315
|
else {
|
|
@@ -339,6 +339,7 @@ export function getFactoryPoolData() {
|
|
|
339
339
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
340
340
|
deposit_abi,
|
|
341
341
|
is_ng,
|
|
342
|
+
factory_type,
|
|
342
343
|
};
|
|
343
344
|
}
|
|
344
345
|
}
|
package/lib/interfaces.d.ts
CHANGED
package/lib/lite-api.js
CHANGED
|
@@ -66,10 +66,10 @@ const _getApi2PoolsData = memoize((chainId) => __awaiter(void 0, void 0, void 0,
|
|
|
66
66
|
promise: true,
|
|
67
67
|
maxAge: 5 * 60 * 1000,
|
|
68
68
|
});
|
|
69
|
-
const adaptLitePool = (pool
|
|
69
|
+
const adaptLitePool = (pool) => {
|
|
70
70
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
71
71
|
return ({
|
|
72
|
-
id: pool.
|
|
72
|
+
id: pool.address.toLowerCase(),
|
|
73
73
|
name: pool.name,
|
|
74
74
|
symbol: pool.symbol,
|
|
75
75
|
assetTypeName: null,
|
|
@@ -111,7 +111,7 @@ export const getLitePoolsFromApi2 = (network, poolType) => __awaiter(void 0, voi
|
|
|
111
111
|
return { poolData: [], tvl: 0, tvlAll: 0 };
|
|
112
112
|
const { pool_data, tvl } = yield _getApi2PoolsData(chainId);
|
|
113
113
|
const poolsOfType = (pool_data !== null && pool_data !== void 0 ? pool_data : []).filter((pool) => API2_REGISTRY_TO_POOL_TYPE[pool.registry_id] === poolType);
|
|
114
|
-
const poolData = poolsOfType.map((pool) => adaptLitePool(pool
|
|
114
|
+
const poolData = poolsOfType.map((pool) => adaptLitePool(pool));
|
|
115
115
|
return {
|
|
116
116
|
poolData,
|
|
117
117
|
tvl: poolData.reduce((sum, p) => sum + p.usdTotal, 0),
|
|
@@ -757,7 +757,7 @@ export class PoolTemplate extends CorePool {
|
|
|
757
757
|
const multicallContract = this.curve.contracts[this.address].multicallContract;
|
|
758
758
|
if (this.isCrypto || this.id === 'wsteth') {
|
|
759
759
|
if (this.curve.isLiteChain) {
|
|
760
|
-
const prices = this.
|
|
760
|
+
const prices = this.factoryType === 'factory-twocrypto'
|
|
761
761
|
? [
|
|
762
762
|
1,
|
|
763
763
|
Number(yield this.curve.contracts[this.address].contract.price_oracle()) / (Math.pow(10, 18)),
|
|
@@ -1415,7 +1415,7 @@ export class PoolTemplate extends CorePool {
|
|
|
1415
1415
|
const multicallContract = this.curve.contracts[this.address].multicallContract;
|
|
1416
1416
|
if (this.isCrypto || this.id === 'wsteth') {
|
|
1417
1417
|
if (this.curve.isLiteChain) {
|
|
1418
|
-
const prices = this.
|
|
1418
|
+
const prices = this.factoryType === 'factory-twocrypto'
|
|
1419
1419
|
? [
|
|
1420
1420
|
1,
|
|
1421
1421
|
Number(yield this.curve.contracts[this.address].contract.price_oracle()) / (Math.pow(10, 18)),
|
|
@@ -1550,7 +1550,7 @@ export class PoolTemplate extends CorePool {
|
|
|
1550
1550
|
const multicallContract = this.curve.contracts[this.address].multicallContract;
|
|
1551
1551
|
if (this.isCrypto || this.id === 'wsteth') {
|
|
1552
1552
|
if (this.curve.isLiteChain) {
|
|
1553
|
-
const prices = this.
|
|
1553
|
+
const prices = this.factoryType === 'factory-twocrypto'
|
|
1554
1554
|
? [
|
|
1555
1555
|
1,
|
|
1556
1556
|
Number(yield this.curve.contracts[this.address].contract.price_oracle()) / (Math.pow(10, 18)),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Curve } from "../../curve.js";
|
|
2
2
|
import { IGaugePool } from "./gaugePool.js";
|
|
3
|
-
import { IPoolData } from "../../interfaces";
|
|
3
|
+
import { IFactoryPoolType, IPoolData } from "../../interfaces";
|
|
4
4
|
export interface ICorePool {
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
@@ -23,6 +23,7 @@ export interface ICorePool {
|
|
|
23
23
|
isMetaFactory: boolean;
|
|
24
24
|
isNg: boolean;
|
|
25
25
|
isLlamma: boolean;
|
|
26
|
+
factoryType: IFactoryPoolType | null;
|
|
26
27
|
basePool: string;
|
|
27
28
|
metaCoinIdx: number;
|
|
28
29
|
underlyingCoins: string[];
|
|
@@ -57,6 +58,7 @@ export declare class CorePool implements ICorePool {
|
|
|
57
58
|
isMetaFactory: boolean;
|
|
58
59
|
isNg: boolean;
|
|
59
60
|
isLlamma: boolean;
|
|
61
|
+
factoryType: IFactoryPoolType | null;
|
|
60
62
|
basePool: string;
|
|
61
63
|
metaCoinIdx: number;
|
|
62
64
|
underlyingCoins: string[];
|
|
@@ -27,6 +27,7 @@ export class CorePool {
|
|
|
27
27
|
this.isMetaFactory = (this.isMeta && this.isFactory) || this.zap === '0xa79828df1850e8a3a3064576f380d90aecdd3359';
|
|
28
28
|
this.isNg = poolData.is_ng || false;
|
|
29
29
|
this.isLlamma = poolData.is_llamma || false;
|
|
30
|
+
this.factoryType = poolData.factory_type || null;
|
|
30
31
|
this.basePool = poolData.base_pool || '';
|
|
31
32
|
this.metaCoinIdx = this.isMeta ? (_a = poolData.meta_coin_idx) !== null && _a !== void 0 ? _a : poolData.wrapped_coins.length - 1 : -1;
|
|
32
33
|
this.underlyingCoins = poolData.underlying_coins;
|
|
@@ -107,7 +107,7 @@ export class StatsPool {
|
|
|
107
107
|
return stablecoinTvlBN.plus(collateralTvlBN).toString();
|
|
108
108
|
}
|
|
109
109
|
if (useApi) {
|
|
110
|
-
const totalLiquidity = yield _getPoolTotalLiquidityFromApi(curve.constants.NETWORK_NAME, this.pool.
|
|
110
|
+
const totalLiquidity = yield _getPoolTotalLiquidityFromApi(curve.constants.NETWORK_NAME, this.pool.address, curve.isLiteChain);
|
|
111
111
|
if (totalLiquidity !== undefined)
|
|
112
112
|
return totalLiquidity;
|
|
113
113
|
}
|
package/lib/prices-api.js
CHANGED
|
@@ -28,16 +28,6 @@ export const PRICES_POOL_TYPE_TO_LEGACY = {
|
|
|
28
28
|
stableswapng: "factory-stable-ng",
|
|
29
29
|
twocryptong: "factory-twocrypto",
|
|
30
30
|
};
|
|
31
|
-
const ID_PREFIX_BY_POOL_TYPE = {
|
|
32
|
-
"main": "main",
|
|
33
|
-
"crypto": "crypto",
|
|
34
|
-
"factory": "factory-v2",
|
|
35
|
-
"factory-crvusd": "factory-crvusd",
|
|
36
|
-
"factory-crypto": "factory-crypto",
|
|
37
|
-
"factory-twocrypto": "factory-twocrypto",
|
|
38
|
-
"factory-tricrypto": "factory-tricrypto",
|
|
39
|
-
"factory-stable-ng": "factory-stable-ng",
|
|
40
|
-
};
|
|
41
31
|
function fetchJson(url) {
|
|
42
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
33
|
var _a;
|
|
@@ -67,12 +57,11 @@ export const getGaugesOverview = () => __awaiter(void 0, void 0, void 0, functio
|
|
|
67
57
|
const { gauges } = yield _getGaugesOverview();
|
|
68
58
|
return gauges !== null && gauges !== void 0 ? gauges : [];
|
|
69
59
|
});
|
|
70
|
-
const
|
|
71
|
-
const adaptPoolFromPricesApi = (pool, id, gaugeAddressByPoolAddress) => {
|
|
60
|
+
const adaptPoolFromPricesApi = (pool, gaugeAddressByPoolAddress) => {
|
|
72
61
|
var _a, _b, _c, _d, _e;
|
|
73
62
|
const coins = [...pool.coins].sort((a, b) => a.pool_index - b.pool_index).slice(0, pool.n_coins);
|
|
74
63
|
return {
|
|
75
|
-
id,
|
|
64
|
+
id: pool.address.toLowerCase(),
|
|
76
65
|
name: pool.name,
|
|
77
66
|
symbol: (_a = pool.lp_token_symbol) !== null && _a !== void 0 ? _a : pool.name,
|
|
78
67
|
assetTypeName: null,
|
|
@@ -113,7 +102,7 @@ export const getPoolsFromPricesApi = (network, poolType) => __awaiter(void 0, vo
|
|
|
113
102
|
const poolsOfType = chainData.data
|
|
114
103
|
.filter((pool) => PRICES_POOL_TYPE_TO_LEGACY[pool.pool_type] === poolType)
|
|
115
104
|
.sort((a, b) => a.creation_block_number - b.creation_block_number);
|
|
116
|
-
const poolData = poolsOfType.map((pool
|
|
105
|
+
const poolData = poolsOfType.map((pool) => adaptPoolFromPricesApi(pool, gaugeAddressByPoolAddress));
|
|
117
106
|
return {
|
|
118
107
|
poolData,
|
|
119
108
|
tvl: poolData.reduce((sum, p) => sum + p.usdTotal, 0),
|
package/lib/router.js
CHANGED
|
@@ -27,10 +27,10 @@ export function setRouterBlacklist(blacklist) {
|
|
|
27
27
|
delete this._getBestRoute;
|
|
28
28
|
}
|
|
29
29
|
function _getTVL(poolId_1, _a) {
|
|
30
|
-
return __awaiter(this, arguments, void 0, function* (poolId, {
|
|
30
|
+
return __awaiter(this, arguments, void 0, function* (poolId, { is_llamma, swap_address }) {
|
|
31
31
|
// LLAMMA liquidity must be calculated on-chain, even when the API has an entry.
|
|
32
32
|
if (!is_llamma) {
|
|
33
|
-
const totalLiquidity = yield _getPoolTotalLiquidityFromApi(this.constants.NETWORK_NAME,
|
|
33
|
+
const totalLiquidity = yield _getPoolTotalLiquidityFromApi(this.constants.NETWORK_NAME, swap_address, this.isLiteChain);
|
|
34
34
|
if (totalLiquidity !== undefined)
|
|
35
35
|
return Number(totalLiquidity);
|
|
36
36
|
}
|
package/lib/utils.d.ts
CHANGED
|
@@ -102,7 +102,6 @@ export declare const findAbiFunction: (abi: Abi, methodName: string) => AbiFunct
|
|
|
102
102
|
export declare const getCountArgsOfMethodByAbi: (abi: Abi, methodName: string) => number;
|
|
103
103
|
export declare const findAbiSignature: (abi: Abi, methodName: string, signature: string) => AbiFunction | undefined;
|
|
104
104
|
export declare const getPoolName: (name: string) => string;
|
|
105
|
-
export declare const isStableNgPool: (name: string) => boolean;
|
|
106
105
|
export declare const assetTypeNameHandler: (assetTypeName: string | null) => REFERENCE_ASSET;
|
|
107
106
|
export declare function getBasePools(this: Curve): Promise<IBasePoolShortItem[]>;
|
|
108
107
|
export declare function log(fnName: string, ...args: unknown[]): void;
|
package/lib/utils.js
CHANGED
|
@@ -779,7 +779,6 @@ export const getPoolName = (name) => {
|
|
|
779
779
|
return separatedName[0].trim();
|
|
780
780
|
}
|
|
781
781
|
};
|
|
782
|
-
export const isStableNgPool = (name) => name.includes('factory-stable-ng');
|
|
783
782
|
export const assetTypeNameHandler = (assetTypeName) => {
|
|
784
783
|
if (!assetTypeName || assetTypeName.toUpperCase() === 'UNKNOWN') {
|
|
785
784
|
return 'OTHER';
|