ETH Price: $2,520.56 (-0.20%)

Contract

0x91E1c84BA8786B1FaE2570202F0126C0b88F6Ec7
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60a06040125847562021-06-07 2:27:381180 days ago1623032858IN
 Create: DODOV1Adapter
0 ETH0.0144316922

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
206369932024-08-29 21:42:356 hrs ago1724967755
0x91E1c84B...0b88F6Ec7
0 ETH
206369932024-08-29 21:42:356 hrs ago1724967755
0x91E1c84B...0b88F6Ec7
0 ETH
206369932024-08-29 21:42:356 hrs ago1724967755
0x91E1c84B...0b88F6Ec7
0 ETH
206369932024-08-29 21:42:356 hrs ago1724967755
0x91E1c84B...0b88F6Ec7
0 ETH
206369932024-08-29 21:42:356 hrs ago1724967755
0x91E1c84B...0b88F6Ec7
0 ETH
206369932024-08-29 21:42:356 hrs ago1724967755
0x91E1c84B...0b88F6Ec7
0 ETH
206369932024-08-29 21:42:356 hrs ago1724967755
0x91E1c84B...0b88F6Ec7
0 ETH
206369932024-08-29 21:42:356 hrs ago1724967755
0x91E1c84B...0b88F6Ec7
0 ETH
206342802024-08-29 12:36:2315 hrs ago1724934983
0x91E1c84B...0b88F6Ec7
0 ETH
206342802024-08-29 12:36:2315 hrs ago1724934983
0x91E1c84B...0b88F6Ec7
0 ETH
206342802024-08-29 12:36:2315 hrs ago1724934983
0x91E1c84B...0b88F6Ec7
0 ETH
206342802024-08-29 12:36:2315 hrs ago1724934983
0x91E1c84B...0b88F6Ec7
0 ETH
206342802024-08-29 12:36:2315 hrs ago1724934983
0x91E1c84B...0b88F6Ec7
0 ETH
206342802024-08-29 12:36:2315 hrs ago1724934983
0x91E1c84B...0b88F6Ec7
0 ETH
206342802024-08-29 12:36:2315 hrs ago1724934983
0x91E1c84B...0b88F6Ec7
0 ETH
206342802024-08-29 12:36:2315 hrs ago1724934983
0x91E1c84B...0b88F6Ec7
0 ETH
206340232024-08-29 11:44:4716 hrs ago1724931887
0x91E1c84B...0b88F6Ec7
0 ETH
206340232024-08-29 11:44:4716 hrs ago1724931887
0x91E1c84B...0b88F6Ec7
0 ETH
206340232024-08-29 11:44:4716 hrs ago1724931887
0x91E1c84B...0b88F6Ec7
0 ETH
206340232024-08-29 11:44:4716 hrs ago1724931887
0x91E1c84B...0b88F6Ec7
0 ETH
206340232024-08-29 11:44:4716 hrs ago1724931887
0x91E1c84B...0b88F6Ec7
0 ETH
206340232024-08-29 11:44:4716 hrs ago1724931887
0x91E1c84B...0b88F6Ec7
0 ETH
206340232024-08-29 11:44:4716 hrs ago1724931887
0x91E1c84B...0b88F6Ec7
0 ETH
206340232024-08-29 11:44:4716 hrs ago1724931887
0x91E1c84B...0b88F6Ec7
0 ETH
206315332024-08-29 3:22:3524 hrs ago1724901755
0x91E1c84B...0b88F6Ec7
0 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DODOV1Adapter

Compiler Version
v0.6.9+commit.3e3065ac

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, Apache-2.0 license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2024-06-21
*/

/**
 *Submitted for verification at optimistic.etherscan.io on 2022-04-18
*/

// File: contracts/intf/IERC20.sol

// This is a file copied from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.9;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    function decimals() external view returns (uint8);

    function name() external view returns (string memory);

    function symbol() external view returns (string memory);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);
}

// File: contracts/SmartRoute/intf/IDODOV1.sol



interface IDODOV1 {
    function init(
        address owner,
        address supervisor,
        address maintainer,
        address baseToken,
        address quoteToken,
        address oracle,
        uint256 lpFeeRate,
        uint256 mtFeeRate,
        uint256 k,
        uint256 gasPriceLimit
    ) external;

    function transferOwnership(address newOwner) external;

    function claimOwnership() external;

