contract Strategy is CurveVoterProxy {
    using SafeERC20 for IERC20;
    using Address for address;
    using SafeMath for uint256;

    constructor(address _vault) public CurveVoterProxy(_vault) {
        dex = sushiswap;
        curve = address(0xF9440930043eb3997fc70e1339dBb11F341de7A8);
        gauge = address(0x824F13f1a2F29cFEEa81154b46C0fc820677A637);
        keepCRV = 1000;
    }

    receive() external payable {}

    function prepareReturn(uint256 _debtOutstanding)
        internal
        override
        returns (
            uint256 _profit,
            uint256 _loss,
            uint256 _debtPayment
        )
    {
        uint before = want.balanceOf(address(this));
        IVoterProxy(proxy).harvest(gauge);
        uint256 _crv = IERC20(crv).balanceOf(address(this));
        if (_crv > 0) {
            _crv = _adjustCRV(_crv);

            IERC20(crv).safeApprove(dex, 0);
            IERC20(crv).safeApprove(dex, _crv);

            address[] memory path = new address[](2);
            path[0] = crv;
            path[1] = weth;
            Uni(dex).swapExactTokensForTokens(_crv, uint256(0), path, address(this), now);
        }
        uint256 _weth = IERC20(weth).balanceOf(address(this));
        if (_weth > 0) {
            WETH(weth).withdraw(_weth);
            _weth = address(this).balance;
            ICurveFi(curve).add_liquidity{value: _weth}([_weth, 0], 0);
        }
        _profit = want.balanceOf(address(this)).sub(before);

        uint _total = estimatedTotalAssets();
        uint _debt = vault.strategies(address(this)).totalDebt;
        if(_total < _debt) {
            _loss = _debt - _total;
            _profit = 0;
        }

        if (_debtOutstanding > 0) {
            _withdrawSome(_debtOutstanding);
            _debtPayment = Math.min(_debtOutstanding, balanceOfWant().sub(_profit));
        }
    }

    // NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary

    function protectedTokens()
        internal
        view
        override
        returns (address[] memory)
    {
        address[] memory protected = new address[](1);
        protected[0] = crv;
        return protected;
    }
}
function protectedTokens()
        internal
        view
        override
        returns (address[] memory)
    {
        address[] memory protected = new address[](1);
        protected[0] = crv;
        return protected;
    }
// NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary