Levva Vault Liquidity Balancing
Learn how Levva Vault Liquidity Balancing is working.
General
The balancer fetches a list of all existing vaults from the database (they appear in the database after an event from the smart contract), excluding the disabled ones (where the DisabledAt
field in the database is manually set to a specific date). Then filters them according to the balancer settings EnabledVaults
from appsettings
. It iterates through all vaults and performs rebalancing for each vault.
Balancing
The balancer iterates over the protocols supported by the vault (e.g., Marginly, Aave, Etherfi), generating arguments for a rebalancing transaction for each as needed. The need for rebalancing is determined by the following settings:
For Marginly
The Balancer adds/removes liquidity based on the target percentage set in the configuration (currently 60%). The Balancer checks pool utilization levels: when depositing, it adds to the pool with the highest utilization (if all utilization levels are equal, it distributes evenly across all pools). When withdrawing, The Balancer withdraws in ascending order of utilization, starting with the pools with the lowest utilization.
For Aave
The Balancer also relies on the target percentage from the settings (currently 30%). When depositing, The Balancer simply deposits into the protocol, and when withdrawing, The Balancer withdraws from it.
For Etherfi
The Balancer similarly follows the target percentage from the settings (currently 30%); when depositing, The Balancer simply adds funds to the protocol, and when withdrawing, The Balancer sends a withdrawal request and records this request in the database to avoid attempting to withdraw the same amount again during future withdrawals or rebalancing.
For all protocols
The Balancer checks the current balance in the protocol and does not attempt to withdraw more than that balance. For Aave, there is also a specific condition to withdraw the entire balance if the difference between the current balance and the rebalancing target is small (the delta is specified as an absolute value in the balancer settings).
If a rebalancing transaction is generated for at least one protocol, it executes the transaction. If not, it skips the rebalancing iteration for the current vault. Further rebalancing occurs on a scheduled basis.
Last updated