Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

WSPAToken

Git Source

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

NameTypeDescription
assetsuint256Amount of spaToken to deposit.
receiveraddressAddress to receive the minted shares.

Returns

NameTypeDescription
sharesuint256Amount 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

NameTypeDescription
sharesuint256Amount of shares to mint.
receiveraddressAddress to receive the minted shares.

Returns

NameTypeDescription
assetsuint256The 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

NameTypeDescription
assetsuint256Amount of spaToken to withdraw.
receiveraddressAddress to receive the spaToken.
owneraddressAddress whose shares will be burned.

Returns

NameTypeDescription
sharesuint256Burned 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

NameTypeDescription
sharesuint256Amount of shares to redeem.
receiveraddressAddress to receive the spaToken.
owneraddressAddress whose shares will be burned.

Returns

NameTypeDescription
assetsuint256Amount of spaToken withdrawn.

name

Returns the name of the token.

function name() public view override(ERC20Upgradeable, IERC20Metadata) returns (string memory);

Returns

NameTypeDescription
<none>stringThe name of the token.

symbol

Returns the symbol of the token.

function symbol() public view override(ERC20Upgradeable, IERC20Metadata) returns (string memory);

Returns

NameTypeDescription
<none>stringThe 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

NameTypeDescription
assetsuint256Amount of spaToken.

Returns

NameTypeDescription
<none>uint256The equivalent shares.

convertToAssets

Converts an amount of shares to the equivalent amount of spaToken.

function convertToAssets(uint256 shares) public view override returns (uint256);

Parameters

NameTypeDescription
sharesuint256Amount of shares.

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
owneraddressAddress of the account.

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
assetsuint256Amount of spaToken to deposit.

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
sharesuint256Amount of shares to mint.

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
sharesuint256Amount of shares to redeem.

Returns

NameTypeDescription
<none>uint256The number of assets that would be withdrawn.

Errors

ZeroAmount

error ZeroAmount();

InsufficientAllowance

error InsufficientAllowance();