Access Control
MethLab Whitelisted DEX
Overview
MethLab Swap adds access control logic to enable Whitelisting. MethLab Swap is a fork of Uniswap V3 AMM designed to offer control over Liquidity Providers (LPs).
Key Features
Whitelisting : Adding liquidity i.e
mint()
is restricted to Whitelisted addresses.Pool-based Whitelisting - Whitelisting is done on a per-pool basis.
Flexibility - Whitelisting can be disabled temporarily or even eliminated completely.
Default Whitelisting - All pools are Whitelisted by default to prevent unauthorized liquidity provisioning.
Fork modifications in MethLab DEX
MethLab DEX is a modified fork of Uniswap V3 AMM on Mantle which comprises of a new contract named Whitelister.sol that has been deployed in addition to the AMM smart contracts.
Purpose
Whitelister.sol is a separate smart contract which contains the logic to Whitelisting logic.
Integration with AMM
The AMM incorporates a require statement to check LP whitelisting status before allowing liquidity addition. The following require
was added in the UniswapV3Pool.sol to continue/revert as per the Whitelister.
require(IWhitelister(whitelister).isAllowed(recipient, data), '!W');
If the Whitelister returns true, the program execution would continue inside the mint()
. If the LP is not whitelisted, Whitelister would return false, and the execution halts with !W
error. The whitelister was abstracted from the core AMM logic to ensure no minimal changes to the AMM.
Transaction Flow
- LPs call the
mint()
function on the NFT Position Manager. - NFT Position Manager calls
mint()
function on the Pool contract. - Pool contract checks LP's whitelisting status with the Whitelister contract by invoking
isAllowed()
function. - Whitelister contract returns either true or false based on LP's whitelisting status.
- Based on the response, the LP's transaction proceeds or halts with an error message.
To learn more about the Whitelister contract, check this.