kit.borrow.borrow, kit.borrow.repay, kit.borrow.addCollateral,
kit.borrow.withdrawCollateralRepayIfNeeded, and kit.borrow.closeLoan run
through several phases before they confirm onchain. Subscribe to those phases
with kit.on to update a progress UI in real time, log operational metrics, or
diagnose where an operation stopped when it fails.
For the phase names and firing rules, see
Borrow phase events.
Prerequisites
Before you begin, ensure that you’ve: These are required so any example below runs with a validkit and adapter.
Subscribe to one phase
Pass aborrow.<phase> name to kit.on to receive only that phase’s events.
Each payload carries operation, method (the phase name), and a values
object with the phase state (pending, success, or error):
TypeScript
execute phase carries a txHash when the batch confirms. For which
phases carry hashes and what a stalled pending state means, see
Borrow phase events.
Subscribe to every Borrow phase
Pass"borrow.*" to receive events for every phase across every loan operation.
A bare "*" also matches, but it delivers bridge, earn, and unified balance
events too, so filter on the payload if you only want Borrow.
TypeScript
Unsubscribe
Pass the same handler reference tokit.off to unregister it. Inline arrow
functions create a new reference each call, so store the handler if you plan to
unsubscribe:
TypeScript