-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtest_rebuild_tuple.php
30 lines (23 loc) · 8.42 KB
/
test_rebuild_tuple.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace SWeb3;
use \stdClass;
include_once("../vendor/autoload.php");
require(__DIR__.'/inc/inc.abitest.php');
$abi_fn = 'swapExactInput';
$abi_swapv3 = '[{"inputs":[{"internalType":"address","name":"_v2Router","type":"address"},{"internalType":"address","name":"_v1Foctroy","type":"address"},{"internalType":"address","name":"_psmUsdd","type":"address"},{"internalType":"address","name":"_v3Router","type":"address"},{"internalType":"address","name":"_wtrx","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"AddPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"admin","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"ChangePool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"name":"SwapExactETHForTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"name":"SwapExactTokensForTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"originOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"TransferAdminship","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"originOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"TransferOwnership","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"WTRX","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"poolVersion","type":"string"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"addPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"poolVersion","type":"string"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"address","name":"gemJoin","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"addPsmPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"poolVersion","type":"string"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"addUsdcPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"changePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"poolVersion","type":"string"}],"name":"isPsmPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"poolVersion","type":"string"}],"name":"isUsdcPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"psmUsdd","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"retrieve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"string[]","name":"poolVersion","type":"string[]"},{"internalType":"uint256[]","name":"versionLen","type":"uint256[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"components":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct SmartExchangeRouter.SwapData","name":"data","type":"tuple"}],"name":"swapExactInput","outputs":[{"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"transferAdminship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"unwrapWTRX","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"v1Factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"v2Router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"v3Router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]';
$raw_data = '0xcef9522900000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000000000c4d2aa000000000000000000000000bbe2a45805232556d2ddaaf42ca9bb2bb0df9b6e0000000000000000000000000000000000000000000000000000000064ce49920000000000000000000000000000000000000000000000000000000000000003000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c000000000000000000000000891cdb91d149f23b1a45d9c5ca78a88d0cb44c1800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002763300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000027632000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
$limit = $_REQUEST['limit'] ?? false;
echo "<h2>Reencoding abi data</h2>";
echo "?limit=count - limit to X parameters for reencoding. Data format: [Block no, 32 byte content, possible offset]";
$t = new abitest($abi_swapv3, $abi_fn, $raw_data);
if ($limit === $t->getABIInputsCount()) {
echo "Too many parameters, setting to: {$limit}<br>";
}
if ($limit === false) {
$t->runTest();
echo "<div style='background: #116611'> </div>";
for ($i = 1; $i <= $t->getABIInputsCount(); $i++)
$t->runTest($i);
} else {
$t->runTest($limit);
}