feat: add WealthVille APY adapter for Solana yield optimizer#2714
feat: add WealthVille APY adapter for Solana yield optimizer#2714amitesh-m wants to merge 1 commit 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) | ⏱️ ~8 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
| // Vault definitions with current on-chain data | ||
| const vaults = [ | ||
| { | ||
| pool: "wealthville-sol-usdc-orca", | ||
| symbol: "SOL-USDC", | ||
| tvlUsd: 32530000, | ||
| apyBase: 181.21, | ||
| underlyingTokens: [ | ||
| "So11111111111111111111111111111111111111112", | ||
| "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
| ], | ||
| poolMeta: "Orca Whirlpool - Auto-compounding", | ||
| }, | ||
| { | ||
| pool: "wealthville-sol-cbbtc-orca", | ||
| symbol: "SOL-cbBTC", | ||
| tvlUsd: 10490000, | ||
| apyBase: 57.34, | ||
| underlyingTokens: [ | ||
| "So11111111111111111111111111111111111111112", | ||
| "cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij", | ||
| ], | ||
| poolMeta: "Orca Whirlpool - Auto-compounding", | ||
| }, | ||
| { | ||
| pool: "wealthville-sol-usdc-raydium-clmm", | ||
| symbol: "SOL-USDC", | ||
| tvlUsd: 5870000, | ||
| apyBase: 44.59, | ||
| underlyingTokens: [ | ||
| "So11111111111111111111111111111111111111112", | ||
| "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
| ], | ||
| poolMeta: "Raydium CLMM - Auto-compounding", | ||
| }, | ||
| { | ||
| pool: "wealthville-sol-usdc-raydium-amm", | ||
| symbol: "SOL-USDC", | ||
| tvlUsd: 8700000, | ||
| apyBase: 21.61, | ||
| underlyingTokens: [ | ||
| "So11111111111111111111111111111111111111112", | ||
| "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
| ], | ||
| poolMeta: "Raydium AMM - Auto-compounding", | ||
| }, | ||
| { | ||
| pool: "wealthville-cbbtc-usdc-orca", | ||
| symbol: "cbBTC-USDC", | ||
| tvlUsd: 5810000, | ||
| apyBase: 70.15, | ||
| underlyingTokens: [ | ||
| "cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij", | ||
| "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
| ], | ||
| poolMeta: "Orca Whirlpool - Auto-compounding", | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
Replace hardcoded APY/TVL with runtime source data.
At Line 10, the code says “current on-chain data”, but Lines 11-67 hardcode APY/TVL values. This will stale quickly and produce incorrect yield output. Since WEALTHVILLE_API already exists (Line 3), apy() should fetch and map live vault data instead of embedding fixed numbers.
Suggested direction
async function apy() {
- // Vault definitions with current on-chain data
- const vaults = [
- ...
- ];
+ const { data } = await axios.get(WEALTHVILLE_API, { timeout: 10000 });
+ const vaults = data?.vaults ?? [];
return vaults.map((v) => ({
pool: v.pool,
chain: CHAIN,
project: PROJECT,
symbol: v.symbol,
- tvlUsd: v.tvlUsd,
- apyBase: v.apyBase,
+ tvlUsd: Number(v.tvlUsd),
+ apyBase: Number(v.apyBase),
apyReward: null,
rewardTokens: [],
underlyingTokens: v.underlyingTokens,
poolMeta: v.poolMeta,
url: URL,
}));
}🤖 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` around lines 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.
| tvlUsd: 32530000, | ||
| apyBase: 181.21, | ||
| underlyingTokens: [ | ||
| "So11111111111111111111111111111111111111112", | ||
| "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
| ], | ||
| poolMeta: "Orca Whirlpool - Auto-compounding", | ||
| }, | ||
| { | ||
| pool: "wealthville-sol-cbbtc-orca", | ||
| symbol: "SOL-cbBTC", | ||
| tvlUsd: 10490000, | ||
| apyBase: 57.34, | ||
| underlyingTokens: [ | ||
| "So11111111111111111111111111111111111111112", | ||
| "cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij", | ||
| ], | ||
| poolMeta: "Orca Whirlpool - Auto-compounding", | ||
| }, | ||
| { | ||
| pool: "wealthville-sol-usdc-raydium-clmm", | ||
| symbol: "SOL-USDC", | ||
| tvlUsd: 5870000, | ||
| apyBase: 44.59, | ||
| underlyingTokens: [ | ||
| "So11111111111111111111111111111111111111112", | ||
| "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
| ], | ||
| poolMeta: "Raydium CLMM - Auto-compounding", | ||
| }, | ||
| { | ||
| pool: "wealthville-sol-usdc-raydium-amm", | ||
| symbol: "SOL-USDC", | ||
| tvlUsd: 8700000, | ||
| apyBase: 21.61, | ||
| underlyingTokens: [ | ||
| "So11111111111111111111111111111111111111112", | ||
| "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
| ], | ||
| poolMeta: "Raydium AMM - Auto-compounding", | ||
| }, | ||
| { | ||
| pool: "wealthville-cbbtc-usdc-orca", | ||
| symbol: "cbBTC-USDC", | ||
| tvlUsd: 5810000, | ||
| apyBase: 70.15, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Read-only check against WealthVille vault API totals (no repo access needed).
set -euo pipefail
curl -sS https://wealthville.net/api/vaults \
| jq '{
vault_count: (.vaults // .data // [] | length),
total_tvl_usd: ((.vaults // .data // []) | map(.tvlUsd // .tvl // 0) | add)
}'Repository: DefiLlama/yield-server
Length of output: 173
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Repo snippet: src/adaptors/wealthville/index.js (lines 1-120) ==="
if [ -f "src/adaptors/wealthville/index.js" ]; then
nl -ba src/adaptors/wealthville/index.js | sed -n '1,120p'
else
echo "File not found"
fi
echo
echo "=== Inspect WealthVille API response (headers + first 400 bytes) ==="
# Use a short timeout and show status/headers; don't dump huge output.
curl -sS -m 15 -D /tmp/wealthville_headers.txt -o /tmp/wealthville_body.txt https://wealthville.net/api/vaults || true
echo "--- Headers ---"
cat /tmp/wealthville_headers.txt || true
echo "--- Body head ---"
# show first 400 bytes with escaping
python3 - <<'PY'
import pathlib, json
p = pathlib.Path("/tmp/wealthville_body.txt")
data = p.read_bytes() if p.exists() else b""
print(data[:400].decode('utf-8','replace'))
print("\n--- Body length ---")
print(len(data))
PY
echo
echo "=== Attempt to parse JSON quickly (jq -e on compact) ==="
# If it's not JSON, jq will fail; capture error and first 100 chars.
python3 - <<'PY'
import pathlib, subprocess, shlex, json, os, textwrap
body = pathlib.Path("/tmp/wealthville_body.txt")
if not body.exists():
print("no body")
raise SystemExit(0)
txt = body.read_text('utf-8','replace')
print("first 120 chars:", txt[:120].replace("\n","\\n"))
PY
jq -e 'true' /tmp/wealthville_body.txt >/dev/null 2>&1 && echo "jq JSON parse: OK" || echo "jq JSON parse: FAILED"Repository: DefiLlama/yield-server
Length of output: 197
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Repo snippet: src/adaptors/wealthville/index.js (lines 1-120) ==="
if [ -f "src/adaptors/wealthville/index.js" ]; then
nl -ba src/adaptors/wealthville/index.js | sed -n '1,120p'
else
echo "File not found"
fi
echo
echo "=== Inspect WealthVille API response (headers + first 400 bytes) ==="
# Use a short timeout and show status/headers; don't dump huge output.
curl -sS -m 15 -D /tmp/wealthville_headers.txt -o /tmp/wealthville_body.txt https://wealthville.net/api/vaults || true
echo "--- Headers ---"
cat /tmp/wealthville_headers.txt || true
echo "--- Body head ---"
# show first 400 bytes with escaping
python3 - <<'PY'
import pathlib
p = pathlib.Path("/tmp/wealthville_body.txt")
data = p.read_bytes() if p.exists() else b""
print(data[:400].decode('utf-8','replace'))
print("\n--- Body length ---")
print(len(data))
PY
echo
echo "=== Attempt to parse JSON quickly (jq -e on compact) ==="
python3 - <<'PY'
import pathlib
body = pathlib.Path("/tmp/wealthville_body.txt")
if not body.exists():
print("no body")
raise SystemExit(0)
txt = body.read_text('utf-8','replace')
print("first 120 chars:", txt[:120].replace("\n","\\n"))
PY
jq -e 'true' /tmp/wealthville_body.txt >/dev/null 2>&1 && echo "jq JSON parse: OK" || echo "jq JSON parse: FAILED"Repository: DefiLlama/yield-server
Length of output: 197
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Repo snippet: src/adaptors/wealthville/index.js (lines 1-120) ==="
if [ -f "src/adaptors/wealthville/index.js" ]; then
sed -n '1,120p' src/adaptors/wealthville/index.js | cat -n | sed -n '1,120p'
else
echo "File not found"
fi
echo
echo "=== Inspect WealthVille API response (headers + body head) ==="
curl -sS -m 15 -D /tmp/wealthville_headers.txt -o /tmp/wealthville_body.txt https://wealthville.net/api/vaults || true
echo "--- Headers ---"
cat /tmp/wealthville_headers.txt || true
echo "--- Body head ---"
python3 - <<'PY'
import pathlib
p = pathlib.Path("/tmp/wealthville_body.txt")
data = p.read_bytes() if p.exists() else b""
print(data[:400].decode('utf-8','replace'))
print("\n--- Body length ---")
print(len(data))
PY
echo
echo "=== Attempt to parse JSON quickly (jq -e on body) ==="
python3 - <<'PY'
import pathlib
body = pathlib.Path("/tmp/wealthville_body.txt")
if not body.exists():
print("no body")
raise SystemExit(0)
txt = body.read_text('utf-8','replace')
print("first 120 chars:", txt[:120].replace("\n","\\n"))
PY
jq -e 'true' /tmp/wealthville_body.txt >/dev/null 2>&1 && echo "jq JSON parse: OK" || echo "jq JSON parse: FAILED"Repository: DefiLlama/yield-server
Length of output: 4987
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Full file: src/adaptors/wealthville/index.js (line count) ==="
wc -l src/adaptors/wealthville/index.js || true
echo
echo "=== Find usages of WEALTHVILLE_API / axios / tvlUsd in wealthville adaptor ==="
rg -n "WEALTHVILLE_API|axios|tvlUsd" src/adaptors/wealthville/index.js || true
echo
echo "=== Show tail (remaining code after line 120 if any) ==="
tail -n 80 src/adaptors/wealthville/index.jsRepository: DefiLlama/yield-server
Length of output: 2753
Clarify tvlUsd units for WealthVille adaptor (hardcoded total ~ $63.4M vs target ~$14.2M)
src/adaptors/wealthville/index.js(lines 15-59) hardcodestvlUsdper vault; the five values sum to 63,400,000, far above the PR’s ~$14.2M objective.- The adaptor doesn’t use
WEALTHVILLE_API/axiosto populate or scale these numbers (both are unused), so the TVL definition/units/scaling fortvlUsdis unclear. - The configured endpoint
https://wealthville.net/api/vaultsreturns HTTP 404 (HTML) here, so the field format/decimals can’t be cross-checked.
Confirm whether tvlUsd is raw USD or requires scaling/decimal adjustment to match the intended TVL basis, and update the constants accordingly before merge.
🤖 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` around lines 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.
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