feat: add best-rate lending router action provider#2
Conversation
Cross-protocol lending router that compares live supply/borrow APY across Compound III, Aave v3, Moonwell, and Morpho Blue on Base mainnet (8453), then routes deposits and borrows to the optimal venue. Actions: - compare_lending_rates: Read live APY from all 4 protocols, rank best-first - get_aggregated_position: Cross-protocol portfolio view with health factors - route_supply: Auto-route supply to best-rate venue (all 4 protocols) - route_borrow: Auto-route borrow to cheapest venue (Compound/Aave v1) - rebalance: Advisory rebalance plan when rates drift v1 limitations: borrow routing is Compound/Aave only; Morpho position tracking is minimal; rebalance is advisory. https://claude.ai/code/session_01H9og3kM8YwPCcUCHnDxTxw
|
@claude start review |
|
Claude finished @zaryab2000's task in 2m 45s —— View job Code Review —
|
| Requirement | Status |
|---|---|
Actions return Promise<string> |
✅ |
| Errors returned, not thrown | ✅ |
Zod v4 .describe() on every field, no .strip() |
✅ |
supportsNetwork correct (Base mainnet only) |
✅ |
Factory exported + re-exported from index.ts |
✅ |
Per-provider README.md |
✅ |
| Changeset (patch, past tense) | ✅ |
pnpm test / pnpm build / lint / format passing |
✅ (per PR) |
Summary: 3 of the 6 critical issues (#1 Compound multi-market, #2 Moonwell decimals, coinbase#6 Morpho address cast) are correctness bugs that produce wrong outputs or would cause runtime failures for non-USDC assets or future Morpho execution. These should be fixed before merging. Issues #3 (health factor comparability) and #5 (rebalance reads positions, not just rates) are design-level and worth addressing even if they require a bit more work.
…h checks - Replace single COMPOUND_COMET_ADDRESS with COMPOUND_COMET_ADDRESSES map (USDC + WETH Comets) - Fix executeSupply/executeBorrow to look up correct Comet by asset symbol - Add Compound health pre-check in routeBorrow alongside existing Aave check - Rewrite rebalance to read user positions and compare against current protocol rate - Fix RateResult.marketAddress → marketId (string, not Address — supports Morpho bytes32) - Add PositionResult.healthComparable flag; skip non-comparable in findLowestHealth - Fix encodeMoonwellMint signature (remove unused mToken param) - Fix Moonwell position to use per-token decimals and non-comparable health - Fix Morpho position user param type and add healthComparable: false - Fix cbeth/cbbtc mToken addresses in constants - Update tests for multi-Comet mocks and position-aware rebalance https://claude.ai/code/session_01H9og3kM8YwPCcUCHnDxTxw
|
@claude review the fixes |
|
Claude finished @zaryab2000's task in 1m 59s —— View job Fix Review —
|
Summary
lendingRouter— a cross-protocol lending router for Base mainnet (chain ID8453)compare_lending_rates,get_aggregated_position,route_supply,route_borrow,rebalanceWhat's included
lendingRouterActionProvider.ts@CreateActionmethodsschemas.ts.describe()on every fieldconstants.tsadapters/compound.tsadapters/aave.tsadapters/moonwell.tsadapters/morpho.tsutils.tslendingRouterActionProvider.test.tsindex.tsREADME.mdv1 Protocol Coverage
v1 Limitations
chainId === "8453")Test plan
pnpm build— cleanpnpm test— 29/29 passedpnpm run lint— cleanpnpm run format— cleansrc/action-providers/index.tssupportsNetworkreturns true only for Base mainnetPromise<string>; errors returned not thrown.describe()on every field, no.strip()https://claude.ai/code/session_01H9og3kM8YwPCcUCHnDxTxw
Generated by Claude Code