ETH Price: $3,673.02 (+0.91%)

Token

ERC-20: Verse Exchange (VERSE-X)
 

Overview

Max Total Supply

570,912.180547818934548187 VERSE-X

Holders

1,789

Market

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 18 Decimals)

Filtered by Token Holder
moradi1990.eth
Balance
0.126444164997815263 VERSE-X

Value
$0.00
0x894C933C4113fA86a84262F12610d4e8266e9194
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Minimal Proxy Contract for 0x7290367aa694703220516a35e68e3d339ee7d193

Contract Name:
SwapsPair

Compiler Version
v0.8.14+commit.80d49f37

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity Multiple files format)

File 5 of 5: SwapsPair.sol
// SPDX-License-Identifier: BCOM

pragma solidity =0.8.14;

import "./IERC20.sol";
import "./ISwapsFactory.sol";
import "./ISwapsCallee.sol";
import "./SwapsERC20.sol";

contract SwapsPair is SwapsERC20 {

    uint224 constant Q112 = 2 ** 112;
    uint112 constant UINT112_MAX = type(uint112).max;
    uint256 public constant MINIMUM_LIQUIDITY = 10 ** 3;

    bytes4 private constant SELECTOR = bytes4(
        keccak256(bytes('transfer(address,uint256)'))
    );

    address public factory;
    address public token0;
    address public token1;

    uint112 private reserve0;
    uint112 private reserve1;
    uint32  private blockTimestampLast;

    uint256 public price0CumulativeLast;
    uint256 public price1CumulativeLast;

    uint256 public kLast;
    uint256 private unlocked;

    modifier lock() {
        require(
            unlocked == 1,
            "SwapsPair: LOCKED"
        );
        unlocked = 0;
        _;
        unlocked = 1;
    }

    event Mint(
        address indexed sender,
        uint256 amount0,
        uint256 amount1
    );

    event Burn(
        address indexed sender,
        uint256 amount0,
        uint256 amount1,
        address indexed to
    );

    event Swap(
        address indexed sender,
        uint256 amount0In,
        uint256 amount1In,
        uint256 amount0Out,
        uint256 amount1Out,
        address indexed to
    );

    event Sync(
        uint112 reserve0,
        uint112 reserve1
    );

    function initialize(
        address _token0,
        address _token1
    )
        external
    {
        require(
            factory == ZERO_ADDRESS,
            "SwapsPair: ALREADY_INITIALIZED"
        );

        token0 = _token0;
        token1 = _token1;
        factory = msg.sender;
        unlocked = 1;
    }

    function getReserves()
        public
        view
        returns (
            uint112,
            uint112,
            uint32
        )
    {
        return (
            reserve0,
            reserve1,
            blockTimestampLast
        );
    }

    function _update(
        uint256 _balance0,
        uint256 _balance1,
        uint112 _reserve0,
        uint112 _reserve1
    )
        private
    {
        require(
            _balance0 <= UINT112_MAX &&
            _balance1 <= UINT112_MAX,
            "SwapsPair: OVERFLOW"
        );

        uint32 blockTimestamp = uint32(block.timestamp % 2 ** 32);

        unchecked {
            uint32 timeElapsed = blockTimestamp - blockTimestampLast;
            if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
                price0CumulativeLast += uint256(uqdiv(encode(_reserve1), _reserve0)) * timeElapsed;
                price1CumulativeLast += uint256(uqdiv(encode(_reserve0), _reserve1)) * timeElapsed;
            }
        }

        reserve0 = uint112(_balance0);
        reserve1 = uint112(_balance1);

        blockTimestampLast = blockTimestamp;

        emit Sync(
            reserve0,
            reserve1
        );
    }

    function _mintFee(
        uint112 _reserve0,
        uint112 _reserve1,
        uint256 _kLast
    )
        private
    {
        if (_kLast == 0) return;

        uint256 rootK = sqrt(uint256(_reserve0) * _reserve1);
        uint256 rootKLast = sqrt(_kLast);

        if (rootK > rootKLast) {

            uint256 liquidity = totalSupply
                * (rootK - rootKLast)
                / (rootK * 5 + rootKLast);

            if (liquidity == 0) return;

            _mint(
                ISwapsFactory(factory).feeTo(),
                liquidity
            );
        }
    }

    function mint(
        address _to
    )
        external
        lock
        returns (uint256 liquidity)
    {
        (
            uint112 _reserve0,
            uint112 _reserve1,

        ) = getReserves();

        uint256 balance0 = IERC20(token0).balanceOf(address(this));
        uint256 balance1 = IERC20(token1).balanceOf(address(this));

        uint256 amount0 = balance0 - _reserve0;
        uint256 amount1 = balance1 - _reserve1;

        _mintFee(
            _reserve0,
            _reserve1,
            kLast
        );

        uint256 _totalSupply = totalSupply;

        if (_totalSupply == 0) {

            liquidity = sqrt(
                amount0 * amount1
            ) - MINIMUM_LIQUIDITY;

            _mint(
               ZERO_ADDRESS,
               MINIMUM_LIQUIDITY
            );

        } else {

            liquidity = min(
                amount0 * _totalSupply / _reserve0,
                amount1 * _totalSupply / _reserve1
            );
        }

        require(
            liquidity > 0,
            "INSUFFICIENT_LIQUIDITY_MINTED"
        );

        _mint(
            _to,
            liquidity
        );

        _update(
            balance0,
            balance1,
            _reserve0,
            _reserve1
        );

        kLast = uint256(reserve0) * reserve1;

        emit Mint(
            msg.sender,
            amount0,
            amount1
        );
    }

    function burn(
        address _to
    )
        external
        lock
        returns (
            uint256 amount0,
            uint256 amount1
        )
    {
        (
            uint112 _reserve0,
            uint112 _reserve1,

        ) = getReserves();

        address _token0 = token0;
        address _token1 = token1;

        uint256 balance0 = IERC20(_token0).balanceOf(address(this));
        uint256 balance1 = IERC20(_token1).balanceOf(address(this));

        uint256 liquidity = balanceOf[address(this)];

        _mintFee(
            _reserve0,
            _reserve1,
            kLast
        );

        uint256 _totalSupply = totalSupply;

        amount0 = liquidity * balance0 / _totalSupply;
        amount1 = liquidity * balance1 / _totalSupply;

        require(
            amount0 > 0 &&
            amount1 > 0,
            "INSUFFICIENT_LIQUIDITY_BURNED"
        );

        _burn(
            address(this),
            liquidity
        );

        _safeTransfer(
            _token0,
            _to,
            amount0
        );

        _safeTransfer(
            _token1,
            _to,
            amount1
        );

        balance0 = IERC20(_token0).balanceOf(address(this));
        balance1 = IERC20(_token1).balanceOf(address(this));

        _update(
            balance0,
            balance1,
            _reserve0,
            _reserve1
        );

        kLast = uint256(reserve0) * reserve1;

        emit Burn(
            msg.sender,
            amount0,
            amount1,
            _to
        );
    }

    function swap(
        uint256 _amount0Out,
        uint256 _amount1Out,
        address _to,
        bytes calldata _data
    )
        external
        lock
    {
        require(
            _amount0Out > 0 ||
            _amount1Out > 0,
            "INSUFFICIENT_OUTPUT_AMOUNT"
        );

        (
            uint112 _reserve0,
            uint112 _reserve1,

        ) = getReserves();

        require(
            _amount0Out < _reserve0 &&
            _amount1Out < _reserve1,
            "INSUFFICIENT_LIQUIDITY"
        );

        uint256 balance0;
        uint256 balance1;

        {
            address _token0 = token0;
            address _token1 = token1;

            if (_amount0Out > 0) _safeTransfer(_token0, _to, _amount0Out);
            if (_amount1Out > 0) _safeTransfer(_token1, _to, _amount1Out);

            if (_data.length > 0) ISwapsCallee(_to).swapsCall(
                msg.sender,
                _amount0Out,
                _amount1Out,
                _data
            );

            balance0 = IERC20(_token0).balanceOf(address(this));
            balance1 = IERC20(_token1).balanceOf(address(this));
        }

        uint256 _amount0In =
            balance0 > _reserve0 - _amount0Out ?
            balance0 - (_reserve0 - _amount0Out) : 0;

        uint256 _amount1In =
            balance1 > _reserve1 - _amount1Out ?
            balance1 - (_reserve1 - _amount1Out) : 0;

        require(
            _amount0In > 0 ||
            _amount1In > 0,
            "INSUFFICIENT_INPUT_AMOUNT"
        );

        {
            uint256 balance0Adjusted = balance0 * 1000 - (_amount0In * 3);
            uint256 balance1Adjusted = balance1 * 1000 - (_amount1In * 3);

            require(
                balance0Adjusted * balance1Adjusted >=
                uint256(_reserve0)
                    * _reserve1
                    * (1000 ** 2)
            );
        }

        _update(
            balance0,
            balance1,
            _reserve0,
            _reserve1
        );

        emit Swap(
            msg.sender,
            _amount0In,
            _amount1In,
            _amount0Out,
            _amount1Out,
            _to
        );
    }

    function skim()
        external
        lock
    {
        address _token0 = token0;
        address _token1 = token1;
        address _feesTo = ISwapsFactory(factory).feeTo();

        _safeTransfer(
            _token0,
            _feesTo,
            IERC20(_token0).balanceOf(address(this)) - reserve0
        );

        _safeTransfer(
            _token1,
            _feesTo,
            IERC20(_token1).balanceOf(address(this)) - reserve1
        );
    }

    function sync()
        external
        lock
    {
        _update(
            IERC20(token0).balanceOf(address(this)),
            IERC20(token1).balanceOf(address(this)),
            reserve0,
            reserve1
        );
    }

    function encode(
        uint112 _y
    )
        pure
        internal
        returns (uint224 z)
    {
        unchecked {
            z = uint224(_y) * Q112;
        }
    }

    function uqdiv(
        uint224 _x,
        uint112 _y
    )
        pure
        internal
        returns (uint224 z)
    {
        unchecked {
            z = _x / uint224(_y);
        }
    }

    function min(
        uint256 _x,
        uint256 _y
    )
        internal
        pure
        returns (uint256 z)
    {
        z = _x < _y ? _x : _y;
    }

    function sqrt(
        uint256 _y
    )
        internal
        pure
        returns (uint256 z)
    {
        unchecked {
            if (_y > 3) {
                z = _y;
                uint256 x = _y / 2 + 1;
                while (x < z) {
                    z = x;
                    x = (_y / x + x) / 2;
                }
            } else if (_y != 0) {
                z = 1;
            }
        }
    }

    function _safeTransfer(
        address _token,
        address _to,
        uint256 _value
    )
        internal
    {
        (bool success, bytes memory data) = _token.call(
            abi.encodeWithSelector(
                SELECTOR,
                _to,
                _value
            )
        );

        require(
            success && (
                data.length == 0 || abi.decode(
                    data, (bool)
                )
            ),
            "SwapsPair: TRANSFER_FAILED"
        );
    }
}

