ETH Price: $3,144.61 (+1.02%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ConnectV2MorphoTokenWrapper

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 8 : main.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {Basic} from "../../common/basic.sol";
import {TokenInterface} from "../../common/interfaces.sol";
import {IMorphoWrapper} from "./interfaces.sol";
import "./events.sol";

abstract contract MorphoTokenWrapper is Basic, Events {
    address internal constant MORPHO_LEGACY_TOKEN =
        0x9994E35Db50125E0DF82e4c2dde62496CE330999;

    address internal constant MORPHO_WRAPPER =
        0x9D03bb2092270648d7480049d0E58d2FcF0E5123;

    address internal constant MORPHO_TOKEN_NEW =
        0x58D97B57BB95320F9a05dC918Aef65434969c2B2;

    error LessTokensReceived();

    /**
     * @dev Convert MORPHO Legacy to MORPHO New.
     */
    function convertToNewMorpho()
        public
        payable
        returns (string memory _eventName, bytes memory _eventParam)
    {
        uint256 _amt = TokenInterface(MORPHO_LEGACY_TOKEN).balanceOf(
            address(this)
        );

        uint256 balanceBefore_ = TokenInterface(MORPHO_TOKEN_NEW).balanceOf(
            address(this)
        );

        approve(TokenInterface(MORPHO_LEGACY_TOKEN), MORPHO_WRAPPER, _amt);

        IMorphoWrapper(MORPHO_WRAPPER).depositFor(address(this), _amt);

        uint256 tokensReceived_ = TokenInterface(MORPHO_TOKEN_NEW).balanceOf(
            address(this)
        ) - balanceBefore_;

        if (tokensReceived_ < (_amt - 100)) {
            revert LessTokensReceived();
        }

        _eventName = "LogConvertToNewMorpho(uint256)";
        _eventParam = abi.encode(tokensReceived_);
    }
}

contract ConnectV2MorphoTokenWrapper is MorphoTokenWrapper {
    string public constant name = "Morpho-Token-Wrapper-v1.0";
}

File 2 of 8 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 3 of 8 : basic.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import { TokenInterface } from "./interfaces.sol";
import { Stores } from "./stores.sol";
import { DSMath } from "./math.sol";

abstract contract Basic is DSMath, Stores {

    function convert18ToDec(uint _dec, uint256 _amt) internal pure returns (uint256 amt) {
        amt = (_amt / 10 ** (18 - _dec));
    }

    function convertTo18(uint _dec, uint256 _amt) internal pure returns (uint256 amt) {
        amt = mul(_amt, 10 ** (18 - _dec));
    }

    function getTokenBal(TokenInterface token) internal view returns(uint _amt) {
        _amt = address(token) == ethAddr ? address(this).balance : token.balanceOf(address(this));
    }

    function getTokensDec(TokenInterface buyAddr, TokenInterface sellAddr) internal view returns(uint buyDec, uint sellDec) {
        buyDec = address(buyAddr) == ethAddr ?  18 : buyAddr.decimals();
        sellDec = address(sellAddr) == ethAddr ?  18 : sellAddr.decimals();
    }

    function encodeEvent(string memory eventName, bytes memory eventParam) internal pure returns (bytes memory) {
        return abi.encode(eventName, eventParam);
    }

    function approve(TokenInterface token, address spender, uint256 amount) internal {
        try token.approve(spender, amount) {

        } catch {
            token.approve(spender, 0);
            token.approve(spender, amount);
        }
    }

    function changeEthAddress(address buy, address sell) internal pure returns(TokenInterface _buy, TokenInterface _sell){
        _buy = buy == ethAddr ? TokenInterface(wethAddr) : TokenInterface(buy);
        _sell = sell == ethAddr ? TokenInterface(wethAddr) : TokenInterface(sell);
    }

    function changeEthAddrToWethAddr(address token) internal pure returns(address tokenAddr){
        tokenAddr = token == ethAddr ? wethAddr : token;
    }

    function convertEthToWeth(bool isEth, TokenInterface token, uint amount) internal {
        if(isEth) token.deposit{value: amount}();
    }

    function convertWethToEth(bool isEth, TokenInterface token, uint amount) internal {
       if(isEth) {
            approve(token, address(token), amount);
            token.withdraw(amount);
        }
    }
}

File 4 of 8 : interfaces.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

interface TokenInterface {
    function approve(address, uint256) external;
    function transfer(address, uint) external;
    function transferFrom(address, address, uint) external;
    function deposit() external payable;
    function withdraw(uint) external;
    function balanceOf(address) external view returns (uint);
    function decimals() external view returns (uint);
    function totalSupply() external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint256);
}

