@@ -3,7 +3,6 @@ pragma solidity 0.8.17;
33
44import {IGelatoRelay} from "./interfaces/IGelatoRelay.sol " ;
55import {IGelato1Balance} from "./interfaces/IGelato1Balance.sol " ;
6- import {GelatoRelayBase} from "./abstract/GelatoRelayBase.sol " ;
76import {GelatoCallUtils} from "./lib/GelatoCallUtils.sol " ;
87import {GelatoTokenUtils} from "./lib/GelatoTokenUtils.sol " ;
98import {SponsoredCall} from "./types/CallTypes.sol " ;
@@ -27,17 +26,20 @@ import {_deprecatedRelayContext} from "./functions/DeprecatedUtils.sol";
2726/// @dev This contract must NEVER hold funds!
2827/// @dev Maliciously crafted transaction payloads could wipe out any funds left here
2928// solhint-disable-next-line max-states-count
30- contract GelatoRelay is IGelatoRelay , IGelato1Balance , GelatoRelayBase {
29+ contract GelatoRelay is IGelatoRelay , IGelato1Balance {
3130 using GelatoCallUtils for address ;
3231 using GelatoTokenUtils for address ;
3332
34- //solhint-disable-next-line const-name-snakecase
35- string public constant name = "GelatoRelay " ;
36- //solhint-disable-next-line const-name-snakecase
37- string public constant version = "2 " ;
33+ address public immutable gelato;
3834
39- // solhint-disable-next-line no-empty-blocks
40- constructor (address _gelato ) GelatoRelayBase (_gelato) {}
35+ modifier onlyGelato () {
36+ require (msg .sender == gelato, "Only callable by gelato " );
37+ _;
38+ }
39+
40+ constructor (address _gelato ) {
41+ gelato = _gelato;
42+ }
4143
4244 /// @dev Previous version kept for backward compatibility
4345 function callWithSyncFee (
@@ -58,7 +60,7 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
5860
5961 uint256 fee = postBalance - preBalance;
6062
61- _feeToken.transfer (msg .sender , fee);
63+ if (fee != 0 ) _feeToken.transfer (msg .sender , fee);
6264
6365 emit LogCallWithSyncFee (_target, _feeToken, _fee, _taskId);
6466 }
@@ -77,9 +79,11 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
7779 bytes32 _correlationId
7880 ) external onlyGelato {
7981 address feeToken;
82+ address feeCollector;
8083 uint256 preBalance;
8184
8285 if (_isRelayContext) {
86+ feeCollector = _getFeeCollectorRelayContext ();
8387 feeToken = _getFeeTokenRelayContext ();
8488 preBalance = feeToken.getBalance (address (this ));
8589 }
@@ -88,7 +92,7 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
8892 ? _target.revertingContractCall (
8993 _encodeRelayContext (
9094 _data,
91- _getFeeCollectorRelayContext () ,
95+ feeCollector ,
9296 feeToken,
9397 _getFeeRelayContext ()
9498 ),
@@ -101,14 +105,13 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
101105
102106 if (_isRelayContext) {
103107 uint256 fee = feeToken.getBalance (address (this )) - preBalance;
104- if (fee != 0 ) feeToken.transfer (msg . sender , fee);
108+ if (fee != 0 ) feeToken.transfer (feeCollector , fee);
105109 }
106110
107111 emit LogCallWithSyncFeeV2 (_target, _correlationId);
108112 }
109113
110114 /// @notice Relay call + One Balance payment - with sponsor authentication
111- /// @notice Sponsor signature allows for payment via sponsor's 1Balance balance
112115 /// @dev Payment is handled with off-chain accounting using Gelato's 1Balance system
113116 /// @param _call Relay call data packed into SponsoredCall struct
114117 /// @notice Oracle value for exchange rate between native tokens and fee token
@@ -126,7 +129,10 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
126129 bytes32 _correlationId
127130 ) external onlyGelato {
128131 // CHECKS
129- _requireChainId (_call.chainId, "GelatoRelay.sponsoredCall: " );
132+ require (
133+ _call.chainId == block .chainid ,
134+ "GelatoRelay.sponsoredCall:chainid "
135+ );
130136
131137 // INTERACTIONS
132138 _call.target.revertingContractCall (
@@ -144,27 +150,4 @@ contract GelatoRelay is IGelatoRelay, IGelato1Balance, GelatoRelayBase {
144150 _correlationId
145151 );
146152 }
147-
148- //solhint-disable-next-line func-name-mixedcase
149- function DOMAIN_SEPARATOR () external view returns (bytes32 ) {
150- return _getDomainSeparator ();
151- }
152-
153- function _getDomainSeparator () internal view returns (bytes32 ) {
154- return
155- keccak256 (
156- abi.encode (
157- keccak256 (
158- bytes (
159- //solhint-disable-next-line max-line-length
160- "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract) "
161- )
162- ),
163- keccak256 (bytes (name)),
164- keccak256 (bytes (version)),
165- block .chainid ,
166- address (this )
167- )
168- );
169- }
170153}
0 commit comments