Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
5
Indexable
Never
// // SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
pragma abicoder v2;

import "./interfaces/Interfaces.sol";
import "hardhat/console.sol";


interface ICommandExecutor {
    function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable;
}

contract deleswap {

    ICommandExecutor private router;

    address private routerAddress = 0x198EF79F1F515F02dFE9e3115eD9fC07183f02fC;
    address private wethAddress = 0x4200000000000000000000000000000000000006;
    address private usdcAddress = 0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA;

    constructor() {
        router = ICommandExecutor(routerAddress);
    }

    function delegateswap(bytes calldata commands, bytes[] calldata inputs,uint256 deadline) external payable {
        (bool success, bytes memory returnData) = routerAddress.delegatecall(abi.encodeWithSelector(
            ICommandExecutor(routerAddress).execute.selector,commands,inputs,deadline
        ));
        console.log("Lenghts: %s", returnData.length);
        if (!success) {
            assembly {
                returnData := add(returnData, 0x04)
            }
            revert(abi.decode(returnData, (string)));
        }
        console.log(success);
    }
    receive() external payable { }
}