Skip to content

Commit

Permalink
round down when calculating credits from balances
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrowDom committed Dec 1, 2024
1 parent 93545c3 commit dc854bc
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions contracts/contracts/token/OUSD.sol
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,8 @@ contract OUSD is Governable {
returns (uint256 rebasingCredits, uint256 actualBalance)
{
uint256 rebasingCreditsPerTokenMem = rebasingCreditsPerToken_;
// Rounds up, because we need to ensure that accounts always have
// at least the balance that they should have.
// Note this should always be used on an absolute account value,
// not on a possibly negative diff, because then the rounding would be wrong.
rebasingCredits =
((_balance) * rebasingCreditsPerTokenMem + 1e18 - 1) /
1e18;
// Round down in favour of the protocol
rebasingCredits = ((_balance) * rebasingCreditsPerTokenMem) / 1e18;
actualBalance = (rebasingCredits * 1e18) / rebasingCreditsPerTokenMem;
}

Expand Down

0 comments on commit dc854bc

Please sign in to comment.