Contract 0x4c56dbcc056655b8813539af9c819ae128c07e17 2

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xbe0899ad8ec698edb2acffb9629baa83ac6428c72d6eb6b19e008590706fdc150x6080604017360342021-09-29 1:38:04364 days 7 hrs ago0xb4efda6daf5ef75d08869a0f9c0213278fb43b6c IN  Create: ArbEthSwapper0 ETH0.013463270097 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xfac2573c317bcf86e80f3cdbcb22b11dbcdf0520d02e47e74368977f8cdb175d270802462022-09-28 0:41:168 hrs 50 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0xfac2573c317bcf86e80f3cdbcb22b11dbcdf0520d02e47e74368977f8cdb175d270802462022-09-28 0:41:168 hrs 50 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0xfac2573c317bcf86e80f3cdbcb22b11dbcdf0520d02e47e74368977f8cdb175d270802462022-09-28 0:41:168 hrs 50 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0xfac2573c317bcf86e80f3cdbcb22b11dbcdf0520d02e47e74368977f8cdb175d270802462022-09-28 0:41:168 hrs 50 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0xfac2573c317bcf86e80f3cdbcb22b11dbcdf0520d02e47e74368977f8cdb175d270802462022-09-28 0:41:168 hrs 50 mins ago 0xc89958b03a55b5de2221acb25b58b89a000215e6 0x4c56dbcc056655b8813539af9c819ae128c07e170 ETH
0xce4aacf7b4232c7d71b208b743187ad8d285154a10565f5c926fdd48d40e3906270729452022-09-27 23:23:4510 hrs 8 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0xce4aacf7b4232c7d71b208b743187ad8d285154a10565f5c926fdd48d40e3906270729452022-09-27 23:23:4510 hrs 8 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0xce4aacf7b4232c7d71b208b743187ad8d285154a10565f5c926fdd48d40e3906270729452022-09-27 23:23:4510 hrs 8 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0xce4aacf7b4232c7d71b208b743187ad8d285154a10565f5c926fdd48d40e3906270729452022-09-27 23:23:4510 hrs 8 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0xce4aacf7b4232c7d71b208b743187ad8d285154a10565f5c926fdd48d40e3906270729452022-09-27 23:23:4510 hrs 8 mins ago 0xc89958b03a55b5de2221acb25b58b89a000215e6 0x4c56dbcc056655b8813539af9c819ae128c07e170 ETH
0x3cd24f47ac690b8a4ef8a9afaf1783e3d5dbeddea0418a7c5894274db1d3d365270509732022-09-27 19:34:5613 hrs 57 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0x3cd24f47ac690b8a4ef8a9afaf1783e3d5dbeddea0418a7c5894274db1d3d365270509732022-09-27 19:34:5613 hrs 57 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0x3cd24f47ac690b8a4ef8a9afaf1783e3d5dbeddea0418a7c5894274db1d3d365270509732022-09-27 19:34:5613 hrs 57 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0x3cd24f47ac690b8a4ef8a9afaf1783e3d5dbeddea0418a7c5894274db1d3d365270509732022-09-27 19:34:5613 hrs 57 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0x3cd24f47ac690b8a4ef8a9afaf1783e3d5dbeddea0418a7c5894274db1d3d365270509732022-09-27 19:34:5613 hrs 57 mins ago 0xc89958b03a55b5de2221acb25b58b89a000215e6 0x4c56dbcc056655b8813539af9c819ae128c07e170 ETH
0x82a4e9a4fd7425fce56dbb8820bfbe0514e3c65d074594411390a87737a655d0269761112022-09-27 11:32:4621 hrs 59 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0x82a4e9a4fd7425fce56dbb8820bfbe0514e3c65d074594411390a87737a655d0269761112022-09-27 11:32:4621 hrs 59 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0x82a4e9a4fd7425fce56dbb8820bfbe0514e3c65d074594411390a87737a655d0269761112022-09-27 11:32:4621 hrs 59 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0x82a4e9a4fd7425fce56dbb8820bfbe0514e3c65d074594411390a87737a655d0269761112022-09-27 11:32:4621 hrs 59 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0x82a4e9a4fd7425fce56dbb8820bfbe0514e3c65d074594411390a87737a655d0269761112022-09-27 11:32:4621 hrs 59 mins ago 0xc89958b03a55b5de2221acb25b58b89a000215e6 0x4c56dbcc056655b8813539af9c819ae128c07e170 ETH
0x72b14a24ed96ad65ada067f5525a16ea95c226fa9f09f35cb6ec19975333d33a269743412022-09-27 11:20:2122 hrs 11 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0x72b14a24ed96ad65ada067f5525a16ea95c226fa9f09f35cb6ec19975333d33a269743412022-09-27 11:20:2122 hrs 11 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0x72b14a24ed96ad65ada067f5525a16ea95c226fa9f09f35cb6ec19975333d33a269743412022-09-27 11:20:2122 hrs 11 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e170xb6dd51d5425861c808fd60827ab6cfbffe6049590 ETH
0x72b14a24ed96ad65ada067f5525a16ea95c226fa9f09f35cb6ec19975333d33a269743412022-09-27 11:20:2122 hrs 11 mins ago 0x4c56dbcc056655b8813539af9c819ae128c07e17 0x74c764d41b77dbbb4fe771dab1939b00b146894a0 ETH
0x72b14a24ed96ad65ada067f5525a16ea95c226fa9f09f35cb6ec19975333d33a269743412022-09-27 11:20:2122 hrs 11 mins ago 0xc89958b03a55b5de2221acb25b58b89a000215e6 0x4c56dbcc056655b8813539af9c819ae128c07e170 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ArbEthSwapper

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 13 : ArbEthSwapper.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.12;
import "@boringcrypto/boring-solidity/contracts/libraries/BoringMath.sol";
import "@sushiswap/core/contracts/uniswapv2/interfaces/IUniswapV2Factory.sol";
import "@sushiswap/core/contracts/uniswapv2/interfaces/IUniswapV2Pair.sol";
import "../../interfaces/ISwapper.sol";
import "@sushiswap/bentobox-sdk/contracts/IBentoBoxV1.sol";
import "../../libraries/UniswapV2Library.sol";


