Skip to content

WallfacerLabs/python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Health & Basic Data Methods

get_health()

Get API health status.

health = client.get_health()
# Returns: {'status': 'Success', 'message': 'Application is healthy'}

get_networks(**kwargs)

Get list of supported blockchain networks.

networks = client.get_networks()
# Returns list of networks with chainId and networkCaip

get_tags(**kwargs)

Get list of vault categorization tags.

tags = client.get_tags()
# Returns list of tags like ['Bridge', 'CDP', 'Liquid Staking', 'RWA', ...]

get_assets(page=None, per_page=None, network=None, **kwargs)

Get list of supported assets.

assets = client.get_assets(
    page=0,
    per_page=50,
    network='mainnet'
)

get_vaults(page=None, per_page=None, network=None, asset_symbol=None, **kwargs)

Get basic list of vaults with simple filtering.

vaults = client.get_vaults(
    page=0,
    per_page=20,
    network='mainnet',
    asset_symbol='USDC',
    only_transactional=True,
    only_app_featured=False
)

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...'
)

get_vault_apy_breakdown(network, vault_address, **kwargs)

Get APY breakdown for a specific vault.

apy_breakdown = client.get_vault_apy_breakdown(
    network='mainnet',
    vault_address='0x1234...'
)

get_vault_tvl_breakdown(network, vault_address, **kwargs)

Get TVL breakdown for a specific vault.

tvl_breakdown = client.get_vault_tvl_breakdown(
    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
)

get_vault_historical_apy(network, vault_address, **kwargs)

Get historical APY data for a specific vault.

historical_apy = client.get_vault_historical_apy(
    network='mainnet',
    vault_address='0x1234...',
    page=0,
    perPage=100
)

get_vault_historical_tvl(network, vault_address, **kwargs)

Get historical TVL data for a specific vault.

historical_tvl = client.get_vault_historical_tvl(
    network='mainnet',
    vault_address='0x1234...',
    page=0,
    perPage=100
)

get_vault_historical_share_price(network, vault_address, **kwargs)

Get historical share price data for a specific vault.

historical_price = client.get_vault_historical_share_price(
    network='mainnet',
    vault_address='0x1234...',
    page=0,
    perPage=100
)

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_position(user_address, network, vault_address, **kwargs)

Get a specific position for a user in a vault.

position = client.get_position(
    user_address='0x1234...',
    network='mainnet',
    vault_address='0x5678...'
)

get_best_vault(user_address, **kwargs)

Get the best vault opportunity for a user.

best_vault = client.get_best_vault(
    user_address='0x1234...'
)

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
)

Rewards Methods

get_rewards_context(user_address, **kwargs)

Get rewards context for a user.

rewards_context = client.get_rewards_context(
    user_address='0x1234...'
)

get_rewards_claim(user_address, **kwargs)

Get rewards claim transaction data for a user.

# Note: claimIds parameter is required by the API
rewards_claim = client.get_rewards_claim(
    user_address='0x1234...',
    claimIds=['claim1', 'claim2']
)

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

About

Python SDK for the Vaults.fyi API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages