fix quote in calculation#87
Merged
Merged
Conversation
6 tasks
turbolent
reviewed
Jan 12, 2026
| 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] |
Member
There was a problem hiding this comment.
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] |
Member
There was a problem hiding this comment.
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) |
Member
There was a problem hiding this comment.
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>
Kay-Zee
approved these changes
Jan 12, 2026
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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