Skip to content

Add multicall utility and metrics aggregation module#90

Merged
tahseen-ccprotocol merged 9 commits intodevelopfrom
feat/contract/metrics
Apr 2, 2026
Merged

Add multicall utility and metrics aggregation module#90
tahseen-ccprotocol merged 9 commits intodevelopfrom
feat/contract/metrics

Conversation

@mahabubAlahi
Copy link
Copy Markdown
Contributor

Summary

  • Multicall utility: Added an ergonomic multicall function that batches multiple entity read calls into a single RPC round-trip via Multicall3. Accepts lazy closures (() => gp.getProtocolFeePercent()) instead of raw ABI descriptors, aligning with the existing entity read pattern. Enabled viem's batch.multicall transport on the provider so all concurrent readContract calls are automatically aggregated. Exposed as both a standalone utility (multicall(...)) and a client convenience method (oak.multicall(...)).

  • Metrics module: Implemented three aggregation functions — getPlatformStats, getCampaignSummary, and getTreasuryReport — that combine multiple on-chain reads into structured reports. Supports all three treasury types (all-or-nothing, keep-whats-raised, payment-treasury) with correct ABI resolution for each.

  • Tests & docs: Added comprehensive unit tests for the multicall utility and all three metrics functions with 100% coverage. Updated README.md with dedicated Multicall and Metrics sections, usage examples, doc links, and the exported entry points table.

- Introduced a new `multicall` function to enable batching of multiple entity read calls into a single RPC request, improving efficiency.
- Updated `provider.ts` to enable `batch.multicall` in the JSON RPC provider configuration.
- Exported the new `multicall` function from the utils index for easy access.
- Implemented a new `multicall` method in the `OakContractsClient` interface to facilitate batching of multiple entity read calls into a single RPC request.
- Updated the `create.ts` file to include the `multicall` function, enhancing the client’s functionality and efficiency in handling multiple asynchronous calls.
- Added `getCampaignSummary` function to aggregate financial data from the CampaignInfo contract, including total raised, refunded, and goal status.
- Introduced `getTreasuryReport` function for per-treasury reporting, supporting AllOrNothing, KeepWhatsRaised, and PaymentTreasury contracts.
- Updated types to reflect new options and return structures for campaign and treasury reports.
- Enhanced documentation with examples for both functions to improve usability.
- Introduced tests for the `multicall` utility, verifying concurrent execution of closures and error propagation.
- Expanded the `getPlatformStats`, `getCampaignSummary`, and `getTreasuryReport` functions with comprehensive tests to ensure accurate financial data aggregation and reporting.
- Implemented mock client for testing contract interactions, improving test coverage and reliability.
- Introduced a new section on Multicall, detailing its usage for batching multiple entity read calls into a single RPC request, with examples for standalone utility and client convenience methods.
- Added a Metrics section, outlining pre-built aggregation functions for platform statistics, campaign summaries, and treasury reports, complete with usage examples.
- Updated the exported entry points to include the new multicall and metrics functionalities for improved accessibility.
@mahabubAlahi mahabubAlahi self-assigned this Apr 2, 2026
@mahabubAlahi mahabubAlahi added the enhancement New feature or request label Apr 2, 2026
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

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a25636fb9

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

Comment thread packages/contracts/src/lib/viem/provider.ts
- Introduced a constant for the canonical Multicall3 address, ensuring consistency across supported chains.
- Updated Celo Mainnet and Celo Sepolia chain definitions to include the Multicall3 contract address and block creation details, enhancing interoperability for multicall functionalities.
@mahabubAlahi
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

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

@tahseen-ccprotocol tahseen-ccprotocol merged commit aaf37dc into develop Apr 2, 2026
2 of 6 checks passed
@devmahmud devmahmud deleted the feat/contract/metrics branch April 2, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants