---
name: tape
description: Quote a Coinbase tokenized stock on Base. Use when a payment must become a B20 stock, when 0x refuses a stock, or when integrating Tape, /api/tape/quote, quoteTape, or TapeRouter.
license: MIT
metadata:
  author: laod
  version: "1.0"
---

# Tape

Tape quotes a buy of a Coinbase stock token on Base. The quote is the route, the pool, the calls to submit, a reference price, and one sentence. Show the sentence. Do not show venue errors.

Tape does not mint or redeem the share. Only the issuer's authorized participants can do that. Tape buys the stock on a Base pool.

## When to use

- A user pays with ETH, WETH, USDC, or another ERC-20 and must receive a `0xb200…` stock.
- A stock-paired market needs the stock before the next call (a song buy, a vault deposit, a follow-up).
- A quote from 0x says the buy token is not authorized, or "no conversion route."
- You need to know, before the user signs, whether a pool can fill.

## Do not

- Do not send a stock buy to 0x. 0x refuses tokenized stocks.
- Do not show raw venue text, legal-restriction strings, or "no conversion route."
- Do not spend more stock on the next step than `execution.minStockOut`.
- Do not treat `market.navUsd` or `market.executionUsd` as the amount the contract will deliver. `minStockOut` is the amount. The reference price is not the execution price.
- Do not invent a transfer policy id. Pass one only when the integrator already knows it.
- Do not tell the user a buy succeeded when `status` is `unavailable`.

## Quote

`POST /api/tape/quote`

```json
{
  "sellToken": "ETH",
  "stock": "BRK.B",
  "sellAmount": "1000000000000000",
  "taker": "0x0000000000000000000000000000000000000001",
  "slippageBps": 200
}
```

`sellToken` is `ETH`, `WETH`, `USDC`, or an ERC-20 address. `stock` is a ticker (`BRK.B`, `AAPL`) or a `0xb200…` address. `sellAmount` is a decimal string of raw units. `slippageBps` of 200 is 2 percent. Optional `router` is a deployed TapeRouter. Optional `followUp` is `{ target, data, value, spender?, stockAmount? }`. Optional `policyId` is a decimal string.

In the LAOD app:

```ts
import { quoteTape } from '@/lib/tape';

const quote = await quoteTape({
  sellToken: 'USDC',
  stock: 'BRK.B',
  sellAmount: 10_000_000n,
  taker,
  slippageBps: 200,
});
```

A malformed body returns HTTP 400 and a `sentence`. A real quote returns HTTP 200 even when `status` is `unavailable`.

## How to read the response

| Field | Use |
|---|---|
| `status` | `ready` or `unavailable` |
| `sentence` | The only line to show a person |
| `execution.minStockOut` | Maximum stock the next step may spend |
| `execution.expectedStockOut` | Expected stock, before slippage |
| `execution.pools` | Pools that filled the quote. `fee` 500 means 0.05% |
| `execution.allowanceTarget` | Who the user approves. Null when the payment is ETH |
| `execution.transaction` | The pool swap alone |
| `calls` | What to submit. Empty when unavailable |
| `atomic.mode` | `batch` or `router` |
| `atomic.call` | The single TapeRouter call, or null in batch mode |
| `market.executionUsd` | Pool price per token, when the venue reported dollars |
| `market.navUsd` | Reference price. Null when the catalog has no dated price |
| `market.stale` | The reference is older than the feed heartbeat |
| `market.sentence` | Say this if you show a dollar figure |
| `wallet.allowed` | `false` means the wallet was checked and cannot transfer the stock |

If `status` is `unavailable`, submit nothing. The sentence already explains it.

Tape refuses a quote whose dollar output is under half the dollar input. That check uses the venue's own dollar marks, not the reference price.

## Submit

Batch mode delivers the stock to `taker`, then runs `followUp` as the taker. Submit `calls` with `wallet_sendCalls` and `atomicRequired: true` when the wallet supports it. LAOD song buys use this path: the stock swap, then the Doppler buy, in one batch.

Router mode is one TapeRouter transaction. ETH is a single signature. An ERC-20 needs an approval of TapeRouter, then that call. The swap must pull the payment from TapeRouter and send the stock to TapeRouter. The owner of TapeRouter must already allow `execution.swapRouter`. If the follow-up reverts, the payment comes back.

Deploy:

```bash
TAPE_SWAP_ROUTERS=0x6131B5fae19EA4f9D964eAc0408E4408b66337b5 \
  npx hardhat run scripts/deployTapeRouter.js --network base --config contracts/hardhat.config.js
```

The router address in that command is Kyber's current Base router. If a later quote names a different `execution.swapRouter`, allow that address too. Use a multisig as owner.

## Pool check

`GET /api/tape/pool?stock=BRK.B`

Probes 10 USDC. `fillable: false` is a normal answer. Cache is one minute. Use this to disable a button before the user types an amount. Use the quote for the amount they will actually pay.

## LAOD

Song buys and the launch seed call Tape when the numeraire is a Coinbase stock. The trade panel shows `sentence` and does not enable Buy while the preview is `unavailable`.
