Batch Command
Combine multiple DeFi operations into a single atomic transaction
Prerequisite: Requires an active authenticated session. Run
starkfi auth loginfirst.
Overview
The batch command lets you combine multiple operations — swaps, staking, lending (supply, borrow, repay, withdraw), sends, DCA orders, and Troves vault deposits/withdrawals — into a single atomic Starknet transaction using multicall. All operations succeed together or revert together.
Usage
starkfi batch [--swap "..."] [--stake "..."] [--supply "..."] [--send "..."] [--borrow "..."] [--repay "..."] [--withdraw "..."] [--dca-create "..."] [--dca-cancel "..."] [--troves-deposit "..."] [--troves-withdraw "..."] [flags]At least 2 operations are required per batch. Each flag can be repeated.
Flags:
| Flag | Description |
|---|---|
--swap "<amount> <from> <to>" | Swap tokens |
--stake "<amount> <token> <validator>" | Stake tokens |
--supply "<amount> <token> <pool>" | Supply to lending pool |
--send "<amount> <token> <recipient>" | Send tokens |
--borrow "<col_amt> <col_token> <bor_amt> <bor_token> <pool>" | Borrow from lending pool |
--repay "<amount> <token> <col_token> <pool>" | Repay lending debt |
--withdraw "<amount> <token> <pool>" | Withdraw from lending pool |
--dca-create "<amount> <sell> <buy> <perCycle> [frequency]" | Create DCA order |
--dca-cancel "<orderId>" | Cancel DCA order |
--troves-deposit "<amount> <strategy> [token]" | Deposit into Troves vault |
--troves-withdraw "<amount> <strategy> [token]" | Withdraw from Troves vault |
--simulate | Estimate fees without executing |
--json | Output raw JSON |
Operations
Swap
--swap "<amount> <fromToken> <toToken>"Stake
--stake "<amount> <token> <validator>"Supply (Lending)
--supply "<amount> <token> <pool>"Send
--send "<amount> <token> <recipient>"Borrow (Lending)
--borrow "<collateral_amount> <collateral_token> <borrow_amount> <borrow_token> <pool>"Example: --borrow "0.5 ETH 500 USDC Prime"
Repay (Lending)
--repay "<amount> <token> <collateral_token> <pool>"Example: --repay "100 USDC ETH Prime"
Withdraw (Lending)
--withdraw "<amount> <token> <pool>"Example: --withdraw "200 USDC Prime"
DCA Create
--dca-create "<amount> <sell> <buy> <perCycle> [frequency]"DCA Cancel
--dca-cancel "<orderId>"Troves Deposit
--troves-deposit "<amount> <strategy_id> [token]"Example: --troves-deposit "100 evergreen_strk"
Troves Withdraw
--troves-withdraw "<amount> <strategy_id> [token]"Example: --troves-withdraw "50 evergreen_strk"
Examples
Swap ETH to USDC, then stake STRK — all in one transaction:
starkfi batch \
--swap "0.1 ETH USDC" \
--stake "100 STRK karnot"Withdraw from lending and swap — atomically:
starkfi batch \
--withdraw "200 USDC Prime" \
--swap "200 USDC ETH"Repay debt and stake with remaining tokens:
starkfi batch \
--repay "100 USDC ETH Prime" \
--stake "50 STRK karnot"Borrow and swap in a single transaction:
starkfi batch \
--borrow "0.5 ETH 500 USDC Prime" \
--swap "250 USDC STRK"Swap and deposit into a vault:
starkfi batch \
--swap "100 USDC STRK" \
--troves-deposit "100 STRK evergreen_strk"How It Works
- Each operation is translated into on-chain calls (approve + execute)
- All calls are composed using Starkzap's
TxBuilder - Everything executes atomically — if any operation fails, the entire batch reverts
- Each flag can be repeated — up to 3 swap pairs per batch
Simulation
Test your batch without executing:
starkfi batch --swap "0.1 ETH USDC" --stake "100 STRK karnot" --simulateReturns estimated gas fee, call count, and validates all operations without spending gas.
MCP equivalent: Trade Tools — batch_execute — same operations available as a single MCP tool
Last updated on