Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x294ad5B1cFEb2B1177101604f6041e6dDFBaB40c
Balance 0.000000000 ETH
Nonce 1
Code Size 7547 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7547 bytes
0x60806040526004361061019a5760003560e01c8063715018a6116100e1578063abab24991161008a578063d004f0f711610064578063d004f0f7146104b0578063d5cf9080146104c3578063f2fde38b146104d9578063f4cde469146104f957600080fd5b8063abab24991461044f578063ad2625e61461046f578063b633b3641461048f57600080fd5b80638da5cb5b116100bb5780638da5cb5b146103ea578063a19a765c14610408578063a95e02f31461041e57600080fd5b8063715018a61461039f57806386a95468146103b4578063872d136a146103ca57600080fd5b8063482c988c1161014357806359d401ef1161011d57806359d401ef146103355780635a76f3191461034b578063704b6c021461037f57600080fd5b8063482c988c146102d557806351e04ca8146102f557806352f7c9881461031557600080fd5b806329d659401161017457806329d65940146102715780632c4e722e1461029157806343060237146102b557600080fd5b806308e4aaef146101de5780632184a44c1461021b578063256179501461024f57600080fd5b366101d957604080513381523460208201527f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874910160405180910390a1005b600080fd5b3480156101ea57600080fd5b506003546101fe906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561022757600080fd5b506101fe7f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc181981565b34801561025b57600080fd5b5061026f61026a366004611b8c565b610519565b005b34801561027d57600080fd5b5061026f61028c366004611b6a565b610709565b34801561029d57600080fd5b506102a760045481565b604051908152602001610212565b3480156102c157600080fd5b5061026f6102d0366004611b6a565b6107ba565b3480156102e157600080fd5b506002546101fe906001600160a01b031681565b34801561030157600080fd5b5061026f610310366004611be9565b61086b565b34801561032157600080fd5b5061026f610330366004611c55565b6108ed565b34801561034157600080fd5b506102a760065481565b34801561035757600080fd5b506101fe7f000000000000000000000000c19ccb3423157f5d537baaba120ecad80c4ba02e81565b34801561038b57600080fd5b5061026f61039a366004611b6a565b61097b565b3480156103ab57600080fd5b5061026f610a2c565b3480156103c057600080fd5b506102a760055481565b3480156103d657600080fd5b5061026f6103e5366004611b6a565b610a40565b3480156103f657600080fd5b506000546001600160a01b03166101fe565b34801561041457600080fd5b506102a760075481565b34801561042a57600080fd5b5060035461043f90600160a81b900460ff1681565b6040519015158152602001610212565b34801561045b57600080fd5b5061026f61046a366004611be9565b610af1565b34801561047b57600080fd5b5061026f61048a366004611c55565b610b73565b34801561049b57600080fd5b5060035461043f90600160a01b900460ff1681565b61026f6104be366004611bbf565b610c01565b3480156104cf57600080fd5b506102a760085481565b3480156104e557600080fd5b5061026f6104f4366004611b6a565b610d24565b34801561050557600080fd5b5061026f610514366004611c23565b610d62565b6009546001600160a01b0316331461056c5760405162461bcd60e51b81526020600482015260116024820152703832b936b4b9b9b4b7b7399032b93937b960791b60448201526064015b60405180910390fd5b6001600160a01b0381166105bb5760405162461bcd60e51b815260206004820152601660248201527543616e6e6f74206265207a65726f206164647265737360501b6044820152606401610563565b6001600160a01b03821661062f576000816001600160a01b03164760405160006040518083038185875af1925050503d8060008114610616576040519150601f19603f3d011682016040523d82523d6000602084013e61061b565b606091505b505090508061062957600080fd5b506106c1565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b15801561067157600080fd5b505afa158015610685573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a99190611c3c565b90506106bf6001600160a01b0384168383610e3e565b505b604080516001600160a01b038085168252831660208201527f34d58c18c6c1df2c698ccac556acea92941ca7b99d2fccf9e3ac1852d0dec36f91015b60405180910390a15050565b610711610ed3565b6001600160a01b0381166107605760405162461bcd60e51b815260206004820152601660248201527543616e6e6f74206265207a65726f206164647265737360501b6044820152606401610563565b600380546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f41712eb87779a1775fe7f793d3dd6e4d40937d9a3ecc171a6f4b735a504066df91016106fd565b6107c2610ed3565b6001600160a01b0381166108115760405162461bcd60e51b815260206004820152601660248201527543616e6e6f74206265207a65726f206164647265737360501b6044820152606401610563565b600980546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fcd6ba6b7da89e039d53b5d981527a893755342bb9d8e5c2f61f6638f1fb5192b91016106fd565b610873610ed3565b600380547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff8116600160a81b84151581810292909217909355604080519390920460ff1680151584526020840191909152917f7ff74f980d3f4732fe97a915bd9c7c6b2c57afae76813b707253cae1c2bdb60991016106fd565b600a546001600160a01b0316331461093b5760405162461bcd60e51b81526020600482015260116024820152703832b936b4b9b9b4b7b7399032b93937b960791b6044820152606401610563565b6005829055600681905560408051838152602081018390527f8987e6f43a6c6bf408c8c427dceb2f98377f859348939ef4ab7b770b510a395a91016106fd565b610983610ed3565b6001600160a01b0381166109d25760405162461bcd60e51b815260206004820152601660248201527543616e6e6f74206265207a65726f206164647265737360501b6044820152606401610563565b600a80546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fcd6ba6b7da89e039d53b5d981527a893755342bb9d8e5c2f61f6638f1fb5192b91016106fd565b610a34610ed3565b610a3e6000610f00565b565b610a48610ed3565b6001600160a01b038116610a975760405162461bcd60e51b815260206004820152601660248201527543616e6e6f74206265207a65726f206164647265737360501b6044820152606401610563565b600280546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fadaded46fea25077b79171cbc8900cbb936c8087915e091788cc6f6aa17ad5b091016106fd565b610af9610ed3565b600380547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff8116600160a01b84151581810292909217909355604080519390920460ff1680151584526020840191909152917f51aec20b3fbdb202a07a0578c4c8deee2cb06542dfe73ef2919efd435808194191016106fd565b600a546001600160a01b03163314610bc15760405162461bcd60e51b81526020600482015260116024820152703832b936b4b9b9b4b7b7399032b93937b960791b6044820152606401610563565b6007829055600881905560408051838152602081018390527f91b988bf4f549a150bf792a6fb6bd1457dc09a5a2c33ab82b868962444281acb91016106fd565b610c09610f50565b7f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc18196001600160a01b0316826001600160a01b03161480610c7a57507f000000000000000000000000c19ccb3423157f5d537baaba120ecad80c4ba02e6001600160a01b0316826001600160a01b0316145b610cc65760405162461bcd60e51b815260206004820152601260248201527f556e737570706f7274656420746f6b656e7300000000000000000000000000006044820152606401610563565b7f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc18196001600160a01b0316826001600160a01b03161415610d0e57610d0981610f7b565b610d17565b610d17816111b9565b610d2060018055565b5050565b610d2c610ed3565b6001600160a01b038116610d5657604051631e4fbdf760e01b815260006004820152602401610563565b610d5f81610f00565b50565b600a546001600160a01b03163314610db05760405162461bcd60e51b81526020600482015260116024820152703832b936b4b9b9b4b7b7399032b93937b960791b6044820152606401610563565b60008111610e005760405162461bcd60e51b815260206004820152601c60248201527f526174696f206d7573742062652067726561746572207468616e2030000000006044820152606401610563565b600480549082905560408051828152602081018490527ffe3b4c3f6e2efdc3dd612c3eb2817308b7568ad72d3f9c9200a08a069c27dff891016106fd565b6040516001600160a01b038316602482015260448101829052610ece90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261148a565b505050565b6000546001600160a01b03163314610a3e5760405163118cdaa760e01b8152336004820152602401610563565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60026001541415610f7457604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b600354600160a01b900460ff1615610fd55760405162461bcd60e51b815260206004820152601360248201527f45786368616e6765206e6f74206f70656e6564000000000000000000000000006044820152606401610563565b600061271060055483610fe89190611ce8565b610ff29190611cc6565b9050600061271060045483856110089190611d07565b6110129190611ce8565b61101c9190611cc6565b90506110536001600160a01b037f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc181916333086611572565b811561109357600354611093906001600160a01b037f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc18198116911684610e3e565b61109f836007546115b0565b6040516308934a5f60e31b8152336004820152602481018290527f000000000000000000000000c19ccb3423157f5d537baaba120ecad80c4ba02e6001600160a01b03169063449a52f890604401600060405180830381600087803b15801561110757600080fd5b505af115801561111b573d6000803e3d6000fd5b5050604080516001600160a01b037f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc1819811682527f000000000000000000000000c19ccb3423157f5d537baaba120ecad80c4ba02e166020820152908101869052606081018490523392507fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e4606291506080015b60405180910390a2505050565b600354600160a81b900460ff16156112135760405162461bcd60e51b815260206004820152601360248201527f45786368616e6765206e6f74206f70656e6564000000000000000000000000006044820152606401610563565b60045460009061122583612710611ce8565b61122f9190611cc6565b90506000612710600654836112449190611ce8565b61124e9190611cc6565b905061125c826008546115b0565b6112887f000000000000000000000000c19ccb3423157f5d537baaba120ecad80c4ba02e33308661179e565b6040516370a0823160e01b81523060048201527f000000000000000000000000c19ccb3423157f5d537baaba120ecad80c4ba02e6001600160a01b0316906342966c689082906370a082319060240160206040518083038186803b1580156112ef57600080fd5b505afa158015611303573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113279190611c3c565b6040518263ffffffff1660e01b815260040161134591815260200190565b600060405180830381600087803b15801561135f57600080fd5b505af1158015611373573d6000803e3d6000fd5b5050505060008111156113ba576003546113ba906001600160a01b037f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc18198116911683610e3e565b6113f9336113c88385611d07565b6001600160a01b037f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc1819169190610e3e565b604080516001600160a01b037f000000000000000000000000c19ccb3423157f5d537baaba120ecad80c4ba02e811682527f0000000000000000000000004fd67c2d9e8c4fdd9c66954bafe124ca50fc18191660208201529081018490526060810183905233907fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e46062906080016111ac565b60006114df826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118bd9092919063ffffffff16565b90508051600014806115005750808060200190518101906115009190611c06565b610ece5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610563565b6040516001600160a01b03808516602483015283166044820152606481018290526115aa9085906323b872dd60e01b90608401610e6a565b50505050565b8015610d205760006115ce6127106115c885856118d4565b9061195b565b90506000600260009054906101000a90046001600160a01b03166001600160a01b03166398d5fdca6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561162257600080fd5b505af1158015611636573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165a9190611c3c565b90506000611674670de0b6b3a76400006115c885856118d4565b9050803410156116c65760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742068616e646c696e6720666565000000000000006044820152606401610563565b6003546040516000916001600160a01b03169083908381818185875af1925050503d8060008114611713576040519150601f19603f3d011682016040523d82523d6000602084013e611718565b606091505b505090508061172657600080fd5b60006117328334611d07565b905061520881111561179557604051600090339083908381818185875af1925050503d8060008114611780576040519150601f19603f3d011682016040523d82523d6000602084013e611785565b606091505b505090508061179357600080fd5b505b50505050505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166323b872dd60e01b17905291516000928392908816916118179190611c77565b6000604051808303816000865af19150503d8060008114611854576040519150601f19603f3d011682016040523d82523d6000602084013e611859565b606091505b50915091508180156118835750805115806118835750808060200190518101906118839190611c06565b6118b55760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b6044820152606401610563565b505050505050565b60606118cc84846000856119c1565b949350505050565b6000826118e357506000611955565b60006118ef8385611ce8565b9050826118fc8583611cc6565b146040518060400160405280601181526020017f4d4154485f4d554c5f4f564552464c4f57000000000000000000000000000000815250906119515760405162461bcd60e51b81526004016105639190611c93565b5090505b92915050565b60008082116040518060400160405280600d81526020017f4d4154485f4449565f5a45524f00000000000000000000000000000000000000815250906119b45760405162461bcd60e51b81526004016105639190611c93565b5060006118cc8385611cc6565b606082471015611a395760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610563565b600080866001600160a01b03168587604051611a559190611c77565b60006040518083038185875af1925050503d8060008114611a92576040519150601f19603f3d011682016040523d82523d6000602084013e611a97565b606091505b5091509150611aa887838387611ab3565b979650505050505050565b60608315611b1f578251611b18576001600160a01b0385163b611b185760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610563565b50816118cc565b6118cc8383815115611b345781518083602001fd5b8060405162461bcd60e51b81526004016105639190611c93565b80356001600160a01b0381168114611b6557600080fd5b919050565b600060208284031215611b7c57600080fd5b611b8582611b4e565b9392505050565b60008060408385031215611b9f57600080fd5b611ba883611b4e565b9150611bb660208401611b4e565b90509250929050565b60008060408385031215611bd257600080fd5b611bdb83611b4e565b946020939093013593505050565b600060208284031215611bfb57600080fd5b8135611b8581611d60565b600060208284031215611c1857600080fd5b8151611b8581611d60565b600060208284031215611c3557600080fd5b5035919050565b600060208284031215611c4e57600080fd5b5051919050565b60008060408385031215611c6857600080fd5b50508035926020909101359150565b60008251611c89818460208701611d1e565b9190910192915050565b6020815260008251806020840152611cb2816040850160208701611d1e565b601f01601f19169190910160400192915050565b600082611ce357634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611d0257611d02611d4a565b500290565b600082821015611d1957611d19611d4a565b500390565b60005b83811015611d39578181015183820152602001611d21565b838111156115aa5750506000910152565b634e487b7160e01b600052601160045260246000fd5b8015158114610d5f57600080fdfea164736f6c6343000807000a

