Skip to main content

Python SDK for interacting with Pendle Finance data

Project description

pendle-yield

pendle-yield is a Python SDK for interacting with Pendle Finance data. It provides a high-level, developer-friendly interface to fetch, analyze, and work with on-chain data from sources like the Etherscan and Pendle Finance APIs.

The primary goal is to simplify data access for developers, analysts, and enthusiasts building tools and strategies around the Pendle ecosystem.

Installation

⚠️ Alpha Version: This package is under active development. APIs may change between releases.

Install from PyPI:

pip install pendle-yield

Quick Start

from pendle_yield import PendleEpoch, PendleYieldClient

# Initialize with your Etherscan API key and optional caching
client = PendleYieldClient(
    etherscan_api_key="your_api_key_here",
    db_path="cache.db"  # Optional: enables caching for better performance
)

# Create epoch object, epoch starts on Th 00:00:00 and ends on Wd 23:59:59
epoch = PendleEpoch("2025-08-21")

# Get enriched vote events for the epoch
votes = client.get_votes_by_epoch(epoch)

# Display vote information
for vote in votes:
    print(f"Voter: {vote.voter_address}")
    print(f"Pool: {vote.pool_name} ({vote.protocol})")
    print(f"APY: {vote.voter_apy*100:.2f}%")
    print(f"Bias: {vote.bias:,}")
    print(f"Slope: {vote.slope:,}")
    print(f"VePendle Value: {vote.ve_pendle_value:.4f}")

Caching

The client supports optional SQLite caching to avoid redundant API calls:

# With caching (recommended for production)
client = PendleYieldClient(
    etherscan_api_key="your_key",
    db_path="cache.db"  # Caches market fees and vote snapshots
)

# Without caching (always fetches fresh data)
client = PendleYieldClient(
    etherscan_api_key="your_key"
)

Caching behavior:

  • Vote events: Cached per block range (automatically uses CachedEtherscanClient)
  • Market fees: Cached permanently for past epochs (immutable data)
  • Vote snapshots: Cached for past and current epochs (snapshot is at epoch start)

Features

Vote Events by Epoch

The get_votes_by_epoch() method:

  1. Fetches vote events from Etherscan for the specified Pendle epoch
  2. Enriches them with pool metadata from Pendle Finance API
  3. Returns structured data combining both sources

Each vote event includes:

  • Voter address and transaction details
  • Pool information (name, address, protocol, expiry, current voter APY)
  • Vote parameters (bias, slope)
  • VePendle value: Calculated voting power at the time of the vote using the formula VePendle = max(0, (bias - slope × timestamp) / 10^18)

Epoch Votes Snapshot

The get_epoch_votes_snapshot() method provides the state of all active votes at the start of an epoch (Thursday 00:00 UTC):

from pendle_yield import PendleEpoch, PendleYieldClient

# Initialize client with caching for better performance
client = PendleYieldClient(
    etherscan_api_key="your_api_key_here",
    db_path="data/cache.db"
)

# Get current epoch
epoch = PendleEpoch()

# Get snapshot at epoch start
snapshot = client.get_epoch_votes_snapshot(epoch)

print(f"Total Active Votes: {len(snapshot.votes)}")
print(f"Total vePendle: {snapshot.total_ve_pendle:,.2f}")

# Analyze individual votes
for vote in snapshot.votes:
    print(f"Voter: {vote.voter_address}")
    print(f"Pool: {vote.pool_address}")
    print(f"vePendle: {vote.ve_pendle_value:,.2f}")

Key concepts:

  • Snapshots are taken at epoch start (Thursday 00:00 UTC) when incentive rates are adjusted
  • Votes cast during an epoch affect the next epoch's snapshot
  • VePendle values decay over time based on bias and slope
  • Expired votes (vePendle ≤ 0) are automatically filtered out
  • Votes persist across epochs unless explicitly removed (weight = 0)
  • Snapshots are cached in SQLite for instant retrieval

Requirements

Development

This project uses PDM for dependency management:

# Install dependencies
pdm install

# Run tests
pdm run pytest

# Run the example
pdm run python examples/basic_usage.py

Pendle API

To update pendle client

openapi-python-client generate --url https://api-v2.pendle.finance/core/docs-json --meta pdm --output-path src --config openapi.yaml --overwrite

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

pendle_yield-0.1.0a2.tar.gz (157.2 kB view details)

Uploaded Source

Built Distribution

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

pendle_yield-0.1.0a2-py3-none-any.whl (417.1 kB view details)

Uploaded Python 3

File details

Details for the file pendle_yield-0.1.0a2.tar.gz.

File metadata

  • Download URL: pendle_yield-0.1.0a2.tar.gz
  • Upload date:
  • Size: 157.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.9 CPython/3.13.7 Darwin/25.0.0

File hashes

Hashes for pendle_yield-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 3faeefc2a58b2f4d16acdcf4c4491f58c950e374df363a2d25d47a8551cf0c51
MD5 c9234177d3af29e40f635f074caa834a
BLAKE2b-256 246b82992d82cc64674aebc2bd57bd1ca371613e46d9120ebcbbfb5104455283

See more details on using hashes here.

File details

Details for the file pendle_yield-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: pendle_yield-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 417.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.9 CPython/3.13.7 Darwin/25.0.0

File hashes

Hashes for pendle_yield-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 6a4beb1c86fadd240dfe684376f8a31b65ad58d9eafc391cc623d21710accaec
MD5 cf4df5caade09cae80a9cb8b897b405a
BLAKE2b-256 88d2e5ac7858c204ea8135a98719725f44c55281aa2cae3e83b55999f4ff6e5c

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