Skip to content

Add brain.fun (Bittensor EVM launchpad) #18710

Open
brain-fun wants to merge 4 commits intoDefiLlama:mainfrom
brain-fun:main
Open

Add brain.fun (Bittensor EVM launchpad) #18710
brain-fun wants to merge 4 commits intoDefiLlama:mainfrom
brain-fun:main

Conversation

@brain-fun
Copy link
Copy Markdown

@brain-fun brain-fun commented Apr 9, 2026

NOTE

Please enable "Allow edits by maintainers" while putting up the PR.


New listing — brain.fun

Name (to be shown on DefiLlama):

brain.fun

Twitter Link:

https://x.com/braintao

List of audit links if any:

https://github.com/Bitsec-AI/audit-reports (Bitsec audit — report will be published in this repository)

Website Link:

https://brain.fun

Logo (High resolution, will be shown with rounded borders):

https://brain.fun/logo.png

Current TVL:

~$24,400 (≈ 73 TAO locked in bonding curves across V1 + V2 factories at the time of writing)

Treasury Addresses (if the protocol has treasury):

N/A — brain.fun does not hold a treasury. Trading fees accrue inside each Factory contract under a pull-pattern balance and are claimed by token creators / protocol owner directly.

Chain:

Bittensor EVM (chain id 964) — bittensor_evm on DefiLlama

Coingecko ID:

N/A — brain.fun has no project token listed on Coingecko.

Coinmarketcap ID:

N/A — brain.fun has no project token listed on Coinmarketcap.

Short Description (to be shown on DefiLlama):

Token launchpad on Bittensor EVM. Anyone can deploy an ERC-20 with a built-in constant-product bonding curve AMM in a single transaction; tokens are tradable from block one against the curve, with no external liquidity pool needed.

Token address and ticker if any:

N/A — brain.fun has no native protocol token. Only user-launched tokens exist on the platform.

Category:

Launchpad

Oracle Provider(s):

None — brain.fun uses no external oracle. Pricing is fully on-chain via the constant-product bonding curve (x * y = k with a virtual TAO reserve).

Implementation Details:

N/A — no oracle integration. All prices are derived from the AMM state of each Token contract (getPrice()), which is a pure function of realTaoReserve + virtualReserve and tokenReserve.

Documentation/Proof:
forkedFrom:

N/A — original implementation. brain.fun is not a fork of another protocol.

methodology (what is being counted as tvl, how is tvl being calculated):

TVL is the sum of realTaoReserve (native TAO locked in the bonding curve) across every Token deployed by both brain.fun factories (V1 + V2) on Bittensor EVM.

For each factory the adapter:

  1. Reads getTokenCount() to learn how many tokens have been deployed.
  2. Resolves every token address via getToken(tokenId) for tokenId ∈ [1, count].
  3. Reads realTaoReserve() from each token contract.
  4. Sums all reserves and reports them as the native gas token (TAO).

This count represents the actual native TAO locked inside the bonding curve contracts and excludes the virtual reserve, so users see only the real, withdrawable liquidity.

Github org/user:

https://github.com/brain-fun

Does this project have a referral program?

No.

Summary by CodeRabbit

  • New Features
    • Added TVL tracking for the Brain Fun protocol on EVM networks.
    • Automated aggregation and batch retrieval of token reserves to compute TVL.
    • Included methodology text and an initial historical start timestamp for analytics.

brain.fun is a token launchpad on Bittensor EVM (chain 964) that uses
constant-product bonding curves with native TAO. Each token contract
holds the locked TAO in realTaoReserve. TVL = sum of all realTaoReserve
across tokens deployed by the factory.

Factory: 0xBa270A620cafAA69a97AbcC4d83C850297ca05B2
Website: https://brain.fun
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 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: 16f88730-0d2a-492f-bc45-581ed0f321db

📥 Commits

Reviewing files that changed from the base of the PR and between d608ab5 and 1f46ab8.

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

📝 Walkthrough

Walkthrough

Adds a new Brain-Fun TVL module that queries two factory contracts (V1 and V2) for token counts, batch-resolves token addresses and their realTaoReserve() values, and aggregates protocol TVL by adding each reserve as native TAO via the provided API.

Changes

Cohort / File(s) Summary
New TVL Module
projects/brain-fun/index.js
Adds tvl(api) async function: parallel getTokenCount() calls to two factories, constructs batch getToken(uint256) calls for each token ID, resolves token addresses, batch-reads realTaoReserve() with permitFailure: true, aggregates non-null reserves via api.addGasToken. Exports methodology, start (1774915200), and bittensor_evm config.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as TVL Caller
    participant API as Adapter API
    participant Factory as Factory Contracts (V1 & V2)
    participant Tokens as Token Contracts
    participant Agg as TVL Aggregator

    Caller->>API: tvl(api)
    API->>Factory: getTokenCount() [parallel]
    Factory-->>API: tokenCount V1, tokenCount V2
    API->>API: build batch getToken(tokenId) list
    alt tokens exist
        API->>Factory: getToken(tokenId...) [batch]
        Factory-->>API: tokenAddresses[]
        API->>Tokens: realTaoReserve() [batch, permitFailure:true]
        Tokens-->>API: reserves[] (some may be null)
        loop aggregate non-null
            API->>Agg: addGasToken(reserve)
        end
        API-->>Caller: return aggregated TVL
    else no tokens
        API-->>Caller: return early (no tokens)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I counted the tokens at two little gates,

