60-minute technical interview for DeFi protocol integration.
Build a 1.5x leveraged LONG position on ETH using Aave V3 and Uniswap V2.
- Python 3.10+
- Foundry (for Anvil)
macOS/Linux:
curl -L https://foundry.paradigm.xyz | bash
foundryupWindows:
Option 1: Using WSL2 (Recommended)
# Install WSL2 first (if not already installed)
wsl --install
# Inside WSL2, install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryupOption 2: Pre-built Binaries
- Download latest release from Foundry Releases
- Extract
anvil.exeto a folder in your PATH - Open PowerShell and verify:
anvil --version
Verify installation:
anvil --version
# Should output: anvil 0.2.0 (or higher)Troubleshooting: See Foundry Installation Guide for detailed instructions.
# 1. Navigate to project directory
cd connector-coding-task
# 2. Install Python dependencies
pip install -r requirements.txt
# 3. Copy environment template
cp .env.example .envTerminal 1: Start Anvil Fork
anvil --fork-url https://eth.llamarpc.com \
--fork-block-number 23726437 \
--chain-id 1 \
--auto-impersonateWhat this does:
- Forks Ethereum mainnet at block 23,726,437
--auto-impersonateallows sending transactions from any address (unlocks all accounts)- Provides deterministic testing environment with WETH-rich test wallet
Keep this terminal running during development.
Build a 1.5x leveraged LONG position on ETH:
- You have 1 ETH worth $3,500
- Create exposure to 1.5 ETH (worth $5,250)
- Use Aave for lending and Uniswap for swapping
- Supply 1 ETH to Aave as collateral
- Borrow $1,750 USDC from Aave (50% LTV)
- Swap $1,750 USDC → 0.5 ETH on Uniswap
- Result: 1.5 ETH total exposure with 1 ETH capital
File: strategy_skeleton.py
-
calculate_borrow_amount()(15 min)- Calculate how much USDC to borrow for target leverage
-
build_position()(30 min)- Execute the 6-step transaction flow
-
Discussion (15 min)
- Risk management, monitoring, unwinding strategy
Terminal 2: Run Test
python test_solution.pyThe test checks your actual Aave position (not your return value):
✅ Collateral supplied > 0 ✅ USDC debt > 0 (borrowed successfully) ✅ Leverage within 20% of target (1.5x) ✅ Health factor > 1.0 (safe from liquidation)
================================================================================
LEVERAGE STRATEGY TEST
================================================================================
✅ Connected to chain ID 1
📦 Block: 23,726,437
💼 Test wallet: 0x49c23...
Initial State:
WETH Balance: 1672.2008 WETH
USDC Balance: 0.00 USDC
ETH Price: $3,500.00
Expected Outcome:
Collateral: 1 ETH ($3,500.00)
Target Leverage: 1.5x
Expected Borrow: ~$1,750.00 USDC
Expected Exposure: ~1.50 ETH
================================================================================
Building 1.5x leveraged position...
================================================================================
[Your implementation logs here]
================================================================================
POSITION STATUS (from Aave)
================================================================================
Collateral: $3,499.71
Debt: $1,714.69
Health Factor: 1.69
LTV: 80.50%
Liquidation Threshold: 83.00%
ETH in Aave: 0.9999 ETH
ETH Purchased: 0.4878 ETH
Total ETH Exposure: 1.4878 ETH
Actual Leverage: 1.49x
================================================================================
VALIDATION RESULTS
================================================================================
✅ Collateral supplied: $3,499.71
✅ USDC borrowed: $1,714.69
✅ Leverage: 1.49x (target: 1.5x, variance: 0.7%)
✅ Collateral matches expected (variance: 0.0%)
================================================================================
TEST SUMMARY
================================================================================
Position Size: $3,499.71
Leverage Achieved: 1.49x / 1.50x target
Health Factor: 1.69
Position Safety: ✅ SAFE
================================================================================
🎉 ALL TESTS PASSED!
# WRONG
usdc_wei = int(1750 * 10**18) # USDC is 6 decimals, not 18!
# CORRECT
usdc_wei = int(1750 * 10**6) # USDC has 6 decimals
weth_wei = int(1.0 * 10**18) # WETH has 18 decimals# WRONG - Will revert!
tx = self.aave.supply(WETH, amount, ...) # No approval first
# CORRECT
tx = self.weth.approve(aave.address, amount, ...) # Approve first
self.wallet.send_and_wait(tx)
tx = self.aave.supply(WETH, amount, ...) # Then supply# WRONG - Could get sandwiched!
min_out = 0 # Accepts any amount
# CORRECT - 1% slippage protection
min_out = int(expected_amount * 0.99)# WRONG
self.aave.borrow(...) # Can't borrow without collateral
self.aave.supply(...) # Supply comes after? Too late!
# CORRECT
self.aave.supply(...) # Supply collateral first
self.aave.borrow(...) # Then borrow# WRONG
deadline = 0 # Transaction can be executed anytime
# CORRECT
deadline = int(time.time()) + 300 # Valid for 5 minutesThis repository is for interview purposes only.