add earn-grid yield adapter (ERC-4626 USDC vault on Base) - #2903
add earn-grid yield adapter (ERC-4626 USDC vault on Base)#2903NukeThemAII wants to merge 4 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Base EarnGrid adaptor. It reads vault and strategy balances on-chain, retrieves Morpho net APYs, calculates weighted APY and idle allocation, and returns a formatted USDC pool record. ChangesEarnGrid Base adaptor
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized adapter addition has no actionable merge-blocking risk remaining and is merge-ready after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant EarnGridAdaptor
participant BaseRPC
participant MorphoBlueGraphQL
participant USDCPriceSource
EarnGridAdaptor->>BaseRPC: Fetch vault assets, receipt supply, and strategy balances
EarnGridAdaptor->>MorphoBlueGraphQL: Fetch MetaMorpho net APYs
EarnGridAdaptor->>USDCPriceSource: Fetch USDC price
BaseRPC-->>EarnGridAdaptor: Return on-chain data
MorphoBlueGraphQL-->>EarnGridAdaptor: Return APY data or failure
USDCPriceSource-->>EarnGridAdaptor: Return USDC price
EarnGridAdaptor->>EarnGridAdaptor: Calculate allocations, weighted APY, idle balance, and price per share
EarnGridAdaptor-->>EarnGridAdaptor: Return formatted USDC pool record
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 earngrid adapter: ● Running earngrid Test › Adapter exports the protocolId matching its protocol slug |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/earngrid/index.js`:
- Around line 145-150: Update the protocolId value in the exported adapter
metadata object to the required inline slug "8384", preserving the other fields
such as timetravel, apy, and url.
- Around line 115-126: Update the weighted APY calculation in the allocations
reduction to divide by totalAssets instead of totalBalance, so idle USDC
represented by idle is included in the vault return denominator. Preserve the
existing positive-total guard and apyBase fallback behavior.
- Around line 85-91: Update the strategy balance-fetch flow in the STRATEGIES
map to convert each MetaMorpho share balance returned by abiBalanceOf into USDC
assets using convertToAssets before calculating balance, idle, or apyBase.
Preserve the existing per-strategy allocation calculations while ensuring they
consume asset-denominated values.
🪄 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: 9f470e83-1e9b-4db9-b63c-0619afae8f18
📒 Files selected for processing (1)
src/adaptors/earngrid/index.js
| const strategyBalanceCalls = STRATEGIES.map((s) => | ||
| sdk.api.abi.call({ | ||
| chain: CHAIN, | ||
| target: s.morphoVault, | ||
| abi: abiBalanceOf, | ||
| params: [VAULT], | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
RPC='https://mainnet.base.org'
VAULT='8694d7d44309665d51cb5002fcec0454f1c233de'
STRATEGY='ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61'
rpc_call() {
curl -sS "$RPC" \
-H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_call\",\"params\":[{\"to\":\"0x$1\",\"data\":\"$2\"},\"latest\"]}" |
jq -r '.result'
}
shares="$(rpc_call "$STRATEGY" "0x70a08231000000000000000000000000$VAULT")"
assets="$(rpc_call "$STRATEGY" "0x07a2d13a${shares#0x}")"
printf 'shares=%s\nassets=%s\n' "$shares" "$assets"Repository: DefiLlama/yield-server
Length of output: 308
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- target file ---'
sed -n '1,180p' src/adaptors/earngrid/index.js
printf '%s\n' '--- related symbols and protocol ID usage ---'
rg -n -C 3 'earngrid|protocolId|morphoVault|abiBalanceOf|convertToAssets|apyBase|idle' src/adaptors/earngrid src 2>/dev/null | head -300Repository: DefiLlama/yield-server
Length of output: 21038
🏁 Script executed:
#!/bin/bash
set -euo pipefail
RPC='https://mainnet.base.org'
VAULT='8694d7d44309665d51cb5002fcec0454f1c233de'
STRATEGIES=(
'ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61'
'beefe94c8ad530842bfe7d8b397938ffc1cb83b2'
'c1256ae5ff1cf2719d4937adb3bbccab2e00a2ca'
'236919f11ff9ea9550a4287696c2fc9e18e6e890'
'beefa7b88064feef0cee02aae bb d95d30df3878f'
)
# Remove the visual separator in the last address.
STRATEGIES[4]='beefa7b88064feef0cee02a aebb d95d30df3878f'
STRATEGIES[4]="${STRATEGIES[4]// /}"
call() {
local to="$1" data="$2"
curl -sS "$RPC" -H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_call\",\"params\":[{\"to\":\"0x$to\",\"data\":\"0x$data\"},\"latest\"]}" |
jq -r 'if .error then ("ERROR: " + (.error.message // "unknown")) else (.result // "NO_RESULT") end'
}
encode_address() { printf '%064s' "$1" | tr ' ' '0'; }
encode_uint() { printf '%064s' "${1#0x}" | tr ' ' '0'; }
printf 'strategy,code_bytes,decimals,totalAssets,balanceOf,convertToAssets,previewRedeem\n'
for strategy in "${STRATEGIES[@]}"; do
code="$(curl -sS "$RPC" -H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_getCode\",\"params\":[\"0x$strategy\",\"latest\"]}" |
jq -r '.result')"
shares="$(call "$strategy" "70a08231$(encode_address "$VAULT")")"
total="$(call "$strategy" "01e1d114")"
decimals="$(call "$strategy" "313ce567")"
if [[ "$shares" == 0x* && "$shares" != *ERROR* ]]; then
assets="$(call "$strategy" "07a2d13a$(encode_uint "$shares")")"
preview="$(call "$strategy" "ಿಂಗ")"
else
assets='not queried'
preview='not queried'
fi
# previewRedeem(uint256) selector is 4b3c5f3f.
if [[ "$shares" == 0x* && "$shares" != *ERROR* ]]; then
preview="$(call "$strategy" "4b3c5f3f$(encode_uint "$shares")")"
fi
bytes=$(( (${`#code`#0x} - 2) / 2 ))
printf '%s,%s,%s,%s,%s,%s,%s\n' "$strategy" "$bytes" "$decimals" "$total" "$shares" "$assets" "$preview"
doneRepository: DefiLlama/yield-server
Length of output: 298
🏁 Script executed:
#!/bin/bash
set -euo pipefail
RPC='https://mainnet.base.org'
VAULT='8694d7d44309665d51cb5002fcec0454f1c233de'
STRATEGIES=(
'ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61'
'beefe94c8ad530842bfe7d8b397938ffc1cb83b2'
'c1256ae5ff1cf2719d4937adb3bbccab2e00a2ca'
'236919f11ff9ea9550a4287696c2fc9e18e6e890'
'beefa7b88064feef0cee02aaebbd95d30df3878f'
)
call() {
local to="$1" data="$2"
curl -sS "$RPC" -H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_call\",\"params\":[{\"to\":\"0x$to\",\"data\":\"0x$data\"},\"latest\"]}" |
jq -r 'if .error then ("ERROR: " + (.error.message // "unknown")) else (.result // "NO_RESULT") end'
}
encode_address() {
printf '%064s' "$1" | tr ' ' '0'
}
encode_uint() {
printf '%064s' "${1#0x}" | tr ' ' '0'
}
printf 'strategy,code_bytes,decimals,totalAssets,balanceOf,convertToAssets,previewRedeem\n'
for strategy in "${STRATEGIES[@]}"; do
code="$(curl -sS "$RPC" -H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_getCode\",\"params\":[\"0x$strategy\",\"latest\"]}" |
jq -r '.result')"
shares="$(call "$strategy" "70a08231$(encode_address "$VAULT")")"
total="$(call "$strategy" "01e1d114")"
decimals="$(call "$strategy" "313ce567")"
assets='not queried'
preview='not queried'
if [[ "$shares" == 0x* ]]; then
assets="$(call "$strategy" "07a2d13a$(encode_uint "$shares")")"
preview="$(call "$strategy" "4b3c5f3f$(encode_uint "$shares")")"
fi
bytes=$(( (${`#code`#0x} - 2) / 2 ))
printf '%s,%s,%s,%s,%s,%s,%s\n' \
"$strategy" "$bytes" "$decimals" "$total" "$shares" "$assets" "$preview"
doneRepository: DefiLlama/yield-server
Length of output: 298
🏁 Script executed:
#!/bin/bash
set -euo pipefail
RPC='https://mainnet.base.org'
VAULT='8694d7d44309665d51cb5002fcec0454f1c233de'
STRATEGIES=(
'ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61'
'beefe94c8ad530842bfe7d8b397938ffc1cb83b2'
'c1256ae5ff1cf2719d4937adb3bbccab2e00a2ca'
'236919f11ff9ea9550a4287696c2fc9e18e6e890'
'beefa7b88064feef0cee02aaebbd95d30df3878f'
)
call() {
local to="$1" data="$2"
curl -sS "$RPC" -H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_call\",\"params\":[{\"to\":\"0x$to\",\"data\":\"0x$data\"},\"latest\"]}" |
jq -r 'if .error then ("ERROR: " + (.error.message // "unknown")) else (.result // "NO_RESULT") end'
}
encode_address() {
printf '%064s' "$1" | tr ' ' '0'
}
encode_uint() {
printf '%064s' "${1#0x}" | tr ' ' '0'
}
printf 'strategy,code_bytes,decimals,totalAssets,balanceOf,convertToAssets,previewRedeem\n'
for strategy in "${STRATEGIES[@]}"; do
code="$(curl -sS "$RPC" -H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_getCode\",\"params\":[\"0x$strategy\",\"latest\"]}" |
jq -r '.result')"
shares="$(call "$strategy" "70a08231$(encode_address "$VAULT")")"
total="$(call "$strategy" "01e1d114")"
decimals="$(call "$strategy" "313ce567")"
assets='not queried'
preview='not queried'
if [[ "$shares" == 0x* ]]; then
assets="$(call "$strategy" "07a2d13a$(encode_uint "$shares")")"
preview="$(call "$strategy" "4b3c5f3f$(encode_uint "$shares")")"
fi
code_hex_len=${`#code`}
code_bytes=$(( (code_hex_len - 2) / 2 ))
printf '%s,%s,%s,%s,%s,%s,%s\n' \
"$strategy" "$code_bytes" "$decimals" "$total" "$shares" "$assets" "$preview"
doneRepository: DefiLlama/yield-server
Length of output: 1183
🏁 Script executed:
#!/bin/bash
set -euo pipefail
RPC='https://mainnet.base.org'
VAULT='8694d7d44309665d51cb5002fcec0454f1c233de'
STRATEGIES=(
'ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61'
'beefe94c8ad530842bfe7d8b397938ffc1cb83b2'
'c1256ae5ff1cf2719d4937adb3bbccab2e00a2ca'
'236919f11ff9ea9550a4287696c2fc9e18e6e890'
'beefa7b88064feef0cee02aaebbd95d30df3878f'
)
call() {
local to="$1" data="$2"
curl -sS "$RPC" -H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_call\",\"params\":[{\"to\":\"0x$to\",\"data\":\"0x$data\"},\"latest\"]}" |
jq -r 'if .error then ("ERROR: " + (.error.message // "unknown")) else (.result // "NO_RESULT") end'
}
encode_address() { printf '%064s' "$1" | tr ' ' '0'; }
encode_uint() { printf '%064s' "${1#0x}" | tr ' ' '0'; }
printf 'strategy,code_bytes,decimals,totalAssets,balanceOf,convertToAssets,previewRedeem\n'
for strategy in "${STRATEGIES[@]}"; do
code="$(curl -sS "$RPC" -H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_getCode\",\"params\":[\"0x$strategy\",\"latest\"]}" |
jq -r '.result')"
shares="$(call "$strategy" "70a08231$(encode_address "$VAULT")")"
total="$(call "$strategy" "01e1d114")"
decimals="$(call "$strategy" "313ce567")"
assets='not queried'
preview='not queried'
if [[ "$shares" == 0x* ]]; then
assets="$(call "$strategy" "07a2d13a$(encode_uint "$shares")")"
preview="$(call "$strategy" "4b3c5f3f$(encode_uint "$shares")")"
fi
code_bytes=$(( (${`#code`} - 2) / 2 ))
printf '%s,%s,%s,%s,%s,%s,%s\n' \
"$strategy" "$code_bytes" "$decimals" "$total" "$shares" "$assets" "$preview"
doneRepository: DefiLlama/yield-server
Length of output: 1139
🏁 Script executed:
python3 - <<'PY'
import json
import urllib.request
rpc = "https://mainnet.base.org"
vault = "8694d7d44309665d51cb5002fcec0454f1c233de"
strategies = [
"ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61",
"beefe94c8ad530842bfe7d8b397938ffc1cb83b2",
"c1256ae5ff1cf2719d4937adb3bbccab2e00a2ca",
"236919f11ff9ea9550a4287696c2fc9e18e6e890",
"beefa7b88064feef0cee02aaebbd95d30df3878f",
]
def word(value):
return value.removeprefix("0x").rjust(64, "0")
calls = []
labels = []
for strategy in strategies:
for label, selector, arg in [
("decimals", "313ce567", ""),
("asset", "38d52e0f", ""),
("totalAssets", "01e1d114", ""),
("totalSupply", "18160ddd", ""),
("balanceOf", "70a08231", word(vault)),
]:
calls.append({
"jsonrpc": "2.0",
"id": len(calls) + 1,
"method": "eth_call",
"params": [{"to": "0x" + strategy, "data": "0x" + selector + arg}, "latest"],
})
labels.append((strategy, label))
# Use one HTTP request to avoid per-call rate limiting.
request = urllib.request.Request(
rpc,
data=json.dumps(calls).encode(),
headers={"content-type": "application/json"},
)
with urllib.request.urlopen(request, timeout=30) as response:
results = {item["id"]: item for item in json.load(response)}
for index, (strategy, label) in enumerate(labels, start=1):
item = results[index]
if "error" in item:
value = "ERROR: " + item["error"].get("message", "unknown")
else:
raw = item.get("result")
try:
value = f"{int(raw, 16)} ({raw})"
except (TypeError, ValueError):
value = raw
print(f"{strategy},{label},{value}")
PYRepository: DefiLlama/yield-server
Length of output: 2447
🏁 Script executed:
python3 - <<'PY'
import json
import urllib.request
rpc = "https://mainnet.base.org"
vault = "8694d7d44309665d51cb5002fcec0454f1c233de"
strategies = [
"ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61",
"beefe94c8ad530842bfe7d8b397938ffc1cb83b2",
"c1256ae5ff1cf2719d4937adb3bbccab2e00a2ca",
"236919f11ff9ea9550a4287696c2fc9e18e6e890",
"beefa7b88064feef0cee02aae bbd95d30df3878f".replace(" ", ""),
]
def word(value):
return value.removeprefix("0x").rjust(64, "0")
calls = []
labels = []
for strategy in strategies:
for label, selector, arg in [
("decimals", "313ce567", ""),
("asset", "38d52e0f", ""),
("totalAssets", "01e1d114", ""),
("totalSupply", "18160ddd", ""),
("balanceOf", "70a08231", word(vault)),
]:
calls.append({
"jsonrpc": "2.0",
"id": len(calls) + 1,
"method": "eth_call",
"params": [{"to": "0x" + strategy, "data": "0x" + selector + arg}, "latest"],
})
labels.append((strategy, label))
request = urllib.request.Request(
rpc,
data=json.dumps(calls).encode(),
headers={"content-type": "application/json"},
)
with urllib.request.urlopen(request, timeout=30) as response:
results = {item["id"]: item for item in json.load(response)}
for index, (strategy, label) in enumerate(labels, start=1):
item = results[index]
if "error" in item:
value = "ERROR: " + item["error"].get("message", "unknown")
else:
raw = item.get("result")
try:
value = f"{int(raw, 16)} ({raw})"
except (TypeError, ValueError):
value = raw
print(f"{strategy},{label},{value}")
PYRepository: DefiLlama/yield-server
Length of output: 2447
🏁 Script executed:
python3 - <<'PY' >/tmp/base-batch.json
import json
vault = "8694d7d44309665d51cb5002fcec0454f1c233de"
strategies = [
"ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61",
"beefe94c8ad530842bfe7d8b397938ffc1cb83b2",
"c1256ae5ff1cf2719d4937adb3bbccab2e00a2ca",
"236919f11ff9ea9550a4287696c2fc9e18e6e890",
"beefa7b88064feef0cee02aaebbd95d30df3878f",
]
def word(value):
return value.removeprefix("0x").rjust(64, "0")
calls = []
labels = []
for strategy in strategies:
for label, selector, arg in [
("decimals", "313ce567", ""),
("asset", "38d52e0f", ""),
("totalAssets", "01e1d114", ""),
("totalSupply", "18160ddd", ""),
("balanceOf", "70a08231", word(vault)),
]:
calls.append({
"jsonrpc": "2.0",
"id": len(calls) + 1,
"method": "eth_call",
"params": [{"to": "0x" + strategy, "data": "0x" + selector + arg}, "latest"],
})
labels.append((strategy, label))
print(json.dumps(calls))
PY
curl -sS -k 'https://mainnet.base.org' \
-H 'content-type: application/json' \
--data-binary `@/tmp/base-batch.json` |
python3 -c '
import json, sys
strategies = [
"ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61",
"beefe94c8ad530842bfe7d8b397938ffc1cb83b2",
"c1256ae5ff1cf2719d4937adb3bbccab2e00a2ca",
"236919f11ff9ea9550a4287696c2fc9e18e6e890",
"beefa7b88064feef0cee02aae bbd95d30df3878f".replace(" ", ""),
]
labels = ["decimals", "asset", "totalAssets", "totalSupply", "balanceOf"]
items = {x["id"]: x for x in json.load(sys.stdin)}
for i, strategy in enumerate(strategies):
for j, label in enumerate(labels):
item = items[i * 5 + j + 1]
if "error" in item:
value = "ERROR: " + item["error"].get("message", "unknown")
else:
raw = item.get("result")
try:
value = f"{int(raw, 16)} ({raw})"
except (TypeError, ValueError):
value = raw
print(f"{strategy},{label},{value}")
'Repository: DefiLlama/yield-server
Length of output: 320
🏁 Script executed:
curl -sS -k 'https://base.publicnode.com' \
-H 'content-type: application/json' \
--data '{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"0xee8f4ec5672f09119b96ab6fb59c27e1b7e44b61","data":"0x07a2d13a000000000000000000000000000000000000000000000000000000bbf4dca14e"},"latest"]}' |
jq .Repository: DefiLlama/yield-server
Length of output: 276
🏁 Script executed:
#!/bin/bash
set -euo pipefail
RPC='https://base.publicnode.com'
VAULT='8694d7d44309665d51cb5002fcec0454f1c233de'
STRATEGY='ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61'
call() {
curl -sS -k "$RPC" \
-H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_call\",\"params\":[{\"to\":\"0x$STRATEGY\",\"data\":\"0x$1\"},\"latest\"]}" |
jq -r 'if .error then ("ERROR: " + (.error.message // "unknown")) else .result end'
}
address_word="$(printf '%064s' "$VAULT" | tr ' ' '0')"
shares="$(call "70a08231$address_word")"
shares_word="${shares#0x}"
shares_word="$(printf '%064s' "$shares_word" | tr ' ' '0')"
printf 'decimals=%s\n' "$(call '313ce567')"
printf 'asset=%s\n' "$(call '38d52e0f')"
printf 'totalAssets=%s\n' "$(call '01e1d114')"
printf 'totalSupply=%s\n' "$(call '18160ddd')"
printf 'balanceOf=%s\n' "$shares"
printf 'convertToAssets=%s\n' "$(call "07a2d13a$shares_word")"
printf 'previewRedeem=%s\n' "$(call "4b3c5f3f$shares_word")"Repository: DefiLlama/yield-server
Length of output: 667
🏁 Script executed:
#!/bin/bash
set -euo pipefail
RPC='https://base.publicnode.com'
VAULT='8694d7d44309665d51cb5002fcec0454f1c233de'
STRATEGY='ee8f4ec5672f09119b96ab6fb59c27e1b7e44b61'
call() {
curl -sS -k "$RPC" \
-H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_call\",\"params\":[{\"to\":\"0x$STRATEGY\",\"data\":\"0x$1\"},\"latest\"]}" |
jq -r 'if .error then ("ERROR: " + (.error.message // "unknown")) else .result end'
}
address_word="$(printf '%064s' "$VAULT" | tr ' ' '0')"
shares="$(call "70a08231$address_word")"
shares_word="$(printf '%064s' "${shares#0x}" | tr ' ' '0')"
printf 'decimals=%s\n' "$(call '313ce567')"
printf 'asset=%s\n' "$(call '38d52e0f')"
printf 'totalAssets=%s\n' "$(call '01e1d114')"
printf 'totalSupply=%s\n' "$(call '18160ddd')"
printf 'balanceOf=%s\n' "$shares"
printf 'convertToAssets=%s\n' "$(call "07a2d13a$shares_word")"
printf 'previewRedeem=%s\n' "$(call "4b3c5f3f$shares_word")"Repository: DefiLlama/yield-server
Length of output: 667
🏁 Script executed:
python3 - <<'PY'
from decimal import Decimal, getcontext
getcontext().prec = 40
total_assets = int("182da02e8e33c", 16)
total_supply = int("13ddad2d3e32697812c5ca6", 16)
shares = int("bbf4dca14e", 16)
print("totalAssets_raw =", total_assets)
print("totalSupply_raw =", total_supply)
print("balanceOf_raw =", shares)
print("adapter_balance =", Decimal(shares) / Decimal(10**6))
print("share_units =", Decimal(shares) / Decimal(10**18))
print("proportional_assets_raw =", Decimal(shares) * Decimal(total_assets) / Decimal(total_supply))
print("proportional_assets_usdc =", Decimal(shares) * Decimal(total_assets) / Decimal(total_supply) / Decimal(10**6))Repository: DefiLlama/yield-server
Length of output: 564
Convert MetaMorpho shares to USDC assets before allocation.
balanceOf(VAULT) returns 18-decimal shares, but the adapter treats them as 6-decimal USDC. Call convertToAssets(balanceOf(VAULT)) for each strategy before calculating balance, idle, and apyBase; otherwise the allocation is overstated by the unit mismatch.
🤖 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/earngrid/index.js` around lines 85 - 91, Update the strategy
balance-fetch flow in the STRATEGIES map to convert each MetaMorpho share
balance returned by abiBalanceOf into USDC assets using convertToAssets before
calculating balance, idle, or apyBase. Preserve the existing per-strategy
allocation calculations while ensuring they consume asset-denominated values.
|
The earngrid adapter exports pools: Test Suites: 1 passed, 1 total |
|
The earngrid adapter exports pools: Test Suites: 1 passed, 1 total |
|
Can we try this one here, thanks. @RohanNero |
0xkr3p
left a comment
There was a problem hiding this comment.
hi @NukeThemAII, thanks for your PR. We have a 10K TVL threshold on our yields and earn-grid pool is $220, pls give me a ping when TVL reaches near 10K until then I will review
…o shares 1e18, bvUSDC shares 1e12)
|
Updated for the v2 redeploy:
TVL still below the 10K threshold — no rush on review, just keeping the adapter current and CI-green. |
|
The earngrid adapter exports pools: Test Suites: 1 passed, 1 total |
thanks for the update.. i've switched the PR to draft, pls change it back once ready |
Description
Adds EarnGrid yield adapter. EarnGrid is a USDC yield vault on Base (ERC-4626) that aggregates MetaMorpho strategies.
The adapter reads:
totalAssets()from the vault for TVLbalanceOf()Already listed in DeFiLlama TVL via ERC-4626 registry.
Summary by CodeRabbit