Skip to the content
TAPEHOUSE

Documentation · Guides

Read a price

Read a Stock Token's band, the market session and any trading halt from the chain, and tell a price from no price.

Every Stock Token has a band on chain: a low edge, a centre and a high edge, with a state that says how far to trust it. In this guide you read the band of TSLA, the session it follows and the halt that can stop it, from code or over HTTP. You need no wallet and no ether.

Before you start#

  • A chain's registry, deployments/46630.json in the repository. The SDKs compile in no address.
  • An SDK, installed as in the quickstart, or curl.
  • The testnet RPC https://rpc.testnet.chain.robinhood.com, or the public indexer https://indexer-production-f5dc.up.railway.app.

The examples below reuse the client and deployments the quickstart builds.

1. Read the band#

TypeScript
import { band } from '@tapehouse/sdk'

const { state, live, mid, halfBps, low, high } = await band.quote(client, deployments, 'TSLA')
FieldMeaning
state0 halted, 1 degraded, 2 closed, 3 open
liveHow many price legs are live
midThe band's centre, USD with 8 decimals
halfBpsThe half-width, in basis points
low, highThe band's edges, USD with 8 decimals

All fields are zero while the band is halted. The margin accounts value a Stock Token at low, and a short position is margined at high. The band explains how the width is set.

2. Read the session#

The band's state follows two clocks: Chainlink's 24/5 session and NYSE's regular hours.

TypeScript
const { state, nyse, nyseNext, changeMs, boundaryMs } = await band.session(client, deployments)

state is 0 when the session is not known, 1 closed and 2 open. changeMs and boundaryMs are milliseconds. The session says what happens to the band at each boundary.

3. Read the halt#

A halt stops the band from pricing an asset. Three things cause one: a halt signed by Tapehouse's halt signer, a pause of the Stock Token's oracle by its issuer, and a multiplier change that Chainlink has not yet confirmed.

TypeScript
const { signedHalt, until, issuedAt, oraclePaused } = await band.halt(client, deployments, 'TSLA')

Each asset has a BandFeed that serves the band's low side as Chainlink's latestRoundData, so a contract that already reads Chainlink can read the band.

TypeScript
const round = await band.latestRound(client, deployments, 'TSLA')
const whole = await band.latestBand(client, deployments, 'TSLA')

The round's answer is the band's low edge, and its round ID and updatedAt are the block time.

What to expect#

  • Closed, degraded and halted bands are valid answers. A reader that needs a price checks state first: a halted band has no price, and a degraded one has a wider band.
  • While the market is closed the band has a price only while someone writes a fresh RedStone package to it, which anyone may do. A band nobody has written to for two minutes can have no live leg.
  • Pin a read to a block when you compare several: the TypeScript functions take { blockNumber } as their last argument, the Go ones a *bind.CallOpts with BlockNumber, the Rust calls .block(...), and the HTTP view a block query parameter.

Errors you may hit#

ErrorCause
The registry has no .bandFeeds.<asset>The registry names no BandFeed for that asset. Check deployments/<chainId>.json.
Error::Argument in Rust, an error from ToBytes32 in GoAn asset name longer than 32 bytes.
NoAnswer(symbol)A BandFeed's latestRoundData or a Morpho oracle read a band with no price. See the Morpho oracle guide.

Next#