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

# Reading markets

> Fetch markets, sleeves and prices straight from devnet.

Everything StonkMe shows is on-chain, so a tracker or bot can read it without our API. These examples use `@anchor-lang/core` and the `stonkme` IDL.

## All markets

```ts theme={null}
import { AnchorProvider, Program } from "@anchor-lang/core";
import { Connection, PublicKey } from "@solana/web3.js";
import idl from "./stonkme.json"; // the stonkme IDL

const connection = new Connection("https://api.devnet.solana.com", "confirmed");
const provider = new AnchorProvider(connection, {} as never, {});
const program = new Program(idl as never, provider);

const markets = await program.account.market.all();
for (const { publicKey, account } of markets) {
  console.log(publicKey.toBase58(), account.take, Object.keys(account.status)[0],
    `${account.joined}/${account.params.maxTraders} traders`);
}
```

## A market's sleeves

```ts theme={null}
const STONKME = new PublicKey("xxBZG1QR7xWNArM8LssvFoESzomYe1UrNoysZFPECDe");
const market = new PublicKey("<market address>");

// Sleeve accounts start with the market key right after the discriminator.
const sleeves = await program.account.sleeve.all([
  { memcmp: { offset: 8, bytes: market.toBase58() } },
]);
for (const { account } of sleeves) {
  console.log(account.trader.toBase58(), Number(account.allocated) / 1e6, "USDC slice",
    Number(account.collateral) / 1e6, "collateral");
}
```

## A price

```ts theme={null}
const VENUE = new PublicKey("E5XoF6nUokucSXx5CSYwUjFhSkAsH5YzyvTpg4xfbfgT");
const feed = Buffer.from("4244d07890e4610f46bbde67de8f43a4bf8b569eebe904f136b469f148503b7f", "hex"); // NVDAx
const [priceAccount] = PublicKey.findProgramAddressSync([Buffer.from("price"), feed], VENUE);

const { data } = (await connection.getAccountInfo(priceAccount))!;
const price = Number(data.readBigInt64LE(73)) * 10 ** data.readInt32LE(89);
const age = Date.now() / 1000 - Number(data.readBigInt64LE(93));
console.log(`NVDAx $${price.toFixed(2)}, ${Math.round(age)}s old`);
```

Every stock's feed id is in `onchain/stocks.json`.


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