Skip to main content

Official Python SDK for BlackSwan Finance

Project description

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: 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

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

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

blackswan_sdk-0.1.2.tar.gz (5.3 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.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: blackswan_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 5.3 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.2.tar.gz
Algorithm Hash digest
SHA256 81da8e652a32bd5cab053cba34cdb16e892886371a39ae75e798c63e8f4c7be0
MD5 4fd58b7c5fa044a939019bff985b8dab
BLAKE2b-256 4d1479330d5637e53f9826841e93262490cefaa2e6b06afb122ed2821a070200

See more details on using hashes here.

Provenance

The following attestation bundles were made for blackswan_sdk-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: blackswan_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e944a75a175b291890530f9e0f4829591a142f49cbaf90ab15fc16ed936de80
MD5 0d96d06708a704326bf60144b62c0908
BLAKE2b-256 db13af4c32a7fb7011d65ab66995a05f6946b35942b7566fadef3219f88e8c40

See more details on using hashes here.

Provenance

The following attestation bundles were made for blackswan_sdk-0.1.2-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.

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