Skip to content

Add Anoncoin adapter#18718

Open
akhil-onjuno wants to merge 4 commits intoDefiLlama:mainfrom
akhil-onjuno:add-anoncoin
Open

Add Anoncoin adapter#18718
akhil-onjuno wants to merge 4 commits intoDefiLlama:mainfrom
akhil-onjuno:add-anoncoin

Conversation

@akhil-onjuno
Copy link
Copy Markdown

@akhil-onjuno akhil-onjuno commented Apr 10, 2026

Anoncoin (Solana)

Protocol: anoncoin.it
Category: Liquidity / Bonding Curve

What does the adapter do?

Calculates TVL by summing SOL held across all Anoncoin pool quote vaults on Solana — both DBC (Dynamic Bonding Curve) and DAMM v2 (migrated) pools.

How it works

  1. Fetches vault addresses from our paginated API (api.dubdub.tv/v1/defillama/tvl)
  2. Deduplicates using a Set
  3. Uses sumTokens2 helper to read on-chain SOL balances
  4. Caches vault list via getCache/setCache

Details

  • Chain: Solana
  • Pools: ~7,300 active pools with TVL > 0
  • Timetravel: false (current state only)
  • Dependencies: Uses the standard DefiLlama Solana helpers (sumTokens2, getCache, setCache, get, sleep)

Summary by CodeRabbit

  • New Features
    • Added Total Value Locked (TVL) tracking for Anoncoin on Solana.
    • Discovers and deduplicates Anoncoin pool vaults from a paginated external API, including migrated DAMM v2 pools.
    • Handles pagination with throttling and page limits for reliable data collection.
    • Aggregates SOL holdings across discovered vaults to compute TVL.
    • Exposes a Solana TVL endpoint with timetravel disabled and a documented methodology.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new Solana TVL adapter for Anoncoin that paginates a DefiLlama-compatible API to collect and deduplicate pool quote-vault addresses (preferring migrated dammV2QuoteVault), optionally caches the full list, and computes TVL by summing SOL in those vaults via sumTokens2.

Changes

