-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemp.ts
71 lines (66 loc) · 2.17 KB
/
temp.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// freezing wallets
startFreezer(params.mint, mainKp)
// create pool
let poolCreationFailed = 0
console.log("\n***************************************************************\n")
while (true) {
if (params.poolId && recoveryMode) {
console.log("Pool id already created before, ", params.poolId.toBase58())
break
}
if (params.poolId && params.poolKeys && recoveryMode) {
console.log("Pool already created before, ", params.poolId.toBase58())
break
}
if (poolCreationFailed > 5) {
console.log("Token creation is failed in repetition, Terminate the process")
return
}
const tokenAmount = new BN(token.uiAmount).mul(new BN(10 ** token.decimals))
const poolInfo = await createPool(mainKp, params.marketId, tokenAmount, token.solAmount)
if (!poolInfo) {
console.log("Pool creation error")
poolCreationFailed++
} else {
const { poolKeys, poolId } = poolInfo
params.poolId = poolId
params.poolKeys = poolKeys
console.log("Pool Id : ", poolId.toBase58())
await outputBalance(mainKp.publicKey)
await sleep(3000)
saveDataToFile(params)
break
}
}
if(!params.poolId){
console.log("Pool id is not set in params")
return
}
// run volume bots
console.log("\n***************************************************************\n")
if (recoveryMode)
runVolumeBot(mainKp, params.mint, params.poolId, params.poolKeys)
else
runVolumeBot(mainKp, params.mint, params.poolId)
await monitorPool(params.poolKeys, token.solAmount, params.poolId)
console.log("\n***************************************************************\n")
let removeTried = 0
while (true) {
if (removeTried > 10) {
console.log("Remove liquidity transaction called many times, pull tx failed")
return
}
const removed = await ammRemoveLiquidity(mainKp, params.poolId, params.poolKeys)
if (removed) {
params.removed = true
saveDataToFile(params)
console.log("Single token has been completed through process")
await sleep(2000)
console.log("\n***************************************************************\n")
console.log(" Preparing for a new token")
return
} else {
console.log("Failed to remove liquidity")
removeTried++
}
}