Key Concepts & Parameters

StableSwap Invariant

At the heart of SPA is a Curve-style invariant equation. Simply, the invariant for two tokens X and Y is:

A * (x + y) + D − A * D  =  D^3  /  (4 * x * y)

Where:

  • A is the amplification coefficient.

  • x, y are the current pool balances of token X and token Y (normalized).

  • D is the invariant (a single number solved by root‐finding).

Key points:

  • When A is large, the curve is flatter near the center, giving minimal slippage for small trades.

  • When A is small, the curve behaves more like an ordinary constant-product AMM, allowing larger trades but higher slippage.

  • The pool continually solves for D to keep (x,y) on the stable-swap curve, except when a fee is charged.

Amplification Coefficient A

The Amplification Coefficient (A) is a core parameter in Tapio's StableSwap implementation that controls how the pricing curve responds to trades and imbalances.

Key Properties:

  • Acts as a scaling factor in the StableSwap invariant equation

  • Determines pool behavior during balanced and imbalanced states

  • Higher A creates flatter curves with minimal slippage for small trades

  • Lower A allows larger price adjustments with higher slippage

Governance and Updates:

  • A adjustments occur through the RampAController contract under Curator governance

  • All changes implement time-delayed transitions to prevent parameter manipulation

  • Changes must respect bounds defined in the Parameter Registry

  • Current A value accessible via SPA contract's getA() method

Buffer

The buffer system is a protective mechanism that maintains LP token reserves to handle protocol imbalances and bad debt scenarios. Unlike user-facing explanations, developers need to understand the technical implementation and state management.

Technical Implementation:

  • Buffer maintains a separate LP token balance (bufferAmount) distinct from circulating supply

  • Buffer percentage (bufferPercent) determines allocation ratio for incoming fees and yield

  • Bad debt tracking (bufferBadDebt) records deficit amounts when buffer capacity is exceeded

  • All buffer operations occur during LP token supply adjustments and fee collection events

State Management:

  • Buffer Addition: Incoming fees first repay outstanding bad debt, then increase buffer reserves

  • Supply Removal: Deficit amounts are recorded as bad debt when buffer cannot cover losses

  • Supply Addition: New yield prioritizes bad debt repayment before buffer allocation and LP rewards

  • Automatic Rebalancing: Buffer operations sync with StableSwap invariant calculations during user interactions

Parameter Change Handling: The buffer system automatically manages value fluctuations that occur during governance parameter adjustments:

  • A Coefficient Changes: When RampAController modifies A, system recalculates StableSwap invariant D

  • Value Stabilization: Buffer absorbs D increases by receiving excess value, or covers D decreases by providing deficit coverage

  • Token Holder Protection: Prevents governance parameter changes from directly affecting circulating token supply

Contract Interactions:

  • Buffer operations are handled within LP Token contract during mint/burn cycles

  • SPA contracts trigger buffer updates through fee collection and yield distribution

  • Buffer state is queryable but not directly modifiable by external contracts

  • Governance can adjust buffer percentage through Keeper-mediated parameter updates

Last updated