feat: add WealthVille APY adapter for Solana yield optimizer#2714
feat: add WealthVille APY adapter for Solana yield optimizer#2714amitesh-m wants to merge 4 commits into
Conversation
WealthVille auto-compounding yield optimizer on Solana. 5 vaults across Orca Whirlpools and Raydium (AMM/CLMM). TVL ~$14.2M. Website: https://wealthville.net
📝 WalkthroughWalkthroughA new Wealthville adaptor module is introduced to ChangesWealthville Adaptor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Error while running wealthville adapter: Test Suites: 1 failed, 1 total |
There was a problem hiding this comment.
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/wealthville/index.js`:
- Around line 10-67: The vaults array currently contains hardcoded tvlUsd and
apyBase values; update the apy() flow to fetch live vault metrics from the
existing WEALTHVILLE_API instead of using fixed numbers. Specifically, remove or
ignore the hardcoded tvlUsd/apyBase inside the vaults constant and implement a
runtime fetch in the apy() function that calls WEALTHVILLE_API, parses the
returned vault list, then maps each vault (matching by pool or underlyingTokens)
to produce the same output shape (including tvlUsd and apyBase) used elsewhere;
ensure you handle network errors and absent fields gracefully and keep pool
identifiers (e.g., "wealthville-sol-usdc-orca") as the matching key.
- Around line 15-60: The hardcoded tvlUsd values in the WealthVille adaptor
(fields named tvlUsd in src/adaptors/wealthville/index.js) total ~63.4M and
likely use the wrong units/scale; inspect and decide whether tvlUsd should be
raw USD or needs decimal/scaling adjustment (e.g., dividing by 1e6 or 1e8) to
match the target ~14.2M, then update the constants accordingly or replace the
hardcoded values with data fetched from WEALTHVILLE_API using axios (ensure
WEALTHVILLE_API and axios are actually used in the module), and add a short
comment explaining the unit/scale chosen so future reviewers understand the
tvlUsd basis.
🪄 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: c420d02f-4d95-4c26-91b4-716671b9d888
📒 Files selected for processing (1)
src/adaptors/wealthville/index.js
There was a problem hiding this comment.
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/wealthville/index.js`:
- Line 1: Remove the literal "undefined" text that appears before the const
keyword in the module initialization statement. The line should start directly
with const utils instead of undefinedconst utils, as the prefix is causing a
syntax/parse error that prevents the module from loading.
- Line 23: The underlyingTokens property is hardcoded to [USDC_SOL] for all
vaults, but vault names from the API response indicate different compositions
(e.g., "SOL USDT High Yield Vault"). To fix this, either extract the underlying
tokens from the vault name or API response if such data is available (parsing
names if they follow a consistent token-pair format), or if USDC is
intentionally used only as a reference denomination for NAV calculations rather
than the actual underlying assets, add a clarifying code comment explaining this
design decision. Avoid hardcoding the same tokens for all vaults.
🪄 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: 6bcf1505-9d6d-47dc-85b6-b90dca227ab6
📒 Files selected for processing (1)
src/adaptors/wealthville/index.js
|
Error while running wealthville adapter: Test Suites: 1 failed, 1 total |
|
Error while running wealthville adapter: Test Suites: 1 failed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/adaptors/wealthville/index.js (2)
30-30: ⚡ Quick winReconsider the USDC fallback for vaults with no underlying tokens.
When
mints.lengthis zero (no tokens found withvalue_usd > 0), the code falls back to[USDC_SOL]. This might hide data quality issues where vaults genuinely have no token holdings or the API data is incomplete. Consider either skipping such vaults or logging a warning to surface potential data issues.💡 Alternative approaches
Option 1: Skip vaults with no tokens
return list - .filter((v) => v && v.status === 'active' && Number(v.tvl_usd) > 0) + .filter((v) => v && v.status === 'active' && Number(v.tvl_usd) > 0 && v.vault_pubkey && v.name) .map((v) => { const mints = [ ...new Set( (v.token_accounts || []) .filter((t) => Number(t.value_usd) > 0 && t.mint) .map((t) => t.mint) ), ]; + if (!mints.length) { + console.warn(`Vault ${v.vault_pubkey} has no underlying tokens, skipping`); + return null; + } return { pool: `${v.vault_pubkey}-solana`, chain: 'Solana', project: 'wealthville', symbol: v.name, tvlUsd: Number(v.tvl_usd) || 0, apyBase: Number(v.apy) || 0, - underlyingTokens: mints.length ? mints : [USDC_SOL], + underlyingTokens: mints, url: 'https://wealthville.net/opportunities', }; - }); + }) + .filter(Boolean);Option 2: Keep fallback but add warning
- underlyingTokens: mints.length ? mints : [USDC_SOL], + underlyingTokens: mints.length ? mints : (() => { + console.warn(`Vault ${v.vault_pubkey} has no token_accounts, falling back to USDC`); + return [USDC_SOL]; + })(),🤖 Prompt for 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. In `@src/adaptors/wealthville/index.js` at line 30, The fallback to USDC_SOL when mints.length is zero masks potential data quality issues in vaults with no token holdings. In the underlyingTokens assignment, implement either Option 1 (skip processing vaults that have no underlying tokens by returning early or excluding them from the results) or Option 2 (keep the USDC_SOL fallback but add a warning log message that surfaces when this default is applied) to make data quality issues visible rather than silently masked.
10-10: Error handling is optional and not the prevailing pattern in this codebase.The
utils.getDatacall will throw on network errors or non-2xx responses, causing the adapter to fail entirely. However, most adapters in the codebase (73%) follow the current pattern of letting errors bubble up rather than catching them locally. If the project prefers consistent error handling across all adapters, this change would be aligned with best practices for resilience. Otherwise, the current approach is consistent with the existing pattern.🤖 Prompt for 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. In `@src/adaptors/wealthville/index.js` at line 10, The utils.getData call at line 10 in the Wealthville adapter follows the prevailing pattern in the codebase where 73% of adapters let errors bubble up rather than implementing local error handling. No change is required as the current approach is consistent with the existing codebase pattern. However, if the project decides to implement consistent error handling across all adapters for improved resilience, you would wrap the utils.getData call in a try-catch block to capture and handle any network errors or non-2xx responses before the adapter fails.
🤖 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/wealthville/index.js`:
- Line 24: The pool ID is being constructed using vault_pubkey without
validation, which can result in invalid pool IDs like "undefined-solana" if
vault_pubkey is null or undefined. Add explicit validation to ensure
vault_pubkey exists before using it in the pool ID string template. This
validation should either skip entries with missing vault_pubkey values or throw
an appropriate error to prevent downstream failures caused by invalid pool
identification.
---
Nitpick comments:
In `@src/adaptors/wealthville/index.js`:
- Line 30: The fallback to USDC_SOL when mints.length is zero masks potential
data quality issues in vaults with no token holdings. In the underlyingTokens
assignment, implement either Option 1 (skip processing vaults that have no
underlying tokens by returning early or excluding them from the results) or
Option 2 (keep the USDC_SOL fallback but add a warning log message that surfaces
when this default is applied) to make data quality issues visible rather than
silently masked.
- Line 10: The utils.getData call at line 10 in the Wealthville adapter follows
the prevailing pattern in the codebase where 73% of adapters let errors bubble
up rather than implementing local error handling. No change is required as the
current approach is consistent with the existing codebase pattern. However, if
the project decides to implement consistent error handling across all adapters
for improved resilience, you would wrap the utils.getData call in a try-catch
block to capture and handle any network errors or non-2xx responses before the
adapter fails.
🪄 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: 4d98f5a8-6630-4ce9-b8fc-446852a7be8e
📒 Files selected for processing (1)
src/adaptors/wealthville/index.js
| ), | ||
| ]; | ||
| return { | ||
| pool: `${v.vault_pubkey}-solana`, |
There was a problem hiding this comment.
Validate that vault_pubkey exists before using it in the pool ID.
If v.vault_pubkey is undefined or null, the pool ID will be invalid (e.g., "undefined-solana"), causing downstream failures or incorrect pool identification.
🛡️ Suggested validation
return list
- .filter((v) => v && v.status === 'active' && Number(v.tvl_usd) > 0)
+ .filter((v) => v && v.status === 'active' && Number(v.tvl_usd) > 0 && v.vault_pubkey && v.name)
.map((v) => {Or add explicit validation in the map:
.map((v) => {
+ if (!v.vault_pubkey || !v.name) {
+ console.warn('Skipping vault missing required fields:', v);
+ return null;
+ }
const mints = [
...new Set(
(v.token_accounts || [])
.filter((t) => Number(t.value_usd) > 0 && t.mint)
.map((t) => t.mint)
),
];
return {
pool: `${v.vault_pubkey}-solana`,
chain: 'Solana',
project: 'wealthville',
symbol: v.name,
tvlUsd: Number(v.tvl_usd) || 0,
apyBase: Number(v.apy) || 0,
underlyingTokens: mints.length ? mints : [USDC_SOL],
url: 'https://wealthville.net/opportunities',
};
- });
+ })
+ .filter(Boolean);🤖 Prompt for 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.
In `@src/adaptors/wealthville/index.js` at line 24, The pool ID is being
constructed using vault_pubkey without validation, which can result in invalid
pool IDs like "undefined-solana" if vault_pubkey is null or undefined. Add
explicit validation to ensure vault_pubkey exists before using it in the pool ID
string template. This validation should either skip entries with missing
vault_pubkey values or throw an appropriate error to prevent downstream failures
caused by invalid pool identification.
WealthVille auto-compounding yield optimizer on Solana. 5 vaults across Orca Whirlpools and Raydium (AMM/CLMM). TVL ~$14.2M. Website: https://wealthville.net
Summary by CodeRabbit