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 theIRegistry
contract.
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
function closeAccount(address _account) public nonReentrant onlyOwner(_account);
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
function depositEth(address account) external payable nonReentrant whenNotPaused onlyOwner(account);
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
function withdrawEth(address account, uint256 amt) external nonReentrant onlyOwner(account);
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
function deposit(address account, address token, uint256 amt) external nonReentrant whenNotPaused onlyOwner(account);
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
function withdraw(address account, address token, uint256 amt) external nonReentrant onlyOwner(account);
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
function borrow(address account, address token, uint256 amt) external nonReentrant whenNotPaused onlyOwner(account);
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
function repay(address account, address token, uint256 amt) external nonReentrant onlyOwner(account);
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
function liquidate(address account) external nonReentrant;
Liquidates an account that is unhealthy according to the RiskEngine
.
Parameters:
account
: The address of the account to be liquidated.
approve
function approve(address account, address token, address spender, uint256 amt) external nonReentrant onlyOwner(account);
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
function exec(address account, address[] calldata target, uint256 amt, bytes[] calldata data) external nonReentrant onlyOwner(account);
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
function settle(address account) external nonReentrant onlyOwner(account);
Settles an account by repaying all the loans.
Parameters:
account
: The address of the account to settle.
getInactiveAccountsOf
function getInactiveAccountsOf(address user) external view returns (address[] memory);
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
function _updateTokensOut(address account, address[] memory tokensOut)
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
function _updateTokensIn(address account, address[] memory tokensIn) internal;
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