defi-protocols
Specialized knowledge of DeFi protocols including smart contracts, tokens, and decentralized lending on blockchains.
What this skill does
# defi-protocols
## Purpose
This skill equips the AI with specialized knowledge of DeFi protocols, enabling precise interactions with smart contracts, tokens, and decentralized lending on blockchains like Ethereum and Binance Smart Chain.
## When to Use
Use this skill for tasks involving DeFi app development, smart contract auditing, token management, or lending protocol integrations. Apply it when handling blockchain transactions, yield farming, or protocol vulnerabilities in real-time coding scenarios.
## Key Capabilities
- Interact with smart contracts using Web3.js or Ethers.js libraries to read/write state.
- Manage ERC-20/ERC-721 tokens, including transfers and approvals.
- Handle decentralized lending via protocols like Aave or Compound, querying interest rates or borrowing limits.
- Analyze on-chain data from block explorers like Etherscan API endpoints (e.g., `/api?module=account&action=balance`).
- Simulate transactions with tools like Hardhat for testing smart contracts.
## Usage Patterns
To use this skill, initialize a Web3 provider in your code and set environment variables for API keys. For example, in a Node.js script, import Web3 and connect to a network:
```javascript
const Web3 = require('web3');
const web3 = new Web3(process.env.RPC_URL || 'http://localhost:8545');
```
For DeFi-specific tasks, wrap contract interactions in try-catch blocks and use ABI files for decoding. When querying Aave, fetch pool data by specifying the contract address and function signature.
## Common Commands/API
- CLI: Use Hardhat for deploying contracts: `npx hardhat run scripts/deploy.js --network sepolia --api-key $ETHEREUM_API_KEY`.
- API: Ethereum JSON-RPC via endpoints like `eth_call` for contract calls: `curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{...}],"id":1}' $RPC_URL`.
- Aave API: Query lending pools with `GET https://api.thegraph.com/subgraphs/name/aave/protocol-v2` using GraphQL queries.
- Config formats: Store ABI in JSON files, e.g., `{ "abi": [{ "name": "balanceOf", "inputs": [...] }] }`, and load via `fs.readFileSync('abi.json')`.
- Token interactions: Use Ethers.js for transfers: `contract.methods.transfer(address, amount).send({ from: walletAddress })`.
## Integration Notes
Integrate this skill with wallets like MetaMask by using Web3 providers that handle signer objects. For authentication, set env vars like `$ETHEREUM_API_KEY` for services such as Infura or Alchemy. When combining with other skills, ensure compatibility by standardizing blockchain networks (e.g., use Web3.js for both DeFi and general blockchain tasks). For oracles like Chainlink, import their contracts and call functions like `getPrice` before executing DeFi logic.
## Error Handling
Handle common errors like transaction reverts by checking for `TransactionError` in Ethers.js: try { await contract.methods.borrow().send(); } catch (error) { if (error.reason.includes('insufficient collateral')) console.log('Add more collateral'); }. For API failures, verify status codes (e.g., 429 for rate limits) and retry with exponential backoff. Use event listeners for blockchain errors, e.g., `contract.events.ErrorOccurred().on('data', handleError)`. Always validate inputs to prevent exploits like reentrancy in lending protocols.
## Concrete Usage Examples
1. **Query Aave Lending Pool:** To check available liquidity for a token, use this Ethers.js snippet: `const pool = await ethers.getContractAt('ILendingPool', '0x...'); const liquidity = await pool.getReserveData(tokenAddress); console.log(liquidity.availableLiquidity.toString());`. Set `$AAVE_SUBGRAPH_KEY` for any required API access.
2. **Deploy a Simple Token Contract:** In a Hardhat project, run `npx hardhat compile` then `npx hardhat deploy --network mumbai`, with config in `hardhat.config.js` like `module.exports = { networks: { mumbai: { url: process.env.RPC_URL, accounts: [process.env.PRIVATE_KEY] } } };`. This deploys an ERC-20 token for DeFi use.
## Graph Relationships
- Related to: ethereum (shares blockchain cluster), smart-contracts (overlaps on contract interactions), tokens (focuses on ERC standards).
- Connected via: blockchain cluster for broader ecosystem access.
- Dependencies: Requires protocols like aave for lending specifics.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.