Tapio is a liquidity aggregator that acts as the middle layer between self-pegging assets and downstream DeFi applications. Liquidity is a cornerstone of DeFi and represents the most significant use case for self-pegging assets when paired with complementary tokens. However, once these assets are utilized in liquidity pools and the resulting SPA token is obtained, the journey often stalls, leaving limited options for further use. Additionally, the ecosystem faces heavy fragmentation of self-pegging asset liquidity, with individual protocols employing distinct reward mechanisms, token models, and architectures—resulting in an increasingly fragmented and inefficient landscape.
Introducing the Tapio SPA Token—the first utility-focused SPA token designed for the self-pegging asset ecosystem. Serving as both a liquidity aggregator and an arbitrage hub, it fundamentally operates as a rebasing SPA token that represents diverse stable pools within Tapio Finance. These pools include pairings between self-pegging assets and their complements, such as:
- stETH-ETH
- USDT-USDC
- rETH-wstETH
Unlike traditional liquidity pools in DEXs, the Tapio SPA Token you receive after depositing assets is pegged to the underlying assets and can be seamlessly used within DeFi or as a medium of exchange, just like any other asset. The Tapio SPA Token also accrues underlying token rewards and fees generated by the pools—such as swaps, redemptions, and more—delivering an attractive real yield APR even before engaging in further DeFi activities.
For added flexibility, the Tapio SPA Token can be wrapped into a wrapped SPA token, adopting an "interest rate" model that simplifies integration and cross-chain usage.
As a synthetic asset protocol, Tapio Finance dynamically adjusts the pricing curves of self-pegging asset pools, enabling efficient swaps and arbitrage opportunities. This ensures the stability of tapETH while unlocking excellent use cases for Tapio's liquidity pools.
In Tapio, users can:
- Create new AMM pools using Factory.
- Mint, swap and redeem tokens in pools.
- Wrap and unwrap SPA tokens.
The protocol is built using modular, upgradeable components and is based on CurveFi's StableSwap algorithm. This design ensuring the system can adapt and scale with evolving protocol requirements.
Tapio uses several core contracts to facilitate management of pools and it's functionality:
The SelfPeggingAssetFactory contract automates the deployment of new pools, simplifying their creation and management. All pools deployed through the Factory are governed by Pike's governance system.
The SelfPeggingAsset conttract represents a AMM pool. It allows users to swap, mint and redeem tokens of the pool. It implements the StableSwap algorithm.
The SPAToken is an ERC20 rebase token issued by StableSwap pools to liquidity providers.
SPAToken balances are dynamic and reflect the holder's share of the total SPAToken supply managed by the protocol. Since account shares are not normalized, the contract tracks the total sum of all shares to compute each account's token balance using the formula:
shares[account] * _totalSupply / _totalShares
Here, _totalSupply represents the total amount of SPAToken managed by the protocol.
The WSPAToken is an ERC4626 standard token that represents an account's share of the total SPAToken supply. Unlike SPAToken, which dynamically updates balances based on staking rewards and swap fees, WSPAToken balances only change during transfers.
Designed as a "power user" token, WSPAToken caters to DeFi protocols that do not support rebasable tokens. The contract serves as a trustless wrapper, accepting SPAToken and minting WSPAToken in return. When users choose to unwrap, the contract burns their WSPAToken and returns the corresponding locked SPAToken.
This is a list of the most frequently needed commands.
Build the contracts:
$ forge buildDelete the build artifacts and cache directories:
$ forge cleanCompile the contracts:
$ forge buildGet a test coverage report:
$ forge coverageDeploy to Base Testnet and automatically verify contracts:
$ forge script ./script/Testnet.s.sol -vvv --rpc-url basesepolia --broadcast --verifyBefore deploying make sure you configure the neccessary variables in .env file. To just test the scripts with just a
dry run remove the --broadcast flag.
Here is an example on how to verify a contract on base sepolia:
$ forge verify-contract <contract-address> <contract-name> --watch --etherscan-api-key <basescan-api-key> --chain-id 84532 --constructor-args <encoded-constructor-args>You can find the contract name and constructor args in the broadcast directory. To encode the constructor args you can use: https://abi.hashex.org/
Format the contracts:
$ forge fmtGet a gas report:
$ forge test --gas-reportLint the contracts:
$ yarn run lintRun the tests:
$ forge testGenerate test coverage and output result to the terminal:
$ yarn run test:coverageGenerate test coverage with lcov report (you'll have to open the ./coverage/index.html file in your browser, to do so
simply copy paste the path):
$ yarn run test:coverage:reportsrc/
├── SPAToken.sol
├── SelfPeggingAsset.sol
├── SelfPeggingAssetFactory.sol
├── WSPAToken.sol
├── interfaces
│ ├── IExchangeRateProvider.sol
│ └── ISPAToken.sol
├── misc
│ ├── ConstantExchangeRateProvider.sol
│ ├── ERC4626ExchangeRate.sol
│ ├── OracleExchangeRate.sol
│ └── reth
│ ├── RocketTokenExchangeRateProvider.sol
│ └── RocketTokenRETHInterface.sol
└── mock
├── MockERC4626Token.sol
├── MockExchangeRateProvider.sol
├── MockOracle.sol
├── MockToken.sol
├── MockTokenERC4626.sol
└── WETH.sol
This project is licensed under MIT.