Skip to content
Verified contractExactMIT

TwinstaSwapRouterV2

Address0x69d30d65727212bebf575224bcb40dd3fd7d1f3a
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.34

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.34+commit.80d5c536
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,305,455
Creation transaction
0x5f178d21d2…9a1541e360

contracts/TwinstaSwapV2.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

// Interface für Standard-Token (USDC, USDT etc.)
interface IERC20 {
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function approve(address spender, uint256 amount) external returns (bool);
}

// Das offizielle Interface für den Uniswap V3 Router
interface ISwapRouter {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
}

contract TwinstaSwapRouterV2 {
    // Deine private Trust Wallet (Hier landen die 0,15%)
    address public constant FEE_WALLET = 0xD0b2C7c687899367a1ACC059fE2f208eaa3acb42;
    uint256 public constant FEE_BPS = 15; // 0,15%
    uint256 public constant BPS_DENOMINATOR = 10000;

    // Die offizielle Adresse des Uniswap V3 Routers auf der Polygon Blockchain
    ISwapRouter public constant swapRouter = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);

    event SwapFeeProcessed(address indexed user, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 feeAmount);

    // Die neue Funktion, die jetzt auch den Ziel-Token (tokenOut) kennt
    function processFeeAndRoute(
        address tokenIn,
        address tokenOut,
        uint24 poolFee,
        uint256 amountIn
    ) external {
        // 1. Deine Gebühr berechnen (0,15%)
        uint256 feeAmount = (amountIn * FEE_BPS) / BPS_DENOMINATOR;
        uint256 swapAmount = amountIn - feeAmount;

        // 2. Die Token vom Nutzer in deinen Contract ziehen
        require(IERC20(tokenIn).transferFrom(msg.sender, address(this), amountIn), "Transfer in Contract fehlgeschlagen");

        // 3. Deine Gebühr sofort an deine Wallet senden
        require(IERC20(tokenIn).transfer(FEE_WALLET, feeAmount), "Gebuehren-Transfer fehlgeschlagen");

        // 4. Dem Uniswap Router die Erlaubnis (Approve) geben, den Rest zu tauschen
        require(IERC20(tokenIn).approve(address(swapRouter), swapAmount), "Uniswap Approve fehlgeschlagen");

        // 5. Den eigentlichen Tausch bei Uniswap auslösen
        ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
            tokenIn: tokenIn,
            tokenOut: tokenOut,
            fee: poolFee, // z.B. 500 für einen 0.05% Pool
            recipient: msg.sender, // Der Nutzer bekommt seine neuen Token direkt von Uniswap!
            deadline: block.timestamp + 300, // 5 Minuten Zeitlimit für den Tausch
            amountIn: swapAmount,
            amountOutMinimum: 0, // Für den ersten Test ohne Limit
            sqrtPriceLimitX96: 0
        });

        swapRouter.exactInputSingle(params);

        emit SwapFeeProcessed(msg.sender, tokenIn, tokenOut, amountIn, feeAmount);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.