MaverickV2Factory
Inherits: IMaverickV2Factory, IMaverickV2FactoryAdmin, Ownable
Pool Factory contract. Deploys both permissionless and permissioned Maverick V2 pools using deterministic create2 addresses. Deployed pools can be looked up by their parameters or by the token pair. This contract is ownable with the owner having permission to set protocol fee for all pools and collect protocol fee proceeds from pools.
State Variables
poolLists
Mapping elements are [tokenA][tokenB] -> list of pools.
poolListsPermissioned
Mapping elements are [accessor][tokenA][tokenB] -> list of pools.
isFactoryPool
Bool indicating whether the pool was deployed from this factory.
isFactoryPoolPermissioned
Bool indicating whether the pool was deployed from this factory.
protocolFeeRatioD3
Proportion of protocol fee to collect on each swap. Value is in 3-decimal format with a maximum value of 0.25e3.
protocolLendingFeeRateD18
Fee rate charged by the protocol for flashloans. Value is in 18-decimal format with a maximum value of 0.02e18.
deployParameters
Called by deployer library to initialize a pool.
protocolFeeReceiver
Address that receives the protocol fee when users call claimProtocolFeeForPool
.
allPools
Array of all permissionless pools.
allPoolsPermissioned
Array of all permissioned pools.
Functions
constructor
setProtocolFeeRatio
Set the protocol fee ratio.
Parameters
Name | Type | Description |
---|---|---|
|
| The new protocol fee ratio to set in 3-decimal units. |
setProtocolLendingFeeRate
Set the protocol lending fee rate.
Parameters
Name | Type | Description |
---|---|---|
|
| The new protocol lending fee rate to set in 18-decimal units. |
setProtocolFeeReceiver
Set the protocol fee receiver address. If protocol fee is non-zero, user will be able to permissionlessly push protocol fee from a given pool to this address.
transferOwnership
Transfer ownership of the contract to a new owner.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the new owner. |
renounceOwnership
Renounce ownership of the contract.
claimProtocolFeeForPool
Claim protocol fee for a pool and transfer it to the protocolFeeReceiver.
Parameters
Name | Type | Description |
---|---|---|
|
| The pool from which to claim the protocol fee. |
|
| A boolean indicating whether tokenA (true) or tokenB (false) is being collected. |
claimProtocolFeeForPool
Claim protocol fee for a pool and transfer it to the protocolFeeReceiver.
Parameters
Name | Type | Description |
---|---|---|
|
| The pool from which to claim the protocol fee. |
updateProtocolFeeRatioForPool
Update the protocol fee ratio for a pool. Can be called permissionlessly allowing any user to sync the pool protocol fee value with the factory protocol fee value.
Parameters
Name | Type | Description |
---|---|---|
|
| The pool for which to update. |
updateProtocolLendingFeeRateForPool
Update the protocol lending fee rate for a pool. Can be called permissionlessly allowing any user to sync the pool protocol lending fee rate value with the factory value.
Parameters
Name | Type | Description |
---|---|---|
|
| The pool for which to update. |
create
Create a new MaverickV2Pool with symmetric swap fees.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| Tick spacing of pool where 1.0001^tickSpacing is the bin width. |
|
| Pool lookback in second in D2 scale. |
|
| Address of tokenA. |
|
| Address of tokenB. |
|
| Tick position that contains the active bins. |
|
| 1-15 number to represent the active kinds 0b0001 = static; 0b0010 = right; 0b0100 = left; 0b1000 = both. E.g. a pool with all 4 modes will have kinds = b1111 = 15 |
createPermissioned
Create a new MaverickV2PoolPermissioned with symmetric swap fees.
Parameters
Name | Type | Description |
---|---|---|
|
| Fraction of the pool swap amount that is retained as an LP in D18 scale. |
|
| Tick spacing of pool where 1.0001^tickSpacing is the bin width. |
|
| Pool lookback in second in D2 scale. |
|
| Address of tokenA. |
|
| Address of tokenB. |
|
| Tick position that contains the active bins. |
|
| 1-15 number to represent the active kinds 0b0001 = static; 0b0010 = right; 0b0100 = left; 0b1000 = both. E.g. a pool with all 4 modes will have kinds = b1111 = 15 |
|
| Only address that can access the pool's public write functions. |
owner
Get the current factory owner.
lookup
Lookup a pool for given parameters.
lookup
Lookup a pool for given parameters.
Lookup a pool for given parameters.
Lookup a pool for given parameters.
Lookup a pool for given parameters.
Lookup a pool for given parameters.
Address of a permissionless pool.
Address of a permissionless pool.
_slice
Prune array from storage to subset of array with range [startIndex, endIndex).
Parameters
Name | Type | Description |
---|---|---|
|
| Storage array of full pool list to be sliced. |
|
| The first index of the pool list in storage to return. |
|
| Upper bound index that is not included in the returned list. |
Returns
Name | Type | Description |
---|---|---|
|
| An array of MaverickV2Pool addresses. |
_createChecks
Check create pool parameters to ensure they are valid. Reverts on an invalid paramter sets.
_checkProtocolFeeRatio
Checks the validity of the protocol fee ratio.
_checkProtocolLendingFeeRate
Checks the validity of the protocol lending fee rate.
Last updated