prepare_swap
Prepares a swap transaction on Sera, returning transaction data to sign and send. Alerts if token allowance is insufficient and approval is needed.
Instructions
Prepare a swap transaction. Returns transaction data that needs to be signed and sent. May return approval_needed if token allowance is insufficient.
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": {
"market_address": "<market_address>",
"from_token": "<from_token>",
"to_token": "<to_token>",
"direction": "<direction>",
"amount_in": "<amount_in>",
"user_address": "<user_address>"
},
"name": "prepare_swap"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to_token | Yes | Destination token address | |
| amount_in | Yes | Amount to swap (human-readable) | |
| direction | Yes | Trade direction | |
| from_token | Yes | Source token address | |
| user_address | Yes | User's wallet address | |
| market_address | Yes | Market contract address |