-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add templates it includes slippage param for uniswap. #23
Conversation
wshino
commented
Nov 7, 2023
•
edited
Loading
edited
- Implement templates including slippage param
- Add mocking unit testing
(bool success, , ,) = core.handleEmailOp(emailOp); | ||
vm.stopPrank(); | ||
|
||
assertTrue(success, "emailOp failed"); |
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.
I think a good way to test would be depositing exactly 0.2 WETH to the wallet, and then assert WETH value went to 0 and DAI value increased to 0.2*PRICE. Can we mock the uniswap methods return a fake price for WETH/DAI and check actual balances at the end of the test?
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.
Thanks @saleel for you review🙏
I thought it would be nice to be able to do that as well. However, this is a process in ISwapRouter.interactInputSingle, so I could only mockCall it this time. Of course, integration testing can be used to fork the actual uniswap and see the value change.
If I find a better way, I will update the test.
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.
@saleel Or maybe we can use fork testing feature same as integration testing, but it might cause some slowdown.
@SoraSuegami What is your opinion?
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.
I see ok, I think we can leave it like this in unit tests then and do proper checks in integration tests. I think its better not to make unit tests slow/complex.
Maybe you want to add one integration test with slippage/sqrt?
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.
I think its better not to make unit tests slow/complex.
I agree with that point.
Please let me know if you need a new email from my email address for the new integration test.
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.
@saleel @SoraSuegami Thank you for your reply,
@saleel Yes I'd like to implement a few integration testing with slippage/sqrt as you said.
@SoraSuegami Could you please new emails like below:
Swap 0.2 ETH to DAI with 0.5 slippage
Swap 200 DAI to USDC under 79244154773652573370267 sqrt price limit
@@ -23,7 +23,7 @@ contract UniswapExtension is Extension { | |||
|
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.
We can call this defaultSlippage
? or defaultSlippagePoints
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.
@saleel I think it's easier to understand. Let me update then.
…ail/email-wallet into feat/slippage-templates-for-uniswap
@wshino |
Thank you! |