Swaps
Swaps are executed directly against liquidity pools without order books or intermediaries.
How Swaps Work
Step-by-Step Process
- Approve token spending - Grant the contract permission to access your tokens
- Send swap transaction - Submit your swap request on-chain
- Contract calculates output - Smart contract determines output based on reserves
- Tokens exchanged - Atomic swap executes instantly on-chain
All swaps happen in a single transaction with guaranteed execution or revert.
Swap Properties
All swaps are:
✅ Non-custodial - You never lose custody of your assets
✅ Transparent - All pricing logic is visible on-chain
✅ Immutable - Contract logic cannot be changed after deployment
✅ Gas-efficient - Optimized for low transaction costs
✅ Instant - Settle in a single blockchain transaction
Pricing Calculation
Price is determined by the constant product formula:
amountOut = (amountIn × reserveOut) / (reserveIn + amountIn)
Example:
Pool has 1000 Token A and 10 Token B:
- You swap 100 Token A
- You receive: (100 × 10) / (1000 + 100) = 0.909 Token B
- New reserves: 1100 Token A, 9.091 Token B
Slippage
Slippage is the difference between expected and executed price.
Causes:
- Large trades relative to pool size
- Other trades executing before yours
- Network congestion delaying execution
Protection:
Set a maximum slippage tolerance:
- 0.5% - Low slippage, may fail in volatile markets
- 1-3% - Balanced for most trades
- 5%+ - High tolerance, useful for illiquid pairs
If the price moves beyond your tolerance, the transaction reverts to protect you.
Trading Fees
Each swap includes a small fee:
- Default: 0.3% of the swap amount
- Fee split:
- 0.25% to liquidity providers
- 0.05% to protocol treasury
Fees are automatically added to the liquidity pool, increasing LP token value.
Advanced Features
Multi-hop Swaps (Future)
Route through multiple pools for better prices:
Token A → Token B → Token C
The router automatically finds the optimal path for your swap.
Deadline Protection
Set a deadline for your swap:
- If execution takes longer than deadline, transaction reverts
- Protects against stuck transactions in mempool
- Prevents execution at stale prices
Minimum Output
Specify minimum output amount:
- Transaction reverts if output is less than minimum
- Protects against excessive slippage
- Useful in volatile market conditions
Swap Interface
Connect your wallet and swap directly through the GO Swap interface:
- Connect Wallet - MetaMask, WalletConnect, etc.
- Select Tokens - Choose input and output tokens
- Enter Amount - Specify how much to swap
- Review Details - Check price, fees, slippage
- Confirm Swap - Approve transaction in wallet
- Done - Tokens arrive instantly
For developers, integrate swaps programmatically via smart contract calls or REST API.