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,tierget_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 otherwiseget_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
Release history Release notifications | RSS feed
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.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81da8e652a32bd5cab053cba34cdb16e892886371a39ae75e798c63e8f4c7be0
|
|
| MD5 |
4fd58b7c5fa044a939019bff985b8dab
|
|
| BLAKE2b-256 |
4d1479330d5637e53f9826841e93262490cefaa2e6b06afb122ed2821a070200
|
Provenance
The following attestation bundles were made for blackswan_sdk-0.1.2.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.2.tar.gz -
Subject digest:
81da8e652a32bd5cab053cba34cdb16e892886371a39ae75e798c63e8f4c7be0 - Sigstore transparency entry: 2013281655
- Sigstore integration time:
-
Permalink:
darealbirdie/blackswan-sdk-py@75a6010639165ad6a2dfa7548e1ff391da4b60ec -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/darealbirdie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@75a6010639165ad6a2dfa7548e1ff391da4b60ec -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e944a75a175b291890530f9e0f4829591a142f49cbaf90ab15fc16ed936de80
|
|
| MD5 |
0d96d06708a704326bf60144b62c0908
|
|
| BLAKE2b-256 |
db13af4c32a7fb7011d65ab66995a05f6946b35942b7566fadef3219f88e8c40
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blackswan_sdk-0.1.2-py3-none-any.whl -
Subject digest:
3e944a75a175b291890530f9e0f4829591a142f49cbaf90ab15fc16ed936de80 - Sigstore transparency entry: 2013281710
- Sigstore integration time:
-
Permalink:
darealbirdie/blackswan-sdk-py@75a6010639165ad6a2dfa7548e1ff391da4b60ec -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/darealbirdie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@75a6010639165ad6a2dfa7548e1ff391da4b60ec -
Trigger Event:
release
-
Statement type: