imUSD

imUSD is the interest-bearing mUSD. This asset represent the deposited mUSD in SAVE and accrues in value.

Contracts are upgradable.

imUSD follows the ERC20 and ERC4626 standards:

For ERC20, the non-standard decreaseAllowance and increaseAllowance functions have been added to mitigate the well-known issues around setting allowances. These are based on the OpenZeppelin ERC20 implementation.

For ERC4626: Tokenized Vault Standard, the non-standard functions deposit(uint256 assets, address receiver, address referrer) and shares(uint256 shares, address receiver, address referrer) have been added to be use with the Alliance Referral program.

ERC-4626 Functions

asset()

function asset() external view returns (address assetTokenAddress);

The address of the underlying token used for the Vault uses for accounting, depositing, and withdrawing.

totalAssets()

function totalAssets() external view returns (uint256 totalManagedAssets);

Total amount of the underlying asset that is “managed” by Vault.

convertToShares()

function convertToShares(uint256 assets) external view returns (uint256 shares);

The amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.

convertToAssets()

function convertToAssets(uint256 shares) external view returns (uint256 assets);

The amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.

maxDeposit()

function maxDeposit(address caller) external view returns (uint256 maxAssets);

The maximum number of underlying assets that caller can deposit.

previewDeposit()

function previewDeposit(uint256 assets) external view returns (uint256 shares);

Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.

deposit()

function deposit(uint256 assets, address receiver) external returns (uint256 shares);

Mint vault shares to receiver by transferring exact amount of underlying asset tokens from the caller.

deposit()

function deposit(uint256 assets, address receiver, address referrer) external returns (uint256 shares);

Overloaded non-standard deposit method with an optional referrer address

maxMint()

function maxMint(address caller) external view returns (uint256 maxShares);

The maximum number of vault shares that caller can mint.

previewMint()

function previewMint(uint256 shares) external view returns (uint256 assets);

Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.

mint()

function mint(uint256 shares, address receiver) external returns (uint256 shares);

Mint exact amount of vault shares to the receiver by transferring enough underlying asset tokens from the caller.

mint()

function mint(uint256 shares, address receiver, address referrer) external returns (uint256 shares);

Overloaded non-standard mint method with an optional referrer address

maxWithdraw()

function maxWithdraw(address owner) external view returns (uint256 maxAssets);

The maximum number of underlying assets that owner can withdraw.

previewWithdraw()

function previewWithdraw(uint256 assets) external view returns (uint256 shares);

Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.

withdraw()

function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);

Burns enough vault shares from owner and transfers the exact amount of underlying asset tokens to the receiver.

maxRedeem()

function maxRedeem(address owner) external view returns (uint256 maxShares);

The maximum number of shares an owner can redeem for underlying assets.

previewRedeem()

function previewRedeem(uint256 shares) external view returns (uint256 assets);

Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block, given current on-chain conditions.

redeem()

function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);

Burns exact amount of vault shares from owner and transfers the underlying asset tokens to the receiver.

ERC-20 Functions

totalSupply()

function totalSupply () external returns (uint256)

Returns the amount of tokens in existence.

balanceOf()

function balanceOf () external returns (uint256)

Returns the amount of tokens owned by account.

transfer()

function transfer () external returns (bool)

Moves amount tokens from the caller's account to recipient.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event.

allowance()

function allowance () external returns (uint256)

Returns the remaining number of tokens thatspenderwill be allowed to spend on behalf ofownerthrough {transferFrom}. This is zero by default.

This value changes when {approve} or {transferFrom} are called.

approve()

function approve () external returns (bool)

Sets amount as the allowance of spender over the caller's tokens.

Returns a boolean value indicating whether the operation succeeded.

IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

Emits an {Approval} event.

transferFrom()

function transferFrom () external returns (bool)

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event.

increaseAllowance()

function increaseAllowance () public returns (bool)

Atomically increases the allowance granted to spender by the caller.

This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}.

Emits an {Approval} event indicating the updated allowance.

Requirements:

  • spender cannot be the zero address.

decreaseAllowance()

function decreaseAllowance () public returns (bool)

Atomically decreases the allowance granted to spender by the caller.

This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}.

Emits an {Approval} event indicating the updated allowance.

Requirements:

  • spender cannot be the zero address.

  • spender must have allowance for the caller of at least

    subtractedValue.

Save Functions

balanceOfUnderlying()

function balanceOfUnderlying (address _user) external returns (uint256 balance)

Returns the underlying balance of a given user

underlyingToCredits()

function underlyingToCredits (uint256 _underlying) external returns (uint256 credits)

Converts a given underlying amount into credits

creditsToUnderlying()

function creditsToUnderlying (uint256 _credits) external returns (uint256 amount)

Converts a given credit amount into underlying

creditBalances()

Deprecated in favour of `balanceOf(address)`. Maintained for backwards compatibility. Returns the credit balance of a given user

function creditBalances (address _user) external returns (uint256)

depositSavings()

function depositSavings (uint256 _underlying) external returns (uint256 creditsIssued)

Deposit the senders savings to the vault, and credit them internally with "credits". Credit amount is calculated as a ratio of deposit amount and exchange rate: credits = underlying / exchangeRate We will first update the internal exchange rate by collecting any interest generated on the underlying.

depositSavings()

function depositSavings (uint256 _underlying, address _beneficiary) external returns (uint256 creditsIssued)

Deposit the senders savings to the vault, and credit them internally with "credits". Credit amount is calculated as a ratio of deposit amount and exchange rate: credits = underlying / exchangeRate We will first update the internal exchange rate by collecting any interest generated on the underlying.

depositSavings()

function depositSavings (uint256 _underlying, address _beneficiary, address _referrer) external returns (uint256 creditsIssued)

Overloaded depositSavings method with an optional referrer address.

redeem()

function redeem () external returns (uint256 massetReturned)

redeemCredits()

function redeemCredits (uint256 _credits) external returns (uint256 massetReturned)

Redeem specific number of the senders "credits" in exchange for underlying. Payout amount is calculated as a ratio of credits and exchange rate: payout = credits * exchangeRate

redeemUnderlying()

function redeemUnderlying (uint256 _underlying) external returns (uint256 creditsBurned)

Redeem credits into a specific amount of underlying. Credits needed to burn is calculated using: credits = underlying / exchangeRate

redeemAndUnwrap()

function redeemAndUnwrap (uint256 _amount, bool _isCreditAmt, uint256 _minAmountOut, address _output, address _beneficiary, address _router, bool _isBassetOut) external returns (uint256 creditsBurned, uint256 massetReturned, uint256 outputQuantity)

Redeem credits into a specific amount of underlying, unwrap into a selected output asset, and send to a beneficiary Credits needed to burn is calculated using: credits = underlying / exchangeRate

poke()

function poke () external

External poke function allows for the redistribution of collateral between here and the current connector, setting the ratio back to the defined optimal.

Last updated