parent
4eb732a15c
commit
a17915f437
|
@ -19,10 +19,11 @@ A monorepo containing APIs, Utils, and examples for Switchboard V2.
|
|||
### Program Examples
|
||||
|
||||
| Package | Description |
|
||||
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [anchor-feed-parser](./programs/anchor-feed-parser) | Anchor example program 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. |
|
||||
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [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 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
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from a provided data feed AccountInfo.
|
|||
```rust
|
||||
use anchor_lang::solana_program::clock;
|
||||
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
|
||||
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)?;
|
||||
|
||||
// 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
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
### Sbv2 Program Examples
|
||||
|
||||
| Package | Description |
|
||||
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [anchor-feed-parser](./anchor-feed-parser) | Anchor example program 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. |
|
||||
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [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 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 = []
|
||||
|
||||
[dependencies]
|
||||
switchboard-v2 = { path = "../../libraries/rs" }
|
||||
# switchboard-v2 = "^0.1.11"
|
||||
# switchboard-v2 = { path = "../../libraries/rs" }
|
||||
switchboard-v2 = "^0.1.11"
|
||||
anchor-lang = "^0.24.2"
|
||||
solana-program = "~1.9.13"
|
|
@ -39,25 +39,12 @@ describe("anchor-buffer-parser test", () => {
|
|||
const payer = (provider.wallet as AnchorWallet).payer;
|
||||
|
||||
let switchboard: SwitchboardTestContext;
|
||||
let localnet = false;
|
||||
|
||||
before(async () => {
|
||||
// First, attempt to load the switchboard devnet PID
|
||||
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
|
||||
// Attempt to load the env from a local file
|
||||
try {
|
||||
switchboard = await SwitchboardTestContext.loadFromEnv(provider);
|
||||
localnet = true;
|
||||
console.log("localnet detected");
|
||||
console.log("local env file detected");
|
||||
return;
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Localnet - ${error.message}`);
|
||||
|
|
|
@ -16,7 +16,7 @@ cpi = ["no-entrypoint"]
|
|||
default = []
|
||||
|
||||
[dependencies]
|
||||
switchboard-v2 = { path = "../../libraries/rs" }
|
||||
# switchboard-v2 = "^0.1.11"
|
||||
# switchboard-v2 = { path = "../../libraries/rs" }
|
||||
switchboard-v2 = "^0.1.11"
|
||||
anchor-lang = "^0.24.2"
|
||||
solana-program = "~1.9.13"
|
|
@ -16,8 +16,8 @@ cpi = ["no-entrypoint"]
|
|||
default = []
|
||||
|
||||
[dependencies]
|
||||
switchboard-v2 = { path = "../../libraries/rs" }
|
||||
# switchboard-v2 = "^0.1.11"
|
||||
# switchboard-v2 = { path = "../../libraries/rs" }
|
||||
switchboard-v2 = "^0.1.11"
|
||||
anchor-lang = "^0.24.2"
|
||||
anchor-spl = "^0.24.2"
|
||||
solana-program = "~1.9.13"
|
||||
|
|
|
@ -66,10 +66,7 @@ describe("anchor-vrf-parser test", () => {
|
|||
before(async () => {
|
||||
// First, attempt to load the switchboard devnet PID
|
||||
try {
|
||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(
|
||||
provider,
|
||||
"9e8rQPoyVZeGA1mD2BBVqDthbFwircnfLTB5JE6yUFQR"
|
||||
);
|
||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(provider);
|
||||
console.log("devnet detected");
|
||||
return;
|
||||
} catch (error: any) {
|
||||
|
|
Loading…
Reference in New Issue