Skip to content

active-users: add protocols via allium - #8533

Open
DaniiRix wants to merge 11 commits into
DefiLlama:masterfrom
DaniiRix:feat/active-users
Open

active-users: add protocols via allium#8533
DaniiRix wants to merge 11 commits into
DefiLlama:masterfrom
DaniiRix:feat/active-users

Conversation

@DaniiRix

@DaniiRix DaniiRix commented Aug 1, 2026

Copy link
Copy Markdown
Member

Adds dailyActiveUsers and dailyTransactionsCount for 111 protocols using Allium’s curated cross-chain tables, plus one Dune adapter for Compound V3.

What's added

Family Count Source
DEXs 84 crosschain.dex.trades
Lending 18 crosschain.lending.*
Lending (Dune) 1 lending.supply / lending.borrow
Hyperliquid 2 hyperliquid.dex.trades
Token-shaped 6 crosschain.assets.transfers

Methodology

  • DEXs: unique transaction_from_address; transactions = distinct transaction_hash.

  • Lending: unique addresses across deposits, withdrawals, borrows, and repayments. Liquidations excluded.

  • Hyperliquid: both maker and taker counted; HIP-3 third-party markets excluded.

  • Token-shaped: users identified via token minting and transfers to configured burn/exit addresses.

  • transaction_from_address is used instead of router/pool-oriented fields such as sender_address or depositor.

  • The existing Uniswap and PancakeSwap router-based active-user adapters are intentionally replaced by the Allium implementations for broader chain coverage.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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

Added shared Allium-based user metrics for DEX, lending, Hyperliquid, and token-transfer activity. Added protocol configurations and registered the adapters for active-user reporting. New-user reporting remains connected to the existing sources.

Changes

Allium user metrics exports

Layer / File(s) Summary
Allium user metrics helper
users/utils/alliumUsers.ts
Adds normalized, memoized Allium queries and adapters for DEX, lending, Hyperliquid, and token-transfer activity.
DEX and lending configurations
users/dexUsers.ts, users/lendingUsers.ts
Defines protocol identifiers, Allium projects, supported chains, and start dates.
Hyperliquid and token configurations
users/hyperliquidUsers.ts, users/tokenUsers.ts
Defines market-specific Hyperliquid datasets and Ethereum staking-token datasets.
Active-user registry integration
users/list.ts
Registers all four adapter sources for active-user reporting without adding them to the new-user registry.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ActiveUserProtocols
  participant AlliumUserAdapter
  participant Allium
  ActiveUserProtocols->>AlliumUserAdapter: request configured user metrics
  AlliumUserAdapter->>Allium: query grouped activity or transfers
  Allium-->>AlliumUserAdapter: return activity rows
  AlliumUserAdapter-->>ActiveUserProtocols: return wallet and transaction counts
Loading

Suggested labels: new-adapter

Suggested reviewers: bheluga

🚥 Pre-merge checks | ✅ 11 | ❌ 4

❌ Failed checks (4 warnings)