interface MemoryInterface {
    function getUint(uint id) external returns (uint num);
    function setUint(uint id, uint val) external;
}

interface InstaMapping {
    function cTokenMapping(address) external view returns (address);
    function gemJoinMapping(bytes32) external view returns (address);
}

interface AccountInterface {
    function enable(address) external;
    function disable(address) external;
    function isAuth(address) external view returns (bool);
    function cast(
        string[] calldata _targetNames,
        bytes[] calldata _datas,
        address _origin
    ) external payable returns (bytes32[] memory responses);
}

interface ListInterface {
    function accountID(address) external returns (uint64);
}

interface InstaConnectors {
    function isConnectors(string[] calldata) external returns (bool, address[] memory);
}

File 5 of 8 : math.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import { SafeMath } from "@openzeppelin/contracts/utils/math/SafeMath.sol";

contract DSMath {
  uint constant WAD = 10 ** 18;
  uint constant RAY = 10 ** 27;

  function add(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(x, y);
  }

  function sub(uint x, uint y) internal virtual pure returns (uint z) {
    z = SafeMath.sub(x, y);
  }

  function mul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.mul(x, y);
  }

  function div(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.div(x, y);
  }

  function wmul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, y), WAD / 2) / WAD;
  }

  function wdiv(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, WAD), y / 2) / y;
  }

  function rdiv(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, RAY), y / 2) / y;
  }

  function rmul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, y), RAY / 2) / RAY;
  }

  function toInt(uint x) internal pure returns (int y) {
    y = int(x);
    require(y >= 0, "int-overflow");
  }

  function toUint(int256 x) internal pure returns (uint256) {
      require(x >= 0, "int-overflow");
      return uint256(x);
  }

  function toRad(uint wad) internal pure returns (uint rad) {
    rad = mul(wad, 10 ** 27);
  }

}

File 6 of 8 : stores.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import { MemoryInterface, InstaMapping, ListInterface, InstaConnectors } from "./interfaces.sol";


abstract contract Stores {

  /**
   * @dev Return ethereum address
   */
  address constant internal ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

  /**
   * @dev Return Wrapped ETH address
   */
  address constant internal wethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

  /**
   * @dev Return memory variable address
   */
  MemoryInterface constant internal instaMemory = MemoryInterface(0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F);

  /**
   * @dev Return InstaDApp Mapping Addresses
   */
  InstaMapping constant internal instaMapping = InstaMapping(0xe81F70Cc7C0D46e12d70efc60607F16bbD617E88);

  /**
   * @dev Return InstaList Address
   */
  ListInterface internal constant instaList = ListInterface(0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb);

  /**
	 * @dev Return connectors registry address
	 */
	InstaConnectors internal constant instaConnectors = InstaConnectors(0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11);

  /**
   * @dev Get Uint value from InstaMemory Contract.
   */
  function getUint(uint getId, uint val) internal returns (uint returnVal) {
    returnVal = getId == 0 ? val : instaMemory.getUint(getId);
  }

  /**
  * @dev Set Uint value in InstaMemory Contract.
  */
  function setUint(uint setId, uint val) virtual internal {
    if (setId != 0) instaMemory.setUint(setId, val);
  }

}

File 7 of 8 : events.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

contract Events {
    event LogConvertToNewMorpho(uint256 indexed newTokensReceived);
}

