Python SDK for Dexodus perpetual futures trading platform on Base
Project description
dexodus-perps-sdk
Python SDK for Dexodus perpetual futures trading platform on Base.
Features
- Position Management: Open, close, increase, and decrease positions
- Real-Time Data: Get positions with live PnL, ROE, and liquidation prices
- Limit Orders: Create Take Profit and Stop Loss orders
- Sponsored Gas: Free transactions for position management
- Market Symbols Enum: Type-safe market selection with IDE autocomplete
- Debug Mode: Verbose logging for development and troubleshooting
- Streamlined Setup: Minimal configuration required
Installation
Prerequisites
This package requires Node.js 16+ to be installed on your system, as it uses the JavaScript SDK internally.
Install Node.js:
- macOS:
brew install nodeor download from nodejs.org - Ubuntu/Debian:
sudo apt install nodejs npm - Windows: Download from nodejs.org
Install Node.js dependencies:
npm install @pythnetwork/hermes-client @biconomy/account ethers dotenv
Install Python Package
pip install dexodus-perps-sdk
Quick Start
from dexodus_perps_sdk import DexodusClient, MarketSymbols
# Initialize client (only private key required!)
client = DexodusClient.create(
debug=False # Optional: Set to True for verbose logging
)
# Open a long position
result = client.open_long(
market=MarketSymbols.BTC,
size=50.0, # $50 position
collateral=10.0, # $10 collateral (5x leverage)
slippage=0.5 # 0.5% slippage
)
print(f"Position opened! TX: {result['transactionHash']}")
Configuration
The SDK requires only your private key for authentication. All network and contract configurations are pre-configured for the Base mainnet.
Set up your environment variables in a .env file:
# Required
PRIVATE_KEY=your_private_key_here
# Optional
DEBUG=false
Network Configuration:
- Network: Base mainnet (Chain ID: 8453)
- Gas Sponsorship: Enabled for position operations
- Contract Integration: Fully configured for Dexodus protocol
API Reference
Client Initialization
# Initialize with private key
client = DexodusClient.create(
private_key="your_private_key", # Optional: uses PRIVATE_KEY env var if not provided
debug=False # Optional: Enable verbose logging
)
# Initialize using environment variable
client = DexodusClient.create() # Uses PRIVATE_KEY from .env
Position Management
# Open positions
client.open_long(market=MarketSymbols.BTC, size=50, collateral=10, slippage=0.5)
client.open_short(market=MarketSymbols.ETH, size=30, collateral=10, slippage=0.5)
# Modify positions
client.increase_position(market=MarketSymbols.BTC, is_long=True, size_delta=25, slippage=0.5)
client.decrease_position(market=MarketSymbols.BTC, is_long=True, size_delta=30, slippage=0.5)
# Get positions with real-time data
positions = client.get_positions()
for pos in positions:
print(f"{pos['marketName']} {pos['isLong'] and 'Long' or 'Short'}: ${pos['pnl']:.2f} PnL")
Limit Orders
# Take Profit
client.create_take_profit(
market=MarketSymbols.BTC,
is_long=True,
size_to_close=25.0,
limit_price=50000.0,
slippage=0.5
)
# Stop Loss
client.create_stop_loss(
market=MarketSymbols.BTC,
is_long=True,
size_to_close=50.0,
limit_price=40000.0,
slippage=0.5
)
Fund Management
# Deposit/withdraw USDC
client.deposit(100.0) # Deposit $100 USDC
client.withdraw(50.0) # Withdraw $50 USDC
# Check balances
balances = client.get_balances()
print(f"Smart Account: ${balances['smartAccount']} USDC")
Market Symbols
Use the MarketSymbols class for type safety:
from dexodus_perps_sdk import MarketSymbols
# Available markets
MarketSymbols.BTC # "BTC"
MarketSymbols.ETH # "ETH"
MarketSymbols.SOL # "SOL"
# ... and more
Gas Fees
- Position Operations: FREE (sponsored by protocol)
- Withdrawals: Paid in USDC (deducted from withdrawal amount)
- Deposits: Standard ETH gas fees
Testing
Test your installation:
# Run the built-in test
dexodus-perps-test
# Or in Python
python -c "from dexodus_perps_sdk import MarketSymbols; print('SDK installed correctly!')"
Requirements
- Python: 3.7+
- Node.js: 16+ (required for JavaScript SDK)
- Network: Base network access
- Funds: USDC for trading
Support
- Documentation: https://docs.dexodus.com/sdk
- Issues: https://github.com/dexodus/perps-sdk-python/issues
- Discord: https://discord.gg/dexodus
- JavaScript SDK: https://www.npmjs.com/package/dexodus-perps-sdk
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dexodus_perps_sdk-1.1.1.tar.gz.
File metadata
- Download URL: dexodus_perps_sdk-1.1.1.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
409035fb6e206c50df0cfdf4ed2cfd2eaca3d36b704968a2413d90791a1b7aae
|
|
| MD5 |
ef087d9ebfda9e7e7e413a6bd58e9d46
|
|
| BLAKE2b-256 |
a3b7d9f02c49661371c68b2f6276233d3b38cc34e8e97d54ee0f442050dcb86c
|
File details
Details for the file dexodus_perps_sdk-1.1.1-py3-none-any.whl.
File metadata
- Download URL: dexodus_perps_sdk-1.1.1-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d60841ee52525a58af6c8a98adf6b6174df78014fca8aafb363e685a5a6eb22f
|
|
| MD5 |
81a1dc57c1ef0433e8ffae563aa15543
|
|
| BLAKE2b-256 |
c3722ef8ef9bd65cce0c764147b6063741bc116465ef6267cb6890b7f9bcf64d
|