feat: enable viem multicall batching on the public client (0.12.0)#56
Conversation
Client-level batch.multicall aggregates concurrent readContract calls into one Multicall3 aggregate3 eth_call (one billed RPC request instead of N). The estimateLiquidity margin probe opts out (batch: false) so its revert-marker classification keeps the same inner msg.sender semantics. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR enables viem's client-level ChangesMulticall Batching Enablement
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
package.json (1)
5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRegenerate
package-lock.jsonto match the version bump.
package-lock.json's rootversionfield is still0.11.0per the provided context, out of sync with this bump to0.12.0. Runnpm install(or equivalent) to refresh the lockfile's root version metadata.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@package.json` at line 5, The root version metadata in package-lock.json is out of sync with the package version bump in package.json. Regenerate the lockfile by running npm install (or equivalent) so the package-lock root version matches 0.12.0, and keep the package-lock.json entry aligned with the version field in package.json.CHANGELOG.md (1)
15-15: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor wording nit flagged by static analysis.
✏️ Suggested tightening
- requests, cutting billed RPC calls roughly in proportion to the read fan-out. Transport-level + requests, cutting billed RPC calls roughly proportional to the read fan-out. Transport-level🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@CHANGELOG.md` at line 15, The changelog entry contains a minor wording issue flagged by static analysis; tighten the phrasing in the affected sentence so it reads more cleanly and consistently, keeping the same meaning. Update the text in CHANGELOG.md around the “requests, cutting billed RPC calls...” sentence to use a more concise, polished wording.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@CHANGELOG.md`:
- Line 15: The changelog entry contains a minor wording issue flagged by static
analysis; tighten the phrasing in the affected sentence so it reads more cleanly
and consistently, keeping the same meaning. Update the text in CHANGELOG.md
around the “requests, cutting billed RPC calls...” sentence to use a more
concise, polished wording.
In `@package.json`:
- Line 5: The root version metadata in package-lock.json is out of sync with the
package version bump in package.json. Regenerate the lockfile by running npm
install (or equivalent) so the package-lock root version matches 0.12.0, and
keep the package-lock.json entry aligned with the version field in package.json.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 19415b1b-fa51-4e16-b7be-897aa6394ca6
📒 Files selected for processing (4)
CHANGELOG.mdpackage.jsonsrc/context.tssrc/utils/liquidity.ts
Summary
batch: { multicall: true }: concurrentreadContractcalls (the 7 config reads ingetPerpConfig, the 4 infetchPerpContractData) are aggregated into a single Multicall3aggregate3eth_call— one billed RPC request instead of N. Transport-level HTTP batching stays for requests multicall cannot aggregate (simulateContract, calls with an account/value).estimateLiquiditymaker-margin probe opts out withbatch: false: routed throughaggregate3the innermsg.senderbecomes the Multicall3 contract instead of the zero address, which can change which allowance-failure revert the margin transfer produces and break the revert-marker classification (PR fix!: size maker liquidity to the on-chain margin check #55 semantics preserved exactly).eth_calls automatically; Arbitrum One and Sepolia both carry the canonical deployment.perpcity-clientgets the dependency bump after that.Test plan
pnpm run ci: build + 263 unit tests + tsc + biomepnpm run test:integration: 38 Anvil integration tests (exercises the no-multicall fallback path)eth_callto Multicall3 in devtools; trading/LP/balance flows unaffected🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Chores