@aztec/bot 0.0.0-test.1 → 0.0.1-commit.b655e406

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 (49) hide show
  1. package/dest/amm_bot.d.ts +33 -0
  2. package/dest/amm_bot.d.ts.map +1 -0
  3. package/dest/amm_bot.js +97 -0
  4. package/dest/base_bot.d.ts +21 -0
  5. package/dest/base_bot.d.ts.map +1 -0
  6. package/dest/base_bot.js +80 -0
  7. package/dest/bot.d.ts +12 -17
  8. package/dest/bot.d.ts.map +1 -1
  9. package/dest/bot.js +24 -86
  10. package/dest/config.d.ts +66 -41
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +55 -32
  13. package/dest/factory.d.ts +38 -16
  14. package/dest/factory.d.ts.map +1 -1
  15. package/dest/factory.js +277 -132
  16. package/dest/index.d.ts +3 -1
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +3 -1
  19. package/dest/interface.d.ts +11 -0
  20. package/dest/interface.d.ts.map +1 -1
  21. package/dest/interface.js +5 -0
  22. package/dest/rpc.d.ts +0 -6
  23. package/dest/rpc.d.ts.map +1 -1
  24. package/dest/rpc.js +0 -11
  25. package/dest/runner.d.ts +14 -10
  26. package/dest/runner.d.ts.map +1 -1
  27. package/dest/runner.js +33 -25
  28. package/dest/store/bot_store.d.ts +44 -0
  29. package/dest/store/bot_store.d.ts.map +1 -0
  30. package/dest/store/bot_store.js +107 -0
  31. package/dest/store/index.d.ts +2 -0
  32. package/dest/store/index.d.ts.map +1 -0
  33. package/dest/store/index.js +1 -0
  34. package/dest/utils.d.ts +7 -4
  35. package/dest/utils.d.ts.map +1 -1
  36. package/dest/utils.js +14 -5
  37. package/package.json +24 -21
  38. package/src/amm_bot.ts +124 -0
  39. package/src/base_bot.ts +96 -0
  40. package/src/bot.ts +52 -103
  41. package/src/config.ts +66 -38
  42. package/src/factory.ts +321 -145
  43. package/src/index.ts +3 -1
  44. package/src/interface.ts +9 -0
  45. package/src/rpc.ts +0 -13
  46. package/src/runner.ts +38 -21
  47. package/src/store/bot_store.ts +141 -0
  48. package/src/store/index.ts +1 -0
  49. package/src/utils.ts +17 -6
package/dest/config.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { type ConfigMappingsType } from '@aztec/foundation/config';
1
+ import { type ConfigMappingsType, SecretValue } from '@aztec/foundation/config';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
+ import { type DataStoreConfig } from '@aztec/kv-store/config';
3
4
  import { type ZodFor } from '@aztec/stdlib/schemas';
4
5
  import type { ComponentsVersions } from '@aztec/stdlib/versioning';
5
6
  import { z } from 'zod';
@@ -7,24 +8,26 @@ declare const BotFollowChain: readonly ["NONE", "PENDING", "PROVEN"];
7
8
  type BotFollowChain = (typeof BotFollowChain)[number];
8
9
  export declare enum SupportedTokenContracts {
9
10
  TokenContract = "TokenContract",
10
- EasyPrivateTokenContract = "EasyPrivateTokenContract"
11
+ PrivateTokenContract = "PrivateTokenContract"
11
12
  }
