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.xyz/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.2

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.2
File Size Uploaded Provenance
veranta_sdk-2.1.2.tar.gz 110.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 204.9 kB

Release files / veranta_sdk-2.1.2.tar.gz

Download URL veranta_sdk-2.1.2.tar.gz
Size 110.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a9d3960f1d3562f188b02553b1bbf18cb1dded2de1727d4f0cf7a99ebef6474c
BLAKE2b-256 checksum
How to use checksums
399a57d8dc22ad77bbdd98eeeeb0bfa2143e0bda02edaafcb401ede6f5e74988
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.2-py3-none-any.whl

Download URL veranta_sdk-2.1.2-py3-none-any.whl
Size 94.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe20f1329ce5c949ff326bb31ff5d79e51e1bf9f88a526c2424b51b1ff9e6b24
BLAKE2b-256 checksum
How to use checksums
12a23e9dd2d91f6a90e57c0d14193d7021422d355001be687972365048358219
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.2

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