-
Notifications
You must be signed in to change notification settings - Fork 3
fix quote in calculation #87
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
Conversation
| let tokenEVMAddress = reverse ? self.tokenPath[0] : self.tokenPath[self.tokenPath.length - 1] | ||
| let desired = FlowEVMBridgeUtils.convertCadenceAmountToERC20Amount( | ||
| // OUT token for this direction | ||
| let outToken = reverse ? self.tokenPath[0] : self.tokenPath[self.tokenPath.length - 1] |
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.
Maybe make this a function, e.g. fun outToken(reverse: Bool): EVM.EVMAddress
| let token0 = self.getPoolToken0(pool) | ||
|
|
||
| // your actual input token for this swap direction: | ||
| let inToken = reverse ? self.tokenPath[self.tokenPath.length - 1] : self.tokenPath[0] |
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.
Maybe make this a function, e.g. fun inToken(reverse: Bool): EVM.EVMAddress
|
|
||
| let word = res.data as! [UInt8] | ||
| let addrSlice = word.slice(from: 12, upTo: 32) | ||
| let addrBytes: [UInt8; 20] = self.to20(addrSlice) |
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.
Here and in the rest of the contract: replace self.to20(addrSlice) with addrSlice.toConstantSized<[UInt8; 20]>() and then remove to20
Co-authored-by: Bastian Müller <bastian@turbolent.com>
- Rename getMaxAmount to getMaxInAmount for clarity - Refactor maxInAmount to reuse isZeroForOne (removes duplicate logic) - Remove dead code: maxOutAmount, getPoolTokens - Add edge case handling to quoteOut (skip clamping when maxInEVM = 0) - Improve variable naming in quoteOut for consistency with quoteIn - Add TODO comments for multi-hop clamping consideration - Fix comment typo (4% → 6% price impact) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ing using string interpolation for better readability and maintainability
…nd unused variable Remove FlowEVMBridge import, commented-out error handling, and unused numerator variable to improve code cleanliness. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
manual test:
https://run.dnz.dev/snippet/f325ea2eeb87aa3f
the original code used
reverseflag to determine swap direction, which was not always matching the pool directionzeroForOneand the cap calculation returned 0