ETH Price: $2,150.46 (+4.46%)

Contract

0xaE623aa980F4876169118261F2DfF65A97ecD385
 

Overview

ETH Balance

0.0002 ETH

Eth Value

$0.43 (@ $2,150.46/ETH)

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Swap ET Hfor BTC157100672022-10-09 10:53:231261 days ago1665312803IN
0xaE623aa9...A97ecD385
0.0001 ETH0.0007286116.71316302
Swap ET Hfor BTC157100622022-10-09 10:52:231261 days ago1665312743IN
0xaE623aa9...A97ecD385
0.0001 ETH0.0011712518.446402

Latest 2 internal transactions

Advanced mode:
Parent Transaction Hash Method Block
From
To
Transfer157100672022-10-09 10:53:231261 days ago1665312803
0xaE623aa9...A97ecD385
0.0001 ETH
Transfer157100622022-10-09 10:52:231261 days ago1665312743
0xaE623aa9...A97ecD385
0.0001 ETH
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BTCETHSwap

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license
/**
 *Submitted for verification at Etherscan.io on 2022-10-09
*/

pragma solidity ^0.8.7;

/* Interface for ERC20 Tokens */
abstract contract Token {
    function transferFrom(address _from, address _to, uint256 _value) public virtual returns (bool success);
    function approve(address _spender, uint256 _value) public virtual returns (bool success);
}

abstract contract pToken {
    function redeem(uint256 _value, string memory destinationAddress, bytes4 destinationChainId) public virtual returns (bool _success);
}

interface Curve {
    function exchange_underlying(int128 i, int128 j, uint256 dx, uint256 min_dy, address receiver) external returns (uint256);
}

abstract contract WETH {
    function deposit() external virtual payable;
    function withdraw(uint256 amount) external virtual;    
    function approve(address guy, uint256 wad) external virtual;
}

interface UniswapRouter {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    function exactInputSingle(ExactInputSingleParams calldata params) external returns (uint256 amountOut);
}


contract BTCETHSwap {

    fallback() external {
        revert();
    }

    // ARB
    address public PBTC_ADDRESS = address(0x62199B909FB8B8cf870f97BEf2cE6783493c4908); 
    address public WBTC_ADDRESS = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); 
    address payable WETH_ADDRESS = payable(address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2));
    address public CURVE_PBTC_POOL  = address(0xC9467E453620f16b57a34a770C6bceBECe002587);
    address public UNISWAP_ROUTER   = address(0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45);

    int128 public CURVE_WBTC_INDEX = 2;
    int128 public CURVE_PBTC_INDEX = 0;
    
    bytes4 public PTOKENS_BTC_CHAINID = 0x01ec97de;


    // Constructor function, initializes the contract and sets the core variables
    constructor() {}

    // Swap PBTC for ETH
    function swapBTCforETH (uint256 amount, address payable recipient) public payable
    {
        Token(PBTC_ADDRESS).transferFrom(msg.sender, address(this), amount);

        // Curve pBTC for wBTC
        uint256 amount_wbtc = CurveSwap(
            false,
            amount
        );

        // Uniswap wBTC for ETH
        uint256 amountETH = Uniswap(
            WBTC_ADDRESS,
            WETH_ADDRESS,
            amount_wbtc,
            recipient,
            3000
        );

        WETH(WETH_ADDRESS).withdraw(amountETH);
    }

    // Swap ETH for PBTC
    function swapETHforBTC (string memory recipient) public payable {
        WETH_ADDRESS.send(msg.value);
        WETH(WETH_ADDRESS).approve(UNISWAP_ROUTER, msg.value);

        // Uniswap ETH for WBTC
        // uint256 amount_WBTC = Uniswap(
        //     WETH_ADDRESS,
        //     WBTC_ADDRESS,
        //     msg.value,
        //     address(this),
        //     500
        // );

        // Token(WBTC_ADDRESS).approve(CURVE_PBTC_POOL, amount_WBTC);

        // // Curve wBTC to pBTC
        // uint256 amount_pbtc = CurveSwap(
        //     true,
        //     amount_WBTC
        // );

        // // Redeem pBTC to recipient address
        // pToken(PBTC_ADDRESS).redeem(
        //     amount_pbtc, 
        //     recipient,
        //     PTOKENS_BTC_CHAINID
        // );
    }



    // Uniswap         
    function Uniswap(
        address tokenIn,
        address tokenOut,
        uint256 amountIn,
        address recipient,
        uint24 fee) internal returns (uint256)
    {

        UniswapRouter.ExactInputSingleParams memory params = UniswapRouter.ExactInputSingleParams(
            tokenIn,
            tokenOut,
            fee,
            recipient,
            block.timestamp,
            amountIn,
            0,
            0
        );

        uint256 amountOut = UniswapRouter(UNISWAP_ROUTER).exactInputSingle(params);
        return amountOut;
    }

    // Curve
    function CurveSwap(bool wtop, uint256 amountSell) internal returns (uint256)
    {
        int128 i;
        int128 j;

        if (wtop)
        {
            i = CURVE_WBTC_INDEX;
            j = CURVE_PBTC_INDEX;
        }
        else
        {
            i = CURVE_PBTC_INDEX;
            j = CURVE_WBTC_INDEX;
        }
        
        Curve(CURVE_PBTC_POOL).exchange_underlying(i, j, amountSell, 0, address(this));
    }    
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"CURVE_PBTC_INDEX","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CURVE_PBTC_POOL","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CURVE_WBTC_INDEX","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PBTC_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PTOKENS_BTC_CHAINID","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNISWAP_ROUTER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WBTC_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"}],"name":"swapBTCforETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"recipient","type":"string"}],"name":"swapETHforBTC","outputs":[],"stateMutability":"payable","type":"function"}]

6080604052600080546001600160a01b03199081167362199b909fb8b8cf870f97bef2ce6783493c490817909155600180548216732260fac5e5542a773aa44fbcfedf7c193bc2c59917905560028054821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc217815560038054831673c9467e453620f16b57a34a770c6bcebece002587179055600480549092167368b3465833fb72a70ecdf485e0e4c7bd8665fc45179091556005556006805463ffffffff19166301ec97de1790553480156100c957600080fd5b506106dd806100d96000396000f3fe6080604052600436106100865760003560e01c806378969a6a1161005957806378969a6a1461015b578063bdd5915f14610175578063d347f61614610195578063d8264920146101aa578063f32622f2146101ca57610086565b806309128a211461009757806311f1002b146100cf5780632ff71e47146101075780634377f1901461013b575b34801561009257600080fd5b600080fd5b3480156100a357600080fd5b506006546100b19060e01b81565b6040516001600160e01b031990911681526020015b60405180910390f35b3480156100db57600080fd5b506003546100ef906001600160a01b031681565b6040516001600160a01b0390911681526020016100c6565b34801561011357600080fd5b5060055461012890600160801b9004600f0b81565b604051600f9190910b81526020016100c6565b34801561014757600080fd5b506000546100ef906001600160a01b031681565b34801561016757600080fd5b5060055461012890600f0b81565b34801561018157600080fd5b506001546100ef906001600160a01b031681565b6101a86101a3366004610578565b6101dd565b005b3480156101b657600080fd5b506004546100ef906001600160a01b031681565b6101a86101d8366004610629565b610274565b6002546040516001600160a01b03909116903480156108fc02916000818181858888f150506002546004805460405163095ea7b360e01b81526001600160a01b0391821692810192909252346024830152909116935063095ea7b392506044019050600060405180830381600087803b15801561025957600080fd5b505af115801561026d573d6000803e3d6000fd5b5050505050565b6000546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd906064016020604051808303816000875af11580156102cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ef9190610665565b5060006102fd600084610389565b600154600254919250600091610324916001600160a01b0390811691168486610bb8610459565b600254604051632e1a7d4d60e01b8152600481018390529192506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561036b57600080fd5b505af115801561037f573d6000803e3d6000fd5b5050505050505050565b600080600084156103ad575050600554600f81810b91600160801b9004900b6103c2565b5050600554600160801b8104600f90810b91900b5b6003546040516322770cc360e11b8152600f84810b600483015283900b602482015260448101869052600060648201523060848201526001600160a01b03909116906344ee19869060a4016020604051808303816000875af115801561042c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610450919061068e565b50505092915050565b60408051610100810182526001600160a01b0387811682528681166020830190815262ffffff85811684860190815287841660608601908152426080870190815260a087018b8152600060c0890181815260e08a01828152600480549c5163414bf38960e01b81528c518c169181019190915298518a1660248a015295519096166044880152925187166064870152905160848601525160a4850152915160c484015251831660e4830152938492169063414bf38990610104016020604051808303816000875af1158015610532573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610556919061068e565b98975050505050505050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561058a57600080fd5b813567ffffffffffffffff808211156105a257600080fd5b818401915084601f8301126105b657600080fd5b8135818111156105c8576105c8610562565b604051601f8201601f19908116603f011681019083821181831017156105f0576105f0610562565b8160405282815287602084870101111561060957600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806040838503121561063c57600080fd5b8235915060208301356001600160a01b038116811461065a57600080fd5b809150509250929050565b60006020828403121561067757600080fd5b8151801515811461068757600080fd5b9392505050565b6000602082840312156106a057600080fd5b505191905056fea26469706673582212205c26b855e87fd5e6c021fdae367f73a0a7fc69a0e827a093902d2984180fb77e64736f6c63430008110033

