Skip to main content

OUSD

OUSD​

NOTE that this is an ERC20 token but the invariant that the sum of balanceOf(x) for all x is not >= totalSupply(). This is a consequence of the rebasing design. Any integrations with OUSD should be aware.

TotalSupplyUpdatedHighres​

event TotalSupplyUpdatedHighres(uint256 totalSupply, uint256 rebasingCredits, uint256 rebasingCreditsPerToken)

AccountRebasingEnabled​

event AccountRebasingEnabled(address account)

AccountRebasingDisabled​

event AccountRebasingDisabled(address account)

RebaseOptions​

enum RebaseOptions {
NotSet,
OptOut,
OptIn
}

_totalSupply​

uint256 _totalSupply

vaultAddress​

address vaultAddress

nonRebasingSupply​

uint256 nonRebasingSupply

nonRebasingCreditsPerToken​

mapping(address => uint256) nonRebasingCreditsPerToken

rebaseState​

mapping(address => enum OUSD.RebaseOptions) rebaseState

isUpgraded​

mapping(address => uint256) isUpgraded

initialize​

function initialize(string _nameArg, string _symbolArg, address _vaultAddress, uint256 _initialCreditsPerToken) external

onlyVault​

modifier onlyVault()

Verifies that the caller is the Vault contract

totalSupply​

function totalSupply() public view returns (uint256)

Return Values​

NameTypeDescription
[0]uint256The total supply of OUSD.

rebasingCreditsPerToken​

function rebasingCreditsPerToken() public view returns (uint256)

Return Values​

NameTypeDescription
[0]uint256Low resolution rebasingCreditsPerToken

rebasingCredits​

function rebasingCredits() public view returns (uint256)

Return Values​

NameTypeDescription
[0]uint256Low resolution total number of rebasing credits

rebasingCreditsPerTokenHighres​

function rebasingCreditsPerTokenHighres() public view returns (uint256)

Return Values​

NameTypeDescription
[0]uint256High resolution rebasingCreditsPerToken

rebasingCreditsHighres​

function rebasingCreditsHighres() public view returns (uint256)

Return Values​

NameTypeDescription
[0]uint256High resolution total number of rebasing credits

balanceOf​

function balanceOf(address _account) public view returns (uint256)

Gets the balance of the specified address.

Parameters​

NameTypeDescription
_accountaddressAddress to query the balance of.

Return Values​

NameTypeDescription
[0]uint256A uint256 representing the amount of base units owned by the specified address.

creditsBalanceOf​

function creditsBalanceOf(address _account) public view returns (uint256, uint256)

Gets the credits balance of the specified address. Backwards compatible with old low res credits per token.

Parameters​

NameTypeDescription
_accountaddressThe address to query the balance of.

Return Values​

NameTypeDescription
[0]uint256(uint256, uint256) Credit balance and credits per token of the address
[1]uint256

creditsBalanceOfHighres​

function creditsBalanceOfHighres(address _account) public view returns (uint256, uint256, bool)

Gets the credits balance of the specified address.

Parameters​

NameTypeDescription
_accountaddressThe address to query the balance of.

Return Values​

NameTypeDescription
[0]uint256(uint256, uint256, bool) Credit balance, credits per token of the address, and isUpgraded
[1]uint256
[2]bool

transfer​

function transfer(address _to, uint256 _value) public returns (bool)

Transfer tokens to a specified address.

Parameters​

NameTypeDescription
_toaddressthe address to transfer to.
_valueuint256the amount to be transferred.

Return Values​

NameTypeDescription
[0]booltrue on success.

transferFrom​

function transferFrom(address _from, address _to, uint256 _value) public returns (bool)

Transfer tokens from one address to another.

Parameters​

NameTypeDescription
_fromaddressThe address you want to send tokens from.
_toaddressThe address you want to transfer to.
_valueuint256The amount of tokens to be transferred.

_executeTransfer​

function _executeTransfer(address _from, address _to, uint256 _value) internal

