Skip to main content

BlackSwan SDK for Python

SDK for interacting with BlackSwan Finance smart contracts.

Installation

pip install blackswan-sdk

Usage

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
  • get_credit_dashboard_by_token_id(token_id) - Same as above but looks up wallet by SBT token
  • get_reputation(wallet) - Returns Reputation with score, tier, successful_loans, defaults, loans_taken
  • get_reputation_by_token_id(token_id) - Same as above but looks up wallet by SBT token
  • get_credit_history(wallet) - Returns aggregate loan data (loans_taken, total_borrowed, total_repaid)
  • has_soul(wallet) - Returns True if wallet owns an SBT
  • token_of(wallet) - Returns the SBT token ID for a wallet
  • get_trust_tier(wallet) - Returns string tier (AAA, AA, A, BBB, BB, B)

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
principal_repaid int Principal repaid (from SBT contract)
interest_repaid int Interest repaid (from SBT contract)
successful_loans int Number of successful loans
defaults int Number of defaults
tier int User tier (0-4)
trust_tier str String representation of trust tier (AAA, AA, A, BBB, BB, B)

Reputation Properties

Property Type Description
trust_ratio int Trust score (0-10000)
tier int Tier based on repayment volume (0-4)
successful_loans int Number of on-time repayments
defaults int Number of defaults
loans_taken int Total loans taken

Example Usage

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")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blackswan_sdk-0.1.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

blackswan_sdk-0.1.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file blackswan_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: blackswan_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for blackswan_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bde71d54fbda39e05170c89c56750396b63b2e5b531c10b889a7b6aa7e8d4876
MD5 ddd8f125aa4795a8061330b51093b70b
BLAKE2b-256 e2ec5835c5e27843fc8e986b07de21ebf19a3cf21d5e2584c21c504c62066a02

See more details on using hashes here.

Provenance

The following attestation bundles were made for blackswan_sdk-0.1.3.tar.gz:

Publisher: python-publish.yml on darealbirdie/blackswan-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file blackswan_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: blackswan_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for blackswan_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f42ef76129fd964fc5a20b592360730396073d2ae16a512a90cbdd46b7819713
MD5 f7f5b43683f6351c09e5994a09eff15b
BLAKE2b-256 dbc73492621cced903dc02910d16ea5386ec7c0939a1274ae101aeab3393acfd

See more details on using hashes here.

Provenance

The following attestation bundles were made for blackswan_sdk-0.1.3-py3-none-any.whl:

Publisher: python-publish.yml on darealbirdie/blackswan-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page