Skip to content

fix: data-warehouse-and-metrics-aggregation (closes #256)#313

Open
AYo101o wants to merge 1 commit intoFracverse:masterfrom
AYo101o:data-warehouse-and-metrics-aggregation
Open

fix: data-warehouse-and-metrics-aggregation (closes #256)#313
AYo101o wants to merge 1 commit intoFracverse:masterfrom
AYo101o:data-warehouse-and-metrics-aggregation

Conversation

@AYo101o
Copy link
Copy Markdown

@AYo101o AYo101o commented Mar 25, 2026

I have implemented a mechanism to track and store cumulative performance metrics for the lending contract. This allows the system to monitor total loans issued, principal borrowed, interest earned, and liquidation performance.

Changes Made

Lending Contract

New PerformanceData Structure:
Added PerformanceData struct to track cumulative metrics:
total_loans_issued: Count of all loans created.
total_principal_borrowed: Total amount of all loans.
total_interest_earned: Total interest collected from repayments.
total_liquidations_count: Number of successful liquidations.
total_collateral_seized: Total value of collateral seized during liquidations.

Storage Integration:
Added DataKey::Performance for on-chain storage.
Initialized performance metrics to zero in the initialize function.

Tracking Logic:
borrow: Now increments total_loans_issued and adds the borrowed amount to total_principal_borrowed.
repay: Now adds the accrued interest to total_interest_earned.
liquidate: Now increments total_liquidations_count and adds the seized collateral value to total_collateral_seized.

Public Access:
Added get_performance_data public function to retrieve these metrics for UI or audit purposes.
Tests
test_performance_tracking: Verifies that metrics correctly accumulate after borrow and repay operations.
test_liquidation_performance: Verifies that liquidation-specific metrics are correctly tracked.

Closes #256

@ONEONUORA
Copy link
Copy Markdown
Contributor

@AYo101o Pls link the pr

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 25, 2026

@AYo101o 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

@AYo101o
Copy link
Copy Markdown
Author

AYo101o commented Mar 25, 2026

@AYo101o Pls link the pr

Done

@ONEONUORA
Copy link
Copy Markdown
Contributor

You will be unassign from this issue in 6 hrs,

@ONEONUORA
Copy link
Copy Markdown
Contributor

@AYo101o Pls fix conflict

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.

[Backend] Data Warehouse & Metrics Aggregation

2 participants