Update the count of non rebasing credits in response to a transfer

Parameters​

NameTypeDescription
_fromaddressThe address you want to send tokens from.
_toaddressThe address you want to transfer to.
_valueuint256Amount of OUSD to transfer

allowance​

function allowance(address _owner, address _spender) public view returns (uint256)

Function to check the amount of tokens that _owner has allowed to _spender.

Parameters​

NameTypeDescription
_owneraddressThe address which owns the funds.
_spenderaddressThe address which will spend the funds.

Return Values​

NameTypeDescription
[0]uint256The number of tokens still available for the _spender.

approve​

function approve(address _spender, uint256 _value) public returns (bool)

Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. This method is included for ERC20 compatibility. increaseAllowance and decreaseAllowance should be used instead.

Changing an allowance with this method brings the risk that someone may transfer both the old and the new allowance - if they are both greater than zero - if a transfer transaction is mined before the later approve() call is mined.

Parameters​

NameTypeDescription
_spenderaddressThe address which will spend the funds.
_valueuint256The amount of tokens to be spent.

increaseAllowance​

function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool)

Increase the amount of tokens that an owner has allowed to _spender. This method should be used instead of approve() to avoid the double approval vulnerability described above.

Parameters​

NameTypeDescription
_spenderaddressThe address which will spend the funds.
_addedValueuint256The amount of tokens to increase the allowance by.

decreaseAllowance​

function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool)

Decrease the amount of tokens that an owner has allowed to _spender.

Parameters​

NameTypeDescription
_spenderaddressThe address which will spend the funds.
_subtractedValueuint256The amount of tokens to decrease the allowance by.

mint​

function mint(address _account, uint256 _amount) external

Mints new tokens, increasing totalSupply.

_mint​

function _mint(address _account, uint256 _amount) internal

Creates _amount tokens and assigns them to _account, increasing the total supply.

Emits a Transfer event with from set to the zero address.

Requirements

  • to cannot be the zero address.

burn​

function burn(address account, uint256 amount) external

Burns tokens, decreasing totalSupply.

_burn​

function _burn(address _account, uint256 _amount) internal

Destroys _amount tokens from _account, reducing the total supply.

Emits a Transfer event with to set to the zero address.

Requirements

  • _account cannot be the zero address.
  • _account must have at least _amount tokens.

_creditsPerToken​

function _creditsPerToken(address _account) internal view returns (uint256)

Get the credits per token for an account. Returns a fixed amount if the account is non-rebasing.

Parameters​

NameTypeDescription
_accountaddressAddress of the account.

_isNonRebasingAccount​

function _isNonRebasingAccount(address _account) internal returns (bool)

Is an account using rebasing accounting or non-rebasing accounting? Also, ensure contracts are non-rebasing if they have not opted in.

Parameters​

NameTypeDescription
_accountaddressAddress of the account.

_ensureRebasingMigration​

function _ensureRebasingMigration(address _account) internal

Ensures internal account for rebasing and non-rebasing credits and supply is updated following deployment of frozen yield change.

governanceRebaseOptIn​

function governanceRebaseOptIn(address _account) public

Enable rebasing for an account.

Add a contract address to the non-rebasing exception list. The address's balance will be part of rebases and the account will be exposed to upside and downside.

Parameters​

NameTypeDescription
_accountaddressAddress of the account.

rebaseOptIn​

function rebaseOptIn() public

Add a contract address to the non-rebasing exception list. The address's balance will be part of rebases and the account will be exposed to upside and downside.

_rebaseOptIn​

function _rebaseOptIn(address _account) internal

rebaseOptOut​

function rebaseOptOut() public

Explicitly mark that an address is non-rebasing.

changeSupply​

function changeSupply(uint256 _newTotalSupply) external

Modify the supply without minting new tokens. This uses a change in the exchange rate between "credits" and OUSD tokens to change balances.

Parameters​

NameTypeDescription
_newTotalSupplyuint256New total supply of OUSD.