From dc854bcbf99959ecbba0d37f336e2b6e98d1d12a Mon Sep 17 00:00:00 2001 From: Domen Grabec Date: Mon, 2 Dec 2024 00:50:31 +0100 Subject: [PATCH] round down when calculating credits from balances --- contracts/contracts/token/OUSD.sol | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/contracts/contracts/token/OUSD.sol b/contracts/contracts/token/OUSD.sol index 8bd07380bf..21880e350e 100644 --- a/contracts/contracts/token/OUSD.sol +++ b/contracts/contracts/token/OUSD.sol @@ -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; }