Vertex Protocol Python SDK
This is the Python SDK for the Vertex Protocol API.
See SDK docs to get started.
Requirements
- Python 3.9 or above
Installation
You can install the SDK via pip:
pip install vertex-protocol
Basic usage
Import the necessary utilities:
from vertex_protocol.client import create_vertex_client, VertexClientMode
from vertex_protocol.contracts.types import DepositCollateralParams
from vertex_protocol.engine_client.types.execute import (
OrderParams,
PlaceOrderParams,
SubaccountParams
)
from vertex_protocol.utils.expiration import OrderType, get_expiration_timestamp
from vertex_protocol.utils.math import to_pow_10, to_x18
from vertex_protocol.utils.nonce import gen_order_nonce
Create the VertexClient providing your private key:
print("setting up vertex client...")
private_key = "xxx"
client = create_vertex_client(VertexClientMode.MAINNET, private_key)
Perform basic operations:
# Depositing collaterals
print("approving allowance...")
approve_allowance_tx_hash = client.spot.approve_allowance(0, to_pow_10(100000, 6))
print("approve allowance tx hash:", approve_allowance_tx_hash)
print("querying my allowance...")
token_allowance = client.spot.get_token_allowance(0, client.context.signer.address)
print("token allowance:", token_allowance)
print("depositing collateral...")
deposit_tx_hash = client.spot.deposit(
DepositCollateralParams(
subaccount_name="default", product_id=0, amount=to_pow_10(100000, 6)
)
)
print("deposit collateral tx hash:", deposit_tx_hash)
# Placing orders
print("placing order...")
owner = client.context.engine_client.signer.address
product_id = 1
order = OrderParams(
sender=SubaccountParams(
subaccount_owner=owner,
subaccount_name="default",
),
priceX18=to_x18(20000),
amount=to_pow_10(1, 17),
expiration=get_expiration_timestamp(OrderType.POST_ONLY, int(time.time()) + 40),
nonce=gen_order_nonce(),
)
res = client.market.place_order({"product_id": product_id, "order": order})
print("order result:", res.json(indent=2))
See Getting Started for more.
Running locally
-
Clone github repo
-
Install poetry
$ curl -sSL https://install.python-poetry.org | python3 -
- Setup a virtual environment and activate it
$ python3 -m venv venv
$ source ./venv/bin/activate
- Install dependencies via
poetry install - Setup an
.envfile and set the following envvars
CLIENT_MODE='mainnet|sepolia-testnet|devnet'
SIGNER_PRIVATE_KEY="0x..."
LINKED_SIGNER_PRIVATE_KEY="0x..." # not required
Run tests
$ poetry run test
Run sanity checks
poetry run client-sanity: runs sanity checks for the top-level client.poetry run engine-sanity: runs sanity checks for theengine-client.poetry run indexer-sanity: runs sanity checks for theindexer-client.poetry run contracts-sanity: runs sanity checks for the contracts module.
Build Docs
To build the docs locally run:
$ poetry run sphinx-build docs/source docs/build
Metadata
Release files for vertex-protocol 3.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| vertex_protocol-3.3.1.tar.gz | 67.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vertex_protocol-3.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 173.3 kB
Release files / vertex_protocol-3.3.1.tar.gz
| Download URL | vertex_protocol-3.3.1.tar.gz |
|---|---|
| Size | 67.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f0f3ca2013c74922190240a2a7f27a0f5e0ede48627dc56d095a9efa97820b4
|
|
BLAKE2b-256 checksum How to use checksums |
87ba34cb2f3f405f6deb1b0a0f3846d8b17824595530c376f992d277e25572d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.11.12 Linux/6.11.0-1012-azure
|
Release files / vertex_protocol-3.3.1-py3-none-any.whl
| Download URL | vertex_protocol-3.3.1-py3-none-any.whl |
|---|---|
| Size | 106.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fca9c5d9bd7072d7ca800466cd79aec09b5e9ec4ca732fa4cc870da5cc392335
|
|
BLAKE2b-256 checksum How to use checksums |
23c3010429fefe43d907e502ab6e065b7c856370289568c49ffa230353d48949
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.11.12 Linux/6.11.0-1012-azure
|
Security for vertex-protocol 3.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.