@@ -3,7 +3,9 @@ pragma solidity >=0.8.18;
3
3
import {IERC20 } from "@oz/token/ERC20/IERC20.sol " ;
4
4
5
5
import {IRegistry} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IRegistry.sol " ;
6
+ import {IOutbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol " ;
6
7
import {DataStructures} from "@aztec/l1-contracts/src/core/libraries/DataStructures.sol " ;
8
+ import {DataStructures as PortalDataStructures} from "./DataStructures.sol " ;
7
9
import {Hash} from "@aztec/l1-contracts/src/core/libraries/Hash.sol " ;
8
10
9
11
import {TokenPortal} from "./TokenPortal.sol " ;
@@ -48,7 +50,7 @@ contract UniswapPortal {
48
50
* @param _aztecRecipient - The aztec address to receive the output assets
49
51
* @param _secretHashForL1ToL2Message - The hash of the secret consumable message. The hash should be 254 bits (so it can fit in a Field element)
50
52
* @param _withCaller - When true, using `msg.sender` as the caller, otherwise address(0)
51
- * @return The entryKey of the deposit transaction in the Inbox
53
+ * @return A hash of the L1 to L2 message inserted in the Inbox
52
54
*/
53
55
function swapPublic (
54
56
address _inputTokenPortal ,
@@ -58,15 +60,27 @@ contract UniswapPortal {
58
60
uint256 _amountOutMinimum ,
59
61
bytes32 _aztecRecipient ,
60
62
bytes32 _secretHashForL1ToL2Message ,
61
- bool _withCaller
63
+ bool _withCaller ,
64
+ // Avoiding stack too deep
65
+ PortalDataStructures.OutboxMessageMetadata[2 ] calldata _outboxMessageMetadata
62
66
) public returns (bytes32 ) {
63
67
LocalSwapVars memory vars;
64
68
65
69
vars.inputAsset = TokenPortal (_inputTokenPortal).underlying ();
66
70
vars.outputAsset = TokenPortal (_outputTokenPortal).underlying ();
67
71
68
72
// Withdraw the input asset from the portal
69
- TokenPortal (_inputTokenPortal).withdraw (address (this ), _inAmount, true );
73
+ {
74
+ TokenPortal (_inputTokenPortal).withdraw (
75
+ address (this ),
76
+ _inAmount,
77
+ true ,
78
+ _outboxMessageMetadata[0 ]._l2BlockNumber,
79
+ _outboxMessageMetadata[0 ]._leafIndex,
80
+ _outboxMessageMetadata[0 ]._path
81
+ );
82
+ }
83
+
70
84
{
71
85
// prevent stack too deep errors
72
86
vars.contentHash = Hash.sha256ToField (
@@ -85,13 +99,20 @@ contract UniswapPortal {
85
99
}
86
100
87
101
// Consume the message from the outbox
88
- registry.getOutbox ().consume (
89
- DataStructures.L2ToL1Msg ({
90
- sender: DataStructures.L2Actor (l2UniswapAddress, 1 ),
91
- recipient: DataStructures.L1Actor (address (this ), block .chainid ),
92
- content: vars.contentHash
93
- })
94
- );
102
+ {
103
+ IOutbox outbox = registry.getOutbox ();
104
+
105
+ outbox.consume (
106
+ DataStructures.L2ToL1Msg ({
107
+ sender: DataStructures.L2Actor (l2UniswapAddress, 1 ),
108
+ recipient: DataStructures.L1Actor (address (this ), block .chainid ),
109
+ content: vars.contentHash
110
+ }),
111
+ _outboxMessageMetadata[1 ]._l2BlockNumber,
112
+ _outboxMessageMetadata[1 ]._leafIndex,
113
+ _outboxMessageMetadata[1 ]._path
114
+ );
115
+ }
95
116
96
117
// Perform the swap
97
118
ISwapRouter.ExactInputSingleParams memory swapParams;
@@ -134,7 +155,7 @@ contract UniswapPortal {
134
155
* @param _secretHashForRedeemingMintedNotes - The hash of the secret to redeem minted notes privately on Aztec. The hash should be 254 bits (so it can fit in a Field element)
135
156
* @param _secretHashForL1ToL2Message - The hash of the secret consumable message. The hash should be 254 bits (so it can fit in a Field element)
136
157
* @param _withCaller - When true, using `msg.sender` as the caller, otherwise address(0)
137
- * @return The entryKey of the deposit transaction in the Inbox
158
+ * @return A hash of the L1 to L2 message inserted in the Inbox
138
159
*/
139
160
function swapPrivate (
140
161
address _inputTokenPortal ,
@@ -144,15 +165,26 @@ contract UniswapPortal {
144
165
uint256 _amountOutMinimum ,
145
166
bytes32 _secretHashForRedeemingMintedNotes ,
146
167
bytes32 _secretHashForL1ToL2Message ,
147
- bool _withCaller
168
+ bool _withCaller ,
169
+ // Avoiding stack too deep
170
+ PortalDataStructures.OutboxMessageMetadata[2 ] calldata _outboxMessageMetadata
148
171
) public returns (bytes32 ) {
149
172
LocalSwapVars memory vars;
150
173
151
174
vars.inputAsset = TokenPortal (_inputTokenPortal).underlying ();
152
175
vars.outputAsset = TokenPortal (_outputTokenPortal).underlying ();
153
176
154
- // Withdraw the input asset from the portal
155
- TokenPortal (_inputTokenPortal).withdraw (address (this ), _inAmount, true );
177
+ {
178
+ TokenPortal (_inputTokenPortal).withdraw (
179
+ address (this ),
180
+ _inAmount,
181
+ true ,
182
+ _outboxMessageMetadata[0 ]._l2BlockNumber,
183
+ _outboxMessageMetadata[0 ]._leafIndex,
184
+ _outboxMessageMetadata[0 ]._path
185
+ );
186
+ }
187
+
156
188
{
157
189
// prevent stack too deep errors
158
190
vars.contentHash = Hash.sha256ToField (
@@ -171,13 +203,20 @@ contract UniswapPortal {
171
203
}
172
204
173
205
// Consume the message from the outbox
174
- registry.getOutbox ().consume (
175
- DataStructures.L2ToL1Msg ({
176
- sender: DataStructures.L2Actor (l2UniswapAddress, 1 ),
177
- recipient: DataStructures.L1Actor (address (this ), block .chainid ),
178
- content: vars.contentHash
179
- })
180
- );
206
+ {
207
+ IOutbox outbox = registry.getOutbox ();
208
+
209
+ outbox.consume (
210
+ DataStructures.L2ToL1Msg ({
211
+ sender: DataStructures.L2Actor (l2UniswapAddress, 1 ),
212
+ recipient: DataStructures.L1Actor (address (this ), block .chainid ),
213
+ content: vars.contentHash
214
+ }),
215
+ _outboxMessageMetadata[1 ]._l2BlockNumber,
216
+ _outboxMessageMetadata[1 ]._leafIndex,
217
+ _outboxMessageMetadata[1 ]._path
218
+ );
219
+ }
181
220
182
221
// Perform the swap
183
222
ISwapRouter.ExactInputSingleParams memory swapParams;
0 commit comments