From 53e6b6133ef79ee949e930d30e8e4ce5121037b2 Mon Sep 17 00:00:00 2001 From: Hilmar X Date: Thu, 3 Sep 2020 17:53:48 +0200 Subject: [PATCH 1/7] added gelato connector --- contracts/connectors/gelato.sol | 334 ++++++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 contracts/connectors/gelato.sol diff --git a/contracts/connectors/gelato.sol b/contracts/connectors/gelato.sol new file mode 100644 index 0000000..4006516 --- /dev/null +++ b/contracts/connectors/gelato.sol @@ -0,0 +1,334 @@ +pragma solidity ^0.6.0; +pragma experimental ABIEncoderV2; + +import { DSMath } from '../common/math.sol'; + + +// Gelato Data Types +struct Provider { + address addr; // if msg.sender == provider => self-Provider + address module; // can be address(0) for self-Providers +} + +struct Condition { + address inst; // can be AddressZero for self-conditional Actions + bytes data; // can be bytes32(0) for self-conditional Actions +} + +enum Operation { Call, Delegatecall } + +enum DataFlow { None, In, Out, InAndOut } + +struct Action { + address addr; + bytes data; + Operation operation; + DataFlow dataFlow; + uint256 value; + bool termsOkCheck; +} + +struct Task { + Condition[] conditions; // optional + Action[] actions; + uint256 selfProviderGasLimit; // optional: 0 defaults to gelatoMaxGas + uint256 selfProviderGasPriceCeil; // optional: 0 defaults to NO_CEIL +} + +struct TaskReceipt { + uint256 id; + address userProxy; + Provider provider; + uint256 index; + Task[] tasks; + uint256 expiryDate; + uint256 cycleId; // auto-filled by GelatoCore. 0 for non-cyclic/chained tasks + uint256 submissionsLeft; +} + +struct TaskSpec { + address[] conditions; // Address: optional AddressZero for self-conditional actions + Action[] actions; + uint256 gasPriceCeil; +} + +// Gelato Interface +interface IGelatoInterface { + + /** + * @dev API to submit a single Task. + */ + function submitTask( + Provider calldata _provider, + Task calldata _task, + uint256 _expiryDate + ) + external; + + + /** + * @dev A Gelato Task Cycle consists of 1 or more Tasks that automatically submit + * the next one, after they have been executed. + */ + function submitTaskCycle( + Provider calldata _provider, + Task[] calldata _tasks, + uint256 _expiryDate, + uint256 _cycles + ) + external; + + + /** + * @dev A Gelato Task Cycle consists of 1 or more Tasks that automatically submit + * the next one, after they have been executed. + */ + function submitTaskChain( + Provider calldata _provider, + Task[] calldata _tasks, + uint256 _expiryDate, + uint256 _sumOfRequestedTaskSubmits + ) + external; + + /** + * @dev Cancel multiple tasks at once + */ + function multiCancelTasks(TaskReceipt[] calldata _taskReceipts) external; + + /** + * @dev Whitelist new executor, TaskSpec(s) and Module(s) in one tx + */ + function multiProvide( + address _executor, + TaskSpec[] calldata _taskSpecs, + address[] calldata _modules + ) + external + payable; + + + /** + * @dev De-Whitelist TaskSpec(s), Module(s) and withdraw funds from gelato in one tx + */ + function multiUnprovide( + uint256 _withdrawAmount, + TaskSpec[] calldata _taskSpecs, + address[] calldata _modules + ) + external; +} + + +interface MemoryInterface { + function setUint(uint _id, uint _val) external; +} + +contract Helpers { + + /** + * @dev Return Memory Variable Address + */ + function getMemoryAddr() internal pure returns (address) { + return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address + } + + /** + * @dev Set Uint value in InstaMemory Contract. + */ + function setUint(uint setId, uint val) internal { + if (setId != 0) MemoryInterface(getMemoryAddr()).setUint(setId, val); + } + + /** + * @dev Connector Details + */ + function connectorID() public pure returns(uint _type, uint _id) { + (_type, _id) = (1, 420); + } +} + +contract GelatoHelpers is Helpers, DSMath { + + /** + * @dev Return Gelato Core Address + */ + function getGelatoCoreAddr() internal pure returns (address) { + return 0x1d681d76ce96E4d70a88A00EBbcfc1E47808d0b8; // Gelato Core address + } + + /** + * @dev Return Instapp DSA Provider Module Address + */ + function getInstadappProviderModuleAddr() internal pure returns (address) { + return 0x0C25452d20cdFeEd2983fa9b9b9Cf4E81D6f2fE2; // ProviderModuleDSA Address + } + +} + + +contract GelatoResolver is GelatoHelpers { + + // ===== Gelato ENTRY APIs ====== + + /** + * @dev Enables first time users to pre-fund eth, whitelist an executor & register the + * ProviderModuleDSA.sol to be able to use Gelato + * @param _executor address of single execot node or gelato'S decentralized execution market + * @param _taskSpecs enables external providers to whitelist TaskSpecs on gelato + * @param _modules address of ProviderModuleDSA + * @param _ethToDeposit amount of eth to deposit on Gelato, only for self-providers + */ + function multiProvide( + address _executor, + TaskSpec[] calldata _taskSpecs, + address[] calldata _modules, + uint256 _ethToDeposit + ) + external + payable + { + try IGelatoInterface(getGelatoCoreAddr()).multiProvide{value: _ethToDeposit}( + _executor, + _taskSpecs, + _modules + ) { + } catch Error(string memory error) { + revert(string(abi.encodePacked("ConnectGelato.multiProvide:", error))); + } catch { + revert("ConnectGelato.multiProvide: unknown error"); + } + } + + /** + * @dev Submits a single, one-time task to Gelato + * @param _provider Consists of proxy module address (DSA) and provider address () + * who will pay for the transaction execution + * @param _task Task specifying the condition and the action connectors + * @param _expiryDate Default 0, othweise timestamp after which the task expires + */ + function submitTask( + Provider calldata _provider, + Task calldata _task, + uint256 _expiryDate + ) + external + { + try IGelatoInterface(getGelatoCoreAddr()).submitTask(_provider, _task, _expiryDate) { + } catch Error(string memory error) { + revert(string(abi.encodePacked("ConnectGelato.submitTask:", error))); + } catch { + revert("ConnectGelato.submitTask: unknown error"); + } + } + + /** + * @dev Submits single or mulitple Task Sequences to Gelato + * @param _provider Consists of proxy module address (DSA) and provider address () + * who will pay for the transaction execution + * @param _tasks A sequence of Tasks, can be a single or multiples + * @param _expiryDate Default 0, othweise timestamp after which the task expires + * @param _cycles How often the Task List should be executed, e.g. 5 times + */ + function submitTaskCycle( + Provider calldata _provider, + Task[] calldata _tasks, + uint256 _expiryDate, + uint256 _cycles + ) + external + { + try IGelatoInterface(getGelatoCoreAddr()).submitTaskCycle( + _provider, + _tasks, + _expiryDate, + _cycles + ) { + } catch Error(string memory error) { + revert(string(abi.encodePacked("ConnectGelato.submitTaskCycle:", error))); + } catch { + revert("ConnectGelato.submitTaskCycle: unknown error"); + } + } + + /** + * @dev Submits single or mulitple Task Chains to Gelato + * @param _provider Consists of proxy module address (DSA) and provider address () + * who will pay for the transaction execution + * @param _tasks A sequence of Tasks, can be a single or multiples + * @param _expiryDate Default 0, othweise timestamp after which the task expires + * @param _sumOfRequestedTaskSubmits The TOTAL number of Task auto-submits + * that should have occured once the cycle is complete + */ + function submitTaskChain( + Provider calldata _provider, + Task[] calldata _tasks, + uint256 _expiryDate, + uint256 _sumOfRequestedTaskSubmits + ) + external + { + try IGelatoInterface(getGelatoCoreAddr()).submitTaskChain( + _provider, + _tasks, + _expiryDate, + _sumOfRequestedTaskSubmits + ) { + } catch Error(string memory error) { + revert(string(abi.encodePacked("ConnectGelato.submitTaskChain:", error))); + } catch { + revert("ConnectGelato.submitTaskChain: unknown error"); + } + } + + // ===== Gelato EXIT APIs ====== + + /** + * @dev Withdraws funds from Gelato, de-whitelists TaskSpecs and Provider Modules + * in one tx + * @param _withdrawAmount Amount of ETH to withdraw from Gelato + * @param _taskSpecs List of Task Specs to de-whitelist, default empty [] + * @param _modules List of Provider Modules to de-whitelist, default empty [] + */ + function multiUnprovide( + uint256 _withdrawAmount, + TaskSpec[] calldata _taskSpecs, + address[] calldata _modules, + uint256 _setId + ) + external + { + uint256 balanceBefore = address(this).balance; + try IGelatoInterface(getGelatoCoreAddr()).multiUnprovide( + _withdrawAmount, + _taskSpecs, + _modules + ) { + setUint(_setId, sub(address(this).balance, balanceBefore)); + } catch Error(string memory error) { + revert(string(abi.encodePacked("ConnectGelato.multiUnprovide:", error))); + } catch { + revert("ConnectGelato.multiUnprovide: unknown error"); + } + } + + /** + * @dev Cancels outstanding Tasks + * @param _taskReceipts List of Task Receipts to cancel + */ + function multiCancelTasks(TaskReceipt[] calldata _taskReceipts) + external + { + try IGelatoInterface(getGelatoCoreAddr()).multiCancelTasks(_taskReceipts) { + } catch Error(string memory error) { + revert(string(abi.encodePacked("ConnectGelato.multiCancelTasks:", error))); + } catch { + revert("ConnectGelato.multiCancelTasks: unknown error"); + } + } +} + + +contract ConnectGelato is GelatoResolver { + string public name = "Gelato-v1.0"; +} \ No newline at end of file From bae4842bab96fa10b9b467bd500d7a2448e2b137 Mon Sep 17 00:00:00 2001 From: Hilmar X Date: Fri, 4 Sep 2020 10:18:00 +0200 Subject: [PATCH 2/7] updated task chain comment --- contracts/connectors/gelato.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/connectors/gelato.sol b/contracts/connectors/gelato.sol index 4006516..0010585 100644 --- a/contracts/connectors/gelato.sol +++ b/contracts/connectors/gelato.sol @@ -68,7 +68,8 @@ interface IGelatoInterface { /** * @dev A Gelato Task Cycle consists of 1 or more Tasks that automatically submit - * the next one, after they have been executed. + * the next one, after they have been executed, where the total number of tasks can + * be only be an even number */ function submitTaskCycle( Provider calldata _provider, @@ -80,8 +81,9 @@ interface IGelatoInterface { /** - * @dev A Gelato Task Cycle consists of 1 or more Tasks that automatically submit - * the next one, after they have been executed. + * @dev A Gelato Task Chain consists of 1 or more Tasks that automatically submit + * the next one, after they have been executed, where the total number of tasks can + * be an odd number */ function submitTaskChain( Provider calldata _provider, From ebd5bd0760d928559581de537101328eac05465b Mon Sep 17 00:00:00 2001 From: Hilmar X Date: Fri, 4 Sep 2020 10:18:59 +0200 Subject: [PATCH 3/7] comment formatting --- contracts/connectors/gelato.sol | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/connectors/gelato.sol b/contracts/connectors/gelato.sol index 0010585..855d024 100644 --- a/contracts/connectors/gelato.sol +++ b/contracts/connectors/gelato.sol @@ -57,7 +57,7 @@ interface IGelatoInterface { /** * @dev API to submit a single Task. - */ + */ function submitTask( Provider calldata _provider, Task calldata _task, @@ -70,7 +70,7 @@ interface IGelatoInterface { * @dev A Gelato Task Cycle consists of 1 or more Tasks that automatically submit * the next one, after they have been executed, where the total number of tasks can * be only be an even number - */ + */ function submitTaskCycle( Provider calldata _provider, Task[] calldata _tasks, @@ -84,7 +84,7 @@ interface IGelatoInterface { * @dev A Gelato Task Chain consists of 1 or more Tasks that automatically submit * the next one, after they have been executed, where the total number of tasks can * be an odd number - */ + */ function submitTaskChain( Provider calldata _provider, Task[] calldata _tasks, @@ -95,12 +95,12 @@ interface IGelatoInterface { /** * @dev Cancel multiple tasks at once - */ + */ function multiCancelTasks(TaskReceipt[] calldata _taskReceipts) external; /** * @dev Whitelist new executor, TaskSpec(s) and Module(s) in one tx - */ + */ function multiProvide( address _executor, TaskSpec[] calldata _taskSpecs, @@ -112,7 +112,7 @@ interface IGelatoInterface { /** * @dev De-Whitelist TaskSpec(s), Module(s) and withdraw funds from gelato in one tx - */ + */ function multiUnprovide( uint256 _withdrawAmount, TaskSpec[] calldata _taskSpecs, @@ -130,7 +130,7 @@ contract Helpers { /** * @dev Return Memory Variable Address - */ + */ function getMemoryAddr() internal pure returns (address) { return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address } @@ -154,14 +154,14 @@ contract GelatoHelpers is Helpers, DSMath { /** * @dev Return Gelato Core Address - */ + */ function getGelatoCoreAddr() internal pure returns (address) { return 0x1d681d76ce96E4d70a88A00EBbcfc1E47808d0b8; // Gelato Core address } /** * @dev Return Instapp DSA Provider Module Address - */ + */ function getInstadappProviderModuleAddr() internal pure returns (address) { return 0x0C25452d20cdFeEd2983fa9b9b9Cf4E81D6f2fE2; // ProviderModuleDSA Address } From b9c5f2935bdcb834265d5a161b36a46abfa6c684 Mon Sep 17 00:00:00 2001 From: Hilmar X Date: Fri, 4 Sep 2020 10:28:56 +0200 Subject: [PATCH 4/7] removed false module comment --- contracts/connectors/gelato.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/connectors/gelato.sol b/contracts/connectors/gelato.sol index 855d024..e998e8a 100644 --- a/contracts/connectors/gelato.sol +++ b/contracts/connectors/gelato.sol @@ -7,7 +7,7 @@ import { DSMath } from '../common/math.sol'; // Gelato Data Types struct Provider { address addr; // if msg.sender == provider => self-Provider - address module; // can be address(0) for self-Providers + address module; // e.g. DSA Provider Module } struct Condition { From 92a5a7e1120d39fe57c908d5cd1b69973ccc8eec Mon Sep 17 00:00:00 2001 From: Hilmar X Date: Fri, 4 Sep 2020 14:37:06 +0200 Subject: [PATCH 5/7] added suggestions --- contracts/connectors/gelato.sol | 90 +++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/contracts/connectors/gelato.sol b/contracts/connectors/gelato.sol index e998e8a..c94f386 100644 --- a/contracts/connectors/gelato.sol +++ b/contracts/connectors/gelato.sol @@ -124,6 +124,11 @@ interface IGelatoInterface { interface MemoryInterface { function setUint(uint _id, uint _val) external; + function getUint(uint _id) external returns (uint); +} + +interface EventInterface { + function emitEvent(uint connectorType, uint connectorID, bytes32 eventCode, bytes calldata eventData) external; } contract Helpers { @@ -135,6 +140,13 @@ contract Helpers { return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address } + /** + * @dev Return InstaEvent Address. + */ + function getEventAddr() internal pure returns (address) { + return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97; // InstaEvent Address + } + /** * @dev Set Uint value in InstaMemory Contract. */ @@ -142,6 +154,13 @@ contract Helpers { if (setId != 0) MemoryInterface(getMemoryAddr()).setUint(setId, val); } + /** + * @dev Get Uint value from InstaMemory Contract. + */ + function getUint(uint getId, uint val) internal returns (uint returnVal) { + returnVal = getId == 0 ? val : MemoryInterface(getMemoryAddr()).getUint(getId); + } + /** * @dev Connector Details */ @@ -171,6 +190,19 @@ contract GelatoHelpers is Helpers, DSMath { contract GelatoResolver is GelatoHelpers { + event LogMultiProvide(address indexed executor, TaskSpec[] indexed taskspecs, address[] indexed modules, uint256 ethToDeposit, uint256 getId, uint256 setId); + + event LogSubmitTask(Provider indexed provider, Task indexed task, uint256 indexed expiryDate, uint256 getId, uint256 setId); + + event LogSubmitTaskCycle(Provider indexed provider, Task[] indexed tasks, uint256 indexed expiryDate, uint256 getId, uint256 setId); + + event LogSubmitTaskChain(Provider indexed provider, Task[] indexed tasks, uint256 indexed expiryDate, uint256 getId, uint256 setId); + + event LogMultiUnprovide(TaskSpec[] indexed taskspecs, address[] indexed modules, uint256 ethToWithdraw, uint256 getId, uint256 setId); + + event LogMultiCancelTasks(TaskReceipt[] indexed taskReceipt, uint256 getId, uint256 setId); + + // ===== Gelato ENTRY APIs ====== /** @@ -185,12 +217,15 @@ contract GelatoResolver is GelatoHelpers { address _executor, TaskSpec[] calldata _taskSpecs, address[] calldata _modules, - uint256 _ethToDeposit + uint256 _ethToDeposit, + uint256 _getId, + uint256 _setId ) external payable { - try IGelatoInterface(getGelatoCoreAddr()).multiProvide{value: _ethToDeposit}( + uint256 ethToDeposit = getUint(_getId, _ethToDeposit); + try IGelatoInterface(getGelatoCoreAddr()).multiProvide{value: ethToDeposit}( _executor, _taskSpecs, _modules @@ -200,6 +235,14 @@ contract GelatoResolver is GelatoHelpers { } catch { revert("ConnectGelato.multiProvide: unknown error"); } + + setUint(_setId, ethToDeposit); + + emit LogMultiProvide(_executor, _taskSpecs, _modules, ethToDeposit, _getId, _setId); + bytes32 _eventCode = keccak256("LogMultiProvide(address,(address[],(address,bytes,uint8,uint8,uint256,bool)[],uint256)[],address[],uint256,uint256,uint256)"); + bytes memory _eventParam = abi.encode(_executor, _taskSpecs, _modules, ethToDeposit, _getId, _setId); + (uint _type, uint _id) = connectorID(); + EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } /** @@ -215,6 +258,7 @@ contract GelatoResolver is GelatoHelpers { uint256 _expiryDate ) external + payable { try IGelatoInterface(getGelatoCoreAddr()).submitTask(_provider, _task, _expiryDate) { } catch Error(string memory error) { @@ -222,6 +266,12 @@ contract GelatoResolver is GelatoHelpers { } catch { revert("ConnectGelato.submitTask: unknown error"); } + + emit LogSubmitTask(_provider, _task, _expiryDate, 0, 0); + bytes32 _eventCode = keccak256("LogSubmitTask((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256),uint256,uint256,uint256)"); + bytes memory _eventParam = abi.encode(_provider, _task, _expiryDate, 0, 0); + (uint _type, uint _id) = connectorID(); + EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } /** @@ -239,6 +289,7 @@ contract GelatoResolver is GelatoHelpers { uint256 _cycles ) external + payable { try IGelatoInterface(getGelatoCoreAddr()).submitTaskCycle( _provider, @@ -251,6 +302,12 @@ contract GelatoResolver is GelatoHelpers { } catch { revert("ConnectGelato.submitTaskCycle: unknown error"); } + + emit LogSubmitTaskCycle(_provider, _tasks, _expiryDate, 0, 0); + bytes32 _eventCode = keccak256("LogSubmitTaskCycle((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)"); + bytes memory _eventParam = abi.encode(_provider, _tasks, _expiryDate, 0, 0); + (uint _type, uint _id) = connectorID(); + EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } /** @@ -269,6 +326,7 @@ contract GelatoResolver is GelatoHelpers { uint256 _sumOfRequestedTaskSubmits ) external + payable { try IGelatoInterface(getGelatoCoreAddr()).submitTaskChain( _provider, @@ -281,6 +339,12 @@ contract GelatoResolver is GelatoHelpers { } catch { revert("ConnectGelato.submitTaskChain: unknown error"); } + + emit LogSubmitTaskChain(_provider, _tasks, _expiryDate, 0, 0); + bytes32 _eventCode = keccak256("LogSubmitTaskChain((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)"); + bytes memory _eventParam = abi.encode(_provider, _tasks, _expiryDate, 0, 0); + (uint _type, uint _id) = connectorID(); + EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } // ===== Gelato EXIT APIs ====== @@ -296,22 +360,33 @@ contract GelatoResolver is GelatoHelpers { uint256 _withdrawAmount, TaskSpec[] calldata _taskSpecs, address[] calldata _modules, + uint256 _getId, uint256 _setId ) external + payable { + uint256 withdrawAmount = getUint(_getId, _withdrawAmount); uint256 balanceBefore = address(this).balance; + uint256 actualWithdrawAmount; try IGelatoInterface(getGelatoCoreAddr()).multiUnprovide( - _withdrawAmount, + withdrawAmount, _taskSpecs, _modules ) { - setUint(_setId, sub(address(this).balance, balanceBefore)); + actualWithdrawAmount = sub(address(this).balance, balanceBefore); + setUint(_setId, actualWithdrawAmount); } catch Error(string memory error) { revert(string(abi.encodePacked("ConnectGelato.multiUnprovide:", error))); } catch { revert("ConnectGelato.multiUnprovide: unknown error"); } + + emit LogMultiUnprovide(_taskSpecs, _modules, actualWithdrawAmount, _getId, _setId); + bytes32 _eventCode = keccak256("LogMultiUnprovide(address,(address[],(address,bytes,uint8,uint8,uint256,bool)[],uint256)[],address[],uint256,uint256,uint256)"); + bytes memory _eventParam = abi.encode(_taskSpecs, _modules, actualWithdrawAmount, _getId, _setId); + (uint _type, uint _id) = connectorID(); + EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } /** @@ -320,6 +395,7 @@ contract GelatoResolver is GelatoHelpers { */ function multiCancelTasks(TaskReceipt[] calldata _taskReceipts) external + payable { try IGelatoInterface(getGelatoCoreAddr()).multiCancelTasks(_taskReceipts) { } catch Error(string memory error) { @@ -327,6 +403,12 @@ contract GelatoResolver is GelatoHelpers { } catch { revert("ConnectGelato.multiCancelTasks: unknown error"); } + + emit LogMultiCancelTasks(_taskReceipts, 0, 0); + bytes32 _eventCode = keccak256("LogMultiCancelTasks((uint256,address,(address,address),uint256,((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)[])"); + bytes memory _eventParam = abi.encode(_taskReceipts, 0, 0); + (uint _type, uint _id) = connectorID(); + EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } } From 36fe5adc31def71e6cc0c0b0cab6ebbdcad0258a Mon Sep 17 00:00:00 2001 From: Hilmar X Date: Fri, 4 Sep 2020 14:53:06 +0200 Subject: [PATCH 6/7] removed try catchs --- contracts/connectors/gelato.sol | 89 +++++++++++++-------------------- 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/contracts/connectors/gelato.sol b/contracts/connectors/gelato.sol index c94f386..25911f5 100644 --- a/contracts/connectors/gelato.sol +++ b/contracts/connectors/gelato.sol @@ -225,23 +225,20 @@ contract GelatoResolver is GelatoHelpers { payable { uint256 ethToDeposit = getUint(_getId, _ethToDeposit); - try IGelatoInterface(getGelatoCoreAddr()).multiProvide{value: ethToDeposit}( + IGelatoInterface(getGelatoCoreAddr()).multiProvide{value: ethToDeposit}( _executor, _taskSpecs, _modules - ) { - } catch Error(string memory error) { - revert(string(abi.encodePacked("ConnectGelato.multiProvide:", error))); - } catch { - revert("ConnectGelato.multiProvide: unknown error"); - } + ); setUint(_setId, ethToDeposit); emit LogMultiProvide(_executor, _taskSpecs, _modules, ethToDeposit, _getId, _setId); - bytes32 _eventCode = keccak256("LogMultiProvide(address,(address[],(address,bytes,uint8,uint8,uint256,bool)[],uint256)[],address[],uint256,uint256,uint256)"); + bytes32 _eventCode = keccak256( + "LogMultiProvide(address,(address[],(address,bytes,uint8,uint8,uint256,bool)[],uint256)[],address[],uint256,uint256,uint256)" + ); bytes memory _eventParam = abi.encode(_executor, _taskSpecs, _modules, ethToDeposit, _getId, _setId); - (uint _type, uint _id) = connectorID(); + (uint256 _type, uint256 _id) = connectorID(); EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } @@ -260,17 +257,14 @@ contract GelatoResolver is GelatoHelpers { external payable { - try IGelatoInterface(getGelatoCoreAddr()).submitTask(_provider, _task, _expiryDate) { - } catch Error(string memory error) { - revert(string(abi.encodePacked("ConnectGelato.submitTask:", error))); - } catch { - revert("ConnectGelato.submitTask: unknown error"); - } + IGelatoInterface(getGelatoCoreAddr()).submitTask(_provider, _task, _expiryDate); emit LogSubmitTask(_provider, _task, _expiryDate, 0, 0); - bytes32 _eventCode = keccak256("LogSubmitTask((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256),uint256,uint256,uint256)"); + bytes32 _eventCode = keccak256( + "LogSubmitTask((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256),uint256,uint256,uint256)" + ); bytes memory _eventParam = abi.encode(_provider, _task, _expiryDate, 0, 0); - (uint _type, uint _id) = connectorID(); + (uint256 _type, uint256 _id) = connectorID(); EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } @@ -291,22 +285,19 @@ contract GelatoResolver is GelatoHelpers { external payable { - try IGelatoInterface(getGelatoCoreAddr()).submitTaskCycle( + IGelatoInterface(getGelatoCoreAddr()).submitTaskCycle( _provider, _tasks, _expiryDate, _cycles - ) { - } catch Error(string memory error) { - revert(string(abi.encodePacked("ConnectGelato.submitTaskCycle:", error))); - } catch { - revert("ConnectGelato.submitTaskCycle: unknown error"); - } + ); emit LogSubmitTaskCycle(_provider, _tasks, _expiryDate, 0, 0); - bytes32 _eventCode = keccak256("LogSubmitTaskCycle((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)"); + bytes32 _eventCode = keccak256( + "LogSubmitTaskCycle((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)" + ); bytes memory _eventParam = abi.encode(_provider, _tasks, _expiryDate, 0, 0); - (uint _type, uint _id) = connectorID(); + (uint256 _type, uint256 _id) = connectorID(); EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } @@ -328,22 +319,19 @@ contract GelatoResolver is GelatoHelpers { external payable { - try IGelatoInterface(getGelatoCoreAddr()).submitTaskChain( + IGelatoInterface(getGelatoCoreAddr()).submitTaskChain( _provider, _tasks, _expiryDate, _sumOfRequestedTaskSubmits - ) { - } catch Error(string memory error) { - revert(string(abi.encodePacked("ConnectGelato.submitTaskChain:", error))); - } catch { - revert("ConnectGelato.submitTaskChain: unknown error"); - } + ); emit LogSubmitTaskChain(_provider, _tasks, _expiryDate, 0, 0); - bytes32 _eventCode = keccak256("LogSubmitTaskChain((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)"); + bytes32 _eventCode = keccak256( + "LogSubmitTaskChain((address,address),((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)" + ); bytes memory _eventParam = abi.encode(_provider, _tasks, _expiryDate, 0, 0); - (uint _type, uint _id) = connectorID(); + (uint256 _type, uint256 _id) = connectorID(); EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } @@ -369,23 +357,21 @@ contract GelatoResolver is GelatoHelpers { uint256 withdrawAmount = getUint(_getId, _withdrawAmount); uint256 balanceBefore = address(this).balance; uint256 actualWithdrawAmount; - try IGelatoInterface(getGelatoCoreAddr()).multiUnprovide( + IGelatoInterface(getGelatoCoreAddr()).multiUnprovide( withdrawAmount, _taskSpecs, _modules - ) { - actualWithdrawAmount = sub(address(this).balance, balanceBefore); + ); + + actualWithdrawAmount = sub(address(this).balance, balanceBefore); setUint(_setId, actualWithdrawAmount); - } catch Error(string memory error) { - revert(string(abi.encodePacked("ConnectGelato.multiUnprovide:", error))); - } catch { - revert("ConnectGelato.multiUnprovide: unknown error"); - } emit LogMultiUnprovide(_taskSpecs, _modules, actualWithdrawAmount, _getId, _setId); - bytes32 _eventCode = keccak256("LogMultiUnprovide(address,(address[],(address,bytes,uint8,uint8,uint256,bool)[],uint256)[],address[],uint256,uint256,uint256)"); + bytes32 _eventCode = keccak256( + "LogMultiUnprovide(address,(address[],(address,bytes,uint8,uint8,uint256,bool)[],uint256)[],address[],uint256,uint256,uint256)" + ); bytes memory _eventParam = abi.encode(_taskSpecs, _modules, actualWithdrawAmount, _getId, _setId); - (uint _type, uint _id) = connectorID(); + (uint256 _type, uint256 _id) = connectorID(); EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } @@ -397,17 +383,14 @@ contract GelatoResolver is GelatoHelpers { external payable { - try IGelatoInterface(getGelatoCoreAddr()).multiCancelTasks(_taskReceipts) { - } catch Error(string memory error) { - revert(string(abi.encodePacked("ConnectGelato.multiCancelTasks:", error))); - } catch { - revert("ConnectGelato.multiCancelTasks: unknown error"); - } + IGelatoInterface(getGelatoCoreAddr()).multiCancelTasks(_taskReceipts); emit LogMultiCancelTasks(_taskReceipts, 0, 0); - bytes32 _eventCode = keccak256("LogMultiCancelTasks((uint256,address,(address,address),uint256,((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)[])"); + bytes32 _eventCode = keccak256( + "LogMultiCancelTasks((uint256,address,(address,address),uint256,((address,bytes)[],(address,bytes,uint8,uint8,uint256,bool)[],uint256,uint256)[],uint256,uint256,uint256)[])" + ); bytes memory _eventParam = abi.encode(_taskReceipts, 0, 0); - (uint _type, uint _id) = connectorID(); + (uint256 _type, uint256 _id) = connectorID(); EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); } } From b6718b7954afdb3647a15d2b4512b10e83a79888 Mon Sep 17 00:00:00 2001 From: Hilmar X Date: Fri, 4 Sep 2020 14:54:33 +0200 Subject: [PATCH 7/7] reformated mutliUnprovide --- contracts/connectors/gelato.sol | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/contracts/connectors/gelato.sol b/contracts/connectors/gelato.sol index 25911f5..df1099d 100644 --- a/contracts/connectors/gelato.sol +++ b/contracts/connectors/gelato.sol @@ -356,15 +356,13 @@ contract GelatoResolver is GelatoHelpers { { uint256 withdrawAmount = getUint(_getId, _withdrawAmount); uint256 balanceBefore = address(this).balance; - uint256 actualWithdrawAmount; IGelatoInterface(getGelatoCoreAddr()).multiUnprovide( withdrawAmount, _taskSpecs, _modules ); - - actualWithdrawAmount = sub(address(this).balance, balanceBefore); - setUint(_setId, actualWithdrawAmount); + uint256 actualWithdrawAmount = sub(address(this).balance, balanceBefore); + setUint(_setId, actualWithdrawAmount); emit LogMultiUnprovide(_taskSpecs, _modules, actualWithdrawAmount, _getId, _setId); bytes32 _eventCode = keccak256(