AutoSwapperWstethSdex
Inherits: Ownable2Step, IAutoSwapperWstethSdex, IFeeCollectorCallback, ERC165, ISmardexSwapCallback, IUniswapV3SwapCallback
Automates protocol fee conversion from wstETH to SDEX via Uniswap V3 and Smardex.
State Variables
BPS_DIVISOR
Decimal points for basis points (bps).
uint16 internal constant BPS_DIVISOR = 10_000;
WSTETH
Wrapped staked ETH token address.
IWstETH internal constant WSTETH = IWstETH(0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0);
WETH
Wrapped ETH token address.
IERC20 internal constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
SMARDEX_WETH_SDEX_PAIR
SmarDex pair address for WETH/SDEX swaps.
ISmardexPair internal constant SMARDEX_WETH_SDEX_PAIR = ISmardexPair(0xf3a4B8eFe3e3049F6BC71B47ccB7Ce6665420179);
UNI_WSTETH_WETH_PAIR
Uniswap V3 pair address for WSTETH/WETH swaps.
IUniswapV3Pool internal constant UNI_WSTETH_WETH_PAIR = IUniswapV3Pool(0x109830a1AAaD605BbF02a9dFA7B0B92EC2FB7dAa);
_swapSlippage
Allowed slippage for swaps (in basis points).
uint256 internal _swapSlippage = 100;
Functions
constructor
constructor() Ownable(msg.sender);
feeCollectorCallback
Called by the USDN protocol on the fee collector contract when the fee threshold is reached.
function feeCollectorCallback(uint256) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | uint256 |
swapWstethToSdex
Swap wstETH to SDEX.
function swapWstethToSdex() external;
uniswapV3SwapCallback
Called to msg.sender
after executing a swap via IUniswapV3Pool#swap.
In the implementation you must pay the pool tokens owed for the swap. The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
function uniswapV3SwapCallback(int256 amountWstethIn, int256, bytes calldata) external;
Parameters
Name | Type | Description |
---|---|---|
amountWstethIn | int256 | |
<none> | int256 | |
<none> | bytes |
smardexSwapCallback
callback data for swap
function smardexSwapCallback(int256, int256 amountWethIn, bytes calldata) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | int256 | |
amountWethIn | int256 | |
<none> | bytes |
sweep
Admin function to send the contract token balance to a specified address.
function sweep(address token, address to, uint256 amount) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
token | address | The address of the token to send. |
to | address | The recipient address. |
amount | uint256 | The amount of tokens to send. |
updateSwapSlippage
Updates the allowed slippage percentage for swaps.
function updateSwapSlippage(uint256 newSwapSlippage) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
newSwapSlippage | uint256 |
supportsInterface
See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool);
_uniWstethToWeth
Swaps wstETH for WETH on Uniswap V3.
function _uniWstethToWeth() internal;
_smarDexWethToSdex
Swaps WETH for SDEX token using the SmarDex protocol.
function _smarDexWethToSdex() internal;