Switchboard V2 SDK is Here!
Current Switchboard V2 SDK Layout
Clone the repository
git clone [https://github.com/switchboard-xyz/switchboard-v2.git](https://github.com/switchboard-xyz/switchboard-v2.git) && cd switchboard-v2
Then, install and link the dependencies
yarn workspaces run build
yarn workspace @switchboard-xyz/switchboardv2-cli link
anchor build && node ./scripts/setup-example-programs.js
Finally, test the example programs
The SDK supports copying a Switchboard devnet environment to your localnet environment for integration testing. This is useful if you want to see how your program will react to Switchboard data feed updates.
First, change the cluster to localnet in Anchor.toml.
Next, create a Switchboard devnet queue and oracle.
sbv2 localnet:env --keypair ../payer-keypair.json -o .switchboard
This command will output:
start-local-validator.sh: starts a local Solana validator with the Switchboard program, IDL, and our devnet environment pre-loaded
start-oracle.sh: start a Switchboard oracle and start heartbeating on the localnet queue
docker-compose.yml: docker file with the Switchboard oracle environment
switchboard.env: contains your Switchboard accounts
In three separate shells, run the following commands in this order:
anchor test --skip-local-validator
The anchor tests are configured to first fetch the account info for the Switchboard DAO controlled devnet permissionless queue. If the account info is not found, it assumes a localnet connection and looks for the switchboard.env with your Switchboard environment specific public keys. If a .switchboard directory or switchboard.env file is not found in the root project directory, it will look 2 levels higher until giving up.
Uniswap & SushiSwap Task Types
Switchboard has added the UniswapExchangeRateTask and SushiSwapExchangeRateTask to resolve the swap price of assets on Uniswap and SushiSwap. These new task types will allow Solana protocols to offer DeFi products using data sourced from Ethereum.
Switchboard also ported over the xStepPriceTask from Switchboard V1 to Switchboard V2. The following is an example of how to use the new task type:
SplTokenParseTask & SplStakePoolTask
Switchboard has added the SplTokenParseTask and SplStakePoolTask to resolve on-chain data in your Switchboard feeds. This will allow developers to build data feeds using live on-chain data. The following is an example of how to fetch the total token supply of the MonkeeDao stake pool:
The publisher got a facelift
… more details soon™!
The Switchboard V2 SDK is here to help developers integrate Switchboard into their applications. We welcome any PRs or feedback from the community!