Skip to content

feat: add pool type and duration metadata#2636

Open
ducnmm wants to merge 3 commits into
DefiLlama:masterfrom
ducnmm:fix/pool-type-duration-metadata
Open

feat: add pool type and duration metadata#2636
ducnmm wants to merge 3 commits into
DefiLlama:masterfrom
ducnmm:fix/pool-type-duration-metadata

Conversation

@ducnmm
Copy link
Copy Markdown

@ducnmm ducnmm commented Apr 29, 2026

Summary

  • add optional type and duration pool metadata to the shared yield-server pool contract
  • persist the new metadata in config, include it in enrichment/public responses, and expose it in /poolsBorrow
  • add a migration plus adapter test coverage for allowed type values and numeric duration

Tests

  • node --check src/queries/yield.js
  • node --check src/handlers/triggerAdaptor.js
  • node --check src/api/controllers/enriched.js
  • node --check src/queries/config.js
  • node --check src/adaptors/test.js
  • node --check migrations/1777200000000_add-pool-type-duration.js
  • npm test -- --runInBand src/adaptors/test.js --testPathPattern=src/adaptors/test.js (fails locally: jest: command not found in this workspace)

Notes

  • selected yield-server#1678 after checking issue comments, PR history, and local code for overlap; there was no competing PR or claim
  • this change only wires the metadata through the pipeline; adapters can adopt the new fields incrementally

Summary by CodeRabbit

Release Notes

  • New Features
    • Pools now include two new optional attributes: type (categorizing pools as Variable Rate Lending, Fixed Rate Lending, Yield Farming, Concentrated Liquidity, or Other) and duration (numeric field)
    • Both fields are now returned in all pool-related API responses and enriched data

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

Warning

Rate limit exceeded

@ducnmm has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 53 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b781f02d-c653-4659-b57a-d15a1171f884

📥 Commits

Reviewing files that changed from the base of the PR and between 18bbd94 and 958bbd7.

📒 Files selected for processing (1)
  • src/api/controllers/enriched.js
📝 Walkthrough

Walkthrough

A database migration adds type and duration columns to the config table. Corresponding updates propagate these fields through the type system, query layer, data processing pipeline, API controllers, and response formatting to surface pool configuration metadata throughout the application.

Changes

Cohort / File(s) Summary
Database Layer
migrations/1777200000000_add-pool-type-duration.js
Migration script adds type and duration columns to config table; rollback removes both columns.
Type System & Validation
src/types/Pool.d.ts, src/adaptors/test.js
Pool interface expanded with optional type (lending/farming/liquidity enum) and duration (number) properties. Test rules added to validate these fields on pool objects.
Data Access Layer
src/queries/config.js, src/queries/yield.js
Query builders extended to include type and duration fields in column sets and result sets; config.js adds defaults to null, yield.js retrieves from joined config data.
Application Layer
src/handlers/triggerAdaptor.js, src/api/controllers/enriched.js, src/utils/enrichedColumns.js
Adaptor pipeline parses and normalizes duration field; controller forwards both fields in enriched pool responses; response column array updated to include the new fields.

Sequence Diagram

sequenceDiagram
    participant DB as Database
    participant QRY as Query Layer
    participant ADT as Adaptor Pipeline
    participant CTL as API Controller
    participant RSP as Response Formatter
    
    DB->>QRY: Fetch config with type, duration
    QRY->>ADT: Pass pool data (type, duration)
    ADT->>ADT: Parse duration (string → number)
    ADT->>ADT: Normalize & round (5 decimals)
    ADT->>CTL: Forward to enrichment
    CTL->>CTL: Include type, duration in enriched pool
    CTL->>RSP: Build response object
    RSP->>RSP: Format with type, duration columns
    RSP-->>DB: Return enriched pool data
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Two fields hopped into the pool so fine,
type and duration now align,
Through DB, queries, pipelines they flow,
From database roots to response glow,
A rabbit's delight, the schema's design!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add pool type and duration metadata' directly and clearly summarizes the main change—adding two new optional metadata fields (type and duration) to the pool contract, which is demonstrated across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ 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
Review rate limit: 0/1 reviews remaining, refill in 58 minutes and 53 seconds.

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 `@src/api/controllers/enriched.js`:
- Around line 113-114: The code currently overwrites supply-side metadata by
unconditionally assigning p.type and p.duration from lendBorrow; change the
assignment so you only take lendBorrow.type and lendBorrow.duration when they
are defined (e.g. use lendBorrow?.type ?? p.type and lendBorrow?.duration ??
p.duration or an explicit check like if (lendBorrow && lendBorrow.type != null)
p.type = lendBorrow.type; same for duration) so poolSupplySide values are
preserved when the borrow-side is null/undefined; update the mapping where
p.type and p.duration are set to use these guarded/null-coalescing checks.
🪄 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: 380d1435-c741-4fab-8f12-2966ec7216f5

📥 Commits

Reviewing files that changed from the base of the PR and between c601654 and 18bbd94.

📒 Files selected for processing (8)
  • migrations/1777200000000_add-pool-type-duration.js
  • src/adaptors/test.js
  • src/api/controllers/enriched.js
  • src/handlers/triggerAdaptor.js
  • src/queries/config.js
  • src/queries/yield.js
  • src/types/Pool.d.ts
  • src/utils/enrichedColumns.js

Comment thread src/api/controllers/enriched.js Outdated
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