Events
Reference for every integrator-facing event that SwapCore (or a library it delegatecalls into) emits. Use these to drive indexers, subgraphs, monitoring dashboards, and UI feeds.
Sources:
lib/SwapEvents.sol— most event declarations (SwapCore inherits this).lib/Utils.sol— declaresBuyerTransferFailedand emits it from the settlement / liquidation paths. BecauseUtilsis a Solidity library that SwapCore delegatecalls, the event is emitted from the SwapCore address, so indexers can subscribe to the SwapCore address as the sole log source.
Event topic signatures below are the canonical keccak256("EventName(type1,type2,...)") — use them as the topic[0] filter in log queries.
Lifecycle events
MarketCreated
event MarketCreated(
bytes32 indexed marketId,
address indexed creator,
address referenceRateOracle,
address baseSwapRateOracle,
address indexed swapToken,
uint64 leverageMultiplier,
uint32 swapTerm,
Types.RateType rateType,
bytes32 correspondingMarketId
);Emitted once per side of the pair from createMarket → _initializeMarket. A single createMarket call therefore produces two MarketCreated events, one with rateType = 0 (BUY_FIXED) and one with rateType = 1 (BUY_FLOATING). Use correspondingMarketId to stitch them together into a pair.
Indexed topics: marketId, creator, swapToken.
MarketConfigured
Emitted alongside MarketCreated from _initializeMarket, carrying the rest of the config that didn't fit in MarketCreated. Use this to snapshot the full market configuration at creation time — later config is not mutable (nothing in SwapCore rewrites these fields), so a single MarketConfigured is all an indexer needs per market.
MarketCreationFeeCollected
Emitted once per createMarket call if a creation fee was configured in Admin at call time. feeToken == address(0) means the fee was paid in ETH; otherwise it's the ERC20 token address. Paired with MarketCreated events on the two market IDs.
Ownership & admin
MarketOwnershipTransferStarted
Emitted by transferMarketOwnership. Marks the start of the 2-step handoff. newOwner == address(0) means an in-flight transfer was cancelled.
MarketOwnerChanged
Emitted by acceptMarketOwnership when the pending owner accepts the role. newOwner is the new owner (msg.sender of acceptMarketOwnership).
MarketLpWhitelistUpdated
Emitted by setMarketLpWhitelist. Only meaningful on markets created with lpWhitelistEnabled = true.
MarketAdminChange
Emitted by terminateMarket with controlType = "terminateMarket" and isPaused = true. The string and bool arguments exist for forward-compatibility with future admin levers, but today this event only ever fires for termination.
Liquidity
CollateralSupplied
Emitted by supplyCollateral. onBehalfOf is the address that got the shares; caller is msg.sender (same unless a bundler is acting). sharePrice is the MtM price at mint.
CollateralTokenWithdrawn
Emitted by withdrawCollateral. amount is in swapToken decimals and was delivered to caller (which may differ from onBehalfOf when a bundler is involved).
Swap lifecycle
SwapCreated
Emitted by buySwap. The indexer reconstructs a position from this event alone — every field that makePayment will need later is included. swapRate is the all-in rate locked by the buyer; baseRate, utilFee, and riskPremium are broken out for analytics.
SwapClosed
Emitted once per swap from every closure path: makePayment, exitSwapEarly, and liquidateSwap. Branch on closureType to distinguish. For liquidations, floatingPayment and fixedPayment are 0 (not computed — liquidation uses an accrual model instead of the full settlement math) and earlyExitFee is 0.
SwapLiquidated
Emitted by liquidateSwap in addition to SwapClosed. Use this when you need the liquidator identity or the boolean flags distinguishing a buyer-side vs. pool-side liquidation. liquidatedParty == address(0) when neither side was technically "the loser" (e.g., dust liquidation). Exactly one of buyerLiquidated / poolLiquidated is true in a real liquidation; both being false is a defensive path that shouldn't occur in production.
SwapTransferred
Emitted by transferSwapPosition. The caller field captures whether the transfer was done directly (caller == previousOwner) or via a delegate (caller != previousOwner, typically the wrapper / bundler).
PoolCollateralZeroed
Emitted inside _settleSwaps when settlement caused the LP pool's collateral to hit zero (the pool lost its entire position). Rare — the last-LP guard and bucket accounting usually prevent this from happening except in extreme-loss scenarios. Monitor this event for risk dashboards; it's the canonical "pool wiped" signal.
Settlement escrow
BuyerTransferFailed
Declared and emitted inside Utils._transferOrEscrow. Because Utils is a Solidity library, the emit happens in SwapCore's execution context and indexers should subscribe to the SwapCore address.
Fires when SwapCore couldn't deliver amount of swapToken to recipient during _settleSwaps or liquidateSwap (typically a blacklisted recipient). The amount is then held in escrowedCollateral[swapId] for later retrieval via claimEscrow. Pair with EscrowClaimed for the full failed-then-recovered cycle.
EscrowClaimed
Emitted by claimEscrow. recipient is always the original swap.userAddress regardless of who called claimEscrow — the caller field captures the delegate (or the owner themselves).
Fees
ProtocolFeeCollected
Emitted by buySwap when protocolFee > 0. feeAmount is the total fee charged to the buyer — use CreatorFeeCollected (if also present in the same tx) to break out how much of that went to the market creator vs. the protocol multisig.
CreatorFeeCollected
Emitted by buySwap when a creator fee split is configured (Admin.creatorFeeShare > 0) and the graceful transfer to market.marketOwner succeeded. feeAmount here is the creator's portion only; subtract from ProtocolFeeCollected.feeAmount in the same tx to recover the multisig's portion. If the transfer to the market owner failed (rare, happens when the owner is a contract that reverts on receive), the event is not emitted and the full protocol fee is sent to the multisig.
Authorization
AuthorizationSet
Emitted by setAuthorization. authorizer is the account whose authorization list changed; authorized is the delegate; isAuthorized is the new state.
Last updated