Contracts

Access-control legend: anyone = permissionless · bonded = permissionless with economic stake · wired = callable only by a registered protocol contract.

BazaarPair — src/BazaarPair.sol

One EIP-1167 clone per market. Initialized once by the factory.

FunctionAccessPurpose
depositCollateral / withdrawCollateralanyone / meta-txcollateral in/out; withdrawal enforces IMR at bracket prices and, while a position is open, the max(0.5% of notional, $5) retained floor
createOrder / cancelOrdersanyone / meta-txsee Orders
matchBatchbonded sequencerthree-pass batch matching
liquidate(users[], …)anyonefull liquidation of insolvent buckets — and, once a settlement price is fixed, the terminal-settlement entry point (no price update, no ETH, no solvency threshold)
executeAdl(winners[], …)anyoneDutch-auction deleveraging
depositToInsurance / requestInsuranceWithdrawal / executeInsuranceWithdrawalanyone / meta-txinsurance LP flows
refreshPriceanyonepush a Pyth update, roll funding/margin state
creditInsuranceFromSequencerwired (sequencer)books slash proceeds
setScheduledTermination / fixSettlementPrice / creditInsuranceFromTerminatorwired (terminator)lifecycle transitions (finalizeTermination is public after the 48 h settlement window; settling positions at the fixed price runs through liquidate)

Key views: batchHashes, positionBuckets, orders, lastPairPrice, getSharesAsOf, plus everything on the lens.

BazaarFactory — src/BazaarFactory.sol

FunctionAccess
proposePairDeployment / settleDeploymentProposalanyone (bonded)
proposeUmaIdentifierUpgrade / settleIdentifierUpgradeProposalanyone (bonded)
activateIdentifierUpgradeanyone, once the 14-day post-approval timelock elapses
expireStuckDeploymentProposal / expireStuckIdentifierUpgradeProposalanyone, once the proposal is provably unsettleable
claimSeedRefundanyone (pays only the caller's own credit)
assertionResolvedCallback / assertionDisputedCallbackwired (the UMA OO recorded per assertion)
getPairAddress / isPair / getAllPairs / pairsCount / proposal gettersview
umaIdentifierIsLiveview — the one-call monitoring endpoint; false means listings and UMA terminations are failing closed
requiredDeploymentBond / requiredIdentifierUpgradeBondview — quote before approving; the constants are floors under UMA's live minimum

oo is immutable; umaIdentifier is the single governed parameter. See Markets & Listing.

BazaarSequencer — src/BazaarSequencer.sol

FunctionAccess
deposit / withdrawanyone (own bond)
challengeOmission / challengeStaleBatchanyone
recordVolumewired (registered pairs)
registerPairwired (factory)
checkVolumeCapacity / getRollingVolume / getDynamicTakerSequencerFeeview

BazaarOracle — src/BazaarOracle.sol

FunctionAccess
registerCompositeanyone (idempotent)
updateAndFetchPrice / fetchHistoricalPriceanyone, payable (Pyth fee)
tryReadFreshPrice / tryReadStalePrice / getUpdateFee / getCompositeIdview

BazaarPairTerminator — src/BazaarPairTerminator.sol

FunctionAccess
proposeTermination / proposePostCessationTermination / settleTerminationProposalanyone (bonded) — both proposals take a pairDescription and a reason, charset- and length-bounded
terminateScheduledPair / terminateStalePairanyone
proposeInsurerTermination / voteForInsurerTermination / executeInsurerTerminationinsurance shareholders (bonded) / anyone to execute
registerPairwired (factory)
UMA callbackswired (recorded OO)
requiredTerminationBond / getLockedShares / isPairview

BazaarPairLens — src/BazaarPairLens.sol

Stateless views: getPositionBucket, checkBucketSolvency, getInsuranceSharePrice, getInsuranceDepositValue, getAdlScoreThreshold, getAdlScore (a candidate's auction score and eligibility, exactly as executeAdl ranks them — sort batches by it descending), getTerminalEntitlement (post-termination payout components: collateral, registered claim, frozen ratio), getTerminalSettlementBounty (a sweep keeper's reward for settling a position at the fixed price), getMaxWithdrawable (the largest withdrawal the margin/retention gates would accept — pass the conservative bracket price: spot − conf for a long, spot + conf for a short), getPendingLiquidationExposure, getAuxState, plus constant getters for EIP-712 domains/typehashes, order lifetimes, min collateral, insurance-withdrawal limits, vault-health thresholds, and the flat sequencer fee. Note: the pair's getUserActiveLimitOrders mutates (lazy cleanup) — eth_call it, don't index it as pure.

External dependencies

DependencyUsed for
Pyth (IPyth)all pricing
UMA Optimistic Oracle V3listings, identifier upgrades, terminations (address immutable)
USDC (ERC-20 + ERC-2612)sole collateral
Arbitrum ArbSys (0x64)L2 block numbers
OpenZeppelinClones, SafeERC20, Math, Initializable, ReentrancyGuard, EnumerableSet, ECDSA, Strings