skill-03-defi-operations
Skill2 starsChanged 6 months agoMITView on GitHub
Executes DeFi operations including token swaps, lending/borrowing, staking, liquidity provision, flash loans, perpetuals, and vault strategies. Use when interacting with Uniswap, Aave, Compound, Lido, or other DeFi protocols.
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/00-web3-agent-core.mdcCursor rule
- .cursor/rules/10-guardrails-first.mdcCursor rule
- .cursor/rules/20-chain-preset-selector.mdcCursor rule
- .cursor/rules/30-simulate-before-send.mdcCursor rule
- skill-01-wallet-managementSkill
- skill-02-smart-contract-interactionSkill
- skill-04-nft-managementSkill
- skill-05-dao-governanceSkill
- skill-06-cross-chain-bridgeSkill
- skill-07-token-analyticsSkill
- skill-08-security-auditSkill
- skill-09-compliance-amlSkill
- skill-10-identity-didSkill
- skill-11-oracle-data-feedsSkill
- skill-12-gas-optimizationSkill
- skill-13-rwa-tokenizationSkill
- skill-14-social-reputationSkill
- skill-15-mev-protectionSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Check price impact (< 1% for large trades.
- Distinctive: line 33
Verify router address against known-good list
- Distinctive: line 46
Always maintain health factor buffer.
- Distinctive: line 52
Liquid staking: verify validator set and slashing risk
- Very specific: line 58
Use defi-protocol-server for current pool APR/TVL
- Distinctive: line 65
Never use flash loans for unbounded external calls
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
DeFi Operations
When to Use
- Swapping tokens on DEXs (Uniswap, Curve, 1inch)
- Lending/borrowing (Aave, Compound, Morpho)
- Staking (Lido stETH, EigenLayer restaking)
- Providing/removing liquidity (Uniswap V3, Curve)
- Flash loans (Aave, Balancer, dYdX)
- Perpetual trading (GMX, dYdX v4)
- Yield vaults (Yearn, ERC-4626 vaults)
Prerequisites
- MCP:
blockchain-rpc-server,defi-protocol-server,price-feed-server - Skills: skill-02 (contract calls), skill-12 (gas), skill-15 (MEV for swaps)
- Guardrails: simulate all txs; screen counterparties
Workflow
1. Swap
- Get quote from
defi-protocol-serveror 1inch API - Check price impact (< 1% for large trades; use TWAP if higher — skill-15)
- Verify router address against known-good list
- Set slippage tolerance (default 0.5%, max 3% without confirmation)
- Approve exact amount (never unlimited without explicit user consent)
- Execute swap; verify received amount ≥ minOut
2. Lend / Borrow
| Protocol | Supply | Borrow | Liquidation Threshold |
| Aave V3 | supply() | borrow() | Health factor > 1.5 recommended |
| Compound V3 | supply() | N/A (Comet) | Collateral factor varies |
| Morpho | Optimizer bundles | Peer-matched rates | Check LLTV |
Always maintain health factor buffer. Monitor oracle price feeds (skill-11).
3. Stake / Restake
- Lido:
submit()ETH → stETH; check rebasing vs wstETH for integrations - EigenLayer: deposit into strategy contracts; track withdrawal queues
- Liquid staking: verify validator set and slashing risk
4. Liquidity Provision
- Uniswap V3: select tick range; narrow ranges = higher IL risk
- Calculate impermanent loss before deposit
- Use
defi-protocol-serverfor current pool APR/TVL
5. Flash Loans
- Identify provider (Aave: 0.09% fee, Balancer: 0% on some pools)
- Build callback contract with atomic repay logic
- Simulate full transaction — revert if unprofitable
- Never use flash loans for unbounded external calls
Protocol References
See knowledge-base/protocols/ for addresses, ABIs, and subgraph endpoints per chain.
Risk Checklist
- Contract verified and on protocol allowlist
- Slippage and deadline set
- Health factor / collateral ratio safe
- Token approvals scoped to exact amount
- MEV protection enabled for swaps > $1,000 (skill-15)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