File 1 of 5: IERC20.sol
// SPDX-License-Identifier: BCOM

pragma solidity =0.8.14;

interface IERC20 {

    function balanceOf(
        address _owner
    )
        external
        view
        returns (uint256);
}

File 2 of 5: ISwapsCallee.sol
// SPDX-License-Identifier: BCOM

pragma solidity =0.8.14;

interface ISwapsCallee {

    function swapsCall(
        address _sender,
        uint256 _amount0,
        uint256 _amount1,
        bytes calldata _data
    )
        external;
}

File 3 of 5: ISwapsFactory.sol
// SPDX-License-Identifier: BCOM

pragma solidity =0.8.14;

interface ISwapsFactory {

    function feeTo()
        external
        view
        returns (address);

    function feeToSetter()
        external
        view
        returns (address);

    function getPair(
        address _tokenA,
        address _tokenB
    )
        external
        view
        returns (address pair);

    function allPairs(uint256)
        external
        view
        returns (address pair);

    function allPairsLength()
        external
        view
        returns (uint256);

    function createPair(
        address _tokenA,
        address _tokenB
    )
        external
        returns (address pair);

    function setFeeTo(
        address
    )
        external;

    function setFeeToSetter(
        address
    )
        external;

    function cloneTarget()
        external
        view
        returns (address target);
}

File 4 of 5: SwapsERC20.sol
// SPDX-License-Identifier: BCOM

pragma solidity =0.8.14;

contract SwapsERC20 {

    string public constant name = "Verse Exchange";
    string public constant symbol = "VERSE-X";
    uint8 public constant decimals = 18;

    address constant ZERO_ADDRESS = address(0);
    uint256 constant UINT256_MAX = type(uint256).max;

    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;
    mapping(address => uint256) public nonces;

    bytes32 public immutable DOMAIN_SEPARATOR;
    bytes32 public constant PERMIT_TYPEHASH = keccak256(
        "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
    );

    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );

    event Transfer(
        address indexed from,
        address indexed to,
        uint256 value
    );

    constructor() {
        DOMAIN_SEPARATOR = keccak256(
            abi.encode(
                keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                keccak256(bytes(name)),
                keccak256(bytes("1")),
                block.chainid,
                address(this)
            )
        );
    }

    function _mint(
        address _to,
        uint256 _value
    )
        internal
    {
        totalSupply =
        totalSupply + _value;

        unchecked {
            balanceOf[_to] =
            balanceOf[_to] + _value;
        }

        emit Transfer(
            ZERO_ADDRESS,
            _to,
            _value
        );
    }

    function _burn(
        address _from,
        uint256 _value
    )
        internal
    {
        unchecked {
            totalSupply =
            totalSupply - _value;
        }

        balanceOf[_from] =
        balanceOf[_from] - _value;

        emit Transfer(
            _from,
            ZERO_ADDRESS,
            _value
        );
    }

    function _approve(
        address _owner,
        address _spender,
        uint256 _value
    )
        private
    {
        allowance[_owner][_spender] = _value;

        emit Approval(
            _owner,
            _spender,
            _value
        );
    }

    function _transfer(
        address _from,
        address _to,
        uint256 _value
    )
        private
    {
        balanceOf[_from] =
        balanceOf[_from] - _value;

        unchecked {
            balanceOf[_to] =
            balanceOf[_to] + _value;
        }

        emit Transfer(
            _from,
            _to,
            _value
        );
    }

    function approve(
        address _spender,
        uint256 _value
    )
        external
        returns (bool)
    {
        _approve(
            msg.sender,
            _spender,
            _value
        );

        return true;
    }

    function transfer(
        address _to,
        uint256 _value
    )
        external
        returns (bool)
    {
        _transfer(
            msg.sender,
            _to,
            _value
        );

        return true;
    }

    function transferFrom(
        address _from,
        address _to,
        uint256 _value
    )
        external
        returns (bool)
    {
        if (allowance[_from][msg.sender] != UINT256_MAX) {
            allowance[_from][msg.sender] -= _value;
        }

        _transfer(
            _from,
            _to,
            _value
        );

        return true;
    }

    function permit(
        address _owner,
        address _spender,
        uint256 _value,
        uint256 _deadline,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    )
        external
    {
        require(
            _deadline >= block.timestamp,
            "SwapsERC20: PERMIT_CALL_EXPIRED"
        );

        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                DOMAIN_SEPARATOR,
                keccak256(
                    abi.encode(
                        PERMIT_TYPEHASH,
                        _owner,
                        _spender,
                        _value,
                        nonces[_owner]++,
                        _deadline
                    )
                )
            )
        );

        if (uint256(_s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            revert("SwapsERC20: INVALID_SIGNATURE");
        }

        address recoveredAddress = ecrecover(
            digest,
            _v,
            _r,
            _s
        );

        require(
            recoveredAddress != ZERO_ADDRESS &&
            recoveredAddress == _owner,
            "SwapsERC20: INVALID_SIGNATURE"
        );

        _approve(
            _owner,
            _spender,
            _value
        );
    }
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0Out","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1Out","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint112","name":"reserve0","type":"uint112"},{"indexed":false,"internalType":"uint112","name":"reserve1","type":"uint112"}],"name":"Sync","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_LIQUIDITY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint112","name":"","type":"uint112"},{"internalType":"uint112","name":"","type":"uint112"},{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"kLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"price0CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price1CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"skim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount0Out","type":"uint256"},{"internalType":"uint256","name":"_amount1Out","type":"uint256"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sync","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]

Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.