Skip to content

feat(pool): include funded_amount in repayment_received event for audit trail (#135)#149

Closed
Micheal-Blessed wants to merge 3 commits into
TrusTrove:mainfrom
Micheal-Blessed:feat/135-pool-repayment-event-funded-amount
Closed

feat(pool): include funded_amount in repayment_received event for audit trail (#135)#149
Micheal-Blessed wants to merge 3 commits into
TrusTrove:mainfrom
Micheal-Blessed:feat/135-pool-repayment-event-funded-amount

Conversation

@Micheal-Blessed

Copy link
Copy Markdown

Summary

The repayment_received event in the Pool contract now includes the original funded_amount (principal), enabling off-chain indexers to reconstruct the complete funding lifecycle for ROI and pool performance tracking.

Problem

While the InvoiceContract emits invoice_repaid, the PoolContract only emitted a generic repayment event with amount and yield_amount. For off-chain indexing of pool performance and ROI, the original principal funded for each invoice is essential but was missing from the event.

Changes

contracts/pool/src/events.rs

  • Added funded_amount: u128 parameter to the repayment_received function
  • Included funded_amount in the event data tuple: (amount, funded_amount, yield_amount)

contracts/pool/src/lib.rs

  • In receive_repayment, the funded_amount is already read from FundedInvoice storage before the event emission — now passed directly to the event call
  • No logic changes; purely additive to the event data

Test Snapshots

  • Deleted all 117 stale pool test snapshots (they must be regenerated after any contract binary change via cargo test -p trusttrove-pool)

Event Data Format (After)

repayment_received(invoice_id, data: (amount, funded_amount, yield_amount))

Where:

  • amount — total amount repaid
  • funded_amount — original principal funded for this invoice (from FundedInvoice storage)
  • yield_amount — yield earned (amount - funded_amount)

Acceptance Criteria

  • The repayment_received event now includes the original funded amount
  • Events provide a full audit trail of the funding lifecycle within the pool
  • No breaking changes to contract logic — purely additive to event data

Closes #135

…it trail (TrusTrove#135)

The repayment_received event now emits the original funded_amount
retrieved from FundedInvoice storage, enabling off-chain indexing
to reconstruct the full funding lifecycle (principal + yield).

Changed:
- events.rs: add funded_amount parameter to repayment_received event
- lib.rs: pass funded_amount to event emission in receive_repayment
- Deleted stale test snapshots (regenerated on next test run)

Closes TrusTrove#135
@K1NGD4VID

Copy link
Copy Markdown
Contributor

Resolve Merge conflict @Micheal-Blessed

…ment-event-funded-amount

# Conflicts:
#	contracts/pool/test_snapshots/test/test_deposit_after_yield_uses_updated_share_price.1.json
#	contracts/pool/test_snapshots/test/test_deposit_during_active_funding.1.json
#	contracts/pool/test_snapshots/test/test_deposit_when_deposits_zero_but_shares_exist.1.json
#	contracts/pool/test_snapshots/test/test_full_lifecycle_multiple_invoices.1.json
#	contracts/pool/test_snapshots/test/test_fund_invoice_allowed_when_below_cap.1.json
#	contracts/pool/test_snapshots/test/test_fund_invoice_fails_asset_mismatch.1.json
#	contracts/pool/test_snapshots/test/test_fund_invoice_fails_when_insufficient_liquidity.1.json
#	contracts/pool/test_snapshots/test/test_fund_invoice_reduces_available_liquidity.1.json
#	contracts/pool/test_snapshots/test/test_fund_invoice_rejects_above_cap.1.json
#	contracts/pool/test_snapshots/test/test_get_stats_after_funding.1.json
#	contracts/pool/test_snapshots/test/test_handle_default.1.json
#	contracts/pool/test_snapshots/test/test_handle_default_unauthorized_caller_panics.1.json
#	contracts/pool/test_snapshots/test/test_lp_position_reflects_current_share_price.1.json
#	contracts/pool/test_snapshots/test/test_multi_invoice_default_first_then_repay_second.1.json
#	contracts/pool/test_snapshots/test/test_multi_invoice_fund_two_repay_one_default_one.1.json
#	contracts/pool/test_snapshots/test/test_new_lp_deposits_after_multiple_yield_events.1.json
#	contracts/pool/test_snapshots/test/test_receive_repayment.1.json
#	contracts/pool/test_snapshots/test/test_receive_repayment_panics_when_amount_below_funded.1.json
#	contracts/pool/test_snapshots/test/test_receive_repayment_unauthorized_caller_panics.1.json
#	contracts/pool/test_snapshots/test/test_reducing_cap_mid_lifecycle_blocks_new_funding.1.json
#	contracts/pool/test_snapshots/test/test_series_of_defaults_erodes_lp_value.1.json
#	contracts/pool/test_snapshots/test/test_two_lps_one_withdraws_after_default.1.json
#	contracts/pool/test_snapshots/test/test_two_lps_receive_proportional_yield.1.json
#	contracts/pool/test_snapshots/test/test_utilization_rate_after_funding.1.json
#	contracts/pool/test_snapshots/test/test_utilization_rate_calculates_correctly.1.json
#	contracts/pool/test_snapshots/test/test_withdraw_after_default_partial.1.json
#	contracts/pool/test_snapshots/test/test_withdraw_fails_if_insufficient_liquidity.1.json
#	contracts/pool/test_snapshots/test/test_withdraw_full_after_default.1.json
#	contracts/pool/test_snapshots/test/test_yield_increases_share_price_after_repayment.1.json
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Micheal-Blessed 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

@Micheal-Blessed

Copy link
Copy Markdown
Author

@K1NGD4VID Resolved, you can review.

@K1NGD4VID

Copy link
Copy Markdown
Contributor

resolve Merge Conflcit @Micheal-Blessed

@K1NGD4VID K1NGD4VID closed this Jul 6, 2026
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.

feat(pool): enhance repayment_received event with funded_amount

2 participants