Skip to main content

Installation

To install the Reflect Oracle SDK within your development environment, run one of the following commands:

Overview

Doppler is the oracle solution used by Reflect. It enables extremely efficient oracle updates on Solana, requiring as little as 21 compute units per update. We use a fork of Doppler that uses 32 CUs due to an additional call to Clock sysvar.
  • Program ID: PRicevBH6BaeaE8qmrxrwGBZ5hSZ9vjBNue5Ygot1ML
The SDK exposes the Doppler class for interacting with oracle accounts: creating new oracle accounts, updating their payloads, and reading the latest data.

Quick Start

Initialize a Doppler instance with a Solana connection and an authority keypair.
initialize.ts

Updating an Oracle

Create an 8-byte payload (u64) and submit an update for an existing oracle account.
updateOracle.ts

Fetching Oracle Data

Read the latest oracle state and decode the price from the 8-byte payload.
fetchOracle.ts

Creating an Oracle Account

Create a new oracle account with an initial payload and slot.
createOracle.ts

Payloads and Serializers

  • Payload format: 8-byte array representing a u64. For prices, this commonly encodes fixed-point integers (e.g., micro-units for 6-decimal tokens).
  • Helpers: createPricePayload(u64) and readPriceFromPayload(payload) provide convenient encoding/decoding for price data.
  • Serializer: Use U8Array8Serializer to serialize and deserialize the 8-byte payloads when calling updateOracle and fetchOracle.

License

MIT