Skip to content

Commit 2f63c44

Browse files
committed
Add balance match require to no rebase migration.
1 parent 8526238 commit 2f63c44

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

contracts/contracts/token/OUSD.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ contract OUSD is Initializable, InitializableERC20Detailed, Governable {
481481
if (nonRebasingCreditsPerToken[_account] != 0) {
482482
return; // Account already is non-rebasing
483483
}
484+
uint256 oldBalance = balanceOf(_account); // For checks
484485
if (_creditBalances[_account] == 0) {
485486
// Since there is no existing balance, we can directly set it to
486487
// high resolution, and do not have to do any other bookkeeping
@@ -509,6 +510,10 @@ contract OUSD is Initializable, InitializableERC20Detailed, Governable {
509510
_rebasingCredits = _rebasingCredits.sub(oldCredits);
510511
}
511512

513+
// Moving to a non rebasing account should always allow perfect accounting.
514+
// This check does cost extra gas, but migrating accounts is rare.
515+
require(oldBalance == balanceOf(_account), "Balances do not match");
516+
512517
emit RebasingDisabled(
513518
_account,
514519
balanceOf(_account),

0 commit comments

Comments
 (0)