Crates.io | drift-rs |
lib.rs | drift-rs |
version | |
source | src |
created_at | 2024-10-04 04:37:21.656002+00 |
updated_at | 2025-02-20 03:45:40.626339+00 |
description | Rust SDK for Drift V2 Protocol on the Solana blockchain. |
homepage | https://drift.trade |
repository | https://github.com/drift-labs/drift-rs |
max_upload_size | |
id | 1396126 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Experimental, high performance Rust SDK for building offchain clients for Drift V2 protocol.
# crates.io
drift-rs = "1.0.0-alpha.10"
# build from source
drift-rs = { git = "https://github.com/drift-labs/drift-rs", tag = "v1.0.0-alpha.10" }
use drift_rs::{DriftClient, Wallet};
use solana_sdk::signature::KeyPair;
async fn main() {
let client = DriftClient::new(
Context::MainNet,
RpcClient::new("https://rpc-provider.com"),
KeyPair::new().into(),
)
.await
.expect("connects");
/// Subscribe to Ws-based live prices, blockhashes, and oracle updates
let markets = [MarketId::spot(1), MarketId::perp(0)];
client.subscribe_markets(&markets).await.unwrap();
}
Install rosetta and configure Rust toolchain for x86_64
softwareupdate --install-rosetta
# replace `1.84.0` with preferred stable version
rustup install 1.84.0-x86_64-apple-darwin
rustup override set 1.84.0-x86_64-apple-darwin
⚠️ the default toolchain is incompatible due to memory layout differences between solana program (BPF) and aarch64 and will fail at runtime with deserialization errors like: InvalidSize
.
drift-rs links to the drift program crate via FFI, build from source (default) or dynamically link with a version from drift-ffi-sys
# Build from source (default)
CARGO_DRIFT_FFI_STATIC=1
# Provide a prebuilt drift_ffi_sys lib
CARGO_DRIFT_FFI_PATH="/path/to/libdrift_ffi_sys"
git tag v<MAJOR.MINOR.PATCH> && git push
res/drift.json
from protocol-v2 branchcargo check