Commit 34b01480 authored by luxq's avatar luxq

fix bug

parent 090c2d86
# pancakeSwaper # Program for swap on pancake
This is a program for swap usdt/klko on pancake.
## How to use it?
#### 1. install golang v1.24 and make
```shell
wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz
tar zxf go1.24.1.linux-amd64.tar.gz -C /usr/local
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
sudo apt install make
```
#### 2. clone the code and build the program
```shell
git clone https://code.wuban.net.cn/luxueqian/pancakeswaper
cd pancakeswaper
make
```
#### 2. fill in the `accounts.json` file with the accounts you want to do swap for.
The example of the `accounts.json` file is as follow:
```json
[
{
"address": "0x",
"private": "0x"
},
{
"address": "0x",
"private": "0x"
}
]
```
#### 4. change configure
There is a `config.yml`, you can change the configure in it.
```yaml
param:
# routine count.
routine: 10
# swap volume for each transaction, unit is 0.1 usdt. example: 1 is 0.1 usdt.
volume: 1
# count of transactions per user.
count: 2
# gas_price unit is Gwei.
gas_price: 1
# slippage, unit is 1/1000. example: 20 means 2.0%.
slippage: 20
# tx deadline, unit is minutes, set 0 to disable.
deadline: 20
rpc:
env: "bsc"
pool: 20
log:
level: "debug"
users: "accounts.json"
```
#### 5. run the program
After check the configure, you can run the program.
```shell
./build/bin/swapper
```
#### 6. check result
When the program is running, you can check the progress in the console.
```text
REPORT Failed/Total Finished/Total
USER 0/80 18/80
TX 0/0
0.18 Cost / 0.28 Receive
```
After the program is finished, you can check the result in the console.
```text
all done, no failed user
```
If an error occurs, you can check the error details in `detail.log`, and the accounts that failed will be recorded in the `failed.json` file.
If the issue is with the account format, please verify that the account format in the `accounts.json` file is correct. After correcting it, rerun the program.
param: param:
# routine count. # routine count.
routine: 10 routine: 10
# swap volume for each transaction, unit is usdt. # swap volume for each transaction, unit is 0.1 usdt. example: 1 is 0.1 usdt.
volume: 1 volume: 1
# count of transactions per user. # count of transactions per user.
count: 2 count: 2
......
[{"inputs":[{"internalType":"address","name":"_deployer","type":"address"},{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH9","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deployer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct ISwapRouter.ExactInputParams","name":"params","type":"tuple"}],"name":"exactInput","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct ISwapRouter.ExactInputSingleParams","name":"params","type":"tuple"}],"name":"exactInputSingle","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMaximum","type":"uint256"}],"internalType":"struct ISwapRouter.ExactOutputParams","name":"params","type":"tuple"}],"name":"exactOutput","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMaximum","type":"uint256"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct ISwapRouter.ExactOutputSingleParams","name":"params","type":"tuple"}],"name":"exactOutputSingle","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"int256","name":"amount0Delta","type":"int256"},{"internalType":"int256","name":"amount1Delta","type":"int256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"pancakeV3SwapCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"refundETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitAllowed","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitAllowedIfNecessary","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitIfNecessary","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"feeBips","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"}],"name":"sweepTokenWithFee","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"unwrapWETH9","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"feeBips","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"}],"name":"unwrapWETH9WithFee","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
#!/bin/bash
# build abi.json to go package.
abigen --abi=abi.json --pkg=v3router --type=V3Router --out=contract.go
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package v3router
import (
"errors"
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// ISwapRouterExactInputParams is an auto generated low-level Go binding around an user-defined struct.
type ISwapRouterExactInputParams struct {
Path []byte
Recipient common.Address
Deadline *big.Int
AmountIn *big.Int
AmountOutMinimum *big.Int
}
// ISwapRouterExactInputSingleParams is an auto generated low-level Go binding around an user-defined struct.
type ISwapRouterExactInputSingleParams struct {
TokenIn common.Address
TokenOut common.Address
Fee *big.Int
Recipient common.Address
Deadline *big.Int
AmountIn *big.Int
AmountOutMinimum *big.Int
SqrtPriceLimitX96 *big.Int
}
// ISwapRouterExactOutputParams is an auto generated low-level Go binding around an user-defined struct.
type ISwapRouterExactOutputParams struct {
Path []byte
Recipient common.Address
Deadline *big.Int
AmountOut *big.Int
AmountInMaximum *big.Int
}
// ISwapRouterExactOutputSingleParams is an auto generated low-level Go binding around an user-defined struct.
type ISwapRouterExactOutputSingleParams struct {
TokenIn common.Address
TokenOut common.Address
Fee *big.Int
Recipient common.Address
Deadline *big.Int
AmountOut *big.Int
AmountInMaximum *big.Int
SqrtPriceLimitX96 *big.Int
}
// V3RouterMetaData contains all meta data concerning the V3Router contract.
var V3RouterMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_deployer\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_factory\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_WETH9\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"WETH9\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"deployer\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"path\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMinimum\",\"type\":\"uint256\"}],\"internalType\":\"structISwapRouter.ExactInputParams\",\"name\":\"params\",\"type\":\"tuple\"}],\"name\":\"exactInput\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMinimum\",\"type\":\"uint256\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"internalType\":\"structISwapRouter.ExactInputSingleParams\",\"name\":\"params\",\"type\":\"tuple\"}],\"name\":\"exactInputSingle\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"path\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountInMaximum\",\"type\":\"uint256\"}],\"internalType\":\"structISwapRouter.ExactOutputParams\",\"name\":\"params\",\"type\":\"tuple\"}],\"name\":\"exactOutput\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountInMaximum\",\"type\":\"uint256\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"internalType\":\"structISwapRouter.ExactOutputSingleParams\",\"name\":\"params\",\"type\":\"tuple\"}],\"name\":\"exactOutputSingle\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"factory\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"data\",\"type\":\"bytes[]\"}],\"name\":\"multicall\",\"outputs\":[{\"internalType\":\"bytes[]\",\"name\":\"results\",\"type\":\"bytes[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"amount0Delta\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1Delta\",\"type\":\"int256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"pancakeV3SwapCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"refundETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"selfPermit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"selfPermitAllowed\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"selfPermitAllowedIfNecessary\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"selfPermitIfNecessary\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountMinimum\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"}],\"name\":\"sweepToken\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountMinimum\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeBips\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeRecipient\",\"type\":\"address\"}],\"name\":\"sweepTokenWithFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountMinimum\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"}],\"name\":\"unwrapWETH9\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountMinimum\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeBips\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeRecipient\",\"type\":\"address\"}],\"name\":\"unwrapWETH9WithFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]",
}
// V3RouterABI is the input ABI used to generate the binding from.
// Deprecated: Use V3RouterMetaData.ABI instead.
var V3RouterABI = V3RouterMetaData.ABI
// V3Router is an auto generated Go binding around an Ethereum contract.
type V3Router struct {
V3RouterCaller // Read-only binding to the contract
V3RouterTransactor // Write-only binding to the contract
V3RouterFilterer // Log filterer for contract events
}
// V3RouterCaller is an auto generated read-only Go binding around an Ethereum contract.
type V3RouterCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// V3RouterTransactor is an auto generated write-only Go binding around an Ethereum contract.
type V3RouterTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// V3RouterFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type V3RouterFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// V3RouterSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type V3RouterSession struct {
Contract *V3Router // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// V3RouterCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type V3RouterCallerSession struct {
Contract *V3RouterCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// V3RouterTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type V3RouterTransactorSession struct {
Contract *V3RouterTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// V3RouterRaw is an auto generated low-level Go binding around an Ethereum contract.
type V3RouterRaw struct {
Contract *V3Router // Generic contract binding to access the raw methods on
}
// V3RouterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type V3RouterCallerRaw struct {
Contract *V3RouterCaller // Generic read-only contract binding to access the raw methods on
}
// V3RouterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type V3RouterTransactorRaw struct {
Contract *V3RouterTransactor // Generic write-only contract binding to access the raw methods on
}
// NewV3Router creates a new instance of V3Router, bound to a specific deployed contract.
func NewV3Router(address common.Address, backend bind.ContractBackend) (*V3Router, error) {
contract, err := bindV3Router(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &V3Router{V3RouterCaller: V3RouterCaller{contract: contract}, V3RouterTransactor: V3RouterTransactor{contract: contract}, V3RouterFilterer: V3RouterFilterer{contract: contract}}, nil
}
// NewV3RouterCaller creates a new read-only instance of V3Router, bound to a specific deployed contract.
func NewV3RouterCaller(address common.Address, caller bind.ContractCaller) (*V3RouterCaller, error) {
contract, err := bindV3Router(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &V3RouterCaller{contract: contract}, nil
}
// NewV3RouterTransactor creates a new write-only instance of V3Router, bound to a specific deployed contract.
func NewV3RouterTransactor(address common.Address, transactor bind.ContractTransactor) (*V3RouterTransactor, error) {
contract, err := bindV3Router(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &V3RouterTransactor{contract: contract}, nil
}
// NewV3RouterFilterer creates a new log filterer instance of V3Router, bound to a specific deployed contract.
func NewV3RouterFilterer(address common.Address, filterer bind.ContractFilterer) (*V3RouterFilterer, error) {
contract, err := bindV3Router(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &V3RouterFilterer{contract: contract}, nil
}
// bindV3Router binds a generic wrapper to an already deployed contract.
func bindV3Router(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(V3RouterABI))
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_V3Router *V3RouterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _V3Router.Contract.V3RouterCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_V3Router *V3RouterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _V3Router.Contract.V3RouterTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_V3Router *V3RouterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _V3Router.Contract.V3RouterTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_V3Router *V3RouterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _V3Router.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_V3Router *V3RouterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _V3Router.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_V3Router *V3RouterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _V3Router.Contract.contract.Transact(opts, method, params...)
}
// WETH9 is a free data retrieval call binding the contract method 0x4aa4a4fc.
//
// Solidity: function WETH9() view returns(address)
func (_V3Router *V3RouterCaller) WETH9(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _V3Router.contract.Call(opts, &out, "WETH9")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// WETH9 is a free data retrieval call binding the contract method 0x4aa4a4fc.
//
// Solidity: function WETH9() view returns(address)
func (_V3Router *V3RouterSession) WETH9() (common.Address, error) {
return _V3Router.Contract.WETH9(&_V3Router.CallOpts)
}
// WETH9 is a free data retrieval call binding the contract method 0x4aa4a4fc.
//
// Solidity: function WETH9() view returns(address)
func (_V3Router *V3RouterCallerSession) WETH9() (common.Address, error) {
return _V3Router.Contract.WETH9(&_V3Router.CallOpts)
}
// Deployer is a free data retrieval call binding the contract method 0xd5f39488.
//
// Solidity: function deployer() view returns(address)
func (_V3Router *V3RouterCaller) Deployer(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _V3Router.contract.Call(opts, &out, "deployer")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// Deployer is a free data retrieval call binding the contract method 0xd5f39488.
//
// Solidity: function deployer() view returns(address)
func (_V3Router *V3RouterSession) Deployer() (common.Address, error) {
return _V3Router.Contract.Deployer(&_V3Router.CallOpts)
}
// Deployer is a free data retrieval call binding the contract method 0xd5f39488.
//
// Solidity: function deployer() view returns(address)
func (_V3Router *V3RouterCallerSession) Deployer() (common.Address, error) {
return _V3Router.Contract.Deployer(&_V3Router.CallOpts)
}
// Factory is a free data retrieval call binding the contract method 0xc45a0155.
//
// Solidity: function factory() view returns(address)
func (_V3Router *V3RouterCaller) Factory(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _V3Router.contract.Call(opts, &out, "factory")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// Factory is a free data retrieval call binding the contract method 0xc45a0155.
//
// Solidity: function factory() view returns(address)
func (_V3Router *V3RouterSession) Factory() (common.Address, error) {
return _V3Router.Contract.Factory(&_V3Router.CallOpts)
}
// Factory is a free data retrieval call binding the contract method 0xc45a0155.
//
// Solidity: function factory() view returns(address)
func (_V3Router *V3RouterCallerSession) Factory() (common.Address, error) {
return _V3Router.Contract.Factory(&_V3Router.CallOpts)
}
// ExactInput is a paid mutator transaction binding the contract method 0xc04b8d59.
//
// Solidity: function exactInput((bytes,address,uint256,uint256,uint256) params) payable returns(uint256 amountOut)
func (_V3Router *V3RouterTransactor) ExactInput(opts *bind.TransactOpts, params ISwapRouterExactInputParams) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "exactInput", params)
}
// ExactInput is a paid mutator transaction binding the contract method 0xc04b8d59.
//
// Solidity: function exactInput((bytes,address,uint256,uint256,uint256) params) payable returns(uint256 amountOut)
func (_V3Router *V3RouterSession) ExactInput(params ISwapRouterExactInputParams) (*types.Transaction, error) {
return _V3Router.Contract.ExactInput(&_V3Router.TransactOpts, params)
}
// ExactInput is a paid mutator transaction binding the contract method 0xc04b8d59.
//
// Solidity: function exactInput((bytes,address,uint256,uint256,uint256) params) payable returns(uint256 amountOut)
func (_V3Router *V3RouterTransactorSession) ExactInput(params ISwapRouterExactInputParams) (*types.Transaction, error) {
return _V3Router.Contract.ExactInput(&_V3Router.TransactOpts, params)
}
// ExactInputSingle is a paid mutator transaction binding the contract method 0x414bf389.
//
// Solidity: function exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160) params) payable returns(uint256 amountOut)
func (_V3Router *V3RouterTransactor) ExactInputSingle(opts *bind.TransactOpts, params ISwapRouterExactInputSingleParams) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "exactInputSingle", params)
}
// ExactInputSingle is a paid mutator transaction binding the contract method 0x414bf389.
//
// Solidity: function exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160) params) payable returns(uint256 amountOut)
func (_V3Router *V3RouterSession) ExactInputSingle(params ISwapRouterExactInputSingleParams) (*types.Transaction, error) {
return _V3Router.Contract.ExactInputSingle(&_V3Router.TransactOpts, params)
}
// ExactInputSingle is a paid mutator transaction binding the contract method 0x414bf389.
//
// Solidity: function exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160) params) payable returns(uint256 amountOut)
func (_V3Router *V3RouterTransactorSession) ExactInputSingle(params ISwapRouterExactInputSingleParams) (*types.Transaction, error) {
return _V3Router.Contract.ExactInputSingle(&_V3Router.TransactOpts, params)
}
// ExactOutput is a paid mutator transaction binding the contract method 0xf28c0498.
//
// Solidity: function exactOutput((bytes,address,uint256,uint256,uint256) params) payable returns(uint256 amountIn)
func (_V3Router *V3RouterTransactor) ExactOutput(opts *bind.TransactOpts, params ISwapRouterExactOutputParams) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "exactOutput", params)
}
// ExactOutput is a paid mutator transaction binding the contract method 0xf28c0498.
//
// Solidity: function exactOutput((bytes,address,uint256,uint256,uint256) params) payable returns(uint256 amountIn)
func (_V3Router *V3RouterSession) ExactOutput(params ISwapRouterExactOutputParams) (*types.Transaction, error) {
return _V3Router.Contract.ExactOutput(&_V3Router.TransactOpts, params)
}
// ExactOutput is a paid mutator transaction binding the contract method 0xf28c0498.
//
// Solidity: function exactOutput((bytes,address,uint256,uint256,uint256) params) payable returns(uint256 amountIn)
func (_V3Router *V3RouterTransactorSession) ExactOutput(params ISwapRouterExactOutputParams) (*types.Transaction, error) {
return _V3Router.Contract.ExactOutput(&_V3Router.TransactOpts, params)
}
// ExactOutputSingle is a paid mutator transaction binding the contract method 0xdb3e2198.
//
// Solidity: function exactOutputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160) params) payable returns(uint256 amountIn)
func (_V3Router *V3RouterTransactor) ExactOutputSingle(opts *bind.TransactOpts, params ISwapRouterExactOutputSingleParams) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "exactOutputSingle", params)
}
// ExactOutputSingle is a paid mutator transaction binding the contract method 0xdb3e2198.
//
// Solidity: function exactOutputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160) params) payable returns(uint256 amountIn)
func (_V3Router *V3RouterSession) ExactOutputSingle(params ISwapRouterExactOutputSingleParams) (*types.Transaction, error) {
return _V3Router.Contract.ExactOutputSingle(&_V3Router.TransactOpts, params)
}
// ExactOutputSingle is a paid mutator transaction binding the contract method 0xdb3e2198.
//
// Solidity: function exactOutputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160) params) payable returns(uint256 amountIn)
func (_V3Router *V3RouterTransactorSession) ExactOutputSingle(params ISwapRouterExactOutputSingleParams) (*types.Transaction, error) {
return _V3Router.Contract.ExactOutputSingle(&_V3Router.TransactOpts, params)
}
// Multicall is a paid mutator transaction binding the contract method 0xac9650d8.
//
// Solidity: function multicall(bytes[] data) payable returns(bytes[] results)
func (_V3Router *V3RouterTransactor) Multicall(opts *bind.TransactOpts, data [][]byte) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "multicall", data)
}
// Multicall is a paid mutator transaction binding the contract method 0xac9650d8.
//
// Solidity: function multicall(bytes[] data) payable returns(bytes[] results)
func (_V3Router *V3RouterSession) Multicall(data [][]byte) (*types.Transaction, error) {
return _V3Router.Contract.Multicall(&_V3Router.TransactOpts, data)
}
// Multicall is a paid mutator transaction binding the contract method 0xac9650d8.
//
// Solidity: function multicall(bytes[] data) payable returns(bytes[] results)
func (_V3Router *V3RouterTransactorSession) Multicall(data [][]byte) (*types.Transaction, error) {
return _V3Router.Contract.Multicall(&_V3Router.TransactOpts, data)
}
// PancakeV3SwapCallback is a paid mutator transaction binding the contract method 0x23a69e75.
//
// Solidity: function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes _data) returns()
func (_V3Router *V3RouterTransactor) PancakeV3SwapCallback(opts *bind.TransactOpts, amount0Delta *big.Int, amount1Delta *big.Int, _data []byte) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "pancakeV3SwapCallback", amount0Delta, amount1Delta, _data)
}
// PancakeV3SwapCallback is a paid mutator transaction binding the contract method 0x23a69e75.
//
// Solidity: function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes _data) returns()
func (_V3Router *V3RouterSession) PancakeV3SwapCallback(amount0Delta *big.Int, amount1Delta *big.Int, _data []byte) (*types.Transaction, error) {
return _V3Router.Contract.PancakeV3SwapCallback(&_V3Router.TransactOpts, amount0Delta, amount1Delta, _data)
}
// PancakeV3SwapCallback is a paid mutator transaction binding the contract method 0x23a69e75.
//
// Solidity: function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes _data) returns()
func (_V3Router *V3RouterTransactorSession) PancakeV3SwapCallback(amount0Delta *big.Int, amount1Delta *big.Int, _data []byte) (*types.Transaction, error) {
return _V3Router.Contract.PancakeV3SwapCallback(&_V3Router.TransactOpts, amount0Delta, amount1Delta, _data)
}
// RefundETH is a paid mutator transaction binding the contract method 0x12210e8a.
//
// Solidity: function refundETH() payable returns()
func (_V3Router *V3RouterTransactor) RefundETH(opts *bind.TransactOpts) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "refundETH")
}
// RefundETH is a paid mutator transaction binding the contract method 0x12210e8a.
//
// Solidity: function refundETH() payable returns()
func (_V3Router *V3RouterSession) RefundETH() (*types.Transaction, error) {
return _V3Router.Contract.RefundETH(&_V3Router.TransactOpts)
}
// RefundETH is a paid mutator transaction binding the contract method 0x12210e8a.
//
// Solidity: function refundETH() payable returns()
func (_V3Router *V3RouterTransactorSession) RefundETH() (*types.Transaction, error) {
return _V3Router.Contract.RefundETH(&_V3Router.TransactOpts)
}
// SelfPermit is a paid mutator transaction binding the contract method 0xf3995c67.
//
// Solidity: function selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterTransactor) SelfPermit(opts *bind.TransactOpts, token common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "selfPermit", token, value, deadline, v, r, s)
}
// SelfPermit is a paid mutator transaction binding the contract method 0xf3995c67.
//
// Solidity: function selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterSession) SelfPermit(token common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.Contract.SelfPermit(&_V3Router.TransactOpts, token, value, deadline, v, r, s)
}
// SelfPermit is a paid mutator transaction binding the contract method 0xf3995c67.
//
// Solidity: function selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterTransactorSession) SelfPermit(token common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.Contract.SelfPermit(&_V3Router.TransactOpts, token, value, deadline, v, r, s)
}
// SelfPermitAllowed is a paid mutator transaction binding the contract method 0x4659a494.
//
// Solidity: function selfPermitAllowed(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterTransactor) SelfPermitAllowed(opts *bind.TransactOpts, token common.Address, nonce *big.Int, expiry *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "selfPermitAllowed", token, nonce, expiry, v, r, s)
}
// SelfPermitAllowed is a paid mutator transaction binding the contract method 0x4659a494.
//
// Solidity: function selfPermitAllowed(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterSession) SelfPermitAllowed(token common.Address, nonce *big.Int, expiry *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.Contract.SelfPermitAllowed(&_V3Router.TransactOpts, token, nonce, expiry, v, r, s)
}
// SelfPermitAllowed is a paid mutator transaction binding the contract method 0x4659a494.
//
// Solidity: function selfPermitAllowed(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterTransactorSession) SelfPermitAllowed(token common.Address, nonce *big.Int, expiry *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.Contract.SelfPermitAllowed(&_V3Router.TransactOpts, token, nonce, expiry, v, r, s)
}
// SelfPermitAllowedIfNecessary is a paid mutator transaction binding the contract method 0xa4a78f0c.
//
// Solidity: function selfPermitAllowedIfNecessary(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterTransactor) SelfPermitAllowedIfNecessary(opts *bind.TransactOpts, token common.Address, nonce *big.Int, expiry *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "selfPermitAllowedIfNecessary", token, nonce, expiry, v, r, s)
}
// SelfPermitAllowedIfNecessary is a paid mutator transaction binding the contract method 0xa4a78f0c.
//
// Solidity: function selfPermitAllowedIfNecessary(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterSession) SelfPermitAllowedIfNecessary(token common.Address, nonce *big.Int, expiry *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.Contract.SelfPermitAllowedIfNecessary(&_V3Router.TransactOpts, token, nonce, expiry, v, r, s)
}
// SelfPermitAllowedIfNecessary is a paid mutator transaction binding the contract method 0xa4a78f0c.
//
// Solidity: function selfPermitAllowedIfNecessary(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterTransactorSession) SelfPermitAllowedIfNecessary(token common.Address, nonce *big.Int, expiry *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.Contract.SelfPermitAllowedIfNecessary(&_V3Router.TransactOpts, token, nonce, expiry, v, r, s)
}
// SelfPermitIfNecessary is a paid mutator transaction binding the contract method 0xc2e3140a.
//
// Solidity: function selfPermitIfNecessary(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterTransactor) SelfPermitIfNecessary(opts *bind.TransactOpts, token common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "selfPermitIfNecessary", token, value, deadline, v, r, s)
}
// SelfPermitIfNecessary is a paid mutator transaction binding the contract method 0xc2e3140a.
//
// Solidity: function selfPermitIfNecessary(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterSession) SelfPermitIfNecessary(token common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.Contract.SelfPermitIfNecessary(&_V3Router.TransactOpts, token, value, deadline, v, r, s)
}
// SelfPermitIfNecessary is a paid mutator transaction binding the contract method 0xc2e3140a.
//
// Solidity: function selfPermitIfNecessary(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) payable returns()
func (_V3Router *V3RouterTransactorSession) SelfPermitIfNecessary(token common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) {
return _V3Router.Contract.SelfPermitIfNecessary(&_V3Router.TransactOpts, token, value, deadline, v, r, s)
}
// SweepToken is a paid mutator transaction binding the contract method 0xdf2ab5bb.
//
// Solidity: function sweepToken(address token, uint256 amountMinimum, address recipient) payable returns()
func (_V3Router *V3RouterTransactor) SweepToken(opts *bind.TransactOpts, token common.Address, amountMinimum *big.Int, recipient common.Address) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "sweepToken", token, amountMinimum, recipient)
}
// SweepToken is a paid mutator transaction binding the contract method 0xdf2ab5bb.
//
// Solidity: function sweepToken(address token, uint256 amountMinimum, address recipient) payable returns()
func (_V3Router *V3RouterSession) SweepToken(token common.Address, amountMinimum *big.Int, recipient common.Address) (*types.Transaction, error) {
return _V3Router.Contract.SweepToken(&_V3Router.TransactOpts, token, amountMinimum, recipient)
}
// SweepToken is a paid mutator transaction binding the contract method 0xdf2ab5bb.
//
// Solidity: function sweepToken(address token, uint256 amountMinimum, address recipient) payable returns()
func (_V3Router *V3RouterTransactorSession) SweepToken(token common.Address, amountMinimum *big.Int, recipient common.Address) (*types.Transaction, error) {
return _V3Router.Contract.SweepToken(&_V3Router.TransactOpts, token, amountMinimum, recipient)
}
// SweepTokenWithFee is a paid mutator transaction binding the contract method 0xe0e189a0.
//
// Solidity: function sweepTokenWithFee(address token, uint256 amountMinimum, address recipient, uint256 feeBips, address feeRecipient) payable returns()
func (_V3Router *V3RouterTransactor) SweepTokenWithFee(opts *bind.TransactOpts, token common.Address, amountMinimum *big.Int, recipient common.Address, feeBips *big.Int, feeRecipient common.Address) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "sweepTokenWithFee", token, amountMinimum, recipient, feeBips, feeRecipient)
}
// SweepTokenWithFee is a paid mutator transaction binding the contract method 0xe0e189a0.
//
// Solidity: function sweepTokenWithFee(address token, uint256 amountMinimum, address recipient, uint256 feeBips, address feeRecipient) payable returns()
func (_V3Router *V3RouterSession) SweepTokenWithFee(token common.Address, amountMinimum *big.Int, recipient common.Address, feeBips *big.Int, feeRecipient common.Address) (*types.Transaction, error) {
return _V3Router.Contract.SweepTokenWithFee(&_V3Router.TransactOpts, token, amountMinimum, recipient, feeBips, feeRecipient)
}
// SweepTokenWithFee is a paid mutator transaction binding the contract method 0xe0e189a0.
//
// Solidity: function sweepTokenWithFee(address token, uint256 amountMinimum, address recipient, uint256 feeBips, address feeRecipient) payable returns()
func (_V3Router *V3RouterTransactorSession) SweepTokenWithFee(token common.Address, amountMinimum *big.Int, recipient common.Address, feeBips *big.Int, feeRecipient common.Address) (*types.Transaction, error) {
return _V3Router.Contract.SweepTokenWithFee(&_V3Router.TransactOpts, token, amountMinimum, recipient, feeBips, feeRecipient)
}
// UnwrapWETH9 is a paid mutator transaction binding the contract method 0x49404b7c.
//
// Solidity: function unwrapWETH9(uint256 amountMinimum, address recipient) payable returns()
func (_V3Router *V3RouterTransactor) UnwrapWETH9(opts *bind.TransactOpts, amountMinimum *big.Int, recipient common.Address) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "unwrapWETH9", amountMinimum, recipient)
}
// UnwrapWETH9 is a paid mutator transaction binding the contract method 0x49404b7c.
//
// Solidity: function unwrapWETH9(uint256 amountMinimum, address recipient) payable returns()
func (_V3Router *V3RouterSession) UnwrapWETH9(amountMinimum *big.Int, recipient common.Address) (*types.Transaction, error) {
return _V3Router.Contract.UnwrapWETH9(&_V3Router.TransactOpts, amountMinimum, recipient)
}
// UnwrapWETH9 is a paid mutator transaction binding the contract method 0x49404b7c.
//
// Solidity: function unwrapWETH9(uint256 amountMinimum, address recipient) payable returns()
func (_V3Router *V3RouterTransactorSession) UnwrapWETH9(amountMinimum *big.Int, recipient common.Address) (*types.Transaction, error) {
return _V3Router.Contract.UnwrapWETH9(&_V3Router.TransactOpts, amountMinimum, recipient)
}
// UnwrapWETH9WithFee is a paid mutator transaction binding the contract method 0x9b2c0a37.
//
// Solidity: function unwrapWETH9WithFee(uint256 amountMinimum, address recipient, uint256 feeBips, address feeRecipient) payable returns()
func (_V3Router *V3RouterTransactor) UnwrapWETH9WithFee(opts *bind.TransactOpts, amountMinimum *big.Int, recipient common.Address, feeBips *big.Int, feeRecipient common.Address) (*types.Transaction, error) {
return _V3Router.contract.Transact(opts, "unwrapWETH9WithFee", amountMinimum, recipient, feeBips, feeRecipient)
}
// UnwrapWETH9WithFee is a paid mutator transaction binding the contract method 0x9b2c0a37.
//
// Solidity: function unwrapWETH9WithFee(uint256 amountMinimum, address recipient, uint256 feeBips, address feeRecipient) payable returns()
func (_V3Router *V3RouterSession) UnwrapWETH9WithFee(amountMinimum *big.Int, recipient common.Address, feeBips *big.Int, feeRecipient common.Address) (*types.Transaction, error) {
return _V3Router.Contract.UnwrapWETH9WithFee(&_V3Router.TransactOpts, amountMinimum, recipient, feeBips, feeRecipient)
}
// UnwrapWETH9WithFee is a paid mutator transaction binding the contract method 0x9b2c0a37.
//
// Solidity: function unwrapWETH9WithFee(uint256 amountMinimum, address recipient, uint256 feeBips, address feeRecipient) payable returns()
func (_V3Router *V3RouterTransactorSession) UnwrapWETH9WithFee(amountMinimum *big.Int, recipient common.Address, feeBips *big.Int, feeRecipient common.Address) (*types.Transaction, error) {
return _V3Router.Contract.UnwrapWETH9WithFee(&_V3Router.TransactOpts, amountMinimum, recipient, feeBips, feeRecipient)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_V3Router *V3RouterTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) {
return _V3Router.contract.RawTransact(opts, nil) // calldata is disallowed for receive function
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_V3Router *V3RouterSession) Receive() (*types.Transaction, error) {
return _V3Router.Contract.Receive(&_V3Router.TransactOpts)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_V3Router *V3RouterTransactorSession) Receive() (*types.Transaction, error) {
return _V3Router.Contract.Receive(&_V3Router.TransactOpts)
}
module code.wuban.net.cn/service/pancakeswapper module code.wuban.net.cn/service/pancakeswapper
go 1.22.8 go 1.24
require ( require (
github.com/adshao/go-binance/v2 v2.6.1 github.com/adshao/go-binance/v2 v2.6.1
......
...@@ -6,11 +6,13 @@ var ( ...@@ -6,11 +6,13 @@ var (
func init() { func init() {
allEnv["bsc"] = Env{ allEnv["bsc"] = Env{
RPC: "https://bscnode.bitheart.org", //RPC: "https://bscnode.bitheart.org",
RPC: "https://four.rpc.48.club",
USDT: "0x55d398326f99059ff775485246999027b3197955", USDT: "0x55d398326f99059ff775485246999027b3197955",
KLKO: "0x215324115417a13879f865Dc5BB651B18A781a59", // KLKO KLKO: "0x215324115417a13879f865Dc5BB651B18A781a59", // KLKO
Permit2: "0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768", Permit2: "0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",
Router: "0x1A0A18AC4BECDDbd6389559687d1A73d8927E416", Router: "0x1b81D678ffb9C0263b24A97847620C99d213eB14",
//Router: "0x1A0A18AC4BECDDbd6389559687d1A73d8927E416",
Pool: "0xcB0AE3B8337f0Cc35563e6b9fC357F2298C0D24a", Pool: "0xcB0AE3B8337f0Cc35563e6b9fC357F2298C0D24a",
ChainId: 56, ChainId: 56,
} }
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"code.wuban.net.cn/service/pancakeswapper/config" "code.wuban.net.cn/service/pancakeswapper/config"
"code.wuban.net.cn/service/pancakeswapper/contracts/buildparam" "code.wuban.net.cn/service/pancakeswapper/contracts/buildparam"
"code.wuban.net.cn/service/pancakeswapper/contracts/erc20" "code.wuban.net.cn/service/pancakeswapper/contracts/erc20"
"code.wuban.net.cn/service/pancakeswapper/contracts/v3router"
"code.wuban.net.cn/service/pancakeswapper/pancake" "code.wuban.net.cn/service/pancakeswapper/pancake"
"code.wuban.net.cn/service/pancakeswapper/types" "code.wuban.net.cn/service/pancakeswapper/types"
"context" "context"
...@@ -59,7 +60,7 @@ func waitTx(client *ethclient.Client, tx *ethtypes.Transaction) *ethtypes.Receip ...@@ -59,7 +60,7 @@ func waitTx(client *ethclient.Client, tx *ethtypes.Transaction) *ethtypes.Receip
func accountApprove(client *ethclient.Client, acc *types.Account, env types.Env) error { func accountApprove(client *ethclient.Client, acc *types.Account, env types.Env) error {
cfg := config.Global cfg := config.Global
permit2 := common.HexToAddress(env.Permit2) //permit2 := common.HexToAddress(env.Permit2)
usdt, err := erc20.NewTokenContract(common.HexToAddress(env.USDT), client) usdt, err := erc20.NewTokenContract(common.HexToAddress(env.USDT), client)
if err != nil { if err != nil {
return fmt.Errorf("erc20.NewTokenContract failed: %v", err) return fmt.Errorf("erc20.NewTokenContract failed: %v", err)
...@@ -77,15 +78,15 @@ func accountApprove(client *ethclient.Client, acc *types.Account, env types.Env) ...@@ -77,15 +78,15 @@ func accountApprove(client *ethclient.Client, acc *types.Account, env types.Env)
addNewTx := func(tx *ethtypes.Transaction) { addNewTx := func(tx *ethtypes.Transaction) {
waitTx(client, tx) waitTx(client, tx)
} }
if tx, err := usdt.Approve(txopts, permit2, abi.MaxUint256); err != nil { //if tx, err := usdt.Approve(txopts, permit2, abi.MaxUint256); err != nil {
return fmt.Errorf("usdt approve permit2 failed: %v", err) // return fmt.Errorf("usdt approve permit2 failed: %v", err)
} else { //} else {
addNewTx(tx) // addNewTx(tx)
} //}
// first approve usdt to permit2. // first approve usdt to permit2.
//if tx, err := usdt.Approve(txopts, permit2, abi.MaxUint256); err != nil { //if tx, err := usdt.Approve(txopts, permit2, abi.MaxUint256); err != nil {
if tx, err := usdt.Approve(txopts, common.HexToAddress(env.Pool), abi.MaxUint256); err != nil { if tx, err := usdt.Approve(txopts, common.HexToAddress(env.Router), abi.MaxUint256); err != nil {
return fmt.Errorf("usdt approve pool failed: %v", err) return fmt.Errorf("usdt approve pool failed: %v", err)
} else { } else {
addNewTx(tx) addNewTx(tx)
...@@ -200,12 +201,12 @@ func HandlerAccountSwap(acc *types.Account, env types.Env, idx uint) { ...@@ -200,12 +201,12 @@ func HandlerAccountSwap(acc *types.Account, env types.Env, idx uint) {
return return
} }
router, err := buildparam.NewParamContract(common.HexToAddress(env.Router), client) //router, err := buildparam.NewParamContract(common.HexToAddress(env.Router), client)
if err != nil { //if err != nil {
addTofailed(acc) // addTofailed(acc)
WriteLog(fmt.Sprintf("[%s] failed: failed to create router contract: %v", acc.Address, err)) // WriteLog(fmt.Sprintf("[%s] failed: failed to create router contract: %v", acc.Address, err))
return // return
} //}
txopts := &bind.TransactOpts{ txopts := &bind.TransactOpts{
From: acc.Addr, From: acc.Addr,
...@@ -236,9 +237,12 @@ func HandlerAccountSwap(acc *types.Account, env types.Env, idx uint) { ...@@ -236,9 +237,12 @@ func HandlerAccountSwap(acc *types.Account, env types.Env, idx uint) {
} }
dec := new(big.Int).SetUint64(1000000000000000000) dec := new(big.Int).SetUint64(1000000000000000000)
fee := big.NewInt(1000) fee := big.NewInt(10000)
for i := 0; i < cfg.Param.Count; i++ { for i := 0; i < cfg.Param.Count; i++ {
in := new(big.Int).Mul(big.NewInt(cfg.Param.Volume), dec) in := new(big.Int).Mul(big.NewInt(cfg.Param.Volume), dec)
in = new(big.Int).Div(in, big.NewInt(10)) // param volume 1 is 0.1
v3r, err := v3router.NewV3Router(common.HexToAddress(env.Router), client)
// calc amountOutMin with price and slippage. // calc amountOutMin with price and slippage.
amountOutMin, err := pancake.GetAmountOutMin(client, env, in, cfg.Param.Slippage, fee) amountOutMin, err := pancake.GetAmountOutMin(client, env, in, cfg.Param.Slippage, fee)
if err != nil { if err != nil {
...@@ -262,7 +266,23 @@ func HandlerAccountSwap(acc *types.Account, env types.Env, idx uint) { ...@@ -262,7 +266,23 @@ func HandlerAccountSwap(acc *types.Account, env types.Env, idx uint) {
inputs := make([][]byte, 0) inputs := make([][]byte, 0)
inputs = append(inputs, data) inputs = append(inputs, data)
deadline := time.Now().Unix() + cfg.Param.Deadline*60 deadline := time.Now().Unix() + cfg.Param.Deadline*60
if execTx, err := router.Execute(txopts, []byte{byte(pancake.V3_SWAP_EXACT_IN)}, inputs, big.NewInt(deadline)); err != nil { //if execTx, err := router.Execute(txopts, []byte{byte(pancake.V3_SWAP_EXACT_IN)}, inputs, big.NewInt(deadline)); err != nil {
// addTofailed(acc)
// WriteLog(fmt.Sprintf("[%s] failed: failed execute swap: %v", acc.Address, err))
// return
//} else {
// addNewTx(execTx)
//}
if execTx, err := v3r.ExactInputSingle(txopts, v3router.ISwapRouterExactInputSingleParams{
TokenIn: common.HexToAddress(env.USDT),
TokenOut: common.HexToAddress(env.KLKO),
Recipient: acc.Addr,
AmountIn: in,
AmountOutMinimum: amountOutMin,
Deadline: big.NewInt(deadline),
Fee: fee,
SqrtPriceLimitX96: big.NewInt(0),
}); err != nil {
addTofailed(acc) addTofailed(acc)
WriteLog(fmt.Sprintf("[%s] failed: failed execute swap: %v", acc.Address, err)) WriteLog(fmt.Sprintf("[%s] failed: failed execute swap: %v", acc.Address, err))
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment