Skip to content

Add emergency pause switch to the AMM pool - #101

Merged
Jaydbrown merged 12 commits into
mainfrom
feat/emergency-pause-switch
Jul 9, 2026
Merged

Add emergency pause switch to the AMM pool#101
Jaydbrown merged 12 commits into
mainfrom
feat/emergency-pause-switch

Conversation

@Jaydbrown

Copy link
Copy Markdown
Contributor

Summary

  • Adds an admin-gated emergency pause switch to the AMM contract, closing the biggest remaining safety gap before real funds could touch it.
  • pause/unpause/is_paused are gated by the existing fee_to_setter admin address — no new init parameter needed.
  • add_liquidity, remove_liquidity, swap, swap_exact_tokens_for_tokens, and swap_tokens_for_exact_tokens all reject with ContractPaused while halted.
  • sync() is deliberately left unguarded since it only reconciles reserves and never moves funds.
  • Both transitions emit events (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 — clean
  • cargo fmt -- --check — clean

Jaydbrown added 11 commits July 9, 2026 15:27
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.
@Jaydbrown
Jaydbrown merged commit 18e6685 into main Jul 9, 2026
3 checks passed
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
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