feat(multisig): multi-sig wallet with proposal-time-snapshotted threshold - #362
Closed
miss-yusrah wants to merge 1 commit into
Closed
feat(multisig): multi-sig wallet with proposal-time-snapshotted threshold#362miss-yusrah wants to merge 1 commit into
miss-yusrah wants to merge 1 commit into
Conversation
Contributor
Author
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.
PR description:
feat: Multi-sig wallet with proposal-time-snapshotted threshold
Context
Closes #340.
Adds a new Soroban smart contract (
contracts/multisig) implementing a multi-signature wallet where the signing policy (owner list + threshold) is captured at proposal creation time and is immutable for that proposal's lifetime.Problem solved
Without snapshotting, a live reconfiguration after a proposal is submitted could silently lower the threshold or add a colluding signer — letting a proposal that was created under a strict policy be executed under a weaker one (or vice-versa, deadlocking legitimate proposals).
Design
PolicySnapshotProposal; storesowners+thresholdas they were atpropose()timereconfigure()approve()execute()invoke_contractto dispatchinstancestorage bumped on every write; persistent proposal entries extended individuallyTests (
tests/multisig_test.rs)basic_proposal_reaches_threshold– happy pathreconfigure_does_not_affect_open_proposal– core snapshot isolation: owner removed post-proposal can still approve; newly-added owner cannotthreshold_snapshot_isolation– raising threshold after proposal creation does not block executionnon_owner_cannot_propose– access controlexecute_before_threshold_fails– guardduplicate_approval_rejected– idempotency guardAll 6 tests pass.
Issue #341 — Token-swap with slippage protection
Short commit title:
PR description:
feat: Token-swap contract with slippage protection against front-running
Context
Closes #341.
Adds a new Soroban smart contract (
contracts/token_swap) implementing an on-chain offer/settlement model where the maker's minimum acceptable output (min_output) is enforced at execution time, not at offer creation time.Problem solved
Without a floor check at settlement, an attacker can front-run the settler by inserting a price-moving transaction ahead of the settle tx in the same ledger close. Because Soroban transactions within a ledger close are ordered deterministically, the exploit is practical. Enforcing
output_amount >= min_outputat execution time means any settlement that delivers less than the maker's floor simply reverts — the offer stays open and the front-runner gains nothing.Design
create_offertoken_in,amount_in,token_out,min_output;amount_inis immediately escrowed in the contractsettle_offeroutput_amount; reverts withSlippageExceededifoutput_amount < min_outputcancel_offertoken_inat any time before settlementtoken_inheld by contract; released to settler only on successful settlementTests (
tests/swap_test.rs)settle_at_exact_minimum– boundary: exact floor accepted; balances verifiedsettle_above_minimum_accepted– price improvement acceptedsettle_below_minimum_rejected– slippage guard fires; offer left opendouble_settle_rejected– idempotencycancel_refunds_maker– escrow refund + subsequent settle blockedfront_run_price_drop_is_blocked– explicit front-running scenarioAll 6 tests pass.