@aztec/bot 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108

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.
Files changed (46) hide show
  1. package/dest/amm_bot.d.ts +9 -9
  2. package/dest/amm_bot.d.ts.map +1 -1
  3. package/dest/amm_bot.js +23 -20
  4. package/dest/base_bot.d.ts +11 -8
  5. package/dest/base_bot.d.ts.map +1 -1
  6. package/dest/base_bot.js +18 -18
  7. package/dest/bot.d.ts +8 -9
  8. package/dest/bot.d.ts.map +1 -1
  9. package/dest/bot.js +11 -12
  10. package/dest/config.d.ts +53 -50
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +27 -25
  13. package/dest/factory.d.ts +14 -32
  14. package/dest/factory.d.ts.map +1 -1
  15. package/dest/factory.js +137 -115
  16. package/dest/index.d.ts +2 -1
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +1 -0
  19. package/dest/interface.d.ts +2 -2
  20. package/dest/interface.d.ts.map +1 -1
  21. package/dest/interface.js +1 -1
  22. package/dest/rpc.d.ts +1 -1
  23. package/dest/runner.d.ts +12 -13
  24. package/dest/runner.d.ts.map +1 -1
  25. package/dest/runner.js +429 -61
  26. package/dest/store/bot_store.d.ts +44 -0
  27. package/dest/store/bot_store.d.ts.map +1 -0
  28. package/dest/store/bot_store.js +107 -0
  29. package/dest/store/index.d.ts +2 -0
  30. package/dest/store/index.d.ts.map +1 -0
  31. package/dest/store/index.js +1 -0
  32. package/dest/utils.d.ts +4 -4
  33. package/dest/utils.d.ts.map +1 -1
  34. package/dest/utils.js +5 -5
  35. package/package.json +16 -13
  36. package/src/amm_bot.ts +39 -31
  37. package/src/base_bot.ts +24 -22
  38. package/src/bot.ts +25 -14
  39. package/src/config.ts +64 -64
  40. package/src/factory.ts +172 -157
  41. package/src/index.ts +1 -0
  42. package/src/interface.ts +1 -1
  43. package/src/runner.ts +19 -23
  44. package/src/store/bot_store.ts +141 -0
  45. package/src/store/index.ts +1 -0
  46. package/src/utils.ts +10 -5
package/src/config.ts CHANGED
@@ -6,13 +6,15 @@ import {
6
6
  getDefaultConfig,
7
7
  numberConfigHelper,
8
8
  optionalNumberConfigHelper,
9
+ pickConfigMappings,
9
10
  secretFrConfigHelper,
10
11
  secretStringConfigHelper,
11
12
  } from '@aztec/foundation/config';
12
- import { Fr } from '@aztec/foundation/fields';
13
+ import { Fr } from '@aztec/foundation/curves/bn254';
14
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
13
15
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
14
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
15
- import { type ZodFor, schemas } from '@aztec/stdlib/schemas';
16
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
17
+ import { schemas, zodFor } from '@aztec/stdlib/schemas';
16
18
  import type { ComponentsVersions } from '@aztec/stdlib/versioning';
17
19
 
18
20
  import { z } from 'zod';
@@ -30,8 +32,6 @@ export type BotConfig = {
30
32
  nodeUrl: string | undefined;
31
33
  /** The URL to the Aztec node admin API to force-flush txs if configured. */
32
34
  nodeAdminUrl: string | undefined;
33
- /** URL to the PXE for sending txs, or undefined if an in-proc PXE is used. */
34
- pxeUrl: string | undefined;
35
35
  /** Url of the ethereum host. */
36
36
  l1RpcUrls: string[] | undefined;
37
37
  /** The mnemonic for the account to bridge fee juice from L1. */
@@ -44,8 +44,6 @@ export type BotConfig = {
44
44
  senderPrivateKey: SecretValue<Fr> | undefined;
45
45
  /** Optional salt to use to instantiate the sender account */
46
46
  senderSalt: Fr | undefined;
47
- /** Encryption secret for a recipient account. */
48
- recipientEncryptionSecret: SecretValue<Fr>;
49
47
  /** Salt for the token contract instantiation. */
50
48
  tokenSalt: Fr;
51
49
  /** Every how many seconds should a new tx be sent. */
@@ -56,6 +54,8 @@ export type BotConfig = {
56
54
  publicTransfersPerTx: number;
57
55
  /** How to handle fee payments. */
58
56
  feePaymentMethod: 'fee_juice';
57
+ /** 'How much is the bot willing to overpay vs. the current min fee' */
58
+ minFeePadding: number;
59
59
  /** True to not automatically setup or start the bot on initialization. */
60
60
  noStart: boolean;
61
61
  /** How long to wait for a tx to be mined before reporting an error. */
@@ -78,50 +78,54 @@ export type BotConfig = {
78
78
  stopWhenUnhealthy: boolean;
79
79
  /** Deploy an AMM contract and do swaps instead of transfers */
80
80
  ammTxs: boolean;
81
- };
81
+ } & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'>;
82
82
 
83
- export const BotConfigSchema = z
84
- .object({
85
- nodeUrl: z.string().optional(),
86
- nodeAdminUrl: z.string().optional(),
87
- pxeUrl: 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
- recipientEncryptionSecret: schemas.SecretValue(schemas.Fr),
95
- tokenSalt: schemas.Fr,
96
- txIntervalSeconds: z.number(),
97
- privateTransfersPerTx: z.number().int().nonnegative(),
98
- publicTransfersPerTx: z.number().int().nonnegative(),
99
- feePaymentMethod: z.literal('fee_juice'),
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
- })
112
- .transform(config => ({
113
- nodeUrl: undefined,
114
- nodeAdminUrl: undefined,
115
- pxeUrl: undefined,
116
- l1RpcUrls: undefined,
117
- senderSalt: undefined,
118
- l2GasLimit: undefined,
119
- daGasLimit: undefined,
120
- l1Mnemonic: undefined,
121
- l1PrivateKey: undefined,
122
- senderPrivateKey: undefined,
123
- ...config,
124
- })) satisfies ZodFor<BotConfig>;
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
+ );
125
129
 
126
130
  export const botConfigMappings: ConfigMappingsType<BotConfig> = {
127
131
  nodeUrl: {
@@ -132,10 +136,6 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
132
136
  env: 'AZTEC_NODE_ADMIN_URL',
133
137
  description: 'The URL to the Aztec node admin API to force-flush txs if configured.',
134
138
  },
135
- pxeUrl: {
136
- env: 'BOT_PXE_URL',
137
- description: 'URL to the PXE for sending txs, or undefined if an in-proc PXE is used.',
138
- },
139
139
  l1RpcUrls: {
140
140
  env: 'ETHEREUM_HOSTS',
141
141
  description: 'URL of the ethereum host.',
@@ -154,7 +154,7 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
154
154
  l1ToL2MessageTimeoutSeconds: {
155
155
  env: 'BOT_L1_TO_L2_TIMEOUT_SECONDS',
156
156
  description: 'How long to wait for L1 to L2 messages to become available on L2',
157
- ...numberConfigHelper(60),
157
+ ...numberConfigHelper(3600),
158
158
  },
159
159
  senderPrivateKey: {
160
160
  env: 'BOT_PRIVATE_KEY',
@@ -163,18 +163,12 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
163
163
  },
164
164
  senderSalt: {
165
165
  env: 'BOT_ACCOUNT_SALT',
166
- description: 'The salt to use to deploys the sender account.',
166
+ description: 'The salt to use to deploy the sender account.',
167
167
  parseEnv: (val: string) => (val ? Fr.fromHexString(val) : undefined),
168
168
  },
169
- recipientEncryptionSecret: {
170
- env: 'BOT_RECIPIENT_ENCRYPTION_SECRET',
171
- description: 'Encryption secret for a recipient account.',
172
- printDefault: sv => sv?.getValue(),
173
- ...secretFrConfigHelper(Fr.fromHexString('0xcafecafe')),
174
- },
175
169
  tokenSalt: {
176
170
  env: 'BOT_TOKEN_SALT',
177
- description: 'Salt for the token contract deployment.',
171
+ description: 'The salt to use to deploy the token contract.',
178
172
  parseEnv: (val: string) => Fr.fromHexString(val),
179
173
  defaultValue: Fr.fromHexString('1'),
180
174
  },
@@ -199,6 +193,11 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
199
193
  parseEnv: val => (val as 'fee_juice') || undefined,
200
194
  defaultValue: 'fee_juice',
201
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
+ },
202
201
  noStart: {
203
202
  env: 'BOT_NO_START',
204
203
  description: 'True to not automatically setup or start the bot on initialization.',
@@ -270,6 +269,7 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
270
269
  description: 'Deploy an AMM and send swaps to it',
271
270
  ...booleanConfigHelper(false),
272
271
  },
272
+ ...pickConfigMappings(dataConfigMappings, ['dataStoreMapSizeKb', 'dataDirectory']),
273
273
  };
274
274
 
275
275
  export function getBotConfigFromEnv(): BotConfig {
@@ -282,7 +282,7 @@ export function getBotDefaultConfig(): BotConfig {
282
282
 
283
283
  export function getVersions(): Partial<ComponentsVersions> {
284
284
  return {
285
- l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString(),
285
+ l2ProtocolContractsHash: protocolContractsHash.toString(),
286
286
  l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
287
287
  };
288
288
  }