Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xf1F47c798d77bADEe7B42fE215f55E4DA6319024
Balance 0 ETH
Nonce 1
Code Size 6297 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6297 bytes
0x608060405234801561000f575f80fd5b50600436106100a7575f3560e01c8063686843ef1161006f578063686843ef1461013f5780637535d2461461016f5780638357984f1461018d5780639d2475d5146101bf578063c54e44eb146101ef578063fa461e331461020d576100a7565b80630beaf38c146100ab5780631836e0da146100c9578063195cd92c146100e75780632b6e1923146101035780633aeef3d314610121575b5f80fd5b6100b3610229565b6040516100c09190610c9f565b60405180910390f35b6100d161024d565b6040516100de9190610cd8565b60405180910390f35b61010160048036038101906100fc9190610d8b565b610271565b005b61010b610324565b6040516101189190610dea565b60405180910390f35b6101296103c2565b6040516101369190610e1b565b60405180910390f35b61015960048036038101906101549190610e34565b6104a0565b6040516101669190610e1b565b60405180910390f35b6101776104f9565b6040516101849190610e7f565b60405180910390f35b6101a760048036038101906101a29190610e98565b61051d565b6040516101b693929190610f42565b60405180910390f35b6101d960048036038101906101d49190610fa8565b6109ae565b6040516101e69190610dea565b60405180910390f35b6101f76109d8565b6040516102049190610cd8565b60405180910390f35b61022760048036038101906102229190611034565b6109fc565b005b7f000000000000000000000000449d117117838ffa61263b61da6301aa2a88b13a81565b7f000000000000000000000000b58e61c3098d85632df34eecfb899a1ed80921cb81565b7f0000000000000000000000008e4318e2cb1ae291254b187001a59a1f8ac78cef73ffffffffffffffffffffffffffffffffffffffff1663128acb083385158585336040516020016102c391906110c5565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016102f29594939291906110ed565b5f604051808303815f87803b158015610309575f80fd5b505af115801561031b573d5f803e3d5ffd5b50505050505050565b5f807f0000000000000000000000008e4318e2cb1ae291254b187001a59a1f8ac78cef73ffffffffffffffffffffffffffffffffffffffff16633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa15801561038f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103b39190611210565b50505050505090508091505090565b5f807f000000000000000000000000449d117117838ffa61263b61da6301aa2a88b13a73ffffffffffffffffffffffffffffffffffffffff1663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa15801561042d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104519190611314565b5050509150505f8113610499576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610490906113e5565b60405180910390fd5b8091505090565b5f8060606402540be400846104b59190611430565b73ffffffffffffffffffffffffffffffffffffffff16901c73ffffffffffffffffffffffffffffffffffffffff16905080816104f19190611471565b915050919050565b7f0000000000000000000000008e4318e2cb1ae291254b187001a59a1f8ac78cef81565b5f8060605f61052a610324565b90505f6105356103c2565b90505f610541826109ae565b90505f8173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161090505f7f000000000000000000000000b58e61c3098d85632df34eecfb899a1ed80921cb73ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b81526004016105cf91906110c5565b6020604051808303815f875af11580156105eb573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061060f91906114b2565b90505f7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b815260040161066b91906110c5565b6020604051808303815f875af1158015610687573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106ab91906114b2565b90505f836106b957826106bb565b815b90507f0000000000000000000000008e4318e2cb1ae291254b187001a59a1f8ac78cef73ffffffffffffffffffffffffffffffffffffffff1663128acb0833861584893360405160200161070f91906110c5565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161073e9594939291906110ed565b5f604051808303815f87803b158015610755575f80fd5b505af1158015610767573d5f803e3d5ffd5b505050505f7f000000000000000000000000b58e61c3098d85632df34eecfb899a1ed80921cb73ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b81526004016107c591906110c5565b6020604051808303815f875af11580156107e1573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061080591906114b2565b90505f7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b815260040161086191906110c5565b6020604051808303815f875af115801561087d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108a191906114b2565b90505f85836108b091906114dd565b90505f85836108bf91906114dd565b90505f6305f5e1008b846108d3919061151d565b6108dd91906115c0565b64e8d4a51000836108ee919061151d565b6108f89190611628565b90508f811215610943578282826040517fce6556ff00000000000000000000000000000000000000000000000000000000815260040161093a93929190611669565b60405180910390fd5b7fd377cb87d4e56cb7dcd6e399ab32de22dbf66add0dae04568e4091504f481be761096d8d6104a0565b8c61097e610979610324565b6104a0565b8686866040516109939695949392919061169e565b60405180910390a15050505050505050505050509193909250565b5f8060c083901b90506402540be4006109c682610bc9565b6109d091906116fd565b915050919050565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b7f0000000000000000000000008e4318e2cb1ae291254b187001a59a1f8ac78cef73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8190611777565b60405180910390fd5b5f8282810190610a9a91906117d0565b90505f851315610b2f577f000000000000000000000000b58e61c3098d85632df34eecfb899a1ed80921cb73ffffffffffffffffffffffffffffffffffffffff166323b872dd8233886040518463ffffffff1660e01b8152600401610b01939291906117fb565b5f604051808303815f87803b158015610b18575f80fd5b505af1158015610b2a573d5f803e3d5ffd5b505050505b5f841315610bc2577f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166323b872dd8233876040518463ffffffff1660e01b8152600401610b94939291906117fb565b5f604051808303815f87803b158015610bab575f80fd5b505af1158015610bbd573d5f803e3d5ffd5b505050505b5050505050565b5f806002600184610bda9190611830565b610be491906116fd565b90508291505b81811015610c1f578091506002818285610c0491906116fd565b610c0e9190611830565b610c1891906116fd565b9050610bea565b50919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f819050919050565b5f610c67610c62610c5d84610c25565b610c44565b610c25565b9050919050565b5f610c7882610c4d565b9050919050565b5f610c8982610c6e565b9050919050565b610c9981610c7f565b82525050565b5f602082019050610cb25f830184610c90565b92915050565b5f610cc282610c6e565b9050919050565b610cd281610cb8565b82525050565b5f602082019050610ceb5f830184610cc9565b92915050565b5f80fd5b5f80fd5b5f8115159050919050565b610d0d81610cf9565b8114610d17575f80fd5b50565b5f81359050610d2881610d04565b92915050565b5f819050919050565b610d4081610d2e565b8114610d4a575f80fd5b50565b5f81359050610d5b81610d37565b92915050565b610d6a81610c25565b8114610d74575f80fd5b50565b5f81359050610d8581610d61565b92915050565b5f805f60608486031215610da257610da1610cf1565b5b5f610daf86828701610d1a565b9350506020610dc086828701610d4d565b9250506040610dd186828701610d77565b9150509250925092565b610de481610c25565b82525050565b5f602082019050610dfd5f830184610ddb565b92915050565b5f819050919050565b610e1581610e03565b82525050565b5f602082019050610e2e5f830184610e0c565b92915050565b5f60208284031215610e4957610e48610cf1565b5b5f610e5684828501610d77565b91505092915050565b5f610e6982610c6e565b9050919050565b610e7981610e5f565b82525050565b5f602082019050610e925f830184610e70565b92915050565b5f60208284031215610ead57610eac610cf1565b5b5f610eba84828501610d4d565b91505092915050565b610ecc81610d2e565b82525050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f610f1482610ed2565b610f1e8185610edc565b9350610f2e818560208601610eec565b610f3781610efa565b840191505092915050565b5f606082019050610f555f830186610ec3565b610f626020830185610ddb565b8181036040830152610f748184610f0a565b9050949350505050565b610f8781610e03565b8114610f91575f80fd5b50565b5f81359050610fa281610f7e565b92915050565b5f60208284031215610fbd57610fbc610cf1565b5b5f610fca84828501610f94565b91505092915050565b5f80fd5b5f80fd5b5f80fd5b5f8083601f840112610ff457610ff3610fd3565b5b8235905067ffffffffffffffff81111561101157611010610fd7565b5b60208301915083600182028301111561102d5761102c610fdb565b5b9250929050565b5f805f806060858703121561104c5761104b610cf1565b5b5f61105987828801610d4d565b945050602061106a87828801610d4d565b935050604085013567ffffffffffffffff81111561108b5761108a610cf5565b5b61109787828801610fdf565b925092505092959194509250565b5f6110af82610c25565b9050919050565b6110bf816110a5565b82525050565b5f6020820190506110d85f8301846110b6565b92915050565b6110e781610cf9565b82525050565b5f60a0820190506111005f8301886110b6565b61110d60208301876110de565b61111a6040830186610ec3565b6111276060830185610ddb565b81810360808301526111398184610f0a565b90509695505050505050565b5f8151905061115381610d61565b92915050565b5f8160020b9050919050565b61116e81611159565b8114611178575f80fd5b50565b5f8151905061118981611165565b92915050565b5f61ffff82169050919050565b6111a58161118f565b81146111af575f80fd5b50565b5f815190506111c08161119c565b92915050565b5f60ff82169050919050565b6111db816111c6565b81146111e5575f80fd5b50565b5f815190506111f6816111d2565b92915050565b5f8151905061120a81610d04565b92915050565b5f805f805f805f60e0888a03121561122b5761122a610cf1565b5b5f6112388a828b01611145565b97505060206112498a828b0161117b565b965050604061125a8a828b016111b2565b955050606061126b8a828b016111b2565b945050608061127c8a828b016111b2565b93505060a061128d8a828b016111e8565b92505060c061129e8a828b016111fc565b91505092959891949750929550565b5f69ffffffffffffffffffff82169050919050565b6112cb816112ad565b81146112d5575f80fd5b50565b5f815190506112e6816112c2565b92915050565b5f815190506112fa81610d37565b92915050565b5f8151905061130e81610f7e565b92915050565b5f805f805f60a0868803121561132d5761132c610cf1565b5b5f61133a888289016112d8565b955050602061134b888289016112ec565b945050604061135c88828901611300565b935050606061136d88828901611300565b925050608061137e888289016112d8565b9150509295509295909350565b5f82825260208201905092915050565b7f496e76616c6964207072696365000000000000000000000000000000000000005f82015250565b5f6113cf600d8361138b565b91506113da8261139b565b602082019050919050565b5f6020820190508181035f8301526113fc816113c3565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61143a82610c25565b915061144583610c25565b925082820261145381610c25565b9150828204841483151761146a57611469611403565b5b5092915050565b5f61147b82610e03565b915061148683610e03565b925082820261149481610e03565b915082820484148315176114ab576114aa611403565b5b5092915050565b5f602082840312156114c7576114c6610cf1565b5b5f6114d484828501611300565b91505092915050565b5f6114e782610d2e565b91506114f283610d2e565b925082820390508181125f8412168282135f85121516171561151757611516611403565b5b92915050565b5f61152782610d2e565b915061153283610d2e565b925082820261154081610d2e565b91507f800000000000000000000000000000000000000000000000000000000000000084145f8412161561157757611576611403565b5b828205841483151761158c5761158b611403565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6115ca82610d2e565b91506115d583610d2e565b9250826115e5576115e4611593565b5b60015f0383147f80000000000000000000000000000000000000000000000000000000000000008314161561161d5761161c611403565b5b828205905092915050565b5f61163282610d2e565b915061163d83610d2e565b92508282019050828112155f8312168382125f84121516171561166357611662611403565b5b92915050565b5f60608201905061167c5f830186610ec3565b6116896020830185610ec3565b6116966040830184610ec3565b949350505050565b5f60c0820190506116b15f830189610e0c565b6116be6020830188610e0c565b6116cb6040830187610e0c565b6116d86060830186610ec3565b6116e56080830185610ec3565b6116f260a0830184610ec3565b979650505050505050565b5f61170782610e03565b915061171283610e03565b92508261172257611721611593565b5b828204905092915050565b7f556e617574686f72697a656400000000000000000000000000000000000000005f82015250565b5f611761600c8361138b565b915061176c8261172d565b602082019050919050565b5f6020820190508181035f83015261178e81611755565b9050919050565b5f61179f82610c25565b9050919050565b6117af81611795565b81146117b9575f80fd5b50565b5f813590506117ca816117a6565b92915050565b5f602082840312156117e5576117e4610cf1565b5b5f6117f2848285016117bc565b91505092915050565b5f60608201905061180e5f8301866110b6565b61181b60208301856110b6565b6118286040830184610e0c565b949350505050565b5f61183a82610e03565b915061184583610e03565b925082820190508082111561185d5761185c611403565b5b9291505056fea2646970667358221220473b3800d409a6a08f21f9d1eec70f323578aa1bfc77853fdc7829e2e73db47264736f6c634300081a0033

