From d8335f0b3580650fc3271a95a47f8d896f0db3b8 Mon Sep 17 00:00:00 2001 From: macket Date: Thu, 21 Nov 2024 19:15:45 +0400 Subject: [PATCH 1/2] fix: routerGraph cache --- src/router.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/router.ts b/src/router.ts index 59fae84a..440e74b4 100644 --- a/src/router.ts +++ b/src/router.ts @@ -3,7 +3,7 @@ import memoize from "memoizee"; import BigNumber from "bignumber.js"; import {ethers} from "ethers"; import { curve, OLD_CHAINS } from "./curve.js"; -import {IDict, IRoute, IRouteOutputAndCost, IRouteStep} from "./interfaces"; +import {IDict, IRoute, IRouteOutputAndCost, IRouteStep, IChainId} from "./interfaces"; import { _cutZeros, _get_price_impact, @@ -54,9 +54,8 @@ function mapDict(dict: IDict, mapper: (key: string, value: T) => U): ID return result; } -const _buildRouteGraph = memoize(async (): Promise>> => { +const _buildRouteGraph = memoize(async (chainId: IChainId): Promise>> => { const constants = curve.constants; - const chainId = curve.chainId; const allPools = Object.entries(curve.getPoolsData()).filter(([id]) => !["crveth", "y", "busd", "pax"].includes(id)); const amplificationCoefficientDict = await _getAmplificationCoefficientsFromApi(); const poolTvlDict: IDict = await entriesToDictAsync(allPools, _getTVL); @@ -69,7 +68,7 @@ const _buildRouteGraph = memoize(async (): Promise>> = }); const _findRoutes = async (inputCoinAddress: string, outputCoinAddress: string): Promise => { - const routerGraph = await _buildRouteGraph(); + const routerGraph = await _buildRouteGraph(curve.chainId); // It's important to pass chainId to not use cache from another network // extract only the fields we need for the worker const poolData = mapDict( curve.getPoolsData(), From 498cbc435e49e8c2cafcd895d9a1fc9b9c37360e Mon Sep 17 00:00:00 2001 From: macket Date: Thu, 21 Nov 2024 19:16:13 +0400 Subject: [PATCH 2/2] build: v2.65.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c14ee4fd..eb465b3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@curvefi/api", - "version": "2.65.12", + "version": "2.65.13", "description": "JavaScript library for curve.fi", "main": "lib/index.js", "author": "Macket",