Check name Status Explanation Resolution
Version 2 Required ⚠️ Warning All new Allium user adapters are constructed by buildUsersAdapter, which explicitly returns version: 1; Allium supports range SQL queries, so the daily-only external API exception does not apply. Change buildUsersAdapter to return version: 2 for the new DEX, lending, Hyperliquid, and token adapters.
Adapter Shape ⚠️ Warning buildUsersAdapter always returns adapter: Object.fromEntries(...), even for shared-start arrays such as Hyperliquid and single-chain DEX entries; it does not use root chains plus one start. Return chains and start at the adapter root when all chains share one start. Keep the keyed adapter object only for differing starts, and use one chainConfig object for any per-chain identity.
Efficiency And Error Handling ⚠️ Warning The feature has no getLogs, raw topics, api.call loops, swallowed catches, or allowNegativeValue, but ZERO_ADDRESS and the cache limit 8 lack source or rationale comments. Add a comment that identifies ZERO_ADDRESS and explains the cache limit source or rationale; replace unexplained magic values such as SQL GROUP BY 1, 2 with named expressions.
Title check ⚠️ Warning The title describes the Allium active-user change but does not follow the required [type] protocol-name - description format. Rename the title to include a type, protocol name, and description separated by -.
✅ Passed checks (11 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 50.00% which is sufficient. The required threshold is 50.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Breakdown Methodology Check ✅ Passed The PR adds user-count adapters only; no fees adapters, dailyFees fields, or fee .add() calls appear in the added users modules.
Income Statement Compliance ✅ Passed The PR adds user-count adapters only; their fetches return dailyActiveUsers and dailyTransactionsCount, with no dailyFees, dailyRevenue, or dailySupplySideRevenue.
Pullhourly Required For Version 2 ✅ Passed The PR-added user adapters contain no version: 2 object; alliumUsers.ts and users/list.ts explicitly return version: 1, so the pullHourly requirement does not apply.
Dune Adapters Are Version 1 ✅ Passed The only PR-changed Dune adapter is four-meme, and it exports version: 1; its query uses explicit timestamps, not TIME_RANGE, and no per-chain Dune queries were added.
Income Statement Balance ✅ Passed The patch adds user-metric adapters and registrations only; it touches no fees files and contains no dailyFees or revenue metrics, so the fee balance check is not applicable.
Fetchoptions Usage ✅ Passed All PR-added fetch logic uses one FetchOptions parameter and startTimestamp/endTimestamp; no old 3-argument signature, raw time recomputation, unused fetch arguments, timestamp returns, or v2 start...
Methodology Keys ✅ Passed All new methodology objects use ActiveUsers and TransactionsCount, the canonical metric suffixes, and contain no code-field keys such as dailyActiveUsers or dailyTransactionsCount.
Description check ✅ Passed The description clearly summarizes the metrics, protocol families, data sources, and counting methodology; the listing template is not applicable.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 7

🤖 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.

Inline comments:
In `@active-users/pharaoh-exchange.ts`:
- Around line 6-9: Update the single-chain configuration in pharaoh-exchange by
replacing the chains object with the array form containing CHAIN.AVAX, while
retaining the existing top-level start date.

In `@helpers/alliumUsers.ts`:
- Around line 75-79: Add breakdownMethodology metadata to the returned adapter
alongside methodology, covering both exported dimensions ActiveUsers and
TransactionsCount. Use the repository’s exact display labels and preserve the
existing methodology entries.
- Line 16: Add JSDoc comments to the exported helpers alliumToLlamaChain and
alliumDexUsersExport. Document chain normalization, the accepted forms of the
chains input, and the behavior when chains includes CHAIN.CHAIN_GLOBAL, using
the existing exported types and symbols.
- Around line 19-21: Define a typed DexUserRow shape and replace every any usage
in this helper: type inflight as Record<string, Promise<DexUserRow>>, make
getDexUserRows return the corresponding typed promise/result, and type the
rows.find callback parameter as DexUserRow while preserving the existing
behavior.
- Around line 47-52: Update fetch around getDexUserRows so an empty successful
result returns zero dailyActiveUsers and dailyTransactionsCount instead of
throwing. Preserve propagation of actual query failures and retain the existing
missing-project fallback for non-empty results.
- Around line 35-36: Update the inflight cache handling around queryAllium so a
rejected promise is removed from inflight[query] before the rejection
propagates. Keep successful promises cached for reuse, and ensure cleanup only
removes the entry associated with the failed request so a newer retry is not
deleted.
- Around line 69-73: Update the adapter metadata returned by the Allium users
adapter to use version 2 and set pullHourly to true, while preserving the
existing fetch and adapter chain configuration.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d81de35f-269e-47f9-a4e0-a678cc7bbe12

📥 Commits

Reviewing files that changed from the base of the PR and between 0958caf and 19d598f.

📒 Files selected for processing (19)
  • active-users/alphaq.ts
  • active-users/aquifer.ts
  • active-users/bisonfi.ts
  • active-users/curve-dex.ts
  • active-users/fluid-dex.ts
  • active-users/goonfi.ts
  • active-users/humidifi.ts
  • active-users/manifest-trade.ts
  • active-users/meteora.ts
  • active-users/orca-dex.ts
  • active-users/pharaoh-exchange.ts
  • active-users/project-x.ts
  • active-users/pumpswap.ts
  • active-users/raydium-amm.ts
  • active-users/scorch.ts
  • active-users/solfi.ts
  • active-users/sun.ts
  • active-users/tessera-v.ts
  • helpers/alliumUsers.ts

Comment thread active-users/pharaoh-exchange.ts Outdated
manta_pacific: CHAIN.MANTA,
};

