Skip to content

Commit f67b64c

Browse files
pxrlnicholaspaimrice32
authored
feat: M01 Deadline Buffer for Fills Is Not Always Respected (#440)
Add explicit handling for non-expiring v3 deposits that are made via the backwards-compatible deposit() function. Authored by Nick. Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> Co-authored-by: Matt Rice <matthewcrice32@gmail.com>
1 parent afb05ba commit f67b64c

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

contracts/SpokePool.sol

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ abstract contract SpokePool is
160160
keccak256(
161161
"UpdateDepositDetails(uint32 depositId,uint256 originChainId,uint256 updatedOutputAmount,address updatedRecipient,bytes updatedMessage)"
162162
);
163+
164+
// This is the magic value that signals to the off-chain validator
165+
// that this deposit can never expire. A deposit with this fill deadline should always be eligible for a
166+
// slow fill, meaning that its output token and input token must be "equivalent". Therefore, this value is only
167+
// used as a fillDeadline in deposit(), a soon to be deprecated function that also hardcodes outputToken to
168+
// the zero address, which forces the off-chain validator to replace the output token with the equivalent
169+
// token for the input token. By using this magic value, off-chain validators do not have to keep
170+
// this event in their lookback window when querying for expired deposts.
171+
uint32 public constant INFINITE_FILL_DEADLINE = type(uint32).max;
163172
/****************************************
164173
* EVENTS *
165174
****************************************/
@@ -469,6 +478,8 @@ abstract contract SpokePool is
469478
* @notice The originToken => destinationChainId must be enabled.
470479
* @notice This method is payable because the caller is able to deposit native token if the originToken is
471480
* wrappedNativeToken and this function will handle wrapping the native token to wrappedNativeToken.
481+
* @dev Produces a V3FundsDeposited event with an infinite expiry, meaning that this deposit can never expire.
482+
* Moreover, the event's outputToken is set to 0x0 meaning that this deposit can always be slow filled.
472483
* @param recipient Address to receive funds at on destination chain.
473484
* @param originToken Token to lock into this contract to initiate deposit.
474485
* @param amount Amount of tokens to deposit. Will be amount of tokens to receive less fees.
@@ -1393,7 +1404,9 @@ abstract contract SpokePool is
13931404

13941405
emit V3FundsDeposited(
13951406
originToken, // inputToken
1396-
address(0), // outputToken
1407+
address(0), // outputToken. Setting this to 0x0 means that the outputToken should be assumed to be the
1408+
// canonical token for the destination chain matching the inputToken. Therefore, this deposit
1409+
// can always be slow filled.
13971410
// - setting token to 0x0 will signal to off-chain validator that the "equivalent"
13981411
// token as the inputToken for the destination chain should be replaced here.
13991412
amount, // inputAmount
@@ -1404,8 +1417,10 @@ abstract contract SpokePool is
14041417
destinationChainId,
14051418
newDepositId,
14061419
quoteTimestamp,
1407-
type(uint32).max, // fillDeadline. Older deposits don't expire.
1408-
0, // exclusivityDeadline.
1420+
INFINITE_FILL_DEADLINE, // fillDeadline. Default to infinite expiry because
1421+
// expired deposits refunds could be a breaking change for existing users of this function.
1422+
0, // exclusivityDeadline. Setting this to 0 along with the exclusiveRelayer to 0x0 means that there
1423+
// is no exclusive deadline
14091424
depositor,
14101425
recipient,
14111426
address(0), // exclusiveRelayer. Setting this to 0x0 will signal to off-chain validator that there

0 commit comments

Comments
 (0)