Skip to content

Conversation

@StepanovDev
Copy link

What I did

Added a validation check to ensure the total deposit amount is greater than zero in the add_liquidity function within swaptemplatebase.vy. This enhancement prevents invalid deposit transactions where all amounts are zero, improving the contract's robustness against potential errors or misuse.

How I did it

  • Introduced a total_amount variable to calculate the sum of all _amounts[i] before processing the deposit.
  • Added an assert total_amount > 0 check at the beginning of the function to reject transactions with no effective deposit.
  • Ensured the change does not alter the existing logic, adding only a safety layer without impacting performance or gas costs significantly.

How to verify it

  • Review the updated add_liquidity function in contracts/pool-templates/swaptemplatebase.vy (lines where total_amount is calculated and checked).
  • Test the function with a deposit of [0, 0, 0] — it should revert with the message "Total deposit amount must be greater than zero".
  • Test with a valid deposit (e.g., [100, 0, 0] or [50, 50, 0]) — it should proceed as expected without reverting.

Related issue

N/A (if no specific issue is linked; if there is one, add e.g., "Fixes #123")

Additional notes

This change was made to enhance the security and usability of the template contract, making it more resilient for new pool deployments. No functional changes to the core algorithm were introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant