@aztec/bot 0.0.0-test.1 → 0.0.1-commit.023c3e5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/amm_bot.d.ts +32 -0
- package/dest/amm_bot.d.ts.map +1 -0
- package/dest/amm_bot.js +101 -0
- package/dest/base_bot.d.ts +21 -0
- package/dest/base_bot.d.ts.map +1 -0
- package/dest/base_bot.js +80 -0
- package/dest/bot.d.ts +13 -18
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +27 -86
- package/dest/config.d.ts +84 -60
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +59 -36
- package/dest/factory.d.ts +30 -31
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +318 -139
- package/dest/index.d.ts +4 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -1
- package/dest/interface.d.ts +12 -1
- package/dest/interface.d.ts.map +1 -1
- package/dest/interface.js +5 -0
- package/dest/rpc.d.ts +1 -7
- package/dest/rpc.d.ts.map +1 -1
- package/dest/rpc.js +0 -11
- package/dest/runner.d.ts +15 -11
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +441 -51
- package/dest/store/bot_store.d.ts +44 -0
- package/dest/store/bot_store.d.ts.map +1 -0
- package/dest/store/bot_store.js +107 -0
- package/dest/store/index.d.ts +2 -0
- package/dest/store/index.d.ts.map +1 -0
- package/dest/store/index.js +1 -0
- package/dest/utils.d.ts +8 -5
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +14 -5
- package/package.json +27 -23
- package/src/amm_bot.ts +124 -0
- package/src/base_bot.ts +92 -0
- package/src/bot.ts +53 -103
- package/src/config.ts +98 -68
- package/src/factory.ts +378 -154
- package/src/index.ts +3 -1
- package/src/interface.ts +9 -0
- package/src/rpc.ts +0 -13
- package/src/runner.ts +38 -21
- package/src/store/bot_store.ts +141 -0
- package/src/store/index.ts +1 -0
- package/src/utils.ts +17 -6
package/src/bot.ts
CHANGED
|
@@ -1,40 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type Wallet,
|
|
7
|
-
createLogger,
|
|
8
|
-
} from '@aztec/aztec.js';
|
|
9
|
-
import { timesParallel } from '@aztec/foundation/collection';
|
|
10
|
-
import type { EasyPrivateTokenContract } from '@aztec/noir-contracts.js/EasyPrivateToken';
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
4
|
+
import { times } from '@aztec/foundation/collection';
|
|
5
|
+
import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
11
6
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
|
|
7
|
+
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
8
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
15
9
|
|
|
10
|
+
import { BaseBot } from './base_bot.js';
|
|
16
11
|
import type { BotConfig } from './config.js';
|
|
17
12
|
import { BotFactory } from './factory.js';
|
|
13
|
+
import type { BotStore } from './store/index.js';
|
|
18
14
|
import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils.js';
|
|
19
15
|
|
|
20
16
|
const TRANSFER_AMOUNT = 1;
|
|
21
17
|
|
|
22
|
-
export class Bot {
|
|
23
|
-
private log = createLogger('bot');
|
|
24
|
-
|
|
25
|
-
private attempts: number = 0;
|
|
26
|
-
private successes: number = 0;
|
|
27
|
-
|
|
18
|
+
export class Bot extends BaseBot {
|
|
28
19
|
protected constructor(
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
node: AztecNode,
|
|
21
|
+
wallet: TestWallet,
|
|
22
|
+
defaultAccountAddress: AztecAddress,
|
|
23
|
+
public readonly token: TokenContract | PrivateTokenContract,
|
|
31
24
|
public readonly recipient: AztecAddress,
|
|
32
|
-
|
|
33
|
-
) {
|
|
25
|
+
config: BotConfig,
|
|
26
|
+
) {
|
|
27
|
+
super(node, wallet, defaultAccountAddress, config);
|
|
28
|
+
}
|
|
34
29
|
|
|
35
|
-
static async create(
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
static async create(
|
|
31
|
+
config: BotConfig,
|
|
32
|
+
wallet: TestWallet,
|
|
33
|
+
aztecNode: AztecNode,
|
|
34
|
+
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
35
|
+
store: BotStore,
|
|
36
|
+
): Promise<Bot> {
|
|
37
|
+
const { defaultAccountAddress, token, recipient } = await new BotFactory(
|
|
38
|
+
config,
|
|
39
|
+
wallet,
|
|
40
|
+
store,
|
|
41
|
+
aztecNode,
|
|
42
|
+
aztecNodeAdmin,
|
|
43
|
+
).setup();
|
|
44
|
+
return new Bot(aztecNode, wallet, defaultAccountAddress, token, recipient, config);
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
public updateConfig(config: Partial<BotConfig>) {
|
|
@@ -42,110 +49,53 @@ export class Bot {
|
|
|
42
49
|
this.config = { ...this.config, ...config };
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
const logCtx = { runId: Date.now() * 1000 + Math.floor(Math.random() * 1000) };
|
|
48
|
-
const { privateTransfersPerTx, publicTransfersPerTx, feePaymentMethod, followChain, txMinedWaitSeconds } =
|
|
49
|
-
this.config;
|
|
52
|
+
protected async createAndSendTx(logCtx: object): Promise<TxHash> {
|
|
53
|
+
const { privateTransfersPerTx, publicTransfersPerTx, feePaymentMethod } = this.config;
|
|
50
54
|
const { token, recipient, wallet } = this;
|
|
51
|
-
const sender = wallet.getAddress();
|
|
52
55
|
|
|
53
56
|
this.log.verbose(
|
|
54
57
|
`Preparing tx with ${feePaymentMethod} fee with ${privateTransfersPerTx} private and ${publicTransfersPerTx} public transfers`,
|
|
55
58
|
logCtx,
|
|
56
59
|
);
|
|
57
60
|
|
|
58
|
-
const calls
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
)),
|
|
69
|
-
);
|
|
70
|
-
} else {
|
|
71
|
-
calls.push(
|
|
72
|
-
...(await timesParallel(privateTransfersPerTx, () =>
|
|
73
|
-
token.methods.transfer(TRANSFER_AMOUNT, sender, recipient).request(),
|
|
74
|
-
)),
|
|
75
|
-
);
|
|
76
|
-
}
|
|
61
|
+
const calls = isStandardTokenContract(token)
|
|
62
|
+
? [
|
|
63
|
+
times(privateTransfersPerTx, () => token.methods.transfer(recipient, TRANSFER_AMOUNT)),
|
|
64
|
+
times(publicTransfersPerTx, () =>
|
|
65
|
+
token.methods.transfer_in_public(this.defaultAccountAddress, recipient, TRANSFER_AMOUNT, 0),
|
|
66
|
+
),
|
|
67
|
+
].flat()
|
|
68
|
+
: times(privateTransfersPerTx, () =>
|
|
69
|
+
token.methods.transfer(TRANSFER_AMOUNT, this.defaultAccountAddress, recipient),
|
|
70
|
+
);
|
|
77
71
|
|
|
78
|
-
const opts = this.getSendMethodOpts();
|
|
79
72
|
const batch = new BatchCall(wallet, calls);
|
|
73
|
+
const opts = await this.getSendMethodOpts(batch);
|
|
80
74
|
|
|
81
75
|
this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx);
|
|
82
|
-
await batch.simulate();
|
|
83
|
-
|
|
84
|
-
this.log.verbose(`Proving transaction`, logCtx);
|
|
85
|
-
const provenTx = await batch.prove(opts);
|
|
86
|
-
|
|
87
|
-
this.log.verbose(`Sending tx`, logCtx);
|
|
88
|
-
const tx = provenTx.send();
|
|
89
|
-
|
|
90
|
-
const txHash = await tx.getTxHash();
|
|
91
|
-
|
|
92
|
-
if (followChain === 'NONE') {
|
|
93
|
-
this.log.info(`Transaction ${txHash} sent, not waiting for it to be mined`);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
76
|
+
await batch.simulate({ from: this.defaultAccountAddress });
|
|
96
77
|
|
|
97
|
-
this.log.verbose(
|
|
98
|
-
|
|
99
|
-
logCtx,
|
|
100
|
-
);
|
|
101
|
-
const receipt = await tx.wait({
|
|
102
|
-
timeout: txMinedWaitSeconds,
|
|
103
|
-
provenTimeout: txMinedWaitSeconds,
|
|
104
|
-
proven: followChain === 'PROVEN',
|
|
105
|
-
});
|
|
106
|
-
this.log.info(
|
|
107
|
-
`Tx #${this.attempts} ${receipt.txHash} successfully mined in block ${receipt.blockNumber} (stats: ${this.successes}/${this.attempts} success)`,
|
|
108
|
-
logCtx,
|
|
109
|
-
);
|
|
110
|
-
this.successes++;
|
|
78
|
+
this.log.verbose(`Sending transaction`, logCtx);
|
|
79
|
+
return batch.send({ ...opts, wait: NO_WAIT });
|
|
111
80
|
}
|
|
112
81
|
|
|
113
82
|
public async getBalances() {
|
|
114
83
|
if (isStandardTokenContract(this.token)) {
|
|
115
84
|
return {
|
|
116
|
-
sender: await getBalances(this.token, this.
|
|
117
|
-
recipient: await getBalances(this.token, this.recipient),
|
|
85
|
+
sender: await getBalances(this.token, this.defaultAccountAddress),
|
|
86
|
+
recipient: await getBalances(this.token, this.recipient, this.defaultAccountAddress),
|
|
118
87
|
};
|
|
119
88
|
} else {
|
|
120
89
|
return {
|
|
121
90
|
sender: {
|
|
122
|
-
privateBalance: await getPrivateBalance(this.token, this.
|
|
91
|
+
privateBalance: await getPrivateBalance(this.token, this.defaultAccountAddress),
|
|
123
92
|
publicBalance: 0n,
|
|
124
93
|
},
|
|
125
94
|
recipient: {
|
|
126
|
-
privateBalance: await getPrivateBalance(this.token, this.recipient),
|
|
95
|
+
privateBalance: await getPrivateBalance(this.token, this.recipient, this.defaultAccountAddress),
|
|
127
96
|
publicBalance: 0n,
|
|
128
97
|
},
|
|
129
98
|
};
|
|
130
99
|
}
|
|
131
100
|
}
|
|
132
|
-
|
|
133
|
-
private getSendMethodOpts(): SendMethodOptions {
|
|
134
|
-
const sender = this.wallet.getAddress();
|
|
135
|
-
const { l2GasLimit, daGasLimit, skipPublicSimulation } = this.config;
|
|
136
|
-
const paymentMethod = new FeeJuicePaymentMethod(sender);
|
|
137
|
-
|
|
138
|
-
let gasSettings, estimateGas;
|
|
139
|
-
if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
|
|
140
|
-
gasSettings = { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) };
|
|
141
|
-
estimateGas = false;
|
|
142
|
-
this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
|
|
143
|
-
} else {
|
|
144
|
-
estimateGas = true;
|
|
145
|
-
this.log.verbose(`Estimating gas for transaction`);
|
|
146
|
-
}
|
|
147
|
-
const baseFeePadding = 2; // Send 3x the current base fee
|
|
148
|
-
this.log.verbose(skipPublicSimulation ? `Skipping public simulation` : `Simulating public transfers`);
|
|
149
|
-
return { fee: { estimateGas, paymentMethod, gasSettings, baseFeePadding }, skipPublicSimulation };
|
|
150
|
-
}
|
|
151
101
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
|
+
SecretValue,
|
|
3
4
|
booleanConfigHelper,
|
|
4
5
|
getConfigFromMappings,
|
|
5
6
|
getDefaultConfig,
|
|
6
7
|
numberConfigHelper,
|
|
7
8
|
optionalNumberConfigHelper,
|
|
9
|
+
pickConfigMappings,
|
|
10
|
+
secretFrConfigHelper,
|
|
11
|
+
secretStringConfigHelper,
|
|
8
12
|
} from '@aztec/foundation/config';
|
|
9
|
-
import { Fr } from '@aztec/foundation/
|
|
13
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
10
15
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
16
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
17
|
+
import { schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
13
18
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
14
19
|
|
|
15
20
|
import { z } from 'zod';
|
|
@@ -19,25 +24,27 @@ type BotFollowChain = (typeof BotFollowChain)[number];
|
|
|
19
24
|
|
|
20
25
|
export enum SupportedTokenContracts {
|
|
21
26
|
TokenContract = 'TokenContract',
|
|
22
|
-
|
|
27
|
+
PrivateTokenContract = 'PrivateTokenContract',
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
export type BotConfig = {
|
|
26
31
|
/** The URL to the Aztec node to check for tx pool status. */
|
|
27
32
|
nodeUrl: string | undefined;
|
|
28
|
-
/** URL to the
|
|
29
|
-
|
|
33
|
+
/** The URL to the Aztec node admin API to force-flush txs if configured. */
|
|
34
|
+
nodeAdminUrl: string | undefined;
|
|
30
35
|
/** Url of the ethereum host. */
|
|
31
36
|
l1RpcUrls: string[] | undefined;
|
|
32
37
|
/** The mnemonic for the account to bridge fee juice from L1. */
|
|
33
|
-
l1Mnemonic: string | undefined;
|
|
38
|
+
l1Mnemonic: SecretValue<string> | undefined;
|
|
34
39
|
/** The private key for the account to bridge fee juice from L1. */
|
|
35
|
-
l1PrivateKey: string | undefined;
|
|
40
|
+
l1PrivateKey: SecretValue<string> | undefined;
|
|
41
|
+
/** How long to wait for L1 to L2 messages to become available on L2 */
|
|
42
|
+
l1ToL2MessageTimeoutSeconds: number;
|
|
36
43
|
/** Signing private key for the sender account. */
|
|
37
|
-
senderPrivateKey: Fr | undefined;
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
/** Salt for the token contract
|
|
44
|
+
senderPrivateKey: SecretValue<Fr> | undefined;
|
|
45
|
+
/** Optional salt to use to instantiate the sender account */
|
|
46
|
+
senderSalt: Fr | undefined;
|
|
47
|
+
/** Salt for the token contract instantiation. */
|
|
41
48
|
tokenSalt: Fr;
|
|
42
49
|
/** Every how many seconds should a new tx be sent. */
|
|
43
50
|
txIntervalSeconds: number;
|
|
@@ -47,6 +54,8 @@ export type BotConfig = {
|
|
|
47
54
|
publicTransfersPerTx: number;
|
|
48
55
|
/** How to handle fee payments. */
|
|
49
56
|
feePaymentMethod: 'fee_juice';
|
|
57
|
+
/** 'How much is the bot willing to overpay vs. the current min fee' */
|
|
58
|
+
minFeePadding: number;
|
|
50
59
|
/** True to not automatically setup or start the bot on initialization. */
|
|
51
60
|
noStart: boolean;
|
|
52
61
|
/** How long to wait for a tx to be mined before reporting an error. */
|
|
@@ -57,8 +66,6 @@ export type BotConfig = {
|
|
|
57
66
|
maxPendingTxs: number;
|
|
58
67
|
/** Whether to flush after sending each 'setup' transaction */
|
|
59
68
|
flushSetupTransactions: boolean;
|
|
60
|
-
/** Whether to skip public simulation of txs before sending them. */
|
|
61
|
-
skipPublicSimulation: boolean;
|
|
62
69
|
/** L2 gas limit for the tx (empty to have the bot trigger an estimate gas). */
|
|
63
70
|
l2GasLimit: number | undefined;
|
|
64
71
|
/** DA gas limit for the tx (empty to have the bot trigger an estimate gas). */
|
|
@@ -69,54 +76,65 @@ export type BotConfig = {
|
|
|
69
76
|
maxConsecutiveErrors: number;
|
|
70
77
|
/** Stops the bot if service becomes unhealthy */
|
|
71
78
|
stopWhenUnhealthy: boolean;
|
|
72
|
-
|
|
79
|
+
/** Deploy an AMM contract and do swaps instead of transfers */
|
|
80
|
+
ammTxs: boolean;
|
|
81
|
+
} & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'>;
|
|
73
82
|
|
|
74
|
-
export const BotConfigSchema =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
83
|
+
export const BotConfigSchema = zodFor<BotConfig>()(
|
|
84
|
+
z
|
|
85
|
+
.object({
|
|
86
|
+
nodeUrl: z.string().optional(),
|
|
87
|
+
nodeAdminUrl: z.string().optional(),
|
|
88
|
+
l1RpcUrls: z.array(z.string()).optional(),
|
|
89
|
+
l1Mnemonic: schemas.SecretValue(z.string()).optional(),
|
|
90
|
+
l1PrivateKey: schemas.SecretValue(z.string()).optional(),
|
|
91
|
+
l1ToL2MessageTimeoutSeconds: z.number(),
|
|
92
|
+
senderPrivateKey: schemas.SecretValue(schemas.Fr).optional(),
|
|
93
|
+
senderSalt: schemas.Fr.optional(),
|
|
94
|
+
tokenSalt: schemas.Fr,
|
|
95
|
+
txIntervalSeconds: z.number(),
|
|
96
|
+
privateTransfersPerTx: z.number().int().nonnegative(),
|
|
97
|
+
publicTransfersPerTx: z.number().int().nonnegative(),
|
|
98
|
+
feePaymentMethod: z.literal('fee_juice'),
|
|
99
|
+
minFeePadding: z.number().int().nonnegative(),
|
|
100
|
+
noStart: z.boolean(),
|
|
101
|
+
txMinedWaitSeconds: z.number(),
|
|
102
|
+
followChain: z.enum(BotFollowChain),
|
|
103
|
+
maxPendingTxs: z.number().int().nonnegative(),
|
|
104
|
+
flushSetupTransactions: z.boolean(),
|
|
105
|
+
l2GasLimit: z.number().int().nonnegative().optional(),
|
|
106
|
+
daGasLimit: z.number().int().nonnegative().optional(),
|
|
107
|
+
contract: z.nativeEnum(SupportedTokenContracts),
|
|
108
|
+
maxConsecutiveErrors: z.number().int().nonnegative(),
|
|
109
|
+
stopWhenUnhealthy: z.boolean(),
|
|
110
|
+
ammTxs: z.boolean().default(false),
|
|
111
|
+
dataDirectory: z.string().optional(),
|
|
112
|
+
dataStoreMapSizeKb: z.number().optional(),
|
|
113
|
+
})
|
|
114
|
+
.transform(config => ({
|
|
115
|
+
nodeUrl: undefined,
|
|
116
|
+
nodeAdminUrl: undefined,
|
|
117
|
+
l1RpcUrls: undefined,
|
|
118
|
+
senderSalt: undefined,
|
|
119
|
+
l2GasLimit: undefined,
|
|
120
|
+
daGasLimit: undefined,
|
|
121
|
+
l1Mnemonic: undefined,
|
|
122
|
+
l1PrivateKey: undefined,
|
|
123
|
+
senderPrivateKey: undefined,
|
|
124
|
+
dataDirectory: undefined,
|
|
125
|
+
dataStoreMapSizeKb: 1_024 * 1_024,
|
|
126
|
+
...config,
|
|
127
|
+
})),
|
|
128
|
+
);
|
|
111
129
|
|
|
112
130
|
export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
113
131
|
nodeUrl: {
|
|
114
132
|
env: 'AZTEC_NODE_URL',
|
|
115
133
|
description: 'The URL to the Aztec node to check for tx pool status.',
|
|
116
134
|
},
|
|
117
|
-
|
|
118
|
-
env: '
|
|
119
|
-
description: 'URL to the
|
|
135
|
+
nodeAdminUrl: {
|
|
136
|
+
env: 'AZTEC_NODE_ADMIN_URL',
|
|
137
|
+
description: 'The URL to the Aztec node admin API to force-flush txs if configured.',
|
|
120
138
|
},
|
|
121
139
|
l1RpcUrls: {
|
|
122
140
|
env: 'ETHEREUM_HOSTS',
|
|
@@ -126,25 +144,31 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
126
144
|
l1Mnemonic: {
|
|
127
145
|
env: 'BOT_L1_MNEMONIC',
|
|
128
146
|
description: 'The mnemonic for the account to bridge fee juice from L1.',
|
|
147
|
+
...secretStringConfigHelper(),
|
|
129
148
|
},
|
|
130
149
|
l1PrivateKey: {
|
|
131
150
|
env: 'BOT_L1_PRIVATE_KEY',
|
|
132
151
|
description: 'The private key for the account to bridge fee juice from L1.',
|
|
152
|
+
...secretStringConfigHelper(),
|
|
153
|
+
},
|
|
154
|
+
l1ToL2MessageTimeoutSeconds: {
|
|
155
|
+
env: 'BOT_L1_TO_L2_TIMEOUT_SECONDS',
|
|
156
|
+
description: 'How long to wait for L1 to L2 messages to become available on L2',
|
|
157
|
+
...numberConfigHelper(3600),
|
|
133
158
|
},
|
|
134
159
|
senderPrivateKey: {
|
|
135
160
|
env: 'BOT_PRIVATE_KEY',
|
|
136
161
|
description: 'Signing private key for the sender account.',
|
|
137
|
-
|
|
162
|
+
...secretFrConfigHelper(),
|
|
138
163
|
},
|
|
139
|
-
|
|
140
|
-
env: '
|
|
141
|
-
description: '
|
|
142
|
-
parseEnv: (val: string) => Fr.fromHexString(val),
|
|
143
|
-
defaultValue: Fr.fromHexString('0xcafecafe'),
|
|
164
|
+
senderSalt: {
|
|
165
|
+
env: 'BOT_ACCOUNT_SALT',
|
|
166
|
+
description: 'The salt to use to deploy the sender account.',
|
|
167
|
+
parseEnv: (val: string) => (val ? Fr.fromHexString(val) : undefined),
|
|
144
168
|
},
|
|
145
169
|
tokenSalt: {
|
|
146
170
|
env: 'BOT_TOKEN_SALT',
|
|
147
|
-
description: '
|
|
171
|
+
description: 'The salt to use to deploy the token contract.',
|
|
148
172
|
parseEnv: (val: string) => Fr.fromHexString(val),
|
|
149
173
|
defaultValue: Fr.fromHexString('1'),
|
|
150
174
|
},
|
|
@@ -169,6 +193,11 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
169
193
|
parseEnv: val => (val as 'fee_juice') || undefined,
|
|
170
194
|
defaultValue: 'fee_juice',
|
|
171
195
|
},
|
|
196
|
+
minFeePadding: {
|
|
197
|
+
env: 'BOT_MIN_FEE_PADDING',
|
|
198
|
+
description: 'How much is the bot willing to overpay vs. the current base fee',
|
|
199
|
+
...numberConfigHelper(3),
|
|
200
|
+
},
|
|
172
201
|
noStart: {
|
|
173
202
|
env: 'BOT_NO_START',
|
|
174
203
|
description: 'True to not automatically setup or start the bot on initialization.',
|
|
@@ -200,11 +229,6 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
200
229
|
description: 'Make a request for the sequencer to build a block after each setup transaction.',
|
|
201
230
|
...booleanConfigHelper(false),
|
|
202
231
|
},
|
|
203
|
-
skipPublicSimulation: {
|
|
204
|
-
env: 'BOT_SKIP_PUBLIC_SIMULATION',
|
|
205
|
-
description: 'Whether to skip public simulation of txs before sending them.',
|
|
206
|
-
...booleanConfigHelper(false),
|
|
207
|
-
},
|
|
208
232
|
l2GasLimit: {
|
|
209
233
|
env: 'BOT_L2_GAS_LIMIT',
|
|
210
234
|
description: 'L2 gas limit for the tx (empty to have the bot trigger an estimate gas).',
|
|
@@ -240,6 +264,12 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
240
264
|
description: 'Stops the bot if service becomes unhealthy',
|
|
241
265
|
...booleanConfigHelper(false),
|
|
242
266
|
},
|
|
267
|
+
ammTxs: {
|
|
268
|
+
env: 'BOT_AMM_TXS',
|
|
269
|
+
description: 'Deploy an AMM and send swaps to it',
|
|
270
|
+
...booleanConfigHelper(false),
|
|
271
|
+
},
|
|
272
|
+
...pickConfigMappings(dataConfigMappings, ['dataStoreMapSizeKb', 'dataDirectory']),
|
|
243
273
|
};
|
|
244
274
|
|
|
245
275
|
export function getBotConfigFromEnv(): BotConfig {
|
|
@@ -252,7 +282,7 @@ export function getBotDefaultConfig(): BotConfig {
|
|
|
252
282
|
|
|
253
283
|
export function getVersions(): Partial<ComponentsVersions> {
|
|
254
284
|
return {
|
|
255
|
-
|
|
285
|
+
l2ProtocolContractsHash: protocolContractsHash.toString(),
|
|
256
286
|
l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
|
|
257
287
|
};
|
|
258
288
|
}
|