Deployed Bytecode

0x6080604052600436106100865760003560e01c806378969a6a1161005957806378969a6a1461015b578063bdd5915f14610175578063d347f61614610195578063d8264920146101aa578063f32622f2146101ca57610086565b806309128a211461009757806311f1002b146100cf5780632ff71e47146101075780634377f1901461013b575b34801561009257600080fd5b600080fd5b3480156100a357600080fd5b506006546100b19060e01b81565b6040516001600160e01b031990911681526020015b60405180910390f35b3480156100db57600080fd5b506003546100ef906001600160a01b031681565b6040516001600160a01b0390911681526020016100c6565b34801561011357600080fd5b5060055461012890600160801b9004600f0b81565b604051600f9190910b81526020016100c6565b34801561014757600080fd5b506000546100ef906001600160a01b031681565b34801561016757600080fd5b5060055461012890600f0b81565b34801561018157600080fd5b506001546100ef906001600160a01b031681565b6101a86101a3366004610578565b6101dd565b005b3480156101b657600080fd5b506004546100ef906001600160a01b031681565b6101a86101d8366004610629565b610274565b6002546040516001600160a01b03909116903480156108fc02916000818181858888f150506002546004805460405163095ea7b360e01b81526001600160a01b0391821692810192909252346024830152909116935063095ea7b392506044019050600060405180830381600087803b15801561025957600080fd5b505af115801561026d573d6000803e3d6000fd5b5050505050565b6000546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd906064016020604051808303816000875af11580156102cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ef9190610665565b5060006102fd600084610389565b600154600254919250600091610324916001600160a01b0390811691168486610bb8610459565b600254604051632e1a7d4d60e01b8152600481018390529192506001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561036b57600080fd5b505af115801561037f573d6000803e3d6000fd5b5050505050505050565b600080600084156103ad575050600554600f81810b91600160801b9004900b6103c2565b5050600554600160801b8104600f90810b91900b5b6003546040516322770cc360e11b8152600f84810b600483015283900b602482015260448101869052600060648201523060848201526001600160a01b03909116906344ee19869060a4016020604051808303816000875af115801561042c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610450919061068e565b50505092915050565b60408051610100810182526001600160a01b0387811682528681166020830190815262ffffff85811684860190815287841660608601908152426080870190815260a087018b8152600060c0890181815260e08a01828152600480549c5163414bf38960e01b81528c518c169181019190915298518a1660248a015295519096166044880152925187166064870152905160848601525160a4850152915160c484015251831660e4830152938492169063414bf38990610104016020604051808303816000875af1158015610532573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610556919061068e565b98975050505050505050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561058a57600080fd5b813567ffffffffffffffff808211156105a257600080fd5b818401915084601f8301126105b657600080fd5b8135818111156105c8576105c8610562565b604051601f8201601f19908116603f011681019083821181831017156105f0576105f0610562565b8160405282815287602084870101111561060957600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806040838503121561063c57600080fd5b8235915060208301356001600160a01b038116811461065a57600080fd5b809150509250929050565b60006020828403121561067757600080fd5b8151801515811461068757600080fd5b9392505050565b6000602082840312156106a057600080fd5b505191905056fea26469706673582212205c26b855e87fd5e6c021fdae367f73a0a7fc69a0e827a093902d2984180fb77e64736f6c63430008110033

Deployed Bytecode Sourcemap

1245:3351:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1305:8;;;1891:46;;;;;;;;;;-1:-1:-1;1891:46:0;;;;;;;;;;;-1:-1:-1;;;;;;176:33:1;;;158:52;;146:2;131:18;1891:46:0;;;;;;;;1617:85;;;;;;;;;;-1:-1:-1;1617:85:0;;;;-1:-1:-1;;;;;1617:85:0;;;;;;-1:-1:-1;;;;;385:32:1;;;367:51;;355:2;340:18;1617:85:0;221:203:1;1844:34:0;;;;;;;;;;-1:-1:-1;1844:34:0;;;;-1:-1:-1;;;1844:34:0;;;;;;;;;602:2:1;591:22;;;;573:41;;561:2;546:18;1844:34:0;429:191:1;1341:81:0;;;;;;;;;;-1:-1:-1;1341:81:0;;;;-1:-1:-1;;;;;1341:81:0;;;1803:34;;;;;;;;;;-1:-1:-1;1803:34:0;;;;;;;;1430:81;;;;;;;;;;-1:-1:-1;1430:81:0;;;;-1:-1:-1;;;;;1430:81:0;;;2674:824;;;;;;:::i;:::-;;:::i;:::-;;1709:85;;;;;;;;;;-1:-1:-1;1709:85:0;;;;-1:-1:-1;;;;;1709:85:0;;;2081:559;;;;;;:::i;:::-;;:::i;2674:824::-;2749:12;;:28;;-1:-1:-1;;;;;2749:12:0;;;;2767:9;2749:28;;;;;:12;:28;:12;:28;2767:9;2749:12;:28;;-1:-1:-1;;2793:12:0;;2815:14;;;2788:53;;-1:-1:-1;;;2788:53:0;;-1:-1:-1;;;;;2815:14:0;;;2788:53;;;2225:51:1;;;;2831:9:0;2292:18:1;;;2285:34;2793:12:0;;;;-1:-1:-1;2788:26:0;;-1:-1:-1;2198:18:1;;;-1:-1:-1;2788:53:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2674:824;:::o;2081:559::-;2185:12;;2179:67;;-1:-1:-1;;;2179:67:0;;2212:10;2179:67;;;2570:34:1;2232:4:0;2620:18:1;;;2613:43;2672:18;;;2665:34;;;-1:-1:-1;;;;;2185:12:0;;;;2179:32;;2505:18:1;;2179:67:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;2291:19;2313:61;2337:5;2357:6;2313:9;:61::i;:::-;2462:12;;2489;;2291:83;;-1:-1:-1;2420:17:0;;2440:141;;-1:-1:-1;;;;;2462:12:0;;;;2489;2291:83;2542:9;2566:4;2440:7;:141::i;:::-;2599:12;;2594:38;;-1:-1:-1;;;2594:38:0;;;;;3138:25:1;;;2420:161:0;;-1:-1:-1;;;;;;2599:12:0;;2594:27;;3111:18:1;;2594:38:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2168:472;;2081:559;;:::o;4143:446::-;4211:7;4236:8;4255;4280:4;4276:207;;;-1:-1:-1;;4314:16:0;;;;;;;-1:-1:-1;;;4349:16:0;;;;4276:207;;;-1:-1:-1;;4420:16:0;;-1:-1:-1;;;4420:16:0;;;;;;;4455;;4276:207;4509:15;;4503:78;;-1:-1:-1;;;4503:78:0;;3466:2:1;3455:22;;;4503:78:0;;;3437:41:1;3514:22;;;3494:18;;;3487:50;3553:18;;;3546:34;;;4509:15:0;3596:18:1;;;3589:34;4575:4:0;3639:19:1;;;3632:61;-1:-1:-1;;;;;4509:15:0;;;;4503:42;;3409:19:1;;4503:78:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;4225:364;;4143:446;;;;:::o;3535:586::-;3780:219;;;;;;;;-1:-1:-1;;;;;3780:219:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3918:15;3780:219;;;;;;;;;;;;-1:-1:-1;3780:219:0;;;;;;;;;;;;4046:14;;;4032:54;;-1:-1:-1;;;4032:54:0;;4176:13:1;;4172:22;;4032:54:0;;;4154:41:1;;;;4237:24;;4233:33;;4211:20;;;4204:63;4309:24;;4305:39;;;4283:20;;;4276:69;4387:24;;4383:33;;4361:20;;;4354:63;4455:24;;4433:20;;;4426:54;4518:24;4496:20;;;4489:54;4581:24;;4559:20;;;4552:54;4648:24;4644:33;;4622:20;;;4615:63;-1:-1:-1;;;4046:14:0;;4032:46;;4088:19:1;;4032:54:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;4012:74;3535:586;-1:-1:-1;;;;;;;;3535:586:0:o;625:127:1:-;686:10;681:3;677:20;674:1;667:31;717:4;714:1;707:15;741:4;738:1;731:15;757:922;826:6;879:2;867:9;858:7;854:23;850:32;847:52;;;895:1;892;885:12;847:52;935:9;922:23;964:18;1005:2;997:6;994:14;991:34;;;1021:1;1018;1011:12;991:34;1059:6;1048:9;1044:22;1034:32;;1104:7;1097:4;1093:2;1089:13;1085:27;1075:55;;1126:1;1123;1116:12;1075:55;1162:2;1149:16;1184:2;1180;1177:10;1174:36;;;1190:18;;:::i;:::-;1265:2;1259:9;1233:2;1319:13;;-1:-1:-1;;1315:22:1;;;1339:2;1311:31;1307:40;1295:53;;;1363:18;;;1383:22;;;1360:46;1357:72;;;1409:18;;:::i;:::-;1449:10;1445:2;1438:22;1484:2;1476:6;1469:18;1524:7;1519:2;1514;1510;1506:11;1502:20;1499:33;1496:53;;;1545:1;1542;1535:12;1496:53;1601:2;1596;1592;1588:11;1583:2;1575:6;1571:15;1558:46;1646:1;1624:15;;;1641:2;1620:24;1613:35;;;;-1:-1:-1;1628:6:1;757:922;-1:-1:-1;;;;;757:922:1:o;1684:362::-;1760:6;1768;1821:2;1809:9;1800:7;1796:23;1792:32;1789:52;;;1837:1;1834;1827:12;1789:52;1860:23;;;-1:-1:-1;1933:2:1;1918:18;;1905:32;-1:-1:-1;;;;;1966:31:1;;1956:42;;1946:70;;2012:1;2009;2002:12;1946:70;2035:5;2025:15;;;1684:362;;;;;:::o;2710:277::-;2777:6;2830:2;2818:9;2809:7;2805:23;2801:32;2798:52;;;2846:1;2843;2836:12;2798:52;2878:9;2872:16;2931:5;2924:13;2917:21;2910:5;2907:32;2897:60;;2953:1;2950;2943:12;2897:60;2976:5;2710:277;-1:-1:-1;;;2710:277:1:o;3704:184::-;3774:6;3827:2;3815:9;3806:7;3802:23;3798:32;3795:52;;;3843:1;3840;3833:12;3795:52;-1:-1:-1;3866:16:1;;3704:184;-1:-1:-1;3704:184:1:o

Swarm Source

ipfs://5c26b855e87fd5e6c021fdae367f73a0a7fc69a0e827a093902d2984180fb77e

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.