Core

Git Source

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

NameTypeDescription
owneraddressThe address of the owner of the contract.
contractAddressesContractAddress[]An array of ContractAddress structures containing addresses of related contracts.
tokenAddressesTokenAddress[]An array of TokenAddress structures containing addresses of relevant ERC-20 tokens.
uniswapV3PoolsUniswapV3Pool[]An array of UniswapV3Pool structures containing the address and fee of the UniswapV3 pools.
initialSlippageToleranceuint16The 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

NameTypeDescription
_withdrawAddressaddressThe 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

NameTypeDescription
_identifierstringThe identifier of the token to withdraw.
_withdrawAddressaddressThe 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

NameTypeDescription
_newImplementationaddressAddress 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

NameTypeDescription
newImplementationaddressAddress of the new contract implementation.
databytesData to send to the new implementation.