Verified Source Code Full Match

Compiler: v0.8.26+commit.8a97fa7a EVM: cancun Optimization: No
Arbitrage.sol 113 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IUniswapV3SwapCallback {
    function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external;
}

contract Arbitrage is IUniswapV3SwapCallback {

    IERC20 public immutable ZCHF;
    IERC20 public immutable USDT;

    IUniswapV3Pool public immutable POOL;
    AggregatorV3Interface public immutable FEED;

    event Balanced(uint256 priceBeforeE8, uint256 targetE8, uint256 priceAfterE8, int256 zchfFlowE18, int256 usdFlowE6, int256 profitsE6);
    error NotProfitableEnough(int256 zchfFlowE18, int256 usdFlowE6, int256 profitsE6);

    constructor() {
        POOL = IUniswapV3Pool(0x8E4318E2cb1ae291254B187001a59a1f8ac78cEF);
        FEED = AggregatorV3Interface(0x449d117117838fFA61263B61dA6301AA2a88B13A);
        ZCHF = IERC20(0xB58E61C3098d85632Df34EecfB899A1Ed80921cB);
        USDT = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7);
    }

    function getChainlinkPrice() public view returns (uint256) {
        (, int256 price,,,) = FEED.latestRoundData();
        require(price > 0, "Invalid price");
        return uint256(price); // 8 decimals
    }

    function convertToUniswapPrice(uint256 chainlinkPrice) public pure returns (uint160){
        uint256 temp = chainlinkPrice << 192; // should not cause overflow as 1e8 is much less than 256 - 192 = 64 bits, whereas chainlink's 8 decimals are about 24 bits
        return uint160(sqrt(temp) / 1e10);
    }

    function getUniswapPrice() public view returns (uint160) {
        (uint160 sqrtPriceX96,,,,,,) = POOL.slot0();
        return sqrtPriceX96;
    }

    function convertToChainlinkPrice(uint160 sqrtPriceX96) public pure returns (uint256){
        uint256 temp = sqrtPriceX96 * (1e10) >> 96;
        return temp * temp; // price ratio with 8 digits
    }

    function balance(int256 minProfitUSDTe6) external returns(int256, uint160, bytes memory) {
        uint160 currentPrice = getUniswapPrice();

        uint256 chainlinkPrice = getChainlinkPrice();
        uint160 targetSqrtPriceX96 = convertToUniswapPrice(chainlinkPrice);
        bool buyCHF = currentPrice < targetSqrtPriceX96;
        int256 balanceZCHFBefore = int256(ZCHF.balanceOf(msg.sender));
        int256 balanceUSDTBefore = int256(USDT.balanceOf(msg.sender));
        int256 max = buyCHF ? balanceUSDTBefore : balanceZCHFBefore;

        POOL.swap(msg.sender, !buyCHF, max, targetSqrtPriceX96, abi.encode(msg.sender));

        int256 balanceZCHFAfter = int256(ZCHF.balanceOf(msg.sender));
        int256 balanceUSDTAfter = int256(USDT.balanceOf(msg.sender));

        int256 flowCHF = balanceZCHFAfter - balanceZCHFBefore;
        int256 flowUSD = balanceUSDTAfter - balanceUSDTBefore;
        int256 profits = flowUSD * 1e12 + flowCHF * int256(uint256(chainlinkPrice)) / 1e8;
        if (profits < minProfitUSDTe6) revert NotProfitableEnough(flowCHF, flowUSD, profits);
        emit Balanced(convertToChainlinkPrice(currentPrice), chainlinkPrice, convertToChainlinkPrice(getUniswapPrice()), flowCHF, flowUSD, profits);
    }

    function swap(bool buyCHF, int256 max, uint160 targetPrice) external {
        POOL.swap(msg.sender, !buyCHF, max, targetPrice, abi.encode(msg.sender));
    }

    function sqrt(uint256 x) internal pure returns (uint256 y) {
        uint256 z = (x + 1) / 2;
        y = x;
        while (z < y) {
            y = z;
            z = (x / z + z) / 2;
        }
    }

    function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external {
        require(msg.sender == address(POOL), "Unauthorized");
        address sender = abi.decode(data, (address));
        if (amount0Delta > 0) {
            IERC20(ZCHF).transferFrom(sender, msg.sender, uint256(amount0Delta));
        }
        if (amount1Delta > 0) {
            IERC20(USDT).transferFrom(sender, msg.sender, uint256(amount1Delta));
        }
    }
}

interface IERC20 {
    function transferFrom(address sender, address recipient, uint256 amount) external;
    function balanceOf(address owner) external returns (uint256);
}

interface AggregatorV3Interface {
    function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80);
}

interface IUniswapV3Pool {
    function slot0() external view returns (uint160, int24, uint16, uint16, uint16, uint8, bool);

    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external;
}

Read Contract

FEED 0x0beaf38c → address
POOL 0x7535d246 → address
USDT 0xc54e44eb → address
ZCHF 0x1836e0da → address
convertToChainlinkPrice 0x686843ef → uint256
convertToUniswapPrice 0x9d2475d5 → uint160
getChainlinkPrice 0x3aeef3d3 → uint256
getUniswapPrice 0x2b6e1923 → uint160

Write Contract 3 functions

These functions modify contract state and require a wallet transaction to execute.

balance 0x8357984f
int256 minProfitUSDTe6
returns: int256, uint160, bytes
swap 0x195cd92c
bool buyCHF
int256 max
uint160 targetPrice
uniswapV3SwapCallback 0xfa461e33
int256 amount0Delta
int256 amount1Delta
bytes data

Recent Transactions

No transactions found for this address