contract ArbEthSwapper is ISwapper {
    using BoringMath for uint256;

    // Local variables
    IBentoBoxV1 public constant bentoBox = IBentoBoxV1(0x74c764D41B77DBbb4fe771daB1939B00b146894A);
    IUniswapV2Pair constant pair = IUniswapV2Pair(0xb6DD51D5425861C808Fd60827Ab6CFBfFE604959);
    IERC20 constant WETH = IERC20(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1);
    IERC20 public constant MIM = IERC20(0xFEa7a6a0B346362BF88A9e4A88416B77a57D6c2A);

    // Given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(
        uint256 amountIn,
        uint256 reserveIn,
        uint256 reserveOut
    ) internal pure returns (uint256 amountOut) {
        uint256 amountInWithFee = amountIn.mul(997);
        uint256 numerator = amountInWithFee.mul(reserveOut);
        uint256 denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // Given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(
        uint256 amountOut,
        uint256 reserveIn,
        uint256 reserveOut
    ) internal pure returns (uint256 amountIn) {
        uint256 numerator = reserveIn.mul(amountOut).mul(1000);
        uint256 denominator = reserveOut.sub(amountOut).mul(997);
        amountIn = (numerator / denominator).add(1);
    }

    // Swaps to a flexible amount, from an exact input amount
    /// @inheritdoc ISwapper
    function swap(
        IERC20 fromToken,
        IERC20 toToken,
        address recipient,
        uint256 shareToMin,
        uint256 shareFrom
    ) public override returns (uint256 extraShare, uint256 shareReturned) {

        (uint256 amountFrom,) = bentoBox.withdraw(fromToken, address(this), address(pair), 0, shareFrom);

        (address token0, ) = UniswapV2Library.sortTokens(address(MIM), address(WETH));

        (uint256 reserve0, uint256 reserve1, ) = pair.getReserves();

        (reserve0, reserve1) = address(WETH) == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
        
        uint256  amountTo = getAmountOut(amountFrom, reserve0, reserve1);

        (uint256 amount0Out, uint256 amount1Out) = address(WETH) == token0
                ? (uint256(0), amountTo)
                : (amountTo, uint256(0));

        pair.swap(amount0Out, amount1Out, address(bentoBox), new bytes(0));

        (, shareReturned) = bentoBox.deposit(toToken, address(bentoBox), recipient, amountTo, 0);
        extraShare = shareReturned.sub(shareToMin);
    }

    // Swaps to an exact amount, from a flexible input amount
    /// @inheritdoc ISwapper
    function swapExact(
        IERC20 fromToken,
        IERC20 toToken,
        address recipient,
        address refundTo,
        uint256 shareFromSupplied,
        uint256 shareToExact
    ) public override returns (uint256 shareUsed, uint256 shareReturned) {
        return (0,0);
    }
}

File 2 of 13 : BoringMath.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

/// @notice A library for performing overflow-/underflow-safe math,
/// updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math).
library BoringMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
        require((c = a + b) >= b, "BoringMath: Add Overflow");
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {
        require((c = a - b) <= a, "BoringMath: Underflow");
    }

    function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
        require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow");
    }

    function to128(uint256 a) internal pure returns (uint128 c) {
        require(a <= uint128(-1), "BoringMath: uint128 Overflow");
        c = uint128(a);
    }

    function to64(uint256 a) internal pure returns (uint64 c) {
        require(a <= uint64(-1), "BoringMath: uint64 Overflow");
        c = uint64(a);
    }

    function to32(uint256 a) internal pure returns (uint32 c) {
        require(a <= uint32(-1), "BoringMath: uint32 Overflow");
        c = uint32(a);
    }
}

/// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint128.
library BoringMath128 {
    function add(uint128 a, uint128 b) internal pure returns (uint128 c) {
        require((c = a + b) >= b, "BoringMath: Add Overflow");
    }

    function sub(uint128 a, uint128 b) internal pure returns (uint128 c) {
        require((c = a - b) <= a, "BoringMath: Underflow");
    }
}

/// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint64.
library BoringMath64 {
    function add(uint64 a, uint64 b) internal pure returns (uint64 c) {
        require((c = a + b) >= b, "BoringMath: Add Overflow");
    }

    function sub(uint64 a, uint64 b) internal pure returns (uint64 c) {
        require((c = a - b) <= a, "BoringMath: Underflow");
    }
}

/// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32.
library BoringMath32 {
    function add(uint32 a, uint32 b) internal pure returns (uint32 c) {
        require((c = a + b) >= b, "BoringMath: Add Overflow");
    }

    function sub(uint32 a, uint32 b) internal pure returns (uint32 c) {
        require((c = a - b) <= a, "BoringMath: Underflow");
    }
}

File 3 of 13 : IUniswapV2Factory.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);
    function migrator() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
    function setMigrator(address) external;
}

File 4 of 13 : IUniswapV2Pair.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 5 of 13 : ISwapper.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import "@boringcrypto/boring-solidity/contracts/interfaces/IERC20.sol";

interface ISwapper {
    /// @notice Withdraws 'amountFrom' of token 'from' from the BentoBox account for this swapper.
    /// Swaps it for at least 'amountToMin' of token 'to'.
    /// Transfers the swapped tokens of 'to' into the BentoBox using a plain ERC20 transfer.
    /// Returns the amount of tokens 'to' transferred to BentoBox.
    /// (The BentoBox skim function will be used by the caller to get the swapped funds).
    function swap(
        IERC20 fromToken,
        IERC20 toToken,
        address recipient,
        uint256 shareToMin,
        uint256 shareFrom
    ) external returns (uint256 extraShare, uint256 shareReturned);

    /// @notice Calculates the amount of token 'from' needed to complete the swap (amountFrom),
    /// this should be less than or equal to amountFromMax.
    /// Withdraws 'amountFrom' of token 'from' from the BentoBox account for this swapper.
    /// Swaps it for exactly 'exactAmountTo' of token 'to'.
    /// Transfers the swapped tokens of 'to' into the BentoBox using a plain ERC20 transfer.
    /// Transfers allocated, but unused 'from' tokens within the BentoBox to 'refundTo' (amountFromMax - amountFrom).
    /// Returns the amount of 'from' tokens withdrawn from BentoBox (amountFrom).
    /// (The BentoBox skim function will be used by the caller to get the swapped funds).
    function swapExact(
        IERC20 fromToken,
        IERC20 toToken,
        address recipient,
        address refundTo,
        uint256 shareFromSupplied,
        uint256 shareToExact
    ) external returns (uint256 shareUsed, uint256 shareReturned);
}