    function sellBaseToken(
        uint256 amount,
        uint256 minReceiveQuote,
        bytes calldata data
    ) external returns (uint256);

    function buyBaseToken(
        uint256 amount,
        uint256 maxPayQuote,
        bytes calldata data
    ) external returns (uint256);

    function querySellBaseToken(uint256 amount) external view returns (uint256 receiveQuote);

    function queryBuyBaseToken(uint256 amount) external view returns (uint256 payQuote);

    function depositBaseTo(address to, uint256 amount) external returns (uint256);

    function withdrawBase(uint256 amount) external returns (uint256);

    function withdrawAllBase() external returns (uint256);

    function depositQuoteTo(address to, uint256 amount) external returns (uint256);

    function withdrawQuote(uint256 amount) external returns (uint256);

    function withdrawAllQuote() external returns (uint256);

    function _BASE_CAPITAL_TOKEN_() external returns (address);

    function _QUOTE_CAPITAL_TOKEN_() external returns (address);

    function _BASE_TOKEN_() external view returns (address);

    function _QUOTE_TOKEN_() external view returns (address);

    function _R_STATUS_() external view returns (uint8);

    function _QUOTE_BALANCE_() external view returns (uint256);

    function _BASE_BALANCE_() external view returns (uint256);

    function _K_() external view returns (uint256);

    function _MT_FEE_RATE_() external view returns (uint256);

    function _LP_FEE_RATE_() external view returns (uint256);

    function getExpectedTarget() external view returns (uint256 baseTarget, uint256 quoteTarget);

    function getOraclePrice() external view returns (uint256);

    function getMidPrice() external view returns (uint256 midPrice); 
}

// File: contracts/lib/SafeMath.sol




/**
 * @title SafeMath
 * @author DODO Breeder
 *
 * @notice Math operations with safety checks that revert on error
 */
library SafeMath {
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "MUL_ERROR");

        return c;
    }

    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "DIVIDING_ERROR");
        return a / b;
    }

    function divCeil(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 quotient = div(a, b);
        uint256 remainder = a - quotient * b;
        if (remainder > 0) {
            return quotient + 1;
        } else {
            return quotient;
        }
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SUB_ERROR");
        return a - b;
    }

    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "ADD_ERROR");
        return c;
    }

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

// File: contracts/lib/SafeERC20.sol



