sherlock-audit / 2024-08-woofi-solana-deployment-judging

0 stars 0 forks source link

Passive Indigo Dolphin - Error messages due to constraint violation can be handled better #93

Closed sherlock-admin3 closed 13 hours ago

sherlock-admin3 commented 13 hours ago

Passive Indigo Dolphin

Low/Info

Error messages due to constraint violation can be handled better

Summary

The codebase is polluted with various constraint checks. This checks could easily be handled to give better error messages than the default which is been used.

Root Cause

try_query.rs (!wooconfig.paused)

swap.rs

incase_token_got_stuck.rs

These are just few examples of the above scenarios in which there are constraint checks but insufficient error handling

Impact

These can make it harder for the developer to debug the cause of an issue in the case of an instruction not passing

PoC

No response

Mitigation

Add an error message to the error file and then use the added error message in your account struct to easily handle it.

This can then be called with constraint = token_vault.mint == token_mint.key() @ ErrorCode::InvalidMint has_one = authority @ ErrorCode::WrongAuthority

Reference