Architecture Overview
This page describes the core architecture of our cross-chain perpetuals trading platform. The system is designed to abstract away the complexity of multi-chain collateral management and provide a seamless user experience for depositing, withdrawing, and managing positions across different blockchains.
Cross-Chain Flow and Collateral Management
Users can deposit collateral and interact with the platform from any supported chain: Sepolia ( USDC ) or Avalanche Fuji (AVAX, USDC, LINK).
Direct Deposits on AVAX
If you're depositing USDC, you can directly use the Avalanche Fuji Perps Contract.
If you're depositing native AVAX or LINK tokens, the platform first routes the deposit through the Pool Manager on Avalanche Fuji, which internally interacts with the Perps Contract to finalize the deposit.
Cross-Chain Deposits (Sepolia to Avalanche Fuji)
If you deposit USDC on Sepolia, the platform uses Chainlink CCIP to move assets to AVAX_POOl_MANAGER which then sends a call to Perps Contract to create deposit on User's behalf.
The CrossChainPoolManager contract orchestrates this transfer.
Since this process takes time, the Avalanche Fuji Pool Manager pre-funds the Perps contract with liquidity on the user's behalf using
depositUSDCforUser()
.Once the cross-chain transfer completes, a finalizing transaction is sent to the AVAX chain to confirm and record the actual user deposit via
depositDirect()
.
Automated Liquidation
Perps.sol and PriceOracle.sol contracts are deployed on the Avalanche Fuji chain.
All user positions and operations are handled in USDC on Avalanche Fuji.
Chainlink Automation monitors price feeds and automatically calls
liquidatePosition()
if liquidation conditions are met.
Summary of Key Contracts
Platform
Avalanche Fuji
Frontend UI for user interaction
CrossChainManager
Sepolia
Sends cross-chain collateral to Avalanche Fuji using CCIP
Pool Manager
Avalanche Fuji
Converts assets to USDC and interacts with Perps contract
Perps.sol & PriceOracle.sol
Avalanche Fuji
Main trading logic and price verification
Chainlink Automation
Avalanche Fuji
Automatically triggers liquidations
Important Notes
All final trading operations occur in USDC on the AVAX chain.
Two-step process for cross-chain:
depositAndSend()
on SepoliadepositDirect()
on Avalanche Fuji
This system ensures real-time UX while maintaining cross-chain integrity and finality.

Last updated