Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x05d17cD6b4783CFa2eE1484677d076C68Fffe2f4
Balance 0 ETH
Nonce 1
Code Size 7567 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7567 bytes
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063853828b6116100c3578063d2a9d8621161007c578063d2a9d86214610279578063dc301fa214610281578063ddca3f4314610289578063e563037e14610291578063f4b9fa7514610299578063f77c4791146102a15761014d565b8063853828b61461020d57806392eefe9b14610215578063ab033ea91461023b578063c1a3d44c14610261578063c92aecc414610269578063d0e30db0146102715761014d565b80633fc8cef3116101155780633fc8cef3146101ad5780634641257d146101b557806351cff8d9146101bd5780635aa6e675146101f55780636ac5db19146101fd578063722713f7146102055761014d565b8063071c03321461015257806316f0115b146101765780631f1fcd511461017e578063257ae0de146101865780632e1a7d4d1461018e575b600080fd5b61015a6102a9565b604080516001600160a01b039092168252519081900360200190f35b61015a6102c1565b61015a6102d0565b61015a6102df565b6101ab600480360360208110156101a457600080fd5b50356102f7565b005b61015a6104da565b6101ab6104f2565b6101e3600480360360208110156101d357600080fd5b50356001600160a01b0316610fb4565b60408051918252519081900360200190f35b61015a6110ea565b6101e36110f9565b6101e36110ff565b6101e361110e565b6101ab6004803603602081101561022b57600080fd5b50356001600160a01b03166112c6565b6101ab6004803603602081101561025157600080fd5b50356001600160a01b0316611335565b6101e36113a4565b61015a611420565b6101ab611432565b61015a6115c1565b6101e36115d9565b6101e3611624565b61015a611629565b61015a611641565b61015a611659565b730e2298e3b3390e3b945a5456fbf59ecc3f55da1681565b6003546001600160a01b031681565b6002546001600160a01b031681565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b6001546001600160a01b03163314610344576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561038f57600080fd5b505afa1580156103a3573d6000803e3d6000fd5b505050506040513d60208110156103b957600080fd5b50519050818110156103f2576103dd6103d8838363ffffffff61166816565b6116b3565b91506103ef828263ffffffff61171d16565b91505b60015460025460408051632988bb9f60e21b81526001600160a01b0392831660048201529051600093929092169163a622ee7c91602480820192602092909190829003018186803b15801561044657600080fd5b505afa15801561045a573d6000803e3d6000fd5b505050506040513d602081101561047057600080fd5b505190506001600160a01b0381166104b8576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b6002546104d5906001600160a01b0316828563ffffffff61177716565b505050565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b60005a9050600360009054906101000a90046001600160a01b03166001600160a01b0316633d18b9126040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561054757600080fd5b505af115801561055b573d6000803e3d6000fd5b505060015460025460408051632988bb9f60e21b81526001600160a01b03928316600482015290516000955091909216925063a622ee7c91602480820192602092909190829003018186803b1580156105b357600080fd5b505afa1580156105c7573d6000803e3d6000fd5b505050506040513d60208110156105dd57600080fd5b505190506001600160a01b038116610625576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b6040805163095ea7b360e01b8152737a250d5630b4cf539739df2c5dacb4c659f2488d600482015260001960248201529051730e2298e3b3390e3b945a5456fbf59ecc3f55da169163095ea7b39160448083019260209291908290030181600087803b15801561069457600080fd5b505af11580156106a8573d6000803e3d6000fd5b505050506040513d60208110156106be57600080fd5b505060408051600380825260808201909252606091602082018380388339019050509050730e2298e3b3390e3b945a5456fbf59ecc3f55da168160008151811061070457fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160018151811061074657fe5b60200260200101906001600160a01b031690816001600160a01b031681525050736b175474e89094c44da98b954eedeac495271d0f8160028151811061078857fe5b6001600160a01b03909216602092830291909101820152604080516370a0823160e01b81523060048201529051737a250d5630b4cf539739df2c5dacb4c659f2488d926338ed173992730e2298e3b3390e3b945a5456fbf59ecc3f55da16926370a0823192602480840193919291829003018186803b15801561080a57600080fd5b505afa15801561081e573d6000803e3d6000fd5b505050506040513d602081101561083457600080fd5b50516000843061084c4261070863ffffffff61171d16565b6040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03166001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b838110156108c55781810151838201526020016108ad565b505050509050019650505050505050600060405180830381600087803b1580156108ee57600080fd5b505af1158015610902573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561092b57600080fd5b810190808051604051939291908464010000000082111561094b57600080fd5b90830190602082018581111561096057600080fd5b825186602082028301116401000000008211171561097d57600080fd5b82525081516020918201928201910280838360005b838110156109aa578181015183820152602001610992565b50505050905001604052505050506109ff7316cac1403377978644e78769daa49d8f6b6cf5656000736b175474e89094c44da98b954eedeac495271d0f6001600160a01b03166117c99092919063ffffffff16565b604080516370a0823160e01b81523060048201529051610ab8917316cac1403377978644e78769daa49d8f6b6cf56591736b175474e89094c44da98b954eedeac495271d0f916370a08231916024808301926020929190829003018186803b158015610a6a57600080fd5b505afa158015610a7e573d6000803e3d6000fd5b505050506040513d6020811015610a9457600080fd5b5051736b175474e89094c44da98b954eedeac495271d0f919063ffffffff6117c916565b604080516370a0823160e01b815230600482015290517316cac1403377978644e78769daa49d8f6b6cf56591638201aa3f91736b175474e89094c44da98b954eedeac495271d0f9182916370a0823191602480820192602092909190829003018186803b158015610b2857600080fd5b505afa158015610b3c573d6000803e3d6000fd5b505050506040513d6020811015610b5257600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b039093166004840152602483019190915273a1d0e215a23d7030842fc67ce582a6afa3ccab8360448301526000606483018190526000196084840152815160a4808501949192918390030190829087803b158015610bcd57600080fd5b505af1158015610be1573d6000803e3d6000fd5b505050506040513d6040811015610bf757600080fd5b5050604080516370a0823160e01b8152306004820152905160009173a1d0e215a23d7030842fc67ce582a6afa3ccab83916370a0823191602480820192602092909190829003018186803b158015610c4e57600080fd5b505afa158015610c62573d6000803e3d6000fd5b505050506040513d6020811015610c7857600080fd5b505190506000610ca1612710610c9584603263ffffffff6118dc16565b9063ffffffff61193516565b9050610d42600160009054906101000a90046001600160a01b03166001600160a01b0316639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b158015610cf457600080fd5b505afa158015610d08573d6000803e3d6000fd5b505050506040513d6020811015610d1e57600080fd5b505173a1d0e215a23d7030842fc67ce582a6afa3ccab83908363ffffffff61177716565b610d6873a1d0e215a23d7030842fc67ce582a6afa3ccab8385600063ffffffff6117c916565b604080516370a0823160e01b81523060048201529051610e0d91869173a1d0e215a23d7030842fc67ce582a6afa3ccab83916370a08231916024808301926020929190829003018186803b158015610dbf57600080fd5b505afa158015610dd3573d6000803e3d6000fd5b505050506040513d6020811015610de957600080fd5b505173a1d0e215a23d7030842fc67ce582a6afa3ccab83919063ffffffff6117c916565b604080516370a0823160e01b815230600482015290516001600160a01b0386169163da4745b39173a1d0e215a23d7030842fc67ce582a6afa3ccab83916370a08231916024808301926020929190829003018186803b158015610e6f57600080fd5b505afa158015610e83573d6000803e3d6000fd5b505050506040513d6020811015610e9957600080fd5b5051604080516001600160e01b031960e085901b168152600481019290925251602480830192600092919082900301818387803b158015610ed957600080fd5b505af1158015610eed573d6000803e3d6000fd5b506000965050601036029450505050505a8361520801030190506d4946c0e9f43f4dee607b0ef1fa1c6001600160a01b031663079d229f3361a0aa8461374a0181610f3457fe5b046040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610f8457600080fd5b505af1158015610f98573d6000803e3d6000fd5b505050506040513d6020811015610fae57600080fd5b50505050565b6001546000906001600160a01b03163314611004576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b6002546001600160a01b0383811691161415611050576040805162461bcd60e51b815260206004808301919091526024820152631dd85b9d60e21b604482015290519081900360640190fd5b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561109657600080fd5b505afa1580156110aa573d6000803e3d6000fd5b505050506040513d60208110156110c057600080fd5b50516001549091506110e5906001600160a01b0384811691168363ffffffff61177716565b919050565b6000546001600160a01b031681565b61271081565b60006111096113a4565b905090565b6001546000906001600160a01b0316331461115e576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b611166611977565b600254604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505160015460025460408051632988bb9f60e21b81526001600160a01b0392831660048201529051939450600093919092169163a622ee7c916024808301926020929190829003018186803b15801561123357600080fd5b505afa158015611247573d6000803e3d6000fd5b505050506040513d602081101561125d57600080fd5b505190506001600160a01b0381166112a5576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b6002546112c2906001600160a01b0316828463ffffffff61177716565b5090565b6000546001600160a01b03163314611313576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314611382576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156113ef57600080fd5b505afa158015611403573d6000803e3d6000fd5b505050506040513d602081101561141957600080fd5b5051905090565b6d4946c0e9f43f4dee607b0ef1fa1c81565b600354600254611456916001600160a01b039182169116600063ffffffff6117c916565b600354600254604080516370a0823160e01b815230600482015290516114ee936001600160a01b039081169316916370a08231916024808301926020929190829003018186803b1580156114a957600080fd5b505afa1580156114bd573d6000803e3d6000fd5b505050506040513d60208110156114d357600080fd5b50516002546001600160a01b0316919063ffffffff6117c916565b600354600254604080516370a0823160e01b815230600482015290516001600160a01b039384169363a694fc3a9316916370a08231916024808301926020929190829003018186803b15801561154357600080fd5b505afa158015611557573d6000803e3d6000fd5b505050506040513d602081101561156d57600080fd5b5051604080516001600160e01b031960e085901b168152600481019290925251602480830192600092919082900301818387803b1580156115ad57600080fd5b505af1158015610fae573d6000803e3d6000fd5b73a1d0e215a23d7030842fc67ce582a6afa3ccab8381565b600354604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156113ef57600080fd5b603281565b7316cac1403377978644e78769daa49d8f6b6cf56581565b736b175474e89094c44da98b954eedeac495271d0f81565b6001546001600160a01b031681565b60006116aa83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506119e9565b90505b92915050565b60035460408051632e1a7d4d60e01b81526004810184905290516000926001600160a01b031691632e1a7d4d916024808301928692919082900301818387803b1580156116ff57600080fd5b505af1158015611713573d6000803e3d6000fd5b5093949350505050565b6000828201838110156116aa576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526104d5908490611a80565b80158061184f575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561182157600080fd5b505afa158015611835573d6000803e3d6000fd5b505050506040513d602081101561184b57600080fd5b5051155b61188a5760405162461bcd60e51b8152600401808060200182810382526036815260200180611d256036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526104d5908490611a80565b6000826118eb575060006116ad565b828202828482816118f857fe5b04146116aa5760405162461bcd60e51b8152600401808060200182810382526021815260200180611cda6021913960400191505060405180910390fd5b60006116aa83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611c38565b600360009054906101000a90046001600160a01b03166001600160a01b031663e9fad8ee6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156119c757600080fd5b505af11580156119db573d6000803e3d6000fd5b505050506119e76104f2565b565b60008184841115611a785760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a3d578181015183820152602001611a25565b50505050905090810190601f168015611a6a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b611a92826001600160a01b0316611c9d565b611ae3576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310611b215780518252601f199092019160209182019101611b02565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611b83576040519150601f19603f3d011682016040523d82523d6000602084013e611b88565b606091505b509150915081611bdf576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610fae57808060200190516020811015611bfb57600080fd5b5051610fae5760405162461bcd60e51b815260040180806020018281038252602a815260200180611cfb602a913960400191505060405180910390fd5b60008183611c875760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611a3d578181015183820152602001611a25565b506000838581611c9357fe5b0495945050505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708115801590611cd15750808214155b94935050505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a72315820e1bcb4bbb202e6a2d31c054a6939aa05338d180666547db11f7152ecca45fabb64736f6c63430005110032

Verified Source Code Partial Match

Compiler: v0.5.17+commit.d19bba13 EVM: istanbul Optimization: Yes (200 runs)
StrategyStandardYam.sol 326 lines
/**
 *Submitted for verification at Etherscan.io on 2020-07-31
*/

// SPDX-License-Identifier: MIT

pragma solidity ^0.5.15;

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function decimals() external view returns (uint);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, 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);
}

library SafeMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;

        return c;
    }
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

library Address {
    function isContract(address account) internal view returns (bool) {
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != 0x0 && codehash != accountHash);
    }
    function toPayable(address account) internal pure returns (address payable) {
        return address(uint160(account));
    }
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-call-value
        (bool success, ) = recipient.call.value(amount)("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
}

library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

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

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

    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        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));
    }
    function callOptionalReturn(IERC20 token, bytes memory data) private {
        require(address(token).isContract(), "SafeERC20: call to non-contract");

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

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

interface Controller {
    function vaults(address) external view returns (address);
    function rewards() external view returns (address);
}

/*

 A strategy must implement the following calls;
 
 - deposit()
 - withdraw(address) must exclude any tokens used in the yield - Controller role - withdraw should return to Controller
 - withdraw(uint) - Controller | Vault role - withdraw should always return to vault
 - withdrawAll() - Controller | Vault role - withdraw should always return to vault
 - balanceOf()
 
 Where possible, strategies must remain as immutable as possible, instead of updating variables, we update the contract by linking it in the controller
 
*/

interface Yam {
    function withdraw(uint) external;
    function getReward() external;
    function stake(uint) external;
    function balanceOf(address) external view returns (uint);
    function exit() external;
}

contract Balancer {
    function joinPool(uint poolAmountOut, uint[] calldata maxAmountsIn) external;
    function exitPool(uint poolAmountIn, uint[] calldata minAmountsOut) external;
    function swapExactAmountIn(
        address tokenIn,
        uint tokenAmountIn,
        address tokenOut,
        uint minAmountOut,
        uint maxPrice
    ) external returns (uint tokenAmountOut, uint spotPriceAfter);
    function swapExactAmountOut(
        address tokenIn,
        uint maxAmountIn,
        address tokenOut,
        uint tokenAmountOut,
        uint maxPrice
    ) external returns (uint tokenAmountIn, uint spotPriceAfter);
    function joinswapExternAmountIn(address tokenIn, uint tokenAmountIn, uint minPoolAmountOut) external returns (uint poolAmountOut);
    function exitswapPoolAmountIn(address tokenOut, uint poolAmountIn, uint minAmountOut) external returns (uint tokenAmountOut);
}
interface UniswapRouter {
  function swapExactTokensForTokens(
      uint amountIn,
      uint amountOutMin,
      address[] calldata path,
      address to,
      uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
    external returns (uint[] memory amounts);
}


interface Yvault{
    function make_profit(uint256 amount) external;
}
interface IFreeFromUpTo {
    function freeFromUpTo(address from, uint256 value) external returns (uint256 freed);
}
contract StrategyStandardYam {
    using SafeERC20 for IERC20;
    using Address for address;
    using SafeMath for uint256;
    

    address constant public yfii = address(0xa1d0E215a23d7030842FC67cE582a6aFa3CCaB83);
    address constant public yam = address(0x0e2298E3B3390e3b945a5456fBf59eCc3f55DA16);
    address constant public unirouter = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
    address constant public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
    address constant public dai = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
    address constant public balancer = address(0x16cAC1403377978644e78769Daa49d8f6B6CF565);

    IFreeFromUpTo public constant chi = IFreeFromUpTo(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c);

    
    
    uint constant public fee = 50;
    uint constant public max = 10000;
    
    address public governance;
    address public controller;
    
    address  public want;
    address  public pool ;
    
    modifier discountCHI {
        uint256 gasStart = gasleft();
        _;
        uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length;
        chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41130);
    }
    
    constructor(address _controller,address _want,address _pool) public {
        governance = tx.origin;
        controller = _controller;
        want = _want;
        pool = _pool;
    }
    
    
    function deposit() external { 
        IERC20(want).safeApprove(pool, 0);
        IERC20(want).safeApprove(pool, IERC20(want).balanceOf(address(this)));
        Yam(pool).stake(IERC20(want).balanceOf(address(this)));
    }
    
    // Controller only function for creating additional rewards from dust
    function withdraw(IERC20 _asset) external returns (uint balance) {
        require(msg.sender == controller, "!controller");
        require(want != address(_asset), "want");
        balance = _asset.balanceOf(address(this));
        _asset.safeTransfer(controller, balance);
    }
    
    // Withdraw partial funds, normally used with a vault withdrawal
    function withdraw(uint _amount) external {
        require(msg.sender == controller, "!controller");
        uint _balance = IERC20(want).balanceOf(address(this));
        if (_balance < _amount) {
            _amount = _withdrawSome(_amount.sub(_balance));
            _amount = _amount.add(_balance);
        }
        
        address _vault = Controller(controller).vaults(address(want));
        require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds
        IERC20(want).safeTransfer(_vault, _amount);
    }
    
    // Withdraw all funds, normally used when migrating strategies
    function withdrawAll() external returns (uint balance) { 
        require(msg.sender == controller, "!controller");
        _withdrawAll();
        balance = IERC20(want).balanceOf(address(this));
        
        address _vault = Controller(controller).vaults(address(want));
        require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds
        IERC20(want).safeTransfer(_vault, balance);
        
    }
    
    function _withdrawAll() internal { 
        Yam(pool).exit();
        harvest();
    }
    
    function harvest() public discountCHI{
        Yam(pool).getReward(); 
        address _vault = Controller(controller).vaults(address(want));
        require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds

        // yam->weth->dai
        IERC20(yam).approve(unirouter, uint(-1));
        address[] memory path3 = new address[](3);
        path3[0] = address(yam);
        path3[1] = address(weth);
        path3[2] = address(dai);
        UniswapRouter(unirouter).swapExactTokensForTokens(IERC20(yam).balanceOf(address(this)), 0, path3, address(this), now.add(1800));

        // dai ->yfii
        IERC20(dai).safeApprove(balancer, 0);
        IERC20(dai).safeApprove(balancer, IERC20(dai).balanceOf(address(this)));
        Balancer(balancer).swapExactAmountIn(dai, IERC20(dai).balanceOf(address(this)), yfii, 0, uint(-1));

        // fee
        uint b = IERC20(yfii).balanceOf(address(this));
        uint _fee = b.mul(fee).div(max);
        IERC20(yfii).safeTransfer(Controller(controller).rewards(), _fee);

        //把yfii 存进去分红.
        IERC20(yfii).safeApprove(_vault, 0);
        IERC20(yfii).safeApprove(_vault, IERC20(yfii).balanceOf(address(this)));
        Yvault(_vault).make_profit(IERC20(yfii).balanceOf(address(this)));
    }
    
    function _withdrawSome(uint256 _amount) internal returns (uint) {
        Yam(pool).withdraw(_amount);
        return _amount;
    }
    
    function balanceOfWant() public view returns (uint) {
        return IERC20(want).balanceOf(address(this));
    }
    
    function balanceOfYam() public view returns (uint) {
        return Yam(pool).balanceOf(address(this));
    }
    
    function balanceOf() public view returns (uint) {
        return balanceOfWant();
               
    }
    
    function setGovernance(address _governance) external {
        require(msg.sender == governance, "!governance");
        governance = _governance;
    }
    
    function setController(address _controller) external {
        require(msg.sender == governance, "!governance");
        controller = _controller;
    }
}

Read Contract

balanceOf 0x722713f7 → uint256
balanceOfWant 0xc1a3d44c → uint256
balanceOfYam 0xdc301fa2 → uint256
balancer 0xe563037e → address
chi 0xc92aecc4 → address
controller 0xf77c4791 → address
dai 0xf4b9fa75 → address
fee 0xddca3f43 → uint256
governance 0x5aa6e675 → address
max 0x6ac5db19 → uint256
pool 0x16f0115b → address
unirouter 0x257ae0de → address
want 0x1f1fcd51 → address
weth 0x3fc8cef3 → address
yam 0x071c0332 → address
yfii 0xd2a9d862 → address

Write Contract 7 functions

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

deposit 0xd0e30db0
No parameters
harvest 0x4641257d
No parameters
setController 0x92eefe9b
address _controller
setGovernance 0xab033ea9
address _governance
withdraw 0x2e1a7d4d
uint256 _amount
withdraw 0x51cff8d9
address _asset
returns: uint256
withdrawAll 0x853828b6
No parameters
returns: uint256

Recent Transactions

No transactions found for this address