# Agentic Starknet Trading

## ◆ Guide: Agentic Starknet Trading

Build AI agents that **trade on Starknet** via AVNU — with high throughput, low fees, and access to the deepest liquidity pools in the Bitcoin L2 ecosystem. Starknet processes $400M+ in monthly DEX volume, making it the strongest venue for agentic trading on Bitcoin rails.

### What you'll build

An agent that can:

1. **Get swap quotes** across Starknet DEX pairs (AVNU)
2. **Execute spot trades** between WBTC, STRK, USDC, and any ERC-20 token
3. **Run DCA strategies** — accumulate WBTC over time from stablecoins
4. **Rebalance** across multiple Starknet assets
5. **Harvest staking rewards** — claim STRK from WBTC staking and compound or convert
6. **Cross-chain arbitrage** — compare prices across Starknet and other chains

### Prerequisites

* Xverse Agentic Wallet CLI installed (`npm i -g @secretkeylabs/xverse-wallet-cli`)
* A funded wallet with assets on Starknet (see [Getting Started](https://claude.ai/chat/getting-started.md))

### Why Starknet?

For agentic trading, Starknet offers the best mix of speed, cost, and liquidity in the Bitcoin ecosystem:

* **High throughput, low fees** — instant finality, fraction-of-a-cent gas
* **Deep DEX liquidity** — $400M+ monthly volume via AVNU and integrated pools
* **BTC-native assets** — WBTC is the primary BTC representation, stakeable for STRK rewards
* **Stablecoin access** — USDC on Starknet for stable trading pairs
* **Programmable** — smart contracts enable complex DeFi strategies

***

### Step 1: Get assets onto Starknet

Bridge BTC to Starknet as WBTC, or buy USDC/STRK directly:

```bash
# Cross-chain swap: BTC L1 → Starknet WBTC (~10-30 min)
xverse-wallet swap execute --from bitcoin:BTC --to starknet:WBTC --amount 0.01 --yes --json

# Or BTC L1 → Starknet STRK
xverse-wallet swap execute --from bitcoin:BTC --to starknet:STRK --amount 0.01 --yes --json

# Or buy directly with fiat
xverse-wallet fund buy --crypto WBTC --amount 100
xverse-wallet fund buy --crypto USDC --amount 100
```

Check your Starknet balances:

```bash
xverse-wallet starknet balance --json
```

### Step 2: Get swap quotes

Use `swap quote` to get pricing from AVNU and other integrated providers:

```bash
# WBTC → STRK
xverse-wallet swap quote --from starknet:WBTC --to starknet:STRK --amount 0.001 --json

# USDC → WBTC
xverse-wallet swap quote --from starknet:USDC --to starknet:WBTC --amount 100 --json

# STRK → USDC
xverse-wallet swap quote --from starknet:STRK --to starknet:USDC --amount 50 --json
```

Starknet-to-Starknet swaps settle instantly — no block confirmations needed.

### Step 3: Execute a swap

```bash
# Preview
xverse-wallet swap execute --from starknet:USDC --to starknet:WBTC --amount 100 --json

# Execute
xverse-wallet swap execute --from starknet:USDC --to starknet:WBTC --amount 100 --yes --json
```

#### Options

| Option              | Description                              |
| ------------------- | ---------------------------------------- |
| `--from <token>`    | Source token (e.g. `starknet:USDC`)      |
| `--to <token>`      | Destination token (e.g. `starknet:WBTC`) |
| `--amount <value>`  | Amount of the source token               |
| `--provider <code>` | Use a specific provider                  |
| `--slippage <pct>`  | Slippage tolerance (percentage)          |
| `--yes`             | Execute (omit for dry run)               |

### Step 4: DCA into WBTC

A DCA agent that accumulates WBTC from USDC at regular intervals:

```bash
# Run daily:
xverse-wallet swap execute --from starknet:USDC --to starknet:WBTC --amount 50 --yes --json
```

**Agent pseudocode:**

```
every 24 hours:
    1. Check USDC balance
       starknet balance --filter USDC --json

    2. If balance >= target_amount:
       swap execute --from starknet:USDC --to starknet:WBTC --amount <target> --yes --json

    3. Optionally stake accumulated WBTC for STRK rewards:
       starknet staking deposit --token wbtc --amount <accumulated> --yes --json

    4. Log trade result
```

### Step 5: Harvest staking rewards

If your agent has staked WBTC, periodically claim STRK rewards and compound or convert:

```bash
# Check staking position and pending rewards
xverse-wallet earn status --json

# Claim STRK rewards
xverse-wallet starknet staking claim --yes --json

# Option A: Compound — swap STRK to WBTC and re-stake
xverse-wallet swap execute --from starknet:STRK --to starknet:WBTC --amount 100 --yes --json
xverse-wallet starknet staking deposit --token wbtc --amount 0.001 --yes --json

# Option B: Take profit — swap STRK to USDC
xverse-wallet swap execute --from starknet:STRK --to starknet:USDC --amount 100 --yes --json

# Option C: Sweep to cold BTC storage
xverse-wallet swap execute --from starknet:STRK --to bitcoin:BTC --amount 100 --yes --json
```

### Step 6: Portfolio rebalancing

An agent that maintains a target allocation (e.g. 60% WBTC / 30% USDC / 10% STRK):

```bash
# 1. Check current allocation
xverse-wallet starknet balance --json

# 2. Rebalance overweight position
xverse-wallet swap execute --from starknet:WBTC --to starknet:USDC --amount 0.0005 --yes --json

# 3. Rebalance underweight position
xverse-wallet swap execute --from starknet:USDC --to starknet:STRK --amount 20 --yes --json

# 4. Verify
xverse-wallet starknet balance --json
```

### Step 7: Cross-chain arbitrage

Compare prices across chains and execute where the rate is best:

```bash
# Compare BTC → WBTC rates
xverse-wallet swap quote --from bitcoin:BTC --to starknet:WBTC --amount 0.01 --json
xverse-wallet swap quote --from bitcoin:BTC --to spark:BTC --amount 0.01 --json

# Execute on the better rate
xverse-wallet swap execute --from bitcoin:BTC --to starknet:WBTC --amount 0.01 --yes --json
```

***

### Putting it all together: Starknet trading agent

```
┌──────────────────────────────────────────────────────┐
│              Starknet Trading Agent                    │
│                                                       │
│  1. Check portfolio & Starknet balances               │
│     portfolio --json                                  │
│     starknet balance --json                           │
│                                                       │
│  2. Get quotes for target pairs                       │
│     swap quote --from starknet:USDC --to starknet:WBTC│
│                                                       │
│  3. Execute trades if conditions met                  │
│     swap execute ... --yes --json                     │
│                                                       │
│  4. Stake idle WBTC for STRK rewards                  │
│     starknet staking deposit --token wbtc ...         │
│                                                       │
│  5. Periodically harvest + compound rewards           │
│     starknet staking claim --yes                      │
│     swap execute --from starknet:STRK --to ...        │
│                                                       │
│  6. Sweep profits to cold BTC storage                 │
│     swap execute --from starknet:WBTC --to bitcoin:BTC│
│                                                       │
│  Loop on schedule or market signal.                   │
└──────────────────────────────────────────────────────┘
```

### Available Starknet trading pairs

All Starknet-to-Starknet swaps settle instantly. Common pairs:

| From                | To                  | Settlement |
| ------------------- | ------------------- | ---------- |
| `starknet:USDC`     | `starknet:WBTC`     | Instant    |
| `starknet:WBTC`     | `starknet:STRK`     | Instant    |
| `starknet:STRK`     | `starknet:USDC`     | Instant    |
| `starknet:USDC`     | `starknet:STRK`     | Instant    |
| Any Starknet ERC-20 | Any Starknet ERC-20 | Instant    |

Cross-chain routes (BTC L1 ↔ Starknet) take \~10-30 minutes due to Bitcoin block confirmations.

### What's next

* Combine Starknet trading with [Lightning commerce](https://claude.ai/chat/guide-lightning-commerce.md) for agents that trade and accept payments
* Add [Flashnet trading](https://claude.ai/chat/guide-flashnet-trading.md) for Spark-native trading pairs
* Explore [treasury management](https://claude.ai/chat/portfolio-and-treasury.md) for full cross-chain fund management
