Skip to content

fix: Cauldron TVL heuristic and precision bug#63

Open
zknpr wants to merge 1 commit intomainfrom
cauldron-tvl-heuristic-15774703087508486808
Open

fix: Cauldron TVL heuristic and precision bug#63
zknpr wants to merge 1 commit intomainfrom
cauldron-tvl-heuristic-15774703087508486808

Conversation

@zknpr
Copy link
Copy Markdown
Owner

@zknpr zknpr commented Mar 8, 2026

Implemented the standard 50/50 AMM heuristic for Cauldron DEX on Bitcoin Cash, where only the BCH side of pairs has known CoinGecko IDs, by doubling the calculated base asset value. In addition, fixed a precision loss bug in the calculation where BigInt integer division silently truncated fractional BCH amounts.


PR created automatically by Jules for task 15774703087508486808 started by @zknpr

- Applied the 2x heuristic to estimate TVL from the known base asset (BCH) since tokens lack CoinGecko IDs.
- Fixed an integer truncation bug by casting total_sats to a Number before performing division.

Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 8, 2026

Warning

Rate limit exceeded

@zknpr has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 57 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b16cc36c-df74-498a-883b-43af178e833f

📥 Commits

Reviewing files that changed from the base of the PR and between 0d3be2a and 399c6cf.

📒 Files selected for processing (1)
  • projects/cauldron/index.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cauldron-tvl-heuristic-15774703087508486808

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/cauldron exports TVL:

bitcoincash               1.18 M

total                    1.18 M 

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR fixes two bugs in the Cauldron DEX TVL adapter for Bitcoin Cash: it corrects a BigInt integer-division precision loss (which previously silently truncated fractional BCH amounts), and adds the standard 50/50 AMM heuristic by multiplying the BCH-side value by 2 to account for the non-BCH side of each pair (which lacks a CoinGecko ID).

Key changes:

  • Replaces Number(total_sats / 100000000n) (BigInt division — always produces a whole number) with Number(total_sats) * 2 / 1e8, preserving sub-BCH precision and doubling for the full pool value.
  • Removes the now-resolved TODO comment about unmapped CoinGecko token identifiers.

Both changes are correct and appropriate for this adapter.

Confidence Score: 5/5

  • This PR is safe to merge. The changes correctly fix precision loss and apply a reasonable AMM heuristic with no regressions.
  • Both the precision fix (using float division instead of BigInt division) and the 50/50 heuristic (multiplying by 2) are logically correct and well-scoped. The changes are minimal, focused, and the surrounding code remains unchanged. For all practical Bitcoin Cash TVL levels, the implementation is sound.
  • No files require special attention.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Fetch /cauldron/tvl/:timestamp] --> B[Reduce token_pairs to total_sats BigInt]
    B --> C{Old logic}
    B --> D{New logic}
    C --> E["total_sats / 100000000n\n(BigInt integer division\n– truncates sub-BCH fractions)"]
    E --> F["Number(result)\n→ whole BCH only, ×1"]
    D --> G["Number(total_sats)\n(preserve full precision)"]
    G --> H["× 2  (50/50 AMM heuristic:\nBCH is one half of every pair)"]
    H --> I["/ 1e8  (convert sats → BCH)\n→ fractional BCH, full TVL"]
    F --> J[Return bitcoin-cash TVL]
    I --> J
Loading

Last reviewed commit: 399c6cf

zknpr added a commit that referenced this pull request Mar 8, 2026
Acknowledging that this work is a duplicate of PR #63 and stopping work on this task.

Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
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