sol-orderly-backend
v0.0.1
Published
Readme
Solana Orderly Network Backend Adapter
This package is based on the Orderly JS SDK’s Solana Adapter. It enables seamless USDC deposits and withdrawals on the Orderly Network from Node.js backend applications. While optimized for Raydium perpetual markets, it also supports other Orderly-compatible brokers.
The official Orderly SDK is primarily frontend-focused — this library bridges the gap for backend integration.
Table of Contents
Features
- Deposit USDC into Orderly Network vaults for Solana brokers
- Withdraw USDC from Orderly Network vaults back to your wallet
- Optimized for Raydium perpetual markets (compatible with other brokers)
- Built for Node.js backends (no wallet adapter UI required)
- Works on devnet and mainnet
- Handles Solana connection setup and transaction confirmation automatically
Installation
Install via npm:
npm install sol-orderly-backend
npm install @solana/web3.js bs58 dotenv @solana/spl-tokenUsage Examples
Deposit USDC
☘️ Before using, ensure you have created an Orderly account with your Solana wallet, and you have created a key, ✓ Deposit USDC into an Orderly Network vault for trading on a Solana broker:
import { Keypair, Connection } from '@solana/web3.js';
import bs58 from 'bs58';
import { DefaultSolanaWalletAdapter } from 'sol-orderly-backend/neuron1.backend.adapter.js';
// or require
// const { DefaultSolanaWalletAdapter } = require('sol-orderly-backend/neuron1.backend.adapter.js');
const solanaAdapter = new DefaultSolanaWalletAdapter();
// Load wallet from environment variable
const secret = process.env.SOLANA_SECRET_KEY;
const wallet = Keypair.fromSecretKey(bs58.decode(secret));
// Connect to Solana devnet
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
const depositData = {
accountId: 'your-orderly-account-id',
brokerId: 'raydium', // Broker ID
tokenAmount: 1.23, // Amount in USDC
};
async function deposit() {
try {
const txSig = await solanaAdapter.depositUSDC(
'devnet', // network can be either in [ 'devnet', 'mainnet']
connection,
{
payerWallet: wallet,
from: 'YourSolanaWalletAddress', // you wallet address from where you want to transfer USDC
data: depositData,
}
);
console.log('Deposit confirmed:', txSig);
} catch (error) {
console.error('Deposit failed:', error.message);
}
}
deposit();Withdraw USDC
Withdraw USDC from an Orderly Network vault back to your Solana wallet:
import { Keypair } from '@solana/web3.js';
import { DefaultSolanaWalletAdapter } from 'sol-orderly-backend/neuron1.backend.adapter.js';
// or require
// const { DefaultSolanaWalletAdapter } = require('sol-orderly-backend/neuron1.backend.adapter.js');
const solanaAdapter = new DefaultSolanaWalletAdapter();
const withdrawData = {
brokerId: 'raydium', // Orderly broker you registered with
amount: 2.5, // Amount in USDC , Remember that withdrawal fee is 1 USDC
orderlyAccountId: 'your-orderly-id', //
orderlyPublic: 'your-orderly-public', // Your public key with ed25519: prefix
};
async function withdraw() {
try {
const txSig = await solanaAdapter.withdrawUSDC(
'devnet', // network can be either in [ 'devnet', 'mainnet']
{
receiverWallet: wallet,
data: withdrawData,
receiver: 'YourSolanaWalletAddress', // your wallet address
}
);
console.log('Withdrawal confirmed:', txSig); // withdrawal transaction result
} catch (error) {
console.error('Withdrawal failed:', error.message);
}
}
withdraw();Security Notes
Your Solana secret key is highly sensitive — anyone with access can control your funds. Follow best practices:
- Never hardcode secret keys in source code.
- Use secure storage methods:
.envfile withdotenv(SOLANA_SECRET_KEY=your-key)- JSON keypair (
id.json) generated viasolana-keygen new - Secure vaults such as AWS KMS or hardware wallets
- Add
.envto.gitignoreto prevent accidental commits - Avoid logging sensitive data
- See Solana Documentation for secure key management
Disclaimer
This is an unofficial, community-maintained library for integrating Solana USDC deposits and withdrawals with the Orderly Network.
It is provided as-is with no guarantees or warranties. For mission-critical systems, validate functionality thoroughly or wait for an official SDK update.
Issues and contributions are welcome — please open a GitHub issue.
