Nonstandard usage of nonce
The protocol implemented two withdraw functions `withdrawDeposit()` and `withdraw()`. While the function `withdrawDeposit()` is designed to be used by the depositor themselves, the function `withdraw()` is designed to be used by anyone who has a signature from the depositor. The function `withdraw()` has a parameter `nonce` but the usage of this param is not aligned with the general meaning of `nonce`.\\n```\\nDepositVault.sol\\n    function withdraw(uint256 amount, uint256 nonce, bytes memory signature, address payable recipient) public {\\n        require(nonce < deposits.length, "Invalid deposit index");\\n        Deposit storage depositToWithdraw = deposits[nonce];//@audit-info non aligned with common understanding of nonce\\n        bytes32 withdrawalHash = getWithdrawalHash(Withdrawal(amount, nonce));\\n        address signer = withdrawalHash.recover(signature);\\n        require(signer == depositToWithdraw.depositor, "Invalid signature");\\n        require(!usedWithdrawalHashes[withdrawalHash], "Withdrawal has already been executed");\\n        require(amount == depositToWithdraw.amount, "Withdrawal amount must match deposit amount");\\n        usedWithdrawalHashes[withdrawalHash] = true;\\n        depositToWithdraw.amount = 0;\\n        if(depositToWithdraw.tokenAddress == address(0)){\\n            recipient.transfer(amount);\\n        } else {\\n            IERC20 token = IERC20(depositToWithdraw.tokenAddress);\\n            token.safeTransfer(recipient, amount);\\n        }\\n        emit WithdrawalMade(recipient, amount);\\n    }\\n```\\n\\nIn common usage, `nonce` is used to track the latest transaction from the EOA and generally it is increased on the user's transaction. It can be effectively used to invalidate the previous signature by the signer. But looking at the current implementation, the parameter `nonce` is merely used as an index to refer the `deposit` at a specific index.\\nThis is a bad naming and can confuse the users.
If the protocol intended to provide a kind of invalidation mechanism using the nonce, there should be a separate mapping that stores the nonce for each user. The current nonce can be used to generate a signature and a depositor should be able to increase the nonce to invalidate the previous signatures. Also the nonce would need to be increased on every successful call to `withdraw()` to prevent replay attack. Please note that with this remediation, the mapping `usedWithdrawalHashes` can be removed completely because the hash will be always decided using the latest nonce and the nonce will be invalidated automatically (because it increases on successful call).\\nIf this is not what the protocol intended, the parameter nonce can be renamed to `depositIndex` as implemented in the function `withdrawDeposit()`.
```\\nDepositVault.sol\\n    function withdraw(uint256 amount, uint256 nonce, bytes memory signature, address payable recipient) public {\\n        require(nonce < deposits.length, "Invalid deposit index");\\n        Deposit storage depositToWithdraw = deposits[nonce];//@audit-info non aligned with common understanding of nonce\\n        bytes32 withdrawalHash = getWithdrawalHash(Withdrawal(amount, nonce));\\n        address signer = withdrawalHash.recover(signature);\\n        require(signer == depositToWithdraw.depositor, "Invalid signature");\\n        require(!usedWithdrawalHashes[withdrawalHash], "Withdrawal has already been executed");\\n        require(amount == depositToWithdraw.amount, "Withdrawal amount must match deposit amount");\\n        usedWithdrawalHashes[withdrawalHash] = true;\\n        depositToWithdraw.amount = 0;\\n        if(depositToWithdraw.tokenAddress == address(0)){\\n            recipient.transfer(amount);\\n        } else {\\n            IERC20 token = IERC20(depositToWithdraw.tokenAddress);\\n            token.safeTransfer(recipient, amount);\\n        }\\n        emit WithdrawalMade(recipient, amount);\\n    }\\n```\\n