Swap
Swap tokens across multiple DEXes with best-price routing, powered by the 7K Aggregator. OnlyFence checks your spending limits and token allowlist before every swap — if the trade violates any safety rule, it is rejected locally before a transaction is signed.
Usage
fence swap <from> <to> <amount> [options]
Examples
# Swap 10 SUI for USDC
fence swap SUI USDC 10
# Swap with JSON output (for agents)
fence swap SUI USDC 100 --output json
# Swap using raw coin type
fence swap SUI 0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC 50
How It Works
- Policy check — verifies both tokens are in your allowlist, trade is under spending limits
- Quote — finds the best route across Cetus, DeepBook, Bluefin, FlowX, and Turbos
- Simulate — dry-runs the transaction to verify it will succeed
- Execute — signs and submits the transaction
- Log — records the trade in your activity history
Supported DEXes
All swaps route through the 7K Aggregator, which finds the best price across:
| DEX | Protocol |
|---|---|
| Cetus | AMM |
| DeepBook | Order book |
| Bluefin | Order book |
| FlowX | AMM |
| Turbos | AMM |
Safety Checks
Every swap goes through the policy engine:
- Token allowlist — both
fromandtotokens must be in your approved list - Per-trade limit — trade USD value must be under
max_single_trade - Daily volume limit — rolling 24h total must stay under
max_24h_volume
If any check fails, the swap is blocked and a rejection reason is returned.
Response
Success
{
"status": "success",
"chain": "sui",
"txDigest": "8Hk4...mW2p",
"fromToken": "SUI",
"toToken": "USDC",
"amountIn": "100",
"amountOut": "98.12",
"valueUsd": 98.0,
"route": "SUI -> USDC via Cetus"
}
Rejection
{
"status": "rejected",
"check": "token_allowlist",
"reason": "token_not_allowed",
"detail": "SCAM is not in the token allowlist"
}