parent
4eb732a15c
commit
a17915f437
11
README.md
11
README.md
|
@ -18,11 +18,12 @@ A monorepo containing APIs, Utils, and examples for Switchboard V2.
|
||||||
|
|
||||||
### Program Examples
|
### Program Examples
|
||||||
|
|
||||||
| Package | Description |
|
| Package | Description |
|
||||||
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [anchor-feed-parser](./programs/anchor-feed-parser) | Anchor example program demonstrating how to deserialize and read an onchain aggregator. |
|
| [anchor-feed-parser](./programs/anchor-feed-parser) | Anchor example program demonstrating how to deserialize and read an onchain aggregator account. |
|
||||||
| [native-feed-parser](./programs/native-feed-parser) | Solana Program Library example demonstrating how to deserialize and read an onchain aggregator. |
|
| [native-feed-parser](./programs/native-feed-parser) | Solana Program Library example demonstrating how to deserialize and read an onchain aggregator account. |
|
||||||
| [anchor-vrf-parser](./programs/anchor-vrf-parser) | Anchor example program demonstrating how to deserialize and read an onchain verifiable randomness function (VRF) account. |
|
| [anchor-vrf-parser](./programs/anchor-vrf-parser) | Anchor example program demonstrating how to deserialize and read an onchain verifiable randomness function (VRF) account. |
|
||||||
|
| [anchor-buffer-parser](./programs/anchor-buffer-parser) | Anchor example program demonstrating how to deserialize and read an onchain buffer relayer account. |
|
||||||
|
|
||||||
### Client Examples
|
### Client Examples
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ from a provided data feed AccountInfo.
|
||||||
```rust
|
```rust
|
||||||
use anchor_lang::solana_program::clock;
|
use anchor_lang::solana_program::clock;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use switchboard_v2::{AggregatorAccountData, SWITCHBOARD_V2_DEVNET, SWITCHBOARD_V2_MAINNET};
|
use switchboard_v2::{AggregatorAccountData, SwitchboardDecimal, SWITCHBOARD_V2_DEVNET, SWITCHBOARD_V2_MAINNET};
|
||||||
|
|
||||||
// check feed owner
|
// check feed owner
|
||||||
let owner = *aggregator.owner;
|
let owner = *aggregator.owner;
|
||||||
|
@ -39,7 +39,7 @@ let decimal: f64 = feed.get_result()?.try_into()?;
|
||||||
feed.check_staleness(clock::Clock::get().unwrap().unix_timestamp, 300)?;
|
feed.check_staleness(clock::Clock::get().unwrap().unix_timestamp, 300)?;
|
||||||
|
|
||||||
// check if feed exceeds a confidence interval of +/i $0.80
|
// check if feed exceeds a confidence interval of +/i $0.80
|
||||||
feed.check_confidence_interval(0.80)?;
|
feed.check_confidence_interval(SwitchboardDecimal::from_f64(0.80))?;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Aggregator History
|
### Aggregator History
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
### Sbv2 Program Examples
|
### Sbv2 Program Examples
|
||||||
|
|
||||||
| Package | Description |
|
| Package | Description |
|
||||||
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [anchor-feed-parser](./anchor-feed-parser) | Anchor example program demonstrating how to deserialize and read an onchain aggregator. |
|
| [anchor-feed-parser](./anchor-feed-parser) | Anchor example program demonstrating how to deserialize and read an onchain aggregator account. |
|
||||||
| [native-feed-parser](./native-feed-parser) | Solana Program Library example demonstrating how to deserialize and read an onchain aggregator. |
|
| [native-feed-parser](./native-feed-parser) | Solana Program Library example demonstrating how to deserialize and read an onchain aggregator account. |
|
||||||
| [anchor-vrf-parser](./anchor-vrf-parser) | Anchor example program demonstrating how to deserialize and read an onchain verifiable randomness function (VRF) account. |
|
| [anchor-vrf-parser](./anchor-vrf-parser) | Anchor example program demonstrating how to deserialize and read an onchain verifiable randomness function (VRF) account. |
|
||||||
|
| [anchor-buffer-parser](./anchor-buffer-parser) | Anchor example program demonstrating how to deserialize and read an onchain buffer relayer account. |
|
||||||
|
|
|
@ -16,7 +16,7 @@ cpi = ["no-entrypoint"]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
switchboard-v2 = { path = "../../libraries/rs" }
|
# switchboard-v2 = { path = "../../libraries/rs" }
|
||||||
# switchboard-v2 = "^0.1.11"
|
switchboard-v2 = "^0.1.11"
|
||||||
anchor-lang = "^0.24.2"
|
anchor-lang = "^0.24.2"
|
||||||
solana-program = "~1.9.13"
|
solana-program = "~1.9.13"
|
|
@ -39,25 +39,12 @@ describe("anchor-buffer-parser test", () => {
|
||||||
const payer = (provider.wallet as AnchorWallet).payer;
|
const payer = (provider.wallet as AnchorWallet).payer;
|
||||||
|
|
||||||
let switchboard: SwitchboardTestContext;
|
let switchboard: SwitchboardTestContext;
|
||||||
let localnet = false;
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
// First, attempt to load the switchboard devnet PID
|
// Attempt to load the env from a local file
|
||||||
try {
|
|
||||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(
|
|
||||||
provider,
|
|
||||||
"9e8rQPoyVZeGA1mD2BBVqDthbFwircnfLTB5JE6yUFQR"
|
|
||||||
);
|
|
||||||
console.log("devnet detected");
|
|
||||||
return;
|
|
||||||
} catch (error: any) {
|
|
||||||
console.log(`Error: SBV2 Devnet - ${error.message}`);
|
|
||||||
}
|
|
||||||
// If fails, fallback to looking for a local env file
|
|
||||||
try {
|
try {
|
||||||
switchboard = await SwitchboardTestContext.loadFromEnv(provider);
|
switchboard = await SwitchboardTestContext.loadFromEnv(provider);
|
||||||
localnet = true;
|
console.log("local env file detected");
|
||||||
console.log("localnet detected");
|
|
||||||
return;
|
return;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log(`Error: SBV2 Localnet - ${error.message}`);
|
console.log(`Error: SBV2 Localnet - ${error.message}`);
|
||||||
|
|
|
@ -16,7 +16,7 @@ cpi = ["no-entrypoint"]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
switchboard-v2 = { path = "../../libraries/rs" }
|
# switchboard-v2 = { path = "../../libraries/rs" }
|
||||||
# switchboard-v2 = "^0.1.11"
|
switchboard-v2 = "^0.1.11"
|
||||||
anchor-lang = "^0.24.2"
|
anchor-lang = "^0.24.2"
|
||||||
solana-program = "~1.9.13"
|
solana-program = "~1.9.13"
|
|
@ -16,8 +16,8 @@ cpi = ["no-entrypoint"]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
switchboard-v2 = { path = "../../libraries/rs" }
|
# switchboard-v2 = { path = "../../libraries/rs" }
|
||||||
# switchboard-v2 = "^0.1.11"
|
switchboard-v2 = "^0.1.11"
|
||||||
anchor-lang = "^0.24.2"
|
anchor-lang = "^0.24.2"
|
||||||
anchor-spl = "^0.24.2"
|
anchor-spl = "^0.24.2"
|
||||||
solana-program = "~1.9.13"
|
solana-program = "~1.9.13"
|
||||||
|
|
|
@ -66,10 +66,7 @@ describe("anchor-vrf-parser test", () => {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
// First, attempt to load the switchboard devnet PID
|
// First, attempt to load the switchboard devnet PID
|
||||||
try {
|
try {
|
||||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(
|
switchboard = await SwitchboardTestContext.loadDevnetQueue(provider);
|
||||||
provider,
|
|
||||||
"9e8rQPoyVZeGA1mD2BBVqDthbFwircnfLTB5JE6yUFQR"
|
|
||||||
);
|
|
||||||
console.log("devnet detected");
|
console.log("devnet detected");
|
||||||
return;
|
return;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|
Loading…
Reference in New Issue