Cohort / File(s) Summary
Anoncoin TVL Adapter
projects/anoncoin/index.js
New module adding fetchAllVaults() which paginates https://api.dubdub.tv/v1/defillama/tvl?page=... with a MAX_PAGES guard and sleep(200) between pages; for each pool picks dammV2QuoteVault when pool.isMigrated else quoteVault, deduplicates addresses into a Set, returns a fullFetchCompleted flag, caches anoncoin-vaults for solana when fully fetched, and exposes solana.tvl that calls sumTokens2({ solOwners }). Exports timetravel: false and a methodology string.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant Cache as Cache Layer
    participant Adapter as Anoncoin Adapter
    participant API as DubDub API
    participant Solana as Solana Chain

    Caller->>Adapter: tvl()
    Adapter->>Cache: getCache("anoncoin-vaults","solana")
    alt Cache hit & valid array
        Cache-->>Adapter: solOwners[]
    else Cache miss or invalid
        Adapter->>API: GET /v1/defillama/tvl?page=1
        loop while hasMore and page <= MAX_PAGES
            API-->>Adapter: pools[], hasMore
            Adapter->>Adapter: choose dammV2QuoteVault if migrated else quoteVault
            Adapter->>Adapter: add address to Set (dedupe)
            alt hasMore and page < MAX_PAGES
                Adapter->>Adapter: sleep(200)
                Adapter->>API: GET /v1/defillama/tvl?page=N+1
            else hasMore but page >= MAX_PAGES
                Adapter-->>Adapter: mark incomplete, stop
            end
        end
        Adapter->>Cache: setCache("anoncoin-vaults", solOwners, "solana") /* if fullFetchCompleted */
    end
    Adapter->>Solana: sumTokens2({ solOwners })
    Solana-->>Adapter: TVL
    Adapter-->>Caller: TVL
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through pages, found each vault's gate,
Picked the new burrow when migration said "wait",
Tossed duplicates out, cached the gathered crew,
Counted SOL in my paws, neat and true,
A joyful little hop — TVL, all through.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new Solana TVL adapter for the Anoncoin protocol.
Description check ✅ Passed The description provides comprehensive adapter details (protocol link, category, how it works, chain, pool count, timetravel setting, and dependencies) but omits most template fields for new listings like audit links, logo, coingecko/coinmarketcap IDs, and oracle provider information.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@projects/anoncoin/index.js`:
- Around line 36-41: The current cache usage with getCache(CACHE_KEY, "solana")
only refetches when empty, so new vaults are never discovered; modify the logic
around getCache/setCache (and the CACHE_KEY/solOwners flow) to respect a TTL:
when setting the cache via setCache(CACHE_KEY, "solana", solOwners) also store a
timestamp or expiration, and when calling getCache check that timestamp (or
returned meta) against a configured TTL (e.g., CACHE_TTL_MS) and force solOwners
= await fetchAllVaults() and update setCache when the cache is stale; ensure you
reference getCache, setCache, CACHE_KEY and fetchAllVaults so the refetch
happens both when cache is missing and when its age exceeds the TTL.
- Around line 14-30: The pagination while loop using hasMore and page can run
indefinitely; introduce a MAX_PAGES constant (e.g., MAX_PAGES = 1000) and
enforce it inside the loop that calls get(`${API_BASE}?page=${page}`) and sleep:
if page exceeds MAX_PAGES, break/throw or log an error and stop paging to fail
safely; update the loop around hasMore/page so functions like get, API_BASE,
sleep, and solOwnersSet remain unchanged but the loop exits when page >
MAX_PAGES (or similar) to prevent unbounded looping.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c620a1e-2365-406a-a328-5a20226e5e79

📥 Commits

Reviewing files that changed from the base of the PR and between 93edba3 and c377d96.

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

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.

♻️ Duplicate comments (1)
projects/anoncoin/index.js (1)

16-19: ⚠️ Potential issue | 🟠 Major

Avoid caching partial data when pagination cap is exceeded.

At Line 16 the code stops pagination with break, then Line 44-46 caches the partial solOwners list as fresh truth. If the API misbehaves, this silently undercounts TVL and persists the undercount in cache.

Suggested fix
-        if (page > MAX_PAGES) {
-            console.error(`anoncoin: exceeded MAX_PAGES (${MAX_PAGES}), stopping pagination`);
-            break;
-        }
+        if (page > MAX_PAGES) {
+            throw new Error(`anoncoin: exceeded MAX_PAGES (${MAX_PAGES})`);
+        }

Also applies to: 44-46

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@projects/anoncoin/index.js` around lines 16 - 19, The code currently breaks
out when page > MAX_PAGES but then proceeds to cache the partially-collected
solOwners; change the flow so partial results are never written to cache: add a
boolean flag (e.g., fullFetchCompleted) that is false by default, set it to true
only when the pagination loop completes normally (not when broken due to
MAX_PAGES), and wrap the existing cache write logic (the lines that persist
solOwners) so it only runs if fullFetchCompleted is true; alternatively, when
the MAX_PAGES cap is hit, throw or return an error/empty result instead of
allowing the caching path to run. Ensure references to solOwners, MAX_PAGES and
the cache write code are updated accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@projects/anoncoin/index.js`:
- Around line 16-19: The code currently breaks out when page > MAX_PAGES but
then proceeds to cache the partially-collected solOwners; change the flow so
partial results are never written to cache: add a boolean flag (e.g.,
fullFetchCompleted) that is false by default, set it to true only when the
pagination loop completes normally (not when broken due to MAX_PAGES), and wrap
the existing cache write logic (the lines that persist solOwners) so it only
runs if fullFetchCompleted is true; alternatively, when the MAX_PAGES cap is
hit, throw or return an error/empty result instead of allowing the caching path
to run. Ensure references to solOwners, MAX_PAGES and the cache write code are
updated accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eab7ec87-6c25-438f-88a9-fb7808e9c6ce

📥 Commits

Reviewing files that changed from the base of the PR and between db11541 and 8529e26.

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

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@projects/anoncoin/index.js`:
- Around line 16-20: The loop truncates pagination when page > MAX_PAGES but
then proceeds to use the partial solOwners list, which can undercount TVL;
modify the pagination/aggregation logic (around hasMore, page, MAX_PAGES) so
that when you hit the MAX_PAGES cutoff you set fullFetchCompleted = false (or a
similar flag) and do not use the partial solOwners for final TVL calculations;
instead attempt to load and use a cached full result (fallback to the partial
solOwners only if no cache is available), and ensure any code that consumes
solOwners checks fullFetchCompleted before relying on it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea91a0c7-f566-4984-8fc5-ad6d45ee4eb5

📥 Commits

Reviewing files that changed from the base of the PR and between 8529e26 and 95d3923.

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

