Events and errors

Every event the contracts emit, with its fields and what it means, and every error a user or an integration can run into, with what to do about it. Names and fields are exactly as in the contracts.

Reading events

Amounts in events use the same scales as the calls: USDC in 6 decimals, pTokens in 18, prices in 18-decimal USDC per whole token. Indexed fields can be filtered on by the node, so a wallet can find its own mints by recipient without scanning every log. The Issuer was deployed at Elysium block 13157064; no Ported log on Elysium is older.

logs.ts
import { parseAbiItem } from "viem"
import { ISSUER, publicClient } from "./ported" // see the Integrate page

const FROM_BLOCK = 13157064n // the Issuer's deployment block
const STEP = 50_000n

const minted = parseAbiItem(
  "event Minted(uint32 indexed perpIndex, address indexed payer, address indexed recipient, uint256 usdcIn, uint256 fee, uint256 tokensOut, uint256 ask)",
)

// Walk forward in fixed windows: RPCs cap the block range of one eth_getLogs.
const head = await publicClient.getBlockNumber()
for (let from = FROM_BLOCK; from <= head; from += STEP) {
  const to = from + STEP - 1n < head ? from + STEP - 1n : head
  const logs = await publicClient.getLogs({
    address: ISSUER,
    event: minted,
    args: { perpIndex: 10003 }, // indexed fields filter on the node
    fromBlock: from,
    toBlock: to,
  })
  for (const l of logs) console.log(l.blockNumber, l.args.recipient, l.args.tokensOut, l.args.ask)
}

Every owned contract also emits OpenZeppelin's OwnershipTransferStarted(previousOwner, newOwner) and OwnershipTransferred(previousOwner, newOwner), and each pToken emits the standard ERC-20 Transfer and Approval. A mint shows as a Transfer from the zero address, a redemption as a Transfer to it.

Issuer: mints and redemptions

EventFieldsMeaning
MintedperpIndex (indexed), payer (indexed), recipient (indexed), usdcIn, fee, tokensOut, askA mint. payer paid usdcIn (fee included) and recipient received tokensOut at the quote's ask.
RedeemedperpIndex (indexed), holder (indexed), recipient (indexed), tokensIn, fee, usdcOut, bidA redemption. holder's tokensIn were burnt at bid (or the settlement price); usdcOut is what recipient is paid, now or from the queue.
RedeemQueuedclaimId (indexed), perpIndex (indexed), recipient (indexed), amountEmitted right after Redeemed when the Issuer could not pay at once. The USDC amount is owed to recipient under claimId.
ClaimPaidclaimId (indexed), recipient (indexed), amountA queued claim was paid in full by payClaims.
ClaimVoidedclaimId (indexed), holder (indexed), tokensThe guardian or owner voided an unpaid claim: tokens were minted back to holder, nothing is owed any more.

Issuer: markets, prices and limits

EventFieldsMeaning
MarketCreatedperpIndex (indexed), token, name, symbolA market was listed and its pToken deployed. Minting stays closed until the market is configured.
MarketConfiguredperpIndex (indexed), paramsThe owner set the market's parameters: mintEnabled, fees, band, and the ceilings on debt and hourly flows.
MarketLimitsSetperpIndex (indexed), maxDebt, maxMintPerHourThe mint-side limits in force changed (risk manager, or a reconfiguration that lowered them).
MintBudgetSetbudget, ceilingThe global mint budget or its ceiling changed. Each mint also spends the budget without an event.
ReferencePriceSetperpIndex (indexed), priceThe band's anchor moved to price: on an accepted trade or pokePrice (at most once a minute), or on a reset by the guardian or owner.
MarketSettledperpIndex (indexed), priceThe market was wound down: minting is off for good and every token redeems at price, without a quote.
SettlementAdjustedperpIndex (indexed), price, maxRedeemPerHour, redeemFeeBpsAfter a wind-down, the redemption pace or fee changed, or the settlement price was corrected (possible once).

Issuer: pauses, roles and USDC moves

EventFieldsMeaning
MintsPausedpausedMinting stopped (true) or restarted (false), on every market.
RedeemsPausedpausedRedemptions and queue payments stopped or restarted.
BridgeOutPausedpausedUSDC leaving the Issuer towards HyperEVM stopped or restarted.
BridgedOutamount, toUSDC sent to the treasury on HyperEVM through Elysium's canonical bridge.
BridgedOutRelayamount, orderIdUSDC sent to the treasury on HyperEVM through Relay, under a daily cap.
RelaySetdepository, dailyCapThe Relay route was turned on, off (zero depository) or re-capped.
FeesWithdrawnamount, toAccrued fees sent to the fee recipient.
PriceSourceSetpriceSourceThe contract that verifies quotes changed.
OperatorSetoperatorNew operator (moves USDC back to HyperEVM).
GuardianSetguardianNew guardian (pauses, resets the band, voids claims).
RiskManagerSetriskManagerNew risk manager (mint-side limits and budget); zero turns the role off.
ParentTreasurySetparentTreasuryNew destination of USDC sent back to HyperEVM.
FeeRecipientSetfeeRecipientNew recipient of withdrawn fees.

