Skip to content

Add a protocol fee deduction on settlement that sends a percentage of repayment proceeds to the treasury #405

Description

@Chucks1093

Summary

The settlement function currently distributes the full repayment to investors with no protocol cut. A configurable protocol fee deducted from the repayment amount before investor distribution would sustain the protocol treasury.

Scope

  • Add set_settlement_fee(fee_bps: u32) admin function to configure the settlement fee (default 200 = 2%)
  • Validate fee_bps is between 0 and 1000
  • In settle_invoice, compute the fee as repayment_amount * fee_bps / 10000 and transfer it to the treasury
  • Distribute repayment_amount minus the fee pro-rata to investors
  • Emit a fee_collected event with the fee amount and treasury address

Acceptance Criteria

  • Fee deducted from repayment before investor distribution
  • Fee transferred to treasury address correctly
  • fee_bps above 1000 panics with FeeTooHigh
  • Non-admin caller on set_settlement_fee panics with Unauthorized
  • fee_collected event emitted with correct amount

ETA: 24 hours


Coordinate on Telegram

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions