-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from eonian-core/development
migrete staging from gelato automation to gelato functions
- Loading branch information
Showing
24 changed files
with
995 additions
and
101 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.26; | ||
|
||
interface IJob { | ||
function canWork() external view returns (bool canExec, bytes memory reason); | ||
function work() external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.26; | ||
|
||
import {IJob} from "./IJob.sol"; | ||
|
||
interface IPayableJob is IJob { | ||
function payableWork() external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.26; | ||
|
||
/// Migraed from Gelato Automation IResolver interface | ||
/// @dev Based on https://github.com/gelatodigital/ops/blob/9a9cde6ab2f1b132b949f9244fd59a1de4da4123/contracts/interfaces/IResolver.sol | ||
interface IChecker { | ||
|
||
/// @param canExec (Boolean): Indicates if Gelato should execute the task | ||
/// @param execPayload (Bytes): Contains the data that executors will use during execution. | ||
function checker() | ||
external | ||
view | ||
returns (bool canExec, bytes memory execPayload); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,151 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.26; | ||
|
||
/// @dev Based on https://github.com/gelatodigital/ops | ||
import { ITaskTreasuryUpgradable } from "./ITaskTreasuryUpgradable.sol"; | ||
|
||
enum Module { | ||
RESOLVER, | ||
TIME, | ||
PROXY, | ||
SINGLE_EXEC | ||
} | ||
|
||
struct ModuleData { | ||
Module[] modules; | ||
bytes[] args; | ||
} | ||
|
||
/// In gelato docs and codebase named as IAutomate, | ||
/// but it fully match with legacy IOps that we used in our contracts | ||
/// To avoid unnecesary changes we will use IOps name | ||
/// | ||
/// Based on | ||
/// - https://github.com/gelatodigital/automate-unit-testing/blob/main/contracts/gelato/Types.sol | ||
/// - https://github.com/gelatodigital/automate-unit-testing/blob/main/contracts/gelato/IAutomate.sol | ||
/// - https://github.com/gelatodigital/ops | ||
interface IOps { | ||
function gelato() external view returns (address payable); | ||
// solhint-disable max-line-length | ||
/** | ||
* @notice Initiates a task with conditions which Gelato will monitor and execute when conditions are met. | ||
* | ||
* @param execAddress Address of contract that should be called by Gelato. | ||
* @param execData Execution data to be called with / function selector if execution data is yet to be determined. | ||
* @param moduleData Conditional modules that will be used. {See LibDataTypes-ModuleData} | ||
* @param feeToken Address of token to be used as payment. Use address(0) if TaskTreasury is being used, 0xeeeeee... for ETH or native tokens. | ||
* | ||
* @return taskId Unique hash of the task created. | ||
*/ | ||
function createTask( | ||
address execAddress, | ||
bytes calldata execData, | ||
ModuleData calldata moduleData, | ||
address feeToken | ||
) external returns (bytes32 taskId); | ||
|
||
/** | ||
* @notice Terminates a task that was created and Gelato can no longer execute it. | ||
* | ||
* @param taskId Unique hash of the task that is being cancelled. {See LibTaskId-getTaskId} | ||
*/ | ||
function cancelTask(bytes32 taskId) external; | ||
|
||
/** | ||
* @notice Execution API called by Gelato. | ||
* | ||
* @param taskCreator The address which created the task. | ||
* @param execAddress Address of contract that should be called by Gelato. | ||
* @param execData Execution data to be called with / function selector if execution data is yet to be determined. | ||
* @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( | ||
address taskCreator, | ||
address execAddress, | ||
bytes memory execData, | ||
ModuleData calldata moduleData, | ||
uint256 txFee, | ||
address feeToken, | ||
bool useTaskTreasuryFunds, | ||
bool revertOnFailure | ||
) external; | ||
|
||
/** | ||
* @notice Sets the address of task modules. Only callable by proxy admin. | ||
* | ||
* @param modules List of modules to be set | ||
* @param moduleAddresses List of addresses for respective modules. | ||
*/ | ||
function setModule( | ||
Module[] calldata modules, | ||
address[] calldata moduleAddresses | ||
) external; | ||
|
||
/** | ||
* @notice Helper function to query fee and feeToken to be used for payment. (For executions which pays itself) | ||
* | ||
* @return uint256 Fee amount to be paid. | ||
* @return address Token to be paid. (Determined and passed by taskCreator during createTask) | ||
*/ | ||
function getFeeDetails() external view returns (uint256, address); | ||
|
||
/** | ||
* @notice Helper func to query all open tasks by a task creator. | ||
* | ||
* @param taskCreator Address of task creator to query. | ||
* | ||
* @return bytes32[] List of taskIds created. | ||
*/ | ||
function getTaskIdsByUser(address taskCreator) | ||
external | ||
view | ||
returns (bytes32[] memory); | ||
|
||
/** | ||
* @notice TaskTreasury contract where user deposit funds to be used for fee payments. | ||
* | ||
* @return ITaskTreasuryUpgradable TaskTreasury contract interface | ||
*/ | ||
function taskTreasury() external view returns (ITaskTreasuryUpgradable); | ||
|
||
/** | ||
* @notice Helper function to compute task id with module arguments | ||
* | ||
* @param taskCreator The address which created the task. | ||
* @param execAddress Address of contract that will be called by Gelato. | ||
* @param execSelector Signature of the function which will be called by Gelato. | ||
* @param moduleData Conditional modules that will be used. {See LibDataTypes-ModuleData} | ||
* @param feeToken Address of token to be used as payment. Use address(0) if TaskTreasury is being used, 0xeeeeee... for ETH or native tokens. | ||
*/ | ||
function getTaskId( | ||
address taskCreator, | ||
address execAddress, | ||
bytes4 execSelector, | ||
ModuleData memory moduleData, | ||
address feeToken | ||
) external pure returns (bytes32 taskId); | ||
|
||
/** | ||
* @notice (Legacy) Helper function to compute task id. | ||
* | ||
* @param taskCreator The address which created the task. | ||
* @param execAddress Address of contract that will be called by Gelato. | ||
* @param execSelector Signature of the function which will be called by Gelato. | ||
* @param useTaskTreasuryFunds Wether fee should be deducted from TaskTreasury. | ||
* @param feeToken Address of token to be used as payment. Use address(0) if TaskTreasury is being used, 0xeeeeee... for ETH or native tokens. | ||
* @param resolverHash Hash of resolverAddress and resolverData {See getResolverHash} | ||
*/ | ||
function getTaskId( | ||
address taskCreator, | ||
address execAddress, | ||
bytes4 execSelector, | ||
bool useTaskTreasuryFunds, | ||
address feeToken, | ||
bytes32 resolverHash | ||
) external pure returns (bytes32); | ||
|
||
function gelato() external view returns (address payable); | ||
|
||
function getFeeDetails() external view returns (uint256, address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.26; | ||
|
||
/// Based on https://github.com/gelatodigital/automate-unit-testing/blob/main/contracts/gelato/IOpsProxy.sol | ||
interface IOpsProxy { | ||
/** | ||
* @notice Emitted when proxy calls a contract successfully in `executeCall` | ||
* | ||
* @param target Address of contract that is called | ||
* @param data Data used in the call. | ||
* @param value Native token value used in the call. | ||
* @param returnData Data returned by the call. | ||
*/ | ||
event ExecuteCall( | ||
address indexed target, bytes data, uint256 value, bytes returnData | ||
); | ||
|
||
/** | ||
* @notice Multicall to different contracts with different datas. | ||
* | ||
* @param targets Addresses of contracts to be called. | ||
* @param datas Datas for each contract call. | ||
* @param values Native token value for each contract call. | ||
*/ | ||
function batchExecuteCall( | ||
address[] calldata targets, | ||
bytes[] calldata datas, | ||
uint256[] calldata values | ||
) external payable; | ||
|
||
/** | ||
* @notice Call to a single contract. | ||
* | ||
* @param target Address of contracts to be called. | ||
* @param data Data for contract call. | ||
* @param value Native token value for contract call. | ||
*/ | ||
function executeCall(address target, bytes calldata data, uint256 value) | ||
external | ||
payable; | ||
|
||
/** | ||
* @return address Ops smart contract address | ||
*/ | ||
function ops() external view returns (address); | ||
|
||
/** | ||
* @return address Owner of the proxy | ||
*/ | ||
function owner() external view returns (address); | ||
|
||
/** | ||
* @return uint256 version of OpsProxy. | ||
*/ | ||
function version() external view returns (uint256); | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/contracts/src/automation/gelato/IOpsProxyFactory.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.26; | ||
|
||
/// Based on https://github.com/gelatodigital/automate-unit-testing/blob/main/contracts/gelato/Types.sol | ||
interface IOpsProxyFactory { | ||
function deployFor(address owner) external returns (address payable proxy); | ||
function getProxyOf(address account) external view returns (address, bool); | ||
function deploy() external returns (address payable proxy); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.