Fee Vault
Last updated
Last updated
The Fee Vault is a contract that allows an admin to earn fees on funds supplied to Blend pools. The Fee Vault is designed for wallets or other integrating protocols that want to add an additional revenue stream based on their users' activity on Blend.
The Fee Vault works by being an intermediary between the Blend pool and the user. It tracks the interest generated by user deposits and determines what amount of that interest should be taken as a fee for the admin.
Each Fee Vault supports at most one Blend pool, but can support multiple assets (reserves) within the same Blend pool. The admin must enable a vault for each reserve they want to support. Each reserve vault is an -style vault that tracks interest generated by the users and enables the contract to fairly share that interest across all users.
The Fee Vault supports two types of fee modes, take rate and capped rate, and the fee mode and amount can be changed at any time.
In take rate mode, the vault takes a fixed percentage of the interest generated by the user deposits. For example, if the vaults earn 100 USDC in interest and the take rate is 10%, the Fee Vault will take 10 USDC as a fee for the admin, and users will earn 90 USDC.
In capped rate mode, the vault calculates how much interest should have been earned by the user deposits to reach the capped rate. If the vault generated more interest, the excess is taken as a fee for the admin.
For example, if the vault has a capped rate of 10% and the vault earns 12% (e.g. 120 USDC) over the period, the users will earn 100 USDC and the admin will take 20 USDC as a fee. If the vault only earns 8% (e.g. 80 USDC), the users will earn 80 USDC and the admin will take 0 USDC as a fee.
The core math of the vault is how rates and interest earned are calculated. In both fee modes, the vault tracks interest earned between update periods on the vault. That is, if a user interacted with the vault on block 100, and another user interacted with the vault on block 200, the vault will calculate the interest earned between block 100 and block 200, and then calculate the fee based on that interest.
For extremely high frequency interactions, like every block, this can lead to situations where rounding can start to impact fee calculations. The Fee Vault protects against this by rounding against the admin, such that rounding can never impact expected user earnings.
All calculations are done based on the last stored reserve vault, and the reserve's b_rate
for the current block. The vault data struct is shown below:
The bTokenAdminFees
is the amount of bTokens
that the admin is due from the vault. To apply this, the vault deducts the bTokenAdminFees
from the total_b_tokens
of the vault, adds it to the accrued_fees
of the vault, and sets the last_update_timestamp
to the current block timestamp.