OMX python api
Python client for interacting with OMX contracts.
Installation
Requirements
- Python 3.10 or higher
- Highly recommended to use Poetry for dependency management
- Osmosis localnet for testing
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,
)
Release files for omxpy 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| omxpy-0.0.12.tar.gz | 29.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| omxpy-0.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 69.0 kB
Release files / omxpy-0.0.12.tar.gz
| Download URL | omxpy-0.0.12.tar.gz |
|---|---|
| Size | 29.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba2a99875ebbde4da73fce9d1f311b5b8157f9d4addf0462f084e2fd41c2a0f8
|
|
BLAKE2b-256 checksum How to use checksums |
e84a6f2fcd12267ea740b71193d493750b0cd1659f57aa7fc9b84558bea7aab8
|
| 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.12-py3-none-any.whl
| Download URL | omxpy-0.0.12-py3-none-any.whl |
|---|---|
| Size | 39.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c20585a7be4834540a608efd4128c7a88fd85f335390f550cc31b4fff9a47b53
|
|
BLAKE2b-256 checksum How to use checksums |
b1f5808fb0a76604e04b7e9b36d7072fece47ca8ead0e2be65ac6d8a31f3a18c
|
| 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
|