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, and sends — into a single atomic Starknet transaction using multicall. All operations succeed together or revert together.
Usage
starkfi batch [--swap "..."] [--stake "..."] [--supply "..."] [--send "..."] [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 |
--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>"Examples
Swap ETH to USDC, then stake STRK — all in one transaction:
starkfi batch \
--swap "0.1 ETH USDC" \
--stake "100 STRK karnot"Three operations combined:
starkfi batch \
--swap "50 USDC ETH" \
--stake "200 STRK karnot" \
--send "10 STRK 0x04a3...abcd"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.
Last updated on