Defining function inputs
If the function you are automating accepts arguments you have two alternative ways that you can define the arguments.
Pre-defining the function arguments would mean that every time Gelato calls the function, it would be using the same argument.
By using a resolver, you can dynamically encode the arguments of the function you are automating.
Here is an example:
This is the function we are automating.
increaseCount
increases a counter on the smart contract by amount
which is the argument. function increaseCount(uint256 amount) external {
require(
((block.timestamp - lastExecuted) > 300),
"Counter: increaseCount: Time not elapsed"
);
count += amount;
lastExecuted = block.timestamp;
}
This resolver returns the data to the function call
increaseCount
. function checker()
external
view
override
returns (bool canExec, bytes memory execData)
{
uint256 lastExecuted = ICounter(COUNTER).lastExecuted();
canExec = (block.timestamp - lastExecuted) > 300;
uint256 countToIncrease = ICounter(COUNTER).count * 2
execPayload = abi.encodeCall(
ICounter.increaseCount,
(countToIncrease)
);
}
The increment on each execution is different every time as
countToIncrease
is different after every execution. Last modified 2mo ago