No project description provided
Project description
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,
)
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
omxpy-0.0.12.tar.gz
(29.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
omxpy-0.0.12-py3-none-any.whl
(39.1 kB
view details)
File details
Details for the file omxpy-0.0.12.tar.gz.
File metadata
- Download URL: omxpy-0.0.12.tar.gz
- Upload date:
- Size: 29.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba2a99875ebbde4da73fce9d1f311b5b8157f9d4addf0462f084e2fd41c2a0f8
|
|
| MD5 |
8d72c7c2fc28d03a4e0bb7c5cbf6d9d8
|
|
| BLAKE2b-256 |
e84a6f2fcd12267ea740b71193d493750b0cd1659f57aa7fc9b84558bea7aab8
|
File details
Details for the file omxpy-0.0.12-py3-none-any.whl.
File metadata
- Download URL: omxpy-0.0.12-py3-none-any.whl
- Upload date:
- Size: 39.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c20585a7be4834540a608efd4128c7a88fd85f335390f550cc31b4fff9a47b53
|
|
| MD5 |
3a413abd02ac8bb73cdaa37bb302cdda
|
|
| BLAKE2b-256 |
b1f5808fb0a76604e04b7e9b36d7072fece47ca8ead0e2be65ac6d8a31f3a18c
|