Skip to content

Add Surge Credit lending yields adapter - #2859

Open
punithbm wants to merge 7 commits into
DefiLlama:masterfrom
punithbm:surge-credit-yields
Open

Add Surge Credit lending yields adapter#2859
punithbm wants to merge 7 commits into
DefiLlama:masterfrom
punithbm:surge-credit-yields

Conversation

@punithbm

@punithbm punithbm commented Jul 30, 2026

Copy link
Copy Markdown

Adds a yields adapter for Surge Credit, a BTC-collateralized USDC lending protocol on Base.

The protocol is already listed (DefiLlama-Adapters TVL PR is merged and live at https://defillama.com/protocol/surge-credit).

  • Slug: surge-credit
  • protocolId: 8328
  • Chain: Base (8453)
  • Adapter: src/adaptors/surge-credit/index.js (single new file)

Pools

One pool per on-chain market on the LiquidityPool contract 0xEE755F1BbcbF6e3260469D0f473522d71d3bdDda:

  • Market 0: variable rate (adaptive)
  • Market 1: fixed rate

How the numbers are computed

Everything is read live on-chain from the pool contract via @defillama/sdk (no external API or fetch, no hardcoded rates):

  • apyBase (lender supply APY) = borrowRate * utilization * (1 - reserveRate), then annualized as e^r - 1 because the pool accrues interest with continuous compounding (ExpMath.wCompoundFactor).
  • apyBaseBorrow = the current borrow rate from getMarketBorrowRate.
  • reserveRate is read live per market from markets(id).reserveRateBps (currently 20% on both), so the supply APY stays correct if it changes.
  • totalSupplyUsd and totalBorrowUsd come from the market struct.
  • tvlUsd = available liquidity (supplied minus borrowed), from getAvailableLiquidity.
  • ltv = maxLtvBps.

USDC is the only underlying, priced at ~$1.

Expected low tvlUsd

The two markets currently run at 97 to 100 percent utilization, so available liquidity (tvlUsd) is small right now (market 0 about $7k, market 1 about $1). The test prints the standard "pools with <10k TVL won't be shown" notice. This is expected: tvlUsd is the correct lending value (supplied minus borrowed), not gross supply. The pools store fine and become visible once available liquidity rises above the threshold. totalSupplyUsd (about $261k and $108k) and the APYs are stored regardless.

Testing

npm run test --adapter=surge-credit passes all 27 checks against live Base mainnet.

Only one file is added. No changes to package.json, lockfiles, or any other adapter. "Allow edits by maintainers" is enabled.

Summary by CodeRabbit

  • New Features
    • Added support for tracking Surge Credit lending markets on Base.
    • Displays supply and borrow APYs, utilization, TVL, available borrow, loan-to-value data, and market details.
    • Provides market-specific links and protocol information.
  • Bug Fixes
    • Excludes inactive or unavailable markets from results.
    • Improved APY calculations for supply and borrowing.
    • Refined TVL and available-borrow calculations based on idle supplied liquidity.

@coderabbitai

coderabbitai Bot commented Jul 30, 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 827d6d6a-1ae2-4f35-b8e8-63248c011d0e

📥 Commits

Reviewing files that changed from the base of the PR and between 6dcf500 and adc96a7.

📒 Files selected for processing (1)
  • src/adaptors/surge-credit/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/adaptors/surge-credit/index.js

📝 Walkthrough

Walkthrough

Adds a Base-chain Surge Credit adapter. It discovers active markets, calculates supply and borrow APYs, derives liquidity metrics, creates one pool per market, and exposes protocol metadata and market-specific URLs.

Changes

Surge Credit adapter

Layer / File(s) Summary
Market discovery and metric calculations
src/adaptors/surge-credit/index.js
Configures Base contracts and read-only ABIs. Reads active markets, metadata, borrow rates, and utilization. Calculates reserve-adjusted supply APY, borrow APY, TVL, available borrow, and market pool records.
Adapter entry point and failure handling
src/adaptors/surge-credit/index.js
Skips markets whose reads or calculations fail. Returns the collected pools and exposes the markets URL, protocol ID, and disabled time travel metadata.

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

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the addition of the Surge Credit lending yields adapter.
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.
✨ 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.

@github-actions

Copy link
Copy Markdown

The surge-credit adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 27 passed, 27 total
Snapshots: 0 total
Time: 0.296 s
Ran all test suites.

Nb of pools: 2
 

Sample pools:
┌─────────┬───────────────────────┬────────┬────────────────┬────────┬─────────────┬────────────────────┬───────────┬───────────────┬────────────────┬────────────────┬────────────────────┬─────┬────────────┬──────────────────────────────────────────────────┬──────────────────────┬────────────────────────┐
│ (index) │ pool                  │ chain  │ project        │ symbol │ tvlUsd      │ apyBase            │ apyReward │ apyBaseBorrow │ totalSupplyUsd │ totalBorrowUsd │ availableBorrowUsd │ ltv │ borrowable │ underlyingTokens                                 │ poolMeta             │ url                    │
├─────────┼───────────────────────┼────────┼────────────────┼────────┼─────────────┼────────────────────┼───────────┼───────────────┼────────────────┼────────────────┼────────────────────┼─────┼────────────┼──────────────────────────────────────────────────┼──────────────────────┼────────────────────────┤
│ 0       │ 'surge-credit-0-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 7274.431097 │ 15.025355421652087 │ null      │ 18            │ 260983.945688  │ 253709.514591  │ 7274.431097        │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Market 0, variable' │ 'https://surge.credit' │
│ 1       │ 'surge-credit-1-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 1.049533    │ 8.241221184159242  │ null      │ 9.9           │ 107986.117939  │ 107985.495479  │ 1.049533           │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Market 1, fixed'    │ 'https://surge.credit' │
└─────────┴───────────────────────┴────────┴────────────────┴────────┴─────────────┴────────────────────┴───────────┴───────────────┴────────────────┴────────────────┴────────────────────┴─────┴────────────┴──────────────────────────────────────────────────┴──────────────────────┴────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@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 `@src/adaptors/surge-credit/index.js`:
- Line 58: Update the TVL assignment in the Surge credit adaptor to use net
supplied assets, calculating totalSupplyUsd minus totalBorrowUsd instead of
availableBorrowUsd. Keep availableBorrowUsd exposed separately for idle
liquidity reporting.
- Line 61: Update the `apyBaseBorrow` calculation in the market-rate mapping to
convert the annual borrow APR returned by `getMarketBorrowRate()` into APY,
matching the supply APY convention; do not expose the raw `borrowRateBps / 100`
APR 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 54d13a17-f1e3-4de5-a68f-a8ff8eada64a

📥 Commits

Reviewing files that changed from the base of the PR and between 6e1f6b8 and 6755b3d.

📒 Files selected for processing (1)
  • src/adaptors/surge-credit/index.js

Comment thread src/adaptors/surge-credit/index.js Outdated
Comment thread src/adaptors/surge-credit/index.js Outdated
@github-actions

Copy link
Copy Markdown

The surge-credit adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 27 passed, 27 total
Snapshots: 0 total
Time: 0.226 s
Ran all test suites.

Nb of pools: 2
 

Sample pools:
┌─────────┬───────────────────────┬────────┬────────────────┬────────┬─────────────┬────────────────────┬───────────┬───────────────┬────────────────┬────────────────┬────────────────────┬─────┬────────────┬──────────────────────────────────────────────────┬───────────────────┬────────────────────────┐
│ (index) │ pool                  │ chain  │ project        │ symbol │ tvlUsd      │ apyBase            │ apyReward │ apyBaseBorrow │ totalSupplyUsd │ totalBorrowUsd │ availableBorrowUsd │ ltv │ borrowable │ underlyingTokens                                 │ poolMeta          │ url                    │
├─────────┼───────────────────────┼────────┼────────────────┼────────┼─────────────┼────────────────────┼───────────┼───────────────┼────────────────┼────────────────┼────────────────────┼─────┼────────────┼──────────────────────────────────────────────────┼───────────────────┼────────────────────────┤
│ 0       │ 'surge-credit-0-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 7274.431097 │ 15.025355421652087 │ null      │ 18            │ 260983.945688  │ 253709.514591  │ 7274.431097        │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Variable Market' │ 'https://surge.credit' │
│ 1       │ 'surge-credit-1-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 1.049533    │ 8.241221184159242  │ null      │ 9.9           │ 107986.117939  │ 107985.495479  │ 1.049533           │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Fixed Market'    │ 'https://surge.credit' │
└─────────┴───────────────────────┴────────┴────────────────┴────────┴─────────────┴────────────────────┴───────────┴───────────────┴────────────────┴────────────────┴────────────────────┴─────┴────────────┴──────────────────────────────────────────────────┴───────────────────┴────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@github-actions

Copy link
Copy Markdown

The surge-credit adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 27 passed, 27 total
Snapshots: 0 total
Time: 0.219 s
Ran all test suites.

Nb of pools: 2
 

Sample pools:
┌─────────┬───────────────────────┬────────┬────────────────┬────────┬────────────────────┬────────────────────┬───────────┬────────────────────┬────────────────┬────────────────┬────────────────────┬─────┬────────────┬──────────────────────────────────────────────────┬───────────────────┬────────────────────────┐
│ (index) │ pool                  │ chain  │ project        │ symbol │ tvlUsd             │ apyBase            │ apyReward │ apyBaseBorrow      │ totalSupplyUsd │ totalBorrowUsd │ availableBorrowUsd │ ltv │ borrowable │ underlyingTokens                                 │ poolMeta          │ url                    │
├─────────┼───────────────────────┼────────┼────────────────┼────────┼────────────────────┼────────────────────┼───────────┼────────────────────┼────────────────┼────────────────┼────────────────────┼─────┼────────────┼──────────────────────────────────────────────────┼───────────────────┼────────────────────────┤
│ 0       │ 'surge-credit-0-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 7274.431096999993  │ 15.025355421652087 │ null      │ 19.721736312181015 │ 260983.945688  │ 253709.514591  │ 7274.431097        │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Variable Market' │ 'https://surge.credit' │
│ 1       │ 'surge-credit-1-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 0.6224599999986822 │ 8.241221184159242  │ null      │ 10.406629955888192 │ 107986.117939  │ 107985.495479  │ 1.049533           │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Fixed Market'    │ 'https://surge.credit' │
└─────────┴───────────────────────┴────────┴────────────────┴────────┴────────────────────┴────────────────────┴───────────┴────────────────────┴────────────────┴────────────────┴────────────────────┴─────┴────────────┴──────────────────────────────────────────────────┴───────────────────┴────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@github-actions

Copy link
Copy Markdown

The surge-credit adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 27 passed, 27 total
Snapshots: 0 total
Time: 0.172 s
Ran all test suites.

Nb of pools: 2
 

Sample pools:
┌─────────┬───────────────────────┬────────┬────────────────┬────────┬─────────────┬────────────────────┬───────────┬────────────────────┬────────────────┬────────────────┬────────────────────┬─────┬────────────┬──────────────────────────────────────────────────┬───────────────────┬────────────────────────────────────────┐
│ (index) │ pool                  │ chain  │ project        │ symbol │ tvlUsd      │ apyBase            │ apyReward │ apyBaseBorrow      │ totalSupplyUsd │ totalBorrowUsd │ availableBorrowUsd │ ltv │ borrowable │ underlyingTokens                                 │ poolMeta          │ url                                    │
├─────────┼───────────────────────┼────────┼────────────────┼────────┼─────────────┼────────────────────┼───────────┼────────────────────┼────────────────┼────────────────┼────────────────────┼─────┼────────────┼──────────────────────────────────────────────────┼───────────────────┼────────────────────────────────────────┤
│ 0       │ 'surge-credit-0-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 7274.431097 │ 15.025355421652087 │ null      │ 19.721736312181015 │ 260983.945688  │ 253709.514591  │ 7274.431097        │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Variable Market' │ 'https://earn.surge.credit/#/market/0' │
│ 1       │ 'surge-credit-1-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 7274.431097 │ 8.241221184159242  │ null      │ 10.406629955888192 │ 107986.117939  │ 107985.495479  │ 7274.431097        │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Fixed Market'    │ 'https://earn.surge.credit/#/market/1' │
└─────────┴───────────────────────┴────────┴────────────────┴────────┴─────────────┴────────────────────┴───────────┴────────────────────┴────────────────┴────────────────┴────────────────────┴─────┴────────────┴──────────────────────────────────────────────────┴───────────────────┴────────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@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 `@src/adaptors/surge-credit/index.js`:
- Around line 66-72: Update the pool object near tvlUsd to calculate TVL as net
supplied liquidity, using totalSupplyUsd minus totalBorrowUsd. Keep maxBorrowUsd
exclusively for availableBorrowUsd and leave the other APY and supply/borrow
fields unchanged.
🪄 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 Plus

Run ID: 65931cfe-b8c0-43d8-86dc-9b40e1d7c5b9

📥 Commits

Reviewing files that changed from the base of the PR and between 3560490 and 9312880.

📒 Files selected for processing (1)
  • src/adaptors/surge-credit/index.js

Comment thread src/adaptors/surge-credit/index.js Outdated
Comment thread src/adaptors/surge-credit/index.js Outdated
chain: utils.formatChain(CHAIN),
project: 'surge-credit',
symbol: 'USDC',
tvlUsd: maxBorrowUsd,

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.

tvl formula should be totalSupplyUsd - totalBorrowUsd

Comment thread src/adaptors/surge-credit/index.js Outdated
const totalBorrowUsd = Number(market.totalBorrowAssets) / 1e6

pools.push({
pool: `surge-credit-${m}-${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.

better to use address here, such as ${LIQUIDITY_POOL.toLowerCase()}-${m}-${chain}

@0xkr3p 0xkr3p 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.

hey @punithbm, thanks for the PR a couple comments to resolve before we can proceed - thanks!

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The surge-credit adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 28 passed, 28 total
Snapshots: 0 total
Time: 0.261 s
Ran all test suites.

Nb of pools: 2
 

Sample pools:
┌─────────┬───────────────────────┬────────┬────────────────┬────────┬────────────┬────────────────────┬───────────┬────────────────────┬────────────────┬────────────────┬────────────────────┬─────┬────────────┬──────────────────────────────────────────────────┬───────────────────┬────────────────────────────────────────┐
│ (index) │ pool                  │ chain  │ project        │ symbol │ tvlUsd     │ apyBase            │ apyReward │ apyBaseBorrow      │ totalSupplyUsd │ totalBorrowUsd │ availableBorrowUsd │ ltv │ borrowable │ underlyingTokens                                 │ poolMeta          │ url                                    │
├─────────┼───────────────────────┼────────┼────────────────┼────────┼────────────┼────────────────────┼───────────┼────────────────────┼────────────────┼────────────────┼────────────────────┼─────┼────────────┼──────────────────────────────────────────────────┼───────────────────┼────────────────────────────────────────┤
│ 0       │ 'surge-credit-0-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 3792.93942 │ 15.244203544601342 │ null      │ 19.721736312181015 │ 258242.53584   │ 254449.59642   │ 3792.93942         │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Variable Market' │ 'https://earn.surge.credit/#/market/0' │
│ 1       │ 'surge-credit-1-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 3792.93942 │ 8.241221184159242  │ null      │ 10.406629955888192 │ 110762.809366  │ 110762.186883  │ 3792.93942         │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Fixed Market'    │ 'https://earn.surge.credit/#/market/1' │
└─────────┴───────────────────────┴────────┴────────────────┴────────┴────────────┴────────────────────┴───────────┴────────────────────┴────────────────┴────────────────┴────────────────────┴─────┴────────────┴──────────────────────────────────────────────────┴───────────────────┴────────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The surge-credit adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 28 passed, 28 total
Snapshots: 0 total
Time: 0.234 s
Ran all test suites.

Nb of pools: 2
 

Sample pools:
┌─────────┬─────────────────────────────────────────────────────┬────────┬────────────────┬────────┬────────────────────┬────────────────────┬───────────┬────────────────────┬────────────────┬────────────────┬────────────────────┬─────┬────────────┬──────────────────────────────────────────────────┬───────────────────┬────────────────────────────────────────┐
│ (index) │ pool                                                │ chain  │ project        │ symbol │ tvlUsd             │ apyBase            │ apyReward │ apyBaseBorrow      │ totalSupplyUsd │ totalBorrowUsd │ availableBorrowUsd │ ltv │ borrowable │ underlyingTokens                                 │ poolMeta          │ url                                    │
├─────────┼─────────────────────────────────────────────────────┼────────┼────────────────┼────────┼────────────────────┼────────────────────┼───────────┼────────────────────┼────────────────┼────────────────┼────────────────────┼─────┼────────────┼──────────────────────────────────────────────────┼───────────────────┼────────────────────────────────────────┤
│ 0       │ '0xee755f1bbcbf6e3260469d0f473522d71d3bddda-0-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 3792.9394200000097 │ 15.244203544601342 │ null      │ 19.721736312181015 │ 258242.53584   │ 254449.59642   │ 3792.9394200000097 │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Variable Market' │ 'https://earn.surge.credit/#/market/0' │
│ 1       │ '0xee755f1bbcbf6e3260469d0f473522d71d3bddda-1-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ 0                  │ 8.241221184159242  │ null      │ 10.406629955888192 │ 110762.809366  │ 110762.186883  │ 0                  │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Fixed Market'    │ 'https://earn.surge.credit/#/market/1' │
└─────────┴─────────────────────────────────────────────────────┴────────┴────────────────┴────────┴────────────────────┴────────────────────┴───────────┴────────────────────┴────────────────┴────────────────┴────────────────────┴─────┴────────────┴──────────────────────────────────────────────────┴───────────────────┴────────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@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 `@src/adaptors/surge-credit/index.js`:
- Around line 64-80: Add an explicit token: null field to the pool object
constructed in the adaptor’s pools.push call, preventing triggerAdaptor.js from
inferring LIQUIDITY_POOL as the token while preserving the existing
underlyingTokens: [USDC] declaration.
- Around line 50-62: Separate TVL from borrowable liquidity in the market
mapping: keep the accounting difference represented by idleUsd for tvlUsd, but
calculate availableBorrowUsd from physical liquidity using totalPhysicalSupply
minus totalPhysicalBorrow or the existing getAvailableLiquidity helper. Update
the relevant mapping logic around isFixed and idleUsd without treating
reserve-accrued accounting value as withdrawable liquidity.
🪄 Autofix

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 Plus

Run ID: 7d91c201-8368-40d8-8f5c-fbc4221ed271

📥 Commits

Reviewing files that changed from the base of the PR and between 9312880 and 6dcf500.

📒 Files selected for processing (1)
  • src/adaptors/surge-credit/index.js

Comment thread src/adaptors/surge-credit/index.js Outdated
Comment thread src/adaptors/surge-credit/index.js
@punithbm

punithbm commented Aug 5, 2026

Copy link
Copy Markdown
Author

@0xkr3p Thanks for the review - addressed both comments and fixed the TVL methodology.

  1. tvlUsd was double-counting across the two markets. The previous version used getMaxBorrowAmount(marketId) as tvlUsd for both pools. That call returns the shared remaining borrow capacity, which is Market 0's idle liquidity, so it returns the identical value for both markets (currently $3,792.94 each) and the same USDC was counted twice.

Fixed to the standard lending convention: tvlUsd = totalSupplyUsd - totalBorrowUsd (available/idle liquidity), computed per market from that market's own supply and borrow. The two markets' supplied figures are a disjoint partition of the same lender base. When a lender's capital is allocated to a fixed loan it moves out of Market 0's supply and into Market 1's, so each dollar is now counted once.

  1. Pool IDs now use the contract address as suggested: ${LIQUIDITY_POOL.toLowerCase()}-${marketId}-${chain}.

  2. On how we're representing the fixed market, want your input on the best convention. Market 1 (fixed rate) holds no idle liquidity of its own. It is funded on demand from Market 0 lenders' opt-in exposure and runs at ~100% utilization by construction. Right now we report it as:

  • tvlUsd: 0 and availableBorrowUsd: 0 (no independent idle liquidity)
  • totalSupplyUsd ($110,762) and totalBorrowUsd ($110,762) still reflect its real size

So the fixed market appears with its true supplied/borrowed figures but a $0 headline TVL, which I think can be better represented given it does not hold separate capital. So is there a convention you would rather we follow?

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The surge-credit adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 28 passed, 28 total
Snapshots: 0 total
Time: 0.276 s
Ran all test suites.

Nb of pools: 2
 

Sample pools:
┌─────────┬─────────────────────────────────────────────────────┬────────┬────────────────┬────────┬───────┬────────────────────┬────────────────────┬───────────┬────────────────────┬────────────────┬────────────────┬────────────────────┬─────┬────────────┬──────────────────────────────────────────────────┬───────────────────┬────────────────────────────────────────┐
│ (index) │ pool                                                │ chain  │ project        │ symbol │ token │ tvlUsd             │ apyBase            │ apyReward │ apyBaseBorrow      │ totalSupplyUsd │ totalBorrowUsd │ availableBorrowUsd │ ltv │ borrowable │ underlyingTokens                                 │ poolMeta          │ url                                    │
├─────────┼─────────────────────────────────────────────────────┼────────┼────────────────┼────────┼───────┼────────────────────┼────────────────────┼───────────┼────────────────────┼────────────────┼────────────────┼────────────────────┼─────┼────────────┼──────────────────────────────────────────────────┼───────────────────┼────────────────────────────────────────┤
│ 0       │ '0xee755f1bbcbf6e3260469d0f473522d71d3bddda-0-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ null  │ 3792.9394200000097 │ 15.244203544601342 │ null      │ 19.721736312181015 │ 258242.53584   │ 254449.59642   │ 3792.9394200000097 │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Variable Market' │ 'https://earn.surge.credit/#/market/0' │
│ 1       │ '0xee755f1bbcbf6e3260469d0f473522d71d3bddda-1-base' │ 'Base' │ 'surge-credit' │ 'USDC' │ null  │ 0                  │ 8.241221184159242  │ null      │ 10.406629955888192 │ 110762.809366  │ 110762.186883  │ 0                  │ 0.5 │ true       │ [ '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' ] │ 'Fixed Market'    │ 'https://earn.surge.credit/#/market/1' │
└─────────┴─────────────────────────────────────────────────────┴────────┴────────────────┴────────┴───────┴────────────────────┴────────────────────┴───────────┴────────────────────┴────────────────┴────────────────┴────────────────────┴─────┴────────────┴──────────────────────────────────────────────────┴───────────────────┴────────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@punithbm
punithbm requested a review from 0xkr3p August 5, 2026 11:16
@0xkr3p

0xkr3p commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

hi @punithbm, thanks for the changes. The adapter APY figure seems slightly overstated compared to the surge UI - is there any reason for this? Happy to proceed with TVL as is for fixed market for now

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