Skip to content

Commit

Permalink
types: fix net asset field adding
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Dec 16, 2024
1 parent adf5a90 commit e06c510
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/types/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ func (b Balance) Add(b2 Balance) Balance {
newB.Locked = b.Locked.Add(b2.Locked)
newB.Borrowed = b.Borrowed.Add(b2.Borrowed)
newB.Interest = b.Interest.Add(b2.Interest)

if !b.NetAsset.IsZero() && !b2.NetAsset.IsZero() {
newB.NetAsset = b.NetAsset.Add(b2.NetAsset)
} else {
// do not use this field, reset it
newB.NetAsset = fixedpoint.Zero
}

return newB
}

Expand Down

0 comments on commit e06c510

Please sign in to comment.