drift

Build Solana trading applications with the Drift Protocol SDK for perpetual futures and spot markets.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI agents and developers often lack accurate, up-to-date knowledge of the Drift Protocol SDK, leading to incorrect precision handling, wrong order parameters, and broken Solana transactions when building trading bots or DeFi integrations. ## Core Features & Use Cases - Order Placement & Management: Place, modify, and cancel market, limit, trigger, and oracle orders for perpetual futures and spot markets with correct BN precision. - Account & Position Operations: Initialize user accounts, manage deposits and withdrawals, query collateral, margin, leverage, health, PnL, and liquidation prices. - Advanced Integrations: Execute Jupiter swaps, subscribe to protocol events, run market-making strategies, manage Drift Vaults, and use Swift off-chain order signing. - Use Case: Build a market-making bot that quotes around the oracle price with post-only orders, adjusts spreads based on inventory, and enforces position limits using the included trading bot template. ## Quick Start Ask the agent to set up a DriftClient on Solana mainnet and place a limit order for 1 SOL-PERP at a specified price 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, PositionDirection, and baseAssetAmount converted via convertToPerpPrecision. Limit orders also require a price converted with convertToPricePrecision, and trigger orders need triggerPrice and triggerCondition.

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

Install @drift-labs/sdk, @solana/web3.js, and @coral-xyz/anchor, then create a DriftClient with a Connection, Wallet, and env set to mainnet-beta or devnet. Call subscribe() before querying accounts, and initialize a user account if one does not exist.

Does the Drift SDK support Python development?

Yes, the driftpy package provides a Python DriftClient with async methods for subscribing, initializing user accounts, and trading. Install it with pip install driftpy and use it with solders and anchorpy for wallet handling.

Why does my Drift order fail with OrderWouldCrossMaker?

This error occurs when a post-only limit order would execute as a taker by crossing the spread. Adjust the price away from the current ask, use PostOnlyParams.TRY_POST_ONLY to skip silently, or PostOnlyParams.SLIDE to auto-adjust the price.

How do I convert amounts to Drift precision units?

Use driftClient.convertToPerpPrecision for perp sizes, convertToSpotPrecision with the market index for spot tokens, and convertToPricePrecision for prices. For reading values, use convertToNumber with constants like QUOTE_PRECISION (10^6) and BASE_PRECISION (10^9).

How do Drift Vaults handle user withdrawals?

Depositors call requestWithdraw with a share amount, wait for the vault's redeem period, then call withdraw to complete the process. Managers cannot bypass the redeem period or directly withdraw user funds.