Overview
OxiSwap CryptoSwap Contract
Key Components
Router Contract (
crypto-router) - Go to Router ContractFactory Contract (
crypto-factory) - Go to Factory ContractPair Contract (
crypto-pair) - Go to Pair Contract
Features
Token swaps
Liquidity provision
Automated market making
Fee collection
Router Contract
The Router contract is the main entry point for users to interact with OxiSwap. It handles:
Adding and removing liquidity
Token swaps (exact input and exact output)
Quote calculations
Path-based multi-hop swaps
Factory Contract
The Factory contract is responsible for:
Creating new trading pairs
Managing the list of all trading pairs
Setting and updating fee parameters
Pair Contract
The Pair contract implements the core AMM (Automated Market Maker) logic:
Minting and burning liquidity tokens
Executing swaps
Maintaining reserves and price accumulators
Implementing the constant product formula (x * y = k)
Key Functions
Router
add_liquidity: Add liquidity to a trading pairremove_liquidity: Remove liquidity from a trading pairswap_exact_input: Swap a fixed input amount for a minimum output amountswap_exact_output: Swap a maximum input amount for a fixed output amount
Factory
create_pair: Create a new trading pairget_pair: Retrieve the asset ID for a trading pairall_pairs_length: Get the total number of trading pairs
Pair
mint: Mint liquidity tokens when adding liquidityburn: Burn liquidity tokens when removing liquidityswap: Execute a token swapget_reserves: Retrieve the current reserves of a trading pair
Security
OxiSwap implements several security measures:
Reentrancy protection
Overflow checks
Deadline checks for transactions
Minimum liquidity requirements
Last updated