File 8 of 8 : interfaces.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface IMorphoWrapper {
    function depositFor(address account, uint256 value) external returns (bool);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"LessTokensReceived","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newTokensReceived","type":"uint256"}],"name":"LogConvertToNewMorpho","type":"event"},{"inputs":[],"name":"convertToNewMorpho","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506105aa806100206000396000f3fe6080604052600436106100295760003560e01c806306fdde031461002e578063c3a320d61461008d575b600080fd5b34801561003a57600080fd5b506100776040518060400160405280601981526020017f4d6f7270686f2d546f6b656e2d577261707065722d76312e300000000000000081525081565b60405161008491906104ca565b60405180910390f35b6100956100a3565b6040516100849291906104e4565b6040516370a0823160e01b81523060048201526060908190600090739994e35db50125e0df82e4c2dde62496ce330999906370a0823190602401602060405180830381865afa1580156100fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061011e9190610512565b6040516370a0823160e01b81523060048201529091506000907358d97b57bb95320f9a05dc918aef65434969c2b2906370a0823190602401602060405180830381865afa158015610173573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101979190610512565b90506101cc739994e35db50125e0df82e4c2dde62496ce330999739d03bb2092270648d7480049d0e58d2fcf0e51238461035b565b6040516317a790f160e11b815230600482015260248101839052739d03bb2092270648d7480049d0e58d2fcf0e512390632f4f21e2906044016020604051808303816000875af1158015610224573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610248919061052b565b506040516370a0823160e01b815230600482015260009082907358d97b57bb95320f9a05dc918aef65434969c2b2906370a0823190602401602060405180830381865afa15801561029d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c19190610512565b6102cb919061054d565b90506102d860648461054d565b8110156102f857604051637479133d60e11b815260040160405180910390fd5b6040518060400160405280601e81526020017f4c6f67436f6e76657274546f4e65774d6f7270686f2875696e7432353629000081525094508060405160200161034391815260200190565b60405160208183030381529060405293505050509091565b60405163095ea7b360e01b81526001600160a01b0383811660048301526024820183905284169063095ea7b390604401600060405180830381600087803b1580156103a557600080fd5b505af19250505080156103b6575060015b61047f5760405163095ea7b360e01b81526001600160a01b0383811660048301526000602483015284169063095ea7b390604401600060405180830381600087803b15801561040457600080fd5b505af1158015610418573d6000803e3d6000fd5b505060405163095ea7b360e01b81526001600160a01b038581166004830152602482018590528616925063095ea7b39150604401600060405180830381600087803b15801561046657600080fd5b505af115801561047a573d6000803e3d6000fd5b505050505b505050565b6000815180845260005b818110156104aa5760208185018101518683018201520161048e565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104dd6020830184610484565b9392505050565b6040815260006104f76040830185610484565b82810360208401526105098185610484565b95945050505050565b60006020828403121561052457600080fd5b5051919050565b60006020828403121561053d57600080fd5b815180151581146104dd57600080fd5b8181038181111561056e57634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212203843064b67c02a3ab420dfe7a96ce2f472a299e64df2d2d388f05467a5674c0e64736f6c63430008130033

Deployed Bytecode

0x6080604052600436106100295760003560e01c806306fdde031461002e578063c3a320d61461008d575b600080fd5b34801561003a57600080fd5b506100776040518060400160405280601981526020017f4d6f7270686f2d546f6b656e2d577261707065722d76312e300000000000000081525081565b60405161008491906104ca565b60405180910390f35b6100956100a3565b6040516100849291906104e4565b6040516370a0823160e01b81523060048201526060908190600090739994e35db50125e0df82e4c2dde62496ce330999906370a0823190602401602060405180830381865afa1580156100fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061011e9190610512565b6040516370a0823160e01b81523060048201529091506000907358d97b57bb95320f9a05dc918aef65434969c2b2906370a0823190602401602060405180830381865afa158015610173573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101979190610512565b90506101cc739994e35db50125e0df82e4c2dde62496ce330999739d03bb2092270648d7480049d0e58d2fcf0e51238461035b565b6040516317a790f160e11b815230600482015260248101839052739d03bb2092270648d7480049d0e58d2fcf0e512390632f4f21e2906044016020604051808303816000875af1158015610224573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610248919061052b565b506040516370a0823160e01b815230600482015260009082907358d97b57bb95320f9a05dc918aef65434969c2b2906370a0823190602401602060405180830381865afa15801561029d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c19190610512565b6102cb919061054d565b90506102d860648461054d565b8110156102f857604051637479133d60e11b815260040160405180910390fd5b6040518060400160405280601e81526020017f4c6f67436f6e76657274546f4e65774d6f7270686f2875696e7432353629000081525094508060405160200161034391815260200190565b60405160208183030381529060405293505050509091565b60405163095ea7b360e01b81526001600160a01b0383811660048301526024820183905284169063095ea7b390604401600060405180830381600087803b1580156103a557600080fd5b505af19250505080156103b6575060015b61047f5760405163095ea7b360e01b81526001600160a01b0383811660048301526000602483015284169063095ea7b390604401600060405180830381600087803b15801561040457600080fd5b505af1158015610418573d6000803e3d6000fd5b505060405163095ea7b360e01b81526001600160a01b038581166004830152602482018590528616925063095ea7b39150604401600060405180830381600087803b15801561046657600080fd5b505af115801561047a573d6000803e3d6000fd5b505050505b505050565b6000815180845260005b818110156104aa5760208185018101518683018201520161048e565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006104dd6020830184610484565b9392505050565b6040815260006104f76040830185610484565b82810360208401526105098185610484565b95945050505050565b60006020828403121561052457600080fd5b5051919050565b60006020828403121561053d57600080fd5b815180151581146104dd57600080fd5b8181038181111561056e57634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212203843064b67c02a3ab420dfe7a96ce2f472a299e64df2d2d388f05467a5674c0e64736f6c63430008130033

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

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.