Native Token Swaps
The CoW Protocol SDK enables selling blockchain native tokens (ETH, MATIC, etc.) through the EthFlow contract. Since native tokens aren’t ERC-20 compliant, they require special handling for on-chain transactions.How It Works
When selling native tokens:- An on-chain transaction is sent to the EthFlow contract
- Native tokens are locked in the contract
- An order is created in the CoW Protocol order book
- Upon filling, the buyer receives their tokens
- Unfilled orders can be cancelled to reclaim funds
Using postSwapOrder (Automatic Detection)
The SDK automatically detects native token orders using the special marker address0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE and routes them through EthFlow.
Using postSellNativeCurrencyOrder
For more control, use the dedicatedpostSellNativeCurrencyOrder method:
Method Signature
Example
Complete Example with Quote
Order Kinds for Native Tokens
- SELL Orders (Supported)
- BUY Orders (Limited)
Gas Cost Considerations
Native token orders require on-chain transactions, making them significantly more expensive than regular orders:Always ensure you have enough ETH for gas in addition to the amount you’re selling.
Cancelling Native Token Orders
Advanced: Custom EthFlow Parameters
Common Chains and Native Tokens
Best Practices
- Verify sufficient balance for both the order amount and gas fees
- Use
OrderKind.SELLfor better predictability with native tokens - Wait for transaction confirmation before querying order status
- Consider wrapping to WETH for smaller amounts where gas costs might exceed savings
- Monitor gas prices before executing native token orders
Next Steps
- Learn about Creating Swap Orders for regular ERC-20 trades
- See Order Management to track and cancel orders
- Explore Token Approvals for ERC-20 approval management