Skip to content

Commit

Permalink
Merge pull request #9 from Uniswap/more-splitting
Browse files Browse the repository at this point in the history
break into ClaimProcessorLogic and slip in extsload
  • Loading branch information
0age authored Oct 30, 2024
2 parents 5858e16 + 58fdf35 commit 1c6f627
Show file tree
Hide file tree
Showing 7 changed files with 990 additions and 1,013 deletions.
76 changes: 38 additions & 38 deletions snapshots/TheCompactTest.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"basicTransfer": "56817",
"basicWithdrawal": "59797",
"batchClaim": "111809",
"batchClaimRegisteredWithDeposit": "111809",
"batchClaimRegisteredWithDepositWithWitness": "112571",
"batchClaimWithWitness": "112565",
"batchDepositAndRegisterViaPermit2": "221878",
"batchDepositAndRegisterWithWitnessViaPermit2": "221856",
"batchTransfer": "81517",
"batchWithdrawal": "99932",
"claim": "56956",
"claimAndWithdraw": "73247",
"claimWithWitness": "59421",
"depositAndRegisterViaPermit2": "124248",
"depositBatchSingleERC20": "67846",
"depositBatchSingleNative": "28149",
"depositBatchViaPermit2NativeAndERC20": "129570",
"depositBatchViaPermit2SingleERC20": "104724",
"depositERC20AndURI": "67095",
"depositERC20Basic": "67124",
"basicTransfer": "56861",
"basicWithdrawal": "59819",
"batchClaim": "111831",
"batchClaimRegisteredWithDeposit": "111831",
"batchClaimRegisteredWithDepositWithWitness": "112593",
"batchClaimWithWitness": "112587",
"batchDepositAndRegisterViaPermit2": "221900",
"batchDepositAndRegisterWithWitnessViaPermit2": "221878",
"batchTransfer": "81539",
"batchWithdrawal": "99954",
"claim": "56978",
"claimAndWithdraw": "73269",
"claimWithWitness": "59443",
"depositAndRegisterViaPermit2": "124270",
"depositBatchSingleERC20": "67868",
"depositBatchSingleNative": "28171",
"depositBatchViaPermit2NativeAndERC20": "129592",
"depositBatchViaPermit2SingleERC20": "104746",
"depositERC20AndURI": "67117",
"depositERC20Basic": "67146",
"depositERC20ViaPermit2AndURI": "98312",
"depositETHAndURI": "26755",
"depositETHBasic": "28318",
"qualifiedBatchClaim": "113227",
"qualifiedBatchClaimWithWitness": "112691",
"qualifiedClaim": "60215",
"depositETHAndURI": "26777",
"depositETHBasic": "28384",
"qualifiedBatchClaim": "113249",
"qualifiedBatchClaimWithWitness": "112713",
"qualifiedClaim": "60237",
"qualifiedClaimWithWitness": "58777",
"qualifiedSplitBatchClaim": "140893",
"qualifiedSplitBatchClaimWithWitness": "140885",
"qualifiedSplitClaim": "86502",
"qualifiedSplitClaimWithWitness": "86846",
"register": "25357",
"splitBatchClaim": "140377",
"splitBatchClaimWithWitness": "140341",
"splitBatchTransfer": "110592",
"splitBatchWithdrawal": "139800",
"splitClaim": "86425",
"splitClaimWithWitness": "85906",
"splitTransfer": "82729",
"splitWithdrawal": "93639"
"qualifiedSplitBatchClaim": "140937",
"qualifiedSplitBatchClaimWithWitness": "140929",
"qualifiedSplitClaim": "86524",
"qualifiedSplitClaimWithWitness": "86890",
"register": "25379",
"splitBatchClaim": "140399",
"splitBatchClaimWithWitness": "140363",
"splitBatchTransfer": "110614",
"splitBatchWithdrawal": "139822",
"splitClaim": "86447",
"splitClaimWithWitness": "85928",
"splitTransfer": "82751",
"splitWithdrawal": "93705"
}
40 changes: 14 additions & 26 deletions src/TheCompact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,25 @@ pragma solidity ^0.8.27;

import { ITheCompact } from "./interfaces/ITheCompact.sol";
import { ITheCompactClaims } from "./interfaces/ITheCompactClaims.sol";

import { BatchTransfer, SplitBatchTransfer } from "./types/BatchClaims.sol";
import { BasicTransfer, SplitTransfer } from "./types/Claims.sol";
import { CompactCategory } from "./types/CompactCategory.sol";
import { Lock } from "./types/Lock.sol";
import { Scope } from "./types/Scope.sol";
import { ResetPeriod } from "./types/ResetPeriod.sol";
import { ForcedWithdrawalStatus } from "./types/ForcedWithdrawalStatus.sol";

