Closure
A Closure handles deposits/withdrawals and swaps for a particular set of tokens and can be thought of as an Multi-swap AMM in and of itself. Each closure is identified by a ClosureId which specifies exactly which tokens are in the set.
Closure Value
They track a target balance for each of the tokens in its set, and what the actual balance is. The combination of the two with parameters from Simplex tell us the amount of "value" held in each token in this Closure. The total sum of the value will always be equal to where N is the number of tokens in the closure and target the is the target balance.
Closures allow users to add value into the pool (deposit liquidity) by adding all the tokens in equal proportion or a single token (by specifying the value desired or the tokens deposited).
Closures also allow traders to exchange one token for another in its set as long as the "value" exchange is equal.
Uses can remove their value from a closure without removing their assets by unstaking and this awards them value tokens which can be redeemed for value in any closure in the overall pool.
The Closure tracks the overall value staked in the pool, as well as the bgtValue staked in the pool. A portion of the overall value is bgt value which are units of value that want to exchange their fee earnings for BGT instead.
Balances
The balances of each token for a closure are tracked internally and deposited into Vertices which then forwards those deposits into a vault and helps the balance grow over token.
After the balance grows, the surplus of tokens cannot be compounded back into the pool without growing the target. So instead of compounding into the LP, the surplus is left in the vault (but moved into the Reserve allocation) and attributed as fee earnings to depositors.
There are safety guidelines for the token balances that prevent a balance from getting too close to 0, and that prevent the closure from accumulating too much of one token. If a token balance has grown to twice the target balance, future deposits are no longer accepted for that token.
Earnings
Earnings come from the surplus growth in our token balances from Vertices, from Swap fees, and from deposit/withdrawal fees for users opting to use single sided actions (which are effectively swaps).
Earnings for non-bgt accumulating value units are kept in the original token but deposited into their respective Vertex to continue to grow. Thus their earnings are tracked as shares in the Reserve which they can redeem upon withdrawal.
BGT accumulating value units have their fees immediately exchanged for a liquid wrapper on BGT through the BGTExchanger. Any unspent fees (because there is no exchange rate available or the exchanger has run out of the liquid BGT) are then deposited into the Reserve to grow and can be redeemed by bgt value units in the future.
Right now, for simplicity's sake, if there is unstaked value then the excess earnings from that unstaked value are split among all staked value. But in the future, this will be properly moved out to give yield for value token holders.
Last updated