12
13
  export type BotConfig = {
13
14
  /** The URL to the Aztec node to check for tx pool status. */
14
15
  nodeUrl: string | undefined;
15
- /** URL to the PXE for sending txs, or undefined if an in-proc PXE is used. */
16
- pxeUrl: string | undefined;
16
+ /** The URL to the Aztec node admin API to force-flush txs if configured. */
17
+ nodeAdminUrl: string | undefined;
17
18
  /** Url of the ethereum host. */
18
19
  l1RpcUrls: string[] | undefined;
19
20
  /** The mnemonic for the account to bridge fee juice from L1. */
20
- l1Mnemonic: string | undefined;
21
+ l1Mnemonic: SecretValue<string> | undefined;
21
22
  /** The private key for the account to bridge fee juice from L1. */
22
- l1PrivateKey: string | undefined;
23
+ l1PrivateKey: SecretValue<string> | undefined;
24
+ /** How long to wait for L1 to L2 messages to become available on L2 */
25
+ l1ToL2MessageTimeoutSeconds: number;
23
26
  /** Signing private key for the sender account. */
24
- senderPrivateKey: Fr | undefined;
25
- /** Encryption secret for a recipient account. */
26
- recipientEncryptionSecret: Fr;
27
- /** Salt for the token contract deployment. */
27
+ senderPrivateKey: SecretValue<Fr> | undefined;
28
+ /** Optional salt to use to instantiate the sender account */
29
+ senderSalt: Fr | undefined;
30
+ /** Salt for the token contract instantiation. */
28
31
  tokenSalt: Fr;
29
32
  /** Every how many seconds should a new tx be sent. */
30
33
  txIntervalSeconds: number;
@@ -34,6 +37,8 @@ export type BotConfig = {
34
37
  publicTransfersPerTx: number;
35
38
  /** How to handle fee payments. */
36
39
  feePaymentMethod: 'fee_juice';
40
+ /** 'How much is the bot willing to overpay vs. the current base fee' */
41
+ baseFeePadding: number;
37
42
  /** True to not automatically setup or start the bot on initialization. */
38
43
  noStart: boolean;
39
44
  /** How long to wait for a tx to be mined before reporting an error. */
@@ -44,8 +49,6 @@ export type BotConfig = {
44
49
  maxPendingTxs: number;
45
50
  /** Whether to flush after sending each 'setup' transaction */
46
51
  flushSetupTransactions: boolean;
47
- /** Whether to skip public simulation of txs before sending them. */
48
- skipPublicSimulation: boolean;
49
52
  /** L2 gas limit for the tx (empty to have the bot trigger an estimate gas). */
50
53
  l2GasLimit: number | undefined;
51
54
  /** DA gas limit for the tx (empty to have the bot trigger an estimate gas). */
@@ -56,127 +59,149 @@ export type BotConfig = {
56
59
  maxConsecutiveErrors: number;
57
60
  /** Stops the bot if service becomes unhealthy */
58
61
  stopWhenUnhealthy: boolean;
59
- };
62
+ /** Deploy an AMM contract and do swaps instead of transfers */
63
+ ammTxs: boolean;
64
+ } & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'>;
60
65
  export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
61
66
  nodeUrl: z.ZodOptional<z.ZodString>;
62
- pxeUrl: z.ZodOptional<z.ZodString>;
67
+ nodeAdminUrl: z.ZodOptional<z.ZodString>;
63
68
  l1RpcUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
64
- l1Mnemonic: z.ZodOptional<z.ZodString>;
65
- l1PrivateKey: z.ZodOptional<z.ZodString>;
66
- senderPrivateKey: z.ZodOptional<ZodFor<Fr>>;
67
- recipientEncryptionSecret: ZodFor<Fr>;
69
+ l1Mnemonic: z.ZodOptional<z.ZodType<SecretValue<string>, any, any>>;
70
+ l1PrivateKey: z.ZodOptional<z.ZodType<SecretValue<string>, any, any>>;
71
+ l1ToL2MessageTimeoutSeconds: z.ZodNumber;
72
+ senderPrivateKey: z.ZodOptional<z.ZodType<SecretValue<Fr>, any, any>>;
73
+ senderSalt: z.ZodOptional<ZodFor<Fr>>;
68
74
  tokenSalt: ZodFor<Fr>;
69
75
  txIntervalSeconds: z.ZodNumber;
70
76
  privateTransfersPerTx: z.ZodNumber;
71
77
  publicTransfersPerTx: z.ZodNumber;
72
78
  feePaymentMethod: z.ZodLiteral<"fee_juice">;
79
+ baseFeePadding: z.ZodNumber;
73
80
  noStart: z.ZodBoolean;
74
81
  txMinedWaitSeconds: z.ZodNumber;
75
82
  followChain: z.ZodEnum<["NONE", "PENDING", "PROVEN"]>;
76
83
  maxPendingTxs: z.ZodNumber;
77
84
  flushSetupTransactions: z.ZodBoolean;
78
- skipPublicSimulation: z.ZodBoolean;
79
85
  l2GasLimit: z.ZodOptional<z.ZodNumber>;
80
86
  daGasLimit: z.ZodOptional<z.ZodNumber>;
81
87
  contract: z.ZodNativeEnum<typeof SupportedTokenContracts>;
82
88
  maxConsecutiveErrors: z.ZodNumber;
83
89
  stopWhenUnhealthy: z.ZodBoolean;
90
+ ammTxs: z.ZodDefault<z.ZodBoolean>;
91
+ dataDirectory: z.ZodOptional<z.ZodString>;
92
+ dataStoreMapSizeKb: z.ZodOptional<z.ZodNumber>;
84
93
  }, "strip", z.ZodTypeAny, {
85
- recipientEncryptionSecret: Fr;
94
+ l1ToL2MessageTimeoutSeconds: number;
86
95
  tokenSalt: Fr;
87
96
  txIntervalSeconds: number;
88
97
  privateTransfersPerTx: number;
89
98
  publicTransfersPerTx: number;
90
99
  feePaymentMethod: "fee_juice";
100
+ baseFeePadding: number;
91
101
  noStart: boolean;
92
102
  txMinedWaitSeconds: number;
93
103
  followChain: "NONE" | "PENDING" | "PROVEN";
94
104
  maxPendingTxs: number;
95
105
  flushSetupTransactions: boolean;
96
- skipPublicSimulation: boolean;
97
106
  contract: SupportedTokenContracts;
98
107
  maxConsecutiveErrors: number;
99
108
  stopWhenUnhealthy: boolean;
109
+ ammTxs: boolean;
110
+ dataDirectory?: string | undefined;
111
+ dataStoreMapSizeKb?: number | undefined;
100
112
  nodeUrl?: string | undefined;
101
- pxeUrl?: string | undefined;
113
+ nodeAdminUrl?: string | undefined;
102
114
  l1RpcUrls?: string[] | undefined;
103
- l1Mnemonic?: string | undefined;
104
- l1PrivateKey?: string | undefined;
105
- senderPrivateKey?: Fr | undefined;
115
+ l1Mnemonic?: SecretValue<string> | undefined;
116
+ l1PrivateKey?: SecretValue<string> | undefined;
117
+ senderPrivateKey?: SecretValue<Fr> | undefined;
118
+ senderSalt?: Fr | undefined;
106
119
  l2GasLimit?: number | undefined;
107
120
  daGasLimit?: number | undefined;
108
121
  }, {
122
+ l1ToL2MessageTimeoutSeconds: number;
109
123
  txIntervalSeconds: number;
110
124
  privateTransfersPerTx: number;
111
125
  publicTransfersPerTx: number;
112
126
  feePaymentMethod: "fee_juice";
127
+ baseFeePadding: number;
113
128
  noStart: boolean;
114
129
  txMinedWaitSeconds: number;
115
130
  followChain: "NONE" | "PENDING" | "PROVEN";
116
131
  maxPendingTxs: number;
117
132
  flushSetupTransactions: boolean;
118
- skipPublicSimulation: boolean;
119
133
  contract: SupportedTokenContracts;
120
134
  maxConsecutiveErrors: number;
121
135
  stopWhenUnhealthy: boolean;
136
+ dataDirectory?: string | undefined;
137
+ dataStoreMapSizeKb?: number | undefined;
122
138
  nodeUrl?: string | undefined;
123
- pxeUrl?: string | undefined;
139
+ nodeAdminUrl?: string | undefined;
124
140
  l1RpcUrls?: string[] | undefined;
125
- l1Mnemonic?: string | undefined;
126
- l1PrivateKey?: string | undefined;
141
+ l1Mnemonic?: any;
142
+ l1PrivateKey?: any;
127
143
  senderPrivateKey?: any;
128
- recipientEncryptionSecret?: any;
144
+ senderSalt?: any;
129
145
  tokenSalt?: any;
130
146
  l2GasLimit?: number | undefined;
131
147
  daGasLimit?: number | undefined;
148
+ ammTxs?: boolean | undefined;
132
149
  }>, {
133
- recipientEncryptionSecret: Fr;
150
+ l1ToL2MessageTimeoutSeconds: number;
134
151
  tokenSalt: Fr;
135
152
  txIntervalSeconds: number;
136
153
  privateTransfersPerTx: number;
137
154
  publicTransfersPerTx: number;
138
155
  feePaymentMethod: "fee_juice";
156
+ baseFeePadding: number;
139
157
  noStart: boolean;
140
158
  txMinedWaitSeconds: number;
141
159
  followChain: "NONE" | "PENDING" | "PROVEN";
142
160
  maxPendingTxs: number;
143
161
  flushSetupTransactions: boolean;
144
- skipPublicSimulation: boolean;
145
162
  contract: SupportedTokenContracts;
146
163
  maxConsecutiveErrors: number;
147
164
  stopWhenUnhealthy: boolean;
165
+ ammTxs: boolean;
166
+ dataDirectory: string | undefined;
167
+ dataStoreMapSizeKb: number;
148
168
  nodeUrl: string | undefined;
149
- pxeUrl: string | undefined;
169
+ nodeAdminUrl: string | undefined;
150
170
  l1RpcUrls: string[] | undefined;
151
- l1Mnemonic: string | undefined;
152
- l1PrivateKey: string | undefined;
153
- senderPrivateKey: Fr | undefined;
171
+ l1Mnemonic: SecretValue<string> | undefined;
172
+ l1PrivateKey: SecretValue<string> | undefined;
173
+ senderPrivateKey: SecretValue<Fr> | undefined;
174
+ senderSalt: Fr | undefined;
154
175
  l2GasLimit: number | undefined;
155
176
  daGasLimit: number | undefined;
156
177
  }, {
178
+ l1ToL2MessageTimeoutSeconds: number;
157
179
  txIntervalSeconds: number;
158
180
  privateTransfersPerTx: number;
159
181
  publicTransfersPerTx: number;
160
182
  feePaymentMethod: "fee_juice";
183
+ baseFeePadding: number;
161
184
  noStart: boolean;
162
185
  txMinedWaitSeconds: number;
163
186
  followChain: "NONE" | "PENDING" | "PROVEN";
164
187
  maxPendingTxs: number;
165
188
  flushSetupTransactions: boolean;
166
- skipPublicSimulation: boolean;
167
189
  contract: SupportedTokenContracts;
168
190
  maxConsecutiveErrors: number;
169
191
  stopWhenUnhealthy: boolean;
192
+ dataDirectory?: string | undefined;
193
+ dataStoreMapSizeKb?: number | undefined;
170
194
  nodeUrl?: string | undefined;
171
- pxeUrl?: string | undefined;
195
+ nodeAdminUrl?: string | undefined;
172
196
  l1RpcUrls?: string[] | undefined;
173
- l1Mnemonic?: string | undefined;
174
- l1PrivateKey?: string | undefined;
197
+ l1Mnemonic?: any;
198
+ l1PrivateKey?: any;
175
199
  senderPrivateKey?: any;
176
- recipientEncryptionSecret?: any;
200
+ senderSalt?: any;
177
201
  tokenSalt?: any;
178
202
  l2GasLimit?: number | undefined;
179
203
  daGasLimit?: number | undefined;
204
+ ammTxs?: boolean | undefined;
180
205
  }>;
181
206
  export declare const botConfigMappings: ConfigMappingsType<BotConfig>;
182
207
  export declare function getBotConfigFromEnv(): BotConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,cAAc,wCAAyC,CAAC;AAC9D,KAAK,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,oBAAY,uBAAuB;IACjC,aAAa,kBAAkB;IAC/B,wBAAwB,6BAA6B;CACtD;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CK,CAAC;AAElC,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CA+I3D,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,WAAW,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAKzD"}
package/dest/config.js CHANGED
@@ -1,7 +1,8 @@
1
- import { booleanConfigHelper, getConfigFromMappings, getDefaultConfig, numberConfigHelper, optionalNumberConfigHelper } from '@aztec/foundation/config';
1
+ import { booleanConfigHelper, getConfigFromMappings, getDefaultConfig, numberConfigHelper, optionalNumberConfigHelper, pickConfigMappings, secretFrConfigHelper, secretStringConfigHelper } from '@aztec/foundation/config';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
+ import { dataConfigMappings } from '@aztec/kv-store/config';
3
4
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
4
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
5
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
5
6
  import { schemas } from '@aztec/stdlib/schemas';
6
7
  import { z } from 'zod';
7
8
  const BotFollowChain = [
@@ -11,42 +12,49 @@ const BotFollowChain = [
11
12
  ];
12
13
  export var SupportedTokenContracts = /*#__PURE__*/ function(SupportedTokenContracts) {
13
14
  SupportedTokenContracts["TokenContract"] = "TokenContract";
14
- SupportedTokenContracts["EasyPrivateTokenContract"] = "EasyPrivateTokenContract";
15
+ SupportedTokenContracts["PrivateTokenContract"] = "PrivateTokenContract";
15
16
  return SupportedTokenContracts;
16
17
  }({});
17
18
  export const BotConfigSchema = z.object({
18
19
  nodeUrl: z.string().optional(),
19
- pxeUrl: z.string().optional(),
20
+ nodeAdminUrl: z.string().optional(),
20
21
  l1RpcUrls: z.array(z.string()).optional(),
21
- l1Mnemonic: z.string().optional(),
22
- l1PrivateKey: z.string().optional(),
23
- senderPrivateKey: schemas.Fr.optional(),
24
- recipientEncryptionSecret: schemas.Fr,
22
+ l1Mnemonic: schemas.SecretValue(z.string()).optional(),
23
+ l1PrivateKey: schemas.SecretValue(z.string()).optional(),
24
+ l1ToL2MessageTimeoutSeconds: z.number(),
25
+ senderPrivateKey: schemas.SecretValue(schemas.Fr).optional(),
26
+ senderSalt: schemas.Fr.optional(),
25
27
  tokenSalt: schemas.Fr,
26
28
  txIntervalSeconds: z.number(),
27
29
  privateTransfersPerTx: z.number().int().nonnegative(),
28
30
  publicTransfersPerTx: z.number().int().nonnegative(),
29
31
  feePaymentMethod: z.literal('fee_juice'),
32
+ baseFeePadding: z.number().int().nonnegative(),
30
33
  noStart: z.boolean(),
31
34
  txMinedWaitSeconds: z.number(),
32
35
  followChain: z.enum(BotFollowChain),
33
36
  maxPendingTxs: z.number().int().nonnegative(),
34
37
  flushSetupTransactions: z.boolean(),
35
- skipPublicSimulation: z.boolean(),
36
38
  l2GasLimit: z.number().int().nonnegative().optional(),
37
39
  daGasLimit: z.number().int().nonnegative().optional(),
38
40
  contract: z.nativeEnum(SupportedTokenContracts),
39
41
  maxConsecutiveErrors: z.number().int().nonnegative(),
40
- stopWhenUnhealthy: z.boolean()
42
+ stopWhenUnhealthy: z.boolean(),
43
+ ammTxs: z.boolean().default(false),
44
+ dataDirectory: z.string().optional(),
45
+ dataStoreMapSizeKb: z.number().optional()
41
46
  }).transform((config)=>({
42
47
  nodeUrl: undefined,
43
- pxeUrl: undefined,
48
+ nodeAdminUrl: undefined,
44
49
  l1RpcUrls: undefined,
50
+ senderSalt: undefined,
51
+ l2GasLimit: undefined,
52
+ daGasLimit: undefined,
45
53
  l1Mnemonic: undefined,
46
54
  l1PrivateKey: undefined,
47
55
  senderPrivateKey: undefined,
48
- l2GasLimit: undefined,
49
- daGasLimit: undefined,
56
+ dataDirectory: undefined,
57
+ dataStoreMapSizeKb: 1_024 * 1_024,
50
58
  ...config
51
59
  }));
52
60
  export const botConfigMappings = {
@@ -54,9 +62,9 @@ export const botConfigMappings = {
54
62
  env: 'AZTEC_NODE_URL',
55
63
  description: 'The URL to the Aztec node to check for tx pool status.'
56
64
  },
57
- pxeUrl: {
58
- env: 'BOT_PXE_URL',
59
- description: 'URL to the PXE for sending txs, or undefined if an in-proc PXE is used.'
65
+ nodeAdminUrl: {
66
+ env: 'AZTEC_NODE_ADMIN_URL',
67
+ description: 'The URL to the Aztec node admin API to force-flush txs if configured.'
60
68
  },
61
69
  l1RpcUrls: {
62
70
  env: 'ETHEREUM_HOSTS',
@@ -65,26 +73,32 @@ export const botConfigMappings = {
65
73
  },
66
74
  l1Mnemonic: {
67
75
  env: 'BOT_L1_MNEMONIC',
68
- description: 'The mnemonic for the account to bridge fee juice from L1.'
76
+ description: 'The mnemonic for the account to bridge fee juice from L1.',
77
+ ...secretStringConfigHelper()
69
78
  },
70
79
  l1PrivateKey: {
71
80
  env: 'BOT_L1_PRIVATE_KEY',
72
- description: 'The private key for the account to bridge fee juice from L1.'
81
+ description: 'The private key for the account to bridge fee juice from L1.',
82
+ ...secretStringConfigHelper()
83
+ },
84
+ l1ToL2MessageTimeoutSeconds: {
85
+ env: 'BOT_L1_TO_L2_TIMEOUT_SECONDS',
86
+ description: 'How long to wait for L1 to L2 messages to become available on L2',
87
+ ...numberConfigHelper(3600)
73
88
  },
74
89
  senderPrivateKey: {
75
90
  env: 'BOT_PRIVATE_KEY',
76
91
  description: 'Signing private key for the sender account.',
77
- parseEnv: (val)=>val ? Fr.fromHexString(val) : undefined
92
+ ...secretFrConfigHelper()
78
93
  },
79
- recipientEncryptionSecret: {
80
- env: 'BOT_RECIPIENT_ENCRYPTION_SECRET',
81
- description: 'Encryption secret for a recipient account.',
82
- parseEnv: (val)=>Fr.fromHexString(val),
83
- defaultValue: Fr.fromHexString('0xcafecafe')
94
+ senderSalt: {
95
+ env: 'BOT_ACCOUNT_SALT',
96
+ description: 'The salt to use to deploy the sender account.',
97
+ parseEnv: (val)=>val ? Fr.fromHexString(val) : undefined
84
98
  },
85
99
  tokenSalt: {
86
100
  env: 'BOT_TOKEN_SALT',
87
- description: 'Salt for the token contract deployment.',
101
+ description: 'The salt to use to deploy the token contract.',
88
102
  parseEnv: (val)=>Fr.fromHexString(val),
89
103
  defaultValue: Fr.fromHexString('1')
90
104
  },
@@ -109,6 +123,11 @@ export const botConfigMappings = {
109
123
  parseEnv: (val)=>val || undefined,
110
124
  defaultValue: 'fee_juice'
111
125
  },
126
+ baseFeePadding: {
127
+ env: 'BOT_BASE_FEE_PADDING',
128
+ description: 'How much is the bot willing to overpay vs. the current base fee',
129
+ ...numberConfigHelper(3)
130
+ },
112
131
  noStart: {
113
132
  env: 'BOT_NO_START',
114
133
  description: 'True to not automatically setup or start the bot on initialization.',
@@ -140,11 +159,6 @@ export const botConfigMappings = {
140
159
  description: 'Make a request for the sequencer to build a block after each setup transaction.',
141
160
  ...booleanConfigHelper(false)
142
161
  },
143
- skipPublicSimulation: {
144
- env: 'BOT_SKIP_PUBLIC_SIMULATION',
145
- description: 'Whether to skip public simulation of txs before sending them.',
146
- ...booleanConfigHelper(false)
147
- },
148
162
  l2GasLimit: {
149
163
  env: 'BOT_L2_GAS_LIMIT',
150
164
  description: 'L2 gas limit for the tx (empty to have the bot trigger an estimate gas).',
@@ -175,7 +189,16 @@ export const botConfigMappings = {
175
189
  env: 'BOT_STOP_WHEN_UNHEALTHY',
176
190
  description: 'Stops the bot if service becomes unhealthy',
177
191
  ...booleanConfigHelper(false)
178
- }
192
+ },
193
+ ammTxs: {
194
+ env: 'BOT_AMM_TXS',
195
+ description: 'Deploy an AMM and send swaps to it',
196
+ ...booleanConfigHelper(false)
197
+ },
198
+ ...pickConfigMappings(dataConfigMappings, [
199
+ 'dataStoreMapSizeKb',
200
+ 'dataDirectory'
201
+ ])
179
202
  };
180
203
  export function getBotConfigFromEnv() {
181
204
  return getConfigFromMappings(botConfigMappings);
@@ -185,7 +208,7 @@ export function getBotDefaultConfig() {
185
208
  }
186
209
  export function getVersions() {
187
210
  return {
188
- l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString(),
211
+ l2ProtocolContractsHash: protocolContractsHash.toString(),
189
212
  l2CircuitsVkTreeRoot: getVKTreeRoot().toString()
190
213
  };
191
214
  }
package/dest/factory.d.ts CHANGED
@@ -1,26 +1,38 @@
1
- import { AztecAddress, type AztecNode, type PXE } from '@aztec/aztec.js';
2
- import { EasyPrivateTokenContract } from '@aztec/noir-contracts.js/EasyPrivateToken';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { AMMContract } from '@aztec/noir-contracts.js/AMM';
3
+ import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
3
4
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
+ import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
6
+ import { TestWallet } from '@aztec/test-wallet/server';
4
7
  import { type BotConfig } from './config.js';
8
+ import type { BotStore } from './store/index.js';
5
9
  export declare class BotFactory {
6
10
  private readonly config;
7
- private pxe;
8
- private node?;
11
+ private readonly wallet;
12
+ private readonly store;
13
+ private readonly aztecNode;
14
+ private readonly aztecNodeAdmin?;
9
15
  private log;
10
- constructor(config: BotConfig, dependencies?: {
11
- pxe?: PXE;
12
- node?: AztecNode;
13
- });
16
+ constructor(config: BotConfig, wallet: TestWallet, store: BotStore, aztecNode: AztecNode, aztecNodeAdmin?: AztecNodeAdmin | undefined);
14
17
  /**
15
18
  * Initializes a new bot by setting up the sender account, registering the recipient,
16
19
  * deploying the token contract, and minting tokens if necessary.
17
20
  */
18
21
  setup(): Promise<{
19
- wallet: import("@aztec/aztec.js").AccountWalletWithSecretKey;
20
- token: TokenContract | EasyPrivateTokenContract;
21
- pxe: PXE;
22
+ wallet: TestWallet;
23
+ defaultAccountAddress: AztecAddress;
24
+ token: TokenContract | PrivateTokenContract;
25
+ node: AztecNode;
22
26
  recipient: AztecAddress;
23
27
  }>;
28
+ setupAmm(): Promise<{
29
+ wallet: TestWallet;
30
+ defaultAccountAddress: AztecAddress;
31
+ amm: AMMContract;
32
+ token0: TokenContract;
33
+ token1: TokenContract;
34
+ node: AztecNode;
35
+ }>;
24
36
  /**
25
37
  * Checks if the sender account contract is initialized, and initializes it if necessary.
26
38
  * @returns The sender wallet.
@@ -29,22 +41,32 @@ export declare class BotFactory {
29
41
  private setupAccountWithPrivateKey;
30
42
  private setupTestAccount;
31
43
  /**
32
- * Registers the recipient for txs in the pxe.
44
+ * Checks if the token contract is deployed and deploys it if necessary.
45
+ * @param wallet - Wallet to deploy the token contract from.
46
+ * @returns The TokenContract instance.
33
47
  */
34
- private registerRecipient;
48
+ private setupToken;
35
49
  /**
36
50
  * Checks if the token contract is deployed and deploys it if necessary.
37
51
  * @param wallet - Wallet to deploy the token contract from.
38
52
  * @returns The TokenContract instance.
39
53
  */
40
- private setupToken;
54
+ private setupTokenContract;
55
+ private setupAmmContract;
56
+ private fundAmm;
57
+ private registerOrDeployContract;
41
58
  /**
42
59
  * Mints private and public tokens for the sender if their balance is below the minimum.
43
60
  * @param token - Token contract.
44
61
  */
45
62
  private mintTokens;
63
+ /**
64
+ * Gets or creates a bridge claim for the recipient.
65
+ * Checks if a claim already exists in the store and reuses it if valid.
66
+ * Only creates a new bridge if fee juice balance is below threshold.
67
+ */
68
+ private getOrCreateBridgeClaim;
46
69
  private bridgeL1FeeJuice;
47
- private advanceL2Block;
48
- private tryFlushTxs;
70
+ private withNoMinTxsPerBlock;
49
71
  }
50
72
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EACZ,KAAK,SAAS,EAMd,KAAK,GAAG,EAIT,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;A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