Skip to content

Commit

Permalink
Merge pull request #19 from Uniswap/clean-up-claim-processor
Browse files Browse the repository at this point in the history
Clean up claim processor
  • Loading branch information
0age authored Nov 3, 2024
2 parents da60e21 + 2a6e883 commit 2b18148
Show file tree
Hide file tree
Showing 9 changed files with 1,007 additions and 662 deletions.
38 changes: 19 additions & 19 deletions snapshots/TheCompactTest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"basicTransfer": "56850",
"basicWithdrawal": "59816",
"batchClaim": "111783",
"batchClaimRegisteredWithDeposit": "111783",
"batchClaimRegisteredWithDepositWithWitness": "112651",
"batchClaimWithWitness": "112645",
"batchClaim": "111810",
"batchClaimRegisteredWithDeposit": "111810",
"batchClaimRegisteredWithDepositWithWitness": "112675",
"batchClaimWithWitness": "112669",
"batchDepositAndRegisterViaPermit2": "221877",
"batchDepositAndRegisterWithWitnessViaPermit2": "221855",
"batchTransfer": "81520",
"batchWithdrawal": "99951",
"claim": "56784",
"claimAndWithdraw": "73083",
"claimWithWitness": "59432",
"claim": "56817",
"claimAndWithdraw": "73116",
"claimWithWitness": "59462",
"depositAndRegisterViaPermit2": "124247",
"depositBatchSingleERC20": "67868",
"depositBatchSingleNative": "28171",
Expand All @@ -22,21 +22,21 @@
"depositERC20ViaPermit2AndURI": "98289",
"depositETHAndURI": "26754",
"depositETHBasic": "28391",
"qualifiedBatchClaim": "113318",
"qualifiedBatchClaimWithWitness": "112858",
"qualifiedClaim": "60196",
"qualifiedClaimWithWitness": "58885",
"qualifiedSplitBatchClaim": "140892",
"qualifiedSplitBatchClaimWithWitness": "140960",
"qualifiedSplitClaim": "86521",
"qualifiedSplitClaimWithWitness": "86998",
"qualifiedBatchClaim": "113348",
"qualifiedBatchClaimWithWitness": "112885",
"qualifiedClaim": "60238",
"qualifiedClaimWithWitness": "58927",
"qualifiedSplitBatchClaim": "140922",
"qualifiedSplitBatchClaimWithWitness": "140987",
"qualifiedSplitClaim": "86554",
"qualifiedSplitClaimWithWitness": "87031",
"register": "25379",
"splitBatchClaim": "140237",
"splitBatchClaimWithWitness": "140307",
"splitBatchClaim": "140264",
"splitBatchClaimWithWitness": "140331",
"splitBatchTransfer": "110587",
"splitBatchWithdrawal": "139819",
"splitClaim": "86242",
"splitClaimWithWitness": "85906",
"splitClaim": "86275",
"splitClaimWithWitness": "85936",
"splitTransfer": "82732",
"splitWithdrawal": "93702"
}
709 changes: 665 additions & 44 deletions src/lib/ClaimProcessorLib.sol

Large diffs are not rendered by default.

665 changes: 113 additions & 552 deletions src/lib/ClaimProcessorLogic.sol

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions src/lib/EventLib.sol
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)
}
}
}
Loading

0 comments on commit 2b18148

Please sign in to comment.