feat(fractional): fractional ownership analytics / performance metrics (#273)#407
Merged
LaGodxy merged 2 commits intoApr 29, 2026
Merged
Conversation
- Add FractionalMetrics struct (trade_count, total_volume, unique_holders, all_time_high_price, all_time_low_price) - Add token_metrics and is_holder storage mappings - Add get_metrics query message - Add record_trade private helper: increments trade_count, total_volume, ATH/ATL - Add update_holder private helper: tracks unique_holders via is_holder bitmap - Hook record_trade + update_holder into buy_shares, redeem_shares, mint_shares - Add 6 unit tests covering all analytics paths
|
@omonxooo-commits 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #273
Tracks per-token performance metrics directly inside the fractional ownership contract, where the authoritative share data lives.
Changes
New type
FractionalMetrics—trade_count,total_volume,unique_holders,all_time_high_price,all_time_low_priceNew storage
token_metrics: Mapping<u64, FractionalMetrics>— one record per property tokenis_holder: Mapping<(AccountId, u64), bool>— tracks whether an account currently holds shares, used to maintain an accurateunique_holderscount without iteratingNew message
get_metrics(token_id) -> FractionalMetrics— read-only query; returns zero-valued struct for unknown tokensPrivate helpers
record_trade(token_id, volume, price_per_share)— incrementstrade_count, adds tototal_volume, updates ATH/ATLupdate_holder(account, token_id, new_balance)— adjustsunique_holdersonly when an account crosses the zero-balance boundaryHooks added to existing messages
mint_sharesupdate_holderon recipientbuy_sharesrecord_trade(volume + price) +update_holderon seller and buyerredeem_sharesrecord_trade(payout + last price) +update_holderon redeemerTests
6 new
#[ink::test]cases:mint_sharesincrementsunique_holders(no double-count for same account)redeem_shares(all shares) decrementsunique_holdersto 0redeem_sharesrecordstrade_countandtotal_volume