contract OpenSignatureLogic is SignatureHelper {

    // ** CONSTANTS **

    // Hash of the EIP712 DealUsdSignature struct
    bytes32 constant internal EIP712_DEAL_STRUCT_SCHEMA_HASH = keccak256(abi.encodePacked(
        "DealUsdSignature(",
        "uint256 coefficient,",
        "uint256 profitPercent,",
        "uint256 valueUsdc,",
        "uint256 minEntryEthPrice,",
        "uint256 maxEntryEthPrice,",
        "uint256 expireTime,",
        "uint256 signNonce,",
        ")"
    ));

    // Hash of the EIP712 Domain Separator data
    bytes32 constant public EIP712_DOMAIN_HASH = keccak256(abi.encode(
        EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH,
        keccak256(bytes(EIP712_DOMAIN_NAME)),
        keccak256(bytes(EIP712_DOMAIN_VERSION)),
        1,
        address(0xBA3EEeb0cf1584eE565F34fCaBa74d3e73268c0b)  // TODO: set deployed contract
    ));

    /* Removed because of contract already deployed */
    // // ** Immutable Storage **

    // // Hash of the EIP712 Domain Separator data
    // bytes32 public EIP712_DOMAIN_HASH;

    // // ** INITIALIZER – Constructor for Upgradable contracts **

    // function initialize() public initializer {
    //     EIP712_DOMAIN_HASH = keccak256(abi.encode(
    //         EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH,
    //         keccak256(bytes(EIP712_DOMAIN_NAME)),
    //         keccak256(bytes(EIP712_DOMAIN_VERSION)),
    //         1,
    //         address(this)
    //     ));
    // }

    // Returns the EIP712 hash of a deal
    function _getDealHash(
        uint[7] memory _params
    )
        internal
        pure
        returns(bytes32)
    {
        // compute the overall signed struct hash
        bytes32 structHash = keccak256(abi.encodePacked(
            EIP712_DEAL_STRUCT_SCHEMA_HASH,
            _params[0],  // coefficient
            _params[1],  // profitPercent
            _params[2],  // valueUsdc
            _params[3],  // minEntryEthPrice
            _params[4],  // maxEntryEthPrice
            _params[5],  // expireTime
            _params[6]   // signNonce
        ));

        // compute eip712 compliant hash
        return keccak256(abi.encodePacked(
            EIP191_HEADER,
            EIP712_DOMAIN_HASH,
            structHash
        ));
    }
}
function _getDealHash(
    uint[7] memory _params
)
    internal
    pure
    returns(bytes32)
{
    // compute the overall signed struct hash
    bytes32 structHash = keccak256(abi.encodePacked(
        EIP712_DEAL_STRUCT_SCHEMA_HASH,
        _params[0],  // coefficient
        _params[1],  // profitPercent
        _params[2],  // valueUsdc
        _params[3],  // minEntryEthPrice
        _params[4],  // maxEntryEthPrice
        _params[5],  // expireTime
        _params[6]   // signNonce
    ));

    // compute eip712 compliant hash
    return keccak256(abi.encodePacked(
        EIP191_HEADER,
        EIP712_DOMAIN_HASH,
        structHash
    ));
}

// // ** Immutable Storage **
// // Hash of the EIP712 Domain Separator data
// bytes32 public EIP712_DOMAIN_HASH;
// // ** INITIALIZER – Constructor for Upgradable contracts **
// function initialize() public initializer {
//     EIP712_DOMAIN_HASH = keccak256(abi.encode(
//         EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH,
//         keccak256(bytes(EIP712_DOMAIN_NAME)),
//         keccak256(bytes(EIP712_DOMAIN_VERSION)),
//         1,
//         address(this)
//     ));
// }
// Returns the EIP712 hash of a deal