Skip to main content

OMX python api

Python client for interacting with OMX contracts.

ReadTheDocs PyPi PyPi PyPi

Installation

Requirements

pip install omxpy
# or with poetry
poetry add omxpy

Example

from cosmpy.aerial.config import NetworkConfig
from cosmpy.tx.rest_client import RestClient
from omxpy.contracts.omx_cw_router import OmxCwRouter
from omxpy.contracts.omx_cw_vault import OmxCwVault
from cosmpy.aerial.wallet import LocalWallet

wallet = LocalWallet.from_mnemonic("...", prefix="osmo")

net_cfg = NetworkConfig(
    chain_id="localosmosis",
    fee_denomination="uosmo",
    staking_denomination="stake",
    fee_minimum_gas_price=0.025,
    url="rest+http://127.0.0.1:1317",
)
rest_client = LedgerClient(net_cfg)
tx_client = TxRestClient(rest_client)

# replace with your contract addresses
vault_addr = "osmo1w..."
osmo_addr = "osmo1j..."
router_addr = "osmo16..."

# create contract clients
router = OmxCwRouter(
    tx=rest_client,
    contract_addr=router_addr,
    net_cfg=net_cfg
    wallet=wallet
)
vault = OmxCwVault(
    tx=rest_client,
    contract_addr=router_addr,
    net_cfg=net_cfg
    wallet=wallet
)

amount_in = "100000000uosmo"
# in real life you would want to use a price oracle
price_in_usd = "1000000000000000000";
# 3x leverage
size_delta = "3000000000000000000";

# add router to the vault
vault.add_router(router=router_addr)

# open long position
router.with_funds(amount_in).increase_position_osmo(
    collateral={"token": osmo_addr},
    index_token=osmo_addr,
    is_long=True,
    min_out="0",
    price=price_in_usd,
    size_delta=size_delta,
)

Metadata

Release files for omxpy 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for omxpy 0.0.11
File Size Uploaded
omxpy-0.0.11.tar.gz 29.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for omxpy 0.0.11
File Interpreter ABI Platform
omxpy-0.0.11-py3-none-any.whl Python 3 none any Details

Total release size: 68.9 kB

Release files / omxpy-0.0.11.tar.gz

Download URL omxpy-0.0.11.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
96e2ffe7901bee89f78aa8a6283a0a03419bca1c4f5fe7e6236a7f34df63bd96
BLAKE2b-256 checksum
How to use checksums
21bfc9231076c96fc8b73792685b9598144359502008203e911ce1552c004f05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.10.12 Linux/5.15.0-1041-azure

Release files / omxpy-0.0.11-py3-none-any.whl

Download URL omxpy-0.0.11-py3-none-any.whl
Size 39.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab461e18d00c008e4a7282bcffcb0c5e50c711b95db8a1cb27e8316559412f5d
BLAKE2b-256 checksum
How to use checksums
4b249b84cd612c11d920f42f655724b4f7f8c7bd3aa8ff456791ce89c73bd822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.10.12 Linux/5.15.0-1041-azure

Release history Release notifications | RSS feed

This release

0.0.11 This release

2 release files

0.0.10

2 release files

0.0.7

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page