Commit 9cd67ec0 authored by Son of Odin's avatar Son of Odin 💬

Merge branch 'vault-coin-length-patch' into 'master'

[bugfix] patch incorrect vault coins length

See merge request !688
parents f450e937 6c85cc2a
Pipeline #129025146 passed with stages
in 66 minutes and 2 seconds
......@@ -107,6 +107,16 @@ func (v Vault) HasFunds() bool {
return false
}
// CoinLength - counts the number of coins this vault has
func (v Vault) CoinLength() (count int) {
for _, coin := range v.Coins {
if !coin.Amount.IsZero() {
count += 1
}
}
return
}
// HasAsset Check if this vault has a particular asset
func (v Vault) HasAsset(asset common.Asset) bool {
return !v.GetCoin(asset).Amount.IsZero()
......
......@@ -151,7 +151,7 @@ func (vm *VaultMgr) EndBlock(ctx sdk.Context, version semver.Version, constAcces
if coin.Asset.IsBNB() {
amt = common.SafeSub(
amt,
common.BNBGasFeeSingleton[0].Amount.MulUint64(uint64(len(vault.Coins))),
common.BNBGasFeeSingleton[0].Amount.MulUint64(uint64(vault.CoinLength())),
)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment