A Checker acts as a bridge between conditions and smart contract executions. Its purpose? To check conditions and determine whether a task should be executed by Gelato. Every Checker returns two main things:
canExec (Boolean): Indicates if Gelato should execute the task.
execData (Bytes): Contains the data that executors will use during execution.
Solidity functions must adhere to the block gas limit for checker calls; exceeding it will cause the call to fail.
In the above, the checker checks the state of a counter and prompts Gelato to execute if 3 minutes (180 seconds) have elapsed since its last execution.
Suppose you’re automating tasks across different pools. Instead of creating multiple tasks, iterate through your list of pools within a single checker:
Copy
Ask AI
function checker() external view returns (bool canExec, bytes memory execPayload){ uint256 delay = harvester.delay(); for (uint256 i = 0; i < vaults.length(); i++) { IVault vault = IVault(getVault(i)); canExec = block.timestamp >= vault.lastDistribution().add(delay); execPayload = abi.encodeWithSelector( IHarvester.harvestVault.selector, address(vault) ); if (canExec) return(true, execPayload); } return(false, bytes("No vaults to harvest"));}
On networks such as Ethereum, gas will get expensive at certain times. If what you are automating is not time-sensitive and don’t mind having your transaction mined at a later point, you can limit the gas price used in your execution in your checker.
Copy
Ask AI
function checker() external view returns (bool canExec, bytes memory execPayload){ // condition here if(tx.gasprice > 80 gwei) return (false, bytes("Gas price too high"));}
This way, Gelato will not execute your transaction if the gas price is higher than 80 GWEI.