Skip to content

Schedule/Cron

These handlers are executed with a frequency specified by the user (every minute, hour, etc).

Use cases

  • Check if there are any pending liquidations in a protocol every minute, and execute the liquidation function.
  • Check a contract's state and react accordingly (by sending notifications, calling a function, etc)

Examples

Liquidation bot

function handle(ScheduleEvent calldata ev) external {
    if (!MY_PROTOCOL.pendingLiquidations()) {
        return;
    }

    kyn.useAccount(...); // TBD

    LiquidationResult memory result = MY_PROTOCOL.liquidate();

    notify(result);
}