-
Notifications
You must be signed in to change notification settings - Fork 49
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
fix: withdraw gas tokens from swap #198
Conversation
WalkthroughWalkthroughThe pull request introduces modifications to the approval and withdrawal logic in the Changes
Possibly related PRs
Recent review detailsConfiguration used: CodeRabbit UI Files ignored due to path filters (2)
Files selected for processing (2)
Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- universal/swap/contracts/Swap.sol (1 hunks)
- universal/swap/contracts/SwapToAnyToken.sol (1 hunks)
Additional comments not posted (2)
universal/swap/contracts/Swap.sol (1)
78-83
: Optimize token approvals with conditional logic.The changes introduced in the approval logic are a good optimization to reduce the number of transactions and potentially save on gas costs. However, consider the following improvements:
- Edge Case Handling: Ensure that there are checks for cases where
amount
might be less thangasFee
, which could lead to underflows. Although Solidity 0.8.26 prevents underflows, explicit validation can prevent logical errors.- Race Conditions: The direct use of the
approve
method can be susceptible to race conditions. Ensure that these scenarios are handled correctly, possibly by using theincreaseAllowance
method or ensuring that the contract's state cannot be altered in unexpected ways between calls.universal/swap/contracts/SwapToAnyToken.sol (1)
93-110
: Enhance withdrawal logic with conditional approvals and structured error handling.The modifications to the withdrawal logic introduce more granular control and improve error handling capabilities. Consider the following improvements:
- Edge Case Handling: Ensure that all edge cases, such as when
amount
is less thangasFee
, are handled correctly to prevent logical errors or underflows.- Security Considerations: Review the entire flow to ensure that the new logic does not introduce security vulnerabilities, especially in the handling of approvals and state changes.
Fixed approval for when the target is a gas token.
Localnet
ETH to USDC:
USDC to ETH:
Depends on zeta-chain/localnet#32
Summary by CodeRabbit
New Features
Bug Fixes
Chores