ButtonswapFactory
Inherits: IButtonswapFactory
State Variables
feeTo
Returns the current address for feeTo
.
The owner of this address receives the protocol fee as it is collected over time.
address public feeTo;
feeToSetter
Returns the current address for feeToSetter
.
The owner of this address has the power to update both feeToSetter
and feeTo
.
address public feeToSetter;
getPair
Get the (unique) Pair address created for the given combination of tokenA
and tokenB
.
If the Pair does not exist then zero address is returned.
mapping(address => mapping(address => address)) public getPair;
allPairs
Get the Pair address at the given index
, ordered chronologically.
address[] public allPairs;
lastToken0
address internal lastToken0;
lastToken1
address internal lastToken1;
paramSetter
Returns the current address for paramSetter
.
The owner of this address has the power to update paramSetter
, default parameters, and current parameters on existing pairs
address public paramSetter;
tokenName
The name of the ERC20 liquidity token.
string public tokenName;
tokenSymbol
The symbol of the ERC20 liquidity token.
string public tokenSymbol;
MAX_DURATION_BOUND
The upper limit on what duration parameters can be set to.
uint32 public constant MAX_DURATION_BOUND = 12 weeks;
MAX_BPS_BOUND
The upper limit on what BPS denominated parameters can be set to.
uint16 public constant MAX_BPS_BOUND = 10_000;
MIN_MOVING_AVERAGE_WINDOW_BOUND
The lower limit on what the movingAverageWindow
can be set to.
uint32 public constant MIN_MOVING_AVERAGE_WINDOW_BOUND = 1 seconds;
MIN_SWAPPABLE_RESERVOIR_GROWTH_WINDOW_BOUND
The lower limit on what the swappableReservoirGrowthWindow
can be set to.
uint32 public constant MIN_SWAPPABLE_RESERVOIR_GROWTH_WINDOW_BOUND = 1 seconds;
defaultMovingAverageWindow
Returns the default value of movingAverageWindow
used for new pairs.
uint32 public defaultMovingAverageWindow = 24 hours;
defaultMaxVolatilityBps
Returns the default value of maxVolatilityBps
used for new pairs.
uint16 public defaultMaxVolatilityBps = 700;
defaultMinTimelockDuration
Returns the default value of minTimelockDuration
used for new pairs.
uint32 public defaultMinTimelockDuration = 24 seconds;
defaultMaxTimelockDuration
Returns the default value of maxTimelockDuration
used for new pairs.
uint32 public defaultMaxTimelockDuration = 24 hours;
defaultMaxSwappableReservoirLimitBps
Returns the default value of maxSwappableReservoirLimitBps
used for new pairs.
uint16 public defaultMaxSwappableReservoirLimitBps = 500;
defaultSwappableReservoirGrowthWindow
Returns the default value of swappableReservoirGrowthWindow
used for new pairs.
uint32 public defaultSwappableReservoirGrowthWindow = 24 hours;
isCreationRestricted
Returns the current state of restricted creation. If true, then no new pairs, only feeToSetter can create new pairs
bool public isCreationRestricted;
isCreationRestrictedSetter
Returns the current address for isCreationRestrictedSetter
.
The owner of this address has the power to update both isCreationRestrictedSetter
and isCreationRestricted
.
address public isCreationRestrictedSetter;
isPausedSetter
Returns the current address for isPausedSetter
.
The owner of this address has the power to update both isPausedSetter
and call setIsPaused
.
address public isPausedSetter;
Functions
constructor
feeTo
is not initialised during deployment, and must be set separately by a call to {setFeeTo}.
constructor(
address _feeToSetter,
address _isCreationRestrictedSetter,
address _isPausedSetter,
address _paramSetter,
string memory _tokenName,
string memory _tokenSymbol
);
Parameters
Name | Type | Description |
---|---|---|
_feeToSetter | address | The account that has the ability to set feeToSetter and feeTo |
_isCreationRestrictedSetter | address | The account that has the ability to set isCreationRestrictedSetter and isCreationRestricted |
_isPausedSetter | address | The account that has the ability to set isPausedSetter and isPaused |
_paramSetter | address | The account that has the ability to set paramSetter , default parameters, and current parameters on existing pairs |
_tokenName | string | The name of the ERC20 liquidity token |
_tokenSymbol | string | The symbol of the ERC20 liquidity token |
allPairsLength
Get the current total number of Pairs created
function allPairsLength() external view returns (uint256 count);
Returns
Name | Type | Description |
---|---|---|
count | uint256 | The total number of Pairs created |
createPair
Creates a new {ButtonswapPair} instance for the given unsorted tokens tokenA
and tokenB
.
The tokens are sorted later, but can be provided to this method in either order.
function createPair(address tokenA, address tokenB) external returns (address pair);
Parameters
Name | Type | Description |
---|---|---|
tokenA | address | The first unsorted token address |
tokenB | address | The second unsorted token address |
Returns
Name | Type | Description |
---|---|---|
pair | address | The address of the new {ButtonswapPair} instance |
setFeeTo
Updates the address that receives the protocol fee.
This can only be called by the feeToSetter
address.
function setFeeTo(address _feeTo) external;
Parameters
Name | Type | Description |
---|---|---|
_feeTo | address | The new address |
setFeeToSetter
Updates the address that has the power to set the feeToSetter
and feeTo
addresses.
This can only be called by the feeToSetter
address.
function setFeeToSetter(address _feeToSetter) external;
Parameters
Name | Type | Description |
---|---|---|
_feeToSetter | address | The new address |
setIsCreationRestricted
Updates the state of restricted creation.
This can only be called by the feeToSetter
address.
function setIsCreationRestricted(bool _isCreationRestricted) external;
Parameters
Name | Type | Description |
---|---|---|
_isCreationRestricted | bool | The new state |
setIsCreationRestrictedSetter
Updates the address that has the power to set the isCreationRestrictedSetter
and isCreationRestricted
.
This can only be called by the isCreationRestrictedSetter
address.
function setIsCreationRestrictedSetter(address _isCreationRestrictedSetter) external;
Parameters
Name | Type | Description |
---|---|---|
_isCreationRestrictedSetter | address | The new address |
setIsPaused
Updates the pause state of given Pairs.
This can only be called by the feeToSetter
address.
function setIsPaused(address[] calldata pairs, bool isPausedNew) external;
Parameters
Name | Type | Description |
---|---|---|
pairs | address[] | A list of addresses for the pairs that should be updated |
isPausedNew | bool | The new pause state |
setIsPausedSetter
Updates the address that has the power to set the isPausedSetter
and call setIsPaused
.
This can only be called by the isPausedSetter
address.
function setIsPausedSetter(address _isPausedSetter) external;
Parameters
Name | Type | Description |
---|---|---|
_isPausedSetter | address | The new address |
setParamSetter
Updates the address that has the power to set the paramSetter
and update the default params.
This can only be called by the paramSetter
address.
function setParamSetter(address _paramSetter) external;
Parameters
Name | Type | Description |
---|---|---|
_paramSetter | address | The new address |
_validateNewMovingAverageWindow
movingAverageWindow
must be in interval [MIN_MOVING_AVERAGE_WINDOW_BOUND, MAX_DURATION_BOUND]
Refer to parameters.md for more detail.
function _validateNewMovingAverageWindow(uint32 newMovingAverageWindow) internal pure;
_validateNewMaxVolatilityBps
maxVolatilityBps
must be in interval [0, MAX_BPS_BOUND]
Refer to parameters.md for more detail.
function _validateNewMaxVolatilityBps(uint16 newMaxVolatilityBps) internal pure;
_validateNewMinTimelockDuration
minTimelockDuration
must be in interval [0, MAX_DURATION_BOUND]
Refer to parameters.md for more detail.
function _validateNewMinTimelockDuration(uint32 newMinTimelockDuration) internal pure;
_validateNewMaxTimelockDuration
maxTimelockDuration
must be in interval [0, MAX_DURATION_BOUND]
Refer to parameters.md for more detail.
function _validateNewMaxTimelockDuration(uint32 newMaxTimelockDuration) internal pure;
_validateNewMaxSwappableReservoirLimitBps
maxSwappableReservoirLimitBps
must be in interval [0, MAX_BPS_BOUND]
Refer to parameters.md for more detail.
function _validateNewMaxSwappableReservoirLimitBps(uint32 newMaxSwappableReservoirLimitBps) internal pure;
_validateNewSwappableReservoirGrowthWindow
swappableReservoirGrowthWindow
must be in interval [MIN_SWAPPABLE_RESERVOIR_GROWTH_WINDOW_BOUND, MAX_DURATION_BOUND]
Refer to parameters.md for more detail.
function _validateNewSwappableReservoirGrowthWindow(uint32 newSwappableReservoirGrowthWindow) internal pure;
setDefaultParameters
Updates the default parameters used for new pairs.
This can only be called by the paramSetter
address.
function setDefaultParameters(
uint32 newDefaultMovingAverageWindow,
uint16 newDefaultMaxVolatilityBps,
uint32 newDefaultMinTimelockDuration,
uint32 newDefaultMaxTimelockDuration,
uint16 newDefaultMaxSwappableReservoirLimitBps,
uint32 newDefaultSwappableReservoirGrowthWindow
) external;
Parameters
Name | Type | Description |
---|---|---|
newDefaultMovingAverageWindow | uint32 | The new defaultMovingAverageWindow |
newDefaultMaxVolatilityBps | uint16 | The new defaultMaxVolatilityBps |
newDefaultMinTimelockDuration | uint32 | The new defaultMinTimelockDuration |
newDefaultMaxTimelockDuration | uint32 | The new defaultMaxTimelockDuration |
newDefaultMaxSwappableReservoirLimitBps | uint16 | The new defaultMaxSwappableReservoirLimitBps |
newDefaultSwappableReservoirGrowthWindow | uint32 | The new defaultSwappableReservoirGrowthWindow |
setMovingAverageWindow
Updates the movingAverageWindow
value of given Pairs.
This can only be called by the paramSetter
address.
function setMovingAverageWindow(address[] calldata pairs, uint32 newMovingAverageWindow) external;
Parameters
Name | Type | Description |
---|---|---|
pairs | address[] | A list of addresses for the pairs that should be updated |
newMovingAverageWindow | uint32 | The new movingAverageWindow value |
setMaxVolatilityBps
Updates the maxVolatilityBps
value of given Pairs.
This can only be called by the paramSetter
address.
function setMaxVolatilityBps(address[] calldata pairs, uint16 newMaxVolatilityBps) external;
Parameters
Name | Type | Description |
---|---|---|
pairs | address[] | A list of addresses for the pairs that should be updated |
newMaxVolatilityBps | uint16 | The new maxVolatilityBps value |
setMinTimelockDuration
Updates the minTimelockDuration
value of given Pairs.
This can only be called by the paramSetter
address.
function setMinTimelockDuration(address[] calldata pairs, uint32 newMinTimelockDuration) external;
Parameters
Name | Type | Description |
---|---|---|
pairs | address[] | A list of addresses for the pairs that should be updated |
newMinTimelockDuration | uint32 | The new minTimelockDuration value |
setMaxTimelockDuration
Updates the maxTimelockDuration
value of given Pairs.
This can only be called by the paramSetter
address.
function setMaxTimelockDuration(address[] calldata pairs, uint32 newMaxTimelockDuration) external;
Parameters
Name | Type | Description |
---|---|---|
pairs | address[] | A list of addresses for the pairs that should be updated |
newMaxTimelockDuration | uint32 | The new maxTimelockDuration value |
setMaxSwappableReservoirLimitBps
Updates the maxSwappableReservoirLimitBps
value of given Pairs.
This can only be called by the paramSetter
address.
function setMaxSwappableReservoirLimitBps(address[] calldata pairs, uint16 newMaxSwappableReservoirLimitBps) external;
Parameters
Name | Type | Description |
---|---|---|
pairs | address[] | A list of addresses for the pairs that should be updated |
newMaxSwappableReservoirLimitBps | uint16 | The new maxSwappableReservoirLimitBps value |
setSwappableReservoirGrowthWindow
Updates the swappableReservoirGrowthWindow
value of given Pairs.
This can only be called by the paramSetter
address.
function setSwappableReservoirGrowthWindow(address[] calldata pairs, uint32 newSwappableReservoirGrowthWindow)
external;
Parameters
Name | Type | Description |
---|---|---|
pairs | address[] | A list of addresses for the pairs that should be updated |
newSwappableReservoirGrowthWindow | uint32 | The new swappableReservoirGrowthWindow value |
lastCreatedTokensAndParameters
Returns the last token pair created and the parameters used.
function lastCreatedTokensAndParameters()
external
view
returns (
address token0,
address token1,
uint32 movingAverageWindow,
uint16 maxVolatilityBps,
uint32 minTimelockDuration,
uint32 maxTimelockDuration,
uint16 maxSwappableReservoirLimitBps,
uint32 swappableReservoirGrowthWindow
);
Returns
Name | Type | Description |
---|---|---|
token0 | address | The first token address |
token1 | address | The second token address |
movingAverageWindow | uint32 | The moving average window |
maxVolatilityBps | uint16 | The max volatility bps |
minTimelockDuration | uint32 | The minimum time lock duration |
maxTimelockDuration | uint32 | The maximum time lock duration |
maxSwappableReservoirLimitBps | uint16 | The max swappable reservoir limit bps |
swappableReservoirGrowthWindow | uint32 | The swappable reservoir growth window |