/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
        );
    }

    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves.

        // A Solidity high level call has three parts:
        //  1. The target address is checked to verify it contains contract code
        //  2. The call itself is made, and success asserted
        //  3. The return value is decoded, which in turn checks the size of the returned data.
        // solhint-disable-next-line max-line-length

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success, "SafeERC20: low-level call failed");

        if (returndata.length > 0) {
            // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

// File: contracts/lib/DecimalMath.sol



/**
 * @title DecimalMath
 * @author DODO Breeder
 *
 * @notice Functions for fixed point number with 18 decimals
 */
library DecimalMath {
    using SafeMath for uint256;

    uint256 internal constant ONE = 10**18;
    uint256 internal constant ONE2 = 10**36;

    function mulFloor(uint256 target, uint256 d) internal pure returns (uint256) {
        return target.mul(d) / (10**18);
    }

    function mulCeil(uint256 target, uint256 d) internal pure returns (uint256) {
        return target.mul(d).divCeil(10**18);
    }

    function divFloor(uint256 target, uint256 d) internal pure returns (uint256) {
        return target.mul(10**18).div(d);
    }

    function divCeil(uint256 target, uint256 d) internal pure returns (uint256) {
        return target.mul(10**18).divCeil(d);
    }

    function reciprocalFloor(uint256 target) internal pure returns (uint256) {
        return uint256(10**36).div(target);
    }

    function reciprocalCeil(uint256 target) internal pure returns (uint256) {
        return uint256(10**36).divCeil(target);
    }

    function powFloor(uint256 target, uint256 e) internal pure returns (uint256) {
        if (e == 0) {
            return 10 ** 18;
        } else if (e == 1) {
            return target;
        } else {
            uint p = powFloor(target, e.div(2));
            p = p.mul(p) / (10**18);
            if (e % 2 == 1) {
                p = p.mul(target) / (10**18);
            }
            return p;
        }
    }
}

// File: contracts/SmartRoute/helper/DODOSellHelper.sol





// import {DODOMath} from "../lib/DODOMath.sol";

interface IDODOSellHelper {
    function querySellQuoteToken(address dodo, uint256 amount) external view returns (uint256);
    
    function querySellBaseToken(address dodo, uint256 amount) external view returns (uint256);
}

library DODOMath {
    using SafeMath for uint256;

    /*
        Integrate dodo curve fron V1 to V2
        require V0>=V1>=V2>0
        res = (1-k)i(V1-V2)+ikV0*V0(1/V2-1/V1)
        let V1-V2=delta
        res = i*delta*(1-k+k(V0^2/V1/V2))
    */
    function _GeneralIntegrate(
        uint256 V0,
        uint256 V1,
        uint256 V2,
        uint256 i,
        uint256 k
    ) internal pure returns (uint256) {
        uint256 fairAmount = DecimalMath.mulFloor(i, V1.sub(V2)); // i*delta
        uint256 V0V0V1V2 = DecimalMath.divCeil(V0.mul(V0).div(V1), V2);
        uint256 penalty = DecimalMath.mulFloor(k, V0V0V1V2); // k(V0^2/V1/V2)
        return DecimalMath.mulFloor(fairAmount, DecimalMath.ONE.sub(k).add(penalty));
    }

    /*
        The same with integration expression above, we have:
        i*deltaB = (Q2-Q1)*(1-k+kQ0^2/Q1/Q2)
        Given Q1 and deltaB, solve Q2
        This is a quadratic function and the standard version is
        aQ2^2 + bQ2 + c = 0, where
        a=1-k
        -b=(1-k)Q1-kQ0^2/Q1+i*deltaB
        c=-kQ0^2
        and Q2=(-b+sqrt(b^2+4(1-k)kQ0^2))/2(1-k)
        note: another root is negative, abondan
        if deltaBSig=true, then Q2>Q1
        if deltaBSig=false, then Q2<Q1
    */
    function _SolveQuadraticFunctionForTrade(
        uint256 Q0,
        uint256 Q1,
        uint256 ideltaB,
        bool deltaBSig,
        uint256 k
    ) internal pure returns (uint256) {
        // calculate -b value and sig
        // -b = (1-k)Q1-kQ0^2/Q1+i*deltaB
        uint256 kQ02Q1 = DecimalMath.mulFloor(k, Q0).mul(Q0).div(Q1); // kQ0^2/Q1
        uint256 b = DecimalMath.mulFloor(DecimalMath.ONE.sub(k), Q1); // (1-k)Q1
        bool minusbSig = true;
        if (deltaBSig) {
            b = b.add(ideltaB); // (1-k)Q1+i*deltaB
        } else {
            kQ02Q1 = kQ02Q1.add(ideltaB); // i*deltaB+kQ0^2/Q1
        }
        if (b >= kQ02Q1) {
            b = b.sub(kQ02Q1);
            minusbSig = true;
        } else {
            b = kQ02Q1.sub(b);
            minusbSig = false;
        }

        // calculate sqrt
        uint256 squareRoot = DecimalMath.mulFloor(
            DecimalMath.ONE.sub(k).mul(4),
            DecimalMath.mulFloor(k, Q0).mul(Q0)
        ); // 4(1-k)kQ0^2
        squareRoot = b.mul(b).add(squareRoot).sqrt(); // sqrt(b*b+4(1-k)kQ0*Q0)

        // final res
        uint256 denominator = DecimalMath.ONE.sub(k).mul(2); // 2(1-k)
        uint256 numerator;
        if (minusbSig) {
            numerator = b.add(squareRoot);
        } else {
            numerator = squareRoot.sub(b);
        }

        if (deltaBSig) {
            return DecimalMath.divFloor(numerator, denominator);
        } else {
            return DecimalMath.divCeil(numerator, denominator);
        }
    }

    /*
        Start from the integration function
        i*deltaB = (Q2-Q1)*(1-k+kQ0^2/Q1/Q2)
        Assume Q2=Q0, Given Q1 and deltaB, solve Q0
        let fairAmount = i*deltaB
    */
    function _SolveQuadraticFunctionForTarget(
        uint256 V1,
        uint256 k,
        uint256 fairAmount
    ) internal pure returns (uint256 V0) {
        // V0 = V1+V1*(sqrt-1)/2k
        uint256 sqrt = DecimalMath.divCeil(DecimalMath.mulFloor(k, fairAmount).mul(4), V1);
        sqrt = sqrt.add(DecimalMath.ONE).mul(DecimalMath.ONE).sqrt();
        uint256 premium = DecimalMath.divCeil(sqrt.sub(DecimalMath.ONE), k.mul(2));
        // V0 is greater than or equal to V1 according to the solution
        return DecimalMath.mulFloor(V1, DecimalMath.ONE.add(premium));
    }
}

contract DODOSellHelper {
    using SafeMath for uint256;

    enum RStatus {ONE, ABOVE_ONE, BELOW_ONE}

    uint256 constant ONE = 10**18;

    struct DODOState {
        uint256 oraclePrice;
        uint256 K;
        uint256 B;
        uint256 Q;
        uint256 baseTarget;
        uint256 quoteTarget;
        RStatus rStatus;
    }

    function querySellBaseToken(address dodo, uint256 amount) public view returns (uint256) {
        return IDODOV1(dodo).querySellBaseToken(amount);
    }

    function querySellQuoteToken(address dodo, uint256 amount) public view returns (uint256) {
        DODOState memory state;
        (state.baseTarget, state.quoteTarget) = IDODOV1(dodo).getExpectedTarget();
        state.rStatus = RStatus(IDODOV1(dodo)._R_STATUS_());
        state.oraclePrice = IDODOV1(dodo).getOraclePrice();
        state.Q = IDODOV1(dodo)._QUOTE_BALANCE_();
        state.B = IDODOV1(dodo)._BASE_BALANCE_();
        state.K = IDODOV1(dodo)._K_();

        uint256 boughtAmount;
        // Determine the status (RStatus) and calculate the amount
        // based on the state
        if (state.rStatus == RStatus.ONE) {
            boughtAmount = _ROneSellQuoteToken(amount, state);
        } else if (state.rStatus == RStatus.ABOVE_ONE) {
            boughtAmount = _RAboveSellQuoteToken(amount, state);
        } else {
            uint256 backOneBase = state.B.sub(state.baseTarget);
            uint256 backOneQuote = state.quoteTarget.sub(state.Q);
            if (amount <= backOneQuote) {
                boughtAmount = _RBelowSellQuoteToken(amount, state);
            } else {
                boughtAmount = backOneBase.add(
                    _ROneSellQuoteToken(amount.sub(backOneQuote), state)
                );
            }
        }
        // Calculate fees
        return
            DecimalMath.divFloor(
                boughtAmount,
                DecimalMath.ONE.add(IDODOV1(dodo)._MT_FEE_RATE_()).add(
                    IDODOV1(dodo)._LP_FEE_RATE_()
                )
            );
    }

    function _ROneSellQuoteToken(uint256 amount, DODOState memory state)
        internal
        pure
        returns (uint256 receiveBaseToken)
    {
        uint256 i = DecimalMath.divFloor(ONE, state.oraclePrice);
        uint256 B2 = DODOMath._SolveQuadraticFunctionForTrade(
            state.baseTarget,
            state.baseTarget,
            DecimalMath.mulFloor(i, amount),
            false,
            state.K
        );
        return state.baseTarget.sub(B2);
    }

    function _RAboveSellQuoteToken(uint256 amount, DODOState memory state)
        internal
        pure
        returns (uint256 receieBaseToken)
    {
        uint256 i = DecimalMath.divFloor(ONE, state.oraclePrice);
        uint256 B2 = DODOMath._SolveQuadraticFunctionForTrade(
            state.baseTarget,
            state.B,
            DecimalMath.mulFloor(i, amount),
            false,
            state.K
        );
        return state.B.sub(B2);
    }

    function _RBelowSellQuoteToken(uint256 amount, DODOState memory state)
        internal
        pure
        returns (uint256 receiveBaseToken)
    {
        uint256 Q1 = state.Q.add(amount);
        uint256 i = DecimalMath.divFloor(ONE, state.oraclePrice);
        return DODOMath._GeneralIntegrate(state.quoteTarget, Q1, state.Q, i, state.K);
    }
}

// File: contracts/SmartRoute/lib/UniversalERC20.sol



library UniversalERC20 {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    IERC20 private constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);

    function universalTransfer(
        IERC20 token,
        address payable to,
        uint256 amount
    ) internal {
        if (amount > 0) {
            if (isETH(token)) {
                to.transfer(amount);
            } else {
                token.safeTransfer(to, amount);
            }
        }
    }

    function universalApproveMax(
        IERC20 token,
        address to,
        uint256 amount
    ) internal {
        uint256 allowance = token.allowance(address(this), to);
        if (allowance < amount) {
            if (allowance > 0) {
                token.safeApprove(to, 0);
            }
            token.safeApprove(to, uint256(-1));
        }
    }

    function universalBalanceOf(IERC20 token, address who) internal view returns (uint256) {
        if (isETH(token)) {
            return who.balance;
        } else {
            return token.balanceOf(who);
        }
    }

    function tokenBalanceOf(IERC20 token, address who) internal view returns (uint256) {
        return token.balanceOf(who);
    }

    function isETH(IERC20 token) internal pure returns (bool) {
        return token == ETH_ADDRESS;
    }
}

