Skip to content
Verified contractExactMIT

DOPELocker

Address0xe308bfb5c8bd665d5df8609ace05aaa45d3251c9
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
21,250,889
Creation transaction
0x277981e2bb…d1a386f8b1

contracts/externalStuff/DOPELocker.sol

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

interface IERC20 {
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
}

interface IERC20Metadata {
    function decimals() external view returns (uint8);
}

interface IUniswapV2Pair {
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function token0() external view returns (address);
    function token1() external view returns (address);
}

contract DOPELocker {
    address public constant TOKEN = 0x85122dc2c0AC24e8aAcafF4a4cCFcbdf36e80f60;
    address public constant TOKEN_WETH_PAIR = 0x1E4B11172868c96897F55ca55518B7DA6917158d;
    address public constant WETH_USDC_PAIR = 0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc;
    address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    address public constant AUTHORIZED_WITHDRAWER = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045;
    
    uint256 public constant TOTAL_SUPPLY = 1000000000 * 1e18; // 1B tokens in 1e18
    uint256 public constant TARGET_MARKET_CAP = 1000000000 * 1e18; // $1B in 1e18

    event TokensReceived(address indexed sender, uint256 amount);
    event TokensWithdrawn(address indexed withdrawer, uint256 amount);

    function adjustDecimals(uint256 amount, address tokenIn, address tokenOut) internal view returns (uint256) {
        uint256 decimalsIn = IERC20Metadata(tokenIn).decimals();
        uint256 decimalsOut = IERC20Metadata(tokenOut).decimals();
        if (decimalsIn == decimalsOut) {
            return amount;
        } else if (decimalsIn > decimalsOut) {
            return amount / (10 ** (decimalsIn - decimalsOut));
        } else {
            return amount * (10 ** (decimalsOut - decimalsIn));
        }
    }

    function getTokenPriceInUSDC() public view returns (uint256) {
        // Get WETH/USDC reserves and adjust USDC to 18 decimals
        IUniswapV2Pair wethUsdcPair = IUniswapV2Pair(WETH_USDC_PAIR);
        (uint256 wethUsdcReserve, uint256 usdcReserve,) = wethUsdcPair.getReserves();
        usdcReserve = adjustDecimals(usdcReserve, USDC, WETH); // Convert USDC to 18 decimals

        // Get TOKEN/WETH reserves (both already 18 decimals)
        IUniswapV2Pair tokenWethPair = IUniswapV2Pair(TOKEN_WETH_PAIR);
        (uint256 reserve0, uint256 reserve1,) = tokenWethPair.getReserves();
        bool isToken0 = tokenWethPair.token0() == TOKEN;
        uint256 tokenReserve = isToken0 ? reserve0 : reserve1;
        uint256 wethReserve = isToken0 ? reserve1 : reserve0;

        // Calculate price in 1e18 format
        uint256 tokenPriceInWeth = (wethReserve * 1e18) / tokenReserve;
        uint256 wethPriceInUsdc = (usdcReserve * 1e18) / wethUsdcReserve;
        uint256 tokenPriceIn18 = (tokenPriceInWeth * wethPriceInUsdc) / 1e18;

        // Convert final price to USDC decimals
        return adjustDecimals(tokenPriceIn18, WETH, USDC);
    }

    function getCurrentMarketCap() public view returns (uint256) {
        // Get price in USDC decimals and convert to 1e18 for calculation
        uint256 priceInUsdc = getTokenPriceInUSDC();
        uint256 priceIn18 = adjustDecimals(priceInUsdc, USDC, WETH);
        
        // Calculate market cap in 1e18
        return (TOTAL_SUPPLY * priceIn18) / 1e18;
    }

    function canWithdraw() public view returns (bool) {
        return getCurrentMarketCap() >= TARGET_MARKET_CAP;
    }

    function withdraw() external {
        require(msg.sender == AUTHORIZED_WITHDRAWER, "Not authorized");
        require(canWithdraw(), "Market cap condition not met");

        IERC20 token = IERC20(TOKEN);
        uint256 balance = token.balanceOf(address(this));
        require(balance > 0, "No tokens to withdraw");

        require(token.transfer(AUTHORIZED_WITHDRAWER, balance), "Transfer failed");
        emit TokensWithdrawn(AUTHORIZED_WITHDRAWER, balance);
    }

    function getStatus() external view returns (
        uint256 tokenPriceInUSDC,
        uint256 currentMarketCap,
        uint256 targetMarketCap,
        bool withdrawalAllowed
    ) {
        tokenPriceInUSDC = getTokenPriceInUSDC();
        currentMarketCap = adjustDecimals(getCurrentMarketCap(), WETH, USDC); // Convert to USDC decimals for display
        targetMarketCap = adjustDecimals(TARGET_MARKET_CAP, WETH, USDC); // Convert to USDC decimals for display
        withdrawalAllowed = canWithdraw();
    }

    receive() external payable {
        revert("Do not send ETH");
    }

    fallback() external payable {
        revert("Do not send ETH");
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.