Phase 5 — Compare Protocols
Expand the scanner to compare yield across the entire Sui ecosystem — not just Cetus. The agent compares trading pool returns (higher risk, higher return) against lending protocol returns (lower risk, simpler).
Time: ~5 minutes | Requires: Phase 4 complete
The idea
Providing liquidity on Cetus is one way to earn yield on Sui. But you could also:
- Lend SUI or USDC on NAVI, Scallop, or Kai Finance — lower return, but much simpler and lower risk
- Provide liquidity on Bluefin, FlowX, or Full Sail — different DEXes, sometimes higher returns
The agent already fetches DeFiLlama data. We just need to extract more protocols.
Update the yield scanner
Extend the scanYields() function from Phase 4:
async function scanYields() {
try {
const allPools = await fetchDefiLlamaYields();
const suiPools = allPools.filter(p => p.chain === 'Sui');
// Phase 4: Top Cetus pools (already implemented)
const cetusPools = suiPools
.filter(p => p.project === 'cetus-clmm')
.sort((a, b) => (b.apy || 0) - (a.apy || 0))
.slice(0, 10)
.map(p => ({ symbol: p.symbol, apy: parseFloat((p.apy || 0).toFixed(2)), tvl: Math.round(p.tvlUsd || 0) }));
// Phase 5: Cross-protocol comparison
const protocols = {};
for (const p of suiPools) {
if (!protocols[p.project]) protocols[p.project] = [];
protocols[p.project].push(p);
}
const crossProtocol = [];
// Lending protocols — find best SUI and USDC lending rates
for (const proj of ['navi-lending', 'scallop-lend', 'current', 'kai-finance']) {
const pools = protocols[proj] || [];
for (const asset of ['SUI', 'HASUI', 'USDC']) {
const pool = pools.find(p => p.symbol === asset);
if (pool) {
crossProtocol.push({
protocol: proj, type: 'lending', asset: pool.symbol,
apy: parseFloat((pool.apy || 0).toFixed(2)),
tvl: Math.round(pool.tvlUsd || 0),
});
}
}
}
// Other DEX pools — find best SUI/USDC pool per DEX
for (const proj of ['cetus-clmm', 'bluefin-spot', 'turbos', 'flowx-v3', 'full-sail']) {
const pools = protocols[proj] || [];
const suiUsdc = pools.find(p => (p.symbol || '').match(/SUI.*USDC|USDC.*SUI/i));
if (suiUsdc) {
crossProtocol.push({
protocol: proj, type: 'lp', asset: suiUsdc.symbol,
apy: parseFloat((suiUsdc.apy || 0).toFixed(2)),
tvl: Math.round(suiUsdc.tvlUsd || 0),
});
}
}
crossProtocol.sort((a, b) => b.apy - a.apy);
const ourPool = suiPools.find(p => p.project === 'cetus-clmm' && (p.symbol || '').match(/USDC.*SUI|SUI.*USDC/i));
log('event', 'yield_scan', {
cetusTopPools: cetusPools,
crossProtocol,
currentPool: {
symbol: 'SUI/USDC', protocol: 'cetus-clmm',
apy: ourPool ? parseFloat((ourPool.apy || 0).toFixed(2)) : null,
tvl: ourPool ? Math.round(ourPool.tvlUsd || 0) : null,
},
bestAlternative: crossProtocol[0] || null,
scanTime: new Date().toISOString(),
});
} catch (err) {
log('warn', 'Yield scan failed', { error: err.message });
}
}What it logs
The yield_scan event now includes cross-protocol data:
{
"crossProtocol": [
{ "protocol": "flowx-v3", "type": "lp", "asset": "SUI-USDC", "apy": 32.7, "tvl": 55270 },
{ "protocol": "bluefin-spot", "type": "lp", "asset": "SUI-USDC", "apy": 32.6, "tvl": 3270836 },
{ "protocol": "cetus-clmm", "type": "lp", "asset": "USDC-SUI", "apy": 24.3, "tvl": 1488269 },
{ "protocol": "kai-finance", "type": "lending", "asset": "SUI", "apy": 6.2, "tvl": 3710052 },
{ "protocol": "scallop-lend", "type": "lending", "asset": "SUI", "apy": 2.9, "tvl": 3359492 }
],
"bestAlternative": { "protocol": "flowx-v3", "type": "lp", "asset": "SUI-USDC", "apy": 32.7 }
}Reading the data
Two categories to compare:
Trading pools (Cetus, Bluefin, FlowX, etc.) — Higher returns but:
- Impermanent loss: if token prices change, you may end up with less value than just holding
- Requires active management (repositioning)
- Gas costs for each reposition
Lending protocols (NAVI, Scallop, Kai) — Lower returns but:
- No impermanent loss
- No repositioning needed — deposit and earn
- Simpler to understand and manage
The right choice depends on your risk tolerance and how actively you want to manage the agent.
What’s next
You now have a complete yield agent: monitoring, trading, optimizing, and comparing across the Sui ecosystem. Future extensions:
- Auto-migration: Agent automatically moves funds to the highest risk-adjusted yield
- Multi-asset: Manage positions in multiple pools simultaneously
- Risk management: Stop-loss if portfolio value drops below a threshold
- Dashboard: Visualize all this data in a web UI (see the dogfood dashboard for an example)
Related
- WaaP for Agents — CLI reference
- Morpho Yield Optimizer — Similar yield strategy on EVM
- Polymarket Agent — Trading agent on Polygon