Skip to main content

Skill Guide

DeFi protocol mechanics (AMMs, lending markets, liquidation engines, yield strategies)

The operational logic governing decentralized financial protocols, specifically the mathematical models for automated market making, the collateral-debt dynamics of lending platforms, the incentive-aligned liquidation mechanisms that maintain protocol solvency, and the risk-adjusted strategies for generating returns across these systems.

This skill is critical for building, auditing, or investing in the infrastructure of decentralized finance, where a deep understanding of these mechanics directly impacts protocol security, capital efficiency, and risk management. Organizations with this expertise can design robust financial primitives, identify arbitrage and vulnerability opportunities, and allocate capital more effectively in a multi-billion dollar ecosystem.
1 Careers
1 Categories
8.5 Avg Demand
20% Avg AI Risk

How to Learn DeFi protocol mechanics (AMMs, lending markets, liquidation engines, yield strategies)

1. **Core Primitives:** Master the constant product formula (x*y=k) and how liquidity pools, swaps, and impermanent loss work in AMMs like Uniswap v2. 2. **Lending Basics:** Understand over-collateralization, collateral factors, and the basic deposit-borrow-repay lifecycle on a platform like Aave v2. 3. **Liquidation Fundamentals:** Grasp the concept of health factors, collateral price triggers, and the basic role of a liquidator.
1. **Protocol Comparison:** Analyze the trade-offs between different AMM curves (e.g., Curve's StableSwap vs. Uniswap v3's concentrated liquidity) and their impact on slippage and LP returns. 2. **Lending Market Dynamics:** Model the interest rate curve utilization and understand how it affects borrow costs and supply yields. Avoid the common mistake of ignoring the oracle dependency and its failure modes. 3. **Strategy Construction:** Move from passive LP provision to simple yield strategies like staking LP tokens in a farm or using a lending market to leverage a position.
1. **System Design & Auditing:** Deconstruct the core smart contract architecture of a protocol (e.g., MakerDAO's liquidations 2.0 or Aave's Safety Module) and identify edge cases in its economic design. 2. **Cross-Protocol Composability:** Architect complex strategies that layer multiple protocols (e.g., using a flash loan to execute an arbitrage across three DEXes and settle in one transaction). 3. **Risk Modeling:** Develop and stress-test risk parameters for a lending market or design an optimal liquidation bot strategy that accounts for gas wars and MEV.

Practice Projects

Beginner
Project

AMM Simulation & Impermanent Loss Calculator

Scenario

You are tasked with explaining the financial risks of providing liquidity to a novice investor. Build a tool that simulates price movements in a constant product AMM and visualizes the resulting impermanent loss compared to simply holding the assets.

How to Execute
1. Choose a simple AMM model (Uniswap v2) and two assets (e.g., ETH/USDC). 2. Set initial liquidity pool parameters and asset prices. 3. Write a script (Python/JS) that models price changes and recalculates the pool's composition and LP token value. 4. Compare this final value to the value of holding the initial assets, plotting the loss curve.
Intermediate
Project

Lending Market Liquidation Bot (Testnet)

Scenario

The protocol you're auditing has a critical threshold: positions with a health factor below 1.0 are eligible for liquidation. You must build a bot to monitor for and execute these liquidations profitably on a testnet fork.

How to Execute
1. Fork a mainnet lending market (e.g., Aave) to a local testnet using Hardhat/Foundry. 2. Use The Graph or direct contract queries to monitor positions and filter those approaching a health factor of 1. 3. Implement the liquidation function call in your bot, calculating the optimal amount to repay to capture the maximum collateral bonus. 4. Test by manipulating collateral prices on the fork and executing your bot, accounting for gas costs in your profitability calculation.
Advanced
Project

Design a Yield Aggregator Vault Strategy

Scenario

You are the lead architect for a new yield vault that must dynamically allocate user funds across multiple DeFi lending and staking protocols to maximize risk-adjusted returns while maintaining liquidity for withdrawals.

How to Execute
1. Define the universe of acceptable yield sources (e.g., Aave, Compound, Lido, Convex) and their risk parameters. 2. Architect a smart contract system with a controller contract that rebalances funds based on a pre-defined strategy (e.g., chasing highest stablecoin yield while maintaining a 10% liquidity buffer). 3. Implement access controls, emergency withdrawal functions, and a transparent fee structure. 4. Develop a comprehensive risk mitigation plan covering oracle failures, protocol exploits, and extreme market volatility.

Tools & Frameworks

Development & Simulation

Foundry (Forge & Anvil)HardhatTenderlyEthers.js / viem

Foundry and Hardhat are the primary development frameworks for compiling, testing, and deploying Solidity smart contracts. Use Anvil (Foundry) or Hardhat Network to fork mainnet state for realistic testing. Tenderly provides advanced transaction simulation and debugging. Ethers.js or viem are used for interacting with contracts programmatically.

Analysis & Monitoring

Dune AnalyticsThe GraphDefiLlamaArkham / Nansen

Dune and The Graph are essential for querying on-chain data to build dashboards for protocol health, TVL, and liquidation activity. DefiLlama provides aggregated TVL and yield data across protocols. Arkham or Nansen are used for wallet/entity labeling to track fund flows and identify key actors like liquidators.

Core Frameworks & Models

Constant Product Formula (x*y=k)Interest Rate Model (Kink Model)Health Factor CalculationBonding Curves (StableSwap)

These are the fundamental mathematical and economic models you must internalize. The constant product formula is the bedrock of most AMMs. The Kink Model (as in Aave/Compound) dynamically adjusts interest rates based on utilization. The Health Factor is the core risk metric for lending positions. Understanding alternative bonding curves is key for specialized AMMs.

Interview Questions

Answer Strategy

Use a step-by-step framework: 1) User initiates `swap` on the Router. 2) Router calls `transferFrom` to move tokens from the user to the pool. 3) Pool calculates output using `getAmountOut` based on the constant product formula. 4) Pool calls `_update` to adjust reserves and send tokens to the user. Security considerations include: reentrancy checks (state updates before external calls), fee-on-transfer token handling, and proper slippage protection by the user.

Answer Strategy

The interviewer is testing your ability to connect on-chain data to systemic risk. Frame your answer around metrics: 1) **Health Factor Distribution:** A sharp increase in positions with HF between 1.0-1.1 signals pressure. 2) **Liquidation Volume vs. Depth:** If liquidation volume overwhelms the collateral's market liquidity (e.g., on-chain DEX depth), prices can spiral. 3) **Oracle Deviation:** Check if the oracle price (Chainlink) is deviating significantly from spot exchange prices. 4) **Protocol Utilization:** Sudden drops in utilization (high withdrawals) indicate loss of confidence. Cascade risk is high when liquidations trigger further price drops, causing more liquidations, especially in correlated collateral like ETH.

Careers That Require DeFi protocol mechanics (AMMs, lending markets, liquidation engines, yield strategies)

1 career found