BAiSEDagent

defi-strategies

0
0
# Install this skill:
npx skills add BAiSEDagent/openclaw-skills --skill "defi-strategies"

Install specific skill from multi-skill repository

# Description

DeFi yield strategies on Base. Liquidity provision, yield farming, auto-compounding, impermanent loss. Use when building or evaluating yield strategies.

# SKILL.md


name: defi-strategies
description: "DeFi yield strategies on Base. Liquidity provision, yield farming, auto-compounding, impermanent loss. Use when building or evaluating yield strategies."
metadata:
openclaw:
emoji: "💱"


DeFi Strategies on Base

Yield-generating strategies using Base DeFi protocols.

Strategy Overview

Strategy APY Range Risk Complexity
USDC Lending 3-8% Low Simple
LP (Stable pairs) 5-15% Low-Med Medium
LP (Volatile pairs) 10-50% Medium Medium
Concentrated LP 20-100%+ High High
Recursive Lending 5-20% Medium High
Yield Farming Variable Medium-High Medium

1. Liquidity Provision (Uniswap V3)

Concentrated Liquidity

// Provide liquidity in a specific price range
const position = await nonfungiblePositionManager.mint({
  token0: USDC_ADDRESS,
  token1: WETH_ADDRESS,
  fee: 500,                    // 0.05% pool
  tickLower: nearestUsableTick(currentTick - 1000, 10),
  tickUpper: nearestUsableTick(currentTick + 1000, 10),
  amount0Desired: parseUnits('500', 6),   // 500 USDC
  amount1Desired: parseEther('0.2'),       // 0.2 ETH
  amount0Min: 0n,
  amount1Min: 0n,
  recipient: AGENT_ADDRESS,
  deadline: Math.floor(Date.now() / 1000) + 300,
});

Impermanent Loss

// IL calculation for 50/50 pool
function impermanentLoss(priceRatio: number): number {
  // priceRatio = new_price / entry_price
  return 2 * Math.sqrt(priceRatio) / (1 + priceRatio) - 1;
}

// Examples:
// Price 2x → IL = -5.7%
// Price 0.5x → IL = -5.7%
// Price 5x → IL = -25.5%
// Price 0.2x → IL = -25.5%

When to LP

  • ✅ Stable pairs (USDC/USDT): minimal IL, steady fees
  • ✅ Correlated pairs (ETH/cbETH): low IL
  • ⚠️ Volatile pairs: fees must exceed IL
  • ❌ Low-volume pairs: insufficient fee income

2. Aerodrome (Base-Native DEX)

// Aerodrome uses ve(3,3) model — lock AERO for voting power
// Vote to direct emissions to pools you LP in
// Higher emissions = higher APY for your LP

// Deposit LP
await aerodromeRouter.addLiquidity(
  tokenA, tokenB, stable, amountA, amountB, minA, minB, AGENT_ADDRESS, deadline
);

// Stake LP for AERO rewards
await aerodromeGauge.deposit(lpAmount);

// Claim rewards
await aerodromeGauge.getReward(AGENT_ADDRESS);

3. Lending Yield (Aave/Moonwell)

// Simple USDC lending
await aavePool.supply(USDC_ADDRESS, amount, AGENT_ADDRESS, 0);

// Check current APY
const reserveData = await aavePool.getReserveData(USDC_ADDRESS);
const supplyAPY = Number(reserveData.currentLiquidityRate) / 1e25; // Ray to percent

4. Auto-Compounding

async function autoCompound() {
  // 1. Claim rewards
  const rewards = await gauge.getReward(AGENT_ADDRESS);

  // 2. Swap rewards to LP tokens
  const half = rewards / 2n;
  await swap(AERO, USDC, half);
  await swap(AERO, WETH, rewards - half);

  // 3. Add liquidity
  await router.addLiquidity(USDC, WETH, ...);

  // 4. Re-stake
  await gauge.deposit(newLpAmount);
}

// Run daily or when rewards exceed gas cost * 10

Yield Evaluation Framework

interface YieldOpportunity {
  protocol: string;
  pool: string;
  baseAPY: number;      // Trading fees
  rewardAPY: number;    // Token incentives
  totalAPY: number;
  tvl: bigint;          // Total value locked
  ilRisk: 'low' | 'medium' | 'high';
  smartContractRisk: 'audited' | 'unaudited' | 'battle-tested';
}

function shouldInvest(opp: YieldOpportunity, minAPY: number): boolean {
  return opp.totalAPY >= minAPY
    && opp.smartContractRisk !== 'unaudited'
    && opp.tvl > parseUnits('100000', 6); // >$100k TVL
}

Safety Rules

  • ⚠️ Only use audited protocols (Aave, Uniswap, Aerodrome, Moonwell)
  • ⚠️ Start small — test with <$50, scale with confidence
  • ⚠️ Monitor IL — exit if IL exceeds fee income
  • ⚠️ Reward token risk — farming rewards may lose value
  • ⚠️ Human approval for any strategy deployment >$100

Cross-References

  • spot-trading: Swap execution for rebalancing
  • leverage-trading: Recursive lending strategies
  • agent-wallet-management: Fund allocation
  • monitoring-alerting: APY and position monitoring

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.