Metadata-Version: 2.4
Name: defi-analytics-py
Version: 1.0.4
Summary: PyPI - defi-analytics-py v4
License: MIT
Project-URL: Homepage, https://github.com/worksOnMyFridge/defi-analytics-py
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: aiohttp>=3.9
Requires-Dist: requests>=2.31

# defi-analytics-py

DeFi analytics library for NEAR Protocol.

[![PyPI version](https://img.shields.io/pypi/v/defi-analytics-py)](https://pypi.org/project/defi-analytics-py/)
[![Python](https://img.shields.io/pypi/pyversions/defi-analytics-py)](https://pypi.org/project/defi-analytics-py/)

## Installation

pip install defi-analytics-py

**Requires Python 3.9+**

## Quick Start

from defi_analytics_py import DefiAnalyticsPyClient

client = DefiAnalyticsPyClient()

## Methods

### Chain

| Method | Description |
|---|---|
| `get_latest_block()` | Fetch the latest block |
| `get_gas_price()` | Get current gas price |

### Accounts

| Method | Description |
|---|---|
| `get_account(account_id)` | Get account details |
| `get_near_balance(account_id)` | Get NEAR token balance |

### Fungible Tokens

| Method | Description |
|---|---|
| `get_ft_metadata(contract_id)` | Get token metadata |
| `get_ft_balance(contract_id, account_id)` | Get token balance for account |

### Pools (Ref Finance)

| Method | Description |
|---|---|
| `get_pools()` | List all liquidity pools |
| `get_pool(pool_id)` | Get a specific pool |
| `get_pool_tvl(pool_id)` | Get TVL for a pool |
| `top_pools_by_tvl(n)` | Return top `n` pools by TVL |

## Example

from defi_analytics_py import DefiAnalyticsPyClient

client = DefiAnalyticsPyClient()

# Chain info
block = client.get_latest_block()
gas = client.get_gas_price()

# Account
balance = client.get_near_balance("alice.near")

# Pools
top = client.top_pools_by_tvl(10)
tvl = client.get_pool_tvl(79)

## Custom RPC

client = DefiAnalyticsPyClient(rpc_url="https://rpc.mainnet.near.org", timeout=60)

## License

MIT
