Skip to content

Add final output guard to simple multi swaps#18

Open
sato820 wants to merge 1 commit into
BitflowFinance:feat/add-latest-contractsfrom
sato820:codex/r02-simple-multi-total-min
Open

Add final output guard to simple multi swaps#18
sato820 wants to merge 1 commit into
BitflowFinance:feat/add-latest-contractsfrom
sato820:codex/r02-simple-multi-total-min

Conversation

@sato820

@sato820 sato820 commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Addresses Sonic Mast audit finding R02 from https://gist.github.com/sonic-mast/c3a352aa6b9b46dd42e36f163d9d9b2d and the AIBTC fix-PR bounty mqewgyvr5063fd520a70.

swap-simple-multi already enforces min-received per leg, but callers could not enforce a route-level output constraint for the final leg. This adds a min-final-output argument, tracks the last leg output in the fold accumulator, and returns it as final-output.

Changes

  • Add min-final-output to swap-simple-multi.
  • Track and assert the final leg output with ERR_MINIMUM_RECEIVED.
  • Return final-output next to per-leg results.
  • Add router tests for the passing and failing final-output cases.
  • Update generated test typings and router docs for the new signature.

Verification

  • git diff --check passes.
  • tsc --noEmit no longer reports any swapSimpleMulti/router typing errors introduced by this change.
  • Full Clarigen/Vitest execution is blocked in this Windows checkout by pre-existing environment/upstream issues: Clarigen exits with unable to mutate url; Clarinet requires LF line endings and, on a normalized temp copy of upstream feat/add-latest-contracts without this patch, fails with the same existing trait error: invalid signature for method 'get-pool-for-add' regarding trait's specification <dlmm-pool-trait>.

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.

1 participant