Token Swapping (AMM)
Cat Wallet features a fully functional Automated Market Maker (AMM) built directly into the dashboard that enabling users to trade tokens instantly on the Ritual Chain.
How Swapping Works
The swap interface interacts directly with the SwapRouter smart contract.
- Liquidity Pools: The AMM relies on user provided liquidity pools (managed via the
SwapFactorycontract). - Automated Pricing: Prices are determined automatically based on the constant product formula ($x \cdot y = k$).
- Approvals: If you are swapping an ERC-20 token (like rUSD) for another token, then the wallet will first prompt you to approve the
SwapRouterto spend your tokens. Or if you are swapping nativeRITUAL, no approval is necessary.
Slippage Tolerance
Cryptocurrency markets are pretty volatile and the "Slippage" is the difference between the expected price of a trade and the actual price at which the trade is executed.
- Default Slippage: The default slippage tolerance is 1%.
- Adjustment: You can adjust slippage to 0.5%, 1%, 3%, or 5% depending on market volatility.
- Protection: If the execution price falls outside of your slippage tolerance while the transaction is confirming, then the swap will automatically revert to protect your funds.
High Price Impact
If you attempt to swap a very large amount of tokens relative to the size of the liquidity pool, you will incur a "high price impact." This means your trade will significantly shift the pool's ratio, and resulting in a worse execution price for you.
Cat Wallet calculates the real AMM price impact and will display a warning if the impact exceeds 15%. You must explicitly acknowledge this warning before the swap button becomes active.
Error Handling
If you encounter an error during a swap:
- "RPC Hiccup": This is a transient error from the Ritual testnet node (
could not coalesce). Cat Wallet automatically intercepts this and retries the swap silently after a 2-second delay. - "Price Moved": The pool reserves changed while your transaction was pending. Try increasing your slippage tolerance.
- "Wallet sent EIP-1559 tx" / "transaction type not supported": Ritual Testnet's RPC expects a specific fee format, and some external wallets pick the wrong one on their own but the Cat Wallet applies an explicit legacy
gasPriceoverride on every transaction sent from an external wallet to prevent this – see Supported Wallets for the developer facing details.