Skip to content

Extract active protocols dynamically rather than statically for Nolus Protocol#2321

Open
metodi96 wants to merge 6 commits intoDefiLlama:masterfrom
metodi96:master
Open

Extract active protocols dynamically rather than statically for Nolus Protocol#2321
metodi96 wants to merge 6 commits intoDefiLlama:masterfrom
metodi96:master

Conversation

@metodi96
Copy link
Contributor

@metodi96 metodi96 commented Jan 30, 2026

Summary by CodeRabbit

  • Refactor
    • Replaced hard-coded protocol and token lists with ETL-driven dynamic retrieval.
    • APY and price calculations now consume live protocol, pool, and currency data.
    • Decimal handling standardized using a stable-quote reference and dynamic currency decimals.
    • Public API surface remains unchanged.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 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

The Nolus Protocol adaptor now sources active protocols and currency decimals from the ETL API instead of hard-coded definitions; getApy was refactored to use ETL-driven protocol/pool data and dynamic decimal adjustments for price/TVL calculations.

Changes

Cohort / File(s) Summary
Dynamic Protocol & Currency Integration
src/adaptors/nolus-protocol/index.js
Removed static protocol/contract list and hard-coded per-symbol decimal adjustments. Added fetchActiveProtocols, fetchCurrencyDecimals, getDecimalAdjustment, STABLE_QUOTE_DECIMALS, and refactored getApy to fetch protocols and currency decimals from ETL, query pools dynamically, and apply decimal normalization during APY/TVL computation.

Sequence Diagram

sequenceDiagram
    participant getApy as getApy()
    participant ETL as ETL API
    participant Pool as Pool Data Source
    participant Calc as Calc Logic

    getApy->>ETL: fetchActiveProtocols()
    ETL-->>getApy: active protocol descriptors (lpp, oracle, symbol, protocolName)

    getApy->>ETL: fetchCurrencyDecimals()
    ETL-->>getApy: ticker → decimals map

    loop for each protocol
        getApy->>Pool: request pool data (using lpp/oracle)
        Pool-->>getApy: pool balances, rates

        getApy->>Calc: compute price & TVL (use decimals map & getDecimalAdjustment)
        Calc-->>getApy: adjusted price & APY
    end

    getApy->>getApy: aggregate results and return APY list
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Hopping through ETL fields so wide,

I fetch protocols with a proud little stride.
Decimals aligned, no hardcoded snare,
APYs prance light with tidy, careful care.
A carrot of data — fresh, clean, and fair. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: dynamically extracting active protocols instead of using static hard-coded contracts for the Nolus Protocol adapter.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

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.

@llamatester
Copy link

The nolus-protocol adapter exports pools:

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

