Yield Basis Action Flow Overview
This document provides an overview of how assets, fees, and interest rates flow through the YB system. Understanding these flows is crucial for developers, users, and integrators.
Asset Flow - Where Assets Go
When users deposit assets (e.g., cbBTC, WBTC), here's what happens:
- User deposits the asset → LT contract receives the asset.
- LT pulls the user-specified
debt
amount of stablecoin from the AMM’s pre-funded buffer (the AMM buffer is funded via the Factory’s stablecoin allocation to the AMM). - LT adds liquidity to the Curve CryptoPool with [debt, assets].
- Curve mints LP tokens directly to the AMM; the AMM updates its leveraged position.
- LT mints LT shares to the user, representing a pro-rata claim on the AMM position.
Note: For L = 2×, the AMM enforces a safety band on debt vs. collateral value (roughly 6.25%–53.125%); extreme
debt
choices (including0
, in most cases) will revert if the combined post-deposit state falls outside this band.
Interest Rate & Fee Flow
Interest accrues from the crvUSD CDP line in the AMM over time. The core multiplier is:
# AMM.vy
def _rate_mul() -> uint256:
return unsafe_div(self.rate_mul * (10**18 + self.rate * (block.timestamp - self.rate_time)), 10**18)
- Who sets the rate: Admin sets the interest rate via LT, which forwards it to the AMM (
LT.set_rate → AMM.set_rate
). It’s bounded byMAX_RATE
(≤ 100% APR). - When fees are realized: On every AMM trade (and on explicit calls), the AMM realizes accrued interest via
_collect_fees()
and transfers available stablecoins to LT.
Usage of the collected interest rate fees in LT.vy
:
LT
reads its stablecoin balance (from AMM fee transfers).- If the balance > 0, LT refuels (rebalances) the Curve pool via
add_liquidity(..., donation=True)
. - This “donates” funds to the pool (no LP minted to LT) and makes the pool's liquidity more concentrated.
# LT.vy
def _distribute_borrower_fees(discount: uint256):
amount = STABLECOIN.balanceOf(self)
if amount > 0:
min_amount = (10**18 - discount) * amount // CRYPTOPOOL.lp_price()
CRYPTOPOOL.add_liquidity([amount, 0], min_amount, empty(address), True) # donation=True
This keeps 100% of interest fees flowing back into the underlying Curve market to support depth and pricing.