[codex] Move swap router empty-list guards before folds#16
Open
caydyan wants to merge 1 commit into
Open
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
swap-multi,swap-x-for-y-same-multi, andswap-y-for-x-same-multi.ERR_EMPTY_SWAPS_LISTdirectly.Audit context
This addresses Sonic Mast's Bitflow
dlmm-swap-router-v-1-1audit R01 from https://gist.github.com/sonic-mast/c3a352aa6b9b46dd42e36f163d9d9b2d. The finding calls out that empty-list checks execute after the fold. Currentmainno longer has the auditedswap-simple-multientrypoint, so this PR fixes the still-present affected entrypoints.Why
The prior behavior was functionally safe for empty lists because folding an empty list returns immediately, but the check read as a post-fold condition. Moving it before the fold makes the empty-list guard an explicit precondition and prevents future changes to fold bodies from accidentally placing any work before the guard.
Validation
git diff --checkclarinet check contracts/dlmm-swap-router-v-1-1.clarAdditional validation attempted:
clarinet checkfor the full project currently fails outside this change on the existingmock-pool/dlmm-pool-traitget-pool-for-addsignature mismatch.npx vitest run tests/routers/swap-router.test.tscurrently fails before collecting tests because the checked-in deployment plan uses atransaction-typeformat that this local Clarinet/Vitest stack cannot read.BTC payout address if this is accepted for any related bounty:
bc1qev5ant33v5y89qqjvcf4mh9hlax5svqf5xd7gc