Skip to content

Commit

Permalink
fix: gelato ops factory and exec
Browse files Browse the repository at this point in the history
  • Loading branch information
ashitakah committed Feb 29, 2024
1 parent 0a5e3a2 commit 10d2429
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 28 deletions.
2 changes: 0 additions & 2 deletions solidity/interfaces/external/IAutomate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ interface IAutomate {
* @param moduleData Conditional modules that will be used. {See LibDataTypes-ModuleData}
* @param txFee Fee paid to Gelato for execution, deducted on the TaskTreasury or transfered to Gelato.
* @param feeToken Token used to pay for the execution. ETH = 0xeeeeee...
* @param useTaskTreasuryFunds If taskCreator's balance on TaskTreasury should pay for the tx.
* @param revertOnFailure To revert or not if call to execAddress fails. (Used for off-chain simulations)
*/
function exec(
Expand All @@ -88,7 +87,6 @@ interface IAutomate {
LibDataTypes.ModuleData calldata moduleData,
uint256 txFee,
address feeToken,
bool useTaskTreasuryFunds,
bool revertOnFailure
) external;

Expand Down
1 change: 0 additions & 1 deletion solidity/interfaces/relays/IGelatoRelay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity 0.8.19;

import {IAutomate} from '@interfaces/external/IAutomate.sol';
import {IGelato} from '@interfaces/external/IGelato.sol';
import {IAutomationVault} from '@interfaces/core/IAutomationVault.sol';

interface IGelatoRelay {
Expand Down
3 changes: 1 addition & 2 deletions solidity/script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ pragma solidity 0.8.19;
import {Script} from 'forge-std/Script.sol';

import {AutomationVaultFactory, IAutomationVaultFactory} from '@contracts/core/AutomationVaultFactory.sol';
import {AutomationVault, IAutomationVault} from '@contracts/core/AutomationVault.sol';
import {IAutomationVault} from '@contracts/core/AutomationVault.sol';
import {OpenRelay, IOpenRelay} from '@contracts/relays/OpenRelay.sol';
import {GelatoRelay, IGelatoRelay} from '@contracts/relays/GelatoRelay.sol';
import {Keep3rRelay, IKeep3rRelay} from '@contracts/relays/Keep3rRelay.sol';
import {Keep3rBondedRelay, IKeep3rBondedRelay} from '@contracts/relays/Keep3rBondedRelay.sol';
import {XKeeperMetadata, IXKeeperMetadata} from '@contracts/periphery/XKeeperMetadata.sol';
import {_NATIVE_TOKEN} from '@utils/Constants.sol';
import {BasicJobChecker} from '@contracts/for-test/BasicJobChecker.sol';
import {IAutomate} from '@interfaces/external/IAutomate.sol';
import {IKeep3rV2} from '@interfaces/external/IKeep3rV2.sol';

Expand Down
2 changes: 1 addition & 1 deletion solidity/test/integration/AutomationVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {CommonIntegrationTest} from '@test/integration/Common.t.sol';

import {IAutomationVault} from '@interfaces/core/IAutomationVault.sol';
import {IERC20, SafeERC20} from '@openzeppelin/token/ERC20/utils/SafeERC20.sol';
import {_DAI_WHALE, _DAI, _NATIVE_TOKEN} from './Constants.sol';
import {_DAI_WHALE, _DAI} from './Constants.sol';

contract IntegrationAutomationVault is CommonIntegrationTest {
using SafeERC20 for IERC20;
Expand Down
4 changes: 2 additions & 2 deletions solidity/test/integration/Common.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {BasicJob} from '@contracts/for-test/BasicJob.sol';
import {Deploy} from '@script/Deploy.s.sol';
import {IAutomate} from '@interfaces/external/IAutomate.sol';
import {IKeep3rV2} from '@interfaces/external/IKeep3rV2.sol';
import {_AUTOMATE, _KEEP3R_V2} from './Constants.sol';
import {_KEEP3R_V2} from './Constants.sol';

contract DeployForTest is Deploy {
uint256 private constant _FORK_BLOCK = 18_500_000;
Expand Down Expand Up @@ -37,7 +37,7 @@ abstract contract CommonIntegrationTest is DeployForTest, Test {
function setUp() public virtual override {
DeployForTest.setUp();

gelatoAutomate = IAutomate(_AUTOMATE); // TODO: check with 0x2A6C106ae13B558BB9E2Ec64Bd2f1f7BEFF3A5E0
gelatoAutomate = IAutomate(0x2A6C106ae13B558BB9E2Ec64Bd2f1f7BEFF3A5E0);
keep3rV2 = IKeep3rV2(_KEEP3R_V2);

bot = makeAddr('Bot');
Expand Down
4 changes: 1 addition & 3 deletions solidity/test/integration/Constants.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {IAutomate} from '@interfaces/external/IAutomate.sol';
import {IOpsProxyFactory} from '@interfaces/external/IOpsProxyFactory.sol';
import {IKeep3rV2} from '@interfaces/external/IKeep3rV2.sol';
import {IKeep3rV1} from '@interfaces/external/IKeep3rV1.sol';
Expand All @@ -13,8 +12,7 @@ address constant _KP3R_WHALE = 0x2FC52C61fB0C03489649311989CE2689D93dC1a2;
address constant _DAI_WHALE = 0xDE228965da0d064b8aE171A02500602e84E8330d;
address constant _NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
IERC20 constant _DAI = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
IAutomate constant _AUTOMATE = IAutomate(0xB3f5503f93d5Ef84b06993a1975B9D21B962892F);
IOpsProxyFactory constant _OPS_PROXY_FACTORY = IOpsProxyFactory(0xC815dB16D4be6ddf2685C201937905aBf338F5D7);
IOpsProxyFactory constant _OPS_PROXY_FACTORY = IOpsProxyFactory(0x44bde1bccdD06119262f1fE441FBe7341EaaC185);
IKeep3rV2 constant _KEEP3R_V2 = IKeep3rV2(0xeb02addCfD8B773A5FFA6B9d1FE99c566f8c44CC);
IKeep3rV1 constant _KEEP3R_V1 = IKeep3rV1(0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44);
IKeep3rHelper constant _KEEP3R_HELPER = IKeep3rHelper(0xeDDe080E28Eb53532bD1804de51BD9Cd5cADF0d4);
24 changes: 8 additions & 16 deletions solidity/test/integration/GelatoRelay.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ contract IntegrationGelatoRelay is CommonIntegrationTest {
_whitelistedCallers[0] = _getDedicatedMsgSender(owner);

// Job selectors array
bytes4[] memory _jobSelectors = new bytes4[](2);
bytes4[] memory _jobSelectors = new bytes4[](1);
_jobSelectors[0] = basicJob.work.selector;
_jobSelectors[1] = basicJob.workHard.selector;

// Job data array
IAutomationVault.JobData[] memory _jobsData = new IAutomationVault.JobData[](1);
Expand All @@ -59,7 +58,7 @@ contract IntegrationGelatoRelay is CommonIntegrationTest {
automationVault.addRelay(address(gelatoRelay), _whitelistedCallers, _jobsData);

(bool _success,) = address(automationVault).call{value: 100 ether}('');
require(_success);
if (!_success) revert();

Check warning on line 61 in solidity/test/integration/GelatoRelay.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

Provide an error message for revert

Check warning on line 61 in solidity/test/integration/GelatoRelay.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

Use Custom Errors instead of revert statements

changePrank(address(gelato));
}
Expand Down Expand Up @@ -94,12 +93,8 @@ contract IntegrationGelatoRelay is CommonIntegrationTest {
IAutomationVault.ExecData[] memory _execData = new IAutomationVault.ExecData[](1);
_execData[0] = IAutomationVault.ExecData(address(basicJob), abi.encodeWithSelector(basicJob.work.selector));

IAutomationVault.FeeData[] memory _feeData = new IAutomationVault.FeeData[](1);
_feeData[0] = IAutomationVault.FeeData(bot, _NATIVE_TOKEN, 1 ether);

// Create exec data for Automate
bytes memory _execDataAutomate =
abi.encodeWithSelector(gelatoRelay.exec.selector, automationVault, _execData, _feeData);
bytes memory _execDataAutomate = abi.encodeWithSelector(gelatoRelay.exec.selector, automationVault, _execData);

// Create module data for Automate
LibDataTypes.ModuleData memory _moduleData = _createModuleData();
Expand All @@ -109,20 +104,17 @@ contract IntegrationGelatoRelay is CommonIntegrationTest {
vm.expectEmit(address(automate));
emit ExecSuccess(1 ether, _NATIVE_TOKEN, address(gelatoRelay), _execDataAutomate, taskId, true);

// Execute in Automate and expect Gelato to execute the job
automate.exec(owner, address(gelatoRelay), _execDataAutomate, _moduleData, 1 ether, _NATIVE_TOKEN, false, true);
//Execute in Automate and expect Gelato to execute the job
automate.exec(owner, address(gelatoRelay), _execDataAutomate, _moduleData, 1 ether, _NATIVE_TOKEN, true);
}

function test_executeAndGetPaymentFromGelato(uint16 _howHard) public {
vm.assume(_howHard <= 1000);

function test_executeAndGetPaymentFromGelato() public {
// Get the fee collector balance
address _feeCollector = gelato.feeCollector();
uint256 _balance = _feeCollector.balance;

IAutomationVault.ExecData[] memory _execData = new IAutomationVault.ExecData[](1);
_execData[0] =
IAutomationVault.ExecData(address(basicJob), abi.encodeWithSelector(basicJob.workHard.selector, _howHard));
_execData[0] = IAutomationVault.ExecData(address(basicJob), abi.encodeWithSelector(basicJob.work.selector));

// Create exec data for Automate
bytes memory _execDataAutomate = abi.encodeWithSelector(gelatoRelay.exec.selector, automationVault, _execData);
Expand All @@ -131,7 +123,7 @@ contract IntegrationGelatoRelay is CommonIntegrationTest {
LibDataTypes.ModuleData memory _moduleData = _createModuleData();

// Execute in Automate and expect Gelato to execute the job
automate.exec(owner, address(gelatoRelay), _execDataAutomate, _moduleData, 1 ether, _NATIVE_TOKEN, false, true);
automate.exec(owner, address(gelatoRelay), _execDataAutomate, _moduleData, 1 ether, _NATIVE_TOKEN, true);

assertEq(_feeCollector.balance, _balance + 1 ether);
}
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/integration/OpenRelay.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract IntegrationOpenRelay is CommonIntegrationTest {
// AutomationVault approve relay data
automationVault.addRelay(address(openRelay), _bots, _jobsData);
(bool _success,) = address(automationVault).call{value: 100 ether}('');
require(_success);
if (!_success) revert();

Check warning on line 31 in solidity/test/integration/OpenRelay.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

Provide an error message for revert

Check warning on line 31 in solidity/test/integration/OpenRelay.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

Use Custom Errors instead of revert statements

changePrank(bot);
}
Expand Down

0 comments on commit 10d2429

Please sign in to comment.