@curvefi/api 2.68.7 → 2.68.9

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.
@@ -0,0 +1,3 @@
1
+ export declare const YB_POOLS: string[];
2
+ export declare const YB_ASSETS: string[];
3
+ export declare const isYBPool: (poolAddress: string) => boolean;
@@ -0,0 +1,13 @@
1
+ export const YB_POOLS = [
2
+ "0xf1f435b05d255a5dbde37333c0f61da6f69c6127",
3
+ "0xd9ff8396554a0d18b2cfbec53e1979b7ecce8373",
4
+ "0x83f24023d15d835a213df24fd309c47dab5beb32",
5
+ ].map((pool) => pool.toLowerCase());
6
+ export const YB_ASSETS = [
7
+ "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", // WBTC
8
+ "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf", // cbBTC
9
+ "0x18084fbA666a33d37592fA2633fD49a74DD93a88", // tBTC
10
+ ].map((asset) => asset.toLowerCase());
11
+ export const isYBPool = (poolAddress) => {
12
+ return YB_POOLS.includes(poolAddress.toLowerCase());
13
+ };
@@ -12,6 +12,7 @@ import gaugeChildABI from "../constants/abis/gauge_child.json" with { type: "jso
12
12
  import ERC20ABI from "../constants/abis/ERC20.json" with { type: "json" };
13
13
  import cryptoFactorySwapABI from "../constants/abis/factory-crypto/factory-crypto-pool-2.json" with { type: "json" };
14
14
  import twocryptoFactorySwapABI from "../constants/abis/factory-twocrypto/factory-twocrypto-pool.json" with { type: "json" };
15
+ import ybTwocryptoPoolABI from "../constants/abis/factory-twocrypto/yb-twocrypto-pool.json" with { type: "json" };
15
16
  import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool.json" with { type: "json" };
16
17
  import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" with { type: "json" };
17
18
  import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
@@ -20,6 +21,7 @@ import { assetTypeNameHandler, getPoolName, isStableNgPool } from "../utils.js";
20
21
  import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" with { type: "json" };
21
22
  import MetaStableSwapNGABI from "../constants/abis/factory-stable-ng/meta-stableswap-ng.json" with { type: "json" };
22
23
  import PlainStableSwapNGABI from "../constants/abis/factory-stable-ng/plain-stableswap-ng.json" with { type: "json" };
24
+ import { isYBPool } from "../constants/ybPools.js";
23
25
  export const lowerCasePoolDataAddresses = (poolsData) => {
24
26
  var _a;
25
27
  for (const poolData of poolsData) {
@@ -43,6 +45,9 @@ export const lowerCasePoolDataAddresses = (poolsData) => {
43
45
  function getSwapAbiByFactoryType(factoryType, pool) {
44
46
  var _a;
45
47
  const isETHEnabled = pool.implementationAddress === ((_a = this.constants.CRYPTO_FACTORY_CONSTANTS.tricryptoDeployImplementations) === null || _a === void 0 ? void 0 : _a.amm_native_transfers_enabled);
48
+ if (factoryType === "factory-twocrypto" && isYBPool(pool.address)) {
49
+ return ybTwocryptoPoolABI;
50
+ }
46
51
  const map = {
47
52
  "factory-crypto": cryptoFactorySwapABI,
48
53
  "factory-twocrypto": twocryptoFactorySwapABI,
@@ -9,8 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import ERC20ABI from "../constants/abis/ERC20.json" with { type: "json" };
11
11
  import twocryptoFactorySwapABI from "../constants/abis/factory-twocrypto/factory-twocrypto-pool.json" with { type: "json" };
12
+ import ybTwocryptoPoolABI from "../constants/abis/factory-twocrypto/yb-twocrypto-pool.json" with { type: "json" };
12
13
  import factoryGaugeABI from "../constants/abis/gauge_factory.json" with { type: "json" };
13
14
  import gaugeChildABI from "../constants/abis/gauge_child.json" with { type: "json" };
15
+ import { isYBPool } from "../constants/ybPools.js";
14
16
  const deepFlatten = (arr) => [].concat(...arr.map((v) => (Array.isArray(v) ? deepFlatten(v) : v)));
15
17
  function getRecentlyCreatedCryptoPoolId(swapAddress) {
16
18
  return __awaiter(this, void 0, void 0, function* () {
@@ -84,7 +86,8 @@ function getPoolsData(factorySwapAddresses) {
84
86
  }
85
87
  function setTwocryptoFactorySwapContracts(factorySwapAddresses) {
86
88
  factorySwapAddresses.forEach((addr) => {
87
- this.setContract(addr, twocryptoFactorySwapABI);
89
+ const abi = isYBPool(addr) ? ybTwocryptoPoolABI : twocryptoFactorySwapABI;
90
+ this.setContract(addr, abi);
88
91
  });
89
92
  }
90
93
  function setTwocryptoFactoryGaugeContracts(factoryGaugeAddresses) {
@@ -4,6 +4,7 @@ export type IRouterWorkerInput = {
4
4
  outputCoinAddress: string;
5
5
  routerGraph: IDict<IDict<IRouteStep[]>>;
6
6
  poolData: IDict<IRoutePoolData>;
7
+ ybAssets: string[];
7
8
  };
8
- export declare function routeFinderWorker(): (({ inputCoinAddress, outputCoinAddress, routerGraph, poolData }: IRouterWorkerInput) => IRouteStep[][]) | undefined;
9
+ export declare function routeFinderWorker(): (({ inputCoinAddress, outputCoinAddress, routerGraph, poolData, ybAssets }: IRouterWorkerInput) => IRouteStep[][]) | undefined;
9
10
  export declare const routeFinderWorkerCode: string;
@@ -1,5 +1,4 @@
1
1
  export function routeFinderWorker() {
2
- const MAX_ROUTES_FOR_ONE_COIN = 5;
3
2
  const MAX_DEPTH = 4;
4
3
  const _removeDuplications = (routesA, routesB) => {
5
4
  const routeToStr = (r) => r.route.map((s) => s.poolId).toString();
@@ -47,9 +46,11 @@ export function routeFinderWorker() {
47
46
  }
48
47
  const _isVisitedCoin = (coinAddress, route) => route.route.find((r) => r.inputCoinAddress === coinAddress) !== undefined;
49
48
  const _findPool = (route, poolId) => route.route.find((r) => r.poolId === poolId);
50
- const findRoutes = ({ inputCoinAddress, outputCoinAddress, routerGraph, poolData }) => {
49
+ const findRoutes = ({ inputCoinAddress, outputCoinAddress, routerGraph, poolData, ybAssets }) => {
51
50
  inputCoinAddress = inputCoinAddress.toLowerCase();
52
51
  outputCoinAddress = outputCoinAddress.toLowerCase();
52
+ const isYBAsset = ybAssets.includes(inputCoinAddress) || ybAssets.includes(outputCoinAddress);
53
+ const MAX_ROUTES_FOR_ONE_COIN = isYBAsset ? 10 : 5;
53
54
  const routes = [{ route: [], minTvl: Infinity, totalTvl: 0 }];
54
55
  const targetRoutesByTvl = [];
55
56
  const targetRoutesByLength = [];
package/lib/router.js CHANGED
@@ -16,6 +16,7 @@ import { L2Networks } from "./constants/L2Networks.js";
16
16
  import { routeFinderWorker, routeFinderWorkerCode } from "./route-finder.worker.js";
17
17
  import { routeGraphWorker, routeGraphWorkerCode } from "./route-graph.worker.js";
18
18
  import { memoizeMethod } from "./constants/utils.js";
19
+ import { YB_ASSETS } from "./constants/ybPools.js";
19
20
  const MAX_STEPS = 5;
20
21
  const ROUTE_LENGTH = (MAX_STEPS * 2) + 1;
21
22
  function _getTVL(poolId) {
@@ -49,7 +50,7 @@ function _findRoutes(inputCoinAddress, outputCoinAddress) {
49
50
  const routerGraph = yield _buildRouteGraph.call(this, this.chainId, this.isLiteChain); // It's important to pass chainId to not use cache from another network
50
51
  // extract only the fields we need for the worker
51
52
  const poolData = mapDict(this.getPoolsData(), (_, { is_lending, wrapped_coin_addresses, underlying_coin_addresses, token_address }) => ({ is_lending, wrapped_coin_addresses, underlying_coin_addresses, token_address }));
52
- const input = { inputCoinAddress, outputCoinAddress, routerGraph, poolData };
53
+ const input = { inputCoinAddress, outputCoinAddress, routerGraph, poolData, ybAssets: YB_ASSETS };
53
54
  return runWorker(routeFinderWorkerCode, routeFinderWorker, Object.assign({ type: 'findRoutes' }, input));
54
55
  });
55
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.68.7",
3
+ "version": "2.68.9",
4
4
  "description": "JavaScript library for curve.finance",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",