AutoSwapperWusdnSdex

Git Source

Inherits: Ownable2Step, IAutoSwapperWusdnSdex, IFeeCollectorCallback, ERC165, ISmardexSwapCallback

Automates protocol fee conversion from WUSDN to SDEX via Smardex.

State Variables

BPS_DIVISOR

Decimal points for basis points (bps).

uint16 internal constant BPS_DIVISOR = 10_000;

WUSDN

Wrapped USDN token address.

IERC20 internal constant WUSDN = IERC20(0x99999999999999Cc837C997B882957daFdCb1Af9);

SMARDEX_WUSDN_SDEX_PAIR

SmarDex pair address for WUSDN/SDEX swaps.

ISmardexPair internal constant SMARDEX_WUSDN_SDEX_PAIR = ISmardexPair(0x11443f5B134c37903705e64129BEFc20e35a3725);

FEE_LP

Fee rates for LP on the SmarDex pair.

uint128 internal immutable FEE_LP;

FEE_POOL

Fee rates for the pool on the SmarDex pair.

uint128 internal immutable FEE_POOL;

_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

NameTypeDescription
<none>uint256

swapWusdnToSdex

Swap WUSDN to SDEX.

function swapWusdnToSdex() external;

smardexSwapCallback

callback data for swap

function smardexSwapCallback(int256, int256 amountWusdnIn, bytes calldata) external;

Parameters

NameTypeDescription
<none>int256
amountWusdnInint256
<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

NameTypeDescription
tokenaddressThe address of the token to send.
toaddressThe recipient address.
amountuint256The amount of tokens to send.

getSwapSlippage

Get the current swap slippage setting (in basis points)

function getSwapSlippage() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Current slippage tolerance

updateSwapSlippage

Updates the allowed slippage percentage for swaps.

function updateSwapSlippage(uint256 newSwapSlippage) external onlyOwner;

Parameters

NameTypeDescription
newSwapSlippageuint256

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool);

_quoteAmountOut

Calculates the amount of SDEX that can be obtained from a given amount of WUSDN.

function _quoteAmountOut(uint256 amountIn) internal view returns (uint256 amountOut_);

Parameters

NameTypeDescription
amountInuint256The amount of WUSDN to swap

Returns

NameTypeDescription
amountOut_uint256The amount of SDEX that can be obtained