WSPAToken
Inherits: ERC4626Upgradeable
It's an ERC4626 standard token that represents the account's share of the total supply of SPA tokens. WSPAToken token's balance only changes on transfers, unlike spaToken that is also changed when staking rewards and swap fee are generated. It's a "power user" token for DeFi protocols which don't support rebasable tokens. The contract is also a trustless wrapper that accepts spaToken tokens and mints WSPAToken in return. Then the user unwraps, the contract burns user's WSPAToken and sends user locked SPA tokens in return.
State Variables
spaToken
ISPAToken public spaToken;
Functions
constructor
constructor();
initialize
function initialize(ISPAToken _spaToken) public initializer;
deposit
Deposits spaToken into the vault in exchange for shares.
function deposit(uint256 assets, address receiver) public override returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Amount of spaToken to deposit. |
receiver | address | Address to receive the minted shares. |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | Amount of shares minted. |
mint
Mints shares for a given amount of assets deposited.
function mint(uint256 shares, address receiver) public override returns (uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | Amount of shares to mint. |
receiver | address | Address to receive the minted shares. |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of spaToken deposited. |
withdraw
Withdraws spaToken from the vault in exchange for burning shares.
function withdraw(uint256 assets, address receiver, address owner) public override returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Amount of spaToken to withdraw. |
receiver | address | Address to receive the spaToken. |
owner | address | Address whose shares will be burned. |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | Burned shares corresponding to the assets withdrawn. |
redeem
Redeems shares for spaToken.
function redeem(uint256 shares, address receiver, address owner) public override returns (uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | Amount of shares to redeem. |
receiver | address | Address to receive the spaToken. |
owner | address | Address whose shares will be burned. |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | Amount of spaToken withdrawn. |
name
Returns the name of the token.
function name() public view override(ERC20Upgradeable, IERC20Metadata) returns (string memory);
Returns
Name | Type | Description |
---|---|---|
<none> | string | The name of the token. |
symbol
Returns the symbol of the token.
function symbol() public view override(ERC20Upgradeable, IERC20Metadata) returns (string memory);
Returns
Name | Type | Description |
---|---|---|
<none> | string | The symbol of the token. |
convertToShares
Converts an amount of spaToken to the equivalent amount of shares.
function convertToShares(uint256 assets) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Amount of spaToken. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The equivalent shares. |
convertToAssets
Converts an amount of shares to the equivalent amount of spaToken.
function convertToAssets(uint256 shares) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | Amount of shares. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The equivalent spaToken. |
maxWithdraw
Returns the maximum amount of assets that can be withdrawn by owner
.
function maxWithdraw(address owner) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
owner | address | Address of the account. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The maximum amount of spaToken that can be withdrawn. |
previewDeposit
Simulates the amount of shares that would be minted for a given amount of assets.
function previewDeposit(uint256 assets) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Amount of spaToken to deposit. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The number of shares that would be minted. |
previewMint
Simulates the amount of assets that would be needed to mint a given amount of shares.
function previewMint(uint256 shares) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | Amount of shares to mint. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The number of assets required. |
previewRedeem
Simulates the amount of assets that would be withdrawn for a given amount of shares.
function previewRedeem(uint256 shares) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | Amount of shares to redeem. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The number of assets that would be withdrawn. |
Errors
ZeroAmount
error ZeroAmount();
InsufficientAllowance
error InsufficientAllowance();