`StructHash.sol`'s rebalancing and order typehashing have an extra lower keccak hash of the type that's not included in the `TYPEHASH` for these actions themselves leading to errors
Audit: 2024-06-krystal-defi-findings
Severity: MEDIUM

# Lines of code

https://github.com/code-423n4/2024-06-krystal-defi/blob/f65b381b258290653fa638019a5a134c4ef90ba8/src/StructHash.sol#L86-L108
https://github.com/code-423n4/2024-06-krystal-defi/blob/f65b381b258290653fa638019a5a134c4ef90ba8/src/EIP712.sol#L24-L28


# Vulnerability details


## Proof of Concept

The `StructHash.sol` library is used to enforce normal hashing of the struct values for different action types and these hashes are to then be used in order core instances of the KrystalDefi protocol.

Going through the library, we can see that whenever a hashing is to be done for any action the helper `_hash()` function returns the keccakked abi.encoded data, [see an example in regards to the `AutoCompoundAction_TYPEHASH`](https://github.com/code-423n4/2024-06-krystal-defi/blob/f65b381b258290653fa638019a5a134c4ef90ba8/src/StructHash.sol#L23-L34).

Issue however is that where as this is rightly done in most instances, it seems to be wrongly implemented for rebalance conditioning and normal order typehashing, see https://github.com/code-423n4/2024-06-krystal-defi/blob/f65b381b258290653fa638019a5a134c4ef90ba8/src/StructHash.sol#L86-L108

```solidity
//@audit below we can see that the value for type needed is specifed as a  `string` and not `bytes32`, this is important to note cause it affects the final typehash gotten
    // keccak256(
    //     "RebalanceCondition(string type,int160 sqrtPriceX96,int64 timeBuffer,TickOffsetCondition tickOffsetCondition,PriceOffsetCondition priceOffsetCondition,TokenRatioCondition tokenRatioCondition)PriceOffsetCondition(uint32 baseToken,uint256 gteOffsetSqrtPriceX96,uint256 lteOffsetSqrtPriceX96)TickOffsetCondition(uint32 gteTickOffset,uint32 lteTickOffset)TokenRatioCondition(int256 lteToken0RatioX64,int256 gteToken0RatioX64)"
    // );
    bytes32 constant RebalanceCondition_TYPEHASH = 0x79a6efb57bb0d511e670abb964181b04730ebe3a5fd187d05341eeb9288deef8;
    struct RebalanceCondition {
        string _type;
        int160 sqrtPriceX96;
        int64 timeBuffer;
        TickOffsetCondition tickOffsetCondition;
        PriceOffsetCondition priceOffsetCondition;
        TokenRatioCondition tokenRatioCondition;
    }
    function _hash(RebalanceCondition memory obj) private pure returns (bytes32) {
        return keccak256(abi.encode(
            RebalanceCondition_TYPEHASH,
            keccak256(bytes(obj._type)), //@audit
            obj.sqrtPriceX96,
            obj.timeBuffer,
            _hash(obj.tickOffsetCondition),
            _hash(obj.priceOffsetCondition),
            _hash(obj.tokenRatioCondition)
        ));
    }
```

Evidently, the `RebalanceCondition_TYPEHASH` expects the type to be attached as a _string_ and not _bytes32_, however as hinted by the @audit tag, the encode keccak hashes the `obj._type` which then causes the value used to be a bytes32 instead of a string.

Now using any[ Keccak 256 online checker](https://emn178.github.io/online-tools/keccak_256.html), we would see that protocol righ