Core
Inherits: Updates
This core contract implements all abstract functions from the inherited contracts, initializes the contract, and adds standard functions.
Functions
constructor
Constructor implemented but unused.
Contract is upgradeable and therefore the constructor is not used.
constructor();
initialize
Initializes contract with the owner and relevant addresses and parameters for operation.
This function sets up all necessary state variables for the contract and can only be called once due to the initializer
modifier.
function initialize(
address owner,
ContractAddress[] memory contractAddresses,
TokenAddress[] memory tokenAddresses,
UniswapV3Pool[] memory uniswapV3Pools,
uint16 initialSlippageTolerance
) external initializer;
Parameters
Name | Type | Description |
---|---|---|
owner | address | The address of the owner of the contract. |
contractAddresses | ContractAddress[] | An array of ContractAddress structures containing addresses of related contracts. |
tokenAddresses | TokenAddress[] | An array of TokenAddress structures containing addresses of relevant ERC-20 tokens. |
uniswapV3Pools | UniswapV3Pool[] | An array of UniswapV3Pool structures containing the address and fee of the UniswapV3 pools. |
initialSlippageTolerance | uint16 | The initial slippage tolerance for token swaps. |
withdrawEth
Withdraw all ETH from the contract.
This function is intended for emergency use.
In normal operation, the contract should not hold ETH,
This function can be called by anyone.
The use of nonReentrant is not required due to the withdrawAddress
check for the OWNER_ROLE
and it drains 100% of the ETH balance anyway.
Throws SimpleSwap__NoEthToWithdraw
if there is no ETH to withdraw.
Emits an EthWithdrawn
event.
Stores the block number of the event.
function withdrawEth(address _withdrawAddress) external checkOwner(_withdrawAddress);
Parameters
Name | Type | Description |
---|---|---|
_withdrawAddress | address | The address to send the withdrawn ETH to. Must have OWNER_ROLE . |
withdrawTokens
Withdraw specified tokens from the contract balance.
The function withdraws the specified tokens from the contract balance to the owner.
Throws SimpleSwap__NoTokensToWithdraw
if there are no tokens to withdraw.
Emits a TokensWithdrawn
event.
Stores the block number of the event.
function withdrawTokens(string memory _identifier, address _withdrawAddress) external checkOwner(_withdrawAddress);
Parameters
Name | Type | Description |
---|---|---|
_identifier | string | The identifier of the token to withdraw. |
_withdrawAddress | address | The address to send the withdrawn tokens to. Must have OWNER_ROLE . |
_authorizeUpgrade
Internal function to authorize an upgrade.
Caller must have OWNER_ROLE
.
function _authorizeUpgrade(address _newImplementation) internal override onlyRole(OWNER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
_newImplementation | address | Address of the new contract implementation. |
upgradeContract
Upgrade the contract to a new implementation.
Caller must have OWNER_ROLE
.
function upgradeContract(address newImplementation, bytes memory data) external payable;
Parameters
Name | Type | Description |
---|---|---|
newImplementation | address | Address of the new contract implementation. |
data | bytes | Data to send to the new implementation. |