feat(cadence): support exact-out mode quote via swap#135
Draft
feat(cadence): support exact-out mode quote via swap#135
Conversation
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.
Summary
This PR adds an opt-in exact-output mode that works through the existing
swap(...)entrypoint, so callers can request exact-out behavior without changing theSwapper.swapsignature.Why
After
swapExactOut(...)was added to the interface, apps that still callswap(...)continue to use exact-input semantics.This change introduces a quote modality so
swap(...)can execute exact-out when explicitly requested.What changed
SwapConnectors.SwapMode(IN/OUT).SwapConnectors.ModeQuote:DeFiActions.QuotemodeleftoverInReceivercapability for returning unused input during exact-out.SwapConnectors.asModeQuote(...)SwapConnectors.asExactInQuote(...)SwapConnectors.asExactOutQuote(...)UniswapV3SwapConnectors.Swapper.swap(...):ModeQuote+OUT, it executes exact-out internally and deposits leftover input toleftoverInReceiver.SwapConnectors.MultiSwapper.swap(...)with the same mode-aware exact-out path, routed through the selected inner swapper.uniswap_v3_swap_exact_output.cdcto use:swap(...)+SwapConnectors.asExactOutQuote(...)FTVaultData), not hardcoded paths.Compatibility
BasicQuote+swap(...).swap(...)is opt-in only (throughModeQuote).Notes
swapExactOut(...); it remains available.swap(...)flows opt into exact-output semantics safely.Design context
This approach is based on the quote-modality direction originally suggested by @jribbink in PR #127 discussions:
The goal is to keep generic
{Swapper}call sites usable while allowing explicit exact-out behavior through quote semantics.