HardVault
The Hard Vault contract is designed to hold LP (Liquidity Provider) tokens as collateral. The contract is ERC1155 compliant, which means that the underlying LP tokens are identified by casted tokenId from token address.
State Variables
The Hard Vault contract has the following state variables:
config
: The address of the protocol configuration contract.
Events
The Hard Vault contract emits the following events:
Deposited
: Emitted when a user deposits LP tokens into the vault.Withdrawn
: Emitted when a user withdraws LP tokens from the vault.
Functions
initialize
The initialize
function is an initializer function that is called when the contract is deployed. It initializes the state variables of the contract.
Parameters:
_config
(IProtocolConfig): The address of the protocol configuration contract.
_encodeTokenId
The _encodeTokenId
function takes an underlying token address and encodes it into a token ID.
Parameters:
uToken
(address): The address of the underlying token.
_decodeTokenId
The _decodeTokenId
function takes a token ID and decodes it into an underlying token address.
Parameters:
tokenId
(uint): The token ID to decode.
balanceOfERC20
The balanceOfERC20
function returns the balance of an underlying ERC20 token for a given user.
Parameters:
token
: The address of the ERC20 token.user
: The address of the user.
getUnderlyingToken
The getUnderlyingToken
function returns the underlying ERC20 token address for a given ERC1155 token ID.
Parameters:
tokenId
: The ERC1155 token ID.
deposit
The deposit
function allows a user to deposit underlying assets into the vault and issue share tokens.
Parameters:
token
: The address of the underlying token to deposit.amount
: The amount of underlying tokens to deposit.
withdraw
The withdraw
function allows a user to withdraw underlying assets from the vault.
Parameters:
token
: The address of the underlying token to withdraw.shareAmount
: The amount of share tokens to redeem.
Last updated