Skip to content

resolv#18517

Merged
waynebruce0x merged 3 commits intomainfrom
resolv-by-subtraction
Mar 25, 2026
Merged

resolv#18517
waynebruce0x merged 3 commits intomainfrom
resolv-by-subtraction

Conversation

@waynebruce0x
Copy link
Copy Markdown
Collaborator

@waynebruce0x waynebruce0x commented Mar 24, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Restored Ethereum TVL reporting so values no longer fail and reflect actual token supplies.
  • Improvements

    • TVL now uses timestamp-driven logic to provide accurate calculations and to surface an error if data is out-of-date.
    • Adjusts reported supply to subtract the 80M tokens minted during the hack for correct USDC-equivalent totals.
  • Documentation

    • Added a clear methodology summary describing the TVL calculation approach.

@llamabutler
Copy link
Copy Markdown

The adapter at projects/resolv exports TVL:

ethereum                  114.10 M
ethereum-staking          2.52 M
staking                   2.52 M

total                    114.10 M 

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 337ff42a-5dea-45db-9fc8-0d309035b30a

📥 Commits

Reviewing files that changed from the base of the PR and between 0909642 and 73f1ef3.

📒 Files selected for processing (1)
  • projects/resolv/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • projects/resolv/index.js

📝 Walkthrough

Walkthrough

The Ethereum adapter gains a functional, timestamp-gated TVL routine that reads token total supplies, subtracts a post-hack minted amount, imports core asset addresses, and adds a methodology string; misrepresentedTokens is also set on the adapter.

Changes

Cohort / File(s) Summary
TVL & metadata
projects/resolv/index.js
Imported ADDRESSES from ../helper/coreAssets.json; added methodology string; set misrepresentedTokens: true; replaced unconditional erroring tvl with a timestamp-based implementation that: throws after a cutoff, applies a mid-range branch that reads tokens[0] (USR) and tokens[1] (RLP) supplies, scales USR to USDC, and subtracts 8e13 to account for minted amount; otherwise falls back to multicall of both token supplies. File ends without trailing newline.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I once would shout "Error!" in flight,
Now I fetch supplies by timestamp light.
I scale, subtract, and gently hum,
TVL counted — hop, hop, done! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'resolv' is overly vague and does not convey the specific change being made to the adapter. Use a more descriptive title such as 'Update resolv adapter to handle post-hack TVL calculations' or similar.
Description check ⚠️ Warning No pull request description was provided; the author did not fill out any of the required template sections for this repository. Add a description explaining the changes, methodology being counted, and reason for updating the resolv adapter.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch resolv-by-subtraction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@llamabutler
Copy link
Copy Markdown

The adapter at projects/resolv exports TVL:

ethereum                  114.39 M
ethereum-staking          2.46 M
staking                   2.46 M

total                    114.39 M 

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
projects/resolv/index.js (2)

14-19: Sequential awaits can be parallelized for better performance.

The two api.call invocations on lines 14 and 19 are independent and could be executed concurrently using Promise.all.

