Skip to content

fix(maintenance-pool): deposit credits the received delta, not the requested amount - #606

Open
yggdrasilworld wants to merge 2 commits into
MergeFi:mainfrom
yggdrasilworld:fix/deposit-fee-delta-532
Open

yggdrasilworld wants to merge 2 commits into
MergeFi:mainfrom
yggdrasilworld:fix/deposit-fee-delta-532

Conversation

@yggdrasilworld

@yggdrasilworld yggdrasilworld commented Oct 14, 2026 •

Copy link
Copy Markdown

What

Fixes maintenance-pool::deposit to credit the received amount (via measure_transfer_delta), not the requested amount — the fee-on-transfer / rebasing-token bug from #532.

The bug

deposit called token_client.transfer(..., &amount) then credited amount to pool.balance, total_deposited, and the Deposit record. For a token that takes a transfer fee, the contract actually receives amount - fee — so the pool's books exceeded its holdings, and later withdrawals/reclaims would fail or eat into other pools.

The fix

Mirrors the established pattern from escrow::fund/contribute and milestones::create_milestone/contribute (#3):

  • measure_transfer_delta measures the contract's actual balance change across the transfer
  • actual_received <= 0 → Error::InvalidAmount
  • pool.balance, total_deposited, and the Deposit record all credit actual_received, not amount

Honest caveat — flagged

  • Not locally compiled — the workspace pins rustc 1.95 + wasm32v1-none, which isn't installable in this environment; the fix is a faithful mirror of the proven escrow::fund usage but I could not build it. Please let CI verify.
  • No fee-on-transfer test added — the issue asks to "test with the existing fee-on-transfer mock token," but no fee-token mock crate exists in the workspace (common, escrow, milestones, maintenance-pool only). If a mock exists elsewhere or one should be added, point me at it and I'll add the regression test.

Resolves #532

Payment: Base USDC 0xD40Df5c27cEa7dd78A3c345401995c319589334e

…quested amount

maintenance-pool::deposit transferred  then credited  to
pool.balance / total_deposited / the Deposit record. With a
fee-on-transfer or rebasing token, the amount that arrives is less than
, so the pool's books exceeded its holdings — later withdrawals
or reclaims fail with insufficient balance or eat into other pools.

Use mergefi_common::measure_transfer_delta as escrow::fund and
milestones::create_milestone already do: measure the contract's actual
balance change across the transfer, reject actual_received <= 0, and
book the received amount.

Resolves MergeFi#532

Note: the fee-on-transfer regression test requires a fee-taking mock
token, which isn't present in the workspace — flagging that the test
gap remains; the fix mirrors the established escrow/milestones pattern.
@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

The AC demands the deposit-delta fix be exercised with a fee-on-transfer
mock — adds MockFeeToken (10% burns in transit) and asserts the pool
credits 90 of a requested 100 deposit.
@yggdrasilworld

Copy link
Copy Markdown
Author

Scope audit addendum: added the AC's demanded fee-on-transfer test — MockFeeToken (10% burns in transit), deposit of 100 credits the received 90. cargo test 43/43.

This branch has not been deployed

No deployments
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.

maintenance-pool::deposit credits the requested amount, not the amount received (no measure_transfer_delta)

1 participant