Skip to main content

Python SDK for Dexodus perpetual futures trading platform on Base (v1.1.0 - Simplified Configuration)

Project description

dexodus-perps-sdk

Python SDK for Dexodus perpetual futures trading platform on Base.

v1.1.0 - Simplified Configuration

What's New:

  • 🎯 Only private key required - all other configuration is hardcoded
  • 🚀 Zero setup complexity - no more API keys or URLs to configure
  • Instant start - just provide your private key and trade
  • 🔄 Matches JavaScript SDK v1.1.0 - same simplified interface

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
  • Simplified Setup: Only private key required, everything else hardcoded

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 node or 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

Super Simple Setup - Only your private key is needed!

Set up your environment variables in a .env file:

# Required (only this!)
PRIVATE_KEY=your_private_key_here

# Optional
DEBUG=false

What's Hardcoded for You:

  • ✅ Chain ID: 8453 (Base mainnet)
  • ✅ RPC URL: Optimized Alchemy endpoint
  • ✅ Biconomy Paymaster: Pre-configured for sponsored gas
  • ✅ Bundler URL: Pre-configured Biconomy bundler
  • ✅ Contract Addresses: All Dexodus contracts

API Reference

Client Initialization

# Only private key required!
client = DexodusClient.create(
    private_key="your_private_key",  # Optional: uses PRIVATE_KEY env var if not provided
    debug=False  # Optional: Enable verbose logging
)

# Or even simpler with 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!')"

Migration from v1.0.0

If you're upgrading from v1.0.0, simply remove the configuration parameters:

# v1.0.0 (old)
client = DexodusClient.create(
    private_key="your_key",
    biconomy_paymaster_api_key="your_api_key",
    bundler_url="your_bundler_url"
)

# v1.1.0 (new - simplified!)
client = DexodusClient.create()  # That's it!

Requirements

  • Python: 3.7+
  • Node.js: 16+ (required for JavaScript SDK)
  • Network: Base network access
  • Funds: USDC for trading

Support

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dexodus_perps_sdk-1.1.0.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dexodus_perps_sdk-1.1.0-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file dexodus_perps_sdk-1.1.0.tar.gz.

File metadata

  • Download URL: dexodus_perps_sdk-1.1.0.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for dexodus_perps_sdk-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8c3ed5b902e8c7d9751c27e13dab1fb5dce886a7baa98f952ec53f9b9b0c6d40
MD5 516da4f1cd2fa4cb3dbf74195bac6791
BLAKE2b-256 76b5f44977f38e8b85178f14244039827a99d3bed16bb0fbe2f47649dc125626

See more details on using hashes here.

File details

Details for the file dexodus_perps_sdk-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dexodus_perps_sdk-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c34fe8a5fe204a4ff17fc70b0f71a281fe1021d0b4a33598436864805a6ac2f1
MD5 4ba6623907ae8ee53f848a4c5255ee9c
BLAKE2b-256 d57ffbef63240437470f5c9d0648c3b0f09458ff2db5b2b3be6140d193946670

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page