Skip to main content

IV3FeeAdapter

Git Source

Functions

TOKEN_JAR

function TOKEN_JAR() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address where collected fees are sent.

FACTORY

function FACTORY() external view returns (IUniswapV3Factory);

Returns

NameTypeDescription
<none>IUniswapV3FactoryThe Uniswap V3 Factory contract.

merkleRoot

function merkleRoot() external view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32The current merkle root used to designate which pools have a fee enabled

feeSetter

function feeSetter() external view returns (address);

Returns

NameTypeDescription
<none>addressThe authorized address to set fees-by-fee-tier AND the merkle root

feeTiers

function feeTiers(uint256 i) external view returns (uint24);

Returns

NameTypeDescription
<none>uint24The fee tiers enabled on the factory

storeFeeTier

Stores a fee tier.

Must be a fee tier that exists on the Uniswap V3 Factory.

function storeFeeTier(uint24 feeTier) external;

Parameters

NameTypeDescription
feeTieruint24The fee tier to store.

defaultFees

Returns the default fee value for a given fee tier.

function defaultFees(uint24 feeTier) external view returns (uint8 defaultFeeValue);

Parameters

NameTypeDescription
feeTieruint24The fee tier to query.

Returns

NameTypeDescription
defaultFeeValueuint8The default fee value expressed as the denominator on the inclusive interval [4, 10]. The fee value is packed (token1Fee << 4 | token0Fee)

enableFeeAmount

Enables a new fee tier on the Uniswap V3 Factory.

Only callable by owner. Also updates the feeTiers array.

function enableFeeAmount(uint24 newFeeTier, int24 tickSpacing) external;

Parameters

NameTypeDescription
newFeeTieruint24The fee tier to enable.
tickSpacingint24The corresponding tick spacing for the new fee tier.

setFactoryOwner

Sets the owner of the Uniswap V3 Factory.

Only callable by owner

function setFactoryOwner(address newOwner) external;

Parameters

NameTypeDescription
newOwneraddressThe new owner of the Uniswap V3 Factory.

collect

Collects protocol fees from the specified pools to the designated TOKEN_JAR

function collect(CollectParams[] calldata collectParams)
external
returns (Collected[] memory amountsCollected);

Parameters

NameTypeDescription
collectParamsCollectParams[]Array of collection parameters for each pool.

Returns

NameTypeDescription
amountsCollectedCollected[]Array of collected amounts for each pool.

setMerkleRoot

Sets the merkle root used for designating which pools have the fee enabled.

Only callable by feeSetter

function setMerkleRoot(bytes32 _merkleRoot) external;

Parameters

NameTypeDescription
_merkleRootbytes32The new merkle root to set.

setDefaultFeeByFeeTier

Sets the default fee value for a specific fee tier.

function setDefaultFeeByFeeTier(uint24 feeTier, uint8 defaultFeeValue) external;

Parameters

NameTypeDescription
feeTieruint24The fee tier, expressed in pips, to set the default fee for.
defaultFeeValueuint8The default fee value to set, expressed as the denominator on the inclusive interval [4, 10]. The fee value is packed (token1Fee << 4 | token0Fee)

triggerFeeUpdate

Triggers a fee update for a single pool with merkle proof verification.

function triggerFeeUpdate(address pool, bytes32[] calldata merkleProof) external;

Parameters

NameTypeDescription
pooladdressThe pool address to update the fee for.
merkleProofbytes32[]The merkle proof corresponding to the set merkle root.

triggerFeeUpdate

Triggers a fee update for one pair of tokens with merkle proof verification. There may be multiple pools initialized from the given pair.

Assumes that token0 < token1.

function triggerFeeUpdate(address token0, address token1, bytes32[] calldata proof) external;

Parameters

NameTypeDescription
token0addressThe first token of the pair.
token1addressThe second token of the pair.
proofbytes32[]The merkle proof corresponding to the set merkle root.

batchTriggerFeeUpdate

Triggers fee updates for multiple pairs of tokens with batch merkle proof verification.

Assumes that token0 < token1 in the token pair.

function batchTriggerFeeUpdate(
Pair[] calldata pairs,
bytes32[] calldata proof,
bool[] calldata proofFlags
) external;

Parameters

NameTypeDescription
pairsPair[]The pair of two tokens. There may be multiple pools initialized from the same pair.
proofbytes32[]The merkle proof corresponding to the set merkle root.
proofFlagsbool[]The flags for the merkle proof verification.

setFeeSetter

Sets a new fee setter address.

function setFeeSetter(address newFeeSetter) external;

Parameters

NameTypeDescription
newFeeSetteraddressThe new address authorized to set fees and merkle roots.

Errors

InvalidProof

Thrown when the merkle proof is invalid.

error InvalidProof();

InvalidFeeTier

Thrown when trying to set a default fee for a non-enabled fee tier.

error InvalidFeeTier();

Unauthorized

Thrown when an unauthorized address attempts to call a restricted function

error Unauthorized();

TierAlreadyStored

Thrown when trying to store a fee tier that is already stored.

error TierAlreadyStored();

Structs

CollectParams

The input parameters for the collection.

struct CollectParams {
/// @param pool The pool to collect fees from.
address pool;
/// @param amount0Requested The amount of token0 to collect. If this is higher than the total
/// collectable amount, it will collect all but 1 wei of the total token0 allotment.
uint128 amount0Requested;
/// @param amount1Requested The amount of token1 to collect. If this is higher than the total
/// collectable amount, it will collect all but 1 wei of the total token1 allotment.
uint128 amount1Requested;
}

Collected

The returned amounts of token0 and token1 that are collected.

struct Collected {
/// @param amount0Collected The amount of token0 that is collected.
uint128 amount0Collected;
/// @param amount1Collected The amount of token1 that is collected.
uint128 amount1Collected;
}

Pair

The pair of tokens to trigger fees for. Each node in the merkle tree is the sorted pair. If one pair in the merkle tree is (USDC, USDT), all pools consisting of those tokens will be allowed to have a fee enabled.

struct Pair {
/// @param token0 The first token of the pair.
address token0;
/// @param token1 The second token of the pair.
address token1;
}