Skip to content

Commit

Permalink
fix: remove tokens from balances that are not in the pool (#7345) (#7347
Browse files Browse the repository at this point in the history
)

* fix: remove tokens from balances that are not in the pool

* Update ingest/sqs/pools/ingester/pool_ingester.go

(cherry picked from commit cb8ce98)

Co-authored-by: Roman <[email protected]>
  • Loading branch information
mergify[bot] and p0mvn authored Jan 20, 2024
1 parent 342bb61 commit f130309
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ingest/sqs/pools/ingester/pool_ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -467,7 +473,7 @@ func (pi *poolIngester) convertPool(
SQSModel: sqsdomain.SQSPool{
TotalValueLockedUSDC: osmoPoolTVL,
TotalValueLockedError: errorInTVLStr,
Balances: balances,
Balances: filteredBalances,
PoolDenoms: denoms,
SpreadFactor: spreadFactor,
},
Expand Down

0 comments on commit f130309

Please sign in to comment.