export const alliumToLlamaChain = (chain: string) => ALLIUM_TO_LLAMA[chain] ?? chain;

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add JSDoc to the exported helper API.

alliumToLlamaChain and alliumDexUsersExport are public exports. Document the chain normalization, the accepted chains forms, and the CHAIN.CHAIN_GLOBAL behavior.

As per path instructions, public helper functions must include JSDoc comments.

Also applies to: 42-46

🤖 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 `@helpers/alliumUsers.ts` at line 16, Add JSDoc comments to the exported
helpers alliumToLlamaChain and alliumDexUsersExport. Document chain
normalization, the accepted forms of the chains input, and the behavior when
chains includes CHAIN.CHAIN_GLOBAL, using the existing exported types and
symbols.

Source: Path instructions

Comment thread helpers/alliumUsers.ts Outdated
Comment thread helpers/alliumUsers.ts Outdated
Comment thread users/utils/alliumUsers.ts
Comment thread users/utils/alliumUsers.ts
Comment thread users/utils/alliumUsers.ts Outdated
Comment on lines +75 to +79
methodology: {
ActiveUsers: "Unique wallets that swapped on the protocol that day. Counted per chain, plus an all-chains total that counts a wallet trading on several chains only once.",
TransactionsCount: "Number of transactions containing at least one swap on the protocol.",
},
};

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add breakdownMethodology metadata.

The returned adapter defines methodology but omits breakdownMethodology. Add entries for both exported dimensions using the repository's exact display labels.

As per coding guidelines, every export must include both methodology and breakdownMethodology.

🤖 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 `@helpers/alliumUsers.ts` around lines 75 - 79, Add breakdownMethodology
metadata to the returned adapter alongside methodology, covering both exported
dimensions ActiveUsers and TransactionsCount. Use the repository’s exact display
labels and preserve the existing methodology entries.

Source: Coding guidelines

@bheluga bheluga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@DaniiRix good to move into users/utils instead of standalone files?

@bheluga bheluga self-assigned this Aug 1, 2026
@DaniiRix

DaniiRix commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

@DaniiRix good to move into users/utils instead of standalone files?

yeah makes more sense, thanks

@coderabbitai coderabbitai Bot removed the helper label Aug 1, 2026
@coderabbitai coderabbitai Bot removed the new-adapter label Aug 2, 2026
@DaniiRix DaniiRix changed the title active-users: add 18 dex protocols via allium active-users: add 18 dex and 18 lending protocols via allium Aug 2, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@users/utils/alliumUsers.ts`:
- Around line 25-35: Bound the successful-query cache in runOnce so resolved
entries in inflight are evicted after the relevant batch completes, or replace
it with an equivalent bounded cache. Preserve the existing catch handler that
deletes failed requests immediately, and ensure repeated calls still share an
in-flight query while it remains cached.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0bf7bba6-0a5b-45c1-852a-a883221d5502

📥 Commits

Reviewing files that changed from the base of the PR and between b4d27e1 and 64a98f5.

📒 Files selected for processing (3)
  • users/lendingUsers.ts
  • users/list.ts
  • users/utils/alliumUsers.ts

Comment thread users/utils/alliumUsers.ts Outdated
@DaniiRix
DaniiRix requested a review from bheluga August 2, 2026 06:10

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@users/utils/alliumUsers.ts`:
- Around line 39-47: Update the inflight caching logic around queryAllium so
pending promises remain in a separate non-evictable map, while
MAX_CACHED_WINDOWS eviction applies only to settled results. Ensure
failed-request cleanup cannot delete a newer promise for the same query key, and
add coverage using more than eight deferred queries followed by a late failure.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b0efa9a8-433c-431f-b2a9-0b09d1f804c3

📥 Commits

Reviewing files that changed from the base of the PR and between 64a98f5 and 953a042.

📒 Files selected for processing (1)
  • users/utils/alliumUsers.ts

Comment on lines +39 to +47
const run = queryAllium(query).catch((e: any) => {
inflight.delete(query);
throw e;
});
inflight.set(query, run);

while (inflight.size > MAX_CACHED_WINDOWS) {
inflight.delete(inflight.keys().next().value as string);
}

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Do not evict pending queries from inflight.

inflight stores both pending and completed promises. The eviction loop can remove a pending query. A later adapter can then start a second queryAllium call for the same window. If the first call fails, its cleanup can delete the newer promise because cleanup uses only the query key.

Keep pending promises in a separate non-evictable map. Apply MAX_CACHED_WINDOWS only to settled results. Add a test with more than eight deferred queries and a late failure.

🤖 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 `@users/utils/alliumUsers.ts` around lines 39 - 47, Update the inflight caching
logic around queryAllium so pending promises remain in a separate non-evictable
map, while MAX_CACHED_WINDOWS eviction applies only to settled results. Ensure
failed-request cleanup cannot delete a newer promise for the same query key, and
add coverage using more than eight deferred queries followed by a late failure.

@DaniiRix DaniiRix changed the title active-users: add 18 dex and 18 lending protocols via allium active-users: add protocols via allium Aug 2, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@users/utils/alliumUsers.ts`:
- Around line 145-160: Update the query construction around tokenConfigs and the
WHERE clause so exit-address checks preserve each configuration’s token-to-exit
mapping. Generate per-token conditions that require LOWER(token_address) to
match the token and LOWER(to_address) to match one of that token’s
exitAddresses, while keeping the zero-address from_address mint condition
separate.
- Around line 165-170: Update alliumTokenUsersExport to use the shared-chain
adapter form by changing the chain-keyed chains object to an array containing
config.chain, while retaining the existing single start: config.start value.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1b1e4a9f-c92b-4006-ae2e-cec84b9e3079

📥 Commits

Reviewing files that changed from the base of the PR and between 953a042 and 8e1452f.

📒 Files selected for processing (4)
  • users/hyperliquidUsers.ts
  • users/list.ts
  • users/tokenUsers.ts
  • users/utils/alliumUsers.ts

Comment thread users/utils/alliumUsers.ts
Comment on lines +165 to +170
export function alliumTokenUsersExport(config: TokenUsersConfig): SimpleAdapter {
tokenConfigs.push(config);
return buildUsersAdapter({
project: config.token.toLowerCase(),
chains: { [config.chain]: config.start },
start: config.start,

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use the shared-chain adapter form.

Each token adapter has one chain and one shared start. Replace the chain-keyed object with chains: [config.chain]. The current object form is reserved for adapters with different chain starts.

Proposed change
-    chains: { [config.chain]: config.start },
+    chains: [config.chain],

As per coding guidelines, use a shared chains array and single start when all chains share the same start.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function alliumTokenUsersExport(config: TokenUsersConfig): SimpleAdapter {
tokenConfigs.push(config);
return buildUsersAdapter({
project: config.token.toLowerCase(),
chains: { [config.chain]: config.start },
start: config.start,
export function alliumTokenUsersExport(config: TokenUsersConfig): SimpleAdapter {
tokenConfigs.push(config);
return buildUsersAdapter({
project: config.token.toLowerCase(),
chains: [config.chain],
start: config.start,
🤖 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 `@users/utils/alliumUsers.ts` around lines 165 - 170, Update
alliumTokenUsersExport to use the shared-chain adapter form by changing the
chain-keyed chains object to an array containing config.chain, while retaining
the existing single start: config.start value.

Source: Coding guidelines

@DaniiRix
DaniiRix marked this pull request as draft August 3, 2026 08:25
@DaniiRix
DaniiRix marked this pull request as ready for review August 3, 2026 16:38
Comment thread users/tokenUsers.ts
chain: CHAIN.ETHEREUM,
token: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", // stETH
// The protocol burns stETH on finalisation, so the exit is the queue transfer.
exitAddresses: ["0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1"], // unstETH withdrawal queue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm, this excludes stake, wrap and unwraps?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

wrap/unwrap is neither entry nor exit so i deliberately excluded them

Comment thread users/alliumUsers.ts
Comment thread users/utils/alliumUsers.ts Outdated
@DaniiRix
DaniiRix requested a review from bheluga August 6, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants