Skip to content

Add GLORB token price via Uniswap V4 StateView (Base)#11347

Closed
glorbwtf wants to merge 1 commit intoDefiLlama:masterfrom
glorbwtf:add-glorb-token-price
Closed

Add GLORB token price via Uniswap V4 StateView (Base)#11347
glorbwtf wants to merge 1 commit intoDefiLlama:masterfrom
glorbwtf:add-glorb-token-price

Conversation

@glorbwtf
Copy link
Copy Markdown

@glorbwtf glorbwtf commented Feb 8, 2026

Summary

  • Adds a price adapter for the GLORB token on Base
  • Reads price from the Uniswap V4 GLORB/WETH pool via the StateView contract
  • Uses getSlot0(poolId) to get the current tick, then derives price via 1.0001^tick

Details

Item Value
Token GLORB (0xa26303226Baa2299adA8D573a6FcD792aB1CFB07)
Chain Base
Pool Uniswap V4 GLORB/WETH
Pool ID 0x3dbf9db7ebb1e81fc0f1ddb24ad492acfc778b2ff8eb0d373176a9583b6746cd
StateView 0xa3c0c9b65bad0b08107aa264b0f3db444b867a71
Current Price ~$0.00000026
Pool Liquidity ~$25k

Verification

Tested the RPC call locally — tick 228250 yields GLORB price of 1.22e-10 WETH, which at $2,128/ETH = $0.00000026, matching GeckoTerminal and DexScreener.

Related

Summary by CodeRabbit

Release Notes

  • New Features
    • Added GLORB token price tracking with real-time data sourced from the Base chain GLORB/WETH liquidity pool

Reads sqrtPriceX96 from Uniswap V4 StateView contract to derive
GLORB/WETH price from the GLORB/WETH pool on Base.

- Pool ID: 0x3dbf9db7...6746cd
- StateView: 0xa3c0c9b6...7a71
- Price derived from tick via 1.0001^tick formula
- Both tokens are 18 decimals, no decimal adjustment needed

Verified: output matches DexScreener/GeckoTerminal ($0.00000026)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

A new GLORB adapter is introduced that queries a GLORB/WETH pool on Base blockchain, retrieves the current tick, computes the GLORB price relative to WETH, and returns the price data. The adapter is then integrated into the adapters map for export.

Changes

Cohort / File(s) Summary
New GLORB Adapter
coins/src/adapters/other/glorb.ts
New adapter module that queries a Uniswap V4-like GLORB/WETH pool on Base, retrieves the tick via getSlot0 ABI call, computes GLORB price in WETH using the formula 1.0001^(-tick), and returns aggregated price data.
Adapter Registry Update
coins/src/adapters/other/index.ts
Imports the new GLORB adapter and registers it in the public adapters map.

Sequence Diagram

sequenceDiagram
    participant Client
    participant GLORB Adapter
    participant Base Chain
    participant GLORB/WETH Pool

    Client->>GLORB Adapter: glorb(timestamp)
    GLORB Adapter->>GLORB Adapter: Construct getSlot0 ABI
    GLORB Adapter->>Base Chain: Query pool state
    Base Chain->>GLORB/WETH Pool: getSlot0()
    GLORB/WETH Pool-->>Base Chain: Return slot0 data (tick)
    Base Chain-->>GLORB Adapter: Receive tick
    GLORB Adapter->>GLORB Adapter: Compute price = 1/1.0001^tick
    GLORB Adapter->>GLORB Adapter: Build pricesObject {glorb: {underlying, price}}
    GLORB Adapter-->>Client: Return writes array with results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A new token hops into place,
GLORB dances on Base's space,
Tick by tick, the price takes flight,
WETH and GLORB now paired just right! ✨

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add GLORB token price via Uniswap V4 StateView (Base)' directly and accurately describes the main change: adding a price adapter for the GLORB token that fetches data from a Uniswap V4 pool on the Base network.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
coins/src/adapters/other/glorb.ts (1)

31-35: Consider using sqrtPriceX96 for higher precision.

getSlot0 already returns sqrtPriceX96. Deriving price from it ((sqrtPriceX96 / 2^96)^2) avoids floating-point drift inherent in Math.pow(1.0001, tick) for large tick values. For tick ~228250 the error is negligible, but using sqrtPriceX96 is the more robust approach.

♻️ Proposed refactor using sqrtPriceX96
-  const tick = Number(slot0.tick);
-  // Both WETH and GLORB are 18 decimals, so decimal adjustment = 0
-  // tick gives price of token1 in token0 terms: GLORB_per_WETH = 1.0001^tick
-  // GLORB price in WETH = 1 / (1.0001^tick)
-  const glorbPriceInWeth = 1 / Math.pow(1.0001, tick);
+  const sqrtPriceX96 = BigInt(slot0.sqrtPriceX96);
+  // sqrtPriceX96 encodes sqrt(token1/token0) * 2^96
+  // price(token1/token0) = (sqrtPriceX96 / 2^96)^2
+  // GLORB price in WETH = 1 / price(token1/token0)
+  const Q96 = 2n ** 96n;
+  const priceNum = Number(sqrtPriceX96 * sqrtPriceX96) / Number(Q96 * Q96);
+  const glorbPriceInWeth = 1 / priceNum;

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.

@waynebruce0x
Copy link
Copy Markdown
Collaborator

There isnt enough liquidity for us to price GLORB using this pool

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