Architecture
Tapio is an asset protocol that enables the creation of Self-Pegging Assets (SPAs) through advanced StableSwap AMM. Tapio features sophisticated governance mechanisms, dynamic fee structures, and built-in risk management systems, all accessible through a suite of interconnected smart contracts designed for seamless integration.
The following diagram illustrates the smart contract architecture of Tapio, showcasing the key components and their relationship.

Each component in this architecture serves a specific purpose in creating and managing Self-Pegging Assets. The following sections provide an overview of these core contracts and their roles within Tapio.
SelfPeggingAssetFactory
SPA Factory serves as the central deployment mechanism for creating a complete Tapio SPA setup. The contract enables permissionless creation of new SPA pools while managing global parameter defaults and ensuring proper initialization of all components.
Core capabilities include:
Single-transaction deployment of complete SPA Systems (SPA, SPAToken, WSPAToken, RampAController, ParameterRegistry, Keeper)
Global defaults management for fees, amplification coefficient, and buffer percentage across all deployments
UUPS upgradeable pattern for protocol-wide improvements
Automatic governance setup with role assignment and ownership transfers to appropriate contracts
Isolated contract sets per SPA deployment with independent governance structures
Permissionless pool creation accessible to any user via
createPool()
function
This design ensures consistent, secure deployment of SPA infrastructure while maintaining isolation between different pool instances.
SelfPeggingAsset (SPA)
SPA is the core AMM contract that implements enhanced StableSwap functionality for correlated assets. SPA manages trading, liquidity provision, and fee collection while maintaining asset pegs through dynamic mechanisms.
Key responsibilities:
Execute token swaps using StableSwap algorithm with minimal slippage for correlated assets
Collect and distribute fees to SPA token holders through automated conversion and rebasing
Implement self-pegging mechanisms including volatility fees and off-peg multipliers for stability
SPA contracts serve as the trading engine that creates and manages Self-Pegging Assets while interfacing with governance contracts for parameter control.
SPAToken
SPA Token is a rebasing ERC20 contract that represents user shares in Tapio pools. SPA tokens automatically increase in balance as pools generate fees and underlying asset yields, providing direct yield accrual to holders.
Key responsibilities:
Manage share-based accounting for proportional pool ownership
Distribute collected fees through automatic rebasing mechanisms
Integrate with buffer system for loss protection and smooth yield distribution
SPA tokens serve as the primary interface between users and SPA yield generation, converting complex pool mechanics into familiar token ownership.
Wrapped SPA Token (WSPAToken)
WSPAToken is a non-rebasing ERC4626-compatible wrapper contract around SPA tokens that enables seamless integration with DeFi protocols. WSPAToken maintains fixed token balances while underlying value grows over time.
Key responsibilities:
Provide standard vault interfaces for lending protocols and DeFi integrations
Enable permissionless wrapping/unwrapping between SPA tokens and wSPA tokens
Maintain fixed token counts with growing underlying asset value for compatibility
WSPAToken bridges Tapio's rebasing mechanics with the broader DeFi ecosystem, ensuring SPAs work with existing protocols without custom integration.
RampAController
RampAController is a specialized contract responsible for managing gradual changes to the amplification coefficient (A) over configurable time periods. The contract implements safety guardrails to prevent extreme A value changes and market shocks through linear interpolation between target values.
Key architectural features include:
Beacon upgradeable pattern for protocol-wide updates
Owned by Keeper contract with role-based access control
Time-based interpolation supports both increasing/decreasing A values
Enhanced security features with additional constraints for small A values (A ≤ 2)
All governance interactions mediated through Keeper middleware - no direct contract access
SPA queries current A value during swap calculations for real-time pricing adjustments
Exchange Rate Providers
Exchange Rate Providers are specialized contracts that supply current exchange rates for each asset in Tapio pools relative to the reference token. These providers ensure accurate fee calculations and volatility tracking while maintaining security against manipulation.
Zap Contract
Zap contract is a stateless utility contract that simplifies user interactions by enabling complex multi-step operations in single transactions. Zap eliminates manual approval management and reduces transaction costs for common user flows.
Key responsibilities:
Execute multi-step operations in single transactions, including deposit-to-wrapped flows (zapIn) and unwrap-to-withdrawal flows (zapOut)
Handle intermediate approvals and transfers automatically for gas optimization
Provide single-asset redemption capabilities for improved user experience
Zap contracts operate without governance or state, focusing purely on user experience enhancement across the Tapio ecosystem.
Governance Contracts
Parameter Registry
Serves as a Immutable and critical policy-setting layer in the Tapio architecture by acting as a boundary enforcer defining safe operating parameters for SPA, and creating a trustless constraint system
Governor retains direct ownership of ParameterRegistry (through a timelock)
Even Governor can not bypass the constraints listed by Parameter Registry
Keeper contract is the main consumer of the Parameter Registry to check if actions being performed are following system constraints for reliable operations.
Keeper
Central governance middleware for Tapio protocol that Mediates interactions between governance roles and core contracts i.e updating the A value for stableswap formula.
Implements role-based access control to other contracts
Enforces hard caps and dynamic ranges on parameters adjustments
Controls access to critical parameters changes in SPA
Upgradeable design via UUPS — for easy-to-upgrade individual approach
Parameter changes checked against both relative and max bounds
Uses immutable
ParameterRegistry
for bounds reference
Last updated