Technical overview
Public contracts, asset accounting, and wallet transactions for lending, USDHN, staking, and swaps
Hann Finance combines lending markets, collateral-backed USDHN borrowing, liquid staking, and swaps. Each product has its own contracts for asset balances, debt, and position ownership. An integration reads those contracts through the selected chain's RPC and submits transactions from the user's wallet.
Contract reads and wallet transactions
Read contract state
Wallet transactions
The integration prepares the contract call, and the wallet signs and submits it. Depending on the action, the destination is the Lending Pool, a CDP Zapper, the bKAIA or HNKAIA vault, or the StableSwap Router. CDP Zappers coordinate the borrowing and swap calls below.
Read-only calls return balances, positions, prices, and quotes. Contracts enforce ownership, asset transfers, debt changes, and execution limits. Simulation evaluates a proposed call without submitting a transaction. The transaction receipt and its logs record the executed result; read the resulting balances and position state after confirmation.
Lending
Pool, reserve aTokens, and debt tokens
Supply assets, borrow from market liquidity, repay, and withdraw
USDHN borrowing
A separate BorrowerOperations and TroveManager for each collateral branch
Lock collateral in a Trove and mint USDHN debt
Earn
Each branch's StabilityPool
Deposit USDHN; receive USDHN yield and collateral from liquidations
bKAIA staking
LSTVault and LSTToken
Deposit KAIA for bKAIA shares; request withdrawals and claim ready tickets
HNKAIA
HNKAIA and HNKAIAAssetVault
Deposit supported staking assets for HNKAIA shares and redeem underlying assets
Swap and LP
StableSwap, StableSwapRouter, LP token, and RewardStaker
Exchange USDT and USDHN, supply liquidity, and stake LP tokens
USDHN collateral branches
USDHN borrowing has KAIA, HNKAIA, and earnUSDT collateral branches. The KAIA branch holds WKAIA; its Zapper wraps native KAIA before supplying collateral. The earnUSDT branch holds wEarnUSDT, the wrapped earnUSDT collateral token.
Each branch contains:
BorrowerOperations, which opens, adjusts, and closes Troves and changes their interest-rate settings.TroveManager, which calculates current debt and collateral, handles liquidations and redemptions, and records Trove status.TroveNFT, which identifies the owner of each position, andSortedTroves, which orders positions by interest rate.ActivePool,DefaultPool,CollSurplusPool, andGasPool, which hold collateral and account for active debt, redistribution, surplus collateral, and gas compensation.StabilityPool, which burns deposited USDHN to offset liquidation debt and receives collateral.PriceFeedandAddressesRegistry, which supply the branch's price and contract configuration.
The shared CollateralRegistry routes USDHN redemptions across active, redeemable branches. HintHelpers supplies insertion hints; RedemptionHelper supplies redemption calculations. A Trove's latest debt includes pending interest, redistribution, and batch-management fees. Read getLatestTroveData() for current position values rather than treating its recorded debt as the full amount owed.
Position health
For an open CDP position with debt, collateral ratio is collateral's USD value divided by the Trove's entire USDHN debt. The contract uses 1e18 units for collateral, debt, price, and the resulting ratio:
The branch enforces MCR for individual collateral ratios, CCR for branch-wide borrowing and withdrawal constraints, SCR for shutdown, and additional limits for batched loans. CDP liquidation uses ICR < MCR. A normal redemption reduces debt and collateral in the selected Troves, starting with lower interest rates after checking any recorded small-debt Trove. Collateral charged as the redemption fee stays in the affected Trove. Liquidation offsets debt through the Stability Pool and redistributes the remainder within the branch.
Lending uses the account's health factor, calculated from enabled collateral, applicable liquidation thresholds, and total debt. Pool.getUserAccountData() returns that health factor at 1e18 precision. An account with a health factor below 1e18 is eligible for Lending liquidation. CDP and Lending maintain separate debt and liquidation rules.
Zappers and flash execution
A Zapper collects the user's approved tokens or native KAIA, executes its configured route, and returns route leftovers to the receiver. Permit2 entrypoints use a signature alongside the token's allowance to Permit2; ordinary allowance paths remain separate.
WKAIAZapper
Native KAIA and WKAIA collateral operations
HNKAIAZapper
HNKAIA collateral operations
EarnUSDTZapper
earnUSDT wrapping and wrapped-collateral operations
LeverageWKAIAZapper, LeverageHNKAIAZapper, LeverageEarnUSDTZapper
Open, increase, reduce, or close a flash-assisted position with the corresponding collateral
FlashSwapper
DEX flash-swap callback, StableSwap execution, and in-transaction settlement
StableSwapZapper
Liquidity operations and LP staking
Flash-assisted execution hands Trove management to the authorized FlashSwapper for the callback and restores the management state afterward. The managed state includes the add manager, remove manager, and receiver. Callback authorization, expected-token checks, configured flash-fee caps, and final-debt checks bind the route to the submitted operation. Balance snapshots separate route leftovers from balances that were already present.
openLeveragedTrove, leverUpTrove, and leverDownTrove take maxDebt, the maximum final entire debt. closeTroveByCollateral sells collateral to repay the entire debt and returns remaining stable tokens; its parameter struct contains troveId and profitReceiver, with no user-supplied minimum-output field. Use each entrypoint's actual limits when preparing a transaction.
Staking, swaps, and cross-chain transfers
Use the LSTVault address for bKAIA deposits, withdrawal requests, claims, and reads. requestUnstakeByShares creates withdrawal tickets for the amount accepted by the staking nodes. Unprocessed shares remain in the wallet. Tickets have separate readiness and claim times. claimMany processes submitted tickets, including partial results. RequestUnstake, ClaimPayout, TicketStatusUpdated, and ClaimManySummary record the opened requests, payouts, ticket states, and batch totals.
HNKAIA represents a share of the vault's supported staking tokens. redeemProRata burns HNKAIA and pays each token in proportion to its vault balance, rounding down in integer token units. This basket redemption has no redemption fee and remains available while priced deposit and single-asset redemption flows are paused. RedeemProRata and RedeemProRataAsset record the redeemed shares and token outputs.
StableSwap provides exact-input and exact-output quotes, liquidity quotes, execution deadlines, minimum outputs, and maximum inputs. StableSwapRouter validates its pools, token allowlist, and recipients. The pool accounts for reserves and fees; LP staking and rewards belong to RewardStaker. LiquidityAdded and LiquidityRemoved record router liquidity operations. Stake, Unstake, and Claim record RewardStaker operations.
USDHNToken implements ERC-20 and permit. USDHNOFTAdapter locks and unlocks the canonical token for LayerZero transfers; USDHNOFT mints and burns the remote-chain token. The app's Bridge flow transfers supported USDT or USDC source assets into Kaia USDT through Rhino.fi. A source-chain receipt confirms the source transaction; destination delivery has its own transaction and status.
Read, simulate, submit, and confirm
Select the chain, contract address, and ABI from the Smart Contracts reference. Identify tokens by chain and address, including each receipt token and debt token.
Read the current balance, allowance, position, price, and quote used by the action. For a Trove, use its latest entire debt; for Lending, use the account-level collateral, debt, and health factor.
Prepare the required token approval, Permit2 signature, credit delegation, or manager/operator permission. Each permission authorizes the specified contract; the following action performs the asset or position change.
Simulate the action with the intended sender, calldata, native value, receiver, deadline, and amount limits. State changes between simulation and execution can cause the submitted transaction to revert.
Submit from the wallet, retain the transaction hash, and check the receipt on the same chain. A reverted action leaves that action's state changes unapplied and still consumes gas; earlier successful approvals remain set.
Decode logs using the emitting contract's ABI and address, then read the resulting position. Check processed amounts for staking tickets and redemptions; receipt success does not imply that the entire requested amount was processed.
Networks and contract addresses
Kaia Mainnet uses chain ID 8217; Kairos testnet uses 1001. Hann Finance's mainnet contracts have not been deployed. Mainnet and testnet address records are separate in Smart Contracts. Use the recorded address for the intended network. A token symbol alone does not identify a contract across networks or across Lending, CDP, and staking.
The Smart Contracts reference lists public contract names, functions, events, deployment status, and network address records. The Integrator Guide describes wallet transactions and event processing. Trove status transitions are described in Trove Manager, and route behavior in Zapper.
Last updated
Was this helpful?