From f130309dfbdd5ee8cfe95f5485bdc1f39c3277e5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 19 Jan 2024 17:33:39 -0700 Subject: [PATCH] fix: remove tokens from balances that are not in the pool (#7345) (#7347) * fix: remove tokens from balances that are not in the pool * Update ingest/sqs/pools/ingester/pool_ingester.go (cherry picked from commit cb8ce98d3ef1cec490f72172b8ac46f9a04cdd1e) Co-authored-by: Roman --- ingest/sqs/pools/ingester/pool_ingester.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ingest/sqs/pools/ingester/pool_ingester.go b/ingest/sqs/pools/ingester/pool_ingester.go index 865d75fcef3..a72390337d9 100644 --- a/ingest/sqs/pools/ingester/pool_ingester.go +++ b/ingest/sqs/pools/ingester/pool_ingester.go @@ -316,6 +316,9 @@ func (pi *poolIngester) convertPool( // Otherwise, the CosmWasmPool model panics. pool = pool.AsSerializablePool() + // filtered balances consisting only of the pool denom balances. + filteredBalances := sdk.NewCoins() + var errorInTVLStr string for _, balance := range balances { // Note that there are edge cases where gamm shares or some random @@ -330,6 +333,9 @@ func (pi *poolIngester) convertPool( continue } + // update filtered balances only with pool tokens + filteredBalances = filteredBalances.Add(balance) + if balance.Denom == UOSMO { osmoPoolTVL = osmoPoolTVL.Add(balance.Amount) continue @@ -467,7 +473,7 @@ func (pi *poolIngester) convertPool( SQSModel: sqsdomain.SQSPool{ TotalValueLockedUSDC: osmoPoolTVL, TotalValueLockedError: errorInTVLStr, - Balances: balances, + Balances: filteredBalances, PoolDenoms: denoms, SpreadFactor: spreadFactor, },