AttestedPriceSource

EventFieldsMeaning
AttesterSetattester (indexed), enabledAn address was added to or removed from the signers whose quotes count.
ThresholdSetthresholdHow many distinct attester signatures a quote needs.
MaxQuoteAgeSetageHow many seconds a quote stays valid after its issuedAt (at most 30).

HyperEVM: CoreAccount, Treasury, factory

Each market's position lives in its own CoreAccount on HyperEVM, which owns a HyperCore account. Its events record what was sent to HyperCore: orders reach Hyperliquid a few seconds after the transaction and are immediate-or-cancel, so whether and at what price an order filled is visible on Hyperliquid, not in these events.

ContractEventFieldsMeaning
CoreAccountOrderSentisBuy (indexed), sz, limitPx, cloidAn IOC order was sent: a buy grows the long, a reduce-only sell shrinks it. sz and limitPx are 1e8-scaled; cloid is the client order id on Hyperliquid.
CoreAccountOrderCancelledcloidA cancel was sent for that order id.
CoreAccountUsdcDepositedevmAmount, destinationDexUSDC moved from the contract on HyperEVM into its HyperCore account.
CoreAccountSpotToPerpusdUSDC moved from HyperCore spot into the market's perp margin.
CoreAccountPerpToSpotusdFree margin moved back to HyperCore spot, never past the leverage cap.
CoreAccountSpotToEvmweiAmountUSDC bridged from HyperCore spot back to the contract on HyperEVM.
CoreAccountHypeToCoreamountHYPE sent to HyperCore to pay its transfer gas.
CoreAccountSweptamountUSDC sent from the account to the treasury, its only allowed destination.
CoreAccountParamsSetparamsNew risk bounds: slippage, leverage cap, settle window, hourly increase and decrease limits.
CoreAccountLeverageSetupBegunagentIsolated-only markets: an agent was registered to set 1x isolated leverage.
CoreAccountLeverageSetupEndedreplacementThe agent was replaced with a fresh keyless address (also on a retry).
CoreAccountRevocationConfirmedreplacementThe guardian or owner confirmed the agent is gone: trading opens.
CoreAccountOperatorSet, GuardianSet, TreasurySetaddress (indexed)Role and destination changes.
TreasuryAccountFundedperpIndex (indexed), account, amountUSDC sent to a market's CoreAccount.
TreasuryBridgedToElysiumamount, feeUSDC sent to the Issuer on Elysium through the canonical bridge; fee is the HYPE paid for the bridge ticket.
TreasuryOwnerWithdrawaltoken, to, amountThe owner moved an asset out (zero token = HYPE). For migrations and emergencies.
TreasuryMoverSet, GuardianSetaddressRole changes.
TreasuryElysiumIssuerSetissuer, refundNew bridge recipient on Elysium and refund address for bridge fees.
TreasuryMaxBridgeFeeSetmaxBridgeFeeNew ceiling on the HYPE one bridge transaction may spend.
CoreAccount, TreasuryPaused, UnpausedaccountOpenZeppelin's pause events, with the caller.
CoreAccountFactoryAccountCreatedperpIndex (indexed), accountA market's CoreAccount was deployed.
CoreAccountFactoryDefaultsSet, UsdcDexSetdefaults / dex, allowedRoles and bounds for new accounts; which Hyperliquid dexs are accepted (USDC-margined only).

BasisVault

Each basis vault emits these events; the epoch mechanics are on Deposits, redemptions, epochs.

EventFieldsMeaning
DepositRequested, DepositCancelledepoch (indexed), user (indexed), assetsUSDC queued for an epoch, or taken back.
RedeemRequested, RedeemCancelledepoch (indexed), user (indexed), sharesShares queued for an epoch's redemption, or taken back.
EpochSettledepoch (indexed), navLow, navHigh, sharesMinted, sharesBurned, assetsReleasedAn epoch closed: deposits priced at the high NAV, redemptions at the low NAV.
DepositClaimedepoch (indexed), user (indexed), sharesShares from a settled deposit delivered.
RedeemClaimedepoch (indexed), user (indexed), assets, sharesReturnedUSDC from a settled redemption paid, and any shares not redeemed for lack of cash returned.
InstantRedeemeduser (indexed), shares, assetsA redemption paid at once from cash, for a higher fee.
PerformanceFeeassets, sharesPerformance fee charged on gains above the high-water mark, as shares to the fee recipient.
Order, Movedspot, isBuy, sz, limitPx, cloid / kind, amountOrders and USDC moves sent to the vault's HyperCore account.
ParamsSet, RolesSet, Paused, ClosingStarted…Configuration, roles, pause, and the start of a permanent wind-down.

