Documentation

Event Handlers

How Ponder processes blockchain events

Indexed Events

DepositCreated

Creates Deposit entity

ActionInitiated

Creates Action entity with pending status

ActionProcessed

Updates Action status, updates Position

FundsReleased

Updates Deposit remainingAmount

Handler Example

ponder.on("Ingress:DepositCreated", async ({ event, context }) => {
  const { db } = context;
  await db.Deposit.create({
    id: event.args.depositId.toString(),
    data: {
      depositor: event.args.depositor,
      token: event.args.token,
      initialAmount: event.args.amount,
      remainingAmount: event.args.amount,
      released: false,
      createdAt: Number(event.block.timestamp),
    },
  });
});

Related