Skip to content

Conversation

@nialexsan
Copy link
Contributor

@nialexsan nialexsan commented Jan 10, 2026

manual test:
https://run.dnz.dev/snippet/f325ea2eeb87aa3f

the original code used reverse flag to determine swap direction, which was not always matching the pool direction zeroForOne and the cap calculation returned 0

@nialexsan nialexsan linked an issue Jan 10, 2026 that may be closed by this pull request
@nialexsan nialexsan requested a review from a team January 12, 2026 15:59
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]
Copy link
Member

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]
Copy link
Member

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)
Copy link
Member

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

nialexsan and others added 4 commits January 12, 2026 16:14
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>
@nialexsan nialexsan requested a review from turbolent January 12, 2026 23:02
liobrasil and others added 3 commits January 12, 2026 19:21
…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>
@nialexsan nialexsan merged commit 8aed875 into main Jan 13, 2026
3 checks passed
@nialexsan nialexsan deleted the nialexsan/fix-univ3-quote-in branch January 13, 2026 01:22
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.

PyUSD (migrating USDF to PyUSD)

5 participants