Errors you can hit

The Issuer calls the price source while checking a trade, so the price source's errors come back from mint and redeem unchanged. Include both contracts' errors in the ABI you decode with.

ErrorRaised byCauseWhat to do
QuoteTooOld(issuedAt)Price sourceThe block's time is past issuedAt + maxQuoteAge.Fetch a new quote right before sending and retry.
QuoteFromFuture(issuedAt)Price sourceissuedAt is more than 5 seconds ahead of the block's time.Retry with a new quote; persistent cases point to a clock problem at the service.
NotEnoughSignatures(valid, threshold)Price sourceFewer signatures than threshold().Gather co-signatures through /cosign.
SignersNotSorted()Price sourceSignatures not in strictly increasing signer order, or one signer twice.Sort by signer address and drop duplicates.
UnknownSigner(signer)Price sourceA signature recovers to an address that is not a registered attester.Check the endpoint you used; verify signatures before sending.
WrongToken(expected, quoted)Price sourceThe quote prices another token.Request the quote for the perp index you are trading.
InvalidPrices(bid, ask)Price sourceZero bid, or bid above ask.Fetch a new quote.
ECDSAInvalidSignature…Price sourceA malformed signature.Pass each signature exactly as received, 65 bytes.
PriceOutOfBand(price, refPrice, allowedBps)IssuerThe bid (or, on a mint, the ask) is too far from the anchor.Wait: the band widens every minute. On a large real gap the guardian resets it.
NoReferencePrice(perpIndex)IssuerThe market has no anchor yet: trading has not opened.Wait for the market to open.
Slippage(out, minOut)IssuerThe quote gives less than your minimum.Recompute the minimum from the quote you send, or accept the new price.
FlowCapExceeded(usedAfter, cap)IssuerThe trade would take the market's hourly USDC in (or out) past its cap.Trade a smaller amount, or wait: the counter decays over the hour. Read mintedLastHour / redeemedLastHour.
MintBudgetExceeded(amount, budget)IssuerLarger than the global mint budget.Mint at most mintBudget(), or wait for it to be topped up.
DebtCapExceeded(debtAfter, maxDebt)IssuerThe market's supply would exceed its debt limit.Mint less; the room is maxDebtNow minus the current debt.
MintsArePaused()IssuerMinting is paused on every market.Wait for the owner to restart it. Redemptions may still be open.
RedeemsArePaused()IssuerRedemptions (and queue payments) are paused.Wait for the guardian or owner to reopen them. Your tokens remain transferable.
MintDisabled(perpIndex)IssuerMinting is not enabled on this market, or it is wound down.Only redeem.
UnknownMarket(perpIndex)IssuerNo market with that perp index.Read perpIndexes.
ZeroAmount()IssuerZero in, or an amount so small it rounds to zero out.Trade a larger amount.
ZeroAddress()IssuerRecipient is the zero address.Pass a recipient.
InvalidQuote(bid, ask)IssuerThe price source returned a bid above the ask.Fetch a new quote.
InvalidParams()IssuerOn a queued redemption, an amount beyond the claim's storage range (absurdly large).Redeem in smaller parts.
MarketSettledAlready(perpIndex)IssuerpokePrice on a wound-down market.No price is needed: redeem directly.
ERC20InsufficientBalancepTokenRedeeming more tokens than you hold.Redeem at most your balance.
"ERC20: insufficient allowance"USDCThe Issuer is not approved for usdcIn. Elysium USDC reverts with strings, not custom errors.Approve the Issuer first.
"ERC20: transfer amount exceeds balance"USDCNot enough USDC.Mint a smaller amount.

Role-gated functions revert with NotOperator, NotGuardian, NotRiskManager or OpenZeppelin's OwnableUnauthorizedAccount when called by anyone else; AboveCeiling, BudgetChanged, ClaimNotOpen and RenounceDisabled come from the same administrative paths. They are listed per role on Roles and powers.

Decoding a revert

Simulate before sending and read the error by name. With viem, walk the error chain to the contract revert:

decode.ts
import { BaseError, ContractFunctionRevertedError } from "viem"
import { ISSUER, issuerAbi, publicClient, walletClient } from "./ported"

try {
  await publicClient.simulateContract({
    account: walletClient.account,
    address: ISSUER,
    abi: issuerAbi, // include the Issuer's and the price source's errors
    functionName: "mint",
    args: [perp, usdcIn, minTokensOut, recipient, priceData],
  })
} catch (e) {
  const revert = e instanceof BaseError ? e.walk((x) => x instanceof ContractFunctionRevertedError) : null
  if (revert instanceof ContractFunctionRevertedError) {
    // e.g. "QuoteTooOld" [1795986787n]: fetch a new quote and retry
    console.log(revert.data?.errorName, revert.data?.args)
  } else {
    throw e
  }
}