Skip to main content

Ticks

Pool Tick Structure

To facilitate the swapping of Loan Tokens and Fixed Tokens, each pool implements an Interest Rate Automated Market Maker (IR-AMM). Each fixed-rate pool's IR-AMM consists of a set of discrete interest rate ticks. The tick structure for a given pool is determined by the bpsPerTick and maxTick parameters.

  • bpsPerTick represents the interest rate spacing between two adjacent ticks. One basis point (BPS) equals 0.01% or one one-hundredth of one percent. The bpsPerTick parameter dictates the granularity of tradable interest rates in the AMM and sets the fee paid by swappers. For example, if bpsPerTick is set to 25 BPS, the fee on every swap will be 25 BPS of the annualized interest rate.
  • maxTick defines the upper boundary of tick indices that the pool can utilize, representing the maximum tick index where liquidity can be placed or swaps can be executed. The highest possible maxTick value for a pool is 111.

For instance, if a pool has bpsPerTick set to 100 (1%) and maxTick set to 14, users can swap at discrete interest rates up to 14%.

Tenor Fixed Tokens

Interest rate ticks

Each tick can hold a balance of Loan Tokens and/or Fixed Tokens on behalf of liquidity providers. The IR-AMM has the following structure:

  • Fixed Tokens are positioned on the lower ticks of the IR-AMM (left side of the illustration below). As lenders swap Loan Tokens for Fixed Tokens (e.g., swapping USDC for Fixed USDC 1Y), the interest rates decrease.
  • Loan Tokens are positioned on the higher ticks of the IR-AMM (right side of the illustration below). As borrowers swap Fixed Tokens for Loan Tokens, the interest rates increase.

Tenor Ticks Tokens

Tick Bitmaps

Tick bitmaps are a core component of the pool's internal tracking, serving as efficient data structures to track which discrete interest rate ticks are active (i.e., where liquidity or limit orders exist). The protocol maintains two separate bitmaps:

  • Bid Bitmap: Used to identify the highest tick with a positive balance of Fixed Tokens. This tick represents the highest rate at which a user can swap Loan Tokens (e.g., USDC) for Fixed Tokens. The bid bitmap also tracks all ticks containing Fixed Tokens, ensuring that swaps navigate active ticks without looping through empty ones.

  • Ask Bitmap: Used to identify the lowest tick with a positive balance of Loan Tokens. This tick represents the lowest rate at which a user can swap Fixed Tokens for Loan Tokens. Like the bid bitmap, the ask bitmap tracks all ticks containing Loan Tokens, optimizing swap efficiency.

How Tick Bitmaps Work

  1. Activation

    • When liquidity is added or a limit order is placed at a specific tick, the corresponding bitmap is updated via a setTick operation:
      • A limit order on the borrow side invokes bidBitmap.setTick(tick), marking the tick as active.
      • A limit order on the lend side updates the ask bitmap via askBitmap.setTick(tick).
  2. Lookup Efficiency Tick bitmaps provide constant-time lookup functions, such as bestBid and bestAsk, which quickly identify the most favorable tick for executing swaps:

    • _bestBid: Identifies the highest active tick with a positive Fixed Token balance.
    • _bestAsk: Identifies the lowest active tick with a positive Loan Token balance.
  3. Dynamic Updating & Clearing

    • As liquidity is withdrawn or limit orders are partially or fully filled, internal methods (e.g., _clearTickInBitmaps) check if a tick's associated balances reach zero. If so, the tick is removed using the clearTick function.
    • During swap operations, if a tick is exhausted:
      • _moveAskTick clears the current tick from the ask bitmap and finds the next active tick.
      • _moveBidTick clears the current tick from the bid bitmap and finds the next active tick.

Benefits of Tick Bitmaps

Maintaining tick bitmaps allows the protocol to:

  • Avoid expensive iteration over a large range of ticks by directly jumping to the next active tick.
  • Reduce computational overhead and, consequently, gas costs during swaps and liquidity operations.

This efficient structure enhances the performance and scalability of the Interest Rate AMM, ensuring optimal execution of swaps and liquidity provision.