Trading
The SDK supports market orders, limit orders, and stop-loss / take-profit management for crypto perpetuals on the main pool. All functions return a txSignature and (where applicable) a positionAddress.
For synthetic commodity trading (XAU, XAG, WTI) see Commodities.
Open a Long Position
For longs the collateralToken must match the principalToken - you deposit the asset you are trading.
import { openMarketLong } from 'adrena-sdk/core';
import { createKitClient } from 'adrena-sdk/clients';
const { wallet, rpc } = await createKitClient();
const result = await openMarketLong({
wallet,
rpc,
principalToken: 'JITOSOL', // asset to trade
collateralToken: 'JITOSOL', // must match principal for longs
collateralAmount: 10, // human-readable units (10 JITOSOL)
leverage: 3, // leverage multiplier
stopLossPrice: 130, // optional - trigger price in USD
takeProfitPrice: 180, // optional - trigger price in USD
});
console.log('tx:', result.txSignature);
console.log('position:', result.positionAddress);Open a Short Position
For shorts the collateralToken must be "USDC" regardless of which asset is being shorted.
Close a Long Position
Closes the existing long position for the given principal token. Defaults to the current oracle price.
Close a Short Position
Check Position Status
Fetch live P&L, size, liquidation price, and other position metrics.
Returned fields
entryPrice
Price at which the position was opened (USD)
pythPrice
Current oracle price (USD)
sizeUsd
Notional position size in USD
totalInterest
Accumulated borrow interest owed
exitFee
Fee charged on close
preFeePnl
P&L before fees
pnl
Net P&L after fees
openTime
Timestamp when the position was opened
updateTime
Timestamp of the most recent position update
Limit Orders
Place a conditional order that fills when the oracle price reaches a target level.
Cancel Stop Loss / Take Profit
Cancels an existing stop-loss and/or take-profit attached to an open position.
Confirming Transactions
All core functions submit transactions via Jito bundles. Use checkTransactionConfirmed to poll for on-chain confirmation:
If the Jito tip endpoint is unreachable the SDK falls back to a standard RPC send automatically.
Last updated
Was this helpful?
