A Peer-2-Peer DEX built on Solana that enables leveraged predictions on any SPL Token since mint.
The project consists of:
- Rust Solana Program: Core on-chain logic for position management and operations
- JavaScript Client API: Easy-to-use interface for interacting with the on-chain program (perfect for any kind of implementation; DEX, Games, Bots..)
- Leveraged Positions: Support for up to 5x leverage (for now)
- Long/Short Positions: Predict in both directions
- Position Management: Initialize, modify, and close positions
- PnL Processing: Automatic profit and loss calculations
- Market Liquidity: Decentralized liquidity per ticker ensuring bad actors cannot bankrupt the DEX
- Fee Structure: Base fees (2%) + leverage fees (0.1% per leverage level) + account creation fee
INITIALIZE: Create new leveraged positionsDEX_MODIFY: Update position parameters (DEX authority only)USER_MODIFY: User-initiated position modificationsPROCESS_PNL: Calculate and distribute profits/lossesFORCE_CLOSE: Emergency position closureMARKET_TRANSFER: Transfer liquidity between markets
const PROGRAM_ID = "URAa3qGD1qVKKqyQrF8iBVZRTwa4Q8RkMd6Gx7u2KL1";
const DEX_PUBKEY = "URAbknhQPhFiY92S5iM9nhzoZC5Vkch7S5VERa4PmuV";
const DEX_FEES_PUBKEY = "URAfeAaGMoavvTe8vqPwMX6cUvTjq8WMG5c9nFo7Q8j";- Node.js 16+
mkdir my-project
cd my-project
npm install uranus-dex-onchain-apiconst { createUranusPositionTransaction } = require('uranus-dex-onchain-api');
const { transaction, positionNonce, positionPda, fees } = await createUranusPositionTransaction(
connection,
ownerKeypair, // User's keypair
mintAddress, // Token mint address
1.0, // SOL amount
3, // 3x leverage
"long" // Direction: "long" or "short"
);
await sendAndConfirmTransaction(connection, transaction, [ownerKeypair]);const { closeUranusPosition } = require('./onchain-api');
const transaction = await closeUranusPosition(
connection,
positionNonce, // Position ID
ownerKeypair, // Owner's keypair
positionPda // Position account address (optional)
);
await sendAndConfirmTransaction(connection, transaction, [ownerKeypair]);For more, visit https://uranus.ag/docs
| Function | Description |
|---|---|
createUranusPositionTransaction() |
Create a new leveraged position |
closeUranusPosition() |
Close an existing position |
getOpenPositions() |
Retrieve open positions with filtering |
getMarketLiquidity() |
Get liquidity for a specific market |
getMarketVolume() |
Calculate trading volume for time period |
getAllMarkets() |
List all available trading markets |
getTickerPrice() |
Fetch current price for a ticker |
pub struct PositionAccount {
pub owner: Pubkey, // Position owner
pub market_mint: Pubkey, // Market token mint
pub market_symbol: [u8; 32], // Market symbol (e.g., "SOL")
pub entry_price: u64, // Entry price in lamports
pub liquidation_price: u64, // Liquidation threshold
pub paid_amount: u64, // Amount paid (after fees)
pub position_size: u64, // Total position size
pub leverage: u8, // Leverage multiplier (1-5x)
pub closed: u8, // Position status
pub position_nonce: u64, // Unique position ID
pub pnl: i64, // Currently unused
pub direction: i8, // 1 = Long, -1 = Short
}- Base Fee: 2% of position value
- Leverage Fee: 0.1% per leverage level
- Minimum Position: 0.01 SOL
- Maximum Leverage: 5x
For a 1 SOL position with 3x leverage:
- Base Fee: 1 SOL × 2% = 0.02 SOL
- Leverage Fee: 1 SOL × 0.023% = 0.0023 SOL
- Total Fees: 0.023 SOL
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Repository: https://github.com/URANUSDEX/dex
- Issues: https://github.com/URANUSDEX/dex/issues
- Website: https://uranus.ag
For support and questions:
- Open an issue on GitHub
- Contact: sakidev (solo dev founder)