Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pancakeSwaper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
pancakeSwaper
Commits
5860be39
Commit
5860be39
authored
Apr 10, 2025
by
luxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
34b01480
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
238 additions
and
142 deletions
+238
-142
README.md
README.md
+12
-14
accounts.csv
accounts.csv
+2
-0
accounts.json
accounts.json
+0
-5
config.yml
config.yml
+7
-1
config.go
config/config.go
+6
-0
pack.go
pancake/pack.go
+8
-6
swapper.go
swapper/swapper.go
+1
-1
account.go
types/account.go
+3
-2
env.go
types/env.go
+13
-15
account.go
work/account.go
+186
-98
No files found.
README.md
View file @
5860be39
...
...
@@ -23,19 +23,11 @@ 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"
}
]
#### 2. fill in the `accounts.csv` file with the accounts you want to do swap for.
The example of the
`accounts.csv`
file is as follow:
```
csv
useraddress, privatekey, recipient
0xeFbb75e446Ec2d8493B3d4d91aC3118953f69b55, 0x1111111111111111, 0xc437593d9C296bf9A5002522A86dad8a4d4Af808
```
#### 4. change configure
...
...
@@ -55,6 +47,12 @@ param:
# tx deadline, unit is minutes, set 0 to disable.
deadline
:
20
pair
:
# pair address.
pair
:
"
0xcB0AE3B8337f0Cc35563e6b9fC357F2298C0D24a"
# klko address
token
:
"
0x215324115417a13879f865Dc5BB651B18A781a59"
rpc
:
env
:
"
bsc"
pool
:
20
...
...
@@ -62,7 +60,7 @@ rpc:
log
:
level
:
"
debug"
users
:
"
accounts.
json
"
users
:
"
accounts.
csv
"
```
#### 5. run the program
...
...
accounts.csv
0 → 100644
View file @
5860be39
useraddress, privatekey, recipient
0xeFbb75e446Ec2d8493B3d4d91aC3118953f69b55, 0x1111111111111111, 0xc437593d9C296bf9A5002522A86dad8a4d4Af808
\ No newline at end of file
accounts.json
deleted
100755 → 0
View file @
34b01480
[
{
"address"
:
"","private"
:
"0x"
},
{
"address"
:
"","private"
:
"0x"
},
{
"address"
:
"","private"
:
"0x"
}
]
\ No newline at end of file
config.yml
View file @
5860be39
...
...
@@ -12,6 +12,12 @@ param:
# tx deadline, unit is minutes, set 0 to disable.
deadline
:
20
pair
:
# pair address.
pair
:
"
0xcB0AE3B8337f0Cc35563e6b9fC357F2298C0D24a"
# klko address
token
:
"
0x215324115417a13879f865Dc5BB651B18A781a59"
rpc
:
env
:
"
bsc"
pool
:
20
...
...
@@ -19,4 +25,4 @@ rpc:
log
:
level
:
"
debug"
users
:
"
accounts.json"
\ No newline at end of file
users
:
"
accounts.csv"
\ No newline at end of file
config/config.go
View file @
5860be39
...
...
@@ -12,6 +12,7 @@ import (
type
Config
struct
{
Log
LogConfig
`yaml:"log"`
Param
ParamConfig
`yaml:"param"`
Pair
PairConfig
`yaml:"pair"`
Rpc
RpcConfig
`yaml:"rpc"`
Users
string
`yaml:"users"`
}
...
...
@@ -25,6 +26,11 @@ type ParamConfig struct {
Deadline
int64
`yaml:"deadline"`
}
type
PairConfig
struct
{
Pair
string
`yaml:"pair"`
Token
string
`yaml:"token"`
}
type
RpcConfig
struct
{
Env
string
`yaml:"env"`
PoolSize
int
`yaml:"pool"`
...
...
pancake/pack.go
View file @
5860be39
package
pancake
import
(
"code.wuban.net.cn/service/pancakeswapper/config"
"code.wuban.net.cn/service/pancakeswapper/contracts/buildparam"
"code.wuban.net.cn/service/pancakeswapper/contracts/v3pool"
"code.wuban.net.cn/service/pancakeswapper/types"
...
...
@@ -30,7 +31,7 @@ func leftPadding(data []byte, length int) []byte {
return
append
(
padding
,
data
...
)
}
func
MakeV3SwapExactInPathData
(
env
types
.
Env
)
[]
byte
{
func
MakeV3SwapExactInPathData
(
env
types
.
Env
,
cfg
*
config
.
Config
)
[]
byte
{
//0000000000000000000000003e3b4d16ce35840c28f90edb7f38e5bdd976c7e3
//0000000000000000000000000000000000000000000000001bc16d674ec80000
//0000000000000000000000000000000000000000000000002620b5d4cdab6c04
...
...
@@ -40,7 +41,7 @@ func MakeV3SwapExactInPathData(env types.Env) []byte {
//55d398326f99059ff775485246999027b3197955002710215324115417a13879f865dc5bb651b18a781a59000000000000000000000000000000000000000000
token0
:=
common
.
HexToAddress
(
env
.
USDT
)
token1
:=
common
.
HexToAddress
(
env
.
KLKO
)
token1
:=
common
.
HexToAddress
(
cfg
.
Pair
.
Token
)
fee
:=
big
.
NewInt
(
10000
)
data
:=
make
([]
byte
,
0
)
data
=
append
(
data
,
token0
.
Bytes
()
...
)
...
...
@@ -49,7 +50,7 @@ func MakeV3SwapExactInPathData(env types.Env) []byte {
return
data
}
func
MakeV3SwapExactInData
(
env
types
.
Env
,
param
ParamV3SwapExactIn
)
([]
byte
,
error
)
{
func
MakeV3SwapExactInData
(
env
types
.
Env
,
param
ParamV3SwapExactIn
,
cfg
*
config
.
Config
)
([]
byte
,
error
)
{
//0000000000000000000000003e3b4d16ce35840c28f90edb7f38e5bdd976c7e3
//0000000000000000000000000000000000000000000000000de0b6b3a7640000
//00000000000000000000000000000000000000000000000012d0ee4f5819f972
...
...
@@ -59,7 +60,7 @@ func MakeV3SwapExactInData(env types.Env, param ParamV3SwapExactIn) ([]byte, err
//55d398326f99059ff775485246999027b3197955002710215324115417a13879
//f865dc5bb651b18a781a59000000000000000000000000000000000000000000
param
.
Path
=
MakeV3SwapExactInPathData
(
env
)
param
.
Path
=
MakeV3SwapExactInPathData
(
env
,
cfg
)
buildAbi
,
_
:=
abi
.
JSON
(
strings
.
NewReader
(
buildparam
.
ParamContractMetaData
.
ABI
))
data
,
err
:=
buildAbi
.
Pack
(
"buildParamV3_SWAP_EXACT_IN"
,
param
.
Recipient
,
param
.
AmountIn
,
param
.
AmountOutMin
,
param
.
Path
,
param
.
PayerIsUser
)
...
...
@@ -103,10 +104,10 @@ func MakePermit2PermitData(acc *types.Account, env types.Env) ([]byte, error) {
// amountIn is the amount of input token (USDT) to swap.
// slippage is the maximum slippage allowed for the swap, the value is percent mul 1000, eg: 20 is 2%.
// feeRate is the fee charged by the pool, the value is percent mul 1000000, eg: 10000 is 1%.
func
GetAmountOutMin
(
client
*
ethclient
.
Client
,
env
types
.
Env
,
amountIn
*
big
.
Int
,
func
GetAmountOutMin
(
c
fg
*
config
.
Config
,
c
lient
*
ethclient
.
Client
,
env
types
.
Env
,
amountIn
*
big
.
Int
,
slippage
int64
,
feeRate
*
big
.
Int
)
(
*
big
.
Int
,
error
)
{
// get slot0 data.
pool
:=
common
.
HexToAddress
(
env
.
Pool
)
pool
:=
common
.
HexToAddress
(
cfg
.
Pair
.
Pair
)
contract
,
err
:=
v3pool
.
NewV3Pool
(
pool
,
client
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -216,6 +217,7 @@ func MakePermit2PermitData2(acc *types.Account, env types.Env, client *ethclient
// Pack the data
buildAbi
,
_
:=
abi
.
JSON
(
strings
.
NewReader
(
buildparam
.
ParamContractMetaData
.
ABI
))
// todo: check method name.
data
,
err
:=
buildAbi
.
Pack
(
"buildParamPermit2"
,
permitSingle
,
signature
)
if
err
!=
nil
{
return
nil
,
err
...
...
swapper/swapper.go
View file @
5860be39
...
...
@@ -26,7 +26,7 @@ func (s *Swapper) Run() {
work
.
WorkInit
(
env
.
ChainId
)
// 1. read account info from json file
accs
:=
work
.
LoadAccounts
(
s
.
cfg
.
Users
)
accs
:=
work
.
LoadAccounts
FromCsv
(
s
.
cfg
.
Users
)
work
.
SetTotalUser
(
len
(
accs
))
waitCh
:=
make
(
chan
struct
{})
...
...
types/account.go
View file @
5860be39
...
...
@@ -13,8 +13,9 @@ type Account struct {
Address
string
`json:"address"`
PrivateKey
string
`json:"private"`
//Nonce uint64 `json:"-"`
PK
*
ecdsa
.
PrivateKey
`json:"-"`
Addr
common
.
Address
`json:"-"`
PK
*
ecdsa
.
PrivateKey
`json:"-"`
Addr
common
.
Address
`json:"-"`
Recipient
string
`json:“recipient"`
}
func
(
a
*
Account
)
sign
(
chainid
*
big
.
Int
,
tx
*
types
.
Transaction
)
(
*
types
.
Transaction
,
error
)
{
...
...
types/env.go
View file @
5860be39
...
...
@@ -6,25 +6,23 @@ var (
func
init
()
{
allEnv
[
"bsc"
]
=
Env
{
//RPC: "https://bscnode.bitheart.org",
RPC
:
"https://four.rpc.48.club"
,
USDT
:
"0x55d398326f99059ff775485246999027b3197955"
,
KLKO
:
"0x215324115417a13879f865Dc5BB651B18A781a59"
,
// KLKO
Permit2
:
"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768"
,
Router
:
"0x1b81D678ffb9C0263b24A97847620C99d213eB14"
,
//Router: "0x1A0A18AC4BECDDbd6389559687d1A73d8927E416",
Pool
:
"0xcB0AE3B8337f0Cc35563e6b9fC357F2298C0D24a"
,
ChainId
:
56
,
RPC
:
"https://four.rpc.48.club"
,
USDT
:
"0x55d398326f99059ff775485246999027b3197955"
,
Permit2
:
"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768"
,
Router
:
"0x1b81D678ffb9C0263b24A97847620C99d213eB14"
,
UniversalRouter
:
"0x1A0A18AC4BECDDbd6389559687d1A73d8927E416"
,
ChainId
:
56
,
}
}
type
Env
struct
{
RPC
string
USDT
string
KLKO
string
Permit2
string
Router
string
Pool
string
RPC
string
USDT
string
//KLKO string
Permit2
string
Router
string
// v3 router.
UniversalRouter
string
//Pool string
ChainId
int64
}
...
...
work/account.go
View file @
5860be39
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment