Skip to main content

Periphery Base Contracts

DeadlineValidation

Validate if the block timestamp has not reached the deadline yet, use for transactions with a de

Modifier: onlyNotExpired()

Reverts if the current block's timestamp is greater than the specified deadline.

FieldTypeExplanation
deadlineuint256Timestamp to check against current block's timestamp

_blockTimestamp()

Returns the current block timestamp. Used for overriding by mock contracts for tests.


ERC721Permit

Nonfungible tokens that support an approve via signature, i.e. permit for ERC721.


ImmutableRouterStorage

Immutable variables that are used by Periphery contracts.

Immutables

FieldTypeExplanation
factoryaddressFactory contract address
WETHaddressCanonical WETH address
poolInitHashbytes32keccak256 hash of the pool's creation code. Used to compute the p
without reading storage from the Factory

RouterTokenHelper

A helper contract to handle transfers, wrapping and unwrapping of tokens.

unwrapWeth()

Unwraps the contract's entire WETH balance to ETH, then transfers them to the recipient.

Input FieldTypeExplanation
minAmountuint256Contract's WETH balance should not be lower than this amount
recioientaddressDesired recipient of unwrapped ETH

transferAllTokens()

Transfers the contract's entire token balance to the recipient

Input FieldTypeExplanation
tokenaddressToken to transfer
minAmountuint256Contract's token balance should not be lower than this amount
recipientaddressDesired recipient of the token

refundEth()

Transfers all ETH balance to the sender.

_transferTokens()

Internal function to help transfer tokens from the sender to the recipient. If token is contract has enough ETH balance, then wrap and transfer WETH**, otherwise use [TokenHelper transfers.

Input FieldTypeExplanation
tokenaddressToken to transfer
senderaddressAddress to pull token funds from
recipientaddressDesired recipient of the token
amountuint256Amount to be transferred

RouterTokenHelperWithFee

Inherits RouteTokenHelper. Contains additional functions to charge a fee f well.

unwrapWethWithFee()

Unwraps the contract's entire WETH balance to ETH, then transfers them to the recipient fee which is transferred to feeRecipient`

Input FieldTypeExplanation
minAmountuint256Contract's WETH balance should not be lower than this amount
recipientaddressDesired recipient of unwrapped ETH
feeBpsuint256Fee to charge in basis points
feeRecipientaddressAddress to receive the fee charged

transferAllTokensWithFee()

Transfers the contract's entire token balance to the recipient. Charges a fee which is transfe feeRecipient.

Input FieldTypeExplanation
tokenaddressToken to transfer
minAmountuint256Contract's token balance should not be lower than this amount
recipientaddressDesired recipient of the token
feeBpsuint256Fee to charge in basis points
feeRecipientaddressAddress to receive the fee charged

Multicall

Enables calling multiple methods in a single call to the contract.

multicall()

Uses delegateCall to sequentially execute functions, then return the result of each execut

Input

FieldTypeExplanation
databytes[]encoded function data for each of the calls to make to this contract

Output

FieldTypeExplanation
resultsbytes[]results from each of the calls passed in

LiquidityHelper

A helper contract to handle liquidity related actions, including mint/add/remove liquidity.

Struct: AddLiquidityParams

Used when minting a new position or adding liquidity to an existing one.

FieldTypeExplanation
token0addressfirst token of the pool
token1addresssecond token of the pool
feeuint16the pool's swap fee
tickLowerint24position's lower tick
tickUpperint24position's upper tick
ticksPreviousint24[2]an array containing 2 values tickLowerPrevious and `tickUpper
are expected to be the nearest initialized tick <= tickLower and tickUpper respectively
amount0Desireduint256token0 amount user wants to add
amount1Desireduint256token1 amount user wants to add
amount0Desireduint256minimum token0 amount that should be used
amount1Desireduint256minimum token1 amount that should be used

Struct: CallbackData

Data for callback from Pool contract.

FieldTypeExplanation
token0addressfirst token of the pool
token1addresssecond token of the pool
feeuint16the pool's swap fee
sourceaddressaddress to transfer token0/token1 from

proAMMMintCallback()

Mint callback function implementation called by a Pool.

Input FieldTypeExplanation
deltaQty0uint256token0 amount requested by the pool
deltaQty1uint256token1 amount requested by the pool
databytesEncoded CallbackData

_addLiquidity()

Add liquidity to a pool. token0 and token1 should be in the correct order, i.e *token0 < tok

Input

TypeExplanation
AddLiquidityParamsParameters for addiing liquidity to a poo

Output

FieldTypeExplanation
liquidityuint128amount of liquidity added
amount0uint256amount of token0 required
amount1uint256amount of token1 required
feeGrowthInsideLastuint256latest feeGrowthInsideLast calculated by the pool
poolIProAMMPoolpool address

_callbackData()

Function to encode input parameters to CallbackData

Input FieldTypeExplanation
token0addressfirst token of the pool
token1addresssecond token of the pool
feeuint16the pool's swap fee

_getPool()

Function for computing the pool address with the given input parameters.

Input FieldTypeExplanation
token0addressfirst token of the pool
token1addresssecond token of the pool
feeuint16the pool's swap fee