vaults.fyi
  • General
    • 🏦Overview
    • 💡Use Cases
      • For Wallets and Apps
        • Monetize Your Wallet Seamlessly & Securely
      • For Analysts
      • For Protocols & Product Teams
    • 🔎Methodology
      • vaults.fyi USD benchmark rate
      • vaults.fyi ETH benchmark rate
    • ❓FAQ
      • Vault requirements for inclusion on vaults.fyi
    • 🤖AI
  • API
    • Introduction
      • Market data
      • Transactional support
      • Portfolio tracking
      • Personalized insights
    • Quickstart
    • Tutorials
      • Wallet Integration
    • SDK
  • Endpoints
    • General
    • Detailed Vaults
    • Historical
    • Portfolio
    • Transactions
    • Legacy (v1) endpoints
      • v1 Market data
        • Get historical data
          • Get historical APY and TVL data on single vault over timestamp range
          • Get historical APY on single vault over timestamp range
          • Get historical TVL on single vault at single timestamp
          • Get historical APY on single vault at single timestamp
        • Get data for multiple vaults
        • Get data on single vault
          • Get APY on single vault
        • Get benchmark rates
        • Get supported vaults, networks & tokens
          • /vaults
          • /networks
          • /tokens
          • /tags
      • v1 Contextual insights
        • Top vault options for address
        • Get single top option for address
        • [Etherscan cards] Get top USD, top ETH vault for address
      • v1 Generate payloads
        • Prepare calldata
          • Supply/Deposit
          • Withdraw/Redeem
            • Request redeem
            • Claim redeem
          • Claim rewards
        • Get contract interaction details
        • Get supported assets
        • Get supported vaults
      • v1 Position tracking
        • Get user balances
        • Get user positions
        • Get list of past vault txns by user address
        • Get estimated returns for user's vault position
  • Case Studies
    • Kraken Wallet
    • Etherscan Cards
    • Gauntlet
  • Plans
    • Credits
      • Credits (v1 endpoints)
  • Links
    • vaults.fyi
    • X
    • Farcaster
    • Wallfacer Labs
Powered by GitBook
On this page
  • Installation
  • API Methods
  1. API

SDK

Installation

For installation instructions use Quickstart

API Methods

getAllVaults(params?)

Get information about all available vaults.

const vaults = await sdk.getAllVaults({
  query: {
    page: 0,
    perPage: 100,
    allowedNetworks: ['mainnet', 'polygon'],
    allowedProtocols: ['aave', 'compound'],
    allowedAssets: ['USDC', 'USDT'],
    minTvl: 1000000,
    maxTvl: 100000000,
    onlyTransactional: true,
    onlyAppFeatured: false
  }
})

getVault(params)

Get detailed information about a specific vault.

const vault = await sdk.getVault({
  path: {
    network: 'mainnet',
    vaultAddress: '0x1234...'
  }
})

Historical Data Methods

getVaultHistoricalData(params)

Get historical APY and TVL data for a vault.

const historicalData = await sdk.getVaultHistoricalData({
  path: {
    network: 'mainnet',
    vaultAddress: '0x1234...'
  },
  query: {
    page: 0,
    perPage: 100,
    apyInterval: '30day',
    fromTimestamp: 1640995200,
    toTimestamp: 1672531200
  }
})

Portfolio Methods

getPositions(params)

Get all positions for a user address.

const positions = await sdk.getPositions({
  path: {
    userAddress: '0x1234...'
  },
  query: {
    allowedNetworks: ['mainnet', 'polygon']
  }
})

getDepositOptions(params)

Get the best deposit options for a user.

const options = await sdk.getDepositOptions({
  path: {
    userAddress: '0x1234...'
  },
  query: {
    allowedNetworks: ['mainnet', 'polygon'],
    allowedAssets: ['USDC', 'USDT'],
    allowedProtocols: ['aave', 'compound'],
    minTvl: 1000000,
    minUsdAssetValueThreshold: 1000,
    onlyTransactional: true,
    onlyAppFeatured: false,
    apyInterval: '7day',
    alwaysReturnAssets: ['USDC'],
    maxVaultsPerAsset: 5
  }
})

getIdleAssets(params)

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

const idleAssets = await sdk.getIdleAssets({
  path: {
    userAddress: '0x1234...'
  }
})

getVaultTotalReturns(params)

Get total returns for a specific user and vault.

const returns = await sdk.getVaultTotalReturns({
  path: {
    userAddress: '0x1234...',
    network: 'mainnet',
    vaultAddress: '0x5678...'
  }
})

getVaultHolderEvents(params)

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

const events = await sdk.getVaultHolderEvents({
  path: {
    userAddress: '0x1234...',
    network: 'mainnet',
    vaultAddress: '0x5678...'
  }
})

Transaction Methods

getTransactionsContext(params)

Get transaction context for a specific vault interaction.

const context = await sdk.getTransactionsContext({
  path: {
    userAddress: '0x1234...',
    network: 'mainnet',
    vaultAddress: '0x5678...'
  }
})

getActions(params)

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

const actions = await sdk.getActions({
  path: {
    action: 'deposit',
    userAddress: '0x1234...',
    network: 'mainnet',
    vaultAddress: '0x5678...'
  },
  query: {
    assetAddress: '0xA0b86a33E6b2e7d8bB9bdB1c23f6fD7b52b5c8e2',
    amount: '1000000000',
    simulate: false
  }
})

Benchmark Methods

getBenchmarks()

Get benchmark data for comparing vault performance.

const benchmarks = await sdk.getBenchmarks()

Error Handling

The SDK throws HttpResponseError for API errors:

import { VaultsSdk, HttpResponseError } from 'vaultsfyi'

try {
  const vault = await sdk.getVault({
    path: {
      network: 'mainnet',
      vaultAddress: 'invalid-address'
    }
  })
} catch (error) {
  if (error instanceof HttpResponseError) {
    console.error('API Error:', error.message)
  }
}

TypeScript Support

This SDK is written in TypeScript and provides full type safety. All API responses are properly typed based on the OpenAPI specification.

// Types are automatically inferred
const vaults = await sdk.getAllVaults() // Type: DetailedVault[]
const vault = await sdk.getVault({ /* ... */ }) // Type: DetailedVault

License

MIT License - see the LICENSE file for details.

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,
    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()

Get benchmark data for comparing vault performance.

benchmarks = client.get_benchmarks()

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

PreviousWallet IntegrationNextEndpoints

Last updated 8 days ago