xWin Swap V3
xWinSwapV3
SwapMethod
enum SwapMethod {
UNISWAPV2,
UNISWAPV3,
UNISWAPV3Multihop
}SwapInfo
struct SwapInfo {
address router;
address[] path;
bytes multihopPath;
uint24 slippage;
uint24 poolFee;
enum xWinSwapV3.SwapMethod swapMethod;
}Received
event Received(address, uint256)receive
receive() external payableonlyExecutor
modifier onlyExecutor()swapData
mapping(address => mapping(address => struct xWinSwapV3.SwapInfo)) swapDataMapping containing swapInfo, for swap pair fromToken, toToken
executors
mapping(address => bool) executorspriceMaster
contract IxWinPriceMaster priceMasterinitialize
function initialize() externalswapTokenToToken
function swapTokenToToken(uint256 _amount, address _fromToken, address _toToken) external returns (uint256)Swap tokens using xWin Swap
Parameters
_amount
uint256
Amount of tokens to swap
_fromToken
address
Token to swap
_toToken
address
Token to receive
swapTokenToToken
function swapTokenToToken(uint256 _amount, address _fromToken, address _toToken, uint32 _slippage) public returns (uint256)Swap tokens using xWin Swap with slippage
Parameters
_amount
uint256
Amount of tokens to swap
_fromToken
address
Token to swap
_toToken
address
Token to receive
_slippage
uint32
Slippage for the swap
internalSwap
function internalSwap(uint256 _amount, address _fromToken, address _toToken, address recipient, uint32 _slippage) internal returns (uint256)Main logic for swapping tokens
_swapV2
function _swapV2(address _fromToken, uint256 amountIn, address[] path, address router, address destination, uint256 amountOutQuote) internal returns (uint256)makes swaps using a uniswapV2 style router
_swapV3
function _swapV3(uint256 _amount, address _fromToken, address _toToken, address _recipient, address routerV3, uint256 amountOutQuote, uint24 poolFee) internal returns (uint256)makes direct swap using a uniswapV3 style router
_swapV3Multihop
function _swapV3Multihop(uint256 _amount, address _fromToken, address _recipient, address routerV3, uint256 amountOutQuote, bytes multihopPath) internal returns (uint256)makes a multihop swap using a uniswapV3 style router
getSwapData
function getSwapData(address _fromtoken, address _totoken) external view returns (struct xWinSwapV3.SwapInfo _swapInfo)View function to get swapInfo for a swap pair
Parameters
_fromtoken
address
Token to swap
_totoken
address
Token to receive
Return Values
_swapInfo
struct xWinSwapV3.SwapInfo
SwapInfo for the swap pair
addTokenPath
function addTokenPath(address _fromtoken, address _totoken, address _router, address[] path, bytes _pathData, uint24 _slippage, uint24 _fee, enum xWinSwapV3.SwapMethod _swapMethod) external_xWinStratSwap
function _xWinStratSwap(uint256 _amount, address _fromToken, address _toToken, uint32 _slippage) internal returns (bool, uint256)This function handles xWinStrategy Token swaps
check if input tokens are xWinStrategies, if yes handle the swap and return true else return false
adminMoveToken
function adminMoveToken(address _tokenAddress) publicsetPriceMaster
function setPriceMaster(address _newPriceMaster) externalsetExecutor
function setExecutor(address _address, bool _allow) externaldepositToStrategy
function depositToStrategy(uint256 _amount, address _strat, uint32 _slippage) internal returns (uint256)withdrawFromStrategy
function withdrawFromStrategy(uint256 _amount, address _strat, uint32 _slippage) internal returns (uint256)Last updated