> ## Documentation Index
> Fetch the complete documentation index at: https://docs.silvana.one/llms.txt
> Use this file to discover all available pages before exploring further.

# Trading Modes

There are 3 trading modes that are currently supported: **Grid Mode**, **Request for Quote (RFQ)**, and **Taker Fill Loops**.

# Grid Mode

In this mode, multiple bid and ask orders are placed. across preset price levels.

When `agent` runs, it places limit orders on a grid of price levels around the current mid price.

Each level is defined by:

* `delta_percent` — signed offset from mid price in percent. Bids use negative values (below mid), offers use positive values (above mid). E.g. `-0.5` on a bid = 0.5% below mid; `0.3` on an offer = 0.3% above mid.
* `quantity` — order size at this level

When the mid price moves by more than `price_change_threshold_percent`, all grid orders are cancelled and re-placed at updated levels.

# RFQ

Quotes from liquidity providers are requested and executed against the best available quote. This mode best suits large-scale corporate trades on substantial amounts.

When `[liquidity_provider]` is configured, the agent connects to the orderbook server via a bidirectional gRPC stream (`SettlementStream`) and receives RFQ requests in real time.

This is a typical RFQ quote flow:

1. Agent connects and sends a handshake identifying the LP.
2. Server routes incoming RFQ requests to the LP.
3. Agent computes a quote price from the mid price and configured spread:
   * **Buy request** (user buys, LP sells): `price = mid * (1 + offer_spread_percent / 100)`
   * **Sell request** (user sells, LP buys): `price = mid * (1 - bid_spread_percent / 100)`
4. Agent validates quantity against `min_quantity` / `max_quantity` and checks balance via `LiquidityManager`.
5. Agent responds with a quote (price, quantity, validity window, settlement deadlines) or a rejection.

<Danger>
  Rejection reasons may include the following:

  * market disabled,
  * RFQ disabled for market,
  * quantity out of range,
  * no mid-price yet,
  * insufficient balance.
</Danger>

Each quote must include:

* `allocate_before_secs` — seconds from DVP creation to allocate tokens (default: 3600)
* `settle_before_secs` — seconds from DVP creation to complete settlement (default: 7200)

# Taker Fill Loops

Buy or sell RFQ orders are executed in chunks until the target amount is fully filled. This is an instance of an RFQ trade with an exceptionally high amount of funds.

Each accepted quote is settled atomically via a single multicall (`Accept_Dvp + Allocate + fees + traffic`).

```text theme={null}
# Buy 10 CC, chunked 0.5-5.0 per round, 60s interval between retries
cloud-agent buy --market CC-USDC --amount 10 \
  --min-settlement 0.5 --max-settlement 5.0 --interval 60

# Sell 10 CC with price floor
cloud-agent sell --market CC-USDC --amount 10 --price-limit 0.14
```

## `buy` and `sell` Flags

| **Flag**               | **Description**                                            |
| :--------------------- | :--------------------------------------------------------- |
| `--market <ID>`        | Market ID (e.g. `CC-USDC`)                                 |
| `--amount <N>`         | Total amount to fill (base instrument)                     |
| `--price-limit <N>`    | Max (buy) or min (sell) price per unit — default: mid ± 3% |
| `--min-settlement <N>` | Minimum per-round size (default: 5.0)                      |
| `--max-settlement <N>` | Maximum per-round size (default: total amount)             |
| `--interval <SECS>`    | Retry interval when no quote arrives (default: 60)         |

## `agent` mode flags

| **Flag**            | **Description**                                              |
| :------------------ | :----------------------------------------------------------- |
| `--settlement-only` | Disable order placement, only settle existing trades         |
| `--orders-only`     | Disable settlement, only place/manage grid orders            |
| `--no-restore`      | Skip loading previous state from `agent-state.json`          |
| `--no-reject`       | Accept all proposals without RFQ-state verification          |
| `--dry-run`         | Prepare and verify transactions without signing or executing |
| `--force`           | Sign and execute even if verification fails                  |
| `--confirm`         | Prompt for confirmation before signing each transaction      |
| `--verbose`         | Enable verbose logging                                       |
| `--config <PATH>`   | Path to agent.toml (default: `agent.toml`)                   |
