Skip to content

fix(amm): disable unsafe dynamic liquidity markets#136

Draft
rndrntwrk wants to merge 2 commits into
mainfrom
security/lvr-amm-disable-dynamic-liquidity
Draft

fix(amm): disable unsafe dynamic liquidity markets#136
rndrntwrk wants to merge 2 commits into
mainfrom
security/lvr-amm-disable-dynamic-liquidity

Conversation

@rndrntwrk

Copy link
Copy Markdown
Collaborator

Summary

Disables dynamic LVR AMM market creation across EVM and Solana until the dynamic liquidity math can be redesigned and differentially verified.

This is a short-term safety gate, not the final dynamic-market implementation. It is scoped to enoomian/staging so the staging product can continue on static AMM markets without carrying the unsafe dynamic path.

Why

Audit triage showed the current dynamic AMM path can quote/drain nearly the whole reserve on a small trade under the dynamic pricing model. That is not safe to expose while the dynamic model is unresolved.

The safest forward fix is to fail closed at market creation on every supported runtime:

  • EVM Router.create(..., isDynamic=true, ...) reverts.
  • Solana create_bet(..., is_dynamic=true, ...) returns DynamicMarketsDisabled.

Static markets remain available and continue to cover the current staging flow.

Changes

  • Adds DynamicMarketsDisabled to the EVM router and rejects dynamic market creation.
  • Updates EVM LVR tests to exercise static markets by default and adds explicit dynamic rejection coverage.
  • Adds DynamicMarketsDisabled to the end of the Solana PredictionMarketError enum to avoid shifting existing Anchor error codes.
  • Rejects Solana dynamic market creation in create_bet.
  • Updates Solana helpers to create static markets by default.
  • Synchronizes generated Solana IDL/type mirrors for anchor/app/keeper consumers.

Validation

  • FOUNDRY_LIBS='["../../node_modules","lib"]' forge test --match-path test/LvrMarket.t.sol
  • anchor build
  • ANCHOR_MANUAL_TEST_SKIP_BUILD=1 bun run test tests/lvr_amm_security.anchor.ts tests/lvr_amm_authoritative_settlement.ts

Targeted results:

  • EVM LvrMarket.t.sol: 33 passing
  • Solana lvr_amm security: 8 passing
  • Solana lvr_amm authoritative settlement: 5 passing

Rollout Notes

This intentionally disables dynamic market creation only. It does not delete the dynamic pricing code or claim the dynamic model is fixed. Re-enabling dynamic liquidity should require a follow-up PR with a corrected model plus EVM/Rust/TS differential tests.

This PR should merge into enoomian/staging first for staging validation before promotion into any broader release path.

Adding `DynamicMarketsDisabled` to `PredictionMarketError` shifts the
generated IDL's error array. Anchor regenerates the IDL on every build,
and `Solana Program Build Gate` requires every downstream IDL mirror to
match the canonical generated artifact.

Propagates the regenerated IDL into:
  - packages/hyperbet-avax/keeper/src/idl
  - packages/hyperbet-bsc/{app,keeper}/src/idl
  - packages/hyperbet-evm/keeper/src/idl
  - packages/hyperbet-ui/src/idl
  - packages/market-maker-bot/src/idl

Mechanical sync only, produced by
`bun run --cwd packages/hyperbet-solana/anchor build` through the
existing `sync-anchor-artifacts` script. No runtime behavior change;
the dynamic-create rejection lives in
`programs/lvr_amm/src/instructions/create_bet.rs`.
@rndrntwrk rndrntwrk force-pushed the security/lvr-amm-disable-dynamic-liquidity branch from 745b51c to f8137a6 Compare May 1, 2026 02:19
@rndrntwrk rndrntwrk changed the base branch from enoomian/staging to main May 1, 2026 02:19
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