diff --git a/.changeset/gorgeous-kiwis-sort.md b/.changeset/gorgeous-kiwis-sort.md new file mode 100644 index 0000000..f4db27c --- /dev/null +++ b/.changeset/gorgeous-kiwis-sort.md @@ -0,0 +1,5 @@ +--- +"@thalalabs/router-sdk": patch +--- + +Use 6 coins for v2 stable pool diff --git a/packages/thalaswap-router/src/PoolDataClient.ts b/packages/thalaswap-router/src/PoolDataClient.ts index 99522ee..01cfbb4 100644 --- a/packages/thalaswap-router/src/PoolDataClient.ts +++ b/packages/thalaswap-router/src/PoolDataClient.ts @@ -217,9 +217,10 @@ class PoolDataClient { ); return rawPools.map((pool) => { - const [coin0, coin1, coin2, coin3] = pool.assets_metadata.map((o) => - this.coins.find((c) => c.address === o.inner), - ); + const [coin0, coin1, coin2, coin3, coin4, coin5] = + pool.assets_metadata.map((o) => + this.coins.find((c) => c.address === o.inner), + ); return { poolType: pool.pool_type === 100 ? "Stable" : "Weighted", type: pool.pool.inner, @@ -233,6 +234,8 @@ class PoolDataClient { asset1: coin1!, asset2: coin2, asset3: coin3, + asset4: coin4, + asset5: coin5, balance0: scaleDown(pool.balances[0], coin0!.decimals), balance1: scaleDown(pool.balances[1], coin1!.decimals), balance2: @@ -243,6 +246,14 @@ class PoolDataClient { pool.balances.length > 3 ? scaleDown(pool.balances[3], coin3!.decimals) : undefined, + balance4: + pool.balances.length > 4 + ? scaleDown(pool.balances[4], coin4!.decimals) + : undefined, + balance5: + pool.balances.length > 5 + ? scaleDown(pool.balances[5], coin5!.decimals) + : undefined, swapFee: Number(pool.swap_fee_bps) / 10000, isV2: true, }; diff --git a/packages/thalaswap-router/src/ThalaswapRouter.ts b/packages/thalaswap-router/src/ThalaswapRouter.ts index 2f76e3a..92364e8 100644 --- a/packages/thalaswap-router/src/ThalaswapRouter.ts +++ b/packages/thalaswap-router/src/ThalaswapRouter.ts @@ -130,11 +130,25 @@ class ThalaswapRouter { } // Convert pool data to LiquidityPool type - const assets = ["asset0", "asset1", "asset2", "asset3"] + const assets = [ + "asset0", + "asset1", + "asset2", + "asset3", + "asset4", + "asset5", + ] .filter((a) => pool[a as AssetIndex]) .map((a) => pool[a as AssetIndex]!); - const balances = ["balance0", "balance1", "balance2", "balance3"] + const balances = [ + "balance0", + "balance1", + "balance2", + "balance3", + "balance4", + "balance5", + ] .filter((b, i) => assets[i]) .map((b) => pool[b as BalanceIndex] as number); diff --git a/packages/thalaswap-router/src/types.ts b/packages/thalaswap-router/src/types.ts index 63105dd..756cb5a 100644 --- a/packages/thalaswap-router/src/types.ts +++ b/packages/thalaswap-router/src/types.ts @@ -39,12 +39,16 @@ type Pool = { asset1: Coin; asset2?: Coin; asset3?: Coin; + asset4?: Coin; + asset5?: Coin; type: string; poolType: "Weighted" | "Stable"; balance0: number; balance1: number; balance2?: number; balance3?: number; + balance4?: number; + balance5?: number; weights: number[]; swapFee: number; amp?: number; @@ -66,8 +70,20 @@ type Predecessors = Record< Record >; -type AssetIndex = "asset0" | "asset1" | "asset2" | "asset3"; -type BalanceIndex = "balance0" | "balance1" | "balance2" | "balance3"; +type AssetIndex = + | "asset0" + | "asset1" + | "asset2" + | "asset3" + | "asset4" + | "asset5"; +type BalanceIndex = + | "balance0" + | "balance1" + | "balance2" + | "balance3" + | "balance4" + | "balance5"; export type { Edge,