Liquidator
The Liquidator module is responsible for collecting reward tokens from vaults, swapping them and donating back the purchased tokens to the vaults. Typically, this is swapping reward tokens to vault assets which are donated back to the vaults to increase their assets per share. For example, swapping $CRV earned in a Curve pool back to a vault asset like $DAI. There can be multiple reward tokens collected from a vault and different target tokens can be specified for each reward token.
The Liquidator's main task is to batch the swapping of rewards collected from multiple vaults. This socializes the gas costs in swapping rewards across multiple vaults.
The Liquidator uses a Swapper module to do on-chain token swaps. A swapper typically uses a swap aggregator like 1Inch or CowSwap but can use decentralized exchanges like Uniswap or Balancer.
Liquidator Contracts
Contract Interface
See the metavaults github repository for contract diagrams and process diagrams.
Variables
syncSwapper
Contract that implements on-chain swaps
asyncSwapper
Contract that implements on-chain async swaps
Functions
collectRewards
The keeper or governor can collect different rewards from a list of vaults. The Liquidator calls each vault to collect their rewards. The vaults transfer the rewards to themselves first and then the Liquidator transfers each reward from each vault to the Liquidator. Vault rewards can be collect multiple times before they are swapped for the vault asset. It's the responsibility of the Liquidator to account for how many rewards were collected from each vault.
Parameters
Return Values
donateTokens
The protocol Governor or Keeper can send the purchased assets in a batch back to the vaults. The order of the input elements is important to aggreate multiple deposits of the same asset to the vault.
ie. Vault 1 has Reward A, Reward B, both rewards are swapped for the same donated Token T.
donateTokens([rewardA.address, rewardB.address], [tokenT.address, tokenT.address], [vault1.Address, vault1.Address] Only triggers one deposit of Token T to the underlying vault
Parameters
Return Values
claimAssets
Vault claims the purchased assets in a batch back. Separate transactions are required if a vault has multiple reward tokens.
Parameters
Return Values
pendingRewards
Parameters
Return Values
pendingVaultRewards
Parameters
Return Values
purchasedAssets
Parameters
Return Values
swap
Swap the collected rewards to desired asset.
Parameters
initiateSwap
Swap the collected rewards to desired asset. Off-chain order must be created providing a "receiver" of the swap.
Parameters
initiateSwaps
Swaps the collected rewards to desired assets. Off-chain order must be created providing a "receiver" of the swap.
Parameters
settleSwap
settles the last batch swap of rewards for assets. initiateSwap
must be called and the swap executed before settleSwap
.
Parameters
settleSwaps
Swaps the collected rewards to desired assets. initiateSwap must be called first before settleSwap
Parameters
setSyncSwapper
Sets a new implementation of the DEX syncSwapper.
Parameters
setAsyncSwapper
Sets a new implementation of the DEX asyncSwapper.
Parameters
rescueToken
Governor rescues tokens from the liquidator in case a vault's donateToken is failing.
Last updated