-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Uniswap/clean-up-claim-processor
Clean up claim processor
- Loading branch information
Showing
9 changed files
with
1,007 additions
and
662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.27; | ||
|
||
/** | ||
* @title EventLib | ||
* @notice Library contract implementing logic for internal functions to | ||
* emit various events. | ||
* @dev Note that most events are still emitted using inline logic; this | ||
* library only implements a few events. | ||
*/ | ||
library EventLib { | ||
// keccak256(bytes("Claim(address,address,address,bytes32)")). | ||
uint256 private constant _CLAIM_EVENT_SIGNATURE = 0x770c32a2314b700d6239ee35ba23a9690f2fceb93a55d8c753e953059b3b18d4; | ||
|
||
// keccak256(bytes("ForcedWithdrawalStatusUpdated(address,uint256,bool,uint256)")). | ||
uint256 private constant _FORCED_WITHDRAWAL_STATUS_UPDATED_SIGNATURE = 0xe27f5e0382cf5347965fc81d5c81cd141897fe9ce402d22c496b7c2ddc84e5fd; | ||
|
||
/** | ||
* @notice Internal function for emitting claim events. The sponsor and allocator | ||
* addresses are sanitized before emission. | ||
* @param sponsor The account sponsoring the compact that the claim is for. | ||
* @param messageHash The EIP-712 hash of the claim message. | ||
* @param allocator The account mediating the claim. | ||
*/ | ||
function emitClaim(address sponsor, bytes32 messageHash, address allocator) internal { | ||
assembly ("memory-safe") { | ||
// Emit the Claim event: | ||
// - topic1: Claim event signature | ||
// - topic2: sponsor address (sanitized) | ||
// - topic3: allocator address (sanitized) | ||
// - topic4: caller address | ||
// - data: messageHash | ||
mstore(0, messageHash) | ||
log4(0, 0x20, _CLAIM_EVENT_SIGNATURE, shr(0x60, shl(0x60, sponsor)), shr(0x60, shl(0x60, allocator)), caller()) | ||
} | ||
} | ||
|
||
/** | ||
* @notice Internal function for emitting forced withdrawal status update events. | ||
* @param id The ERC6909 token identifier of the resource lock. | ||
* @param withdrawableAt The timestamp when withdrawal becomes possible. | ||
*/ | ||
function emitForcedWithdrawalStatusUpdatedEvent(uint256 id, uint256 withdrawableAt) internal { | ||
assembly ("memory-safe") { | ||
// Emit ForcedWithdrawalStatusUpdated event: | ||
// - topic1: Event signature | ||
// - topic2: Caller address | ||
// - topic3: Token id | ||
// - data: [activating flag, withdrawableAt timestamp] | ||
mstore(0, iszero(iszero(withdrawableAt))) | ||
mstore(0x20, withdrawableAt) | ||
log3(0, 0x40, _FORCED_WITHDRAWAL_STATUS_UPDATED_SIGNATURE, caller(), id) | ||
} | ||
} | ||
} |
Oops, something went wrong.