Skip to content

fix: correct funding-rate keys, faucet auth reuse, mainnet deploy gua… - #495

Merged
abayomicornelius merged 1 commit into
SO4-Markets:mainfrom
zane1502:fix/issues-397-399-400-401
Jul 25, 2026
Merged

fix: correct funding-rate keys, faucet auth reuse, mainnet deploy gua…#495
abayomicornelius merged 1 commit into
SO4-Markets:mainfrom
zane1502:fix/issues-397-399-400-401

Conversation

@zane1502

Copy link
Copy Markdown
Contributor

What was fixed (all verified via cargo test, plus an independent peer review pass)

  1. reader::get_funding_rate_info reads storage with the wrong token key, unlike get_funding_info #397 — get_funding_rate_info now loads the market and keys funding/OI reads off
    long_token/short_token, matching get_funding_info. Added 2 tests.
  2. TestFaucet::claim_many has a known auth-reuse bug, yet docs tell the frontend to use it as the primary claim button #399 — claim_many now authorizes once per call (shared do_claim helper) instead of once per
    token in a loop. Added a 2-token test.
  3. make deploy-contract has no mainnet guard, letting test_faucet/test_token bypass guard-not-mainnet #400 — deploy-contract now refuses test_token/test_faucet on mainnet (scoped to just those
    two, doesn't touch other contracts); added a matching on-chain network_id self-check in both
    contracts' initialize so even a raw stellar contract invoke can't bypass it. Added tests for
    both.
  4. README architecture/contract map and the deployment tooling omit four real contracts #401 — Added fee_batch_sweeper, insurance_fund_router, market_util_reader, order_cleanup to
    the README architecture diagram/contract map/project tree, docs/deployment.md, and mx/common.mk.

Closes #397
Closes #399
Closes #400
Closes #401

…rd, periphery docs

- reader::get_funding_rate_info read funding/OI storage keyed by
  (market_token, market_token) instead of (market_token, long_token) /
  (market_token, short_token), silently returning zeros on real markets.
  Load the market and derive keys the same way get_funding_info already does.

- TestFaucet::claim_many called account.require_auth() once per token inside
  a loop, tripping a Soroban auth-reuse failure on real signed transactions.
  Both claim and claim_many now authorize once per invocation via a shared
  do_claim helper.

- make deploy-contract had no mainnet guard, so test_token/test_faucet could
  be deployed to mainnet through the generic target. Added an inline guard in
  mx/deploy.mk plus an on-chain network_id self-check in both contracts'
  initialize so a direct stellar contract invoke can't bypass it either.

- fee_batch_sweeper, insurance_fund_router, market_util_reader, and
  order_cleanup were implemented and audited but missing from the README
  architecture diagram/contract map, the deployment runbook, and
  mx/common.mk's CONTRACTS list.

Closes SO4-Markets#397, closes SO4-Markets#399, closes SO4-Markets#400, closes SO4-Markets#401
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@zane1502 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@abayomicornelius
abayomicornelius merged commit 8c8b1c7 into SO4-Markets:main Jul 25, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment