Add emergency pause switch to the AMM pool - #101
Merged
Conversation
Reserves storage slot for the emergency pause flag ahead of wiring up the actual pause/unpause entrypoints.
Returned by state-mutating entrypoints when the pool is halted.
is_paused/require_not_paused read the new Paused flag; require_fee_to_setter centralizes the existing fee_to_setter auth check for reuse by the upcoming pause entrypoints.
set_fee_to and set_fee_to_setter both re-implemented the same require_auth + FeeToSetter comparison inline; route both through the shared helper instead.
Gated by the fee_to_setter admin address (the contract's only existing privileged role) so no new init parameter is needed.
add_liquidity, remove_liquidity, swap_exact_tokens_for_tokens, and swap_tokens_for_exact_tokens now reject with ContractPaused while the pool is halted.
Covers the router-style swap() entrypoint, which has no deadline param and was handled separately from the other four.
Covers admin-only access control on pause/unpause, that every fund-moving entrypoint rejects with ContractPaused while halted, that unpause restores normal operation, and that sync() is deliberately left unguarded.
ed25519-dalek published a breaking 3.0.0 that soroban-env-host's testutils can't compile against (ChaCha20Rng no longer satisfies its CryptoRng bound). Without a committed lockfile, every fresh resolution -- including CI once its cache rolls over -- picks up the break. Pin the whole graph so builds are reproducible and this class of upstream breakage can't reoccur silently.
3 tasks
emwulrd
pushed a commit
to emwulrd/Nodus-Protocol-Smart-Contract
that referenced
this pull request
Jul 20, 2026
Covers environment setup (Rust, Stellar CLI), WASM build, test commands (unit, integration, fuzz, coverage), code style (rustfmt, clippy), PR requirements (conventional commits, coverage threshold), review process, and Soroban-specific gotchas (wasm32v1-none target, no_std, testnet deployment). Closes Nodus-protocol#101
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
pause/unpause/is_pausedare gated by the existingfee_to_setteradmin address — no new init parameter needed.add_liquidity,remove_liquidity,swap,swap_exact_tokens_for_tokens, andswap_tokens_for_exact_tokensall reject withContractPausedwhile halted.sync()is deliberately left unguarded since it only reconciles reserves and never moves funds.v1_pause/v1_unpau) for off-chain indexers.Test plan
cargo build(dev profile)cargo build --release --target wasm32v1-none(matches CI's build job)cargo test --features testutils— 52 passed, 0 failed (11 new pause-specific tests)cargo clippy --all-targets --features testutils -- -D warnings— cleancargo fmt -- --check— clean