#
Swapper
This is an contract that will handle all of the swaps for the vault. So far it will use an router to swap any tokens and send them back to the sender. It is set as another contract to be able to change it in the future if the paradigm of router change drastically. It is meant to be used in a push / pull manner with the swap function.
#
State Variables
#
swapRouter
Dex/aggregaor router to call to perform swaps
address public swapRouter;
#
tokenTransferAddress
Address to allow to swap tokens
address public tokenTransferAddress;
#
vault
Address of the ERC4626 vault
address public vault;
#
Functions
#
onlyVault
modifier onlyVault();
#
constructor
constructor(address initialOwner, address initialSwapRouter, address initialTokenTransferAddress)
Owned2Step(initialOwner);
#
setSwapRouter
Set the dex/aggregator router to call to perform swaps
function setSwapRouter(address newSwapRouter) external onlyOwner;
Parameters
#
setTokenTransferAddress
Set the token proxy address to allow to swap tokens
function setTokenTransferAddress(address newTokenTransferAddress) external onlyOwner;
Parameters
#
setVault
Set the vault address
function setVault(address newVault) external onlyOwner;
Parameters
#
recoverERC20
Recover ERC2O tokens in the contract
Recover ERC2O tokens in the contract
function recoverERC20(address token) external onlyOwner returns (bool);
Parameters
Returns
#
swap
Swap tokens using the router/aggregator
The calldatas should set the recipient of the tokens to the vault
function swap(address[] calldata tokens, bytes[] calldata callDatas) external onlyVault;
Parameters
#
_performRouterSwap
Perform the swap using the router/aggregator
function _performRouterSwap(bytes calldata callData) internal;
Parameters
#
Events
#
SwapRouterUpdated
Event emitted when the swap router is updated
event SwapRouterUpdated(address oldSwapRouter, address newSwapRouter);
#
TokenTransferAddressUpdated
Event emitted when the token proxy is updated
event TokenTransferAddressUpdated(address oldTokenTransferAddress, address newTokenTransferAddress);
#
VaultUpdated
Event emitted when the vault is updated
event VaultUpdated(address oldVault, address newVault);