Events and accounting
Rebuild volume, fees and interest from events alone, counting each execution once and keeping accruals apart from payments.
Updated Nov 9, 2026
Dusk emits events by self-CPI, including for executions nested under the leverage delegate. The full list, with fields, is generated in the events reference. Each number has one canonical event, and accrued and paid interest must never be added together.
Identifying an event
Index only successful, finalized transactions. An event is identified by transaction signature, invocation path and event ordinal; one transaction, and one position, can contain several executions. Match related records inside their originating instruction invocation, not by position alone.
Event families
| Family | Events |
|---|---|
| Market | MarketCreated, MarketHealthUpdated, MarketReduceOnlyUpdated |
| Liquidity and yield | LiquidityAdded, LiquidityRemoved, YieldClaimed, YieldRecipientUpdated, HarvestAuthorityUpdated |
| Swaps | SwapExecuted |
| Credit | MarketCollateralDeposited, MarketCollateralWithdrawn, MarketDebtUpdated, BorrowPositionLiquidated |
| hLP | HlpOpened, HlpClosed, HlpTerminalLiquidated |
| Leverage | LeveragePositionOpened, LeveragePositionUpdated, LeveragePositionClosed, LeveragePositionLiquidated, LeverageDelegationUpdated |
| Operators | OperatorChangeAnnounced, OperatorChangeResolved, OperatorChanged, ManagerChanged, OperatorRevenueClaimed |
| Protocol revenue | ProtocolAuctionConfigUpdated, ProtocolAuctionRecipientsUpdated, ProtocolAuctionRouteUpdated, ProtocolAuctionSplitUpdated, ProtocolAuctionSettled |
| Referral | ReferralPartnerConfigured, ReferralRecipientUpdated, ReferralInterestShareCapUpdated, ReferralBound, ReferralInterestAccrued, ReferralInterestClaimed |
The leverage-delegate program emits two events of its own, OrderProtocolFeePaid and ProtectionExecuted; the rest of an execution surfaces as Dusk events.
Swaps and swap fees
SwapExecuted is the canonical record of every AMM execution: ordinary swaps, leverage opens, increases, decreases and closes, plus any liquidation route that actually executes through Dusk's AMM. Atomic external flash routes and EMA-and-smoothed-depth emergency accounting are recorded by their own settlement events and do not imply a spot swap. Adding or repaying leverage margin emits no swap event.
origin names the product that caused the execution; trader is the beneficial owner, actor the signer, position the leverage or credit position when there is one. Amounts mean the same thing for every origin:
| Field | Meaning |
|---|---|
amount_in | AMM input before trading fees, after any input transfer fee; includes borrowed principal when it funds a leverage swap |
amount_in_after_fee | Input applied to the curve |
amount_out | AMM output after trading fees, before output transfer fees |
gross_amount_out | Output before an output-denominated trading fee |
base_fee, divergence_fee, volatility_fee | The trading fee components, in the mint fee_asset_side names |
retained_fee, compounded_fee | Allocations of those fees, not additional fees |
Volume is one side of each execution, valued with one price convention across origins. DEX volume includes leverage-originated executions; filter by origin for direct spot volume. Leverage lifecycle events repeat their embedded swap receipts for context and must not be counted again.
Credit
Use MarketDebtUpdated.cash_debit from borrow invocations for direct credit origination: principal leaving the market before any transfer fee. cash_credit is the borrower's net receipt.
Keep repayments, liquidations and supplier deposits as separate flows. Outstanding debt is a balance, not volume, and it moves with interest and share rounding.
LeveragePositionLiquidated.socialized_loss records funded principal loss allocated to junior backing first and senior backing second. These are liquidation accounting fields, not trading volume. A zero-net collateral liquidation can emit this event without SwapExecuted.
Interest accrued
BorrowInterestAccrued records one asset's borrow-index checkpoint with three buckets, each the difference between that bucket's independently floored debt at the old and new index:
credit_intereston direct credit positions,margin_intereston isolated leverage positions,hlp_intereston aggregate hLP funding.
Never split an aggregate afterwards; that misattributes rounding atoms.
Accrual is lazy: any instruction that touches the market may checkpoint interest owed by all three sources, and the event belongs to the debt buckets, not to the instruction that triggered it. No event is emitted for a zero-atom accrual or a repeated checkpoint in the same slot; previews emit nothing.
Accrued interest is not collected cash, protocol revenue or supplier yield.
Interest paid
BorrowInterestPaid is the canonical record of a payment, with source equal to Credit, Margin or Hlp:
| Field | Meaning |
|---|---|
interest_paid | Gross interest collected, excluding principal |
interest_vault_credit | Actual net interest-vault receipt |
protocol_interest_revenue | Protocol allocation from that net receipt, before referral |
referral_amount | The part of the protocol allocation owed to the referrer |
caller_bounty | Gross terminal hLP caller reward funded from interest |
The protocol keeps protocol_interest_revenue − referral_amount. The remaining net receipt is split between the operator and LP income books: the operator receives its configured share of base interest, while the protocol markup is added on top. Read those allocations from the income books; do not treat all non-protocol receipts as LP income.
OperatorRevenueClaimed records a later payout, not another interest collection. Transfer fees and the terminal bounty explain why gross collection can exceed the vault receipt. A later ProtocolAuctionSettled is not a second collection.
Rules of thumb
- Count a payment once.
ReferralInterestAccrued,YieldClaimedand embedded lifecycle interest repeat it for context. - Keep accrual and payment as separate series; never sum them into one revenue number.
- Spot, credit and margin volumes overlap by design. Report them side by side; do not add them.
- Convert atoms to a common currency off-chain with an explicit price source and period convention. The indexer's activity endpoint publishes its own.