Skip to main content

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

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

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.1.tar.gz (26.6 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.1-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

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

Hashes for dexodus_perps_sdk-1.1.1.tar.gz
Algorithm Hash digest
SHA256 409035fb6e206c50df0cfdf4ed2cfd2eaca3d36b704968a2413d90791a1b7aae
MD5 ef087d9ebfda9e7e7e413a6bd58e9d46
BLAKE2b-256 a3b7d9f02c49661371c68b2f6276233d3b38cc34e8e97d54ee0f442050dcb86c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dexodus_perps_sdk-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d60841ee52525a58af6c8a98adf6b6174df78014fca8aafb363e685a5a6eb22f
MD5 81a1dc57c1ef0433e8ffae563aa15543
BLAKE2b-256 c3722ef8ef9bd65cce0c764147b6063741bc116465ef6267cb6890b7f9bcf64d

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