Skip to content

feat(KeepWhatsRaised): redirect all fees to platform admin on cancelled treasuries#84

Merged
adnanhq merged 2 commits intofeat/kwr-void-pledgefrom
feat/proposal-p1
Apr 23, 2026
Merged

feat(KeepWhatsRaised): redirect all fees to platform admin on cancelled treasuries#84
adnanhq merged 2 commits intofeat/kwr-void-pledgefrom
feat/proposal-p1

Conversation

@Suvadra-Barua
Copy link
Copy Markdown
Collaborator

@Suvadra-Barua Suvadra-Barua commented Apr 2, 2026

Summary

When a KeepWhatsRaised treasury 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 updates disburseFees() 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.sol

  • disburseFees() now branches on s_cancellationTime > 0:
    • Not cancelled: unchanged — protocol fees → protocol admin, platform fees → platform admin.
    • Cancelled: protocolShare + platformShare is transferred to the platform admin in a single transfer; FeesDisbursed is emitted with protocolShare = 0 and platformShare = protocolShare + platformShare so indexers can see the redirection.
  • Fee accumulators (s_protocolFeePerToken, s_platformFeePerToken) are still zeroed per token in both paths.
  • Function remains callable before or after cancellation so accrued fees are never trapped.
  • Updated NatSpec to document the cancelled-treasury behavior.

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 exactly protocolFee + platformFee + vakiCommission + paymentGatewayFees.
  • testDisburseFeesWithoutCancellation_NormalSplit — non-cancelled path still splits fees correctly between protocol and platform admins.
  • testDisburseFeesAfterCancellation_EventEmitsZeroProtocolFeesDisbursed is emitted with protocolShare == 0 and the full amount in platformShare.
  • testDisburseFeesAfterCancellation_BackerRefundUnaffected — backer on-chain refund amount is unchanged by the redirected fee disbursement.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

amount += ICampaignTreasury(tempTreasury).getRaisedAmount();

P2 Badge Sum available balances when reporting available raised amount

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".

@Suvadra-Barua Suvadra-Barua changed the base branch from dev to main April 10, 2026 19:03
@Suvadra-Barua Suvadra-Barua changed the title Feat/proposal p1 feat(KeepWhatsRaised): redirect all fees to platform admin on cancelled treasuries Apr 23, 2026
@Suvadra-Barua Suvadra-Barua changed the base branch from main to feat/kwr-void-pledge April 23, 2026 16:05
@adnanhq adnanhq merged commit fb4fc73 into feat/kwr-void-pledge Apr 23, 2026
1 check passed
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.

2 participants