Skip to main content

WithdrawProxy

To ensure that PublicVaults always have sufficient funds to cover new loan originations, liquidity providers must signal that they wish to withdraw funds at least one epoch in advance. When the first liquidity provider signals a withdraw for the next epoch, a WithdrawProxy is deployed for that epoch. The liquidity provider then burns their VaultTokens with the WithdrawProxy and receives an equal amount of WithdrawTokens for that WithdrawProxy. Any other withdrawing liquidity providers for the next epoch may burn their VaultTokens with that same WithdrawProxy to receive WithdrawTokens.

At the next epoch boundary, the PublicVault records the value of the burned VaultTokens for each withdrawing liquidity provider in withdrawReserve. For example, if an LP had burned 10 VaultTokens halfway through the previous epoch, and each VaultTokens is now worth 1.5 WETH, the PublicVault would add 15 WETH to the withdrawReserve. If there are any active liquidations at the epoch boundary, WithdrawProxy will have been set as the liquidated liens' payee to collect auction funds. In this scenario, the PublicVault would record the ratio between withdrawing and remaining funds as the liquidationWithdrawRatio. If 100 WETH is being withdrawn (a withdrawReserve of 100) and 400 WETH remains in the vault, auctioned funds will be split between the PublicVault and the WithdrawProxy in a 1:5 ratio.

Liquidations which are paid out after a scheduled withdraw will be split between LPs and the Vault in a 1:5 ratio.

The PublicVault pauses all loan originations until the withdrawReserve is met, either from loan repayments or recovered auction funds. The PublicVault then begins sending funds to the WithdrawProxy for that epoch. WithdrawToken holders can burn their tokens in exchange for the funds held by the WithdrawProxy. Since loans in the previous epoch had been capped to end before the end of the next epoch, the withdrawReserve should be met if no liquidations are triggered near the end of the epoch.

If a loan is liquidated and the auction end is scheduled after the epoch boundary when the WithdrawProxy begins accumulating funds for LPs to withdraw, then the payee for the liquidated LienToken is permanently set to the address of the WithdrawProxy to collect all auction funds. If any other LienTokens are liquidated before the end of the current epoch, the payee for those LienTokens are also set to the WithdrawProxy. The reserve value for all auctioned liens is tracked by the WithdrawProxy. Once all auctioned funds are recovered, the funds collected from auctions into the WithdrawProxy are proportionally split between withdrawing and remaining LPs (the WithdrawProxy and the PublicVault). This withdraw ratio is determined at the epoch boundary, when the funds owed to all withdrawing LPs is calculated.