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

# Oracle

> Build with Scope, Kamino's on-chain oracle aggregator: read prices, inspect feed wiring, and refresh price slots

## Overview

Scope is Kamino's oracle aggregation framework for on-chain pricing. The Scope TypeScript SDK and REST endpoints provide direct access to price data, feed configuration, and refresh instructions. In leverage and flash-loan flows, price refreshes are commonly included before execution so reserves and strategies read the latest market data.

<Note>
  A Scope feed is a fixed-size account: each `OraclePrices` account holds 512 slots, and a token's USD price is resolved through a "scope chain" of up to 4 slot indices (padded with the sentinel `65535`). For the configuration side, read [Configure oracles](/docs/curators/markets/configuring-oracles) and [Scope oracle types](/docs/curators/markets/scope-oracle-types).
</Note>

## Key Components of Oracle Integration

<CardGroup cols={3}>
  <Card title="Prices" icon="dollar-sign">
    Read every populated slot in a feed, or resolve a single token via its scope chain.
  </Card>

  <Card title="Feed Internals" icon="database">
    Inspect a feed's configuration, per-hop chain metadata, and per-slot oracle mappings.
  </Card>

  <Card title="Refresh" icon="rotate">
    Build the permissionless refresh instruction that pushes fresh prices on-chain.
  </Card>
</CardGroup>

## Integration Options

<CardGroup cols={2}>
  <Card title="Scope TypeScript SDK" icon="code">
    On-chain reads against the Scope program plus the refresh-instruction builder. TypeScript only.
  </Card>

  <Card title="REST API" icon="globe">
    Off-chain aggregated Scope prices keyed by mint. Language-agnostic, no RPC required.
  </Card>
</CardGroup>

### Read all prices

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import { createSolanaRpc } from '@solana/kit';
    import { Scope, SCOPE_MAINNET_HUBBLE_FEED } from '@kamino-finance/scope-sdk';
    import Decimal from 'decimal.js';

    const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
    const scope = new Scope('mainnet-beta', rpc);

    const oraclePrices = await scope.getSingleOraclePrices({
      config: SCOPE_MAINNET_HUBBLE_FEED.configuration,
    });

    const populated = oraclePrices.prices
      .map((p, index) => ({ index, p }))
      .filter(({ p }) => p.price.value.toString() !== '0');

    console.log(`${populated.length} populated of ${oraclePrices.prices.length} slots`);
    populated.slice(0, 5).forEach(({ index, p }) => {
      const price = new Decimal(p.price.value.toString()).div(new Decimal(10).pow(Number(p.price.exp)));
      console.log(`  [${index}] ${price.toString()}`);
    });
    ```

    <a href="https://github.com/Kamino-Finance/scope-sdk" target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

### Get a single token price

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import { createSolanaRpc } from '@solana/kit';
    import { Scope, SCOPE_MAINNET_HUBBLE_FEED } from '@kamino-finance/scope-sdk';

    const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
    const scope = new Scope('mainnet-beta', rpc);

    // SOL/USD lives at slot 0 of the Hubble feed. Single-hop chain padded with 65535.
    const CHAIN = [0, 65535, 65535, 65535];

    const oraclePrices = await scope.getSingleOraclePrices({
      config: SCOPE_MAINNET_HUBBLE_FEED.configuration,
    });

    const { price, timestamp } = await scope.getPriceFromChain(CHAIN, oraclePrices);
    console.log(`Price: ${price.toString()} (updated ${new Date(timestamp.toNumber() * 1000).toISOString()})`);
    ```

    <a href="https://github.com/Kamino-Finance/scope-sdk" target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

## What's Covered

<CardGroup cols={2}>
  <Card title="Prices" icon="dollar-sign" href="/docs/build/developers/oracle/data/prices">
    Read every populated slot in a feed, or resolve a single token via its scope chain. SDK plus REST.
  </Card>

  <Card title="Feed Internals" icon="database" href="/docs/build/developers/oracle/data/feeds">
    Feed configuration, per-hop chain metadata, and per-slot oracle mappings.
  </Card>

  <Card title="Refresh Prices" icon="rotate" href="/docs/build/developers/oracle/operations/refresh">
    Build and send the permissionless refresh instruction for one or more slots.
  </Card>
</CardGroup>

## Relevant Links

<CardGroup cols={2}>
  <Card title="NPM SDK package" icon="npm" href="https://www.npmjs.com/package/@kamino-finance/scope-sdk">
    Install the Scope TypeScript SDK to read feeds and build refresh instructions.
  </Card>

  <Card title="Scope SDK repository" icon="github" href="https://github.com/Kamino-Finance/scope-sdk">
    TypeScript SDK source and example scripts.
  </Card>

  <Card title="Oracle Architecture" icon="book-open" href="/docs/security/oracles">
    Scope, price protection, and manipulation resistance explained.
  </Card>

  <Card title="Scope Oracle Types" icon="sliders" href="/docs/curators/markets/scope-oracle-types">
    Specialized Scope oracle entry types for fixed-income, multi-source, pegged, and LST assets.
  </Card>
</CardGroup>
