WLPToken

Git Source

Inherits: ERC4626Upgradeable

It's an ERC4626 standard token that represents the account's share of the total supply of lpToken tokens. WLPToken token's balance only changes on transfers, unlike lpToken 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 lpToken tokens and mints wlpToken in return. Then the user unwraps, the contract burns user's wlpToken and sends user locked lpToken in return.

State Variables

lpToken

ILPToken public lpToken;

Functions

initialize

function initialize(ILPToken _lpToken) public initializer;

deposit

Deposits lpToken into the vault in exchange for shares.

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

Parameters

NameTypeDescription
assetsuint256Amount of lpToken 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 lpToken deposited.

withdraw

Withdraws lpToken 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 lpToken to withdraw.
receiveraddressAddress to receive the lpToken.
owneraddressAddress whose shares will be burned.

Returns

NameTypeDescription
sharesuint256Burned shares corresponding to the assets withdrawn.

redeem

Redeems shares for lpToken.

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

Parameters

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

Returns

NameTypeDescription
assetsuint256Amount of lpToken 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 lpToken to the equivalent amount of shares.

function convertToShares(uint256 assets) public view override returns (uint256);

Parameters

NameTypeDescription
assetsuint256Amount of lpToken.

Returns

NameTypeDescription
<none>uint256The equivalent shares.

convertToAssets

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

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

Parameters

NameTypeDescription
sharesuint256Amount of shares.

Returns

NameTypeDescription
<none>uint256The equivalent lpToken.

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 lpToken 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 lpToken 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();