Perform a single-pool swap on MachineX (peaq EVM) using the SwapRouter exactInputSingle flow in JavaScript with ethers.js v6.
This README includes:
- Pool discovery via Factory
getPool() - TickSpacing handling (required by router)
- Basic output estimate + slippage-based
amountOutMinimum - ERC-20 approval
- Executing the swap
⚠️ Important: Theslot0-based estimate is a rough quote (does not account for price impact, fees, or tick crossings). For production quoting, use an official Quoter/SDK if available.
- Node.js 18+
ethersv6- An EVM private key funded with the input token (e.g., WPEAQ, USDC, USDT, etc.)
- Native PEAQ for gas
Install deps:
npm i ethers dotenv