Gelato-automations/deployments/mainnet/solcInputs/32abadde127e3c5f4f727f0b5ec233f4.json

34 lines
12 KiB
JSON

{
"language": "Solidity",
"sources": {
"contracts/contracts/connectors/ConnectGelato.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity 0.7.4;\npragma experimental ABIEncoderV2;\n\n// solhint-disable\n\n// Gelato Data Types\nstruct Provider {\n address addr; // if msg.sender == provider => self-Provider\n address module; // e.g. DSA Provider Module\n}\n\nstruct Condition {\n address inst; // can be AddressZero for self-conditional Actions\n bytes data; // can be bytes32(0) for self-conditional Actions\n}\n\nenum Operation {Call, Delegatecall}\n\nenum DataFlow {None, In, Out, InAndOut}\n\nstruct Action {\n address addr;\n bytes data;\n Operation operation;\n DataFlow dataFlow;\n uint256 value;\n bool termsOkCheck;\n}\n\nstruct Task {\n Condition[] conditions; // optional\n Action[] actions;\n uint256 selfProviderGasLimit; // optional: 0 defaults to gelatoMaxGas\n uint256 selfProviderGasPriceCeil; // optional: 0 defaults to NO_CEIL\n}\n\nstruct TaskReceipt {\n uint256 id;\n address userProxy;\n Provider provider;\n uint256 index;\n Task[] tasks;\n uint256 expiryDate;\n uint256 cycleId; // auto-filled by GelatoCore. 0 for non-cyclic/chained tasks\n uint256 submissionsLeft;\n}\n\nstruct TaskSpec {\n address[] conditions; // Address: optional AddressZero for self-conditional actions\n Action[] actions;\n uint256 gasPriceCeil;\n}\n\n// Gelato Interface\ninterface IGelatoInterface {\n /**\n * @dev API to submit a single Task.\n */\n function submitTask(\n Provider calldata _provider,\n Task calldata _task,\n uint256 _expiryDate\n ) external;\n\n /**\n * @dev A Gelato Task Cycle consists of 1 or more Tasks that automatically submit\n * the next one, after they have been executed, where the total number of tasks can\n * be only be an even number\n */\n function submitTaskCycle(\n Provider calldata _provider,\n Task[] calldata _tasks,\n uint256 _expiryDate,\n uint256 _cycles\n ) external;\n\n /**\n * @dev A Gelato Task Chain consists of 1 or more Tasks that automatically submit\n * the next one, after they have been executed, where the total number of tasks can\n * be an odd number\n */\n function submitTaskChain(\n Provider calldata _provider,\n Task[] calldata _tasks,\n uint256 _expiryDate,\n uint256 _sumOfRequestedTaskSubmits\n ) external;\n\n /**\n * @dev Cancel multiple tasks at once\n */\n function multiCancelTasks(TaskReceipt[] calldata _taskReceipts) external;\n\n /**\n * @dev Whitelist new executor, TaskSpec(s) and Module(s) in one tx\n */\n function multiProvide(\n address _executor,\n TaskSpec[] calldata _taskSpecs,\n address[] calldata _modules\n ) external payable;\n\n /**\n * @dev De-Whitelist TaskSpec(s), Module(s) and withdraw funds from gelato in one tx\n */\n function multiUnprovide(\n uint256 _withdrawAmount,\n TaskSpec[] calldata _taskSpecs,\n address[] calldata _modules\n ) external;\n}\n\ninterface MemoryInterface {\n function setUint(uint256 _id, uint256 _val) external;\n\n function getUint(uint256 _id) external returns (uint256);\n}\n\nabstract contract Helpers {\n uint256 internal immutable _id;\n\n constructor(uint256 id) {\n _id = id;\n }\n\n /**\n * @dev Return Memory Variable Address\n */\n function getMemoryAddr() internal pure returns (address) {\n return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address\n }\n\n /**\n * @dev Set Uint value in InstaMemory Contract.\n */\n function setUint(uint256 setId, uint256 val) internal {\n if (setId != 0) MemoryInterface(getMemoryAddr()).setUint(setId, val);\n }\n\n /**\n * @dev Get Uint value from InstaMemory Contract.\n */\n function getUint(uint256 getId, uint256 val)\n internal\n returns (uint256 returnVal)\n {\n returnVal = getId == 0\n ? val\n : MemoryInterface(getMemoryAddr()).getUint(getId);\n }\n\n /**\n * @dev Connector Details\n */\n function connectorID() public view returns (uint256 _type, uint256 id) {\n (_type, id) = (1, _id);\n }\n}\n\ncontract DSMath {\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x + y) >= x, \"math-not-safe\");\n }\n\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x - y) <= x, \"sub-overflow\");\n }\n}\n\nabstract contract GelatoHelpers is Helpers, DSMath {\n /**\n * @dev Return Gelato Core Address\n */\n function getGelatoCoreAddr() internal pure returns (address) {\n return 0x025030BdAa159f281cAe63873E68313a703725A5; // Gelato Core address\n }\n\n /**\n * @dev Return Instapp DSA Provider Module Address\n */\n function getInstadappProviderModuleAddr() internal pure returns (address) {\n return 0x0C25452d20cdFeEd2983fa9b9b9Cf4E81D6f2fE2; // ProviderModuleDSA Address\n }\n}\n\nabstract contract GelatoResolver is GelatoHelpers {\n event LogMultiProvide(\n address indexed executor,\n TaskSpec[] indexed taskspecs,\n address[] indexed modules,\n uint256 ethToDeposit,\n uint256 getId,\n uint256 setId\n );\n\n event LogSubmitTask(\n Provider indexed provider,\n Task indexed task,\n uint256 indexed expiryDate,\n uint256 getId,\n uint256 setId\n );\n\n event LogSubmitTaskCycle(\n Provider indexed provider,\n Task[] indexed tasks,\n uint256 indexed expiryDate,\n uint256 getId,\n uint256 setId\n );\n\n event LogSubmitTaskChain(\n Provider indexed provider,\n Task[] indexed tasks,\n uint256 indexed expiryDate,\n uint256 getId,\n uint256 setId\n );\n\n event LogMultiUnprovide(\n TaskSpec[] indexed taskspecs,\n address[] indexed modules,\n uint256 ethToWithdraw,\n uint256 getId,\n uint256 setId\n );\n\n event LogMultiCancelTasks(\n TaskReceipt[] indexed taskReceipt,\n uint256 getId,\n uint256 setId\n );\n\n // ===== Gelato ENTRY APIs ======\n\n /**\n * @dev Enables first time users to pre-fund eth, whitelist an executor & register the\n * ProviderModuleDSA.sol to be able to use Gelato\n * @param _executor address of single execot node or gelato'S decentralized execution market\n * @param _taskSpecs enables external providers to whitelist TaskSpecs on gelato\n * @param _modules address of ProviderModuleDSA\n * @param _ethToDeposit amount of eth to deposit on Gelato, only for self-providers\n */\n function multiProvide(\n address _executor,\n TaskSpec[] calldata _taskSpecs,\n address[] calldata _modules,\n uint256 _ethToDeposit,\n uint256 _getId,\n uint256 _setId\n ) external payable {\n uint256 ethToDeposit = getUint(_getId, _ethToDeposit);\n ethToDeposit = ethToDeposit == uint256(-1)\n ? address(this).balance\n : ethToDeposit;\n\n IGelatoInterface(getGelatoCoreAddr()).multiProvide{value: ethToDeposit}(\n _executor,\n _taskSpecs,\n _modules\n );\n\n setUint(_setId, ethToDeposit);\n\n emit LogMultiProvide(\n _executor,\n _taskSpecs,\n _modules,\n ethToDeposit,\n _getId,\n _setId\n );\n }\n\n /**\n * @dev Submits a single, one-time task to Gelato\n * @param _provider Consists of proxy module address (DSA) and provider address ()\n * who will pay for the transaction execution\n * @param _task Task specifying the condition and the action connectors\n * @param _expiryDate Default 0, othweise timestamp after which the task expires\n */\n function submitTask(\n Provider calldata _provider,\n Task calldata _task,\n uint256 _expiryDate\n ) external payable {\n IGelatoInterface(getGelatoCoreAddr()).submitTask(\n _provider,\n _task,\n _expiryDate\n );\n\n emit LogSubmitTask(_provider, _task, _expiryDate, 0, 0);\n }\n\n /**\n * @dev Submits single or mulitple Task Sequences to Gelato\n * @param _provider Consists of proxy module address (DSA) and provider address ()\n * who will pay for the transaction execution\n * @param _tasks A sequence of Tasks, can be a single or multiples\n * @param _expiryDate Default 0, othweise timestamp after which the task expires\n * @param _cycles How often the Task List should be executed, e.g. 5 times\n */\n function submitTaskCycle(\n Provider calldata _provider,\n Task[] calldata _tasks,\n uint256 _expiryDate,\n uint256 _cycles\n ) external payable {\n IGelatoInterface(getGelatoCoreAddr()).submitTaskCycle(\n _provider,\n _tasks,\n _expiryDate,\n _cycles\n );\n\n emit LogSubmitTaskCycle(_provider, _tasks, _expiryDate, 0, 0);\n }\n\n /**\n * @dev Submits single or mulitple Task Chains to Gelato\n * @param _provider Consists of proxy module address (DSA) and provider address ()\n * who will pay for the transaction execution\n * @param _tasks A sequence of Tasks, can be a single or multiples\n * @param _expiryDate Default 0, othweise timestamp after which the task expires\n * @param _sumOfRequestedTaskSubmits The TOTAL number of Task auto-submits\n * that should have occured once the cycle is complete\n */\n function submitTaskChain(\n Provider calldata _provider,\n Task[] calldata _tasks,\n uint256 _expiryDate,\n uint256 _sumOfRequestedTaskSubmits\n ) external payable {\n IGelatoInterface(getGelatoCoreAddr()).submitTaskChain(\n _provider,\n _tasks,\n _expiryDate,\n _sumOfRequestedTaskSubmits\n );\n\n emit LogSubmitTaskChain(_provider, _tasks, _expiryDate, 0, 0);\n }\n\n // ===== Gelato EXIT APIs ======\n\n /**\n * @dev Withdraws funds from Gelato, de-whitelists TaskSpecs and Provider Modules\n * in one tx\n * @param _withdrawAmount Amount of ETH to withdraw from Gelato\n * @param _taskSpecs List of Task Specs to de-whitelist, default empty []\n * @param _modules List of Provider Modules to de-whitelist, default empty []\n */\n function multiUnprovide(\n uint256 _withdrawAmount,\n TaskSpec[] calldata _taskSpecs,\n address[] calldata _modules,\n uint256 _getId,\n uint256 _setId\n ) external payable {\n uint256 withdrawAmount = getUint(_getId, _withdrawAmount);\n uint256 balanceBefore = address(this).balance;\n\n IGelatoInterface(getGelatoCoreAddr()).multiUnprovide(\n withdrawAmount,\n _taskSpecs,\n _modules\n );\n\n uint256 actualWithdrawAmount =\n sub(address(this).balance, balanceBefore);\n\n setUint(_setId, actualWithdrawAmount);\n\n emit LogMultiUnprovide(\n _taskSpecs,\n _modules,\n actualWithdrawAmount,\n _getId,\n _setId\n );\n }\n\n /**\n * @dev Cancels outstanding Tasks\n * @param _taskReceipts List of Task Receipts to cancel\n */\n function multiCancelTasks(TaskReceipt[] calldata _taskReceipts)\n external\n payable\n {\n IGelatoInterface(getGelatoCoreAddr()).multiCancelTasks(_taskReceipts);\n\n emit LogMultiCancelTasks(_taskReceipts, 0, 0);\n }\n}\n\ncontract ConnectGelato is GelatoResolver {\n string public name = \"ConnectGelato-v2.0\";\n\n constructor(uint256 _id) Helpers(_id) {}\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata",
"devdoc",
"userdoc",
"storageLayout",
"evm.gasEstimates"
],
"": ["ast"]
}
},
"metadata": {
"useLiteralContent": true
}
}
}