rhea-sdk
rhea-sdk is an asynchronous SDK for interacting with Rhea Finance DEX.
It is made on top of py-near - a pretty simple and fully asynchronous framework for working with NEAR blockchain.
Installation
- Install the latest stable version of rhea-sdk, simply running
pip install rhea-sdk - Create NEAR account and get your private key wallet
Examples
📚 Click to see some basic examples
Usage examples
from py_near.account import Account
from rhea_sdk import Rhea
wnear_contract = "wrap.near"
usdc_contract = "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1"
async def main():
account = Account(account_id="example.near", private_key="ed25519:...")
await account.startup()
rhea = Rhea(account=account)
# Get account tokens balance
near_balance = await rhea.get_near_balance()
usdc_balance = await rhea.get_token_balance(usdc_contract)
wnear_balance = await rhea.get_token_balance(wnear_contract)
# Wrap or Unwrap some NEAR
await rhea.wrap_near(0.15)
await rhea.unwrap_near(0.05)
# List all DLC pools
pools = await rhea.dcl.get_pools()
# Get DLC pool_id by tokens and commission
pool_id = rhea.dcl.get_pool_id(wnear_contract, usdc_contract, 100)
# Get pool extended info by pool_id
pool = await rhea.dcl.get_pool(pool_id)
# Get current tokens price in the pool
prices = await rhea.dcl.get_tokens_price(pool_id)
# Quote output amount of token for swap
amount_to_swap = "0.1"
output_amount = await rhea.dcl.quote(usdc_contract, wnear_contract, pool_id, amount_to_swap)
# Quote input amount of token for swap
desired_output_amount = "0.1"
input_amount = await rhea.dcl.quote_by_output(wnear_contract, usdc_contract, pool_id, desired_output_amount)
# Swap
amount_to_swap = "0.1"
min_output_amount = "0"
await rhea.dcl.swap(wnear_contract, usdc_contract, pool_id, amount_to_swap, min_output_amount)
# Swap by output
desired_output_amount = "0.1"
max_input_amount = "0.5"
await rhea.dcl.swap_by_output(wnear_contract, usdc_contract, pool_id, desired_output_amount, max_input_amount)
# Get account lending information
account_info = await rhea.lending.get_account() # Current account
other_account_info = await rhea.lending.get_account("another_account.near")
# Get asset information
wnear_asset_info = await rhea.lending.get_asset(wnear_contract)
usdc_asset_info = await rhea.lending.get_asset(usdc_contract)
# Supply tokens as collateral
await rhea.lending.supply(
token_id=wnear_contract,
amount="10.5" # Amount in human-readable format (e.g., "10.5" for 10.5 tokens)
)
# Borrow tokens against collateral
await rhea.lending.borrow(
token_id=usdc_contract,
amount="100.0" # Amount in human-readable format
)
# Repay borrowed tokens
await rhea.lending.repay(
token_id=usdc_contract,
amount="50.0" # Amount in human-readable format
)
Official rhea-sdk resources:
- Social media:
- PyPI: rhea-sdk
- Documentation: Github repo
- Source: Github repo
- Issues/Bug tracker: Github issues tracker
Contributors
Code Contributors
This project exists thanks to all the people who contribute.
Metadata
Release files for rhea-sdk 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rhea_sdk-0.3.0.tar.gz | 10.9 kB | Without provenance | Details for rhea_sdk-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rhea_sdk-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for rhea_sdk-0.3.0-py3-none-any.whl |
Total release size: 22.3 kB
Release files / rhea_sdk-0.3.0.tar.gz
| Download URL | rhea_sdk-0.3.0.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b15e080a655be14bfb953bf3c4b21489a67d84e33120bad96cbc06d12b479742
|
|
BLAKE2b-256 checksum How to use checksums |
f7e4a697c71eb4eece4a6235edb444d9df1e7ccedd41cfbc91894e9a918c66ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.3
|
Release files / rhea_sdk-0.3.0-py3-none-any.whl
| Download URL | rhea_sdk-0.3.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6db49f33c3e88bed9ce977c626091ecdbf7e6ce53c4ebc805b4bd218c1de8787
|
|
BLAKE2b-256 checksum How to use checksums |
3dbcf33b6ea4bb3aeb038b9ca7f0131f0ea166608e9e5efeb9befc1924dcf41d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.3
|
Security for rhea-sdk 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.