Brought back their TAO from curious crates,
Batched all the calls, skipped the null calls too,
A rabbit hops off with the TVL in view — woo! ✨

🚥 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 clearly and concisely summarizes the main change: adding a brain.fun adapter for Bittensor EVM launchpad, which matches the changeset and PR objectives.
Description check ✅ Passed The PR description comprehensively fills all required template sections with detailed, relevant information about brain.fun, including name, links, TVL, methodology, chain details, and implementation 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: 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/brain-fun/index.js`:
- Line 45: The timestamp assigned to the start field (start: 1742832000) does
not match the commented date; update the start value to the correct Unix
timestamp for March 31, 2026 (use 1774915200) or change the inline comment to
reflect the actual date for the existing value; locate the start field in
projects/brain-fun/index.js (the start: 1742832000 entry) and make the
timestamp/comment consistent.
🪄 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: 81e0eb88-e800-4c95-a5f4-211ae3f2fcd9

📥 Commits

Reviewing files that changed from the base of the PR and between ecb3b3e and b93e44d.

📒 Files selected for processing (1)
  • projects/brain-fun/index.js

@brain-fun
Copy link
Copy Markdown
Author

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/brain-fun/index.js`:
- Line 45: The timestamp assigned to the start field (start: 1742832000) does
not match the commented date; update the start value to the correct Unix
timestamp for March 31, 2026 (use 1774915200) or change the inline comment to
reflect the actual date for the existing value; locate the start field in
projects/brain-fun/index.js (the start: 1742832000 entry) and make the
timestamp/comment consistent.

🪄 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

Good catch — fixed in 1774915200, start of day for the first deploy

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 (1)
projects/brain-fun/index.js (1)

31-34: Add permitFailure: true and filter nulls to prevent single-token failures from breaking TVL collection.

If any token's realTaoReserve() call reverts, the entire multiCall fails and TVL collection fails for the whole protocol. Using permitFailure: true allows partial success, with failed calls returning null in the result array.

Proposed fix
 const reserves = await api.multiCall({
   abi: "function realTaoReserve() view returns (uint256)",
   calls: tokenAddresses,
+  permitFailure: true,
 });
 
 // Sum all reserves as native gas token (TAO)
 reserves.forEach((reserve) => {
-  api.addGasToken(reserve);
+  if (reserve) api.addGasToken(reserve);
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@projects/brain-fun/index.js` around lines 31 - 34, The multiCall to fetch
reserves using api.multiCall currently fails entirely if any token's
realTaoReserve() reverts; update the api.multiCall call for reserves to include
permitFailure: true so partial results return null for failed calls, then after
the call filter out null entries from the reserves array (or map nulls to zero)
before using them with tokenAddresses to compute TVL; target the reserves
variable, the api.multiCall invocation, and the realTaoReserve() results when
implementing this change.
🤖 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/brain-fun/index.js`:
- Around line 31-34: The multiCall to fetch reserves using api.multiCall
currently fails entirely if any token's realTaoReserve() reverts; update the
api.multiCall call for reserves to include permitFailure: true so partial
results return null for failed calls, then after the call filter out null
entries from the reserves array (or map nulls to zero) before using them with
tokenAddresses to compute TVL; target the reserves variable, the api.multiCall
invocation, and the realTaoReserve() results when implementing this change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4b0c192-474d-4689-969c-271b2af5080a

📥 Commits

Reviewing files that changed from the base of the PR and between b93e44d and d608ab5.

📒 Files selected for processing (1)
  • projects/brain-fun/index.js

@brain-fun
Copy link
Copy Markdown
Author

🧹 Nitpick comments (1)

projects/brain-fun/index.js (1)> 31-34: Add permitFailure: true and filter nulls to prevent single-token failures from breaking TVL collection.

If any token's realTaoReserve() call reverts, the entire multiCall fails and TVL collection fails for the whole protocol. Using permitFailure: true allows partial success, with failed calls returning null in the result array.

Proposed fix

 const reserves = await api.multiCall({
   abi: "function realTaoReserve() view returns (uint256)",
   calls: tokenAddresses,
+  permitFailure: true,
 });
 
 // Sum all reserves as native gas token (TAO)
 reserves.forEach((reserve) => {
-  api.addGasToken(reserve);
+  if (reserve) api.addGasToken(reserve);
 });

🤖 Prompt for AI Agents

Verify each finding against the current code and only fix it if needed.

In `@projects/brain-fun/index.js` around lines 31 - 34, The multiCall to fetch
reserves using api.multiCall currently fails entirely if any token's
realTaoReserve() reverts; update the api.multiCall call for reserves to include
permitFailure: true so partial results return null for failed calls, then after
the call filter out null entries from the reserves array (or map nulls to zero)
before using them with tokenAddresses to compute TVL; target the reserves
variable, the api.multiCall invocation, and the realTaoReserve() results when
implementing this change.

🤖 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/brain-fun/index.js`:
- Around line 31-34: The multiCall to fetch reserves using api.multiCall
currently fails entirely if any token's realTaoReserve() reverts; update the
api.multiCall call for reserves to include permitFailure: true so partial
results return null for failed calls, then after the call filter out null
entries from the reserves array (or map nulls to zero) before using them with
tokenAddresses to compute TVL; target the reserves variable, the api.multiCall
invocation, and the realTaoReserve() results when implementing this change.

Done — added permitFailure: true and a null guard before addGasToken.

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