feat(KeepWhatsRaised): redirect all fees to platform admin on cancelled treasuries#84
Conversation
There was a problem hiding this comment.
💡 Codex Review
contracts/src/CampaignInfo.sol
Line 303 in 17ade70
getTotalAvailableRaisedAmount() currently aggregates ICampaignTreasury.getRaisedAmount(), which is not the same as currently available funds. In this codebase, withdraw() transfers contract balances without decrementing s_tokenRaisedAmounts, so this function can keep returning a positive “available” amount after funds were already withdrawn. Any integration that uses this API for liquidity/claimability decisions will overestimate what is actually available.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Summary
When a
KeepWhatsRaisedtreasury is cancelled (e.g. due to fraud), backer contributions are reversed off-chain via payment gateways. In that scenario the protocol should not collect fees on contributions that are being refunded. This PR updatesdisburseFees()so that on a cancelled treasury all accrued fees (protocol + platform) are routed to the platform admin, while behavior on non-cancelled treasuries remains unchanged.Changes
src/treasuries/KeepWhatsRaised.soldisburseFees()now branches ons_cancellationTime > 0:protocolShare + platformShareis transferred to the platform admin in a single transfer;FeesDisbursedis emitted withprotocolShare = 0andplatformShare = protocolShare + platformShareso indexers can see the redirection.s_protocolFeePerToken,s_platformFeePerToken) are still zeroed per token in both paths.Tests
Added 5 unit tests in
test/foundry/unit/KeepWhatsRaised.t.sol:testDisburseFeesAfterCancellation_AllFeesToPlatformAdmin— protocol admin receives 0, platform admin receives > 0 after cancellation.testDisburseFeesAfterCancellation_PlatformReceivesBothShares— platform admin receives exactlyprotocolFee + platformFee + vakiCommission + paymentGatewayFees.testDisburseFeesWithoutCancellation_NormalSplit— non-cancelled path still splits fees correctly between protocol and platform admins.testDisburseFeesAfterCancellation_EventEmitsZeroProtocol—FeesDisbursedis emitted withprotocolShare == 0and the full amount inplatformShare.testDisburseFeesAfterCancellation_BackerRefundUnaffected— backer on-chain refund amount is unchanged by the redirected fee disbursement.