@@ -5,29 +5,34 @@ pragma solidity ^0.8.27;
5
5
import {IERC7683Allocator } from '../interfaces/IERC7683Allocator.sol ' ;
6
6
import {SimpleAllocator} from './SimpleAllocator.sol ' ;
7
7
import {Claim, Mandate} from './types/TribunalStructs.sol ' ;
8
+
9
+ import {IERC1271 } from '@openzeppelin/contracts/interfaces/IERC1271.sol ' ;
8
10
import {ECDSA} from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol ' ;
9
11
import {ITheCompact} from '@uniswap/the-compact/interfaces/ITheCompact.sol ' ;
10
12
import {Compact} from '@uniswap/the-compact/types/EIP712Types.sol ' ;
11
13
12
14
contract ERC7683Allocator is SimpleAllocator , IERC7683Allocator {
13
15
/// @notice The typehash of the OrderData struct
14
- // keccak256("OrderData(address arbiter,address sponsor,uint256 nonce,uint256 id,uint256 amount,Mandate mandate)
15
- // Mandate( uint256 chainId,address tribunal,address recipient,uint256 expires, address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,bytes32 salt)")
16
- bytes32 public constant ORDERDATA_TYPEHASH = 0x9e0e1bdb0df35509b65bbc49d209dd42496c5a3f13998f9a74dc842d6932656b ;
16
+ // keccak256("OrderData(address arbiter,address sponsor,uint256 nonce,uint256 id,uint256 amount,
17
+ // uint256 chainId,address tribunal,address recipient,address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,uint256[] decayCurve, bytes32 salt,uint256 targetBlock,uint256 maximumBlocksAfterTarget )")
18
+ bytes32 public constant ORDERDATA_TYPEHASH = 0x9687614112a074c792f7035dc9365f34672a3aa8d3c312500bd47ddcaa0383b5 ;
17
19
18
20
/// @notice The typehash of the OrderDataGasless struct
19
- // keccak256("OrderDataGasless(address arbiter,uint256 id,uint256 amount,Mandate mandate)
20
- // Mandate( uint256 chainId,address tribunal,address recipient,uint256 expires, address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,bytes32 salt)")
21
+ // keccak256("OrderDataGasless(address arbiter,uint256 id,uint256 amount,
22
+ // uint256 chainId,address tribunal,address recipient,address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,uint256[] decayCurve ,bytes32 salt)")
21
23
bytes32 public constant ORDERDATA_GASLESS_TYPEHASH =
22
- 0x9ab67658b7c0f35b64fdadd7adee1e58b6399a8201f38c355d3a109a2d7081d7 ;
24
+ 0xe9b624fa654c7f07ce16d31bf0165a4030d4022f62987afad8ef9d30fc8a0b88 ;
25
+
26
+ /// @notice keccak256("QualifiedClaim(bytes32 claimHash,uint256 targetBlock,uint256 maximumBlocksAfterTarget)")
27
+ bytes32 public constant QUALIFICATION_TYPEHASH = 0x59866b84bd1f6c909cf2a31efd20c59e6c902e50f2c196994e5aa85cdc7d7ce0 ;
23
28
24
29
/// @notice keccak256("Compact(address arbiter,address sponsor,uint256 nonce,uint256 expires,uint256 id,uint256 amount,Mandate mandate)
25
- // Mandate(uint256 chainId,address tribunal,address recipient,uint256 expires,address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,bytes32 salt)")
30
+ // Mandate(uint256 chainId,address tribunal,address recipient,uint256 expires,address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,uint256[] decayCurve, bytes32 salt)")
26
31
bytes32 public constant COMPACT_WITNESS_TYPEHASH =
27
- 0x27f09e0bb8ce2ae63380578af7af85055d3ada248c502e2378b85bc3d05ee0b0 ;
32
+ 0xfd9cda0e5e31a3a3476cb5b57b07e2a4d6a12815506f69c880696448cd9897a5 ;
28
33
29
- /// @notice keccak256("Mandate(uint256 chainId,address tribunal,address recipient,uint256 expires,address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,bytes32 salt)")
30
- bytes32 internal constant MANDATE_TYPEHASH = 0x52c75464356e20084ae43acac75087fbf0e0c678e7ffa326f369f37e88696036 ;
34
+ /// @notice keccak256("Mandate(uint256 chainId,address tribunal,address recipient,uint256 expires,address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,uint256[] decayCurve, bytes32 salt)")
35
+ bytes32 internal constant MANDATE_TYPEHASH = 0x74d9c10530859952346f3e046aa2981a24bb7524b8394eb45a9deddced9d6501 ;
31
36
32
37
/// @notice uint256(uint8(keccak256("ERC7683Allocator.nonce")))
33
38
uint8 internal constant NONCE_MASTER_SLOT_SEED = 0x39 ;
@@ -101,7 +106,7 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
101
106
/// @inheritdoc IERC7683Allocator
102
107
function getCompactWitnessTypeString () external pure returns (string memory ) {
103
108
return
104
- 'Compact(address arbiter,address sponsor,uint256 nonce,uint256 expires,uint256 id,uint256 amount,Mandate mandate)Mandate(uint256 chainId,address tribunal,address recipient,uint256 expires,address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,bytes32 salt)) ' ;
109
+ 'Compact(address arbiter,address sponsor,uint256 nonce,uint256 expires,uint256 id,uint256 amount,Mandate mandate)Mandate(uint256 chainId,address tribunal,address recipient,uint256 expires,address token,uint256 minimumAmount,uint256 baselinePriorityFee,uint256 scalingFactor,uint256[] decayCurve, bytes32 salt)) ' ;
105
110
}
106
111
107
112
/// @inheritdoc IERC7683Allocator
@@ -116,6 +121,12 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
116
121
return nonceFree_;
117
122
}
118
123
124
+ /// @inheritdoc IERC7683Allocator
125
+ function createFillerData (address claimant_ ) external pure returns (bytes memory fillerData ) {
126
+ fillerData = abi.encode (claimant_);
127
+ return fillerData;
128
+ }
129
+
119
130
function _open (OrderData memory orderData_ , uint32 fillDeadline_ , address sponsor_ , bytes memory sponsorSignature_ )
120
131
internal
121
132
{
@@ -151,15 +162,16 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
151
162
orderData_.minimumAmount,
152
163
orderData_.baselinePriorityFee,
153
164
orderData_.scalingFactor,
165
+ keccak256 (abi.encodePacked (orderData_.decayCurve)),
154
166
orderData_.salt
155
167
)
156
168
)
157
169
)
158
170
);
159
- bytes32 digest = keccak256 (abi.encodePacked (bytes2 (0x1901 ), _COMPACT_DOMAIN_SEPARATOR, claimHash));
160
171
161
172
// We check for the length, which means this could also be triggered by a zero length signature provided in the openFor function. This enables relaying of orders if the claim was registered on the compact.
162
173
if (sponsorSignature_.length > 0 ) {
174
+ bytes32 digest = keccak256 (abi.encodePacked (bytes2 (0x1901 ), _COMPACT_DOMAIN_SEPARATOR, claimHash));
163
175
// confirm the signature matches the digest
164
176
address signer = ECDSA.recover (digest, sponsorSignature_);
165
177
if (sponsor_ != signer) {
@@ -174,7 +186,13 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
174
186
}
175
187
}
176
188
177
- _sponsor[digest] = tokenHash;
189
+ bytes32 qualifiedClaimHash = keccak256 (
190
+ abi.encode (QUALIFICATION_TYPEHASH, claimHash, orderData_.targetBlock, orderData_.maximumBlocksAfterTarget)
191
+ );
192
+ bytes32 qualifiedDigest =
193
+ keccak256 (abi.encodePacked (bytes2 (0x1901 ), _COMPACT_DOMAIN_SEPARATOR, qualifiedClaimHash));
194
+
195
+ _sponsor[qualifiedDigest] = tokenHash;
178
196
179
197
// Emit an open event
180
198
emit Open (
@@ -200,7 +218,6 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
200
218
_claim[tokenHash_] = expires;
201
219
_amount[tokenHash_] = amount;
202
220
_nonce[tokenHash_] = nonce;
203
-
204
221
return tokenHash_;
205
222
}
206
223
@@ -220,6 +237,7 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
220
237
minimumAmount: orderData.minimumAmount,
221
238
baselinePriorityFee: orderData.baselinePriorityFee,
222
239
scalingFactor: orderData.scalingFactor,
240
+ decayCurve: orderData.decayCurve,
223
241
salt: orderData.salt
224
242
});
225
243
Claim memory claim = Claim ({
@@ -239,7 +257,7 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
239
257
fillInstructions[0 ] = FillInstruction ({
240
258
destinationChainId: orderData.chainId,
241
259
destinationSettler: _addressToBytes32 (orderData.tribunal),
242
- originData: abi.encode (claim, mandate)
260
+ originData: abi.encode (claim, mandate, orderData.targetBlock, orderData.maximumBlocksAfterTarget )
243
261
});
244
262
245
263
Output memory spent = Output ({
@@ -337,7 +355,10 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
337
355
minimumAmount: orderDataGasless_.minimumAmount,
338
356
baselinePriorityFee: orderDataGasless_.baselinePriorityFee,
339
357
scalingFactor: orderDataGasless_.scalingFactor,
340
- salt: orderDataGasless_.salt
358
+ decayCurve: orderDataGasless_.decayCurve,
359
+ salt: orderDataGasless_.salt,
360
+ targetBlock: 0 ,
361
+ maximumBlocksAfterTarget: 0
341
362
});
342
363
return orderData_;
343
364
}
0 commit comments