Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions contracts/contracts/mocks/TestUpgradedOUSD.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../token/OUSD.sol";

// used to alter internal state of OUSD contract
contract TestUpgradedOUSD is OUSD {
constructor() OUSD() {}

function overwriteCreditBalances(address _account, uint256 _creditBalance)
public
{
_creditBalances[_account] = _creditBalance;
}

function overwriteAlternativeCPT(address _account, uint256 _acpt) public {
alternativeCreditsPerToken[_account] = _acpt;
}

function overwriteRebaseState(address _account, RebaseOptions _rebaseOption)
public
{
rebaseState[_account] = _rebaseOption;
}
}
30 changes: 10 additions & 20 deletions contracts/contracts/token/OUSD.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract OUSD is Governable {
uint256 public _totalSupply;
mapping(address => mapping(address => uint256)) private _allowances;
address public vaultAddress = address(0);
mapping(address => uint256) private _creditBalances;
mapping(address => uint256) internal _creditBalances;
uint256 private _rebasingCredits; // Sum of all rebasing credits (_creditBalances for rebasing accounts)
uint256 private _rebasingCreditsPerToken;
uint256 public nonRebasingSupply; // All nonrebasing balances
Expand Down Expand Up @@ -456,22 +456,22 @@ contract OUSD is Governable {

/**
* @dev Before a `rebaseOptIn` or non yield delegating token `transfer` can be executed contract
* accounts need to have a more explicitly defined rebasing state set.
*
* accounts need to have a more explicitly defined rebasing state set.
*
* Contract account can be in the following states before `autoMigrate` is called:
* 1. Under any token contract codebase they haven't been part of any token transfers yet
* having rebaseState `NotSet` and `alternativeCreditsPerToken == 0`
* 2. Under older token contract codebase they have the default rebaseState set to `NotSet` and
* the codebase has "auto-migrated" them by setting the `alternativeCreditsPerToken` to some
* the codebase has "auto-migrated" them by setting the `alternativeCreditsPerToken` to some
* value greater than 0.
* 3. Contract has under any token contract codebase explicitly requested to be opted out of rebasing
*
* Case 1. Needs to be migrated using autoMigrate to a nonRebasing account.
*
*
* Note: Even with this _autoMigrate function in place there will still be Case 2 accounts existing that
* will behave exactly like RebaseState StdNonRebasing account, and still having their rebase state
* set to `NotSet`
*
*
* @param _account Address of the account.
*/
function _autoMigrate(address _account) internal returns (bool) {
Expand Down Expand Up @@ -511,10 +511,7 @@ contract OUSD is Governable {
* to upside and downside.
* @param _account Address of the account.
*/
function governanceRebaseOptIn(address _account)
external
onlyGovernor
{
function governanceRebaseOptIn(address _account) external onlyGovernor {
_rebaseOptIn(_account);
}

Expand All @@ -537,7 +534,7 @@ contract OUSD is Governable {
RebaseOptions state = rebaseState[_account];
require(
state == RebaseOptions.StdNonRebasing ||
state == RebaseOptions.NotSet,
state == RebaseOptions.NotSet,
"Only standard non-rebasing accounts can opt in"
);

Expand Down Expand Up @@ -590,10 +587,7 @@ contract OUSD is Governable {
* the exchange rate between "credits" and OUSD tokens to change balances.
* @param _newTotalSupply New total supply of OUSD.
*/
function changeSupply(uint256 _newTotalSupply)
external
onlyVault
{
function changeSupply(uint256 _newTotalSupply) external onlyVault {
require(_totalSupply > 0, "Cannot increase 0 supply");

if (_totalSupply == _newTotalSupply) {
Expand Down Expand Up @@ -626,10 +620,7 @@ contract OUSD is Governable {
);
}

function delegateYield(address from, address to)
external
onlyGovernor
{
function delegateYield(address from, address to) external onlyGovernor {
require(from != to, "Cannot delegate to self");
require(
yieldFrom[to] == address(0) &&
Expand All @@ -655,7 +646,6 @@ contract OUSD is Governable {
"Invalid rebaseState to"
);


if (
alternativeCreditsPerToken[from] == 0 &&
(stateFrom == RebaseOptions.NotSet ||
Expand Down
8 changes: 7 additions & 1 deletion contracts/deploy/deployActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
getOracleAddresses,
isMainnet,
isHolesky,
isTest,
} = require("../test/helpers.js");
const { deployWithConfirmation, withConfirmation } = require("../utils/deploy");
const {
Expand Down Expand Up @@ -1190,7 +1191,12 @@ const deployOUSDCore = async () => {
await deployWithConfirmation("VaultProxy");

// Main contracts
const dOUSD = await deployWithConfirmation("OUSD");
let dOUSD;
if (isTest) {
dOUSD = await deployWithConfirmation("TestUpgradedOUSD");
} else {
dOUSD = await deployWithConfirmation("OUSD");
}
const dVault = await deployWithConfirmation("Vault");
const dVaultCore = await deployWithConfirmation("VaultCore");
const dVaultAdmin = await deployWithConfirmation("VaultAdmin");
Expand Down
Loading
Loading