@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.
- package/dest/amm_bot.d.ts +9 -9
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +23 -20
- package/dest/base_bot.d.ts +11 -8
- package/dest/base_bot.d.ts.map +1 -1
- package/dest/base_bot.js +18 -18
- package/dest/bot.d.ts +8 -9
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +11 -12
- package/dest/config.d.ts +53 -50
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +27 -25
- package/dest/factory.d.ts +14 -32
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +137 -115
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/interface.d.ts +2 -2
- package/dest/interface.d.ts.map +1 -1
- package/dest/interface.js +1 -1
- package/dest/rpc.d.ts +1 -1
- package/dest/runner.d.ts +12 -13
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +429 -61
- 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 +4 -4
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +5 -5
- package/package.json +16 -13
- package/src/amm_bot.ts +39 -31
- package/src/base_bot.ts +24 -22
- package/src/bot.ts +25 -14
- package/src/config.ts +64 -64
- package/src/factory.ts +172 -157
- package/src/index.ts +1 -0
- package/src/interface.ts +1 -1
- package/src/runner.ts +19 -23
- package/src/store/bot_store.ts +141 -0
- package/src/store/index.ts +1 -0
- 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/
|
|
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 {
|
|
15
|
-
import {
|
|
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 =
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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(
|
|
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
|
|
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: '
|
|
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
|
-
|
|
285
|
+
l2ProtocolContractsHash: protocolContractsHash.toString(),
|
|
286
286
|
l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
|
|
287
287
|
};
|
|
288
288
|
}
|