{"id":21044093,"url":"https://github.com/drift-labs/drift-rs","last_synced_at":"2026-04-02T19:31:33.410Z","repository":{"id":224458446,"uuid":"763304318","full_name":"drift-labs/drift-rs","owner":"drift-labs","description":"rust sdk to interact with drift v2","archived":false,"fork":false,"pushed_at":"2026-03-26T02:54:49.000Z","size":1935,"stargazers_count":50,"open_issues_count":11,"forks_count":44,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-03-26T23:57:47.501Z","etag":null,"topics":["dex","driftv2","perpetuals","rust","solana"],"latest_commit_sha":null,"homepage":"https://docs.rs/drift-rs/latest/drift_rs/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drift-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-26T03:13:25.000Z","updated_at":"2026-03-26T02:54:50.000Z","dependencies_parsed_at":"2024-05-01T02:27:52.522Z","dependency_job_id":"9dbc262c-b73b-4128-bc5e-1e03ac52f7b2","html_url":"https://github.com/drift-labs/drift-rs","commit_stats":null,"previous_names":["drift-labs/drift-rs"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/drift-labs/drift-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdrift-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdrift-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdrift-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdrift-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drift-labs","download_url":"https://codeload.github.com/drift-labs/drift-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drift-labs%2Fdrift-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31314379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dex","driftv2","perpetuals","rust","solana"],"created_at":"2024-11-19T14:15:24.008Z","updated_at":"2026-04-02T19:31:33.402Z","avatar_url":"https://github.com/drift-labs.png","language":"Rust","funding_links":[],"categories":["Awesome Drift"],"sub_categories":["Official SDK"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg height=\"120x\" src=\"https://uploads-ssl.webflow.com/611580035ad59b20437eb024/616f97a42f5637c4517d0193_Logo%20(1)%20(1).png\" /\u003e\n\n  \u003ch1 style=\"margin-top:20px;\"\u003edrift-rs\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003ca href=\"https://crates.io/crates/drift-rs\"\u003e\u003cimg alt=\"Crates.io\" src=\"https://img.shields.io/crates/v/drift-rs.img\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://docs.drift.trade/developer-resources/sdk-documentation\"\u003e\u003cimg alt=\"Docs\" src=\"https://img.shields.io/badge/docs-tutorials-blueviolet\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://discord.com/channels/849494028176588802/878700556904980500\"\u003e\u003cimg alt=\"Discord Chat\" src=\"https://img.shields.io/discord/889577356681945098?color=blueviolet\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/project-serum/anchor?color=blueviolet\" /\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n# drift-rs\n\nExperimental, high performance Rust SDK for building offchain clients for [Drift V2](https://github.com/drift-labs/protocol-v2) protocol.\n\nSee the official [docs](https://docs.rs/drift-rs/latest/drift_rs/)\n\n## Install\n```toml\ndrift-rs = { git = \"https://github.com/drift-labs/drift-rs\", tag = \"v1.0.0\" }\n```\n_*_ crates.io requires [libdrift](https://github.com/drift-labs/drift-ffi-sys/?tab=readme-ov-file#from-source) is installed and linked locally\n\n\n## Use\nThe `DriftClient` struct provides methods for reading drift program accounts and crafting transactions.  \nIt is built on a subscription model where live account updates are transparently cached and made accessible via accessor methods.  \nThe client may be subscribed either via Ws or gRPC.  \n\n```rust\nuse drift_rs::{AccountFilter, DriftClient, Wallet, grpc::GrpcSubscribeOpts};\nuse solana_sdk::signature::Keypair;\n\nasync fn main() {\n    let client = DriftClient::new(\n        Context::MainNet,\n        RpcClient::new(\"https://rpc-provider.com\"),\n        Keypair::new().into(),\n    )\n    .await\n    .expect(\"connects\");\n\n    // Subscribe via WebSocket\n    //\n    // 1) Ws-based live market and price changes\n    let markets = [MarketId::spot(1), MarketId::perp(0)];\n    client.subscribe_markets(\u0026markets).await.unwrap();\n    client.subscribe_oracles(\u0026markets).await.unwrap();\n    client.subscribe_account(\"SUBACCOUNT_1\");\n\n    // OR 2) subscribe via gRPC (advanced)\n    // gRPC automatically subscribes to all markets and oracles\n    client.grpc_subscribe(\n      \"https://grpc.example.com\".into(),\n      \"API-X-TOKEN\".into(),\n      GrpcSubscribeOpts::default()\n        .user_accounts(\"SUBACCOUNT_1\", \"SUB_ACCOUNT_2\")\n        .on_slot(move |new_slot| {\n          // do something on slot\n        })\n        .on_account(\n          AccountFilter::partial().with_discriminator(User::DISCRIMINATOR),\n          move |account| {\n              // do something on user account updates\n          })\n    ).await;\n\n    //\n    // Fetch latest values\n    ///\n    let sol_perp_price = client.oracle_price(MarketId::perp(0));\n    let subaccount_1: User = client.try_get_account(\"SUBACCOUNT_1\"));\n```\n## Setup\n\n### Mac\n\nInstall rosetta (m-series only) and configure Rust toolchain for `x86_64`  \n⚠️ `1.76.0-x86_64` must also be installed alongside latest stable rust\n\n```bash\nsoftwareupdate --install-rosetta\n\n# replace '1.85.0' with preferred latest stable version\nrustup install 1.85.0-x86_64-apple-darwin 1.76.0-x86_64-apple-darwin --force-non-host\n\nrustup override set 1.85.0-x86_64-apple-darwin\n```\n\n### Linux \n```bash\n# replace '1.85.0' with preferred latest stable version\nrustup install 1.85.0-x86_64-unknown-linux-gnu 1.76.0-x86_64-unknown-linux-gnu --force-non-host\n\nrustup override set 1.85.0-x86_64-unknown-linux-gnu\n```\n\n⚠️ the non-x86_64 toolchains are incompatible due to memory layout differences between solana program (BPF) and aarch64 and will fail at runtime with deserialization errors like: `InvalidSize`.\n\n## Local Development\ndrift-rs links to the drift program crate via FFI, build from source (default) by cloning git submodule or dynamically link with a version from [drift-ffi-sys](https://github.com/drift-labs/drift-ffi-sys/releases)\n\n**clone repo and submodules**\n```bash\ngit clone https://github.com/drift-labs/drift-rs \u0026\u0026\\\ncd drift-rs \u0026\u0026\\\ngit submodule update --init --recursive\n```\n\n**build**\n```bash\n# Build from source (default)\nCARGO_DRIFT_FFI_STATIC=1\n\n# Provide a prebuilt drift_ffi_sys lib \nCARGO_DRIFT_FFI_PATH=\"/path/to/libdrift_ffi_sys\"\n```\n## Development\n\n## Release\n`git tag v\u003cMAJOR.MINOR.PATCH\u003e \u0026\u0026 git push`\n\n## Updating IDL types\nfrom repo root dir:\n```shell\n./scripts/idl-update.sh\ncargo check # build new IDL types\n# commit changes...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrift-labs%2Fdrift-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrift-labs%2Fdrift-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrift-labs%2Fdrift-rs/lists"}