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

# Bitcoin and Solana

> What's different when a swap starts or ends on native Bitcoin or Solana.

Bitcoin is chain `-1` and Solana is chain `-2`. The quote, execute and status calls are the same as
on any chain. This page covers what your wallet code does differently.

## Bitcoin

**Buying BTC.** Set `destinationAddress` to the user's Bitcoin address. The execution is whatever
the source chain needs, usually a `TRANSACTION` or a `DEPOSIT`.

**Selling BTC** returns a `DEPOSIT`: the user sends BTC to `deposit.address`. With
[`signBitcoinPsbt`](#signbitcoinpsbt), some routes return a `TRANSACTION` instead.

* Set `userAddress` to the Bitcoin address the BTC is sent from. If it isn't a Bitcoin address, also
  set `refundAddress` to one. Set both on the quote: some venues won't take them later.
* From a native SegWit (`bc1q…`) `userAddress`, the answer includes `deposit.psbt`: the deposit,
  your fee as a second output and change back to the sender, built from their confirmed coins. Sign
  and broadcast it as is.
* Without `deposit.psbt` (another address type, too little balance), pay exactly `deposit.amount`
  to `deposit.address`. When the execution has a `fee`, add a second output of `fee.amount` sats to
  `fee.address` in the **same** transaction. One deposit per transaction.
* Or show the address and a QR code and let the user send from any wallet.

A Bitcoin deposit usually takes 30 minutes or more to settle. Poll `/status` every 10 to 15
seconds.

A swap that fails before the BTC is swapped sends it back to `refundAddress`, minus a refund fee.
One that fails later pays a stablecoin, WBTC or the output token to `destinationAddress`, sometimes
on another chain the route passed through, and can take over 6 hours. Both read `refunded`.

Quote a token to check that it routes from native BTC.
[`/tokens/btc-coverage`](https://docs.ravn.exchange/api-reference/btc-coverage) ranks RAVN's tokens by how many BTC venues
list them.

### `signBitcoinPsbt`

Set `signBitcoinPsbt: true`, with `broadcastViaRavn: true`, on the quote if your app signs a Bitcoin
PSBT that RAVN builds, with the JS SDK's `signBitcoinPsbt` handler. From a native SegWit (`bc1q…`)
`userAddress`, some routes can then win as a `TRANSACTION` instead of a `DEPOSIT`. If you charge
a fee, they sit out when it would come to under 546 sats, the smallest output Bitcoin nodes relay.

`transaction.psbt` is the whole payment from the user's confirmed coins: the amount to the venue,
its memo, your fee and change. Sign every input without broadcasting it, and post it to
[`/submit-transaction`](https://docs.ravn.exchange/api-reference/submit-transaction) within 30 minutes. RAVN sends only that
exact transaction.

Never pay that address any other way. Without the memo, Layerswap can't match the payment to the
swap, and its support needs proof of ownership and up to 3 days to return it.

## Solana

Native SOL is the mint `So11111111111111111111111111111111111111112`.

**A `TRANSACTION`** carries `transaction.serialized`, a base64 versioned transaction. Sign it and
send it with `confirmed` commitment: it's built on a confirmed blockhash, so a `finalized`
preflight reports `BlockhashNotFound` for its first \~13 seconds. Any fee is already inside it.
Send it from the user's own wallet: a smart account (Squads-style) that runs it inside its own
program pays the fee where RAVN can't see it.

**A `DEPOSIT`** is a transfer of `deposit.amount` to `deposit.address`. When it carries your fee,
`deposit.transaction` is the deposit and the fee as one unsigned transaction: sign and send it
within a minute, before its blockhash expires. Missed the minute? Call `/execute` again with a new
`Idempotency-Key` (the same key returns the same expired transaction) and send only to the **new**
deposit. Building it yourself? Put the fee in the **same** transaction: a System transfer for SOL,
or `createAssociatedTokenAccountIdempotent` then `transferChecked` (under the mint's own token
program, such as Token-2022) for a token. One deposit per transaction.

`/status` takes `txHash` only for EVM transactions. Don't send a Solana signature there.

### `broadcastViaRavn`

Set `broadcastViaRavn: true` on the quote if your app can post a signed Solana transaction back to
RAVN instead of broadcasting it. It adds routes that often price better:

* Layerswap memo payments: a Solana wallet's USDC into native BTC, or USDG into Robinhood Chain
  stocks, with no account rent. Often the best price under about \$200.
* Jupiter orders a market maker or gas sponsor also signs. Long-tail tokens can price 7 to 33 bp
  better, and a wallet short of SOL can still swap. This doesn't apply when RAVN adds your fee to
  the order: fees under 50 bps, and some pairs above. Then the market maker or gas sponsor can't sign it.

A `TRANSACTION` that then carries `submit` must **not** be broadcast. Sign it and post it to
[`/submit-transaction`](https://docs.ravn.exchange/api-reference/submit-transaction), within seconds for a Jupiter order. One
without `submit` you broadcast as usual.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.