UNPKG

@ohgeez/fsushi

Version:

fSUSHI is a protocol built on top of [FlashStake](http://flashstake.io/) and [SushiSwap](https://sushi.com) that enables stakers to get instant, upfront yield without waiting for it to accrue.

625 lines (359 loc) 19 kB
# IERC4626 *Interface of the ERC4626 "Tokenized Vault Standard", as defined in https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. _Available since v4.7._* ## Methods ### allowance ```solidity function allowance(address owner, address spender) external view returns (uint256) ``` *Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called.* #### Parameters | Name | Type | Description | |---|---|---| | owner | address | undefined | | spender | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### approve ```solidity function approve(address spender, uint256 amount) external nonpayable 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.* #### Parameters | Name | Type | Description | |---|---|---| | spender | address | undefined | | amount | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | bool | undefined | ### asset ```solidity function asset() external view returns (address assetTokenAddress) ``` *Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. - MUST be an ERC-20 token contract. - MUST NOT revert.* #### Returns | Name | Type | Description | |---|---|---| | assetTokenAddress | address | undefined | ### balanceOf ```solidity function balanceOf(address account) external view returns (uint256) ``` *Returns the amount of tokens owned by `account`.* #### Parameters | Name | Type | Description | |---|---|---| | account | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### convertToAssets ```solidity function convertToAssets(uint256 shares) external view returns (uint256 assets) ``` *Returns 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. - MUST NOT be inclusive of any fees that are charged against assets in the Vault. - MUST NOT show any variations depending on the caller. - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. - MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.* #### Parameters | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | ### convertToShares ```solidity function convertToShares(uint256 assets) external view returns (uint256 shares) ``` *Returns 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. - MUST NOT be inclusive of any fees that are charged against assets in the Vault. - MUST NOT show any variations depending on the caller. - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. - MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.* #### Parameters | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | ### decimals ```solidity function decimals() external view returns (uint8) ``` *Returns the decimals places of the token.* #### Returns | Name | Type | Description | |---|---|---| | _0 | uint8 | undefined | ### deposit ```solidity function deposit(uint256 assets, address receiver) external nonpayable returns (uint256 shares) ``` *Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. - MUST emit the Deposit event. - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit. - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.* #### Parameters | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | | receiver | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | ### maxDeposit ```solidity function maxDeposit(address receiver) external view returns (uint256 maxAssets) ``` *Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call. - MUST return a limited value if receiver is subject to some deposit limit. - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. - MUST NOT revert.* #### Parameters | Name | Type | Description | |---|---|---| | receiver | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | maxAssets | uint256 | undefined | ### maxMint ```solidity function maxMint(address receiver) external view returns (uint256 maxShares) ``` *Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. - MUST return a limited value if receiver is subject to some mint limit. - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. - MUST NOT revert.* #### Parameters | Name | Type | Description | |---|---|---| | receiver | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | maxShares | uint256 | undefined | ### maxRedeem ```solidity function maxRedeem(address owner) external view returns (uint256 maxShares) ``` *Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call. - MUST return a limited value if owner is subject to some withdrawal limit or timelock. - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. - MUST NOT revert.* #### Parameters | Name | Type | Description | |---|---|---| | owner | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | maxShares | uint256 | undefined | ### maxWithdraw ```solidity function maxWithdraw(address owner) external view returns (uint256 maxAssets) ``` *Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call. - MUST return a limited value if owner is subject to some withdrawal limit or timelock. - MUST NOT revert.* #### Parameters | Name | Type | Description | |---|---|---| | owner | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | maxAssets | uint256 | undefined | ### mint ```solidity function mint(uint256 shares, address receiver) external nonpayable returns (uint256 assets) ``` *Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. - MUST emit the Deposit event. - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint. - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.* #### Parameters | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | | receiver | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | ### name ```solidity function name() external view returns (string) ``` *Returns the name of the token.* #### Returns | Name | Type | Description | |---|---|---| | _0 | string | undefined | ### previewDeposit ```solidity 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. - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction. - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough tokens approved, etc. - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. - MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.* #### Parameters | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | ### previewMint ```solidity function previewMint(uint256 shares) external view returns (uint256 assets) ``` *Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions. - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction. - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would be accepted, regardless if the user has enough tokens approved, etc. - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. - MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.* #### Parameters | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | ### previewRedeem ```solidity function previewRedeem(uint256 shares) external view returns (uint256 assets) ``` *Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions. - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction. - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc. - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. - MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.* #### Parameters | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | ### previewWithdraw ```solidity 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. - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called in the same transaction. - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the withdrawal would be accepted, regardless if the user has enough shares, etc. - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. - MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.* #### Parameters | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | ### redeem ```solidity function redeem(uint256 shares, address receiver, address owner) external nonpayable returns (uint256 assets) ``` *Burns exactly shares from owner and sends assets of underlying tokens to receiver. - MUST emit the Withdraw event. - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem. - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.* #### Parameters | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | | receiver | address | undefined | | owner | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | ### symbol ```solidity function symbol() external view returns (string) ``` *Returns the symbol of the token.* #### Returns | Name | Type | Description | |---|---|---| | _0 | string | undefined | ### totalAssets ```solidity function totalAssets() external view returns (uint256 totalManagedAssets) ``` *Returns the total amount of the underlying asset that is “managed” by Vault. - SHOULD include any compounding that occurs from yield. - MUST be inclusive of any fees that are charged against assets in the Vault. - MUST NOT revert.* #### Returns | Name | Type | Description | |---|---|---| | totalManagedAssets | uint256 | undefined | ### totalSupply ```solidity function totalSupply() external view returns (uint256) ``` *Returns the amount of tokens in existence.* #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### transfer ```solidity function transfer(address to, uint256 amount) external nonpayable returns (bool) ``` *Moves `amount` tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* #### Parameters | Name | Type | Description | |---|---|---| | to | address | undefined | | amount | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | bool | undefined | ### transferFrom ```solidity function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) ``` *Moves `amount` tokens from `from` to `to` 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.* #### Parameters | Name | Type | Description | |---|---|---| | from | address | undefined | | to | address | undefined | | amount | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | bool | undefined | ### withdraw ```solidity function withdraw(uint256 assets, address receiver, address owner) external nonpayable returns (uint256 shares) ``` *Burns shares from owner and sends exactly assets of underlying tokens to receiver. - MUST emit the Withdraw event. - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the withdraw execution, and are accounted for during withdraw. - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.* #### Parameters | Name | Type | Description | |---|---|---| | assets | uint256 | undefined | | receiver | address | undefined | | owner | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | shares | uint256 | undefined | ## Events ### Approval ```solidity event Approval(address indexed owner, address indexed spender, uint256 value) ``` #### Parameters | Name | Type | Description | |---|---|---| | owner `indexed` | address | undefined | | spender `indexed` | address | undefined | | value | uint256 | undefined | ### Deposit ```solidity event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares) ``` #### Parameters | Name | Type | Description | |---|---|---| | sender `indexed` | address | undefined | | owner `indexed` | address | undefined | | assets | uint256 | undefined | | shares | uint256 | undefined | ### Transfer ```solidity event Transfer(address indexed from, address indexed to, uint256 value) ``` #### Parameters | Name | Type | Description | |---|---|---| | from `indexed` | address | undefined | | to `indexed` | address | undefined | | value | uint256 | undefined | ### Withdraw ```solidity event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares) ``` #### Parameters | Name | Type | Description | |---|---|---| | sender `indexed` | address | undefined | | receiver `indexed` | address | undefined | | owner `indexed` | address | undefined | | assets | uint256 | undefined | | shares | uint256 | undefined |