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 metricsget_credit_dashboard_by_token_id(token_id)- Same as above but looks up wallet by SBT tokenget_reputation(wallet)- Returns Reputation with score, tier, successful_loans, defaults, loans_takenget_reputation_by_token_id(token_id)- Same as above but looks up wallet by SBT tokenget_credit_history(wallet)- Returns aggregate loan data (loans_taken, total_borrowed, total_repaid)has_soul(wallet)- Returns True if wallet owns an SBTtoken_of(wallet)- Returns the SBT token ID for a walletget_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bde71d54fbda39e05170c89c56750396b63b2e5b531c10b889a7b6aa7e8d4876
|
|
| MD5 |
ddd8f125aa4795a8061330b51093b70b
|
|
| BLAKE2b-256 |
e2ec5835c5e27843fc8e986b07de21ebf19a3cf21d5e2584c21c504c62066a02
|
Provenance
The following attestation bundles were made for blackswan_sdk-0.1.3.tar.gz:
Publisher:
python-publish.yml on darealbirdie/blackswan-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blackswan_sdk-0.1.3.tar.gz -
Subject digest:
bde71d54fbda39e05170c89c56750396b63b2e5b531c10b889a7b6aa7e8d4876 - Sigstore transparency entry: 2164975491
- Sigstore integration time:
-
Permalink:
darealbirdie/blackswan-sdk-py@e8ad55a27355ee1d11a0d825a9d5cff64b67cd28 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/darealbirdie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e8ad55a27355ee1d11a0d825a9d5cff64b67cd28 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f42ef76129fd964fc5a20b592360730396073d2ae16a512a90cbdd46b7819713
|
|
| MD5 |
f7f5b43683f6351c09e5994a09eff15b
|
|
| BLAKE2b-256 |
dbc73492621cced903dc02910d16ea5386ec7c0939a1274ae101aeab3393acfd
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blackswan_sdk-0.1.3-py3-none-any.whl -
Subject digest:
f42ef76129fd964fc5a20b592360730396073d2ae16a512a90cbdd46b7819713 - Sigstore transparency entry: 2164975499
- Sigstore integration time:
-
Permalink:
darealbirdie/blackswan-sdk-py@e8ad55a27355ee1d11a0d825a9d5cff64b67cd28 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/darealbirdie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e8ad55a27355ee1d11a0d825a9d5cff64b67cd28 -
Trigger Event:
release
-
Statement type: