library F3DKeysCalcLong {
    using SafeMath for *;
    // 根据ETH计算KEY
    function keysRec(uint256 _curEth, uint256 _newEth)
        internal
        pure
        returns (uint256)
    {
        return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
    }
    
    // 根据KEY算ETH
    function ethRec(uint256 _curKeys, uint256 _sellKeys)
        internal
        pure
        returns (uint256)
    {
        return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
    }

    // 根据ETH算KEY
    function keys(uint256 _eth) 
        internal
        pure
        returns(uint256)
    {
        return ((((((_eth).mul(1000000000000000000)).mul(31250000000000000000000000000)).add(56249882812561035156250000000000000000000000000000000000000000000000)).sqrt()).sub(7499992187500000000000000000000000)) / (15625000000);
    }
    
    // 根据KEY算ETH
    function eth(uint256 _keys) 
        internal
        pure
        returns(uint256)  
    {
        return ((7812500000).mul(_keys.sq()).add((7499992187500000).mul(_keys.mul(1000000000000000000)))) / ((1000000000000000000).sq()) ;
    }
}
function keysRec(uint256 _curEth, uint256 _newEth)
    internal
    pure
    returns (uint256)
{
    return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}

// 根据ETH计算KEY