@curvefi/api 2.69.3 → 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 +1 -0
- package/lib/curve.js +2 -0
- package/lib/index.d.ts +2 -0
- 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;
|
package/lib/curve.js
CHANGED
|
@@ -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',
|
package/lib/index.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -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
|
}
|