block-quote On this pagechevron-down
copy Copy chevron-down
Risk Management The RiskEngine contract determines whether a user can safely borrow or withdraw based on their asset-to-debt ratio. It helps the Vanna protocol maintain solvency by ensuring only healthy accounts can interact with liquidity.
Copy function initDep () external adminOnly Initializes dependent contracts like the Oracle and AccountManager via the Registry.
Risk Check Functions
isBorrowAllowed
Copy function isBorrowAllowed (
address account ,
address token ,
uint amt
) external returns ( bool ) Checks if a user account is allowed to borrow a specific token amount.
Parameters:
account: The address of the user’s smart account.
token: The token the user wants to borrow (ERC20 address).
amt: The amount of the token to be borrowed (in token's smallest units).
Returns:
true if borrowing is allowed, false otherwise.
isWithdrawAllowed
Checks if a user account is allowed to withdraw a specific token amount.
Parameters:
account: The address of the user’s smart account.
token: The token the user wants to withdraw.
amt: The amount of the token to withdraw (in token's smallest units).
Returns:
true if withdrawal is allowed, false otherwise.
isAccountHealthy
Checks if a user's account has a healthy balance-to-borrow ratio.
Parameters:
account: The user account address to check.
Returns:
true if the account is healthy, false otherwise.
Returns the total USD value (in wei) of a user’s assets.
Parameters:
account: Address of the user account.
Returns:
Total balance in USD (wei precision).
Returns the total USD value (in wei) of a user’s debt.
Parameters:
account: Address of the user account.
Returns:
Total borrows in USD (wei precision).
Internal Helpers
Converts the token amount into a USD value using the Oracle.
Parameters:
token: Address of the token being valued.
amt: Amount of the token.
account: Account requesting the price (used by Oracle for context).
Returns:
USD value of the token amount (in wei).
Calculates the total USD value of all assets held by a user's account.
Parameters:
account: The address of the user account.
Returns:
Total asset value in USD (in wei).
Calculates the total USD value of all borrows held by a user's account.
Parameters:
account: The address of the user account.
Returns:
Total borrow value in USD (in wei).
_isAccountHealthy
Checks if the provided balance and borrow values meet the threshold ratio.
Parameters:
accountBalance: The user's total USD balance (wei).
accountBorrows: The user's total USD borrows (wei).
Returns:
true if balance/borrows > threshold (1.1e18), otherwise false.
Last updated 11 months ago