Skip to main content

No project description provided

Project description

Supurr SDK

A Python SDK for interacting with the Supurr protocol, supporting both Up/Down and Above/Below trading products.

Installation

pip install supurr-sdk

Quick Start

Initialize the Exchange

from supurr_sdk import SupurrExchange

# Initialize with your private key and desired product
exchange = SupurrExchange(
    pk="your_private_key",
    product="up_down"  # or "above_below"
)

Accessing Token Information

# Get token name
token_name = exchange.token.name  # e.g., "WHYPE"

# Get token decimals
decimals = exchange.token.decimals  # e.g., 18

# Convert human readable amount to token decimals
amount = int(0.1 * 10**exchange.token.decimals)  # 0.1 token in decimals

# Convert token decimals to human readable amount
human_readable = amount / 10**exchange.token.decimals  # back to 0.1

Trading with Up/Down Product

# Set the active market
exchange.product.set_active_market("BTCUSD")

# Place a trade
result = exchange.place_trade(
    is_up=True,  # True for up, False for down
    amount=int(0.1 * 10**18),  # Amount in token-decimals
    duration=360  # Expiration time in seconds (should be multiple of 60)
)

Trading with Above/Below Product

# Set the active market
exchange.product.set_active_market("BTCUSD")

# Get valid expiry timestamps
valid_timestamps = exchange.product.get_valid_expiry_timestamps()

# Place a trade with strike price
result = exchange.place_trade(
    is_up=True,  # True for above, False for below
    amount=int(0.01 * 10**18),  # Amount in token-decimals
    expiration=valid_timestamps[0],  # Use a valid timestamp
    strike=84000  # Strike price
)

Checking Current Price

# Get current price for the active market
current_price = exchange.price_provider.get_price(exchange.product.active_market)

Retrieving Trade History

# Get all trades for the current user of particular product
user_trades = exchange.get_user_ongoing_trades()

# Get all trades across the protocol of particular product
all_trades = exchange.get_all_ongoing_trades()

Features

  • Support for both Up/Down and Above/Below trading products
  • Integration with Pyth price feeds
  • Automatic market selection and validation
  • Built-in token approval handling
  • Support for multiple markets (e.g., BTCUSD)

Available Markets

# Get current price for the active market
current_markets = exchange.product.markets
  • BTCUSD (with price precision of 1)

Error Handling

The SDK includes built-in validation for:

  • Invalid expiration times
  • Invalid strike prices
  • Market availability
  • Token approvals
  • Max trade size availability

Notes

  • All amounts should be provided in token-decimals (if token has 18 decimals than; 1Token= 10^18)
  • All time related information is expected in seconds (not ms).
  • The SDK uses Web3.py for blockchain interactions
  • Make sure to have sufficient token in wallet before trading

Development

To run the test suite:

pytest tests/

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

supurr_sdk-0.1.7.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

supurr_sdk-0.1.7-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file supurr_sdk-0.1.7.tar.gz.

File metadata

  • Download URL: supurr_sdk-0.1.7.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.15 Linux/6.2.0-39-generic

File hashes

Hashes for supurr_sdk-0.1.7.tar.gz
Algorithm Hash digest
SHA256 bce2bbfdf888b3372846dc3fd3c99ffd4f18f3c333260c5cf9e5b377049b910a
MD5 c9347a7beb1e6f733a5ad075695aeb26
BLAKE2b-256 ba98b75237f5e74e14d5a805254c8d29fefa00836bd4fa34032a5642d042471d

See more details on using hashes here.

File details

Details for the file supurr_sdk-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: supurr_sdk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.15 Linux/6.2.0-39-generic

File hashes

Hashes for supurr_sdk-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 af8b3ebd9e96e993b35708111a8b04eadeb91b307028c51bf2e4a36b29d74aa1
MD5 e9644ce6fd87f912754f0d58774f39c0
BLAKE2b-256 92800178e6595b2257d94e15b59620473d1636e55d11545deafd6ac5ba07fc97

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