Skip to main content

A Python SDK for interacting with the Vaults.fyi API

Project description

Vaults.fyi Python SDK

A Python SDK for interacting with the Vaults.fyi API. This package provides feature-equivalent functionality to the JavaScript SDK with Pythonic naming conventions.

Installation

pip install vaultsfyi

Quick Start

from vaultsfyi import VaultsSdk

# Initialize the SDK
client = VaultsSdk(api_key="your_api_key_here")

# Get user's idle assets
idle_assets = client.get_idle_assets("0x742d35Cc6543C001")

# Get best deposit options (filtered for USDC/USDS)
deposit_options = client.get_deposit_options(
    "0x742d35Cc6543C001",
    allowed_assets=["USDC", "USDS"]
)

# Get user positions
positions = client.get_positions("0x742d35Cc6543C001")

# Generate deposit transaction
transaction = client.get_actions(
    action="deposit",
    user_address="0x742d35Cc6543C001",
    network="mainnet",
    vault_address="0x...",
    amount="1000000",
    asset_address="0x...",
    simulate=False
)

API Methods

Vault Methods

get_all_vaults(**kwargs)

Get information about all available vaults.

vaults = client.get_all_vaults(
    page=0,
    perPage=100,
    allowedNetworks=['mainnet', 'polygon'],
    allowedProtocols=['aave', 'compound'],
    allowedAssets=['USDC', 'USDT'],
    minTvl=1000000,
    maxTvl=100000000,
    onlyTransactional=True,
    onlyAppFeatured=False
)

get_vault(network, vault_address, **kwargs)

Get detailed information about a specific vault.

vault = client.get_vault(
    network='mainnet',
    vault_address='0x1234...'
)

Historical Data Methods

get_vault_historical_data(network, vault_address, **kwargs)

Get historical APY and TVL data for a vault.

historical_data = client.get_vault_historical_data(
    network='mainnet',
    vault_address='0x1234...',
    page=0,
    perPage=100,
    apyInterval='30day',
    fromTimestamp=1640995200,
    toTimestamp=1672531200
)

Portfolio Methods

get_positions(user_address, **kwargs)

Get all positions for a user address.

positions = client.get_positions(
    user_address='0x1234...',
    allowedNetworks=['mainnet', 'polygon']
)

get_deposit_options(user_address, allowed_assets=None, **kwargs)

Get the best deposit options for a user.

options = client.get_deposit_options(
    user_address='0x1234...',
    allowed_assets=['USDC', 'USDT'],
    allowedNetworks=['mainnet', 'polygon'],
    allowedProtocols=['aave', 'compound'],
    minTvl=1000000,
    minApy=0.05,
    minUsdAssetValueThreshold=1000,
    onlyTransactional=True,
    onlyAppFeatured=False,
    apyInterval='7day',
    alwaysReturnAssets=['USDC'],
    maxVaultsPerAsset=5
)

get_idle_assets(user_address, **kwargs)

Get idle assets in a user's wallet that could be earning yield.

idle_assets = client.get_idle_assets(
    user_address='0x1234...'
)

get_vault_total_returns(user_address, network, vault_address, **kwargs)

Get total returns for a specific user and vault.

returns = client.get_vault_total_returns(
    user_address='0x1234...',
    network='mainnet',
    vault_address='0x5678...'
)

get_vault_holder_events(user_address, network, vault_address, **kwargs)

Get events (deposits, withdrawals) for a specific user and vault.

events = client.get_vault_holder_events(
    user_address='0x1234...',
    network='mainnet',
    vault_address='0x5678...'
)

Transaction Methods

get_transactions_context(user_address, network, vault_address, **kwargs)

Get transaction context for a specific vault interaction.

context = client.get_transactions_context(
    user_address='0x1234...',
    network='mainnet',
    vault_address='0x5678...'
)

get_actions(action, user_address, network, vault_address, **kwargs)

Get available actions (deposit, withdraw, etc.) for a vault.

actions = client.get_actions(
    action='deposit',
    user_address='0x1234...',
    network='mainnet',
    vault_address='0x5678...',
    amount='1000000000',
    asset_address='0xA0b86a33E6b2e7d8bB9bdB1c23f6fD7b52b5c8e2',
    simulate=False
)

Benchmark Methods

get_benchmarks(network, code)

Get benchmark APY data for a specific network and benchmark code.

# Get USD benchmark for mainnet
usd_benchmark = client.get_benchmarks('mainnet', 'usd')

# Get ETH benchmark for mainnet
eth_benchmark = client.get_benchmarks('mainnet', 'eth')

get_historical_benchmarks(network, code, **kwargs)

Get historical benchmark APY data with pagination and filtering.

# Get historical USD benchmarks with basic pagination
historical = client.get_historical_benchmarks(
    network='mainnet',
    code='usd',
    page=0,
    per_page=100
)

# Get historical ETH benchmarks with timestamp filtering
historical_filtered = client.get_historical_benchmarks(
    network='mainnet',
    code='eth',
    from_timestamp=1640995200,
    to_timestamp=1672531200,
    page=0,
    per_page=50
)

Available benchmark codes:

  • 'usd' - USD benchmark rate (includes Aave v3 USDC/USDT, sDAI, Compound v3 USDC)
  • 'eth' - ETH benchmark rate (includes Lido stETH, ether.fi eETH, Coinbase cbETH, Rocket Pool rETH)

Error Handling

The SDK provides specific exception types:

from vaultsfyi import VaultsSdk, HttpResponseError, AuthenticationError

try:
    client = VaultsSdk(api_key="invalid_key")
    result = client.get_benchmarks()
except AuthenticationError:
    print("Invalid API key")
except HttpResponseError as e:
    print(f"API error: {e}")

Requirements

  • Python 3.8+
  • requests

License

MIT License

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

vaultsfyi-1.2.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vaultsfyi-1.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file vaultsfyi-1.2.0.tar.gz.

File metadata

  • Download URL: vaultsfyi-1.2.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for vaultsfyi-1.2.0.tar.gz
Algorithm Hash digest
SHA256 fc2d04c7e6d0cef8b47b23a1bea17ce9734aa8dc57dc82a2f77efe57f4e42fcf
MD5 7c72a8dfa7b4a0da37e285258f9bbee8
BLAKE2b-256 5875f017e466917b32f15e04cdc5b65efec8b75f24352a6415d15ec527edbffa

See more details on using hashes here.

File details

Details for the file vaultsfyi-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: vaultsfyi-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for vaultsfyi-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ad765bf05e1e87e13c5ffe647cfb82aaa8fc8250a197a213444636f5b48b22b
MD5 3054972193d8a9a68642772aaefb1f03
BLAKE2b-256 55a1eeba4c3eebd5698562363aa588f0853e8137235d54e809ba696a100c11a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page