Trade Tools
get_swap_quote, swap_tokens, get_multi_swap_quote, multi_swap, batch_execute
Prerequisite: All trade tools require an active authenticated session. Call
get_auth_statusfirst to verify.
Recommended Flow
Always follow the quote → confirm → execute pattern:
1. get_swap_quote → Show quote to user
2. User confirms → Proceed to execute
3. swap_tokens → Execute the swap
4. get_tx_status → Verify confirmationget_swap_quote
Get a price quote for a swap without executing. Always call this before swap_tokens so the user can review the expected output.
| Param | Type | Required | Description |
|---|---|---|---|
amount | string | Yes | Amount to swap (e.g., 0.1, 100) |
from_token | string | Yes | Source token symbol (e.g., ETH, USDC) |
to_token | string | Yes | Destination token symbol (e.g., STRK, DAI) |
This is a read-only tool — safe to call without user confirmation. Returns expected output amount, estimated gas cost, and route details.
swap_tokens
Execute a token swap on Starknet using Fibrous DEX aggregation.
| Param | Type | Required | Description |
|---|---|---|---|
amount | string | Yes | Amount to swap (e.g., 0.1, 100) |
from_token | string | Yes | Source token to sell (e.g., ETH, STRK) |
to_token | string | Yes | Destination token to buy (e.g., USDC, DAI) |
slippage | number | No | Slippage tolerance in % (default: 1) |
simulate | boolean | No | Set true to estimate fees without executing |
Important: Always call
get_swap_quotefirst and confirm with the user before executing.
get_multi_swap_quote
Get quotes for 2–3 swap pairs at once using Fibrous batch routing.
| Param | Type | Required | Description |
|---|---|---|---|
swaps | array | Yes | Array of 2–3 swap objects |
Each swap object: { amount, from_token, to_token }
This is a read-only tool — safe to call without user confirmation.
multi_swap
Execute 2–3 swaps in a single multicall transaction. Call get_multi_swap_quote first to preview.
| Param | Type | Required | Description |
|---|---|---|---|
swaps | array | Yes | Array of 2–3 swap objects |
slippage | number | No | Slippage tolerance in % (default: 1) |
simulate | boolean | No | Set true to estimate fees without executing |
Each swap object: { amount, from_token, to_token }
Note: Minimum 2, maximum 3 swap pairs per transaction.
batch_execute
Execute a batch of mixed operations (swap + stake + supply + send) atomically in a single Starknet multicall.
| Param | Type | Required | Description |
|---|---|---|---|
operations | array | Yes | Array of operation objects (minimum 2) |
simulate | boolean | No | Set true to estimate fees without executing |
Each operation has a type and params:
| Type | Params | Example |
|---|---|---|
swap | amount, from_token, to_token | { "type": "swap", "params": { "amount": "100", "from_token": "USDC", "to_token": "ETH" } } |
stake | amount, token, pool or validator | { "type": "stake", "params": { "amount": "50", "token": "STRK", "validator": "karnot" } } |
supply | amount, token, pool | { "type": "supply", "params": { "amount": "200", "token": "USDC", "pool": "Prime" } } |
send | amount, token, to | { "type": "send", "params": { "amount": "10", "token": "STRK", "to": "0x04a3..." } } |
Note: Minimum 2 operations required per batch. Each operation is executed atomically — if any fails, the entire batch reverts.
Last updated on