// File: contracts/SmartRoute/intf/IDODOAdapter.sol



interface IDODOAdapter {
    
    function sellBase(address to, address pool, bytes memory data) external;

    function sellQuote(address to, address pool, bytes memory data) external;
}

// File: contracts/SmartRoute/adapter/DODOV1Adapter.sol







contract DODOV1Adapter is IDODOAdapter {
    using SafeMath for uint256;
    using UniversalERC20 for IERC20;

    address public immutable _DODO_SELL_HELPER_;

    constructor(address dodoSellHelper) public {
        _DODO_SELL_HELPER_ = dodoSellHelper;
    }
    
    function sellBase(address to, address pool, bytes memory) external override {
        address curBase = IDODOV1(pool)._BASE_TOKEN_();
        uint256 curAmountIn = IERC20(curBase).tokenBalanceOf(address(this));
        IERC20(curBase).universalApproveMax(pool, curAmountIn);
        IDODOV1(pool).sellBaseToken(curAmountIn, 0, "");
        if(to != address(this)) {
            address curQuote = IDODOV1(pool)._QUOTE_TOKEN_();
            SafeERC20.safeTransfer(IERC20(curQuote), to, IERC20(curQuote).tokenBalanceOf(address(this)));
        }
    }

    function sellQuote(address to, address pool, bytes memory) external override {
        address curQuote = IDODOV1(pool)._QUOTE_TOKEN_();
        uint256 curAmountIn = IERC20(curQuote).tokenBalanceOf(address(this));
        IERC20(curQuote).universalApproveMax(pool, curAmountIn);
        uint256 canBuyBaseAmount = IDODOSellHelper(_DODO_SELL_HELPER_).querySellQuoteToken(
            pool,
            curAmountIn
        );
        IDODOV1(pool).buyBaseToken(canBuyBaseAmount, curAmountIn, "");
        if(to != address(this)) {
            address curBase = IDODOV1(pool)._BASE_TOKEN_();
            SafeERC20.safeTransfer(IERC20(curBase), to, canBuyBaseAmount);
        }
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"dodoSellHelper","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"_DODO_SELL_HELPER_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"sellBase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"sellQuote","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a060405234801561001057600080fd5b50604051610b50380380610b508339818101604052602081101561003357600080fd5b5051606081901b6001600160601b0319166080526001600160a01b0316610ae461006c6000398061048a528061061c5250610ae46000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806330e6ae31146100465780636f7929f214610107578063af1280b0146101c6575b600080fd5b6101056004803603606081101561005c57600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561009057600080fd5b8201836020820111156100a257600080fd5b803590602001918460018302840111640100000000831117156100c457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101ea945050505050565b005b6101056004803603606081101561011d57600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561015157600080fd5b82018360208201111561016357600080fd5b8035906020019184600183028401116401000000008311171561018557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103be945050505050565b6101ce61061a565b604080516001600160a01b039092168252519081900360200190f35b6000826001600160a01b0316634a248d2a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561022557600080fd5b505afa158015610239573d6000803e3d6000fd5b505050506040513d602081101561024f57600080fd5b50519050600061026e6001600160a01b0383163063ffffffff61063e16565b905061028a6001600160a01b038316858363ffffffff6106c916565b836001600160a01b0316638dae73338260006040518363ffffffff1660e01b815260040180838152602001828152602001806020018281038252600081526020016020019350505050602060405180830381600087803b1580156102ed57600080fd5b505af1158015610301573d6000803e3d6000fd5b505050506040513d602081101561031757600080fd5b50506001600160a01b03851630146103b7576000846001600160a01b031663d4b970466040518163ffffffff1660e01b815260040160206040518083038186803b15801561036457600080fd5b505afa158015610378573d6000803e3d6000fd5b505050506040513d602081101561038e57600080fd5b505190506103b581876103b06001600160a01b0383163063ffffffff61063e16565b610793565b505b5050505050565b6000826001600160a01b031663d4b970466040518163ffffffff1660e01b815260040160206040518083038186803b1580156103f957600080fd5b505afa15801561040d573d6000803e3d6000fd5b505050506040513d602081101561042357600080fd5b5051905060006104426001600160a01b0383163063ffffffff61063e16565b905061045e6001600160a01b038316858363ffffffff6106c916565b6040805163ca19ebd960e01b81526001600160a01b0386811660048301526024820184905291516000927f0000000000000000000000000000000000000000000000000000000000000000169163ca19ebd9916044808301926020929190829003018186803b1580156104d057600080fd5b505afa1580156104e4573d6000803e3d6000fd5b505050506040513d60208110156104fa57600080fd5b50516040805163733e738360e11b815260048101839052602481018590526060604482015260006064820181905291519293506001600160a01b0388169263e67ce7069260a480840193602093929083900390910190829087803b15801561056157600080fd5b505af1158015610575573d6000803e3d6000fd5b505050506040513d602081101561058b57600080fd5b50506001600160a01b03861630146103b5576000856001600160a01b0316634a248d2a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105d857600080fd5b505afa1580156105ec573d6000803e3d6000fd5b505050506040513d602081101561060257600080fd5b50519050610611818884610793565b50505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561069657600080fd5b505afa1580156106aa573d6000803e3d6000fd5b505050506040513d60208110156106c057600080fd5b50519392505050565b60408051636eb1769f60e11b81523060048201526001600160a01b038481166024830152915160009286169163dd62ed3e916044808301926020929190829003018186803b15801561071a57600080fd5b505afa15801561072e573d6000803e3d6000fd5b505050506040513d602081101561074457600080fd5b505190508181101561078d578015610771576107716001600160a01b03851684600063ffffffff6107ea16565b61078d6001600160a01b0385168460001963ffffffff6107ea16565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526107e59084906108f9565b505050565b801580610870575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561084257600080fd5b505afa158015610856573d6000803e3d6000fd5b505050506040513d602081101561086c57600080fd5b5051155b6108ab5760405162461bcd60e51b8152600401808060200182810382526036815260200180610a796036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526107e59084905b60006060836001600160a01b0316836040518082805190602001908083835b602083106109375780518252601f199092019160209182019101610918565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610999576040519150601f19603f3d011682016040523d82523d6000602084013e61099e565b606091505b5091509150816109f5576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561078d57808060200190516020811015610a1157600080fd5b505161078d5760405162461bcd60e51b815260040180806020018281038252602a815260200180610a4f602a913960400191505060405180910390fdfe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220cbb4824bfd2aba0943a00fcd78c274406fb1ef3aa12e6a1fe37d64763522b66e64736f6c63430006090033000000000000000000000000533da777aedce766ceae696bf90f8541a4ba80eb

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100415760003560e01c806330e6ae31146100465780636f7929f214610107578063af1280b0146101c6575b600080fd5b6101056004803603606081101561005c57600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561009057600080fd5b8201836020820111156100a257600080fd5b803590602001918460018302840111640100000000831117156100c457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101ea945050505050565b005b6101056004803603606081101561011d57600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561015157600080fd5b82018360208201111561016357600080fd5b8035906020019184600183028401116401000000008311171561018557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103be945050505050565b6101ce61061a565b604080516001600160a01b039092168252519081900360200190f35b6000826001600160a01b0316634a248d2a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561022557600080fd5b505afa158015610239573d6000803e3d6000fd5b505050506040513d602081101561024f57600080fd5b50519050600061026e6001600160a01b0383163063ffffffff61063e16565b905061028a6001600160a01b038316858363ffffffff6106c916565b836001600160a01b0316638dae73338260006040518363ffffffff1660e01b815260040180838152602001828152602001806020018281038252600081526020016020019350505050602060405180830381600087803b1580156102ed57600080fd5b505af1158015610301573d6000803e3d6000fd5b505050506040513d602081101561031757600080fd5b50506001600160a01b03851630146103b7576000846001600160a01b031663d4b970466040518163ffffffff1660e01b815260040160206040518083038186803b15801561036457600080fd5b505afa158015610378573d6000803e3d6000fd5b505050506040513d602081101561038e57600080fd5b505190506103b581876103b06001600160a01b0383163063ffffffff61063e16565b610793565b505b5050505050565b6000826001600160a01b031663d4b970466040518163ffffffff1660e01b815260040160206040518083038186803b1580156103f957600080fd5b505afa15801561040d573d6000803e3d6000fd5b505050506040513d602081101561042357600080fd5b5051905060006104426001600160a01b0383163063ffffffff61063e16565b905061045e6001600160a01b038316858363ffffffff6106c916565b6040805163ca19ebd960e01b81526001600160a01b0386811660048301526024820184905291516000927f000000000000000000000000533da777aedce766ceae696bf90f8541a4ba80eb169163ca19ebd9916044808301926020929190829003018186803b1580156104d057600080fd5b505afa1580156104e4573d6000803e3d6000fd5b505050506040513d60208110156104fa57600080fd5b50516040805163733e738360e11b815260048101839052602481018590526060604482015260006064820181905291519293506001600160a01b0388169263e67ce7069260a480840193602093929083900390910190829087803b15801561056157600080fd5b505af1158015610575573d6000803e3d6000fd5b505050506040513d602081101561058b57600080fd5b50506001600160a01b03861630146103b5576000856001600160a01b0316634a248d2a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105d857600080fd5b505afa1580156105ec573d6000803e3d6000fd5b505050506040513d602081101561060257600080fd5b50519050610611818884610793565b50505050505050565b7f000000000000000000000000533da777aedce766ceae696bf90f8541a4ba80eb81565b6000826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561069657600080fd5b505afa1580156106aa573d6000803e3d6000fd5b505050506040513d60208110156106c057600080fd5b50519392505050565b60408051636eb1769f60e11b81523060048201526001600160a01b038481166024830152915160009286169163dd62ed3e916044808301926020929190829003018186803b15801561071a57600080fd5b505afa15801561072e573d6000803e3d6000fd5b505050506040513d602081101561074457600080fd5b505190508181101561078d578015610771576107716001600160a01b03851684600063ffffffff6107ea16565b61078d6001600160a01b0385168460001963ffffffff6107ea16565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526107e59084906108f9565b505050565b801580610870575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561084257600080fd5b505afa158015610856573d6000803e3d6000fd5b505050506040513d602081101561086c57600080fd5b5051155b6108ab5760405162461bcd60e51b8152600401808060200182810382526036815260200180610a796036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526107e59084905b60006060836001600160a01b0316836040518082805190602001908083835b602083106109375780518252601f199092019160209182019101610918565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610999576040519150601f19603f3d011682016040523d82523d6000602084013e61099e565b606091505b5091509150816109f5576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561078d57808060200190516020811015610a1157600080fd5b505161078d5760405162461bcd60e51b815260040180806020018281038252602a815260200180610a4f602a913960400191505060405180910390fdfe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220cbb4824bfd2aba0943a00fcd78c274406fb1ef3aa12e6a1fe37d64763522b66e64736f6c63430006090033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000533da777aedce766ceae696bf90f8541a4ba80eb

-----Decoded View---------------
Arg [0] : dodoSellHelper (address): 0x533dA777aeDCE766CEAe696bf90f8541A4bA80Eb

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000533da777aedce766ceae696bf90f8541a4ba80eb


Deployed Bytecode Sourcemap

20472:1542:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;20752:558;;;;;;;;;;;;;;;;-1:-1:-1;;;;;20752:558:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;20752:558:0;;-1:-1:-1;20752:558:0;;-1:-1:-1;;;;;20752:558:0:i;:::-;;21318:693;;;;;;;;;;;;;;;;-1:-1:-1;;;;;21318:693:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;21318:693:0;;-1:-1:-1;21318:693:0;;-1:-1:-1;;;;;21318:693:0:i;20591:43::-;;;:::i;:::-;;;;-1:-1:-1;;;;;20591:43:0;;;;;;;;;;;;;;20752:558;20839:15;20865:4;-1:-1:-1;;;;;20857:26:0;;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;20857:28:0;;-1:-1:-1;20896:19:0;20918:45;-1:-1:-1;;;;;20918:30:0;;20957:4;20918:45;:30;:45;:::i;:::-;20896:67;-1:-1:-1;20974:54:0;-1:-1:-1;;;;;20974:35:0;;21010:4;20896:67;20974:54;:35;:54;:::i;:::-;21047:4;-1:-1:-1;;;;;21039:27:0;;21067:11;21080:1;21039:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;;21100:19:0;;21114:4;21100:19;21097:206;;21136:16;21163:4;-1:-1:-1;;;;;21155:27:0;;:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;21155:29:0;;-1:-1:-1;21199:92:0;21155:29;21240:2;21244:46;-1:-1:-1;;;;;21244:31:0;;21284:4;21244:46;:31;:46;:::i;:::-;21199:22;:92::i;:::-;21097:206;;20752:558;;;;;:::o;21318:693::-;21406:16;21433:4;-1:-1:-1;;;;;21425:27:0;;:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;21425:29:0;;-1:-1:-1;21465:19:0;21487:46;-1:-1:-1;;;;;21487:31:0;;21527:4;21487:46;:31;:46;:::i;:::-;21465:68;-1:-1:-1;21544:55:0;-1:-1:-1;;;;;21544:36:0;;21581:4;21465:68;21544:55;:36;:55;:::i;:::-;21637:111;;;-1:-1:-1;;;21637:111:0;;-1:-1:-1;;;;;21637:111:0;;;;;;;;;;;;;;;21610:24;;21653:18;21637:55;;;;:111;;;;;;;;;;;;;;:55;:111;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;21637:111:0;21759:61;;;-1:-1:-1;;;21759:61:0;;;;;;;;;;;;;;;;;;;-1:-1:-1;21759:61:0;;;;;;;;21637:111;;-1:-1:-1;;;;;;21759:26:0;;;;;:61;;;;;21637:111;;21759:61;;;;;;;;;;;:26;:61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;;21834:19:0;;21848:4;21834:19;21831:173;;21870:15;21896:4;-1:-1:-1;;;;;21888:26:0;;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;21888:28:0;;-1:-1:-1;21931:61:0;21888:28;21971:2;21975:16;21931:22;:61::i;:::-;21831:173;21318:693;;;;;;:::o;20591:43::-;;;:::o;19898:129::-;19972:7;19999:5;-1:-1:-1;;;;;19999:15:0;;20015:3;19999:20;;;;;;;;;;;;;-1:-1:-1;;;;;19999:20:0;-1:-1:-1;;;;;19999:20:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;19999:20:0;;19898:129;-1:-1:-1;;;19898:129:0:o;19280:374::-;19425:34;;;-1:-1:-1;;;19425:34:0;;19449:4;19425:34;;;;-1:-1:-1;;;;;19425:34:0;;;;;;;;;19405:17;;19425:15;;;;;:34;;;;;;;;;;;;;;:15;:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;19425:34:0;;-1:-1:-1;19474:18:0;;;19470:177;;;19513:13;;19509:78;;19547:24;-1:-1:-1;;;;;19547:17:0;;19565:2;19569:1;19547:24;:17;:24;:::i;:::-;19601:34;-1:-1:-1;;;;;19601:17:0;;19619:2;-1:-1:-1;;19601:34:0;:17;:34;:::i;:::-;19280:374;;;;:::o;7034:211::-;7178:58;;;-1:-1:-1;;;;;7178:58:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;7178:58:0;-1:-1:-1;;;7178:58:0;;;7151:86;;7171:5;;7151:19;:86::i;:::-;7034:211;;;:::o;7546:670::-;7964:10;;;7963:62;;-1:-1:-1;7980:39:0;;;-1:-1:-1;;;7980:39:0;;8004:4;7980:39;;;;-1:-1:-1;;;;;7980:39:0;;;;;;;;;:15;;;;;;:39;;;;;;;;;;;;;;;:15;:39;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7980:39:0;:44;7963:62;7941:166;;;;-1:-1:-1;;;7941:166:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8145:62;;;-1:-1:-1;;;;;8145:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;8145:62:0;-1:-1:-1;;;8145:62:0;;;8118:90;;8138:5;;8607:1046;9267:12;9281:23;9316:5;-1:-1:-1;;;;;9308:19:0;9328:4;9308:25;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;9308:25:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9266:67;;;;9352:7;9344:52;;;;;-1:-1:-1;;;9344:52:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9413:17;;:21;9409:237;;9568:10;9557:30;;;;;;;;;;;;;;;-1:-1:-1;9557:30:0;9549:85;;;;-1:-1:-1;;;9549:85:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Swarm Source

ipfs://cbb4824bfd2aba0943a00fcd78c274406fb1ef3aa12e6a1fe37d64763522b66e

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ 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.