Metadata-Version: 2.4
Name: blackswan-sdk
Version: 0.1.2
Summary: Official Python SDK for BlackSwan Finance
Author: BlackSwan Finance
License: MIT
Keywords: ethereum,defi,credit,web3,polygon,blackswan
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: web3>=7.0.0
Dynamic: license-file

# BlackSwan SDK for Python

SDK for interacting with BlackSwan Finance smart contracts.

## Installation

```bash
pip install blackswan-sdk
```

## Usage

```python
from blackswan import BlackSwanClient

# Amoy (Polygon testnet)
client = BlackSwanClient(
    network="amoy",
    rpc_url="https://polygon-amoy.g.alchemy.com/v2/your-api-key"
)

# Sepolia (Ethereum testnet)
client = BlackSwanClient(
    network="sepolia",
    rpc_url="https://eth-sepolia.g.alchemy.com/v2/your-api-key"
)

dashboard = client.get_credit_dashboard("0x...")
print(dashboard.trust_ratio)
```

## Methods

- `get_credit_dashboard(wallet)` - Returns CreditDashboard with all credit metrics: `trust_ratio`, `current_apr`, `borrowed_usd`, `repaid_usd`, `successful_loans`, `defaults`, `tier`
- `get_trust_ratio(wallet)` - Returns trust score (0-10000)  
- `get_current_apr(wallet)` - Returns current APR index/risk increase in basis points (divide by 1000 for percentage)
- `balance_of(wallet)` - Returns 1 if wallet has SBT, 0 otherwise
- `get_reputation(wallet)` - Returns reputation score and tier (A-E)
- `get_credit_history(wallet)` - Returns credit history with loan count and amounts

### CreditDashboard Properties

| Property | Type | Description |
|----------|------|-------------|
| `trust_ratio` | int | Trust score (0-10000) |
| `current_apr` | int | Current APR index/risk increase in basis points (divide by 1000 for percentage) |
| `borrowed_usd` | int | Total USD borrowed |
| `repaid_usd` | int | Total USD repaid |
| `successful_loans` | int | Number of successful loans |
| `defaults` | int | Number of defaults |
| `tier` | int | User tier (0-4) |
| `trust_tier` | str | String representation of tier (AAA, AA, A, BBB, BB, B) |

### Example Usage

```python
from blackswan import BlackSwanClient

client = BlackSwanClient(
    network="amoy",
    rpc_url="https://polygon-amoy.g.alchemy.com/v2/your-api-key"
)

wallet = "0x..."

dashboard = client.get_credit_dashboard(wallet)
print(f"Trust: {dashboard.trust_ratio} ({dashboard.trust_tier})")
print(f"APR: {dashboard.current_apr / 1000}%")
print(f"Loans: {dashboard.successful_loans} successful, {dashboard.defaults} defaults")
```

