@curvefi/api 2.70.5 → 2.71.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -7
- 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/avalanche.js +1 -1
- package/lib/constants/pools/ethereum.js +2 -2
- package/lib/constants/volumeNetworks.d.ts +0 -2
- package/lib/constants/volumeNetworks.js +1 -3
- package/lib/curve.js +6 -9
- package/lib/dao.js +37 -28
- package/lib/external-api.d.ts +3 -8
- package/lib/external-api.js +23 -122
- package/lib/factory/factory-api.js +7 -3
- package/lib/factory/factory-crypto.js +4 -2
- package/lib/factory/factory-tricrypto.js +4 -2
- package/lib/factory/factory-twocrypto.js +4 -2
- package/lib/factory/factory.js +14 -8
- package/lib/interfaces.d.ts +6 -23
- package/lib/lite-api.d.ts +4 -0
- package/lib/lite-api.js +130 -0
- package/lib/pools/PoolTemplate.d.ts +0 -2
- package/lib/pools/PoolTemplate.js +9 -13
- 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.d.ts +21 -0
- package/lib/prices-api.js +138 -0
- package/lib/router.js +3 -3
- package/lib/utils.d.ts +1 -2
- package/lib/utils.js +3 -10
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -494,13 +494,6 @@ import curve from "@curvefi/api";
|
|
|
494
494
|
// true
|
|
495
495
|
await pool.isGaugeKilled();
|
|
496
496
|
// false
|
|
497
|
-
await pool.gaugeStatus();
|
|
498
|
-
// null OR
|
|
499
|
-
//{
|
|
500
|
-
// rewardsNeedNudging: false,
|
|
501
|
-
// areCrvRewardsStuckInBridge: false,
|
|
502
|
-
//
|
|
503
|
-
// }
|
|
504
497
|
})()
|
|
505
498
|
````
|
|
506
499
|
|
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
|
+
"0xc9b8a3fdecb9d5b218d02555a8baf332e5b740d5": {
|
|
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
|
+
"0x29a3d66b30bc4ad674a4fdaf27578b64f6afbfe7": {
|
|
336
336
|
address: "0x4244eB811D6e0Ef302326675207A95113dB4E1F8".toLowerCase(),
|
|
337
337
|
ABI: MetaZapFantomABI,
|
|
338
338
|
},
|
|
@@ -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'],
|
|
@@ -1505,8 +1505,8 @@ export const POOLS_DATA_ETHEREUM = lowerCasePoolDataAddresses({
|
|
|
1505
1505
|
is_meta: true,
|
|
1506
1506
|
is_crypto: true,
|
|
1507
1507
|
base_pool: '3pool',
|
|
1508
|
-
underlying_coins: ['
|
|
1509
|
-
wrapped_coins: ['
|
|
1508
|
+
underlying_coins: ['EURC', 'DAI', 'USDC', 'USDT'],
|
|
1509
|
+
wrapped_coins: ['EURC', '3Crv'],
|
|
1510
1510
|
underlying_coin_addresses: [
|
|
1511
1511
|
'0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c',
|
|
1512
1512
|
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
package/lib/curve.js
CHANGED
|
@@ -49,7 +49,7 @@ import circulatingSupplyABI from './constants/abis/circulating_supply.json' with
|
|
|
49
49
|
import rootGaugeFactoryABI from "./constants/abis/gauge_factory/root_gauge_factory.json" with { type: "json" };
|
|
50
50
|
import fastBridgeABI from './constants/abis/fastBridge.json' with { type: 'json' };
|
|
51
51
|
import { extractDecimals, extractGauges, formatUnits, lowerCasePoolDataAddresses, parseUnits, } from "./constants/utils.js";
|
|
52
|
-
import {
|
|
52
|
+
import { _getPoolFilters } from "./external-api.js";
|
|
53
53
|
import { L2Networks } from "./constants/L2Networks.js";
|
|
54
54
|
import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto.js";
|
|
55
55
|
import { applyFeeDataOverride, computeEip1559Fees, computeLegacyOrFallback, fetchFeeHistory, getNetworkConstants, } from "./utils.js";
|
|
@@ -661,14 +661,11 @@ export class Curve {
|
|
|
661
661
|
}
|
|
662
662
|
_filterHiddenPools(pools_1) {
|
|
663
663
|
return __awaiter(this, arguments, void 0, function* (pools, isFiltered = false) {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
filteredAddresses = new Set(poolFilters[this.constants.NETWORK_NAME]);
|
|
670
|
-
}
|
|
671
|
-
return Object.fromEntries(Object.entries(pools).filter(([id, pool]) => !(hiddenPools === null || hiddenPools === void 0 ? void 0 : hiddenPools.includes(id)) && !(filteredAddresses === null || filteredAddresses === void 0 ? void 0 : filteredAddresses.has(pool.swap_address))));
|
|
664
|
+
if (!isFiltered)
|
|
665
|
+
return pools;
|
|
666
|
+
const poolFilters = yield _getPoolFilters();
|
|
667
|
+
const filteredAddresses = new Set(poolFilters[this.constants.NETWORK_NAME]);
|
|
668
|
+
return Object.fromEntries(Object.entries(pools).filter(([, pool]) => !filteredAddresses.has(pool.swap_address)));
|
|
672
669
|
});
|
|
673
670
|
}
|
|
674
671
|
_updateDecimalsAndGauges(pools) {
|
package/lib/dao.js
CHANGED
|
@@ -8,7 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Contract } from "ethers";
|
|
11
|
-
import {
|
|
11
|
+
import { _getDaoProposal, _getDaoProposalList } from './external-api.js';
|
|
12
|
+
import { getGaugesOverview } from './prices-api.js';
|
|
12
13
|
import { _getAddress, BN, DIGas, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from './utils.js';
|
|
13
14
|
import feeDistributorViewABI from "./constants/abis/fee_distributor_view.json" with { type: "json" };
|
|
14
15
|
// ----------------- Refactored boosting stuff -----------------
|
|
@@ -230,26 +231,33 @@ export function claimFees() {
|
|
|
230
231
|
});
|
|
231
232
|
}
|
|
232
233
|
// ----------------- Gauge weights -----------------
|
|
234
|
+
const toRelativeWeightPct = (gaugeRelativeWeight) => (gaugeRelativeWeight * 100).toString();
|
|
235
|
+
const assertHasNoRootGaugeGap = (gauge) => {
|
|
236
|
+
var _a;
|
|
237
|
+
if (((_a = gauge.pool) === null || _a === void 0 ? void 0 : _a.chain) && gauge.pool.chain !== 'ethereum') {
|
|
238
|
+
throw Error(`Cannot resolve mainnet root gauge for L2 gauge ${gauge.address} (chain: ${gauge.pool.chain}) - prices.curve.finance API doesn't provide a root-gauge field yet`);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
233
241
|
export function getVotingGaugeList() {
|
|
234
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
var _a, _b;
|
|
243
|
+
var _a, _b, _c, _d, _e, _f;
|
|
236
244
|
if (this.chainId !== 1)
|
|
237
245
|
throw Error("Ethereum-only method");
|
|
238
|
-
const gaugeData =
|
|
246
|
+
const gaugeData = yield getGaugesOverview();
|
|
239
247
|
const res = [];
|
|
240
|
-
for (
|
|
241
|
-
if (
|
|
248
|
+
for (const gauge of gaugeData) {
|
|
249
|
+
if (gauge.is_killed && gauge.gauge_relative_weight === 0)
|
|
242
250
|
continue;
|
|
243
251
|
res.push({
|
|
244
|
-
poolUrl:
|
|
245
|
-
network:
|
|
246
|
-
gaugeAddress:
|
|
247
|
-
poolAddress:
|
|
248
|
-
lpTokenAddress:
|
|
249
|
-
poolName:
|
|
250
|
-
totalVeCrv: this.formatUnits(
|
|
251
|
-
relativeWeight:
|
|
252
|
-
isKilled:
|
|
252
|
+
poolUrl: '',
|
|
253
|
+
network: (_b = (_a = gauge.pool) === null || _a === void 0 ? void 0 : _a.chain) !== null && _b !== void 0 ? _b : '',
|
|
254
|
+
gaugeAddress: gauge.address,
|
|
255
|
+
poolAddress: (_d = (_c = gauge.pool) === null || _c === void 0 ? void 0 : _c.address) !== null && _d !== void 0 ? _d : '',
|
|
256
|
+
lpTokenAddress: gauge.lp_token,
|
|
257
|
+
poolName: (_f = (_e = gauge.pool) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : gauge.name,
|
|
258
|
+
totalVeCrv: this.formatUnits(gauge.gauge_weight, 18),
|
|
259
|
+
relativeWeight: toRelativeWeightPct(gauge.gauge_relative_weight),
|
|
260
|
+
isKilled: gauge.is_killed,
|
|
253
261
|
});
|
|
254
262
|
}
|
|
255
263
|
return res;
|
|
@@ -257,17 +265,17 @@ export function getVotingGaugeList() {
|
|
|
257
265
|
}
|
|
258
266
|
export function userGaugeVotes() {
|
|
259
267
|
return __awaiter(this, arguments, void 0, function* (address = "") {
|
|
260
|
-
var _a, _b;
|
|
268
|
+
var _a, _b, _c, _d, _e, _f;
|
|
261
269
|
if (this.chainId !== 1)
|
|
262
270
|
throw Error("Ethereum-only method");
|
|
263
271
|
address = _getAddress.call(this, address);
|
|
264
272
|
const gcMulticallContract = this.contracts[this.constants.ALIASES.gauge_controller].multicallContract;
|
|
265
273
|
const veMulticallContract = this.contracts[this.constants.ALIASES.voting_escrow].multicallContract;
|
|
266
|
-
const gaugeData =
|
|
274
|
+
const gaugeData = yield getGaugesOverview();
|
|
267
275
|
const calls = [veMulticallContract.balanceOf(address)];
|
|
268
|
-
for (const
|
|
269
|
-
|
|
270
|
-
calls.push(gcMulticallContract.vote_user_slopes(address,
|
|
276
|
+
for (const gauge of gaugeData) {
|
|
277
|
+
assertHasNoRootGaugeGap(gauge);
|
|
278
|
+
calls.push(gcMulticallContract.vote_user_slopes(address, gauge.address));
|
|
271
279
|
}
|
|
272
280
|
const [veCrvBalance, ...votes] = yield this.multicallProvider.all(calls);
|
|
273
281
|
const res = { gauges: [], powerUsed: "0.0", veCrvUsed: "0.0" };
|
|
@@ -279,21 +287,22 @@ export function userGaugeVotes() {
|
|
|
279
287
|
let dt = votes[i][2] - BigInt(Math.floor(Date.now() / 1000));
|
|
280
288
|
if (dt < BigInt(0))
|
|
281
289
|
dt = BigInt(0);
|
|
290
|
+
const gauge = gaugeData[i];
|
|
282
291
|
res.gauges.push({
|
|
283
292
|
userPower: this.formatUnits(votes[i][1], 2),
|
|
284
293
|
userVeCrv: this.formatUnits(votes[i][0] * dt, 18),
|
|
285
294
|
userFutureVeCrv: this.formatUnits(veCrvBalance * votes[i][1] / BigInt(10000), 18),
|
|
286
295
|
expired: dt === BigInt(0),
|
|
287
296
|
gaugeData: {
|
|
288
|
-
poolUrl:
|
|
289
|
-
network:
|
|
290
|
-
gaugeAddress:
|
|
291
|
-
poolAddress:
|
|
292
|
-
lpTokenAddress:
|
|
293
|
-
poolName:
|
|
294
|
-
totalVeCrv: this.formatUnits(
|
|
295
|
-
relativeWeight:
|
|
296
|
-
isKilled:
|
|
297
|
+
poolUrl: '',
|
|
298
|
+
network: (_b = (_a = gauge.pool) === null || _a === void 0 ? void 0 : _a.chain) !== null && _b !== void 0 ? _b : '',
|
|
299
|
+
gaugeAddress: gauge.address,
|
|
300
|
+
poolAddress: (_d = (_c = gauge.pool) === null || _c === void 0 ? void 0 : _c.address) !== null && _d !== void 0 ? _d : '',
|
|
301
|
+
lpTokenAddress: gauge.lp_token,
|
|
302
|
+
poolName: (_f = (_e = gauge.pool) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : gauge.name,
|
|
303
|
+
totalVeCrv: this.formatUnits(gauge.gauge_weight, 18),
|
|
304
|
+
relativeWeight: toRelativeWeightPct(gauge.gauge_relative_weight),
|
|
305
|
+
isKilled: gauge.is_killed,
|
|
297
306
|
},
|
|
298
307
|
});
|
|
299
308
|
powerUsed += votes[i][1];
|
package/lib/external-api.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import memoize from "memoizee";
|
|
2
|
-
import { ICurveLiteNetwork, IDaoProposal, IDaoProposalListItem, IDict, IExtendedPoolDataFromApi,
|
|
2
|
+
import { ICurveLiteNetwork, IDaoProposal, IDaoProposalListItem, IDict, IExtendedPoolDataFromApi, INetworkName, IPoolType, IVolumeAndAPYs } from "./interfaces";
|
|
3
3
|
export declare const uncached_getAllPoolsFromApi: (network: INetworkName, isLiteChain: boolean) => Promise<Record<IPoolType, IExtendedPoolDataFromApi>>;
|
|
4
4
|
export declare const createUsdPricesDict: (allTypesExtendedPoolData: IExtendedPoolDataFromApi[]) => IDict<number>;
|
|
5
5
|
export declare const createCrvApyDict: (allTypesExtendedPoolData: IExtendedPoolDataFromApi[]) => IDict<[number, number]>;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const _getVolumes: ((network: string) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: string) => Promise<IVolumeAndAPYs>>;
|
|
8
|
-
export declare const _getFactoryAPYs: ((network: string) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: string) => Promise<IVolumeAndAPYs>>;
|
|
9
|
-
export declare const _getAllGauges: (() => Promise<IDict<IGaugesDataFromApi>>) & memoize.Memoized<() => Promise<IDict<IGaugesDataFromApi>>>;
|
|
10
|
-
export declare const _getAllGaugesFormatted: (() => Promise<IDict<any>>) & memoize.Memoized<() => Promise<IDict<any>>>;
|
|
11
|
-
export declare const _getHiddenPools: ((isLiteChain: boolean) => Promise<IDict<string[]>>) & memoize.Memoized<(isLiteChain: boolean) => Promise<IDict<string[]>>>;
|
|
6
|
+
export declare const _getVolumes: ((network: INetworkName) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: INetworkName) => Promise<IVolumeAndAPYs>>;
|
|
12
7
|
export declare const _getPoolFilters: (() => Promise<IDict<string[]>>) & memoize.Memoized<() => Promise<IDict<string[]>>>;
|
|
13
8
|
export declare const _generateBoostingProof: ((block: number, address: string) => Promise<{
|
|
14
9
|
block_header_rlp: string;
|
|
@@ -19,5 +14,5 @@ export declare const _generateBoostingProof: ((block: number, address: string) =
|
|
|
19
14
|
}>>;
|
|
20
15
|
export declare const _getDaoProposalList: (() => Promise<IDaoProposalListItem[]>) & memoize.Memoized<() => Promise<IDaoProposalListItem[]>>;
|
|
21
16
|
export declare const _getDaoProposal: ((type: "PARAMETER" | "OWNERSHIP", id: number) => Promise<IDaoProposal>) & memoize.Memoized<(type: "PARAMETER" | "OWNERSHIP", id: number) => Promise<IDaoProposal>>;
|
|
22
|
-
export declare const _getLiteNetworksData: ((
|
|
17
|
+
export declare const _getLiteNetworksData: ((chainId: number) => Promise<any>) & memoize.Memoized<(chainId: number) => Promise<any>>;
|
|
23
18
|
export declare const _getCurveLiteNetworks: (() => Promise<ICurveLiteNetwork[]>) & memoize.Memoized<() => Promise<ICurveLiteNetwork[]>>;
|
package/lib/external-api.js
CHANGED
|
@@ -8,11 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import memoize from "memoizee";
|
|
11
|
+
import { getPoolsFromPricesApi, getVolumesFromPricesApi } from "./prices-api.js";
|
|
12
|
+
import { getLiteDeploymentFromApi2, getLiteNetworksFromApi2, getLitePoolsFromApi2, } from "./lite-api.js";
|
|
13
|
+
// Core chains that ARE fully configured in the library (static POOLS_DATA / ALIASES /
|
|
14
|
+
// implementationABIDict) but whose live pool data is NOT indexed by prices.curve.finance.
|
|
15
|
+
// Their factory pools live in api2 instead, so we fetch from there while keeping them core
|
|
16
|
+
// (static main/crypto pools + impl-ABI dict all keep working).
|
|
17
|
+
const API2_BACKED_CORE_CHAINS = ["avalanche"];
|
|
11
18
|
const uncached_getPoolsFromApi = (network, poolType, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return (_a = yield fetchData(url)) !== null && _a !== void 0 ? _a : { poolData: [], tvl: 0, tvlAll: 0 };
|
|
19
|
+
if (isLiteChain || API2_BACKED_CORE_CHAINS.includes(network))
|
|
20
|
+
return yield getLitePoolsFromApi2(network, poolType);
|
|
21
|
+
return yield getPoolsFromPricesApi(network, poolType);
|
|
16
22
|
});
|
|
17
23
|
const getPoolTypes = (isLiteChain) => isLiteChain ? ["factory-twocrypto", "factory-tricrypto", "factory-stable-ng"] :
|
|
18
24
|
["main", "crypto", "factory", "factory-crvusd", "factory-crypto", "factory-twocrypto", "factory-tricrypto", "factory-stable-ng"];
|
|
@@ -107,86 +113,7 @@ export const createCrvApyDict = (allTypesExtendedPoolData) => {
|
|
|
107
113
|
}
|
|
108
114
|
return apyDict;
|
|
109
115
|
};
|
|
110
|
-
export const
|
|
111
|
-
var _a, _b, _c;
|
|
112
|
-
const data = yield fetchData(`https://api.curve.finance/api/getSubgraphData/${network}`);
|
|
113
|
-
const poolsData = data.poolList.map((data) => ({
|
|
114
|
-
address: data.address,
|
|
115
|
-
volumeUSD: data.volumeUSD,
|
|
116
|
-
day: data.latestDailyApy,
|
|
117
|
-
week: data.latestWeeklyApy,
|
|
118
|
-
}));
|
|
119
|
-
return {
|
|
120
|
-
poolsData: poolsData,
|
|
121
|
-
totalVolume: (_a = data.totalVolume) !== null && _a !== void 0 ? _a : 0,
|
|
122
|
-
cryptoVolume: (_b = data.cryptoVolume) !== null && _b !== void 0 ? _b : 0,
|
|
123
|
-
cryptoShare: (_c = data.cryptoShare) !== null && _c !== void 0 ? _c : 0,
|
|
124
|
-
};
|
|
125
|
-
}), {
|
|
126
|
-
promise: true,
|
|
127
|
-
maxAge: 5 * 60 * 1000, // 5m
|
|
128
|
-
});
|
|
129
|
-
export const _getVolumes = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
-
var _a, _b, _c;
|
|
131
|
-
const { pools, totalVolumes } = yield fetchData(`https://api.curve.finance/api/getVolumes/${network}`);
|
|
132
|
-
const poolsData = pools.map((data) => ({
|
|
133
|
-
address: data.address,
|
|
134
|
-
volumeUSD: data.volumeUSD,
|
|
135
|
-
day: data.latestDailyApyPcent,
|
|
136
|
-
week: data.latestWeeklyApyPcent,
|
|
137
|
-
}));
|
|
138
|
-
return {
|
|
139
|
-
poolsData: poolsData !== null && poolsData !== void 0 ? poolsData : [],
|
|
140
|
-
totalVolume: (_a = totalVolumes.totalVolume) !== null && _a !== void 0 ? _a : 0,
|
|
141
|
-
cryptoVolume: (_b = totalVolumes.totalCryptoVolume) !== null && _b !== void 0 ? _b : 0,
|
|
142
|
-
cryptoShare: (_c = totalVolumes.cryptoVolumeSharePcent) !== null && _c !== void 0 ? _c : 0,
|
|
143
|
-
};
|
|
144
|
-
}), {
|
|
145
|
-
promise: true,
|
|
146
|
-
maxAge: 5 * 60 * 1000, // 5m
|
|
147
|
-
});
|
|
148
|
-
export const _getFactoryAPYs = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
-
const [stableData, cryptoData] = yield Promise.all(['stable', 'crypto'].map((type) => fetchData(`https://api.curve.finance/api/getFactoryAPYs/${network}/${type}`)));
|
|
150
|
-
const stableVolume = stableData.totalVolumeUsd || stableData.totalVolume || 0;
|
|
151
|
-
const cryptoVolume = cryptoData.totalVolumeUsd || cryptoData.totalVolume || 0;
|
|
152
|
-
return {
|
|
153
|
-
poolsData: [...stableData.poolDetails, ...cryptoData.poolDetails].map((item) => {
|
|
154
|
-
var _a, _b, _c;
|
|
155
|
-
return ({
|
|
156
|
-
address: item.poolAddress,
|
|
157
|
-
volumeUSD: (_a = item.totalVolumeUsd) !== null && _a !== void 0 ? _a : 0,
|
|
158
|
-
day: (_b = item.apy) !== null && _b !== void 0 ? _b : 0,
|
|
159
|
-
week: ((_c = item.apy) !== null && _c !== void 0 ? _c : 0) * 7, // Because api does not return week apy
|
|
160
|
-
});
|
|
161
|
-
}),
|
|
162
|
-
totalVolume: stableVolume + cryptoVolume,
|
|
163
|
-
cryptoVolume,
|
|
164
|
-
cryptoShare: 100 * cryptoVolume / (stableVolume + cryptoVolume),
|
|
165
|
-
};
|
|
166
|
-
}), {
|
|
167
|
-
promise: true,
|
|
168
|
-
maxAge: 5 * 60 * 1000, // 5m
|
|
169
|
-
});
|
|
170
|
-
export const _getAllGauges = memoize(() => fetchData(`https://api.curve.finance/api/getAllGauges`), {
|
|
171
|
-
promise: true,
|
|
172
|
-
maxAge: 5 * 60 * 1000, // 5m
|
|
173
|
-
});
|
|
174
|
-
export const _getAllGaugesFormatted = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
175
|
-
const data = yield fetchData(`https://api.curve.finance/api/getAllGauges`);
|
|
176
|
-
const gaugesDict = {};
|
|
177
|
-
Object.values(data).forEach((d) => {
|
|
178
|
-
var _a, _b;
|
|
179
|
-
gaugesDict[d.gauge.toLowerCase()] = {
|
|
180
|
-
is_killed: (_a = d.is_killed) !== null && _a !== void 0 ? _a : false,
|
|
181
|
-
gaugeStatus: (_b = d.gaugeStatus) !== null && _b !== void 0 ? _b : null,
|
|
182
|
-
};
|
|
183
|
-
});
|
|
184
|
-
return gaugesDict;
|
|
185
|
-
}), {
|
|
186
|
-
promise: true,
|
|
187
|
-
maxAge: 60 * 60 * 1000, // 60m
|
|
188
|
-
});
|
|
189
|
-
export const _getHiddenPools = memoize((isLiteChain) => fetchData(`https://${isLiteChain ? 'api-core' : 'api'}.curve.finance/v1/getHiddenPools`), {
|
|
116
|
+
export const _getVolumes = memoize((network) => getVolumesFromPricesApi(network), {
|
|
190
117
|
promise: true,
|
|
191
118
|
maxAge: 5 * 60 * 1000, // 5m
|
|
192
119
|
});
|
|
@@ -225,22 +152,18 @@ export const _getDaoProposal = memoize((type, id) => fetchJson(`https://api-py.l
|
|
|
225
152
|
maxAge: 5 * 60 * 1000, // 5m
|
|
226
153
|
});
|
|
227
154
|
// --- CURVE LITE ---
|
|
228
|
-
export const _getLiteNetworksData = memoize((
|
|
229
|
-
var _a, _b, _c
|
|
155
|
+
export const _getLiteNetworksData = memoize((chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
var _a, _b, _c;
|
|
230
157
|
try {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
const { data } = (_a = yield response.json()) !== null && _a !== void 0 ? _a : {};
|
|
234
|
-
if (response.status !== 200 || !data) {
|
|
235
|
-
console.error('Failed to fetch network data:', response.status, data);
|
|
158
|
+
const data = yield getLiteDeploymentFromApi2(chainId);
|
|
159
|
+
if (!data)
|
|
236
160
|
return null;
|
|
237
|
-
}
|
|
238
161
|
const { config, contracts } = data;
|
|
239
162
|
const network_name = config.network_name || 'Unknown Network';
|
|
240
163
|
const native_currency_symbol = config.native_currency_symbol || 'N/A';
|
|
241
|
-
const wrapped_native_token = ((
|
|
242
|
-
const native_token = ((
|
|
243
|
-
const wrapper = ((
|
|
164
|
+
const wrapped_native_token = ((_a = config.wrapped_native_token) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
165
|
+
const native_token = ((_b = config.native_token) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
|
|
166
|
+
const wrapper = ((_c = config.wrapper) === null || _c === void 0 ? void 0 : _c.toLowerCase()) || wrapped_native_token;
|
|
244
167
|
return {
|
|
245
168
|
NAME: network_name,
|
|
246
169
|
ALIASES: {
|
|
@@ -278,29 +201,13 @@ export const _getLiteNetworksData = memoize((networkName) => __awaiter(void 0, v
|
|
|
278
201
|
maxAge: 5 * 60 * 1000, // 5 minutes
|
|
279
202
|
});
|
|
280
203
|
export const _getCurveLiteNetworks = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
console.error('Failed to fetch Curve platforms:',
|
|
204
|
+
try {
|
|
205
|
+
return yield getLiteNetworksFromApi2();
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
console.error('Failed to fetch Curve platforms:', error);
|
|
286
209
|
return [];
|
|
287
210
|
}
|
|
288
|
-
const { platforms, platformsMetadata } = data;
|
|
289
|
-
return Object.keys(platforms)
|
|
290
|
-
.map((id) => {
|
|
291
|
-
var _a;
|
|
292
|
-
const { name, rpcUrl, nativeCurrencySymbol, explorerBaseUrl, isMainnet, chainId } = (_a = platformsMetadata[id]) !== null && _a !== void 0 ? _a : {};
|
|
293
|
-
return name && {
|
|
294
|
-
id,
|
|
295
|
-
name,
|
|
296
|
-
rpcUrl,
|
|
297
|
-
chainId,
|
|
298
|
-
explorerUrl: explorerBaseUrl,
|
|
299
|
-
nativeCurrencySymbol,
|
|
300
|
-
isTestnet: !isMainnet,
|
|
301
|
-
};
|
|
302
|
-
})
|
|
303
|
-
.filter(Boolean);
|
|
304
211
|
}), {
|
|
305
212
|
promise: true,
|
|
306
213
|
maxAge: 5 * 60 * 1000, // 5 minutes
|
|
@@ -312,9 +219,3 @@ function fetchJson(url) {
|
|
|
312
219
|
return (_a = yield response.json()) !== null && _a !== void 0 ? _a : {};
|
|
313
220
|
});
|
|
314
221
|
}
|
|
315
|
-
function fetchData(url) {
|
|
316
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
317
|
-
const { data } = yield fetchJson(url);
|
|
318
|
-
return data;
|
|
319
|
-
});
|
|
320
|
-
}
|
|
@@ -17,7 +17,7 @@ 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" };
|
|
@@ -102,7 +102,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
102
102
|
const implementationABIDict = (_a = this.constants.STABLE_FACTORY_CONSTANTS.implementationABIDict) !== null && _a !== void 0 ? _a : {};
|
|
103
103
|
let rawPoolList = rawPoolListInput;
|
|
104
104
|
if (!isCrypto)
|
|
105
|
-
rawPoolList = rawPoolList.filter((p) => is_ng || p.implementationAddress in implementationABIDict);
|
|
105
|
+
rawPoolList = rawPoolList.filter((p) => is_ng || (!!p.implementationAddress && p.implementationAddress in implementationABIDict));
|
|
106
106
|
// Filter duplications
|
|
107
107
|
const mainAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address);
|
|
108
108
|
rawPoolList = rawPoolList.filter((p) => !mainAddresses.includes(p.address));
|
|
@@ -197,6 +197,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
197
197
|
deposit_abi: basePoolZap.ABI,
|
|
198
198
|
in_api: true,
|
|
199
199
|
is_ng,
|
|
200
|
+
factory_type: factoryType,
|
|
200
201
|
};
|
|
201
202
|
}
|
|
202
203
|
else {
|
|
@@ -221,6 +222,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
221
222
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
222
223
|
in_api: true,
|
|
223
224
|
is_ng,
|
|
225
|
+
factory_type: factoryType,
|
|
224
226
|
};
|
|
225
227
|
}
|
|
226
228
|
}
|
|
@@ -236,7 +238,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
236
238
|
const basePoolIdZapDict = (_g = this.constants.STABLE_FACTORY_CONSTANTS.basePoolIdZapDict) !== null && _g !== void 0 ? _g : {};
|
|
237
239
|
let deposit_address = (_h = this.constants.STABLE_FACTORY_CONSTANTS.stableNgBasePoolZap) !== null && _h !== void 0 ? _h : this.constants.ZERO_ADDRESS;
|
|
238
240
|
let deposit_abi = StableNgBasePoolZapABI;
|
|
239
|
-
if (
|
|
241
|
+
if (allPoolsData[basePoolId].is_ng) {
|
|
240
242
|
this.setContract(deposit_address, StableNgBasePoolZapABI);
|
|
241
243
|
}
|
|
242
244
|
else {
|
|
@@ -267,6 +269,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
267
269
|
deposit_abi,
|
|
268
270
|
in_api: true,
|
|
269
271
|
is_ng,
|
|
272
|
+
factory_type: factoryType,
|
|
270
273
|
};
|
|
271
274
|
}
|
|
272
275
|
else {
|
|
@@ -291,6 +294,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
|
|
|
291
294
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
292
295
|
in_api: true,
|
|
293
296
|
is_ng,
|
|
297
|
+
factory_type: factoryType,
|
|
294
298
|
};
|
|
295
299
|
}
|
|
296
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)];
|
|
@@ -130,6 +130,7 @@ function getCoinsData(tokenAddresses, coinAddresses, existingCoinAddrNameDict, e
|
|
|
130
130
|
}
|
|
131
131
|
else if (addr === "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2") {
|
|
132
132
|
coinAddrNamesDict[addr] = "MKR";
|
|
133
|
+
coinAddrDecimalsDict[addr] = 18;
|
|
133
134
|
}
|
|
134
135
|
else {
|
|
135
136
|
newCoinAddresses.push(addr);
|
|
@@ -214,6 +215,7 @@ export function getTricryptoFactoryPoolData() {
|
|
|
214
215
|
swap_abi: isETHEnabled ? tricryptoFactorySwapABI : tricryptoFactoryEthDisabledSwapABI,
|
|
215
216
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
216
217
|
is_ng: true,
|
|
218
|
+
factory_type: "factory-tricrypto",
|
|
217
219
|
};
|
|
218
220
|
}
|
|
219
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)];
|
|
@@ -136,6 +136,7 @@ function getCoinsData(tokenAddresses, coinAddresses, existingCoinAddrNameDict, e
|
|
|
136
136
|
}
|
|
137
137
|
else if (addr === "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2") {
|
|
138
138
|
coinAddrNamesDict[addr] = "MKR";
|
|
139
|
+
coinAddrDecimalsDict[addr] = 18;
|
|
139
140
|
}
|
|
140
141
|
else {
|
|
141
142
|
newCoinAddresses.push(addr);
|
|
@@ -206,6 +207,7 @@ export function getTwocryptoFactoryPoolData() {
|
|
|
206
207
|
swap_abi: twocryptoFactorySwapABI,
|
|
207
208
|
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
208
209
|
is_ng: true,
|
|
210
|
+
factory_type: "factory-twocrypto",
|
|
209
211
|
};
|
|
210
212
|
}
|
|
211
213
|
return TWOCRYPTO_FACTORY_POOLS_DATA;
|