Multi-signature approval to Uniswap V4 swaps. This means that before a swap can occur, a predefined number of authorized signers need to approve it. The contract can be configured with a list of authorized signers and a requirement for how many of those signers need to approve a given swap.
Please follow these steps, if you all ready have Foundry setup ignore steps 1 and 2
Step 1: Install Rust https://doc.rust-lang.org/book/ch01-01-installation.html
Step 2: Install Foundry https://book.getfoundry.sh/getting-started/installation#using-foundryup
Step 3: Build
Please run the command below to build your contracts
forge build
If you get a stack to deep error try running the command below
forge build --via-ir
Step 4: Test
Please run the command below to test your contracts, the given tests are examples please generate your own.
forge test
-
BaseHook Integration: Inherits from the
BaseHook
contract to interface with the Uniswap V4 core functionality. -
Multi-Signature Approval: Before a swap can be executed, it requires approval from a set number of authorized signers.
-
Swap Approval Management: Offers functions to approve, check approval status, and complete a swap after all required approvals are received.
-
Signer Management: The contract owner can add or remove authorized signers.
- approveSwap: Allows an authorized signer to approve a swap.
- addSigner: Allows the owner to add a new authorized signer.
- removeSigner: Allows the owner to remove an authorized signer.
- setRequiredSignatures: Allows the owner to modify the number of required approvals for a swap.
- getApprovalDetails: Returns the number of approvals a swap has received and whether the caller has approved it.
- beforeSwap: Checks if the swap has the required approvals before execution.
- afterSwap: Cleans up after a swap is executed.
- ApprovalAdded: Emitted when a signer approves a swap.
- SwapCompleted: Emitted after a swap with the required approvals is executed.
When the contract is deployed, it requires:
- _poolManager: A reference to the Uniswap V4 Pool Manager.
- _signers: An array of initial authorized signers.
- _requiredSignatures: The number of approvals required to execute a swap.
- onlyOwner: Ensures that only the contract owner can execute the function.
The contract imports and interacts with various other contracts, such as:
- Uniswap V4 Core: For core functionalities related to pools.
- Initialization: The contract is initialized with a list of authorized signers and a set number of required approvals.
- Swap Execution: Before a swap is executed, it requires approval from a set number of authorized signers. Each signer can call
approveSwap
to approve a swap. - Signer Management: The contract owner can add or remove signers as needed.