Skip to content

Commit

Permalink
Problem: negative coin amount error when query supply liquid of non B…
Browse files Browse the repository at this point in the history
…aseCoinUnit
  • Loading branch information
mmsqe committed Dec 30, 2024
1 parent d1d09c9 commit 466606f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [#1088](https://github.com/crypto-org-chain/chain-main/pull/1088) Upgrade solomachine to `v0.1.4` and ibc-go to `v8.5.1`.
* [#1091](https://github.com/crypto-org-chain/chain-main/pull/1091) Update cometbft to `0.38.13`, sdk to `v0.50.10` and memiavl to latest.
- [#1091](https://github.com/crypto-org-chain/chain-main/pull/1091) Upgrade cometbft to v0.38.13, cosmos-sdk to `v0.50.10`.
- [#1097](https://github.com/crypto-org-chain/chain-main/pull/1097) Avoid negative coin amount error when query supply liquid of non BaseCoinUnit.

*Dec 6, 2023*

Expand Down
10 changes: 7 additions & 3 deletions x/supply/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,13 @@ func (k Keeper) GetTotalModuleAccountBalance(ctx sdk.Context, moduleNames ...str

// GetLiquidSupply returns the total liquid supply in the system
func (k Keeper) GetLiquidSupply(ctx sdk.Context) sdk.Coins {
totalSupply := k.GetTotalSupply(ctx)
unvestedSupply := k.GetUnvestedSupply(ctx)
moduleAccountBalance := k.GetTotalModuleAccountBalance(ctx, ModuleAccounts...)

return totalSupply.Sub(unvestedSupply...).Sub(moduleAccountBalance...)
res := sdk.Coins{}
for _, balance := range moduleAccountBalance {
totalSupply := k.bankKeeper.GetSupply(ctx, balance.Denom)
totalSupply = totalSupply.Sub(sdk.NewCoin(balance.Denom, unvestedSupply.AmountOf(balance.Denom)))
res = append(res, totalSupply.Sub(balance))
}
return res

Check warning on line 148 in x/supply/keeper/keeper.go

View check run for this annotation

Codecov / codecov/patch

x/supply/keeper/keeper.go#L142-L148

Added lines #L142 - L148 were not covered by tests
}

0 comments on commit 466606f

Please sign in to comment.