import { ClaimProcessor } from "./lib/ClaimProcessor.sol";
import { ConsumerLib } from "./lib/ConsumerLib.sol";
import { IdLib } from "./lib/IdLib.sol";
import { EfficiencyLib } from "./lib/EfficiencyLib.sol";
import { Extsload } from "./lib/Extsload.sol";
import { HashLib } from "./lib/HashLib.sol";
import { IdLib } from "./lib/IdLib.sol";
import { ValidityLib } from "./lib/ValidityLib.sol";
import { Extsload } from "./lib/Extsload.sol";

import { ERC6909 } from "solady/tokens/ERC6909.sol";
import { FixedPointMathLib } from "solady/utils/FixedPointMathLib.sol";
import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";
import { IPermit2 } from "permit2/src/interfaces/IPermit2.sol";
import { Tstorish } from "tstorish/Tstorish.sol";
import { ISignatureTransfer } from "permit2/src/interfaces/ISignatureTransfer.sol";
import { BasicTransfer, SplitTransfer } from "./types/Claims.sol";

import { BatchTransfer, SplitBatchTransfer } from "./types/BatchClaims.sol";

import { COMPACT_TYPEHASH } from "./types/EIP712Types.sol";

import { SplitComponent, TransferComponent, SplitByIdComponent, BatchClaimComponent, SplitBatchClaimComponent } from "./types/Components.sol";

import { IAllocator } from "./interfaces/IAllocator.sol";
import { MetadataRenderer } from "./lib/MetadataRenderer.sol";

import { ClaimProcessor } from "./lib/ClaimProcessor.sol";

/**
* @title The Compact
Expand All @@ -41,7 +31,7 @@ import { ClaimProcessor } from "./lib/ClaimProcessor.sol";
* formation (and, if necessary, involuntary dissolution) of "resource locks."
* This contract has not yet been properly tested, audited, or reviewed.
*/
contract TheCompact is ITheCompact, ClaimProcessor, ERC6909 {
contract TheCompact is ITheCompact, ClaimProcessor, ERC6909, Extsload {
using HashLib for address;
using HashLib for bytes32;
using HashLib for uint256;
Expand All @@ -55,8 +45,6 @@ contract TheCompact is ITheCompact, ClaimProcessor, ERC6909 {
using IdLib for Lock;
using IdLib for ResetPeriod;
using IdLib for CompactCategory;
using SafeTransferLib for address;
using FixedPointMathLib for uint256;
using ConsumerLib for uint256;
using EfficiencyLib for bool;
using EfficiencyLib for uint256;
Expand Down Expand Up @@ -190,11 +178,9 @@ contract TheCompact is ITheCompact, ClaimProcessor, ERC6909 {
Scope, //scope
address recipient,
bytes calldata signature
) external payable returns (uint256[] memory ids) {
uint256 totalTokensLessInitialNative;
bool firstUnderlyingTokenIsNative;
uint256[] memory initialTokenBalances;
(totalTokensLessInitialNative, firstUnderlyingTokenIsNative, ids, initialTokenBalances) = _preprocessAndPerformInitialNativeDeposit(permitted, recipient);
) external payable returns (uint256[] memory) {
(uint256 totalTokensLessInitialNative, bool firstUnderlyingTokenIsNative, uint256[] memory ids, uint256[] memory initialTokenBalances) =
_preprocessAndPerformInitialNativeDeposit(permitted, recipient);

bytes32 witness = _deriveCompactDepositWitnessHash(uint256(0x84).asStubborn());

Expand All @@ -213,6 +199,8 @@ contract TheCompact is ITheCompact, ClaimProcessor, ERC6909 {
_writeSignatureAndPerformPermit2Call(m, uint256(0xc0).asStubborn(), signatureOffsetValue, signature);

_verifyBalancesAndPerformDeposits(ids, permitted, initialTokenBalances, recipient, firstUnderlyingTokenIsNative);

return ids;
}

function depositAndRegister(
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ClaimProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.27;

import { ITheCompactClaims } from "../interfaces/ITheCompactClaims.sol";
import { InternalLogic } from "./InternalLogic.sol";
import { ClaimProcessorLogic } from "./ClaimProcessorLogic.sol";

import { BasicClaim, QualifiedClaim, ClaimWithWitness, QualifiedClaimWithWitness, SplitClaim, SplitClaimWithWitness, QualifiedSplitClaim, QualifiedSplitClaimWithWitness } from "../types/Claims.sol";

Expand Down Expand Up @@ -55,7 +55,7 @@ import {
ExogenousQualifiedSplitBatchMultichainClaimWithWitness
} from "../types/BatchMultichainClaims.sol";

contract ClaimProcessor is ITheCompactClaims, InternalLogic {
contract ClaimProcessor is ITheCompactClaims, ClaimProcessorLogic {
function claim(BasicClaim calldata claimPayload) external returns (bool) {
return _processBasicClaim(claimPayload, _release);
}
Expand Down
Loading

0 comments on commit 1c6f627

Please sign in to comment.