Verified Source Code Partial Match

Compiler: v0.8.7+commit.e28d00a7 EVM: london Optimization: Yes (800 runs)
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IR2MNER.sol 14 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "./IERC20.sol";

interface IR2MNER is IERC20 {
    function mintTo(address to, uint256 _amount) external;

    function burn(uint256 _amount) external;

    function decimals() external returns (uint8);

    function rebase(int256 _amount) external returns (uint256);
}
rMnerExchange.sol 225 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "./utils/SafeMath.sol";
import "./utils/SafeERC20.sol";
import "./utils/TransferHelper.sol";
import "./utils/Ownable.sol";
import "./utils/ReentrancyGuard.sol";
import "./interface/IR2MNER.sol";
import "./interface/IERC20.sol";

interface IRMNERPrice is IERC20 {
    function getPrice() external returns (uint256);
}

contract rMnerExchange is Ownable, ReentrancyGuard {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    address public immutable rMNER;
    address public immutable r2MNER;

    address public rMnerPrice;

    address public feeReceive = 0xFcE8666024f64b104B1a59c2d18Ea0319533c0b7;

    bool public stopSwap = false;

    bool public stopOutSwap = false;

    uint256 public rate = 10000;

    uint256 public inFee = 0;
    uint256 public outFee = 30;

    uint256 public btcInFee = 0;
    uint256 public btcOutFee = 0;

    address assetManager;
    address admin;

    modifier onlyAssetManager() {
        require(msg.sender == assetManager, "permissions error");
        _;
    }

    modifier onlyAdmin() {
        require(msg.sender == admin, "permissions error");
        _;
    }

    event Swap(address indexed user, address tokenA, address tokenB, uint256 inAmount, uint256 outAmount);

    constructor(
        address _rMNER,
        address _r2MNER,
        address _price,
        address _admin,
        address _assetManger
    ) Ownable(msg.sender) {
        require(_price != address(0), "Cannot be zero address");
        require(_assetManger != address(0), "Cannot be zero address");
        require(_admin != address(0), "Cannot be zero address");
        require(_rMNER != address(0), "Cannot be zero address");
        require(_r2MNER != address(0), "Cannot be zero address");
        rMNER = _rMNER;
        r2MNER = _r2MNER;
        rMnerPrice = _price;
        admin = _admin;
        assetManager = _assetManger;
    }

    function swap(address tokenA, uint256 _amount) public payable nonReentrant {
        require(tokenA == rMNER || tokenA == r2MNER, "Unsupported tokens");

        if (tokenA == rMNER) {
            _swapIn(_amount);
        } else {
            _swapOut(_amount);
        }
    }
    function _swapIn(uint256 _amount) internal {
        require(!stopSwap, "Exchange not opened");

        uint256 _rMnerFee = (_amount * inFee) / 10000;
        uint256 _outAmount = ((_amount - _rMnerFee) * rate) / 10000;

        IERC20(rMNER).safeTransferFrom(msg.sender, address(this), _amount);
        if (_rMnerFee > 0) {
            IERC20(rMNER).safeTransfer(feeReceive, _rMnerFee);
        }
        _takeBtcFee(_amount, btcInFee);

        IR2MNER(r2MNER).mintTo(msg.sender, _outAmount);

        emit Swap(msg.sender, rMNER, r2MNER, _amount, _outAmount);
    }

    function _swapOut(uint256 _amount) internal {
        require(!stopOutSwap, "Exchange not opened");
        uint256 _outAmount = (_amount * 10000) / rate;
        uint256 _feeAmount = (_outAmount * outFee) / 10000;

        _takeBtcFee(_outAmount, btcOutFee);

        TransferHelper.safeTransferFrom(r2MNER, msg.sender, address(this), _amount);
        IR2MNER(r2MNER).burn(IR2MNER(r2MNER).balanceOf(address(this)));

        if (_feeAmount > 0) {
            IERC20(rMNER).safeTransfer(feeReceive, _feeAmount);
        }
        IERC20(rMNER).safeTransfer(msg.sender, _outAmount - _feeAmount);

        emit Swap(msg.sender, r2MNER, rMNER, _amount, _outAmount);
    }

    function _takeBtcFee(uint256 _amount, uint256 _feeRate) internal {
        if (_feeRate > 0) {
            uint256 _feeAmount = _amount.mul(_feeRate).div(10000);
            uint256 _rMnerPrice = IRMNERPrice(rMnerPrice).getPrice();
            uint256 _btcFee = _feeAmount.mul(_rMnerPrice).div(10 ** 18);
            require(msg.value >= _btcFee, "Insufficient handling fee");
            (bool rsuccess, ) = payable(feeReceive).call{ value: _btcFee }("");
            if (!rsuccess) {
                revert();
            }
            uint256 _feeOver = msg.value - _btcFee;
            if (_feeOver > 21000) {
                (bool success, ) = payable(msg.sender).call{ value: _feeOver }("");
                if (!success) {
                    revert();
                }
            }
        }
    }

    function withdrawTokensSelf(address token, address to) external onlyAssetManager {
        require(to != address(0), "Cannot be zero address");
        if (token == address(0)) {
            (bool success, ) = payable(to).call{ value: address(this).balance }("");
            if (!success) {
                revert();
            }
        } else {
            uint256 bal = IERC20(token).balanceOf(address(this));
            IERC20(token).safeTransfer(to, bal);
        }
        emit Withdraw(token, to);
    }

    function setBtcFee(uint256 _in, uint256 _out) external onlyAdmin {
        btcInFee = _in;
        btcOutFee = _out;
        emit UpdateBtcFee(_in, _out);
    }

    function setFee(uint256 _in, uint256 _out) external onlyAdmin {
        inFee = _in;
        outFee = _out;
        emit UpdateFee(_in, _out);
    }

    function setSwapRate(uint256 _rate) external onlyAdmin {
        require(_rate > 0, "Ratio must be greater than 0");
        uint256 prev = rate;
        rate = _rate;
        emit UpdateRate(prev, _rate);
    }
    function setStopOutSwap(bool _stop) external onlyOwner {
        bool prev = stopOutSwap;
        stopOutSwap = _stop;
        emit UpdateOutSwapState(prev, _stop);
    }

    function setStopSwap(bool _stop) external onlyOwner {
        bool prev = stopSwap;
        stopSwap = _stop;
        emit UpdateSwapState(prev, _stop);
    }

    function setPriceAddress(address rMnerPrice_) external onlyOwner {
        require(rMnerPrice_ != address(0), "Cannot be zero address");
        address prev = rMnerPrice;
        rMnerPrice = rMnerPrice_;
        emit UpdateRMnerPrice(prev, rMnerPrice_);
    }

    function setFeeReceive(address feeReceive_) external onlyOwner {
        require(feeReceive_ != address(0), "Cannot be zero address");
        address prev = feeReceive;
        feeReceive = feeReceive_;
        emit UpdateFeeReceive(prev, feeReceive_);
    }

    function setAdmin(address admin_) external onlyOwner {
        require(admin_ != address(0), "Cannot be zero address");
        address prev = admin;
        admin = admin_;
        emit UpdateAdmin(prev, admin_);
    }

    function setAssetManager(address assetManager_) external onlyOwner {
        require(assetManager_ != address(0), "Cannot be zero address");
        address prev = assetManager;
        assetManager = assetManager_;
        emit UpdateAdmin(prev, assetManager_);
    }

    receive() external payable {
        emit Received(msg.sender, msg.value);
    }

    event Received(address, uint256);

    event Withdraw(address token, address to);
    event UpdateBtcFee(uint256 inFee, uint256 outFee);
    event UpdateFee(uint256 inFee, uint256 outFee);
    event UpdateSwapState(bool oldState, bool newState);
    event UpdateRate(uint256 oldRate, uint256 newRate);
    event UpdateRMnerPrice(address old, address newAddress);
    event UpdateFeeReceive(address old, address newAddress);
    event UpdateOutSwapState(bool oldState, bool newState);
    event UpdateAdmin(address old, address newAddress);
    event UpdateAssetManager(address old, address newAddress);
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.7;

import {Context} from "./Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.7;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../interface/IERC20.sol";
import "../interface/IERC20Permit.sol";
import "./Address.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 IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    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'
        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 Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}
SafeMath.sol 72 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;


/**
 * @title SafeMath
 * @dev Math operations with safety checks that revert on error
 */
library SafeMath {
    string private constant ERROR_ADD_OVERFLOW = "MATH_ADD_OVERFLOW";
    string private constant ERROR_SUB_UNDERFLOW = "MATH_SUB_UNDERFLOW";
    string private constant ERROR_MUL_OVERFLOW = "MATH_MUL_OVERFLOW";
    string private constant ERROR_DIV_ZERO = "MATH_DIV_ZERO";

    /**
    * @dev Multiplies two numbers, reverts on overflow.
    */
    function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
        // 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-solidity/pull/522
        if (_a == 0) {
            return 0;
        }

        uint256 c = _a * _b;
        require(c / _a == _b, ERROR_MUL_OVERFLOW);

        return c;
    }

    /**
    * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
    */
    function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
        require(_b > 0, ERROR_DIV_ZERO); // Solidity only automatically asserts when dividing by 0
        uint256 c = _a / _b;
        // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold

        return c;
    }

    /**
    * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
    */
    function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
        require(_b <= _a, ERROR_SUB_UNDERFLOW);
        uint256 c = _a - _b;

        return c;
    }

    /**
    * @dev Adds two numbers, reverts on overflow.
    */
    function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
        uint256 c = _a + _b;
        require(c >= _a, ERROR_ADD_OVERFLOW);

        return c;
    }

    /**
    * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
    * reverts when dividing by zero.
    */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0, ERROR_DIV_ZERO);
        return a % b;
    }
}
TransferHelper.sol 60 lines
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import "../interface/IERC20.sol";

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) =
            token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

