StarkFiStarkFi

Batch Command

Combine multiple DeFi operations into a single atomic transaction

Prerequisite: Requires an active authenticated session. Run starkfi auth login first.

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:

FlagDescription
--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
--simulateEstimate fees without executing
--jsonOutput 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

  1. Each operation is translated into on-chain calls (approve + execute)
  2. All calls are composed using Starkzap's TxBuilder
  3. Everything executes atomically — if any operation fails, the entire batch reverts
  4. 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" --simulate

Returns estimated gas fee, call count, and validates all operations without spending gas.

Edit on GitHub

Last updated on

On this page