Vault
Main entry point for minting and burning the protocol's synthetic tokens.
The Vault is the core contract of SIR Protocol. It uses a singleton architecture โ all vaults live in a single contract. Users interact with the Vault to create new vaults, mint/burn APE and TEA tokens, and query vault state.
The Vault inherits from TEA (the ERC1155 LP token contract) and deploys APE contracts (ERC20 clones) for each vault.
Chain differences:
mint()lock parameter: On MegaETH,mint()includes aportionLockTimeparameter that lets LPers reduce their minting fee by locking TEA. On Ethereum and HyperEVM this parameter does not exist.Native token: Send ETH with
mint()on Ethereum/MegaETH (WETH vaults), or HYPE on HyperEVM (WHYPE vaults). The contract auto-wraps the native token.Swap callback: Named
uniswapV3SwapCallbackon Ethereum/MegaETH,hyperswapV3SwapCallbackon HyperEVM.
initialize
initializeCreates a new vault. Permissionless โ anyone can call it. Deploys a new APE (ERC20) contract for the vault and initializes the Oracle for the token pair if needed. Reverts if the vault already exists.
function initialize(VaultParameters memory vaultParams) externalvaultParams
VaultParameters
The debt token, collateral token, and leverage tier identifying the new vault
Each unique combination of
(debtToken, collateralToken, leverageTier)creates a distinct vault with its own APE token.
mint
mintMints APE or TEA tokens by depositing collateral. Supports three deposit methods:
Collateral token โ set
collateralToDepositMin = 0Debt token (auto-swapped via Uniswap/HyperSwap/Kumbaya) โ set
collateralToDepositMin > 0as slippage protectionNative ETH/HYPE โ send value with the call (only for WETH/WHYPE vaults)
isAPE
bool
true to mint APE, false to mint TEA
vaultParams
VaultParameters
The vault to mint into
amountToDeposit
uint256
Amount of collateral (or debt token if collateralToDepositMin > 0) to deposit. Ignored when sending native ETH/HYPE.
collateralToDepositMin
uint144
Set to 0 when depositing collateral directly. When depositing debt token, this is the minimum collateral to receive from the swap (slippage protection).
deadline
uint40
Transaction deadline timestamp. Set to 0 to disable.
portionLockTime
uint8
MegaETH only. 0 = full fee (no lock), 255 = no fee (full lock period). Ignored for APE mints.
Returns: uint256 โ amount of APE or TEA tokens minted.
When minting with native ETH/HYPE,
msg.valueoverridesamountToDeposit. The contract wraps it to WETH/WHYPE automatically.
burn
burnBurns APE or TEA tokens and returns collateral to the caller.
isAPE
bool
true to burn APE, false to burn TEA
vaultParams
VaultParameters
The vault to burn from
amount
uint256
Amount of APE or TEA tokens to burn
deadline
uint40
Transaction deadline timestamp. Set to 0 to disable.
Returns: uint144 โ amount of collateral received.
On MegaETH, burning TEA will revert with
TEALockedif the caller's TEA position is still within its lock period.
getReserves
getReservesReturns the current reserves of a vault โ how much collateral belongs to APE holders vs TEA holders (LPs), and the current price.
vaultParams
VaultParameters
The vault to query
Returns: Reserves โ (reserveApes, reserveLPers, tickPriceX42)
vaultStates
vaultStatesReturns the raw on-chain state of a vault.
vaultParams
VaultParameters
The vault to query
Returns: VaultState โ (reserve, tickPriceSatX42, vaultId)
Use
getReserves()for the decomposed view (separate APE and LP reserves). UsevaultStates()to get the vault ID or raw storage values.
ORACLE
ORACLEReturns the current Oracle contract address. On MegaETH, this accounts for pending oracle changes with a time delay.
Returns: The active Oracle contract address.
totalReserves
totalReservesReturns the total collateral balance across all vaults for a given token (excluding fees reserved for stakers).
collateral
address
The collateral token address
Returns: uint256 โ total collateral held.
APE_IMPLEMENTATION
APE_IMPLEMENTATIONReturns the address of the APE implementation contract used for deploying clones.
Returns: The APE implementation address.
Last updated