Parallel fetch example
       if (api.timestamp > 1774137600) {
-        api.add(ADDRESSES.ethereum.USDC, (await api.call({ target: tokens[0], abi: 'erc20:totalSupply' })) / 10 **12)
-        // Subtract 80M after hack 
-        // https://etherscan.io/tx/0x41b6b9376d174165cbd54ba576c8f6675ff966f17609a7b80d27d8652db1f18f
-        // https://etherscan.io/tx/0xfe37f25efd67d0a4da4afe48509b258df48757b97810b28ce4c649658dc33743
-        api.add(ADDRESSES.ethereum.USDC, -8e13)
-        api.add(tokens[1], await api.call({ target: tokens[1], abi: 'erc20:totalSupply' }))
+        const [usrSupply, rlpSupply] = await Promise.all([
+          api.call({ target: tokens[0], abi: 'erc20:totalSupply' }),
+          api.call({ target: tokens[1], abi: 'erc20:totalSupply' }),
+        ])
+        api.add(ADDRESSES.ethereum.USDC, BigInt(usrSupply) / BigInt(10 ** 12))
+        // Subtract 80M after hack 
+        // https://etherscan.io/tx/0x41b6b9376d174165cbd54ba576c8f6675ff966f17609a7b80d27d8652db1f18f
+        // https://etherscan.io/tx/0xfe37f25efd67d0a4da4afe48509b258df48757b97810b28ce4c649658dc33743
+        api.add(ADDRESSES.ethereum.USDC, -8e13)
+        api.add(tokens[1], rlpSupply)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@projects/resolv/index.js` around lines 14 - 19, The two independent token
supply fetches use sequential awaits (api.call for tokens[0] and tokens[1]);
change them to run in parallel via Promise.all, await both results together,
then call api.add for ADDRESSES.ethereum.USDC (divide result[0] by 10**12) and
api.add(tokens[1], result[1]); keep the subsequent hard-coded subtraction
api.add(ADDRESSES.ethereum.USDC, -8e13) in place and ensure you use the same
symbols (api.call, api.add, tokens, ADDRESSES) when replacing the code.

13-14: Consider using BigInt arithmetic to avoid potential precision loss.

The division / 10 ** 12 coerces the large totalSupply value to a JavaScript Number, which may lose precision for supplies exceeding Number.MAX_SAFE_INTEGER (~9e15). USR with 18 decimals and ~114M supply approaches 1.14e26 in raw units.

Also, the timestamp 1774137600 would benefit from a comment indicating the target date.

Suggested improvement
     misrepresentedTokens: true,
     tvl: async (api) => { 
-      if (api.timestamp > 1774137600) {
-        api.add(ADDRESSES.ethereum.USDC, (await api.call({ target: tokens[0], abi: 'erc20:totalSupply' })) / 10 **12)
+      // Nov 19, 2026 - apply hack adjustment after this date
+      if (api.timestamp > 1774137600) {
+        const usrSupply = await api.call({ target: tokens[0], abi: 'erc20:totalSupply' })
+        api.add(ADDRESSES.ethereum.USDC, BigInt(usrSupply) / BigInt(10 ** 12))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@projects/resolv/index.js` around lines 13 - 14, The current expression in the
api.add call coerces a big ERC20 totalSupply to a Number via `/ 10 ** 12`,
risking precision loss; update the logic that reads (await api.call({ target:
tokens[0], abi: 'erc20:totalSupply' })) / 10 **12 to use BigInt arithmetic
(e.g., cast totalSupply to BigInt, divide by BigInt(10) ** BigInt(12) or scale
appropriately) before passing to api.add so values remain exact, and ensure
api.add accepts the BigInt (or convert to a safe string if required); also add a
brief comment beside the literal timestamp 1774137600 indicating its
human-readable date for clarity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@projects/resolv/index.js`:
- Around line 14-19: The two independent token supply fetches use sequential
awaits (api.call for tokens[0] and tokens[1]); change them to run in parallel
via Promise.all, await both results together, then call api.add for
ADDRESSES.ethereum.USDC (divide result[0] by 10**12) and api.add(tokens[1],
result[1]); keep the subsequent hard-coded subtraction
api.add(ADDRESSES.ethereum.USDC, -8e13) in place and ensure you use the same
symbols (api.call, api.add, tokens, ADDRESSES) when replacing the code.
- Around line 13-14: The current expression in the api.add call coerces a big
ERC20 totalSupply to a Number via `/ 10 ** 12`, risking precision loss; update
the logic that reads (await api.call({ target: tokens[0], abi:
'erc20:totalSupply' })) / 10 **12 to use BigInt arithmetic (e.g., cast
totalSupply to BigInt, divide by BigInt(10) ** BigInt(12) or scale
appropriately) before passing to api.add so values remain exact, and ensure
api.add accepts the BigInt (or convert to a safe string if required); also add a
brief comment beside the literal timestamp 1774137600 indicating its
human-readable date for clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f46e8a23-bac2-4f1c-bcc6-1e4ca1c5c0a6

📥 Commits

Reviewing files that changed from the base of the PR and between f732e9f and 0909642.

📒 Files selected for processing (1)
  • projects/resolv/index.js

@llamabutler
Copy link
Copy Markdown

The adapter at projects/resolv exports TVL:

ethereum                  116.74 M
ethereum-staking          2.31 M
staking                   2.31 M

total                    116.74 M 

@waynebruce0x waynebruce0x merged commit 1023c57 into main Mar 25, 2026
2 checks passed
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.

2 participants