File 6 of 13 : IBentoBoxV1.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import '@boringcrypto/boring-solidity/contracts/interfaces/IERC20.sol';
import '@boringcrypto/boring-solidity/contracts/libraries/BoringRebase.sol';
import './IBatchFlashBorrower.sol';
import './IFlashBorrower.sol';
import './IStrategy.sol';

interface IBentoBoxV1 {
    event LogDeploy(address indexed masterContract, bytes data, address indexed cloneAddress);
    event LogDeposit(address indexed token, address indexed from, address indexed to, uint256 amount, uint256 share);
    event LogFlashLoan(address indexed borrower, address indexed token, uint256 amount, uint256 feeAmount, address indexed receiver);
    event LogRegisterProtocol(address indexed protocol);
    event LogSetMasterContractApproval(address indexed masterContract, address indexed user, bool approved);
    event LogStrategyDivest(address indexed token, uint256 amount);
    event LogStrategyInvest(address indexed token, uint256 amount);
    event LogStrategyLoss(address indexed token, uint256 amount);
    event LogStrategyProfit(address indexed token, uint256 amount);
    event LogStrategyQueued(address indexed token, address indexed strategy);
    event LogStrategySet(address indexed token, address indexed strategy);
    event LogStrategyTargetPercentage(address indexed token, uint256 targetPercentage);
    event LogTransfer(address indexed token, address indexed from, address indexed to, uint256 share);
    event LogWhiteListMasterContract(address indexed masterContract, bool approved);
    event LogWithdraw(address indexed token, address indexed from, address indexed to, uint256 amount, uint256 share);
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    function balanceOf(IERC20, address) external view returns (uint256);
    function batch(bytes[] calldata calls, bool revertOnFail) external payable returns (bool[] memory successes, bytes[] memory results);
    function batchFlashLoan(IBatchFlashBorrower borrower, address[] calldata receivers, IERC20[] calldata tokens, uint256[] calldata amounts, bytes calldata data) external;
    function claimOwnership() external;
    function deploy(address masterContract, bytes calldata data, bool useCreate2) external payable;
    function deposit(IERC20 token_, address from, address to, uint256 amount, uint256 share) external payable returns (uint256 amountOut, uint256 shareOut);
    function flashLoan(IFlashBorrower borrower, address receiver, IERC20 token, uint256 amount, bytes calldata data) external;
    function harvest(IERC20 token, bool balance, uint256 maxChangeAmount) external;
    function masterContractApproved(address, address) external view returns (bool);
    function masterContractOf(address) external view returns (address);
    function nonces(address) external view returns (uint256);
    function owner() external view returns (address);
    function pendingOwner() external view returns (address);
    function pendingStrategy(IERC20) external view returns (IStrategy);
    function permitToken(IERC20 token, address from, address to, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
    function registerProtocol() external;
    function setMasterContractApproval(address user, address masterContract, bool approved, uint8 v, bytes32 r, bytes32 s) external;
    function setStrategy(IERC20 token, IStrategy newStrategy) external;
    function setStrategyTargetPercentage(IERC20 token, uint64 targetPercentage_) external;
    function strategy(IERC20) external view returns (IStrategy);
    function strategyData(IERC20) external view returns (uint64 strategyStartDate, uint64 targetPercentage, uint128 balance);
    function toAmount(IERC20 token, uint256 share, bool roundUp) external view returns (uint256 amount);
    function toShare(IERC20 token, uint256 amount, bool roundUp) external view returns (uint256 share);
    function totals(IERC20) external view returns (Rebase memory totals_);
    function transfer(IERC20 token, address from, address to, uint256 share) external;
    function transferMultiple(IERC20 token, address from, address[] calldata tos, uint256[] calldata shares) external;
    function transferOwnership(address newOwner, bool direct, bool renounce) external;
    function whitelistMasterContract(address masterContract, bool approved) external;
    function whitelistedMasterContracts(address) external view returns (bool);
    function withdraw(IERC20 token_, address from, address to, uint256 amount, uint256 share) external returns (uint256 amountOut, uint256 shareOut);
}

File 7 of 13 : UniswapV2Library.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0;

import "@sushiswap/core/contracts/uniswapv2/interfaces/IUniswapV2Pair.sol";

import "@sushiswap/core/contracts/uniswapv2/libraries/SafeMath.sol";

library UniswapV2Library {
    using SafeMathUniswap for uint256;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, "UniswapV2Library: IDENTICAL_ADDRESSES");
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), "UniswapV2Library: ZERO_ADDRESS");
    }

    // calculates the CREATE2 address for a pair without making any external calls
    function pairFor(
        address factory,
        address tokenA,
        address tokenB,
        bytes32 pairCodeHash
    ) internal pure returns (address pair) {
        (address token0, address token1) = sortTokens(tokenA, tokenB);
        pair = address(
            uint256(
                keccak256(
                    abi.encodePacked(
                        hex"ff",
                        factory,
                        keccak256(abi.encodePacked(token0, token1)),
                        pairCodeHash // init code hash
                    )
                )
            )
        );
    }

    // fetches and sorts the reserves for a pair
    function getReserves(
        address factory,
        address tokenA,
        address tokenB,
        bytes32 pairCodeHash
    ) internal view returns (uint256 reserveA, uint256 reserveB) {
        (address token0, ) = sortTokens(tokenA, tokenB);
        (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB, pairCodeHash)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
    function quote(
        uint256 amountA,
        uint256 reserveA,
        uint256 reserveB
    ) internal pure returns (uint256 amountB) {
        require(amountA > 0, "UniswapV2Library: INSUFFICIENT_AMOUNT");
        require(reserveA > 0 && reserveB > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
        amountB = amountA.mul(reserveB) / reserveA;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(
        uint256 amountIn,
        uint256 reserveIn,
        uint256 reserveOut
    ) internal pure returns (uint256 amountOut) {
        require(amountIn > 0, "UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT");
        require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
        uint256 amountInWithFee = amountIn.mul(997);
        uint256 numerator = amountInWithFee.mul(reserveOut);
        uint256 denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(
        uint256 amountOut,
        uint256 reserveIn,
        uint256 reserveOut
    ) internal pure returns (uint256 amountIn) {
        require(amountOut > 0, "UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT");
        require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
        uint256 numerator = reserveIn.mul(amountOut).mul(1000);
        uint256 denominator = reserveOut.sub(amountOut).mul(997);
        amountIn = (numerator / denominator).add(1);
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(
        address factory,
        uint256 amountIn,
        address[] memory path,
        bytes32 pairCodeHash
    ) internal view returns (uint256[] memory amounts) {
        require(path.length >= 2, "UniswapV2Library: INVALID_PATH");
        amounts = new uint256[](path.length);
        amounts[0] = amountIn;
        for (uint256 i; i < path.length - 1; i++) {
            (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1], pairCodeHash);
            amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(
        address factory,
        uint256 amountOut,
        address[] memory path,
        bytes32 pairCodeHash
    ) internal view returns (uint256[] memory amounts) {
        require(path.length >= 2, "UniswapV2Library: INVALID_PATH");
        amounts = new uint256[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint256 i = path.length - 1; i > 0; i--) {
            (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i], pairCodeHash);
            amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }
}

File 8 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

interface IERC20 {
    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

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

    /// @notice EIP 2612
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}

File 9 of 13 : BoringRebase.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import "./BoringMath.sol";

struct Rebase {
    uint128 elastic;
    uint128 base;
}

/// @notice A rebasing library using overflow-/underflow-safe math.
library RebaseLibrary {
    using BoringMath for uint256;
    using BoringMath128 for uint128;

    /// @notice Calculates the base value in relationship to `elastic` and `total`.
    function toBase(
        Rebase memory total,
        uint256 elastic,
        bool roundUp
    ) internal pure returns (uint256 base) {
        if (total.elastic == 0) {
            base = elastic;
        } else {
            base = elastic.mul(total.base) / total.elastic;
            if (roundUp && base.mul(total.elastic) / total.base < elastic) {
                base = base.add(1);
            }
        }
    }

    /// @notice Calculates the elastic value in relationship to `base` and `total`.
    function toElastic(
        Rebase memory total,
        uint256 base,
        bool roundUp
    ) internal pure returns (uint256 elastic) {
        if (total.base == 0) {
            elastic = base;
        } else {
            elastic = base.mul(total.elastic) / total.base;
            if (roundUp && elastic.mul(total.base) / total.elastic < base) {
                elastic = elastic.add(1);
            }
        }
    }

    /// @notice Add `elastic` to `total` and doubles `total.base`.
    /// @return (Rebase) The new total.
    /// @return base in relationship to `elastic`.
    function add(
        Rebase memory total,
        uint256 elastic,
        bool roundUp
    ) internal pure returns (Rebase memory, uint256 base) {
        base = toBase(total, elastic, roundUp);
        total.elastic = total.elastic.add(elastic.to128());
        total.base = total.base.add(base.to128());
        return (total, base);
    }

    /// @notice Sub `base` from `total` and update `total.elastic`.
    /// @return (Rebase) The new total.
    /// @return elastic in relationship to `base`.
    function sub(
        Rebase memory total,
        uint256 base,
        bool roundUp
    ) internal pure returns (Rebase memory, uint256 elastic) {
        elastic = toElastic(total, base, roundUp);
        total.elastic = total.elastic.sub(elastic.to128());
        total.base = total.base.sub(base.to128());
        return (total, elastic);
    }

    /// @notice Add `elastic` and `base` to `total`.
    function add(
        Rebase memory total,
        uint256 elastic,
        uint256 base
    ) internal pure returns (Rebase memory) {
        total.elastic = total.elastic.add(elastic.to128());
        total.base = total.base.add(base.to128());
        return total;
    }

    /// @notice Subtract `elastic` and `base` to `total`.
    function sub(
        Rebase memory total,
        uint256 elastic,
        uint256 base
    ) internal pure returns (Rebase memory) {
        total.elastic = total.elastic.sub(elastic.to128());
        total.base = total.base.sub(base.to128());
        return total;
    }

    /// @notice Add `elastic` to `total` and update storage.
    /// @return newElastic Returns updated `elastic`.
    function addElastic(Rebase storage total, uint256 elastic) internal returns (uint256 newElastic) {
        newElastic = total.elastic = total.elastic.add(elastic.to128());
    }

    /// @notice Subtract `elastic` from `total` and update storage.
    /// @return newElastic Returns updated `elastic`.
    function subElastic(Rebase storage total, uint256 elastic) internal returns (uint256 newElastic) {
        newElastic = total.elastic = total.elastic.sub(elastic.to128());
    }
}

File 10 of 13 : IBatchFlashBorrower.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import '@boringcrypto/boring-solidity/contracts/interfaces/IERC20.sol';

interface IBatchFlashBorrower {
    function onBatchFlashLoan(
        address sender,
        IERC20[] calldata tokens,
        uint256[] calldata amounts,
        uint256[] calldata fees,
        bytes calldata data
    ) external;
}

File 11 of 13 : IFlashBorrower.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import '@boringcrypto/boring-solidity/contracts/interfaces/IERC20.sol';

interface IFlashBorrower {
    function onFlashLoan(
        address sender,
        IERC20 token,
        uint256 amount,
        uint256 fee,
        bytes calldata data
    ) external;
}

File 12 of 13 : IStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

interface IStrategy {
    // Send the assets to the Strategy and call skim to invest them
    function skim(uint256 amount) external;

    // Harvest any profits made converted to the asset and pass them to the caller
    function harvest(uint256 balance, address sender) external returns (int256 amountAdded);

    // Withdraw assets. The returned amount can differ from the requested amount due to rounding.
    // The actualAmount should be very close to the amount. The difference should NOT be used to report a loss. That's what harvest is for.
    function withdraw(uint256 amount) external returns (uint256 actualAmount);

    // Withdraw all assets in the safest way possible. This shouldn't fail.
    function exit(uint256 balance) external returns (int256 amountAdded);
}

File 13 of 13 : SafeMath.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity =0.6.12;

// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)

library SafeMathUniswap {
    function add(uint x, uint y) internal pure returns (uint z) {
        require((z = x + y) >= x, 'ds-math-add-overflow');
    }

    function sub(uint x, uint y) internal pure returns (uint z) {
        require((z = x - y) <= x, 'ds-math-sub-underflow');
    }

    function mul(uint x, uint y) internal pure returns (uint z) {
        require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
    }
}

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

Contract ABI

[{"inputs":[],"name":"MIM","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bentoBox","outputs":[{"internalType":"contract IBentoBoxV1","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"shareToMin","type":"uint256"},{"internalType":"uint256","name":"shareFrom","type":"uint256"}],"name":"swap","outputs":[{"internalType":"uint256","name":"extraShare","type":"uint256"},{"internalType":"uint256","name":"shareReturned","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"uint256","name":"shareFromSupplied","type":"uint256"},{"internalType":"uint256","name":"shareToExact","type":"uint256"}],"name":"swapExact","outputs":[{"internalType":"uint256","name":"shareUsed","type":"uint256"},{"internalType":"uint256","name":"shareReturned","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5061080a806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80634622be90146100515780636b2ace87146100b6578063daec383d146100da578063e343fe12146100e2575b600080fd5b61009d600480360360c081101561006757600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a00135610124565b6040805192835260208301919091528051918290030190f35b6100be610132565b604080516001600160a01b039092168252519081900360200190f35b6100be61014a565b61009d600480360360a08110156100f857600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101359060800135610162565b600080965096945050505050565b7374c764d41b77dbbb4fe771dab1939b00b146894a81565b73fea7a6a0b346362bf88a9e4a88416b77a57d6c2a81565b6040805163097da6d360e41b81526001600160a01b038716600482015230602482015273b6dd51d5425861c808fd60827ab6cfbffe60495960448201526000606482018190526084820184905282519092839283927374c764d41b77dbbb4fe771dab1939b00b146894a926397da6d309260a4808201939182900301818787803b1580156101ef57600080fd5b505af1158015610203573d6000803e3d6000fd5b505050506040513d604081101561021957600080fd5b50519050600061025173fea7a6a0b346362bf88a9e4a88416b77a57d6c2a7382af49447d8a07e3bd95bd0d56f35241523fbab1610569565b50905060008073b6dd51d5425861c808fd60827ab6cfbffe6049596001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156102a457600080fd5b505afa1580156102b8573d6000803e3d6000fd5b505050506040513d60608110156102ce57600080fd5b5080516020909101516dffffffffffffffffffffffffffff91821693501690507382af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b0384161461031957808261031c565b81815b9092509050600061032e858484610647565b90506000807382af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b0387161461035f57826000610363565b6000835b604080516000808252602082019283905263022c0d9f60e01b835260248201858152604483018590527374c764d41b77dbbb4fe771dab1939b00b146894a60648401819052608060848501908152845160a4860181905297995095975073b6dd51d5425861c808fd60827ab6cfbffe6049599663022c0d9f968a968a969395939493919260c48601928190849084905b8381101561040b5781810151838201526020016103f3565b50505050905090810190601f1680156104385780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561045a57600080fd5b505af115801561046e573d6000803e3d6000fd5b505050507374c764d41b77dbbb4fe771dab1939b00b146894a6001600160a01b03166302b9446c8e7374c764d41b77dbbb4fe771dab1939b00b146894a8f8760006040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b03168152602001838152602001828152602001955050505050506040805180830381600087803b15801561051b57600080fd5b505af115801561052f573d6000803e3d6000fd5b505050506040513d604081101561054557600080fd5b50602001519750610556888c610695565b9850505050505050509550959350505050565b600080826001600160a01b0316846001600160a01b031614156105bd5760405162461bcd60e51b81526004018080602001828103825260258152602001806107b06025913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b0316106105dd5782846105e0565b83835b90925090506001600160a01b038216610640576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b600080610656856103e56106eb565b9050600061066482856106eb565b9050600061067e83610678886103e86106eb565b90610757565b905080828161068957fe5b04979650505050505050565b808203828111156106e5576040805162461bcd60e51b8152602060048201526015602482015274426f72696e674d6174683a20556e646572666c6f7760581b604482015290519081900360640190fd5b92915050565b60008115806107065750508082028282828161070357fe5b04145b6106e5576040805162461bcd60e51b815260206004820152601860248201527f426f72696e674d6174683a204d756c204f766572666c6f770000000000000000604482015290519081900360640190fd5b818101818110156106e5576040805162461bcd60e51b815260206004820152601860248201527f426f72696e674d6174683a20416464204f766572666c6f770000000000000000604482015290519081900360640190fdfe556e697377617056324c6962726172793a204944454e544943414c5f414444524553534553a2646970667358221220540dddfe4bc2d90b9e39a89c9350c1897e55e96d8835821d547f71ada41220f864736f6c634300060c0033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.