Vanna Account Manager
Overview
The AccountManager contract is a core component of the Vanna protocol. It facilitates the creation and management of user accounts, allowing the users to interact with the protocol by performing actions such as opening, closing accounts, depositing, withdrawing, borrowing, repaying loans, and managing risk. It also interacts with external systems like the RiskEngine, Controller, and token contracts for various operations.
External Functions
init
function init(IRegistry _registry) external;Initializes the contract with the provided registry address. This function can only be invoked once.
Parameters:
_registry: The address of theIRegistrycontract.
initDep
function initDep() external adminOnly;Initializes the external dependencies of the contract by assigning the addresses for the RiskEngine, Controller, AccountFactory, and TrackToken contracts.
openAccount
function openAccount(address owner) external nonReentrant whenNotPaused returns (address);Opens a new account for a user. If the user has inactive accounts, it reuses one, otherwise, a new account is created. The account is then activated.
Parameters:
owner: The address of the user who will own the newly opened account.
Returns:
The address of the newly opened or reused account.
closeAccount
Closes a specified account for a user. An account can only be closed if it has no outstanding debt. The account is then deactivated.
Parameters:
_account: The address of the account to be closed.
depositEth
Deposits ETH into an account by first wrapping it into WETH and transferring it to the account.
Parameters:
account: The address of the account to deposit ETH into.
withdrawEth
Withdraws a specified amount of ETH from the account to the owner, ensuring the account remains healthy.
Parameters:
account: The address of the account to withdraw from.amt: The amount of ETH to withdraw.
deposit
Deposits a specified token into an account, provided the token is allowed as collateral.
Parameters:
account: The address of the account to deposit the token into.token: The address of the token to deposit.amt: The amount of the token to deposit.
withdraw
Withdraws a specified amount of token from the account to the owner.
Parameters:
account: The address of the account to withdraw from.token: The address of the token to withdraw.amt: The amount of the token to withdraw.
borrow
Borrows a specified amount of token from the protocol and transfers it to the account.
Parameters:
account: The address of the account to borrow from.token: The address of the token to borrow.amt: The amount of token to borrow.
repay
Repays a specified amount of loan from the account to the protocol.
Parameters:
account: The address of the account to repay the loan from.token: The address of the token to repay.amt: The amount of token to repay.
liquidate
Liquidates an account that is unhealthy according to the RiskEngine.
Parameters:
account: The address of the account to be liquidated.
approve
Approves a spender to transfer a specified amount of token from the account.
Parameters:
account: The address of the account.token: The address of the token to approve.spender: The address of the spender.amt: The amount of token to approve.
exec
Executes external calls on behalf of the account. The target contract must be allowed by the controller.
Parameters:
account: The address of the account performing the execution.target: The addresses of the contracts to interact with.amt: The amount of ETH to send to the target contract.data: The data for the contract interaction.
settle
Settles an account by repaying all the loans.
Parameters:
account: The address of the account to settle.
getInactiveAccountsOf
Fetches a list of inactive accounts associated with a user.
Parameters:
user: The address of the user.
Returns:
A list of inactive accounts associated with the user.
Internal Functions
_updateTokensOut
Updates the list of tokens held by an account when assets are added or modified.
Parameters:
account: The address of the account.tokensOut: An array of token addresses that have been added to the account.
_updateTokensIn
Updates the list of tokens held by an account when assets are added or modified.
Parameters:
account: The address of the account.tokensIn: An array of token addresses that have been added to the account
Last updated