> ## 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.

# How to Buy & Sell Assets

**Silvana Book** operates differently from traditional exchanges. Orders are matched privately off-chain by agents and only settled on-chain once both sides fulfill the required conditions.

Here, you’ll learn how to execute buy and sell operations, understand price and quantity, and select the right trading method based on your strategy.

# Trading

Silvana supports two trading flows:

* **RFQ (Request for Quote)** is a request that a firm quotes from liquidity providers (LPs), accepts one, and then settles. Best when you want fast execution and an explicit quote.
* **Limit orders (CLOB)** are bids/offers on the order book and get filled when the market trades at your price. Best when you want price control and are willing to wait.

<Info>
  Example for `CBTC/CC` with quantity = 0.10 and price = 1000 (CC per CBTC):

  * **Buy**: receive `0.10 CBTC`, pay `100 CC`
  * **Sell**: deliver `0.10 CBTC`, receive `100 CC`
</Info>

# Buy via CLI

If your goal is simply to purchase an asset without building against the gRPC API yet, the fastest path is the Silvana Book agent CLI.

Throughout this page, commands use `cloud-agent`. If you haven’t installed it into your `PATH`, use `target/release/cloud-agent` instead.

The CLI purchase flow uses RFQ under the hood and can chunk a large buy into multiple settlements until the full amount is filled.

**Prerequisites**

<Note>
  The following links are **necessary** for developers to access the protocol, library interface, and reference implementation:

  * [**Proto specification**](https://github.com/SilvanaOne/silvana-book-agent/tree/main/proto/silvana)
  * [**NPM library**](https://www.npmjs.com/package/@silvana-one/orderbook)
  * [**Agent code repository**](https://github.com/SilvanaOne/silvana-book-agent)
</Note>

* Build the CLI:

```javascript theme={null}
cargo build --release -p orderbook-cloud-agent
```

* Onboard once (writes/updates your `.env`):

```javascript theme={null}
target/release/cloud-agent onboard --rpc <ORDERBOOK_GRPC_URL>
```

## Step 1. Pick a market

You’ll need a `market\_id` (example: `CBTC-CC`). Obtain it via `OrderbookService`.GetMarkets (or from your environment).

## Step 2. Sanity-check balances

```javascript theme={null}
cloud-agent info balance
```

## Step 3. Add a purchase via RFQ fill loop

```javascript theme={null}
# Buy <BASE_AMOUNT> units of base on <MARKET_ID>
cloud-agent buyer --market <MARKET_ID> --amount <BASE_AMOUNT>
```

Useful knobs:

* `--price-limit \<PRICE\>`: maximum price per 1 base (quote per base)
* `--min-settlement \<AMT\>`: minimum chunk size per settlement
* `--max-settlement \<AMT\>`: cap chunk size per settlement
* `--interval \<SECS\>`: retry interval between RFQ rounds

# Sell via CLI

Use this when you want to **sell the base asset** on a market (e.g., sell CBTC for CC on CBTC-CC) without wiring up the gRPC API. Like the buy loop, this uses RFQ and can split a large sell into multiple settlements, retrying until the full amount is filled.

```javascript theme={null}
# Sell <BASE_AMOUNT> units of base on <MARKET_ID>
cloud-agent seller --market <MARKET_ID> --amount <BASE_AMOUNT>
```

# Buy via RFQ

<Tip>
  **Goal**: request quotes, accept the best one, then track settlement to completion.
</Tip>

## Step 1. Choose a market

Call `OrderbookService.GetMarkets` and select `market_id`.

## Step 2. Request quotes

Call `OrderbookService.RequestQuotes` with:

* `market_id`
* `direction = "buy"`
* `quantity` (base quantity you want to buy)

## Step 3. Review quotes

For each quote, check:

* `price` (quote per base)
* `quote_quantity` (total quote you will pay)
* `valid_until` (expiry)
* optional deadlines: `allocate_before_secs`, `settle_before_secs`
* fee estimates: `estimated_total_fee`

## Step 4. Accept a quote

* Call `OrderbookService.AcceptQuote(rfq_id, quote_id)`.
* Save `proposal_id` (used to track settlement).

## Step 5. Track settlement

Subscribe: `OrderbookService.SubscribeSettlements`, or Poll: `SettlementService.GetSettlementStatus(settlement_id = proposal_id)` for authoritative step-by-step state.

# Sell via RFQ

Same as RFQ buy, but with `direction = "sell"` and `quantity` equal to the base amount you want to sell.

1. Choose a market (`GetMarkets` → `market_id`)
2. Request quotes (`direction = "sell"`, `quantity` = base to sell)
3. Review quotes (`price`, `quote_quantity`, `valid_until`, deadlines, fee estimate)
4. Accept a quote (`AcceptQuote` → save `proposal_id`)
5. Track settlement (`SubscribeSettlements` or `GetSettlementStatus`)

# Buy via limit order (CLOB)

<Tip>
  **Goal**: place a bid at your price and get filled when counterparties trade there.
</Tip>

## Step 1. Read the book

Call `OrderbookService.GetOrderbookDepth` and/or `OrderbookService.GetMarketData`.

## Step 2. Submit a bid

Call `OrderbookService.SubmitOrder` with:

* `order_type = ORDER_TYPE_BID`
* `price` and `quantity` (base)
* optional `time_in_force` and `expires_at`

## Step 3. Monitor fills

Submit `OrderbookService.SubscribeOrders` or `OrderbookService.GetOrders`.

## Step 4. Cancel if needed

Use `OrderbookService.CancelOrder(order_id)`.

## Step 5. Track settlement for matched fills

Use `OrderbookService.SubscribeSettlements` or `SettlementService.GetSettlementStatus`.

# Sell via limit order (CLOB)

Same as limit buy, but submit `order_type = ORDER_TYPE_OFFER` in Step 2.

# How to know a trade is complete

<Check>
  A trade is complete when its settlement proposal is **settled** (not just “accepted” or “in progress”).

  * **Orderbook view**: `SubscribeSettlements` / `GetSettlementProposals`
  * **Settlement view (authoritative)**: `SettlementService.GetSettlementStatus`
</Check>

# Common pitfalls

<Warning>
  1. FQ `direction` is always from the requester’s perspective.
  2. Сheck balances and keep a `CC` reserve for fees.
  3. Don’t accept after `valid\_until`.
  4. Respect minimum sizes and tick sizes from `GetMarkets`.
</Warning>
