From 9dbcb2d874b03e156726805b088afec58bb4b032 Mon Sep 17 00:00:00 2001 From: Jon Ator Date: Sat, 3 Aug 2024 15:23:23 -0400 Subject: [PATCH] fix SQS total weight values --- .../server/src/queries/complex/pools/providers/sidecar.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/server/src/queries/complex/pools/providers/sidecar.ts b/packages/server/src/queries/complex/pools/providers/sidecar.ts index 9bcc549568..3ca9cddac3 100644 --- a/packages/server/src/queries/complex/pools/providers/sidecar.ts +++ b/packages/server/src/queries/complex/pools/providers/sidecar.ts @@ -152,6 +152,7 @@ function getPoolDenomsFromSidecarPool({ chain_model, balances }: SidecarPool) { function makePoolRawResponseFromChainPool( chainPool: SidecarPool["chain_model"] ): PoolRawResponse { + // CL pools if ("current_tick_liquidity" in chainPool) { return { ...chainPool, @@ -162,6 +163,7 @@ function makePoolRawResponseFromChainPool( } as PoolRawResponse; } + // Stable pools if ("scaling_factors" in chainPool) { return { ...chainPool, @@ -172,13 +174,17 @@ function makePoolRawResponseFromChainPool( } as PoolRawResponse; } - if ("id" in chainPool) { + // Weighted pools + if ("total_weight" in chainPool) { return { ...chainPool, id: chainPool.id?.toString(), + // SQS diverges from the node model by returning total_weight as a string decimal instead of string integer + total_weight: chainPool.total_weight.split(".")[0], } as PoolRawResponse; } + // Cosmwasm pools return { ...chainPool, pool_id: chainPool.pool_id?.toString(),