A command-line tool for interacting with Bonzo Finance's lending protocol on Hedera. This script supports deposits, withdrawals, borrowing, and repayments for various tokens including WHBAR.
- 🔄 Support for multiple tokens (WHBAR, USDC, SAUCE, etc.)
- 💰 Native HBAR to WHBAR conversion
- 🔒 Automatic collateral management
- 📊 Detailed balance tracking
- 🌐 Support for both testnet and mainnet
- Node.js (v14 or higher)
- npm or yarn
- Hedera account with HBAR
- Private key with sufficient HBAR for gas fees
Create a .env file in the root directory with the following variables:
# Testnet
PRIVATE_KEY_TESTNET=your_private_key
ACCOUNT_ID_TESTNET=your_account_id
# Mainnet
PRIVATE_KEY_MAINNET=your_mainnet_private_key
ACCOUNT_ID_MAINNET=your_mainnet_account_id
# RPC URL
PROVIDER_URL_MAINNET=your_mainnet_provider_url
# Chain Type
CHAIN_TYPE=hedera_testnetnpm installnode index.js <action> <token> <amount>-
action: The operation to performdeposit: Supply assets to the lending poolwithdraw: Withdraw supplied assetsborrow: Borrow assets from the lending poolrepay: Repay borrowed assets
-
token: The token symbol to operate withWHBAR: Wrapped HBARUSDC: USD CoinSAUCE: Sauce TokenHBARX: HBARX TokenKARATE: Karate TokenGRELF: Grelf TokenKBL: KBL TokenBONZO: Bonzo TokenDOVU: DOVU TokenHST: HST TokenPACK: Pack TokenSTEAM: Steam Token
-
amount: The amount to deposit/withdraw/borrow/repay (in human-readable format)
# Deposit 1 WHBAR
node index.js deposit WHBAR 1
# Withdraw 100 USDC
node index.js withdraw USDC 100
# Borrow 50 SAUCE
node index.js borrow SAUCE 50
# Repay 25 WHBAR
node index.js repay WHBAR 25For WHBAR operations, the script automatically:
- Checks WHBAR balance
- Converts native HBAR to WHBAR if needed
- Approves WHBAR tokens to both the lending pool and WHBAR contract
- Executes the requested operation
- Enables the asset as collateral (for deposits)
The script provides detailed balance information:
- Initial token and aToken balances
- Final token and aToken balances
- Amount of tokens spent/received
- Confirmation of aToken minting
The script includes comprehensive error handling for:
- Insufficient balances
- Failed transactions
- Invalid parameters
- Network issues
- Testnet:
https://testnet.hashio.io/api - Mainnet: Custom provider URL (specified in .env)
The script automatically handles token decimals:
- WHBAR: 8 decimals
- USDC: 6 decimals
- SAUCE: 6 decimals
- HBARX: 8 decimals
- KARATE: 8 decimals
- GRELF: 8 decimals
- KBL: 8 decimals
- BONZO: 8 decimals
- DOVU: 8 decimals
- HST: 8 decimals
- PACK: 6 decimals
- STEAM: 2 decimals
- Never commit your
.envfile - Keep your private keys secure
- Use testnet for testing
- Verify transaction details before confirming