Skip to main content

Veranta Python SDK

Python SDK for Veranta v2, leveraged perpetuals on Base. API-first: no ABIs, no web3, no RPC required. The SDK signs locally and everything else comes from Veranta services.

import asyncio
from veranta_sdk import AsyncVeranta

async def main():
    async with AsyncVeranta() as client:              # reads VERANTA_* env vars
        await client.trade.market_open("ETH/USD", "long", collateral=100, leverage=10)
        positions = await client.account.positions()
        print(positions.positions)

asyncio.run(main())

Install

pip install veranta-sdk            # core
pip install "veranta-sdk[kms]"     # + AWS KMS signing
pip install "veranta-sdk[streams]" # + Socket.IO pair-data stream

Python 3.10+.

Renamed from avantis-trader-sdk

Avantis is now Veranta (September 14, 2026). Same protocol and contracts; new names: package veranta-sdk, import veranta_sdk, classes AsyncVeranta / Veranta / VerantaConfig / VerantaError, env vars VERANTA_*. The old package name ships one final compatibility release that re-exports this package, the old class names stay as deprecated aliases, and AVANTIS_* env vars are still read with a warning. Details: sdk.veranta.com/migration/rename.

Upgrading from v1 (0.8.x)

v2 is a ground-up, breaking rewrite for the Veranta v2 protocol (live August 12, 2026); the v1 TraderClient API is removed. Follow the migration guide. Veranta v1 is superseded on-chain by the upgrade, so staying on the old SDK is only a stopgap; pin avantis-trader-sdk<2 if you need time to migrate.

Setup (default: gasless API key)

  1. Create an API key with the Veranta API Key Generator. One wallet signature registers it as a trading delegate for your account (it can trade, but can never move funds to itself; payouts always go to your wallet).
  2. Approve USDC once (prompted on the UI).
  3. Configure:
export VERANTA_PRIVATE_KEY=0x...      # the API key
export VERANTA_TRADER_ADDRESS=0x...   # your wallet

(Or copy .env.example to .env; it documents every supported variable, including the optional ones.)

That's it. Every action is now a signed message relayed by Veranta. No gas, no RPC, no ETH.

Execution modes

Two independent axes; any combination works:

signer = API key (delegate) signer = trader key
relayer (default, gasless) sign intents, Veranta submits same
direct (own RPC + ETH) delegatedAction-wrapped txs plain txs
export VERANTA_EXECUTION=direct       # opt into self-broadcasting
export VERANTA_RPC_URL=https://...    # your Base RPC

Market makers can additionally use the local intent builder (client.local_intents()) to build and sign orders with zero HTTP round-trips on the hot path; see examples/13_mm_fast_path.py.

What's covered

  • Trading: market/limit opens (incl. coin-sized orders and Upside markets with automatic PnL-order routing), partial/full closes, margin updates, position increases, TP/SL updates, partial TP/SL trigger orders, TWAP.
  • Account: positions with liq price/rollover/funding, limit orders, TWAPs, balances, allowances, delegation management, USDC approvals, rebate and keeper-reward claims, builder codes.
  • Markets: full 100+ pair catalog (funding rates, spreads, OI and caps, fees, leverage envelopes, market hours), live prices, dynamic spread, OHLCV candles.
  • Info: trade/order history with full fee breakdowns, portfolio analytics (PnL, win rate, volume, fees), referral stats, vault APY.
  • Compute (pure functions, UI parity): net PnL incl. Upside profit-share tiers and loss protection, liquidation price, skew-adjusted open fees, maker/taker classification, OI headroom, TP/SL bounds, pre-trade validation.
  • Streams: Lazer SSE + Pyth Hermes prices, pair-data updates, order execution events.
  • LP: vault deposit/withdraw (ERC-4626), previews, utilization, APY.
  • Referral: codes (incl. gasless registration), tiers, rebates.

Correctness guarantees

  • Every EIP-712 intent is digest-verified locally against the API before submission, so encoding drift fails loudly instead of reverting on-chain.
  • The signing implementation is tested against golden vectors computed by the actual on-chain hashing library (all 17 intent types).
  • The EIP-7702 relayer envelope is byte-for-byte compatible with the Veranta web app's implementation.

Examples

See examples/: one runnable script per flow, from 01_configure_and_meta.py to 19_upside_pairs.py.

Errors

All failures raise typed exceptions from veranta_sdk.errors: ValidationError (pre-trade checks, human-readable), RelayError, DigestMismatchError, DelegationError, RateLimitedError, RpcError, etc.

Security model

The API/delegate key can trade on your account but cannot withdraw funds, approve USDC, or add other delegates. Worst case for a leaked key is malicious trading until you revoke it (client.account.revoke_delegate) or it expires. Keep expiries short (90 days recommended) and never commit keys.

Development

pip install -e ".[dev]"
pytest            # 150+ tests incl. golden vectors and EIP-7702 parity
ruff check .
mypy veranta_sdk

Metadata

Release files for veranta-sdk 2.1.1

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

Source distribution (sdist)

Source distribution for veranta-sdk 2.1.1
File Size Uploaded Provenance
veranta_sdk-2.1.1.tar.gz 110.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for veranta-sdk 2.1.1
File Interpreter ABI Platform
veranta_sdk-2.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 205.0 kB

Release files / veranta_sdk-2.1.1.tar.gz

Download URL veranta_sdk-2.1.1.tar.gz
Size 110.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f94feda3cd3256b538482f8b4179b29757da15fe522519773275dd43afdd563b
BLAKE2b-256 checksum
How to use checksums
680c33ee5587d21ae725b859d8b75f17e7b615672e63116703b8afaad491e9c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / veranta_sdk-2.1.1-py3-none-any.whl

Download URL veranta_sdk-2.1.1-py3-none-any.whl
Size 94.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
648557934a84442d45c0f7e0d4cdd828f9e80f8c067182498455779965e1e6bf
BLAKE2b-256 checksum
How to use checksums
a14f135d768689c8ad033b5045976a9cee5ea3790fc15af87fd50bb3a0d95f1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for veranta-sdk 2.1.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.

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