// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IUniswapV2Router { function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); } contract SellTixDEX { IUniswapV2Router public router; IERC20 public stxToken; IERC20 public maticToken; constructor(address _router, address _stx, address _matic) { router = IUniswapV2Router(_router); stxToken = IERC20(_stx); maticToken = IERC20(_matic); } function swapSTXForMatic(uint256 stxAmount) external { // User sends STX stxToken.transferFrom(msg.sender, address(this), stxAmount); // Swap STX for MATIC through DEX address[] memory path = new address[](2); path[0] = address(stxToken); path[1] = address(maticToken); router.swapExactTokensForTokens( stxAmount, 0, // Accept any amount of MATIC path, msg.sender, block.timestamp ); } }