Nb of pools: 8
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────────────┬─────────┬──────────────────┬──────────────┬────────────────────┬──────────────────────┬───────────────┬─────────────────┬────────────────┬────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────┐
│ (index) │ pool                                                               │ chain   │ project          │ symbol       │ tvlUsd             │ apyBase              │ apyBaseBorrow │ apyRewardBorrow │ totalSupplyUsd │ totalBorrowUsd │ underlyingTokens                                                                                                                                                     │ poolMeta │
├─────────┼────────────────────────────────────────────────────────────────────┼─────────┼──────────────────┼──────────────┼────────────────────┼──────────────────────┼───────────────┼─────────────────┼────────────────┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ 0       │ 'nolus1ueytzwqyadm6r0z8ajse7g6gzum4w3vv04qazctf8ugqrrej6n4sq027cf' │ 'Nolus' │ 'nolus-protocol' │ 'USDC_NOBLE' │ 645147.346132      │ 7.541530823106897    │ 17.4          │ 0               │ 1251765.870933 │ 605239.89221   │ [ 'ibc/F5FABF52B54E65064B57BF6DBD8E5FAD22CEE9F4B8A57ADBB20CCD0173AA72A4', 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4' ]                   │ ''       │
│ 1       │ 'nolus1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3sqaa3c5' │ 'Nolus' │ 'nolus-protocol' │ 'USDC'       │ 33121.148469       │ 5.114975776151159    │ 17.6          │ 0               │ 53054.674216   │ 19759.541662   │ [ 'ibc/7FBDBEEEBA9C50C4BCDF7BF438EAB99E64360833D240B32655C96E319559E911', 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858' ]                   │ ''       │
│ 2       │ 'nolus1w2yz345pqheuk85f0rj687q6ny79vlj9sd6kxwwex696act6qgkqfz7jy3' │ 'Nolus' │ 'nolus-protocol' │ 'ALL_BTC'    │ 24289.102852293054 │ 0.009215887000524468 │ 3.3           │ 0               │ 24495.22691899 │ 132.7852178    │ [ 'ibc/E45CFCB959F4F6D1065B7033EE49A88E606E6AD82E75725219B3D68B0FA89987', 'factory/osmo1z6r6qdknhgsc0zeracktgpcxf43j6sekq07nw8sxduc9lg0qjjlqfu25e3/alloyed/allBTC' ] │ ''       │
│ 3       │ 'nolus1qufnnuwj0dcerhkhuxefda6h5m24e64v2hfp9pac5lglwclxz9dsva77wm' │ 'Nolus' │ 'nolus-protocol' │ 'ALL_SOL'    │ 5761.129569953059  │ 0                    │ 7.7           │ 0               │ 5785.916204294 │ 0              │ [ 'ibc/762E1E45658845A12E214A91C3C05FDFC5951D60404FAADA225A369A96DCD9A9', 'factory/osmo1n3n75av8awcnw4jl62n3l48e6e4sxqmaf97w5ua6ddu4s475q5qq9udvx4/alloyed/allSOL' ] │ ''       │
│ 4       │ 'nolus1u0zt8x3mkver0447glfupz9lz6wnt62j70p5fhhtu3fr46gcdd9s5dz9l6' │ 'Nolus' │ 'nolus-protocol' │ 'ATOM'       │ 3179.9516576405467 │ 0                    │ 8.6           │ 0               │ 3200.954415    │ 0              │ [ 'ibc/6CDD4663F2F09CD62285E2D45891FC149A3568E316CE3EBBE201A71A78A69388', 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2' ]                   │ ''       │
│ 5       │ 'nolus17vsedux675vc44yu7et9m64ndxsy907v7sfgrk7tw3xnjtqemx3q6t3xw6' │ 'Nolus' │ 'nolus-protocol' │ 'USDC_NOBLE' │ 2992.402242        │ 11.54105950001902    │ 16.6          │ 0               │ 15245.26058    │ 12225.185625   │ [ 'ibc/18161D8EFBD00FF5B7683EF8E923B8913453567FBE3FB6672D75712B0DEB6682', 'ibc/B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81' ]                   │ ''       │
│ 6       │ 'nolus1lxr7f5xe02jq6cce4puk6540mtu9sg36at2dms5sk69wdtzdrg9qq0t67z' │ 'Nolus' │ 'nolus-protocol' │ 'AKT'        │ 1703.9453664931527 │ 0                    │ 7.2           │ 0               │ 1716.916265    │ 0              │ [ 'ibc/ADC63C00000CA75F909D2BE3ACB5A9980BED3A73B92746E0FCE6C67414055459', 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4' ]                   │ ''       │
│ 7       │ 'nolus1py7pxw74qvlgq0n6rfz7mjrhgnls37mh87wasg89n75qt725rams8yr46t' │ 'Nolus' │ 'nolus-protocol' │ 'OSMO'       │ 1240.6338213265108 │ 0                    │ 4.9           │ 0               │ 1247.017135    │ 0              │ [ 'ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518', 'uosmo' ]                                                                                  │ ''       │
└─────────┴────────────────────────────────────────────────────────────────────┴─────────┴──────────────────┴──────────────┴────────────────────┴──────────────────────┴───────────────┴─────────────────┴────────────────┴────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Copy link
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

🤖 Fix all issues with AI agents
In `@src/adaptors/nolus-protocol/index.js`:
- Around line 34-40: The protocols.map projection directly accesses nested
properties p.contracts.lpp and p.contracts.oracle which will throw if contracts
is null/undefined; update the mapping in the protocols.map callback (the code
creating objects with lpp/oracle/symbol/protocolName/meta) to defensively read
contracts (e.g., const c = p.contracts || {}; or use optional chaining) and
assign lpp and oracle from that safe reference so missing contracts produce
undefined (or a sensible default string) instead of throwing.
🧹 Nitpick comments (2)
src/adaptors/nolus-protocol/index.js (2)

71-75: Consider parallelizing independent API calls.

fetchActiveProtocols() and fetchCurrencyDecimals() are independent and could be fetched concurrently to reduce latency.

⚡ Proposed optimization
-  // Fetch active protocols dynamically from ETL
-  const contracts = await fetchActiveProtocols();
-
-  // Fetch currency decimals for dynamic adjustment
-  const currencyDecimals = await fetchCurrencyDecimals();
+  // Fetch active protocols and currency decimals concurrently
+  const [contracts, currencyDecimals] = await Promise.all([
+    fetchActiveProtocols(),
+    fetchCurrencyDecimals(),
+  ]);

94-97: Prefer strict equality operator.

Use === instead of == for type-safe comparison.

♻️ Proposed fix
     let currencyData = _.find(
       oracleCurrenciesData.data,
-      (n) => n.ticker == lppTickerData.data,
+      (n) => n.ticker === lppTickerData.data,
     );

@llamatester
Copy link

The nolus-protocol adapter exports pools:

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

Nb of pools: 8
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────────────┬─────────┬──────────────────┬──────────────┬────────────────────┬──────────────────────┬───────────────┬─────────────────┬────────────────┬────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────┐
│ (index) │ pool                                                               │ chain   │ project          │ symbol       │ tvlUsd             │ apyBase              │ apyBaseBorrow │ apyRewardBorrow │ totalSupplyUsd │ totalBorrowUsd │ underlyingTokens                                                                                                                                                     │ poolMeta │
├─────────┼────────────────────────────────────────────────────────────────────┼─────────┼──────────────────┼──────────────┼────────────────────┼──────────────────────┼───────────────┼─────────────────┼────────────────┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ 0       │ 'nolus1ueytzwqyadm6r0z8ajse7g6gzum4w3vv04qazctf8ugqrrej6n4sq027cf' │ 'Nolus' │ 'nolus-protocol' │ 'USDC_NOBLE' │ 645147.346132      │ 7.541530823106897    │ 17.4          │ 0               │ 1251765.870933 │ 605239.89221   │ [ 'ibc/F5FABF52B54E65064B57BF6DBD8E5FAD22CEE9F4B8A57ADBB20CCD0173AA72A4', 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4' ]                   │ ''       │
│ 1       │ 'nolus1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3sqaa3c5' │ 'Nolus' │ 'nolus-protocol' │ 'USDC'       │ 33121.148469       │ 5.114975776151159    │ 17.6          │ 0               │ 53054.674216   │ 19759.541662   │ [ 'ibc/7FBDBEEEBA9C50C4BCDF7BF438EAB99E64360833D240B32655C96E319559E911', 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858' ]                   │ ''       │
│ 2       │ 'nolus1w2yz345pqheuk85f0rj687q6ny79vlj9sd6kxwwex696act6qgkqfz7jy3' │ 'Nolus' │ 'nolus-protocol' │ 'ALL_BTC'    │ 24356.828022499725 │ 0.009215887000524468 │ 3.3           │ 0               │ 24495.22691899 │ 132.7852178    │ [ 'ibc/E45CFCB959F4F6D1065B7033EE49A88E606E6AD82E75725219B3D68B0FA89987', 'factory/osmo1z6r6qdknhgsc0zeracktgpcxf43j6sekq07nw8sxduc9lg0qjjlqfu25e3/alloyed/allBTC' ] │ ''       │
│ 3       │ 'nolus1qufnnuwj0dcerhkhuxefda6h5m24e64v2hfp9pac5lglwclxz9dsva77wm' │ 'Nolus' │ 'nolus-protocol' │ 'ALL_SOL'    │ 5779.381386353941  │ 0                    │ 7.7           │ 0               │ 5785.916204294 │ 0              │ [ 'ibc/762E1E45658845A12E214A91C3C05FDFC5951D60404FAADA225A369A96DCD9A9', 'factory/osmo1n3n75av8awcnw4jl62n3l48e6e4sxqmaf97w5ua6ddu4s475q5qq9udvx4/alloyed/allSOL' ] │ ''       │
│ 4       │ 'nolus1u0zt8x3mkver0447glfupz9lz6wnt62j70p5fhhtu3fr46gcdd9s5dz9l6' │ 'Nolus' │ 'nolus-protocol' │ 'ATOM'       │ 3178.2943571948417 │ 0                    │ 8.6           │ 0               │ 3200.954415    │ 0              │ [ 'ibc/6CDD4663F2F09CD62285E2D45891FC149A3568E316CE3EBBE201A71A78A69388', 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2' ]                   │ ''       │
│ 5       │ 'nolus17vsedux675vc44yu7et9m64ndxsy907v7sfgrk7tw3xnjtqemx3q6t3xw6' │ 'Nolus' │ 'nolus-protocol' │ 'USDC_NOBLE' │ 2992.402242        │ 11.54105950001902    │ 16.6          │ 0               │ 15245.26058    │ 12225.185625   │ [ 'ibc/18161D8EFBD00FF5B7683EF8E923B8913453567FBE3FB6672D75712B0DEB6682', 'ibc/B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81' ]                   │ ''       │
│ 6       │ 'nolus1lxr7f5xe02jq6cce4puk6540mtu9sg36at2dms5sk69wdtzdrg9qq0t67z' │ 'Nolus' │ 'nolus-protocol' │ 'AKT'        │ 1718.9430141908617 │ 0                    │ 7.2           │ 0               │ 1716.916265    │ 0              │ [ 'ibc/ADC63C00000CA75F909D2BE3ACB5A9980BED3A73B92746E0FCE6C67414055459', 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4' ]                   │ ''       │
│ 7       │ 'nolus1py7pxw74qvlgq0n6rfz7mjrhgnls37mh87wasg89n75qt725rams8yr46t' │ 'Nolus' │ 'nolus-protocol' │ 'OSMO'       │ 1242.8073616237873 │ 0                    │ 4.9           │ 0               │ 1247.017135    │ 0              │ [ 'ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518', 'uosmo' ]                                                                                  │ ''       │
└─────────┴────────────────────────────────────────────────────────────────────┴─────────┴──────────────────┴──────────────┴────────────────────┴──────────────────────┴───────────────┴─────────────────┴────────────────┴────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Copy link
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

🤖 Fix all issues with AI agents
In `@src/adaptors/nolus-protocol/index.js`:
- Around line 62-70: The code currently falls back to stable decimals using the
logical OR operator which treats 0 as falsy; update the decimal fallback to use
nullish coalescing (??) so only null/undefined trigger the default. In practice,
modify getDecimalAdjustment usage and any other places (e.g., the block around
lines referenced 132-134) to compute lpnDecimals = (currency.decimal_digits ??
STABLE_QUOTE_DECIMALS) and then call getDecimalAdjustment(lpnDecimals), and
replace any other patterns like x || STABLE_QUOTE_DECIMALS with x ??
STABLE_QUOTE_DECIMALS to preserve a possible zero value.

@llamatester
Copy link

The nolus-protocol adapter exports pools:

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

Nb of pools: 8
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────────────┬─────────┬──────────────────┬──────────────┬────────────────────┬──────────────────────┬───────────────┬─────────────────┬────────────────┬────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────┐
│ (index) │ pool                                                               │ chain   │ project          │ symbol       │ tvlUsd             │ apyBase              │ apyBaseBorrow │ apyRewardBorrow │ totalSupplyUsd │ totalBorrowUsd │ underlyingTokens                                                                                                                                                     │ poolMeta │
├─────────┼────────────────────────────────────────────────────────────────────┼─────────┼──────────────────┼──────────────┼────────────────────┼──────────────────────┼───────────────┼─────────────────┼────────────────┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│ 0       │ 'nolus1ueytzwqyadm6r0z8ajse7g6gzum4w3vv04qazctf8ugqrrej6n4sq027cf' │ 'Nolus' │ 'nolus-protocol' │ 'USDC_NOBLE' │ 645147.346132      │ 7.541530823106897    │ 17.4          │ 0               │ 1251765.870933 │ 605239.89221   │ [ 'ibc/F5FABF52B54E65064B57BF6DBD8E5FAD22CEE9F4B8A57ADBB20CCD0173AA72A4', 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4' ]                   │ ''       │
│ 1       │ 'nolus1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3sqaa3c5' │ 'Nolus' │ 'nolus-protocol' │ 'USDC'       │ 33121.148469       │ 5.114975776151159    │ 17.6          │ 0               │ 53054.674216   │ 19759.541662   │ [ 'ibc/7FBDBEEEBA9C50C4BCDF7BF438EAB99E64360833D240B32655C96E319559E911', 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858' ]                   │ ''       │
│ 2       │ 'nolus1w2yz345pqheuk85f0rj687q6ny79vlj9sd6kxwwex696act6qgkqfz7jy3' │ 'Nolus' │ 'nolus-protocol' │ 'ALL_BTC'    │ 24364.484118425513 │ 0.009215887000524468 │ 3.3           │ 0               │ 24495.22691899 │ 132.7852178    │ [ 'ibc/E45CFCB959F4F6D1065B7033EE49A88E606E6AD82E75725219B3D68B0FA89987', 'factory/osmo1z6r6qdknhgsc0zeracktgpcxf43j6sekq07nw8sxduc9lg0qjjlqfu25e3/alloyed/allBTC' ] │ ''       │
│ 3       │ 'nolus1qufnnuwj0dcerhkhuxefda6h5m24e64v2hfp9pac5lglwclxz9dsva77wm' │ 'Nolus' │ 'nolus-protocol' │ 'ALL_SOL'    │ 5781.01662126549   │ 0                    │ 7.7           │ 0               │ 5785.916204294 │ 0              │ [ 'ibc/762E1E45658845A12E214A91C3C05FDFC5951D60404FAADA225A369A96DCD9A9', 'factory/osmo1n3n75av8awcnw4jl62n3l48e6e4sxqmaf97w5ua6ddu4s475q5qq9udvx4/alloyed/allSOL' ] │ ''       │
│ 4       │ 'nolus1u0zt8x3mkver0447glfupz9lz6wnt62j70p5fhhtu3fr46gcdd9s5dz9l6' │ 'Nolus' │ 'nolus-protocol' │ 'ATOM'       │ 3165.265903455149  │ 0                    │ 8.6           │ 0               │ 3200.954415    │ 0              │ [ 'ibc/6CDD4663F2F09CD62285E2D45891FC149A3568E316CE3EBBE201A71A78A69388', 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2' ]                   │ ''       │
│ 5       │ 'nolus17vsedux675vc44yu7et9m64ndxsy907v7sfgrk7tw3xnjtqemx3q6t3xw6' │ 'Nolus' │ 'nolus-protocol' │ 'USDC_NOBLE' │ 2992.402242        │ 11.54105950001902    │ 16.6          │ 0               │ 15245.26058    │ 12225.185625   │ [ 'ibc/18161D8EFBD00FF5B7683EF8E923B8913453567FBE3FB6672D75712B0DEB6682', 'ibc/B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81' ]                   │ ''       │
│ 6       │ 'nolus1lxr7f5xe02jq6cce4puk6540mtu9sg36at2dms5sk69wdtzdrg9qq0t67z' │ 'Nolus' │ 'nolus-protocol' │ 'AKT'        │ 1716.7373550329175 │ 0                    │ 7.2           │ 0               │ 1716.916265    │ 0              │ [ 'ibc/ADC63C00000CA75F909D2BE3ACB5A9980BED3A73B92746E0FCE6C67414055459', 'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4' ]                   │ ''       │
│ 7       │ 'nolus1py7pxw74qvlgq0n6rfz7mjrhgnls37mh87wasg89n75qt725rams8yr46t' │ 'Nolus' │ 'nolus-protocol' │ 'OSMO'       │ 1242.6874578517136 │ 0                    │ 4.9           │ 0               │ 1247.017135    │ 0              │ [ 'ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518', 'uosmo' ]                                                                                  │ ''       │
└─────────┴────────────────────────────────────────────────────────────────────┴─────────┴──────────────────┴──────────────┴────────────────────┴──────────────────────┴───────────────┴─────────────────┴────────────────┴────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Copy link
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

🤖 Fix all issues with AI agents
In `@src/adaptors/nolus-protocol/index.js`:
- Around line 62-70: getDecimalAdjustment currently returns 1 whenever
lpnDecimals < STABLE_QUOTE_DECIMALS which skips the required downscaling and
inflates price/TVL; update the function (and the duplicate logic at the other
occurrence around lines 131-134) to always return Math.pow(10, decimalDiff)
(where decimalDiff = lpnDecimals - STABLE_QUOTE_DECIMALS) so negative
differences correctly produce fractional adjustment factors, and ensure callers
use that factor for price/TVL scaling.

@slasher125
Copy link
Collaborator

@metodi96
sry for late response.

pls change the symbols to USDC, instead of USDC_NOBLE -> can add Noble to poolMeta. (same for other pools)

Copy link
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 (2)
src/adaptors/nolus-protocol/index.js (2)

165-165: Misleading comment.

The comment references "USDT address on ethereum" but this adapter is for the Nolus chain, and bank_symbol/dex_symbol are likely not addresses. Consider updating or removing the comment.

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

In `@src/adaptors/nolus-protocol/index.js` at line 165, The inline comment for
underlyingTokens is misleading—update or remove the phrase "eg here USDT address
on ethereum" and clarify that underlyingTokens holds symbol identifiers
(currencyData.bank_symbol, currencyData.dex_symbol) for the Nolus adapter rather
than Ethereum addresses; ensure the comment correctly reflects the Nolus chain
and the actual data type (symbols vs. addresses) next to the underlyingTokens:
[currencyData.bank_symbol, currencyData.dex_symbol] line.

98-110: Consider parallelizing contract queries for better performance.

The loop makes 4 sequential queryContract calls per protocol. With 8+ protocols, this adds latency. Since each iteration's queries are independent of other iterations, you could batch them.

♻️ Optional: Parallelize with Promise.all
-  for (let i = 0; i < contracts.length; i++) {
-    const c = contracts[i];
-    let lppTickerData = await queryContract(c.lpp, { lpn: [] });
-    let oracleCurrenciesData = await queryContract(c.oracle, {
-      currencies: {},
-    });
-    let oraclePriceData = await queryContract(c.oracle, {
-      stable_price: { currency: lppTickerData.data },
-    });
+  const results = await Promise.all(
+    contracts.map(async (c) => {
+      const lppTickerData = await queryContract(c.lpp, { lpn: [] });
+      const [oracleCurrenciesData, oraclePriceData, lppBalanceData] = await Promise.all([
+        queryContract(c.oracle, { currencies: {} }),
+        queryContract(c.oracle, { stable_price: { currency: lppTickerData.data } }),
+        queryContract(c.lpp, { lpp_balance: [] }),
+      ]);
+      return { c, lppTickerData, oracleCurrenciesData, oraclePriceData, lppBalanceData };
+    })
+  );
+
+  for (const { c, lppTickerData, oracleCurrenciesData, oraclePriceData, lppBalanceData } of results) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/adaptors/nolus-protocol/index.js` around lines 98 - 110, The four
sequential queryContract calls inside the for loop (using variables
lppTickerData, oracleCurrenciesData, oraclePriceData, currencyData) should be
parallelized: for each contract c call the independent queries concurrently with
Promise.all (or map to an async worker and await Promise.all over contracts) and
then destructure the results to compute currencyData (using _.find) — this keeps
the same logic but removes per-contract sequential waits and batches work across
contracts to reduce latency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/adaptors/nolus-protocol/index.js`:
- Line 165: The inline comment for underlyingTokens is misleading—update or
remove the phrase "eg here USDT address on ethereum" and clarify that
underlyingTokens holds symbol identifiers (currencyData.bank_symbol,
currencyData.dex_symbol) for the Nolus adapter rather than Ethereum addresses;
ensure the comment correctly reflects the Nolus chain and the actual data type
(symbols vs. addresses) next to the underlyingTokens: [currencyData.bank_symbol,
currencyData.dex_symbol] line.
- Around line 98-110: The four sequential queryContract calls inside the for
loop (using variables lppTickerData, oracleCurrenciesData, oraclePriceData,
currencyData) should be parallelized: for each contract c call the independent
queries concurrently with Promise.all (or map to an async worker and await
Promise.all over contracts) and then destructure the results to compute
currencyData (using _.find) — this keeps the same logic but removes per-contract
sequential waits and batches work across contracts to reduce latency.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 619a97a and 41e6a08.

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

Copy link
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

🧹 Nitpick comments (1)
src/adaptors/nolus-protocol/index.js (1)

104-127: Consider parallelizing per-pool RPC calls to reduce adapter latency.

Line 106 through Line 127 executes multiple network calls serially per protocol. A small Promise.all refactor would improve runtime and reduce timeout exposure.

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

In `@src/adaptors/nolus-protocol/index.js` around lines 104 - 127, The loop over
contracts calls queryContract serially (variables/functions: queryContract,
lppTickerData, oracleCurrenciesData, oraclePriceData, lppBalanceData) which
increases latency; refactor to run independent RPCs in parallel with
Promise.all: first kick off queryContract(c.lpp, { lpn: [] }) and
queryContract(c.oracle, { currencies: {} }) in parallel and await both, then
once lppTickerData is available start the dependent oracle price query
(queryContract(c.oracle, { stable_price: { currency: lppTickerData.data } }))
together with the lpp balance query (queryContract(c.lpp, { lpp_balance: [] }))
using Promise.all, then proceed with the existing currencyData checks and
continue; ensure you preserve variable names and null checks when unpacking
Promise.all results.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/adaptors/nolus-protocol/index.js`:
- Around line 49-59: The pool mapping uses a display-normalized symbol for both
presentation and math; add a canonical LPN ticker field (e.g., lpnSymbol or
canonicalSymbol) set to p.lpn_symbol when building the object in the map
(alongside the existing display-only symbol), and then update any downstream
decimal lookups (the places that index currencyDecimals currently with c.symbol)
to use that new canonical field (e.g., c.lpnSymbol) for all decimal/math
calculations so presentation aliases don't change decimal factors.

---

Nitpick comments:
In `@src/adaptors/nolus-protocol/index.js`:
- Around line 104-127: The loop over contracts calls queryContract serially
(variables/functions: queryContract, lppTickerData, oracleCurrenciesData,
oraclePriceData, lppBalanceData) which increases latency; refactor to run
independent RPCs in parallel with Promise.all: first kick off
queryContract(c.lpp, { lpn: [] }) and queryContract(c.oracle, { currencies: {}
}) in parallel and await both, then once lppTickerData is available start the
dependent oracle price query (queryContract(c.oracle, { stable_price: {
currency: lppTickerData.data } })) together with the lpp balance query
(queryContract(c.lpp, { lpp_balance: [] })) using Promise.all, then proceed with
the existing currencyData checks and continue; ensure you preserve variable
names and null checks when unpacking Promise.all results.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e2bfa72-d563-4bec-aa74-402642b8174c

📥 Commits

Reviewing files that changed from the base of the PR and between 41e6a08 and 3d46723.

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

Comment on lines +49 to +59
.filter((p) => p.contracts?.lpp && p.contracts?.oracle)
.map((p) => {
const override = symbolMeta[p.lpn_symbol];
return {
lpp: p.contracts.lpp,
oracle: p.contracts.oracle,
symbol: override ? override.symbol : p.lpn_symbol,
protocolName: p.name,
meta: override ? override.meta : '',
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use canonical LPN ticker for decimal math; keep symbol as display-only.

Line 149 currently indexes currencyDecimals with c.symbol, but c.symbol is normalized for presentation (e.g., ALL_BTC -> BTC, ALL_SOL -> SOL). That can apply the wrong decimal factor and skew price/TVL for aliased pools.

🔧 Proposed fix
   return protocols
     .filter((p) => p.contracts?.lpp && p.contracts?.oracle)
     .map((p) => {
       const override = symbolMeta[p.lpn_symbol];
       return {
         lpp: p.contracts.lpp,
         oracle: p.contracts.oracle,
+        lpnTicker: p.lpn_symbol,
         symbol: override ? override.symbol : p.lpn_symbol,
         protocolName: p.name,
         meta: override ? override.meta : '',
       };
     });
@@
-    const lpnDecimals = currencyDecimals[c.symbol] ?? STABLE_QUOTE_DECIMALS;
+    const lpnTicker = lppTickerData?.data || c.lpnTicker;
+    const lpnDecimals =
+      currencyDecimals[lpnTicker] ??
+      currencyData?.decimal_digits ??
+      STABLE_QUOTE_DECIMALS;
     const decimalsAdjustment = getDecimalAdjustment(lpnDecimals);

Also applies to: 149-151

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

In `@src/adaptors/nolus-protocol/index.js` around lines 49 - 59, The pool mapping
uses a display-normalized symbol for both presentation and math; add a canonical
LPN ticker field (e.g., lpnSymbol or canonicalSymbol) set to p.lpn_symbol when
building the object in the map (alongside the existing display-only symbol), and
then update any downstream decimal lookups (the places that index
currencyDecimals currently with c.symbol) to use that new canonical field (e.g.,
c.lpnSymbol) for all decimal/math calculations so presentation aliases don't
change decimal factors.

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.

3 participants