Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a swap pause functionality #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Danbaba1
Copy link

Description

This PR introduces a pause mechanism for swap operations in the Pair contract. The functionality allows the contract owner to pause and unpause swap operations in emergency situations, enhancing the contract's security and risk management capabilities.

Changes Made

  • Integrated OpenZeppelin's PausableComponent for pause functionality
  • Added OwnableComponent to manage pause permissions
  • Added new external functions:
    • pause(): Allows owner to pause swap operations
    • unpause(): Allows owner to resume swap operations
  • Modified swap() function to include pause check
  • Added appropriate events and error messages
  • Set factory as initial owner in constructor

Technical Details

  • Pause state is tracked using PausableComponent's storage
  • Only the contract owner can pause/unpause (initially set to factory)
  • Added assert_not_paused() check in swap function
  • All other operations (mint, burn, sync) remain unaffected by pause state

Security Considerations

  • Only contract owner can pause/unpause
  • Reentrancy protection maintained
  • Events emitted for pause/unpause actions for transparency
  • Factory maintains control as initial owner

Testing Required

  • Pause functionality by owner
  • Unpause functionality by owner
  • Swap attempts during paused state
  • Swap attempts during unpaused state
  • Authorization checks for pause/unpause
  • Event emissions for pause/unpause actions

Impact

This change allows for emergency intervention in case of:

  • Detected vulnerabilities
  • Market manipulation attempts
  • Technical issues
  • Regulatory requirements

Backwards Compatibility

  • No breaking changes to existing interfaces
  • New functions are additive only
  • Existing transactions will work as before when not paused

Additional Notes

Please ensure thorough testing of pause functionality in both normal and edge cases before deployment.

@mul1sh
Copy link
Owner

mul1sh commented Nov 19, 2024

@Danbaba1 , great job

@Danbaba1
Copy link
Author

@mul1sh Thank you

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.

2 participants