Asynchronous SDK for interacting with Rhea Finance DEX
Project description
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.
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
rhea_sdk-0.3.0.tar.gz
(10.9 kB
view details)
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
rhea_sdk-0.3.0-py3-none-any.whl
(11.4 kB
view details)
File details
Details for the file rhea_sdk-0.3.0.tar.gz.
File metadata
- Download URL: rhea_sdk-0.3.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b15e080a655be14bfb953bf3c4b21489a67d84e33120bad96cbc06d12b479742
|
|
| MD5 |
5401d452efb4149605f8540f38e686e7
|
|
| BLAKE2b-256 |
f7e4a697c71eb4eece4a6235edb444d9df1e7ccedd41cfbc91894e9a918c66ea
|
File details
Details for the file rhea_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: rhea_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6db49f33c3e88bed9ce977c626091ecdbf7e6ce53c4ebc805b4bd218c1de8787
|
|
| MD5 |
6d9d4193de856f1e3a888977b79fc2ba
|
|
| BLAKE2b-256 |
3dbcf33b6ea4bb3aeb038b9ca7f0131f0ea166608e9e5efeb9befc1924dcf41d
|