Haedal Module
The Haedal Module provides staking and unstaking functionality for the Haedal protocol, allowing users to stake SUI to receive haSUI and obtain APY statistics.
Core Features
- SUI Staking: Stake SUI to receive haSUI
- haSUI Unstaking: Unstake haSUI to receive SUI
- APY Query: Get current staking annual percentage yield
Configuration Options
packageId
The package ID of the Haedal contract, defaults to 0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2
.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
const walletClient = new WalletClient({
configs: {
haedal: {
packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2"
}
}
})
configId
The ID of the Haedal configuration object, defaults to 0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca
.
API Reference
getApy
Get the current APY for Haedal staking.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
const walletClient = new WalletClient()
const apy = await walletClient.haedal.getApy()
console.log('Current APY:', apy)
Result Example
5.2
stake
Stake SUI to receive haSUI.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
const walletClient = new WalletClient()
const result = await walletClient.haedal.stake(
1000000000, // Staking amount (1 SUI)
{ dryRun: false } // Optional parameters
)
stakePTB
Adds staking operation to a transaction block for building complex transactions.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
import { Transaction } from '@mysten/sui/transactions'
const walletClient = new WalletClient()
const tx = new Transaction()
// Get SUI balance and merge coins
const suiBalance = walletClient.balance.portfolio.getBalance('0x2::sui::SUI')
const mergedCoin = mergeCoinsPTB(tx, suiBalance.coins, {
balance: 1000000000, // 1 SUI
useGasCoin: true
})
// Add staking operation to transaction
const haSUICoin = await walletClient.haedal.stakePTB(tx, mergedCoin)
// Transfer haSUI to user address
tx.transferObjects([haSUICoin], walletClient.address)
// Execute transaction
const result = await walletClient.signExecuteTransaction({
transaction: tx,
dryRun: false
})
stake
method instead.unstake
Unstake haSUI to receive SUI.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
const walletClient = new WalletClient()
const result = await walletClient.haedal.unstake(
1000000000, // Unstaking amount (1 haSUI)
{ dryRun: false } // Optional parameters
)
unstakePTB
Adds unstaking operation to a transaction block for building complex transactions.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
import { Transaction } from '@mysten/sui/transactions'
const walletClient = new WalletClient()
const tx = new Transaction()
// Get haSUI balance and merge coins
const haSuiBalance = walletClient.balance.portfolio.getBalance(
'0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI'
)
const mergedCoin = mergeCoinsPTB(tx, haSuiBalance.coins, {
balance: 1000000000 // 1 haSUI
})
// Add unstaking operation to transaction
const suiCoin = await walletClient.haedal.unstakePTB(tx, mergedCoin)
// Transfer SUI to user address
tx.transferObjects([suiCoin], walletClient.address)
// Execute transaction
const result = await walletClient.signExecuteTransaction({
transaction: tx,
dryRun: false
})
unstake
method instead.Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
const walletClient = new WalletClient({
configs: {
haedal: {
configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca"
}
}
})
coinType
The haSUI token type, defaults to 0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI
.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
const walletClient = new WalletClient({
configs: {
haedal: {
coinType: '0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI'
}
}
})
Events
haedal:stake-success
Event triggered when staking is successful.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
const walletClient = new WalletClient()
walletClient.events.on('haedal:stake-success', (data) => {
console.log('Staking successful:', {
suiAmount: data.suiAmount
})
})
Event Data Example
{
"suiAmount": 1000000000
}
haedal:unstake-success
Event triggered when unstaking is successful.
Usage Example
import { WalletClient } from '@naviprotocol/wallet-client'
const walletClient = new WalletClient()
walletClient.events.on('haedal:unstake-success', (data) => {
console.log('Unstaking successful:', {
haSUIAmount: data.haSUIAmount
})
})
Event Data Example
{
"haSUIAmount": 1000000000
}