Python SDK for the Kaleidoswap protocol - Trade RGB assets on Lightning Network
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Kaleidoswap Python SDK
Pure Python SDK for interacting with the Kaleidoswap protocol. Trade RGB assets on Lightning Network with ease.
Installation
pip install kaleidoswap-sdk
Or with development dependencies:
pip install kaleidoswap-sdk[dev]
Quick Start
import asyncio
from kaleidoswap_sdk import KaleidoClient
async def main():
# Create client
client = KaleidoClient.create(
base_url="https://api.kaleidoswap.com"
)
async with client:
# List available assets
assets = await client.maker.list_assets()
for asset in assets.assets:
print(f"{asset.ticker}: {asset.name}")
# Get trading pairs
pairs = await client.maker.list_pairs()
for pair in pairs.pairs:
print(f"{pair.base.ticker}/{pair.quote.ticker}")
asyncio.run(main())
Features
- Async-first design - All API methods are async using
asyncio - Type-safe - Full type hints with Pydantic models
- Feature parity - Matches the TypeScript SDK 1-to-1
MakerClient (Market Operations)
# List assets
assets = await client.maker.list_assets()
# List trading pairs
pairs = await client.maker.list_pairs()
# Get a quote
quote = await client.maker.get_quote(PairQuoteRequest(...))
# Create swap order
order = await client.maker.create_swap_order(CreateSwapOrderRequest(...))
# Get order status
status = await client.maker.get_swap_order_status(SwapOrderStatusRequest(...))
# LSP operations
lsp_info = await client.maker.get_lsp_info()
RlnClient (RGB Lightning Node Operations)
Requires node_url configuration:
client = KaleidoClient.create(
base_url="https://api.kaleidoswap.com",
node_url="http://localhost:3000"
)
# Node info
info = await client.rln.get_node_info()
# BTC operations
balance = await client.rln.get_btc_balance()
address = await client.rln.get_address()
# RGB asset operations
assets = await client.rln.list_assets()
await client.rln.send_asset(SendAssetRequest(...))
# Lightning channels
channels = await client.rln.list_channels()
await client.rln.open_channel(OpenChannelRequest(...))
# Payments
await client.rln.send_payment(SendPaymentRequest(...))
WebSocket Streaming
# Enable WebSocket
ws = client.maker.enable_websocket("wss://api.kaleidoswap.com/ws")
# Stream quotes
unsubscribe = await client.maker.stream_quotes(
from_asset="BTC",
to_asset="USDT",
from_amount=100000,
from_layer=Layer.BTC_LN,
to_layer=Layer.RGB_LN,
on_update=lambda quote: print(quote),
)
# Later: stop streaming
unsubscribe()
ws.disconnect()
Utility Functions
from kaleidoswap_sdk import to_smallest_units, to_display_units
# Convert BTC to satoshis
sats = to_smallest_units(1.5, 8) # 150000000
# Convert satoshis to BTC
btc = to_display_units(150000000, 8) # 1.5
Error Handling
from kaleidoswap_sdk import (
KaleidoError,
APIError,
ValidationError,
NotFoundError,
NodeNotConfiguredError,
)
try:
quote = await client.maker.get_quote(request)
except ValidationError as e:
print(f"Invalid request: {e}")
except NotFoundError as e:
print(f"Resource not found: {e}")
except APIError as e:
print(f"API error ({e.status_code}): {e}")
except KaleidoError as e:
print(f"SDK error: {e}")
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=kaleidoswap_sdk
# Type checking
mypy kaleidoswap_sdk
# Linting
ruff check kaleidoswap_sdk
License
MIT
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 kaleidoswap_sdk-0.5.0.tar.gz.
File metadata
- Download URL: kaleidoswap_sdk-0.5.0.tar.gz
- Upload date:
- Size: 200.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1d25eb12f763017290f24ac89f5bb514062ef8dea318826c7c77eb3853aa0a9
|
|
| MD5 |
7d9d96f9db2e11be967af4b5c52be082
|
|
| BLAKE2b-256 |
57b74d0fa06095f9c9b501bac4266c0d64ee5146ee5037e4aff77449364810bf
|
File details
Details for the file kaleidoswap_sdk-0.5.0-py3-none-any.whl.
File metadata
- Download URL: kaleidoswap_sdk-0.5.0-py3-none-any.whl
- Upload date:
- Size: 330.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
227d1414daea51905ec4883c319c531c7dec9ab7777b7a793f9a46785dcc032f
|
|
| MD5 |
9ceacb703e25fdd441c3592525d9c3e7
|
|
| BLAKE2b-256 |
5c8561d06e89efb2f872a1291fb313cb5e87d86f231128e1b2a8673b715d3641
|