@curvefi/api 2.69.2 → 2.69.4
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/curve.d.ts +8 -7
- package/lib/curve.js +25 -17
- package/lib/external-api.d.ts +1 -0
- package/lib/external-api.js +13 -0
- package/lib/index.d.ts +14 -12
- package/lib/index.js +2 -1
- package/lib/route-graph.worker.d.ts +2 -1
- package/lib/route-graph.worker.js +6 -1
- package/lib/router.d.ts +1 -0
- package/lib/router.js +7 -1
- package/package.json +1 -1
package/lib/curve.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare class Curve implements ICurve {
|
|
|
38
38
|
constants: INetworkConstants;
|
|
39
39
|
nativeTokenAddress: string;
|
|
40
40
|
poolAddressMapCache: IDict<string> | null;
|
|
41
|
+
routerBlacklist: string[];
|
|
41
42
|
constructor();
|
|
42
43
|
init(providerType: 'JsonRpc' | 'Web3' | 'Infura' | 'Alchemy' | 'NoRPC', providerSettings: {
|
|
43
44
|
url?: string;
|
|
@@ -59,14 +60,14 @@ export declare class Curve implements ICurve {
|
|
|
59
60
|
initContract: (address: string, abi: any, provider: BrowserProvider | JsonRpcProvider | Signer) => Contract;
|
|
60
61
|
initMulticallContract: (address: string, abi: any) => MulticallContract;
|
|
61
62
|
setContract(address: string | undefined, abi: any): void;
|
|
62
|
-
_filterHiddenPools(pools: IDict<IPoolData
|
|
63
|
+
_filterHiddenPools(pools: IDict<IPoolData>, isFiltered?: boolean): Promise<IDict<IPoolData>>;
|
|
63
64
|
_updateDecimalsAndGauges(pools: IDict<IPoolData>): void;
|
|
64
|
-
fetchFactoryPools: (useApi?: boolean) => Promise<void>;
|
|
65
|
-
fetchCrvusdFactoryPools: (useApi?: boolean) => Promise<void>;
|
|
66
|
-
fetchCryptoFactoryPools: (useApi?: boolean) => Promise<void>;
|
|
67
|
-
fetchStableNgFactoryPools: (useApi?: boolean) => Promise<void>;
|
|
68
|
-
fetchTworyptoFactoryPools: (useApi?: boolean) => Promise<void>;
|
|
69
|
-
fetchTricryptoFactoryPools: (useApi?: boolean) => Promise<void>;
|
|
65
|
+
fetchFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
66
|
+
fetchCrvusdFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
67
|
+
fetchCryptoFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
68
|
+
fetchStableNgFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
69
|
+
fetchTworyptoFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
70
|
+
fetchTricryptoFactoryPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
70
71
|
fetchNewFactoryPools: () => Promise<string[]>;
|
|
71
72
|
fetchNewCryptoFactoryPools: () => Promise<string[]>;
|
|
72
73
|
fetchNewStableNgFactoryPools: () => Promise<string[]>;
|
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 { _getHiddenPools } from "./external-api.js";
|
|
52
|
+
import { _getHiddenPools, _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";
|
|
@@ -85,7 +85,7 @@ export class Curve {
|
|
|
85
85
|
constructor() {
|
|
86
86
|
this.initContract = memoizedContract();
|
|
87
87
|
this.initMulticallContract = memoizedMulticallContract();
|
|
88
|
-
this.fetchFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
88
|
+
this.fetchFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
|
|
89
89
|
if (!("factory" in this.constants.ALIASES))
|
|
90
90
|
return;
|
|
91
91
|
if (useApi) {
|
|
@@ -94,11 +94,11 @@ export class Curve {
|
|
|
94
94
|
else {
|
|
95
95
|
this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getFactoryPoolData.call(this));
|
|
96
96
|
}
|
|
97
|
-
this.constants.FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA);
|
|
97
|
+
this.constants.FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA, isFiltered);
|
|
98
98
|
this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
|
|
99
99
|
this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory"] = this.isNoRPC ? null : yield this.contracts[this.constants.ALIASES.factory].contract.gauge_implementation(this.constantOptions);
|
|
100
100
|
});
|
|
101
|
-
this.fetchCrvusdFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
101
|
+
this.fetchCrvusdFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
|
|
102
102
|
if (!("crvusd_factory" in this.constants.ALIASES))
|
|
103
103
|
return;
|
|
104
104
|
if (useApi) {
|
|
@@ -110,10 +110,10 @@ export class Curve {
|
|
|
110
110
|
}
|
|
111
111
|
this.constants.CRVUSD_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.crvusd_factory));
|
|
112
112
|
}
|
|
113
|
-
this.constants.CRVUSD_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.CRVUSD_FACTORY_POOLS_DATA);
|
|
113
|
+
this.constants.CRVUSD_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.CRVUSD_FACTORY_POOLS_DATA, isFiltered);
|
|
114
114
|
this._updateDecimalsAndGauges(this.constants.CRVUSD_FACTORY_POOLS_DATA);
|
|
115
115
|
});
|
|
116
|
-
this.fetchCryptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
116
|
+
this.fetchCryptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
|
|
117
117
|
if (!("crypto_factory" in this.constants.ALIASES))
|
|
118
118
|
return;
|
|
119
119
|
if (useApi) {
|
|
@@ -125,11 +125,11 @@ export class Curve {
|
|
|
125
125
|
}
|
|
126
126
|
this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getCryptoFactoryPoolData.call(this));
|
|
127
127
|
}
|
|
128
|
-
this.constants.CRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
128
|
+
this.constants.CRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA, isFiltered);
|
|
129
129
|
this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
130
130
|
this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory-crypto"] = this.isNoRPC ? null : yield this.contracts[this.constants.ALIASES.crypto_factory].contract.gauge_implementation(this.constantOptions);
|
|
131
131
|
});
|
|
132
|
-
this.fetchStableNgFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
132
|
+
this.fetchStableNgFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
|
|
133
133
|
if (!("stable_ng_factory" in this.constants.ALIASES))
|
|
134
134
|
return;
|
|
135
135
|
if (useApi) {
|
|
@@ -141,10 +141,10 @@ export class Curve {
|
|
|
141
141
|
}
|
|
142
142
|
this.constants.STABLE_NG_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getFactoryPoolData.call(this, 0, undefined, this.constants.ALIASES.stable_ng_factory));
|
|
143
143
|
}
|
|
144
|
-
this.constants.STABLE_NG_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.STABLE_NG_FACTORY_POOLS_DATA);
|
|
144
|
+
this.constants.STABLE_NG_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.STABLE_NG_FACTORY_POOLS_DATA, isFiltered);
|
|
145
145
|
this._updateDecimalsAndGauges(this.constants.STABLE_NG_FACTORY_POOLS_DATA);
|
|
146
146
|
});
|
|
147
|
-
this.fetchTworyptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
147
|
+
this.fetchTworyptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
|
|
148
148
|
if (!("twocrypto_factory" in this.constants.ALIASES))
|
|
149
149
|
return;
|
|
150
150
|
if (useApi) {
|
|
@@ -156,7 +156,7 @@ export class Curve {
|
|
|
156
156
|
}
|
|
157
157
|
this.constants.TWOCRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getTwocryptoFactoryPoolData.call(this));
|
|
158
158
|
}
|
|
159
|
-
this.constants.TWOCRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.TWOCRYPTO_FACTORY_POOLS_DATA);
|
|
159
|
+
this.constants.TWOCRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.TWOCRYPTO_FACTORY_POOLS_DATA, isFiltered);
|
|
160
160
|
this._updateDecimalsAndGauges(this.constants.TWOCRYPTO_FACTORY_POOLS_DATA);
|
|
161
161
|
if (this.chainId === 1) {
|
|
162
162
|
this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory-twocrypto"] = this.isNoRPC ? null :
|
|
@@ -167,7 +167,7 @@ export class Curve {
|
|
|
167
167
|
yield this.contracts[this.constants.ALIASES.child_gauge_factory].contract.get_implementation(this.constantOptions);
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
|
-
this.fetchTricryptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
170
|
+
this.fetchTricryptoFactoryPools = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true, isFiltered = false) {
|
|
171
171
|
if (!("tricrypto_factory" in this.constants.ALIASES))
|
|
172
172
|
return;
|
|
173
173
|
if (useApi) {
|
|
@@ -179,7 +179,7 @@ export class Curve {
|
|
|
179
179
|
}
|
|
180
180
|
this.constants.TRICRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(yield getTricryptoFactoryPoolData.call(this));
|
|
181
181
|
}
|
|
182
|
-
this.constants.TRICRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
182
|
+
this.constants.TRICRYPTO_FACTORY_POOLS_DATA = yield this._filterHiddenPools(this.constants.TRICRYPTO_FACTORY_POOLS_DATA, isFiltered);
|
|
183
183
|
this._updateDecimalsAndGauges(this.constants.TRICRYPTO_FACTORY_POOLS_DATA);
|
|
184
184
|
if (this.chainId === 1) {
|
|
185
185
|
this.constants.FACTORY_GAUGE_IMPLEMENTATIONS["factory-tricrypto"] = this.isNoRPC ? null :
|
|
@@ -326,6 +326,7 @@ export class Curve {
|
|
|
326
326
|
this.options = {};
|
|
327
327
|
this.nativeTokenAddress = NETWORK_CONSTANTS[1].NATIVE_COIN.address;
|
|
328
328
|
this.poolAddressMapCache = null;
|
|
329
|
+
this.routerBlacklist = [];
|
|
329
330
|
this.constants = {
|
|
330
331
|
NATIVE_TOKEN: NETWORK_CONSTANTS[1].NATIVE_COIN,
|
|
331
332
|
NETWORK_NAME: 'ethereum',
|
|
@@ -364,6 +365,7 @@ export class Curve {
|
|
|
364
365
|
this.constantOptions = { gasLimit: 12000000 };
|
|
365
366
|
this.options = {};
|
|
366
367
|
this.nativeTokenAddress = NETWORK_CONSTANTS[1].NATIVE_COIN.address;
|
|
368
|
+
this.routerBlacklist = [];
|
|
367
369
|
this.constants = {
|
|
368
370
|
NATIVE_TOKEN: NETWORK_CONSTANTS[1].NATIVE_COIN,
|
|
369
371
|
NETWORK_NAME: 'ethereum',
|
|
@@ -662,10 +664,16 @@ export class Curve {
|
|
|
662
664
|
};
|
|
663
665
|
this.contracts[address] = new Proxy(coreContract, proxyHandler);
|
|
664
666
|
}
|
|
665
|
-
_filterHiddenPools(
|
|
666
|
-
return __awaiter(this,
|
|
667
|
-
const
|
|
668
|
-
|
|
667
|
+
_filterHiddenPools(pools_1) {
|
|
668
|
+
return __awaiter(this, arguments, void 0, function* (pools, isFiltered = false) {
|
|
669
|
+
const hiddenPoolsAll = yield _getHiddenPools(this.isLiteChain);
|
|
670
|
+
const hiddenPools = hiddenPoolsAll[this.constants.NETWORK_NAME];
|
|
671
|
+
let filteredAddresses;
|
|
672
|
+
if (isFiltered) {
|
|
673
|
+
const poolFilters = yield _getPoolFilters();
|
|
674
|
+
filteredAddresses = new Set(poolFilters[this.constants.NETWORK_NAME]);
|
|
675
|
+
}
|
|
676
|
+
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))));
|
|
669
677
|
});
|
|
670
678
|
}
|
|
671
679
|
_updateDecimalsAndGauges(pools) {
|
package/lib/external-api.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const _getFactoryAPYs: ((network: string) => Promise<IVolumeAndAP
|
|
|
9
9
|
export declare const _getAllGauges: (() => Promise<IDict<IGaugesDataFromApi>>) & memoize.Memoized<() => Promise<IDict<IGaugesDataFromApi>>>;
|
|
10
10
|
export declare const _getAllGaugesFormatted: (() => Promise<IDict<any>>) & memoize.Memoized<() => Promise<IDict<any>>>;
|
|
11
11
|
export declare const _getHiddenPools: ((isLiteChain: boolean) => Promise<IDict<string[]>>) & memoize.Memoized<(isLiteChain: boolean) => Promise<IDict<string[]>>>;
|
|
12
|
+
export declare const _getPoolFilters: (() => Promise<IDict<string[]>>) & memoize.Memoized<() => Promise<IDict<string[]>>>;
|
|
12
13
|
export declare const _generateBoostingProof: ((block: number, address: string) => Promise<{
|
|
13
14
|
block_header_rlp: string;
|
|
14
15
|
proof_rlp: string;
|
package/lib/external-api.js
CHANGED
|
@@ -190,6 +190,19 @@ export const _getHiddenPools = memoize((isLiteChain) => fetchData(`https://${isL
|
|
|
190
190
|
promise: true,
|
|
191
191
|
maxAge: 5 * 60 * 1000, // 5m
|
|
192
192
|
});
|
|
193
|
+
export const _getPoolFilters = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
|
+
try {
|
|
195
|
+
const { data } = yield fetchJson("https://prices.curve.finance/v1/chains/pool_filters");
|
|
196
|
+
return Object.fromEntries((data !== null && data !== void 0 ? data : []).map(({ chain, pools }) => [chain, pools.map((pool) => pool.address.toLowerCase())]));
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
console.error('Error fetching pool filters:', error);
|
|
200
|
+
return {};
|
|
201
|
+
}
|
|
202
|
+
}), {
|
|
203
|
+
promise: true,
|
|
204
|
+
maxAge: 5 * 60 * 1000, // 5m
|
|
205
|
+
});
|
|
193
206
|
export const _generateBoostingProof = memoize((block, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
207
|
const url = `https://prices.curve.finance/v1/general/get_merkle_proof?block=${block}&account_address=${address}`;
|
|
195
208
|
const { block_header_rlp, proof_rlp } = yield fetchJson(url);
|
package/lib/index.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export declare const createCurve: () => {
|
|
|
72
72
|
getIsLiteChain: () => boolean;
|
|
73
73
|
isNoRPC: boolean;
|
|
74
74
|
factory: {
|
|
75
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
75
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
76
76
|
fetchNewPools: () => Promise<string[]>;
|
|
77
77
|
getPoolList: () => string[];
|
|
78
78
|
deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5, emaTime?: number | undefined, oracleAddress?: string | undefined, methodName?: string | undefined) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -98,11 +98,11 @@ export declare const createCurve: () => {
|
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
crvUSDFactory: {
|
|
101
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
101
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
102
102
|
getPoolList: () => string[];
|
|
103
103
|
};
|
|
104
104
|
stableNgFactory: {
|
|
105
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
105
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
106
106
|
fetchNewPools: () => Promise<string[]>;
|
|
107
107
|
getPoolList: () => string[];
|
|
108
108
|
deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, offpegFeeMultiplier: string | number, assetTypes: (0 | 1 | 2 | 3)[], implementationIdx: 0, emaTime: number, oracleAddresses: string[], methodNames: string[]) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -122,7 +122,7 @@ export declare const createCurve: () => {
|
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
cryptoFactory: {
|
|
125
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
125
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
126
126
|
fetchNewPools: () => Promise<string[]>;
|
|
127
127
|
getPoolList: () => string[];
|
|
128
128
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -143,7 +143,7 @@ export declare const createCurve: () => {
|
|
|
143
143
|
};
|
|
144
144
|
};
|
|
145
145
|
twocryptoFactory: {
|
|
146
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
146
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
147
147
|
fetchNewPools: () => Promise<string[]>;
|
|
148
148
|
getPoolList: () => string[];
|
|
149
149
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number, implementationIdx?: import("./constants/twoCryptoImplementations.js").TwoCryptoImplementation | undefined) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -165,7 +165,7 @@ export declare const createCurve: () => {
|
|
|
165
165
|
};
|
|
166
166
|
};
|
|
167
167
|
tricryptoFactory: {
|
|
168
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
168
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
169
169
|
fetchNewPools: () => Promise<string[]>;
|
|
170
170
|
getPoolList: () => string[];
|
|
171
171
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, emaTime: number, initialPrices: (string | number)[]) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -249,6 +249,7 @@ export declare const createCurve: () => {
|
|
|
249
249
|
_secondBasePools?: string[];
|
|
250
250
|
_secondBaseTokens?: string[];
|
|
251
251
|
};
|
|
252
|
+
setBlacklist: (blacklist: string[]) => void;
|
|
252
253
|
expected: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<string>;
|
|
253
254
|
required: (inputCoin: string, outputCoin: string, outAmount: string | number) => Promise<string>;
|
|
254
255
|
priceImpact: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<number>;
|
|
@@ -404,7 +405,7 @@ declare const _default: {
|
|
|
404
405
|
getIsLiteChain: () => boolean;
|
|
405
406
|
isNoRPC: boolean;
|
|
406
407
|
factory: {
|
|
407
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
408
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
408
409
|
fetchNewPools: () => Promise<string[]>;
|
|
409
410
|
getPoolList: () => string[];
|
|
410
411
|
deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5, emaTime?: number | undefined, oracleAddress?: string | undefined, methodName?: string | undefined) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -430,11 +431,11 @@ declare const _default: {
|
|
|
430
431
|
};
|
|
431
432
|
};
|
|
432
433
|
crvUSDFactory: {
|
|
433
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
434
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
434
435
|
getPoolList: () => string[];
|
|
435
436
|
};
|
|
436
437
|
stableNgFactory: {
|
|
437
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
438
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
438
439
|
fetchNewPools: () => Promise<string[]>;
|
|
439
440
|
getPoolList: () => string[];
|
|
440
441
|
deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, offpegFeeMultiplier: string | number, assetTypes: (0 | 1 | 2 | 3)[], implementationIdx: 0, emaTime: number, oracleAddresses: string[], methodNames: string[]) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -454,7 +455,7 @@ declare const _default: {
|
|
|
454
455
|
};
|
|
455
456
|
};
|
|
456
457
|
cryptoFactory: {
|
|
457
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
458
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
458
459
|
fetchNewPools: () => Promise<string[]>;
|
|
459
460
|
getPoolList: () => string[];
|
|
460
461
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -475,7 +476,7 @@ declare const _default: {
|
|
|
475
476
|
};
|
|
476
477
|
};
|
|
477
478
|
twocryptoFactory: {
|
|
478
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
479
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
479
480
|
fetchNewPools: () => Promise<string[]>;
|
|
480
481
|
getPoolList: () => string[];
|
|
481
482
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number, implementationIdx?: import("./constants/twoCryptoImplementations.js").TwoCryptoImplementation | undefined) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -497,7 +498,7 @@ declare const _default: {
|
|
|
497
498
|
};
|
|
498
499
|
};
|
|
499
500
|
tricryptoFactory: {
|
|
500
|
-
fetchPools: (useApi?: boolean) => Promise<void>;
|
|
501
|
+
fetchPools: (useApi?: boolean, isFiltered?: boolean) => Promise<void>;
|
|
501
502
|
fetchNewPools: () => Promise<string[]>;
|
|
502
503
|
getPoolList: () => string[];
|
|
503
504
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, emaTime: number, initialPrices: (string | number)[]) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -581,6 +582,7 @@ declare const _default: {
|
|
|
581
582
|
_secondBasePools?: string[];
|
|
582
583
|
_secondBaseTokens?: string[];
|
|
583
584
|
};
|
|
585
|
+
setBlacklist: (blacklist: string[]) => void;
|
|
584
586
|
expected: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<string>;
|
|
585
587
|
required: (inputCoin: string, outputCoin: string, outAmount: string | number) => Promise<string>;
|
|
586
588
|
priceImpact: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<number>;
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { PoolTemplate, getPool } from "./pools/index.js";
|
|
11
11
|
import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList, getUserLiquidityUSD, getUserClaimable, } from "./pools/utils.js";
|
|
12
|
-
import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapPopulateApprove, swapEstimateGas, swap, populateSwap, getSwappedAmount, approveFromCalldata, approveFromCalldataEstimateGas, swapFromCalldata, swapFromCalldataEstimateGas, } from "./router.js";
|
|
12
|
+
import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapPopulateApprove, swapEstimateGas, swap, populateSwap, getSwappedAmount, approveFromCalldata, approveFromCalldataEstimateGas, swapFromCalldata, swapFromCalldataEstimateGas, setRouterBlacklist, } from "./router.js";
|
|
13
13
|
import { isSupported, assertIsSupported, allowedToBridge, bridgeCost, bridgeIsApproved, bridgeApproveEstimateGas, bridgeApprove, bridgeEstimateGas, bridge, getSupportedNetworks, } from "./bridge.js";
|
|
14
14
|
import { Curve } from "./curve.js";
|
|
15
15
|
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, calculateVeCrv, } from "./boosting.js";
|
|
@@ -222,6 +222,7 @@ export const createCurve = () => {
|
|
|
222
222
|
router: {
|
|
223
223
|
getBestRouteAndOutput: getBestRouteAndOutput.bind(_curve),
|
|
224
224
|
getArgs: getArgs.bind(_curve),
|
|
225
|
+
setBlacklist: setRouterBlacklist.bind(_curve),
|
|
225
226
|
expected: swapExpected.bind(_curve),
|
|
226
227
|
required: swapRequired.bind(_curve),
|
|
227
228
|
priceImpact: swapPriceImpact.bind(_curve),
|
|
@@ -7,6 +7,7 @@ export type IRouteGraphInput = {
|
|
|
7
7
|
allPools: [string, IPoolData][];
|
|
8
8
|
amplificationCoefficientDict: IDict<number>;
|
|
9
9
|
poolTvlDict: IDict<number>;
|
|
10
|
+
blacklist?: string[];
|
|
10
11
|
};
|
|
11
|
-
export declare function routeGraphWorker(): (({ constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict }: IRouteGraphInput) => IDict<IDict<IRouteStep[]>>) | undefined;
|
|
12
|
+
export declare function routeGraphWorker(): (({ constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict, blacklist }: IRouteGraphInput) => IDict<IDict<IRouteStep[]>>) | undefined;
|
|
12
13
|
export declare const routeGraphWorkerCode: string;
|
|
@@ -4,9 +4,11 @@ export function routeGraphWorker() {
|
|
|
4
4
|
const EXCLUDED_POOLS_FROM_ROUTER = {
|
|
5
5
|
1: ['usdt'], // Ethereum mainnet
|
|
6
6
|
};
|
|
7
|
-
const createRouteGraph = ({ constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict }) => {
|
|
7
|
+
const createRouteGraph = ({ constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict, blacklist }) => {
|
|
8
8
|
var _a, _b, _c, _d;
|
|
9
9
|
const routerGraph = {};
|
|
10
|
+
// Pool addresses we don't want to index when building routes
|
|
11
|
+
const blacklistedPools = new Set((blacklist !== null && blacklist !== void 0 ? blacklist : []).map((a) => a.toLowerCase()));
|
|
10
12
|
// ETH <-> WETH (exclude Celo)
|
|
11
13
|
if (chainId !== 42220) {
|
|
12
14
|
const wrapperAddress = constants.NATIVE_TOKEN.wrapperAddress || constants.NATIVE_TOKEN.wrappedAddress;
|
|
@@ -263,6 +265,9 @@ export function routeGraphWorker() {
|
|
|
263
265
|
// Skip excluded pools from router
|
|
264
266
|
if ((_d = EXCLUDED_POOLS_FROM_ROUTER[chainId]) === null || _d === void 0 ? void 0 : _d.includes(poolId))
|
|
265
267
|
continue;
|
|
268
|
+
// Skip blacklisted pools
|
|
269
|
+
if (blacklistedPools.has(poolAddress))
|
|
270
|
+
continue;
|
|
266
271
|
const excludedUnderlyingSwaps = (poolId === 'ib' && chainId === 1) ||
|
|
267
272
|
(poolId === 'geist' && chainId === 250) ||
|
|
268
273
|
(poolId === 'saave' && chainId === 1);
|
package/lib/router.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ethers, TransactionLike } from "ethers";
|
|
2
2
|
import { type Curve } from "./curve.js";
|
|
3
3
|
import { IRoute } from "./interfaces";
|
|
4
|
+
export declare function setRouterBlacklist(this: Curve, blacklist: string[]): void;
|
|
4
5
|
export declare function getBestRouteAndOutput(this: Curve, inputCoin: string, outputCoin: string, amount: number | string): Promise<{
|
|
5
6
|
route: IRoute;
|
|
6
7
|
output: string;
|
package/lib/router.js
CHANGED
|
@@ -19,6 +19,12 @@ import { memoizeMethod } from "./constants/utils.js";
|
|
|
19
19
|
import { YB_ASSETS } from "./constants/ybPools.js";
|
|
20
20
|
const MAX_STEPS = 5;
|
|
21
21
|
const ROUTE_LENGTH = (MAX_STEPS * 2) + 1;
|
|
22
|
+
export function setRouterBlacklist(blacklist) {
|
|
23
|
+
this.routerBlacklist = (blacklist !== null && blacklist !== void 0 ? blacklist : []).map((a) => a.toLowerCase());
|
|
24
|
+
// Drop the memoized route graph / routes so they get rebuilt with the new blacklist
|
|
25
|
+
delete this._buildRouteGraph;
|
|
26
|
+
delete this._getBestRoute;
|
|
27
|
+
}
|
|
22
28
|
function _getTVL(poolId) {
|
|
23
29
|
return __awaiter(this, void 0, void 0, function* () { return Number(yield getPool.call(this, poolId).stats.totalLiquidityMemoized()); });
|
|
24
30
|
}
|
|
@@ -40,7 +46,7 @@ function _buildRouteGraphImpl(chainId, isLiteChain) {
|
|
|
40
46
|
const allPools = Object.entries(this.getPoolsData()).filter(([id]) => !["crveth", "y", "busd", "pax", "susd", "aave"].includes(id));
|
|
41
47
|
const amplificationCoefficientDict = yield _getAmplificationCoefficientsFromApi.call(this);
|
|
42
48
|
const poolTvlDict = yield entriesToDictAsync(allPools, _getTVL.bind(this));
|
|
43
|
-
const input = { constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict };
|
|
49
|
+
const input = { constants, chainId, isLiteChain, allPools, amplificationCoefficientDict, poolTvlDict, blacklist: this.routerBlacklist };
|
|
44
50
|
return runWorker(routeGraphWorkerCode, routeGraphWorker, Object.assign({ type: 'createRouteGraph' }, input));
|
|
45
51
|
});
|
|
46
52
|
}
|