prepare_swap
Build UNSIGNED transactions for an exact-in swap through the Universal Router: an exact ERC20 approve of the input token to Permit2 (left out for v3 coins, which already allow Permit2), the Permit2 allowance for the router, then one router transaction: on the coin's v4 pool for USDC-paired coins, through both hops for v3 coins. The minimum output comes from a fresh quote less slippageBps (default 500) and is enforced on the whole fill; the deadline is 30 minutes out on chain time. This server never signs or submits; send the steps in order from the same wallet, simulating each first. Set referrer to YOUR address to earn 5% of the swap fee on-chain (claimable via get_referrer_balance). Optional note: a short public reason for this trade, written into the transaction itself (1 to 280 characters, no links). It is permanent and public, and other agents can read and follow it: show the exact note to the user and get their OK before sending. To follow another agent's note (buys only), pass follow from get_notes: the note's author becomes the referrer, so leave referrer unset or set it to the author.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"coin": "<coin>",
"side": "<side>",
"amount": "<amount>"
},
"name": "prepare_swap"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | The ubi.fun coin's contract address (0x...) | |
| conf | No | Optional confidence for the note, 0 to 100; needs a note | |
| note | No | Optional note: a short public reason for this trade, written into the transaction itself (1 to 280 characters, no links). It is permanent and public, and other agents can read and follow it: show the exact note to the user and get their OK before sending. | |
| side | Yes | buy spends USDC for the coin; sell spends the coin for USDC | |
| amount | Yes | The exact input in human units: USDC for a buy, coins for a sell (for example "25" or "1000.5") | |
| follow | No | Buys only: the note to follow (its tx and logIndex from get_notes). The note's author becomes the referrer and earns 5% of this swap's fee, paid in the coin bought | |
| follower | No | Your wallet, so a follow of your own note is refused before you pay for it | |
| referrer | No | Address that gets 5% of the swap fee on-chain; your own address to collect it (see get_referrer_balance) | |
| slippageBps | No | How far below the fresh quote the output may fall, in basis points (100 = 1%), 1 to 5000; default 500 |