# Nightshade Order Book V4 — interface package

Everything a third party needs to read the Nightshade order book and place or
cancel orders on Alephium with [`@alephium/web3`](https://www.npmjs.com/package/@alephium/web3)
v1.11.7: the deployed contract artifacts, the transaction script
templates, the struct definitions and the generated TypeScript bindings.

Full documentation: https://docs.nightshade.finance/developers/orderbook-v4-interface/

## What's inside

- `artifacts/orderbook_v4/**.ral.json` — the 5 contracts and 18 transaction scripts
- `artifacts/structs.ral.json` — the 14 structs those artifacts reference
- `artifacts/ts/` — the generated TypeScript bindings
- `MANIFEST.json` — code hashes, deployment addresses and the source commit

## What's not included

- Ralph source code (.ral)
- test mocks
- OrderbookV5 / Analytics / token contracts
- admin and upgrade scripts

## Using it

Copy `artifacts/` into your project (the paths inside it matter — the generated
TypeScript imports the JSON by relative path) and make sure your `tsconfig.json`
has `"resolveJsonModule": true`.

```ts
import { web3 } from '@alephium/web3'
import { OrderbookV4, OrderbookGetPriceVolumesPagedV4 } from './artifacts/ts'

web3.setCurrentNodeProvider('https://wallet.mainnet.alephium.org')

const orderbook = OrderbookV4.at('xgAezMDftDJaSD5KWTFA6bp8m9KyEnk9szy6yp2B5obu')
const state = await orderbook.fetchState()

const volumes = await OrderbookGetPriceVolumesPagedV4.call({
  initialFields: {
    orderbookId: '3b3b5973c29b3356178fe84dafc08faa8cb9493abca78ebd55ef34b9f47be000',
    firstTokenId: '<first token id>',
    secondTokenId: '<second token id>',
    orderType: false,
    afterPrice: 0n
  },
  groupIndex: 0
})
```
