A liquidation runs the active
beforeLiquidation and afterLiquidation hooks of every instance that holds the market, once per liquidation. Create Hook describes the timing in full.
Receive liquidation notices
AnafterLiquidation hook with actionType: 'inform' announces every liquidation of the market to a URL you run.
webhookSecret when the hook is created. This response is the only place it appears: later reads carry signed: true and never the secret. If it is lost, issue a new one with rotateSecret.
webhookUrl and riskUri must be http or https URLs on a public host. The SDK checks the scheme before sending. The API refuses a private, reserved or local host, and checks the address again on every outbound call.
A delivery is queued, then sent and retried by a worker, up to eight attempts in all. A liquidation is announced to a hook at most once, and every attempt of one delivery carries the same id, so a retry is never a second event.
Verify a delivery
Each delivery is aPOST. Its x-webhook-signature header is an HMAC-SHA256 in hex, keyed with webhookSecret exactly as returned, over the x-webhook-timestamp value, a dot, and the raw request body.
x-trusset-delivery-id, which stays the same across retries.
The body carries id, event, hookId, marketId, emittedAt and timestamp. A liquidation adds the loan, the amounts, the borrower, the transaction hash and the outcome. A monitor breach adds the monitor and its failing fields. Signed deliveries lists every field and the retry schedule.
A 2xx answer delivers it. A 5xx, 408, 425 or 429 answer, a timeout or a connection failure is retried. Any other answer, a redirect included, fails the delivery for good.
Monitor an external risk source
AmonitorRisk hook fetches riskUri on a schedule and checks fields of the JSON it returns. A field with a dot-notation path fails when the path resolves to nothing, or when its comparison with threshold fails.
riskUri and at least one riskFields entry for this type. A hook without checkFrequency is never scheduled and runs only through execute. The scheduler picks a new monitor up at its next wake-up, not at the moment of this call.
When a monitor evaluates to false, every active afterLiquidation hook that lists it in triggerHookIds acts on the breach. An inform hook then sends a riskBreach delivery. A buy hook only logs that a breach carries no auction to act on.
hookId here is the monitor’s id. A hook that lists triggers acts only when every listed hook is active and its last counted run returned false.
Check a loan before liquidation
AbeforeLiquidation hook evaluates parameterChecks and records the result. It does not block the liquidation.
debtValue and none of the other four parameters, so a check on healthFactor, collateralValue, collateralRatio or interestAccrued fails on every liquidation. Those parameters only take effect in a test run where you supply them.
Test a hook
execute runs one hook now and returns its outcome, whether or not the hook is active. What it needs depends on the type: nothing for monitorRisk, loanData for beforeLiquidation, and liquidationData for afterLiquidation.
success and result. A monitor run lists each evaluated field in fields, and a check run lists checkResults.
Executing an inform hook sends a real delivery to its webhookUrl. The run returns at once with queued: true and the deliveryId, before anything is sent. Pass an eventKey to make the call idempotent: a second call with the same key queues nothing and returns duplicate: true.
execute call after an ambiguous failure, because a repeat without eventKey queues a second delivery.
Buy hooks return steps, not bids
Treat abuy run as a price signal. To place the bid, use auctions.bid with the auction id from the run. It builds the same two steps, signs them with the bidder’s wallet and confirms the mined bid. See Auctions.
Change, pause or delete a hook
update changes only the fields you send. Arrays and webhookPayload are replaced whole, not merged. Validation runs against the merged record, so switching actionType to inform on a hook without a webhookUrl is refused.
checkFrequency, actionType or riskThreshold cannot be unset once stored. An inactive hook drops out of everything that runs on its own, and execute still runs it when called for it directly. Deliveries it queued before it was paused are still sent.
toggle instead.
Rotate the signing secret
503 while it switches so the delivery is retried. A hook whose signed reads false holds no secret, and rotating issues it one.
Read hooks, runs and deliveries
list returns every hook on the market, newest first. get refuses a hook of another market with HOOK_NOT_FOUND. executions and deliveries return newest first and page with limit, from 1 to 200, and offset.
The execution log and a hook’s executionCount are different counts. An unmet trigger, a skipped bid or a short wallet balance adds a log entry without counting as a run. An inform run is logged when its delivery is delivered or fails for good, not when it is queued.
A delivery’s status is PENDING, RETRYING, DELIVERED or FAILED. Delivered and failed deliveries are kept for at least 30 days.