Read Contract

btcInFee 0xa19a765c → uint256
btcOutFee 0xd5cf9080 → uint256
feeReceive 0x08e4aaef → address
inFee 0x86a95468 → uint256
outFee 0x59d401ef → uint256
owner 0x8da5cb5b → address
r2MNER 0x5a76f319 → address
rMNER 0x2184a44c → address
rMnerPrice 0x482c988c → address
rate 0x2c4e722e → uint256
stopOutSwap 0xa95e02f3 → bool
stopSwap 0xb633b364 → bool

Write Contract 13 functions

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

renounceOwnership 0x715018a6
No parameters
setAdmin 0x704b6c02
address admin_
setAssetManager 0x43060237
address assetManager_
setBtcFee 0xad2625e6
uint256 _in
uint256 _out
setFee 0x52f7c988
uint256 _in
uint256 _out
setFeeReceive 0x29d65940
address feeReceive_
setPriceAddress 0x872d136a
address rMnerPrice_
setStopOutSwap 0x51e04ca8
bool _stop
setStopSwap 0xabab2499
bool _stop
setSwapRate 0xf4cde469
uint256 _rate
swap 0xd004f0f7
address tokenA
uint256 _amount
transferOwnership 0xf2fde38b
address newOwner
withdrawTokensSelf 0x25617950
address token
address to

Recent Transactions

No transactions found for this address