Vanna Account
Overview
The Account
contract acts as a dynamic and distributed asset reserve that holds a user’s collateral and borrowed assets. It facilitates asset management and enables interactions with external contracts for seamless transactions. The contract is designed for integration into DeFi protocols that require secure and controlled asset management, particularly for leveraged positions.
getAssets
Description: Returns the list of ERC-20 assets (collaterals and borrows) associated with the account.
Signature:
function getAssets() external view returns (address[] memory)
Returns:
assets
: An array of asset addresses in the account.
getBorrows
Description: Returns the list of ERC-20 tokens that are borrowed by the account.
Signature:
function getBorrows() external view returns (address[] memory)
Returns:
borrows
: An array of borrowed asset addresses in the account.
addAsset
Description: Adds a given ERC-20 token to the
assets
list.Signature:
function addAsset(address token) external
Parameters:
token
: The ERC-20 token address to add to the assets list.
Modifiers:
accountManagerOnly
addBorrow
Description: Adds a given ERC-20 token to the
borrows
list.Signature:
function addBorrow(address token) external
Parameters:
token
: The ERC-20 token address to add to the borrows list.
Modifiers:
accountManagerOnly
removeAsset
Description: Removes a given ERC-20 token from the
assets
list.Signature:
function removeAsset(address token) external
Parameters:
token
: The ERC-20 token address to remove from the assets list.
Modifiers:
accountManagerOnly
removeBorrow
Description: Removes a given ERC-20 token from the
borrows
list.Signature:
function removeBorrow(address token) external
Parameters:
token
: The ERC-20 token address to remove from the borrows list.
Modifiers:
accountManagerOnly
hasNoDebt
Description: Returns
true
if the account has no borrowed assets, otherwise returnsfalse
.Signature:
function hasNoDebt() external view returns (bool)
Returns:
hasNoDebt
: A boolean indicating whether the account has no debt.
exec
Description: Executes a transaction with an external contract. The
accountManager
can use this function to interact with other contracts.Signature:
function exec(address target, uint amt, bytes calldata data) external returns (bool, bytes memory)
Parameters:
target
: The address of the external contract to interact with.amt
: The amount of Ether to send to the target contract.data
: The encoded function signature and parameters for the external contract.
Returns:
success
: A boolean indicating whether the transaction was successful.retData
: The data returned by the target contract.
sweepTo
Description: Transfers all assets (ERC-20 tokens and Ether) from the account to the specified address. After the transfer, the contract clears the
assets
list.Signature:
function sweepTo(address toAddress) external
Parameters:
toAddress
: The address to which all assets will be sent.
Modifiers:
accountManagerOnly
Internal Functions
Description: Removes a specific ERC-20 token from an array of addresses (used for removing assets or borrowed tokens).
Signature:
function _remove(address[] storage arr, address token) internal
Parameters:
arr
: The array of addresses (eitherassets
orborrows
).token
: The token address to remove from the array.
Last updated