sbv2-solana/website/docs/oracle/architecture.mdx

46 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebar_position: 1
slug: .
title: Architecture
---
import OracleMetrics from "/idl/types/OracleMetrics.md";
# Oracle Architecture
A Switchboard oracle is a Node.js container that sits between the Solana blockchain and the internet and waits for update requests from an oracle queue. An oracle queue assigns updates to oracles in a round robin fashion.
An oracle account is a program derived address (PDA) between the oracle queue its being initialized for, as well as the oracles staking wallet. Before an oracle is granted permissions to use a queue, it must transfer the minimum stake amount, set by the queue, to its staking wallet.
## Staking
An oracle is required to transfer `queue.minStake` tokens to its staking wallet, `oracle.tokenAccount`, before being granted queue permissions. The minStake acts as an insurance policy to entice honest oracle behavior.
## Heartbeat
An oracle is required to heartbeat on-chain in order to join the queue and be assigned update request. An oracle must heartbeat before the queue's specified `queue.oracleTimeout` or it will be removed from the queue by the queue's garbage collector.
## Metrics
The oracle also tracks its performance, `oracle.metrics`.
<OracleMetrics />
## Cost & Reward Estimations
An oracle is required to submit an [aggregatorSaveResult](/idl/instructions/aggregatorSaveResult) transaction each time it updates a feed, which incurs a cost of 5000 lamports. This fee is set by the Solana network and is subject to change.
$T_{perUpdate}=T_{queueReward} - 5000$
where,
- `T` is the raw token amount in base units (_Ex: lamports or satoshis_)
To estimate an oracles cost basis, you will need to know a queue's capacity (Oracles, Feeds, VRFs) and the average number of update request an oracle is assigned over a given time period.
You will also need to factor in the oracle's heartbeat cost, which is 5000 lamports each. The number of heartbeats is dependent on its `queue.oracleTimeout`, which determines how often an oracle is required to heartbeat.
## More Information
- [/idl/accounts/OracleAccountData](/idl/accounts/OracleAccountData)