Comment on lines +16 to +20
while (hasMore) {
if (page > MAX_PAGES) {
console.error(`anoncoin: exceeded MAX_PAGES (${MAX_PAGES}), stopping pagination`);
break;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid using partial owner lists when pagination is truncated.

Line 17 stops pagination with break, but Line 49 still uses partial solOwners. This can silently undercount TVL whenever MAX_PAGES is hit. Prefer cached full data when fullFetchCompleted is false (fallback to partial only if cache is unavailable).

Proposed fix
 async function tvl() {
     let solOwners;
     try {
-        const result = await fetchAllVaults();
-        solOwners = result.solOwners;
-        if (result.fullFetchCompleted) {
-            await setCache(CACHE_KEY, "solana", solOwners);
-        }
+        const result = await fetchAllVaults();
+        if (result.fullFetchCompleted) {
+            solOwners = result.solOwners;
+            await setCache(CACHE_KEY, "solana", solOwners);
+        } else {
+            const cached = await getCache(CACHE_KEY, "solana");
+            solOwners = Array.isArray(cached) && cached.length ? cached : result.solOwners;
+        }
     } catch (e) {
         console.error("anoncoin: API fetch failed, falling back to cache", e.message);
         const cached = await getCache(CACHE_KEY, "solana");
         solOwners = Array.isArray(cached) ? cached : [];
     }

     return sumTokens2({ solOwners });
 }

Also applies to: 47-51

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@projects/anoncoin/index.js` around lines 16 - 20, The loop truncates
pagination when page > MAX_PAGES but then proceeds to use the partial solOwners
list, which can undercount TVL; modify the pagination/aggregation logic (around
hasMore, page, MAX_PAGES) so that when you hit the MAX_PAGES cutoff you set
fullFetchCompleted = false (or a similar flag) and do not use the partial
solOwners for final TVL calculations; instead attempt to load and use a cached
full result (fallback to the partial solOwners only if no cache is available),
and ensure any code that consumes solOwners checks fullFetchCompleted before
relying on it.

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.

♻️ Duplicate comments (1)
projects/anoncoin/index.js (1)

13-17: ⚠️ Potential issue | 🟠 Major

Fail fast when pagination is truncated; current flow can silently undercount TVL.

At Line 16, hitting MAX_PAGES exits the loop but still returns partial solOwners (Line 36), and Line 40 then prices that partial set. This should error out (or use a known-complete fallback), not publish partial TVL.

Suggested fix
 async function fetchAllVaults() {
     const solOwnersSet = new Set();
     let page = 1;
     let hasMore = true;

-    while (hasMore) {
-        if (page > MAX_PAGES) {
-            console.error(`anoncoin: exceeded MAX_PAGES (${MAX_PAGES}), stopping pagination`);
-            break;
-        }
+    while (hasMore && page <= MAX_PAGES) {
         const { data } = await get(`${API_BASE}?page=${page}`);
         const pools = data.pools || [];
@@
         if (hasMore) await sleep(200);
     }

+    if (hasMore) {
+        throw new Error(`anoncoin: pagination exceeded MAX_PAGES (${MAX_PAGES})`);
+    }
+
     return { solOwners: [...solOwnersSet] };
 }

Also applies to: 36-41

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@projects/anoncoin/index.js` around lines 13 - 17, The loop that pages owner
data uses hasMore and breaks when page > MAX_PAGES, which allows the function to
continue and price a truncated solOwners set; change the behavior so hitting
MAX_PAGES signals failure instead of breaking: in the pagination loop
(referencing hasMore, MAX_PAGES and solOwners) replace the break with throwing
an Error (or returning a specific failure result) so the function does not
proceed to the pricing/TVL calculation on partial data; ensure any callers
handle the thrown error or failure result to avoid publishing partial TVL.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@projects/anoncoin/index.js`:
- Around line 13-17: The loop that pages owner data uses hasMore and breaks when
page > MAX_PAGES, which allows the function to continue and price a truncated
solOwners set; change the behavior so hitting MAX_PAGES signals failure instead
of breaking: in the pagination loop (referencing hasMore, MAX_PAGES and
solOwners) replace the break with throwing an Error (or returning a specific
failure result) so the function does not proceed to the pricing/TVL calculation
on partial data; ensure any callers handle the thrown error or failure result to
avoid publishing partial TVL.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69e4e0fb-03c0-4d61-96da-8db55196f978

📥 Commits

Reviewing files that changed from the base of the PR and between 95d3923 and 4433354.

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

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.

1 participant