@baseline-markets/cli
v0.6.0
Published
Command-line interface for [Baseline](https://www.baseline.markets), an AMM for project tokens, providing efficient market making, MEV protection, a floor price and no-liquidation leverage. Launch tokens, trade them, and manage staking and credit position
Readme
Baseline CLI
Command-line interface for Baseline, an AMM for project tokens, providing efficient market making, MEV protection, a floor price and no-liquidation leverage. Launch tokens, trade them, and manage staking and credit positions — from a terminal, a script, or an AI agent.
Every command prints a human-readable summary by default and structured JSON
with --format json. Every state-changing command can be dry-run first, so
the safe path is always available: quote, then simulate, then execute.
Install
Run without installing:
npx @baseline-markets/cli --helpOr install globally:
npm install -g @baseline-markets/cli
baseline --helpQuick start
Trade on Ethereum mainnet (the default chain — pass --chain-id 8453 for
Base or --chain-id 84532 for Base Sepolia):
# 1. Read-only price quote. No account or key needed.
baseline quote swap --token 0xToken --buy --amount 100 --format json
# 2. Simulate the exact calls: approval + swap, with a gas estimate.
# Needs only an address — nothing is signed or sent.
baseline swap --token 0xToken --buy --amount 100 --simulate --account 0xYou --format json
# 3. Execute for real (needs a key).
export BASELINE_PRIVATE_KEY=0x...
baseline swap --token 0xToken --buy --amount 100 --slippage-bps 100 --format jsonThe same three tiers apply everywhere: quote swap / position / info are
read-only, --simulate builds and simulates the exact calls without sending
anything (pass --account to simulate as any address — no key required), and
omitting --simulate (or passing --execute for launch) signs and sends.
Concepts
- BToken — the token side of a Baseline pool: a normal ERC20 launched through Baseline, paired with a reserve token (for example WETH or a stablecoin). The pool's reserves give every BToken a floor price.
- Swap — buy or sell BTokens against the reserve through Baseline's AMM.
- Position — your staked BTokens (earning reserve rewards) and your credit account (borrow reserve from the pool against staked BTokens, with no liquidations; repay to unlock).
- Launch — deploy a new BToken.
zrpmode (default) launches with zero initial reserves;standardmode seeds the pool with initial reserve liquidity.
Commands
| Command | What it does | Needs |
|---|---|---|
| baseline info [token] | Inspect a deployed token | nothing |
| baseline quote swap | Price a swap | nothing |
| baseline swap | Simulate or execute a swap | address for simulate, key for execute |
| baseline position | Inspect staking + credit position | nothing |
| baseline position stake\|unstake\|claim\|borrow\|repay | Simulate or execute a position action | address for simulate, key for execute |
| baseline launch | Build, simulate, or execute launch calls | address for build/simulate, key for execute |
baseline <command> --help lists every flag with its constraints.
Global options and defaults
| Option | Default | Notes |
|---|---|---|
| --chain-id | 1 (Ethereum) | Supported: 1 (Ethereum), 8453 (Base), 84532 (Base Sepolia), 999 (HyperEVM), 4663 (Robinhood Chain) |
| --rpc-url | chain's public RPC | Any JSON-RPC endpoint for the chain |
| --format | human-readable | --format json for structured output |
| --private-key | BASELINE_PRIVATE_KEY env | Prefer the env var (or a .env file) over the flag so keys stay out of shell history |
| --slippage-bps | 100 (1%) | Swap slippage tolerance |
| --approval | infinite | ERC20 approval policy; exact approves only the required amount |
| --confirmations | 1 | Confirmations to wait for per transaction |
Swaps
Four modes, combining a side with an exactness:
--buy --exact-in— spend an exact reserve amount for at least the quoted BTokens (--exact-inis the default).--buy --exact-out— buy an exact BToken amount for at most the quoted reserve input.--sell --exact-in/--sell --exact-out— mirror image with BToken input or exact reserve output.
baseline quote swap --token 0xToken --sell --exact-out --amount 50 --format json
baseline swap --token 0xToken --sell --exact-out --amount 50 --slippage-bps 50Execution bundles an ERC20 approval for the input token (when needed) with
the swap itself. Slippage limits are derived from the quote: minOut for
exact-in, maxIn for exact-out.
Positions
Inspect (read-only):
baseline position --token 0xToken --user 0xUser --format jsonReports staked balance, earned rewards, credit collateral, debt, and current max borrow.
Act (each also accepts --simulate):
baseline position stake --token 0xToken --amount 25 # approves BToken, then deposits
baseline position unstake --token 0xToken --amount 10
baseline position claim --token 0xToken # --as-native for native ETH
baseline position borrow --token 0xToken --amount 100 # --output-native for native ETH
baseline position repay --token 0xToken --amount 50 # --use-native to repay with ETHThe native-ETH flags apply when the reserve is a wrapped-native token.
Launch
Build launch calls without sending anything (the output is
wallet_sendCalls-compatible, so another wallet — a browser wallet, Base
Account, a multisig frontend — can sign it):
baseline launch \
--name "My Token" \
--symbol MTK \
--reserve 0xReserveToken \
--total-supply 1000000 \
--account 0xDeployer \
--output launch.json \
--format jsonSimulate the calls and estimate gas (--account is enough; nothing is
signed):
baseline launch ... --simulate --account 0xDeployer --format jsonExecute with a key (--account is then derived from the key):
baseline launch ... --executeLaunch modes:
--mode zrp(default) — zero-reserve launch; the pool BToken amount is derived from--total-supply.--mode standard— seeds initial liquidity; requires--initial-pool-btokensand--initial-pool-reserves.
The result includes the precomputed BToken address plus app and explorer links.
Gas and nonce controls
Execution submits an atomic wallet_sendCalls bundle by default. Passing any
gas or nonce option switches to individual sequential transactions so the
fields can be applied — this is not atomic: if a later transaction
reverts, earlier ones (for example an approval) stay confirmed. The error
reports the confirmed transaction hashes and the calls that were never sent,
and the result's mode field says which path ran (batch or
transactions).
baseline swap ... --gas-limit-multiplier 1.2 --max-fee-gwei 0.2 --priority-fee-gwei 0.01--gas-limit-multiplier— gas limit = simulated gas × multiplier (defaults to 1.2 when any other gas option is set).--max-fee-gwei/--priority-fee-gwei— EIP-1559 fees;--priority-fee-gweirequires--max-fee-gwei.--gas-price-gwei— legacy gas price; cannot be combined with the EIP-1559 options.--nonce— nonce for the first transaction; later calls increment from it.
Gas and nonce options apply to execution only and cannot be combined with
--simulate. To replace a stuck transaction, reuse its nonce with higher
fees:
baseline swap ... --nonce 42 --max-fee-gwei 0.5 --priority-fee-gwei 0.05JSON output
Token amounts are always objects, never bare numbers:
{ "raw": "100000000000000000000", "formatted": "100", "decimals": 18 }--simulate results include the serialized calls, per-call simulation
results, and a gas estimate:
{
"calls": [{ "to": "0x…", "data": "0x…" }],
"simulation": ["0x…"],
"gasEstimate": {
"calls": [{ "index": 0, "gasUsed": "45123" }],
"totalGas": "45123"
}
}Execution results report the path taken and every confirmed transaction:
{
"execution": {
"mode": "batch",
"bundles": [{ "id": "0x…", "atomic": true }],
"transactions": [
{ "index": 0, "hash": "0x…", "status": "success", "blockNumber": "…", "gasUsed": "…" }
]
},
"transaction": { "hash": "0x…" }
}In transactions mode each entry also includes the applied gasLimit (and
nonce when overridden). On failure the CLI exits non-zero with an error
message; sequential-mode reverts embed a JSON payload listing the reverted
call, the already-confirmed transactions, and the calls that were never sent.
Environment
BASELINE_PRIVATE_KEY— signer forswap,positionactions, andlaunch --execute. Loaded from the environment or a local.envfile.--rpc-url/ chain default RPC — all commands accept a custom endpoint.
The published package also ships an agent skill (skills/) describing launch
workflows for AI agents.
Development
bun run --cwd packages/cli dev --help # run from source
bun run --cwd packages/cli test
bun run --cwd packages/cli typecheck
# fork integration tests
RPC_URL=https://sepolia.base.org bun run --cwd packages/cli test:integration