Skip to content

Commit

Permalink
update txjammer (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorian1te authored Jan 30, 2024
1 parent ee04c47 commit 9d27fc7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 388 deletions.
8 changes: 4 additions & 4 deletions tools/txJammer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Options:
-w2, --wallet2 <file> you must send in a json wallet
-p2, --password2 <password> you must send in a password for wallet 2
-d, --durationSeconds <number> the seconds you want to run the txJammer for
-p, --pauseTimeSeconds <number> the seconds you want to pause between actions
-p, --pauseTimeMSeconds <number> the seconds you want to pause between actions
-u, --txAmountInUsd <min-max> the value of each tx in USD terms
-s, --configActions <config> custom action configuration
-s, --configSwap <config> custom swap configuration
Expand All @@ -46,7 +46,7 @@ Runs random txs with a monetary value between 1-3 USD for 60 secs with a pause b
yarn ts-node txJammerCommander.ts \
--wallet1 ./keystore1.txt --password1 123 \
--wallet2 ./keystore2.txt --password2 123 \
--durationSeconds 60 --pauseTimeSeconds 2 \
--durationSeconds 60 --pauseTimeMSeconds 2 \
--txAmountInUsd 1-3 \
--estimateOnly
```
Expand All @@ -72,7 +72,7 @@ Additionally, a specfic **Swap Config** specified with --configSwap, specifies t
yarn ts-node txJammerCommander.ts \
--wallet1 ./keystore1.txt --password1 123 \
--wallet2 ./keystore2.txt --password2 123 \
--durationSeconds 60 --pauseTimeSeconds 2 \
--durationSeconds 60 --pauseTimeMSeconds 2 \
--txAmountInUsd 1-3 \
--estimateOnly \
--configActions "transfer 500, addLp 0, withdrawLp 0, swap 300" \
Expand Down Expand Up @@ -105,7 +105,7 @@ Additionally, a specfic **WithdrawLP Config** specified with --configWithdrawLp,
yarn ts-node txJammerCommander.ts \
--wallet1 ./keystore1.txt --password1 123 \
--wallet2 ./keystore2.txt --password2 123 \
--durationSeconds 60 --pauseTimeSeconds 2 \
--durationSeconds 60 --pauseTimeMSeconds 2 \
--txAmountInUsd 1-3 \
--estimateOnly \
--configTransfer "BNB.BNB 300, BCH.BCH 200, * 50" \
Expand Down
6 changes: 3 additions & 3 deletions tools/txJammer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@xchainjs/xchain-ethereum": "file:../../packages/xchain-ethereum",
"@xchainjs/xchain-litecoin": "file:../../packages/xchain-litecoin",
"@xchainjs/xchain-midgard": "file:../../packages/xchain-midgard",
"@xchainjs/xchain-thorchain": "file:../../packages/xchain-thorchain",
"@xchainjs/xchain-thorchain-amm": "file:../../packages/xchain-thorchain-amm",
"@xchainjs/xchain-thorchain": "0.28.17",
"@xchainjs/xchain-thorchain-amm": "0.8.18",
"@xchainjs/xchain-thornode": "file:../../packages/xchain-thornode",
"@xchainjs/xchain-util": "file:../../packages/xchain-util",
"@xchainjs/xchain-avax": "file:../../packages/xchain-avax",
Expand Down Expand Up @@ -67,4 +67,4 @@
"tslib": "^2.1.0",
"typescript": "^4.2.3"
}
}
}
10 changes: 5 additions & 5 deletions tools/txJammer/txJammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class TxJammer {
private minAmount: number
private maxAmount: number
private durationSeconds: number
private pauseTimeSeconds: number
private pauseTimeMSeconds: number

private keystore1FilePath: string
private keystore1Password: string
Expand All @@ -75,7 +75,7 @@ export class TxJammer {
minAmount: number,
maxAmount: number,
durationSeconds: number,
pauseTimeSeconds: number,
pauseTimeMSeconds: number,
keystore1FilePath: string,
keystore1Password: string,
keystore2FilePath: string,
Expand All @@ -90,7 +90,7 @@ export class TxJammer {
this.minAmount = minAmount
this.maxAmount = maxAmount
this.durationSeconds = durationSeconds
this.pauseTimeSeconds = pauseTimeSeconds
this.pauseTimeMSeconds = pauseTimeMSeconds

this.keystore1FilePath = keystore1FilePath
this.keystore1Password = keystore1Password
Expand Down Expand Up @@ -120,7 +120,6 @@ export class TxJammer {

this.wallet1 = new Wallet(phrase1, this.thorchainQuery)
this.wallet2 = new Wallet(phrase2, this.thorchainQuery)

this.pools = await this.thorchainCache.getPools()
this.setupWeightedActions()
await this.setupWeightedChoices()
Expand Down Expand Up @@ -156,6 +155,7 @@ export class TxJammer {
assetsIncludingSynths.push(asset)
assetsIncludingSynths.push(assetToString(synth))
}
assetsIncludingSynths.push('THOR.RUNE') // add rune to the list of assets
this.setupWeightedSwaps(assetsIncludingSynths)
this.setupWeightedTransfers(assetsIncludingSynths)
this.setupWeightedAddLps(assets)
Expand Down Expand Up @@ -264,7 +264,7 @@ export class TxJammer {
const action = weighted.select(this.weightedActions) as string
console.log(`executing ${action}..`)
await this.executeAction(action)
await delay(this.pauseTimeSeconds * 1000)
await delay(this.pauseTimeMSeconds)
currentTime = new Date()
}
await this.writeToFile()
Expand Down
8 changes: 6 additions & 2 deletions tools/txJammer/txJammerCommander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ program.requiredOption('-p1, --password1 <password>', 'you must send in a passwo
program.requiredOption('-w2, --wallet2 <file> ', 'you must send in a json wallet ')
program.requiredOption('-p2, --password2 <password>', 'you must send in a password for wallet 2')
program.requiredOption('-d, --durationSeconds <number>', 'the seconds you want to run the txJammer for', parseInteger)
program.requiredOption('-p, --pauseTimeSeconds <number>', 'the seconds you want to pause between actions', parseInteger)
program.requiredOption(
'-p, --pauseTimeMSeconds <number>',
'the miliseconds you want to pause between actions',
parseInteger,
)
program.requiredOption('-u, --txAmountInUsd <min-max>', 'the value of each tx in USD terms', parseMinMaxAmounts)
program.option('-s, --configActions <config>', 'custom action configuration ', parseCustomActions)
program.option('-s, --configSwap <config>', 'custom swap configuration ', parseCustomSwap)
Expand All @@ -140,7 +144,7 @@ const txJammer = new TxJammer(
Number(options.txAmountInUsd[0]),
Number(options.txAmountInUsd[1]),
Number(options.durationSeconds),
options.pauseTimeSeconds,
options.pauseTimeMSeconds,
options.wallet1,
options.password1,
options.wallet2,
Expand Down
Loading

0 comments on commit 9d27fc7

Please sign in to comment.