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(0xEB16Ae0052ed37f479f7fe63849198Df1765a733);
        gauge = address(0x462253b8F74B72304c145DB0e4Eebd326B22ca39);
        keepCRV = 1000;
    }

    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[](3);
            path[0] = crv;
            path[1] = weth;
            path[2] = dai;

            Uni(dex).swapExactTokensForTokens(_crv, uint256(0), path, address(this), now);
        }
        uint256 _dai = IERC20(dai).balanceOf(address(this));
        if (_dai > 0) {
            IERC20(dai).safeApprove(curve, 0);
            IERC20(dai).safeApprove(curve, _dai);
            ICurveFi(curve).add_liquidity([_dai, 0], 0, true);
        }
        _profit = want.balanceOf(address(this)).sub(before);

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

        uint _losss;
        if (_debtOutstanding > 0) {
            (_debtPayment, _losss) = liquidatePosition(_debtOutstanding);
        }
        _loss = _loss.add(_losss);
    }

    // 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;
    }
}
/**
 * @dev This is a mock strategy
 *
 * It shows the flow of how to implement customized functions
 * after inheriting the CurveVoterProxy template
 */
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