drift

Build perpetual futures and spot trading applications on Solana using the Drift Protocol SDK.

1|1|Updated May 21, 2026
One-click install
npx skills add https://github.com/naruto11eth/cryptoskills --skill drift-naruto11eth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drift
Source: https://github.com/naruto11eth/cryptoskills/tree/main/skills/drift
Command: npx skills add https://github.com/naruto11eth/cryptoskills --skill drift-naruto11eth

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @drift-labs/sdk, @solana/web3.js, @coral-xyz/anchor, driftpy, and includes references (resource) components.

What problem does it solve? Developers building on Drift Protocol face complex SDK patterns: BigNumber precision handling, multiple order types, margin calculations, and sub-account management. This Skill provides complete, working TypeScript and Python code patterns for every Drift operation, eliminating guesswork around precision constants, order parameters, and account initialization. ## Core Features & Use Cases - Trading Operations: Place market, limit, trigger, and oracle orders for perpetual futures and spot markets, with post-only enforcement and atomic cancel-and-place. - Account & Position Management: Initialize user accounts, deposit and withdraw collateral, query positions, calculate PnL, leverage, health, and liquidation prices. - Advanced Integrations: Execute Jupiter swaps through Drift, subscribe to protocol events, manage vaults, implement market making strategies, and use Swift off-chain order signing. - Use Case: Build a market making bot that quotes around the oracle price, adjusts spreads based on inventory, enforces position limits, and shuts down gracefully using the included trading bot template. ## Quick Start Set up a Drift client on Solana mainnet and place a limit order to buy 1 SOL-PERP at $100 using the Drift SDK.

Frequently Asked Questions about drift

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I place a perpetual futures order on Drift Protocol?

Use driftClient.placePerpOrder with orderType, marketIndex, direction, and baseAssetAmount converted via convertToPerpPrecision. Limit orders also require a price in PRICE_PRECISION, and trigger orders need triggerPrice and triggerCondition.

How do I set up the Drift SDK with TypeScript on Solana?

Install @drift-labs/sdk, @solana/web3.js, and @coral-xyz/anchor, then create a DriftClient with a Connection, Wallet, and environment. Call subscribe() before use, and initialize a user account with initializeUserAccount if one does not exist.

Does Drift Protocol have a Python SDK?

Yes, DriftPy provides Python bindings installable via pip install driftpy. It supports the same core operations as the TypeScript SDK, including DriftClient setup, account subscription, and order placement.

Why does my Drift order fail with OrderWouldCrossMaker?

This error occurs when a post-only order would execute as a taker by crossing the spread. Fix it by pricing below the current ask, using PostOnlyParams.TRY_POST_ONLY to skip silently, or PostOnlyParams.SLIDE to auto-adjust the price.

How do I calculate liquidation price and account health on Drift?

Use the User class methods: user.liquidationPrice(marketIndex) returns the liquidation price for a perp position, user.getHealth() returns account health from 0-100, and user.canBeLiquidated() checks liquidation risk.

What precision should I use for Drift order amounts?

Drift uses BN.js with fixed precision: QUOTE_PRECISION (10^6) for USDC, BASE_PRECISION (10^9) for perp sizes, and PRICE_PRECISION (10^6) for prices. Use convertToPerpPrecision, convertToSpotPrecision, and convertToPricePrecision helpers for correct conversion.