From dd2c205836543bd69ff857e7e59626fc6f2441cb Mon Sep 17 00:00:00 2001 From: SamuelQZQ Date: Mon, 12 Aug 2024 12:05:54 +0800 Subject: [PATCH 1/2] Add pool filter in ThalaswapRouter Option argument. So that user can filter out some pools for the router. --- packages/thalaswap-router/src/ThalaswapRouter.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/thalaswap-router/src/ThalaswapRouter.ts b/packages/thalaswap-router/src/ThalaswapRouter.ts index d03afb0..b540432 100644 --- a/packages/thalaswap-router/src/ThalaswapRouter.ts +++ b/packages/thalaswap-router/src/ThalaswapRouter.ts @@ -63,6 +63,7 @@ const scaleUp = (amount: number, decimals: number): number => { type Options = { maxAllowedSwapPercentage?: number; + poolFilter?: (pool: Pool) => boolean; }; class ThalaswapRouter { @@ -102,6 +103,11 @@ class ThalaswapRouter { const graph: Graph = {}; for (const pool of pools) { + // Apply pool filter if provided + if (this.options.poolFilter && !this.options.poolFilter(pool)) { + continue; + } + // Convert pool data to LiquidityPool type const assets = ["asset0", "asset1", "asset2", "asset3"] .filter((a) => pool[a as AssetIndex]) From 9e6b60c5d2bbd575512263b05cc5ccd67863125e Mon Sep 17 00:00:00 2001 From: SamuelQZQ Date: Mon, 12 Aug 2024 12:06:03 +0800 Subject: [PATCH 2/2] Add pool filter in ThalaswapRouter Option argument. So that user can filter out some pools for the router. --- .changeset/long-garlics-dance.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/long-garlics-dance.md diff --git a/.changeset/long-garlics-dance.md b/.changeset/long-garlics-dance.md new file mode 100644 index 0000000..fd25d54 --- /dev/null +++ b/.changeset/long-garlics-dance.md @@ -0,0 +1,5 @@ +--- +"@thalalabs/router-sdk": minor +--- + +Add pool filter in ThalaswapRouter Option argument. So that user can filter out some pools for the router.