StarkFiStarkFi

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_status first to verify.

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 confirmation

get_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.

ParamTypeRequiredDescription
amountstringYesAmount to swap (e.g., 0.1, 100)
from_tokenstringYesSource token symbol (e.g., ETH, USDC)
to_tokenstringYesDestination 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.

ParamTypeRequiredDescription
amountstringYesAmount to swap (e.g., 0.1, 100)
from_tokenstringYesSource token to sell (e.g., ETH, STRK)
to_tokenstringYesDestination token to buy (e.g., USDC, DAI)
slippagenumberNoSlippage tolerance in % (default: 1)
simulatebooleanNoSet true to estimate fees without executing

Important: Always call get_swap_quote first and confirm with the user before executing.


get_multi_swap_quote

Get quotes for 2–3 swap pairs at once using Fibrous batch routing.

ParamTypeRequiredDescription
swapsarrayYesArray 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.

ParamTypeRequiredDescription
swapsarrayYesArray of 2–3 swap objects
slippagenumberNoSlippage tolerance in % (default: 1)
simulatebooleanNoSet 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.

ParamTypeRequiredDescription
operationsarrayYesArray of operation objects (minimum 2)
simulatebooleanNoSet true to estimate fees without executing

Each operation has a type and params:

TypeParamsExample
swapamount, from_token, to_token{ "type": "swap", "params": { "amount": "100", "from_token": "USDC", "to_token": "ETH" } }
stakeamount, token, pool or validator{ "type": "stake", "params": { "amount": "50", "token": "STRK", "validator": "karnot" } }
supplyamount, token, pool{ "type": "supply", "params": { "amount": "200", "token": "USDC", "pool": "Prime" } }
sendamount, 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.

Edit on GitHub

Last updated on

On this page