@aztec/bot 6.0.0-nightly.20260604 → 6.0.0-nightly.20260721
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 +3 -2
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +2 -2
- package/dest/bot.d.ts +3 -2
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +2 -2
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +3 -3
- package/dest/cross_chain_bot.d.ts +5 -3
- package/dest/cross_chain_bot.d.ts.map +1 -1
- package/dest/cross_chain_bot.js +7 -6
- package/dest/factory.d.ts +6 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +66 -215
- package/dest/runner.d.ts +3 -2
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +6 -4
- package/package.json +15 -15
- package/src/amm_bot.ts +3 -0
- package/src/bot.ts +3 -0
- package/src/config.ts +3 -2
- package/src/cross_chain_bot.ts +6 -2
- package/src/factory.ts +62 -208
- package/src/runner.ts +26 -3
package/dest/factory.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
-
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
3
2
|
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
3
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
5
4
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
@@ -8,18 +7,15 @@ import { createLogger } from '@aztec/aztec.js/log';
|
|
|
8
7
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
9
8
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
10
9
|
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
11
|
-
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
12
10
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
13
11
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
14
12
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
15
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
16
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
18
15
|
import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
19
16
|
import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
20
17
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
21
18
|
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
22
|
-
import { GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
23
19
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
24
20
|
import { SupportedTokenContracts } from './config.js';
|
|
25
21
|
import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
@@ -27,20 +23,21 @@ import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils
|
|
|
27
23
|
const MINT_BALANCE = 1e12;
|
|
28
24
|
const MIN_BALANCE = 1e3;
|
|
29
25
|
const FEE_JUICE_TOP_UP_THRESHOLD = 100n * 10n ** 18n;
|
|
30
|
-
const FEE_JUICE_TOP_UP_TARGET = 10_000n * 10n ** 18n;
|
|
31
26
|
export class BotFactory {
|
|
32
27
|
config;
|
|
33
28
|
wallet;
|
|
34
29
|
store;
|
|
35
30
|
aztecNode;
|
|
36
31
|
aztecNodeAdmin;
|
|
32
|
+
syncChainTip;
|
|
37
33
|
log;
|
|
38
|
-
constructor(config, wallet, store, aztecNode, aztecNodeAdmin){
|
|
34
|
+
constructor(config, wallet, store, aztecNode, aztecNodeAdmin, syncChainTip){
|
|
39
35
|
this.config = config;
|
|
40
36
|
this.wallet = wallet;
|
|
41
37
|
this.store = store;
|
|
42
38
|
this.aztecNode = aztecNode;
|
|
43
39
|
this.aztecNodeAdmin = aztecNodeAdmin;
|
|
40
|
+
this.syncChainTip = syncChainTip;
|
|
44
41
|
this.log = createLogger('bot');
|
|
45
42
|
// Set fee padding on the wallet so that all transactions during setup
|
|
46
43
|
// (token deploy, minting, etc.) use the configured padding, not the default.
|
|
@@ -52,8 +49,8 @@ export class BotFactory {
|
|
|
52
49
|
*/ async setup() {
|
|
53
50
|
const defaultAccountAddress = await this.setupAccount();
|
|
54
51
|
const recipient = (await this.wallet.createSchnorrAccount(Fr.random(), Fr.random())).address;
|
|
55
|
-
|
|
56
|
-
await this.
|
|
52
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress);
|
|
53
|
+
const token = await this.setupToken(defaultAccountAddress);
|
|
57
54
|
await this.mintTokens(token, defaultAccountAddress);
|
|
58
55
|
return {
|
|
59
56
|
wallet: this.wallet,
|
|
@@ -65,8 +62,8 @@ export class BotFactory {
|
|
|
65
62
|
}
|
|
66
63
|
async setupAmm() {
|
|
67
64
|
const defaultAccountAddress = await this.setupAccount();
|
|
68
|
-
|
|
69
|
-
await this.
|
|
65
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress);
|
|
66
|
+
const token0 = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotToken0', 'BOT0');
|
|
70
67
|
const token1 = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotToken1', 'BOT1');
|
|
71
68
|
const liquidityToken = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotLPToken', 'BOTLP');
|
|
72
69
|
const amm = await this.setupAmmContract(defaultAccountAddress, this.config.tokenSalt, token0, token1, liquidityToken);
|
|
@@ -86,6 +83,7 @@ export class BotFactory {
|
|
|
86
83
|
* seeding initial L1→L2 messages, and waiting for the first to be ready.
|
|
87
84
|
*/ async setupCrossChain() {
|
|
88
85
|
const defaultAccountAddress = await this.setupAccount();
|
|
86
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress);
|
|
89
87
|
// Create L1 client (same pattern as bridgeL1FeeJuice)
|
|
90
88
|
const l1RpcUrls = this.config.l1RpcUrls;
|
|
91
89
|
if (!l1RpcUrls?.length) {
|
|
@@ -101,7 +99,7 @@ export class BotFactory {
|
|
|
101
99
|
// Fetch Rollup version (needed for Inbox L2Actor struct)
|
|
102
100
|
const rollupContract = new RollupContract(l1Client, l1ContractAddresses.rollupAddress.toString());
|
|
103
101
|
const rollupVersion = await rollupContract.getVersion();
|
|
104
|
-
// Deploy TestContract
|
|
102
|
+
// Deploy TestContract (pays from the standing balance funded above).
|
|
105
103
|
const contract = await this.setupTestContract(defaultAccountAddress);
|
|
106
104
|
// Recover any pending messages from store (clean up stale ones first)
|
|
107
105
|
await this.store.cleanupOldPendingMessages();
|
|
@@ -117,7 +115,8 @@ export class BotFactory {
|
|
|
117
115
|
this.log.info(`Waiting for first L1→L2 message to be ready...`);
|
|
118
116
|
const firstMsg = allMessages[0];
|
|
119
117
|
await waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(firstMsg.msgHash), {
|
|
120
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
118
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
119
|
+
chainTip: this.syncChainTip
|
|
121
120
|
});
|
|
122
121
|
this.log.info(`First L1→L2 message is ready`);
|
|
123
122
|
}
|
|
@@ -154,102 +153,24 @@ export class BotFactory {
|
|
|
154
153
|
return await this.setupTestAccount();
|
|
155
154
|
}
|
|
156
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Keyless fallback for tests and local dev: reuses the first genesis test account, whose address is
|
|
158
|
+
* pre-funded with fee juice via `initialFundedAccounts`. The test accounts are initializerless, so this
|
|
159
|
+
* must create an initializerless account for the address to match the funded one. Production bots set a
|
|
160
|
+
* sender private key and fund the resulting initializerless account from L1 instead; see
|
|
161
|
+
* setupAccountWithPrivateKey.
|
|
162
|
+
*/ async setupTestAccount() {
|
|
163
|
+
const [initialAccountData] = await getInitialTestAccountsData();
|
|
164
|
+
const accountManager = await this.wallet.createSchnorrInitializerlessAccount(initialAccountData.secret, initialAccountData.salt, initialAccountData.signingKey);
|
|
165
|
+
return accountManager.address;
|
|
166
|
+
}
|
|
157
167
|
async setupAccountWithPrivateKey(secret) {
|
|
158
168
|
const salt = this.config.senderSalt ?? Fr.ONE;
|
|
159
169
|
const signingKey = deriveSigningKey(secret);
|
|
160
|
-
const accountManager = await this.wallet.
|
|
161
|
-
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
162
|
-
if (metadata.initializationStatus === ContractInitializationStatus.INITIALIZED) {
|
|
163
|
-
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
164
|
-
const timer = new Timer();
|
|
165
|
-
const address = accountManager.address;
|
|
166
|
-
this.log.info(`Account at ${address} registered. duration=${timer.ms()}`);
|
|
167
|
-
await this.store.deleteBridgeClaim(address);
|
|
168
|
-
return address;
|
|
169
|
-
} else {
|
|
170
|
-
const address = accountManager.address;
|
|
171
|
-
this.log.info(`Deploying account at ${address}`);
|
|
172
|
-
const claim = await this.getOrCreateBridgeClaim(address);
|
|
173
|
-
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
174
|
-
const deployMethod = await accountManager.getDeployMethod();
|
|
175
|
-
await this.withNoMinTxsPerBlock(async ()=>{
|
|
176
|
-
const { txHash } = await deployMethod.send({
|
|
177
|
-
from: NO_FROM,
|
|
178
|
-
fee: {
|
|
179
|
-
paymentMethod
|
|
180
|
-
},
|
|
181
|
-
wait: NO_WAIT
|
|
182
|
-
});
|
|
183
|
-
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
184
|
-
return waitForTx(this.aztecNode, txHash, {
|
|
185
|
-
timeout: this.config.txMinedWaitSeconds
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
this.log.info(`Account deployed at ${address}`);
|
|
189
|
-
// Clean up the consumed bridge claim
|
|
190
|
-
await this.store.deleteBridgeClaim(address);
|
|
191
|
-
return accountManager.address;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async setupTestAccount() {
|
|
195
|
-
const [initialAccountData] = await getInitialTestAccountsData();
|
|
196
|
-
const accountManager = await this.wallet.createSchnorrAccount(initialAccountData.secret, initialAccountData.salt, initialAccountData.signingKey);
|
|
170
|
+
const accountManager = await this.wallet.createSchnorrInitializerlessAccount(secret, salt, signingKey);
|
|
197
171
|
return accountManager.address;
|
|
198
172
|
}
|
|
199
173
|
/**
|
|
200
|
-
* Setup token and refuel first: if the token already exists (restart scenario),
|
|
201
|
-
* run ensureFeeJuiceBalance before any step that might need fee juice. When deploying,
|
|
202
|
-
* use a bridge claim if balance is below threshold.
|
|
203
|
-
*/ async setupTokenWithOptionalEarlyRefuel(sender) {
|
|
204
|
-
const token = await this.getTokenInstance(sender);
|
|
205
|
-
const address = token.address;
|
|
206
|
-
const metadata = await this.wallet.getContractMetadata(address);
|
|
207
|
-
if (metadata.isContractPublished) {
|
|
208
|
-
this.log.info(`Token at ${address.toString()} already deployed, refueling before setup`);
|
|
209
|
-
await this.ensureFeeJuiceBalance(sender, token);
|
|
210
|
-
}
|
|
211
|
-
return this.setupToken(sender);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Setup token0 for AMM with refuel-first behaviour when token already exists.
|
|
215
|
-
*/ async setupTokenContractWithOptionalEarlyRefuel(deployer, salt, name, ticker, decimals = 18) {
|
|
216
|
-
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals, {
|
|
217
|
-
salt,
|
|
218
|
-
universalDeploy: true
|
|
219
|
-
});
|
|
220
|
-
const instance = await deploy.getInstance();
|
|
221
|
-
const metadata = await this.wallet.getContractMetadata(instance.address);
|
|
222
|
-
if (metadata.isContractPublished) {
|
|
223
|
-
this.log.info(`Token ${name} at ${instance.address.toString()} already deployed, refueling before setup`);
|
|
224
|
-
const token = TokenContract.at(instance.address, this.wallet);
|
|
225
|
-
await this.ensureFeeJuiceBalance(deployer, token);
|
|
226
|
-
}
|
|
227
|
-
return this.setupTokenContract(deployer, salt, name, ticker, decimals);
|
|
228
|
-
}
|
|
229
|
-
async getTokenInstance(sender) {
|
|
230
|
-
const salt = this.config.tokenSalt;
|
|
231
|
-
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
232
|
-
const deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18, {
|
|
233
|
-
salt,
|
|
234
|
-
universalDeploy: true
|
|
235
|
-
});
|
|
236
|
-
const instance = await deploy.getInstance();
|
|
237
|
-
return TokenContract.at(instance.address, this.wallet);
|
|
238
|
-
}
|
|
239
|
-
if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
240
|
-
const tokenSecretKey = Fr.random();
|
|
241
|
-
const tokenPublicKeys = (await deriveKeys(tokenSecretKey)).publicKeys;
|
|
242
|
-
const deploy = PrivateTokenContract.deploy(this.wallet, MINT_BALANCE, sender, {
|
|
243
|
-
salt,
|
|
244
|
-
universalDeploy: true,
|
|
245
|
-
publicKeys: tokenPublicKeys
|
|
246
|
-
});
|
|
247
|
-
const instance = await deploy.getInstance();
|
|
248
|
-
return PrivateTokenContract.at(instance.address, this.wallet);
|
|
249
|
-
}
|
|
250
|
-
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
174
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
254
175
|
* Uses a bridge claim for deploy when balance is below threshold to avoid failing before refuel.
|
|
255
176
|
* @param sender - Aztec address to deploy the token contract from.
|
|
@@ -395,83 +316,38 @@ export class BotFactory {
|
|
|
395
316
|
if (metadata.isContractPublished) {
|
|
396
317
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
397
318
|
await deploy.register();
|
|
398
|
-
|
|
399
|
-
const sender = deployOpts.from === NO_FROM ? undefined : deployOpts.from;
|
|
400
|
-
const balance = sender ? await getFeeJuiceBalance(sender, this.aztecNode) : 0n;
|
|
401
|
-
const useClaim = sender && balance < FEE_JUICE_TOP_UP_THRESHOLD && this.config.feePaymentMethod === 'fee_juice' && !!this.config.l1RpcUrls?.length;
|
|
402
|
-
const mnemonicOrPrivateKey = this.config.l1PrivateKey?.getValue() ?? this.config.l1Mnemonic?.getValue();
|
|
403
|
-
if (useClaim && mnemonicOrPrivateKey) {
|
|
404
|
-
const claim = await this.getOrCreateBridgeClaim(sender);
|
|
405
|
-
const paymentMethod = new FeeJuicePaymentMethodWithClaim(sender, claim);
|
|
406
|
-
const { estimatedGas } = await deploy.simulate({
|
|
407
|
-
...deployOpts,
|
|
408
|
-
fee: {
|
|
409
|
-
estimateGas: true,
|
|
410
|
-
paymentMethod
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
const maxFeesPerGas = (await this.getMinFees()).mul(1 + this.config.minFeePadding);
|
|
414
|
-
const gasSettings = GasSettings.from({
|
|
415
|
-
...estimatedGas,
|
|
416
|
-
maxFeesPerGas,
|
|
417
|
-
maxPriorityFeesPerGas: GasFees.empty()
|
|
418
|
-
});
|
|
419
|
-
await this.withNoMinTxsPerBlock(async ()=>{
|
|
420
|
-
const { txHash } = await deploy.send({
|
|
421
|
-
...deployOpts,
|
|
422
|
-
fee: {
|
|
423
|
-
gasSettings,
|
|
424
|
-
paymentMethod
|
|
425
|
-
},
|
|
426
|
-
wait: NO_WAIT
|
|
427
|
-
});
|
|
428
|
-
this.log.info(`Sent contract ${name} deploy tx ${txHash.toString()} (using bridge claim, balance was ${balance})`);
|
|
429
|
-
return waitForTx(this.aztecNode, txHash, {
|
|
430
|
-
timeout: this.config.txMinedWaitSeconds
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
|
-
await this.store.deleteBridgeClaim(sender);
|
|
434
|
-
} else {
|
|
435
|
-
const { estimatedGas } = await deploy.simulate({
|
|
436
|
-
...deployOpts,
|
|
437
|
-
fee: {
|
|
438
|
-
estimateGas: true
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
this.log.info(`Deploying contract ${name} at ${address.toString()}`, {
|
|
442
|
-
estimatedGas
|
|
443
|
-
});
|
|
444
|
-
await this.withNoMinTxsPerBlock(async ()=>{
|
|
445
|
-
const { txHash } = await deploy.send({
|
|
446
|
-
...deployOpts,
|
|
447
|
-
fee: {
|
|
448
|
-
gasSettings: estimatedGas
|
|
449
|
-
},
|
|
450
|
-
wait: NO_WAIT
|
|
451
|
-
});
|
|
452
|
-
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
453
|
-
return waitForTx(this.aztecNode, txHash, {
|
|
454
|
-
timeout: this.config.txMinedWaitSeconds
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
}
|
|
319
|
+
return instance;
|
|
458
320
|
}
|
|
321
|
+
// Setup always runs ensureFeeJuiceBalance before any deploy, so the account pays from its standing
|
|
322
|
+
// balance here. No manual gas estimation: the embedded wallet simulates before sending and derives
|
|
323
|
+
// the gas limits and padded maxFeesPerGas itself.
|
|
324
|
+
this.log.info(`Deploying contract ${name} at ${address.toString()}`);
|
|
325
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
326
|
+
const { txHash } = await deploy.send({
|
|
327
|
+
...deployOpts,
|
|
328
|
+
wait: NO_WAIT
|
|
329
|
+
});
|
|
330
|
+
this.log.info(`Sent contract ${name} deploy tx ${txHash.toString()}`);
|
|
331
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
332
|
+
timeout: this.config.txMinedWaitSeconds
|
|
333
|
+
});
|
|
334
|
+
});
|
|
459
335
|
return instance;
|
|
460
336
|
}
|
|
461
|
-
/**
|
|
462
|
-
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
463
|
-
* @param token - Token contract.
|
|
464
|
-
*/ /**
|
|
465
|
-
* Ensures the account has sufficient fee juice by bridging from L1 if balance is below threshold.
|
|
466
|
-
* Bridges repeatedly until balance reaches the target (10k FJ).
|
|
467
|
-
* Used on startup/restart to top up when the account has run out after previous runs.
|
|
468
|
-
*/ async ensureFeeJuiceBalance(account, token) {
|
|
469
|
-
const { feePaymentMethod, l1RpcUrls } = this.config;
|
|
470
|
-
if (feePaymentMethod !== 'fee_juice' || !l1RpcUrls?.length) {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
337
|
+
/** True when the config allows bridging fee juice from L1 (fee_juice mode, an L1 RPC, and an L1 key). */ isL1BridgingConfigured() {
|
|
473
338
|
const mnemonicOrPrivateKey = this.config.l1PrivateKey?.getValue() ?? this.config.l1Mnemonic?.getValue();
|
|
474
|
-
|
|
339
|
+
return this.config.feePaymentMethod === 'fee_juice' && !!this.config.l1RpcUrls?.length && !!mnemonicOrPrivateKey;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Ensures the account holds enough fee juice before any other setup step. The account starts empty
|
|
343
|
+
* (initializerless accounts have no deployment tx) and the runtime loop pays fees from this balance and
|
|
344
|
+
* never refuels itself, so every flow funds the account up front. Bridges claims from L1 and consumes
|
|
345
|
+
* each with a claim-only tx until the balance clears the threshold, working from a zero (fresh run) or
|
|
346
|
+
* drained (restart) balance. Each bridge mints a fixed amount well above the threshold, so this is a
|
|
347
|
+
* single bridge in practice. No-op when L1 bridging is not configured or the balance is already above
|
|
348
|
+
* the threshold.
|
|
349
|
+
*/ async ensureFeeJuiceBalance(account) {
|
|
350
|
+
if (!this.isL1BridgingConfigured()) {
|
|
475
351
|
return;
|
|
476
352
|
}
|
|
477
353
|
let balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
@@ -479,31 +355,16 @@ export class BotFactory {
|
|
|
479
355
|
this.log.info(`Fee juice balance ${balance} above threshold ${FEE_JUICE_TOP_UP_THRESHOLD}, skipping top-up`);
|
|
480
356
|
return;
|
|
481
357
|
}
|
|
482
|
-
this.log.info(`Fee juice balance ${balance} below threshold ${FEE_JUICE_TOP_UP_THRESHOLD}, bridging from L1
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
const claim = await this.
|
|
358
|
+
this.log.info(`Fee juice balance ${balance} below threshold ${FEE_JUICE_TOP_UP_THRESHOLD}, bridging from L1`);
|
|
359
|
+
while(balance < FEE_JUICE_TOP_UP_THRESHOLD){
|
|
360
|
+
// Persist the claim before consuming it: if the top-up tx fails or the bot crashes mid-loop, the
|
|
361
|
+
// next run reuses the pending claim instead of bridging again (and wasting the bridged funds).
|
|
362
|
+
const claim = await this.getOrCreateBridgeClaim(account);
|
|
487
363
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(account, claim);
|
|
488
|
-
const { estimatedGas } = await minimalInteraction.simulate({
|
|
489
|
-
from: account,
|
|
490
|
-
fee: {
|
|
491
|
-
estimateGas: true,
|
|
492
|
-
paymentMethod
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
const gasSettings = GasSettings.from({
|
|
496
|
-
...estimatedGas,
|
|
497
|
-
maxFeesPerGas,
|
|
498
|
-
maxPriorityFeesPerGas: GasFees.empty()
|
|
499
|
-
});
|
|
500
364
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
501
|
-
const
|
|
365
|
+
const executionPayload = await paymentMethod.getExecutionPayload();
|
|
366
|
+
const { txHash } = await this.wallet.sendTx(executionPayload, {
|
|
502
367
|
from: account,
|
|
503
|
-
fee: {
|
|
504
|
-
gasSettings,
|
|
505
|
-
paymentMethod
|
|
506
|
-
},
|
|
507
368
|
wait: NO_WAIT
|
|
508
369
|
});
|
|
509
370
|
this.log.info(`Sent fee juice top-up tx ${txHash.toString()}`);
|
|
@@ -511,6 +372,7 @@ export class BotFactory {
|
|
|
511
372
|
timeout: this.config.txMinedWaitSeconds
|
|
512
373
|
});
|
|
513
374
|
});
|
|
375
|
+
await this.store.deleteBridgeClaim(account);
|
|
514
376
|
balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
515
377
|
this.log.info(`Fee juice balance after top-up: ${balance}`);
|
|
516
378
|
}
|
|
@@ -556,19 +418,18 @@ export class BotFactory {
|
|
|
556
418
|
});
|
|
557
419
|
}
|
|
558
420
|
/**
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
421
|
+
* Returns a usable bridge claim for the recipient, reusing a persisted one when its L1→L2 message is
|
|
422
|
+
* still available (resuming a top-up that failed or crashed before the claim was consumed) and bridging
|
|
423
|
+
* a fresh claim otherwise. The caller deletes the claim from the store once it has been consumed.
|
|
562
424
|
*/ async getOrCreateBridgeClaim(recipient) {
|
|
563
|
-
// Check if we have an existing claim in the store
|
|
564
425
|
const existingClaim = await this.store.getBridgeClaim(recipient);
|
|
565
426
|
if (existingClaim) {
|
|
566
427
|
this.log.info(`Found existing bridge claim for ${recipient.toString()}, checking validity...`);
|
|
567
|
-
// Check if the message is ready on L2
|
|
568
428
|
try {
|
|
569
429
|
const messageHash = Fr.fromHexString(existingClaim.claim.messageHash);
|
|
570
430
|
await this.withNoMinTxsPerBlock(()=>waitForL1ToL2MessageReady(this.aztecNode, messageHash, {
|
|
571
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
431
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
432
|
+
chainTip: this.syncChainTip
|
|
572
433
|
}));
|
|
573
434
|
return existingClaim.claim;
|
|
574
435
|
} catch (err) {
|
|
@@ -596,22 +457,12 @@ export class BotFactory {
|
|
|
596
457
|
const mintAmount = await portal.getTokenManager().getMintAmount();
|
|
597
458
|
const claim = await portal.bridgeTokensPublic(recipient, mintAmount, true);
|
|
598
459
|
await this.withNoMinTxsPerBlock(()=>waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(claim.messageHash), {
|
|
599
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
460
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
461
|
+
chainTip: this.syncChainTip
|
|
600
462
|
}));
|
|
601
463
|
this.log.info(`Created a claim for ${mintAmount} L1 fee juice to ${recipient}.`, claim);
|
|
602
464
|
return claim;
|
|
603
465
|
}
|
|
604
|
-
/** Returns worst-case min fees across predicted slots, with fallback to current min fees. */ async getMinFees() {
|
|
605
|
-
try {
|
|
606
|
-
const predicted = await this.aztecNode.getPredictedMinFees(ManaUsageEstimate.Limit);
|
|
607
|
-
if (predicted.length === 0) {
|
|
608
|
-
return this.aztecNode.getCurrentMinFees();
|
|
609
|
-
}
|
|
610
|
-
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
611
|
-
} catch {
|
|
612
|
-
return this.aztecNode.getCurrentMinFees();
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
466
|
async withNoMinTxsPerBlock(fn) {
|
|
616
467
|
if (!this.aztecNodeAdmin || !this.config.flushSetupTransactions) {
|
|
617
468
|
this.log.verbose(`No node admin client or flushing not requested (not setting minTxsPerBlock to 0)`);
|
package/dest/runner.d.ts
CHANGED
|
@@ -13,13 +13,14 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
|
|
|
13
13
|
private readonly telemetry;
|
|
14
14
|
private readonly aztecNodeAdmin;
|
|
15
15
|
private readonly store;
|
|
16
|
+
private readonly syncChainTip?;
|
|
16
17
|
private log;
|
|
17
18
|
private bot?;
|
|
18
19
|
private runningPromise;
|
|
19
20
|
private consecutiveErrors;
|
|
20
21
|
private healthy;
|
|
21
22
|
readonly tracer: Tracer;
|
|
22
|
-
constructor(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore);
|
|
23
|
+
constructor(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore, syncChainTip?: "checkpointed" | "finalized" | "latest" | "proposed" | "proven" | undefined);
|
|
23
24
|
/** Initializes the bot if needed. Blocks until the bot setup is finished. */
|
|
24
25
|
setup(): Promise<void>;
|
|
25
26
|
private doSetup;
|
|
@@ -50,4 +51,4 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
|
|
|
50
51
|
/** Returns the bot sender address. */
|
|
51
52
|
getInfo(): Promise<BotInfo>;
|
|
52
53
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVubmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcnVubmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBSXRELE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ3RFLE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBRSxLQUFLLFNBQVMsRUFBRSxLQUFLLE1BQU0sRUFBYSxNQUFNLHlCQUF5QixDQUFDO0FBQ3ZHLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBSzlELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUU3QyxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFDNUQsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTVDLHFCQUFhLFNBQVUsWUFBVyxZQUFZLEVBQUUsU0FBUzs7SUFVckQsT0FBTyxDQUFDLE1BQU07SUFDZCxPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU07SUFDdkIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQzFCLE9BQU8sQ0FBQyxRQUFRLENBQUMsU0FBUztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLGNBQWM7SUFDL0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLO0lBQ3RCLE9BQU8sQ0FBQyxRQUFRLENBQUMsWUFBWSxDQUFDO0lBZmhDLE9BQU8sQ0FBQyxHQUFHLENBQXVCO0lBQ2xDLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBbUI7SUFDL0IsT0FBTyxDQUFDLGNBQWMsQ0FBaUI7SUFDdkMsT0FBTyxDQUFDLGlCQUFpQixDQUFLO0lBQzlCLE9BQU8sQ0FBQyxPQUFPLENBQVE7SUFFdkIsU0FBZ0IsTUFBTSxFQUFFLE1BQU0sQ0FBQztJQUUvQixZQUNVLE1BQU0sRUFBRSxTQUFTLEVBQ1IsTUFBTSxFQUFFLGNBQWMsRUFDdEIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsU0FBUyxFQUFFLGVBQWUsRUFDMUIsY0FBYyxFQUFFLGNBQWMsR0FBRyxTQUFTLEVBQzFDLEtBQUssRUFBRSxRQUFRLEVBQ2YsWUFBWSxDQUFDLDZFQUFVLEVBS3pDO0lBRUQsNkVBQTZFO0lBQ2hFLEtBQUssa0JBSWpCO1lBR2EsT0FBTztJQU1yQjs7O09BR0c7SUFDVSxLQUFLLGtCQU1qQjtJQUVEOztPQUVHO0lBQ1UsSUFBSSxrQkFPaEI7SUFFTSxTQUFTLFlBRWY7SUFFRCwwQ0FBMEM7SUFDbkMsU0FBUyxZQUVmO0lBRUQ7OztPQUdHO0lBQ1UsTUFBTSxDQUFDLE1BQU0sRUFBRSxTQUFTLGlCQWFwQztJQUVEOzs7T0FHRztJQUNVLEdBQUcsa0JBc0JmO0lBRUQscURBQXFEO0lBQzlDLFNBQVMsdUJBR2Y7SUFFRCxzQ0FBc0M7SUFDekIsT0FBTyxJQUFJLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FNdkM7Q0F3RUYifQ==
|
package/dest/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAa,MAAM,yBAAyB,CAAC;AACvG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAK9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,SAAU,YAAW,YAAY,EAAE,SAAS;;IAUrD,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAfhC,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,GAAG,CAAC,CAAmB;IAC/B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,OAAO,CAAQ;IAEvB,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,YACU,MAAM,EAAE,SAAS,EACR,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,eAAe,EAC1B,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,KAAK,EAAE,QAAQ,EACf,YAAY,CAAC,6EAAU,EAKzC;IAED,6EAA6E;IAChE,KAAK,kBAIjB;YAGa,OAAO;IAMrB;;;OAGG;IACU,KAAK,kBAMjB;IAED;;OAEG;IACU,IAAI,kBAOhB;IAEM,SAAS,YAEf;IAED,0CAA0C;IACnC,SAAS,YAEf;IAED;;;OAGG;IACU,MAAM,CAAC,MAAM,EAAE,SAAS,iBAapC;IAED;;;OAGG;IACU,GAAG,kBAsBf;IAED,qDAAqD;IAC9C,SAAS,uBAGf;IAED,sCAAsC;IACzB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAMvC;CAwEF"}
|
package/dest/runner.js
CHANGED
|
@@ -386,6 +386,7 @@ export class BotRunner {
|
|
|
386
386
|
telemetry;
|
|
387
387
|
aztecNodeAdmin;
|
|
388
388
|
store;
|
|
389
|
+
syncChainTip;
|
|
389
390
|
static{
|
|
390
391
|
({ e: [_call_work, _initProto] } = _apply_decs_2203_r(this, [
|
|
391
392
|
[
|
|
@@ -428,13 +429,14 @@ export class BotRunner {
|
|
|
428
429
|
consecutiveErrors;
|
|
429
430
|
healthy;
|
|
430
431
|
tracer;
|
|
431
|
-
constructor(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store){
|
|
432
|
+
constructor(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store, syncChainTip){
|
|
432
433
|
this.config = config;
|
|
433
434
|
this.wallet = wallet;
|
|
434
435
|
this.aztecNode = aztecNode;
|
|
435
436
|
this.telemetry = telemetry;
|
|
436
437
|
this.aztecNodeAdmin = aztecNodeAdmin;
|
|
437
438
|
this.store = store;
|
|
439
|
+
this.syncChainTip = syncChainTip;
|
|
438
440
|
this.log = (_initProto(this), createLogger('bot'));
|
|
439
441
|
this.consecutiveErrors = 0;
|
|
440
442
|
this.healthy = true;
|
|
@@ -538,13 +540,13 @@ export class BotRunner {
|
|
|
538
540
|
try {
|
|
539
541
|
switch(this.config.botMode){
|
|
540
542
|
case 'crosschain':
|
|
541
|
-
this.bot = CrossChainBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
|
|
543
|
+
this.bot = CrossChainBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
|
|
542
544
|
break;
|
|
543
545
|
case 'amm':
|
|
544
|
-
this.bot = AmmBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
|
|
546
|
+
this.bot = AmmBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
|
|
545
547
|
break;
|
|
546
548
|
case 'transfer':
|
|
547
|
-
this.bot = Bot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
|
|
549
|
+
this.bot = Bot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
|
|
548
550
|
break;
|
|
549
551
|
default:
|
|
550
552
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bot",
|
|
3
|
-
"version": "6.0.0-nightly.
|
|
3
|
+
"version": "6.0.0-nightly.20260721",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@aztec/accounts": "6.0.0-nightly.
|
|
58
|
-
"@aztec/aztec.js": "6.0.0-nightly.
|
|
59
|
-
"@aztec/entrypoints": "6.0.0-nightly.
|
|
60
|
-
"@aztec/ethereum": "6.0.0-nightly.
|
|
61
|
-
"@aztec/foundation": "6.0.0-nightly.
|
|
62
|
-
"@aztec/kv-store": "6.0.0-nightly.
|
|
63
|
-
"@aztec/l1-artifacts": "6.0.0-nightly.
|
|
64
|
-
"@aztec/noir-contracts.js": "6.0.0-nightly.
|
|
65
|
-
"@aztec/noir-protocol-circuits-types": "6.0.0-nightly.
|
|
66
|
-
"@aztec/noir-test-contracts.js": "6.0.0-nightly.
|
|
67
|
-
"@aztec/protocol-contracts": "6.0.0-nightly.
|
|
68
|
-
"@aztec/stdlib": "6.0.0-nightly.
|
|
69
|
-
"@aztec/telemetry-client": "6.0.0-nightly.
|
|
70
|
-
"@aztec/wallets": "6.0.0-nightly.
|
|
57
|
+
"@aztec/accounts": "6.0.0-nightly.20260721",
|
|
58
|
+
"@aztec/aztec.js": "6.0.0-nightly.20260721",
|
|
59
|
+
"@aztec/entrypoints": "6.0.0-nightly.20260721",
|
|
60
|
+
"@aztec/ethereum": "6.0.0-nightly.20260721",
|
|
61
|
+
"@aztec/foundation": "6.0.0-nightly.20260721",
|
|
62
|
+
"@aztec/kv-store": "6.0.0-nightly.20260721",
|
|
63
|
+
"@aztec/l1-artifacts": "6.0.0-nightly.20260721",
|
|
64
|
+
"@aztec/noir-contracts.js": "6.0.0-nightly.20260721",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "6.0.0-nightly.20260721",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "6.0.0-nightly.20260721",
|
|
67
|
+
"@aztec/protocol-contracts": "6.0.0-nightly.20260721",
|
|
68
|
+
"@aztec/stdlib": "6.0.0-nightly.20260721",
|
|
69
|
+
"@aztec/telemetry-client": "6.0.0-nightly.20260721",
|
|
70
|
+
"@aztec/wallets": "6.0.0-nightly.20260721",
|
|
71
71
|
"source-map-support": "^0.5.21",
|
|
72
72
|
"tslib": "^2.4.0",
|
|
73
73
|
"viem": "npm:@aztec/viem@2.38.2",
|
package/src/amm_bot.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
|
5
5
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
6
6
|
import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
7
7
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
8
|
+
import type { BlockTag } from '@aztec/stdlib/block';
|
|
8
9
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
9
10
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
10
11
|
|
|
@@ -37,6 +38,7 @@ export class AmmBot extends BaseBot {
|
|
|
37
38
|
aztecNode: AztecNode,
|
|
38
39
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
39
40
|
store: BotStore,
|
|
41
|
+
syncChainTip?: BlockTag,
|
|
40
42
|
): Promise<AmmBot> {
|
|
41
43
|
const { defaultAccountAddress, token0, token1, amm } = await new BotFactory(
|
|
42
44
|
config,
|
|
@@ -44,6 +46,7 @@ export class AmmBot extends BaseBot {
|
|
|
44
46
|
store,
|
|
45
47
|
aztecNode,
|
|
46
48
|
aztecNodeAdmin,
|
|
49
|
+
syncChainTip,
|
|
47
50
|
).setupAmm();
|
|
48
51
|
return new AmmBot(aztecNode, wallet, defaultAccountAddress, amm, token0, token1, config);
|
|
49
52
|
}
|
package/src/bot.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { TxHash } from '@aztec/aztec.js/tx';
|
|
|
4
4
|
import { times } from '@aztec/foundation/collection';
|
|
5
5
|
import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
6
6
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
7
|
+
import type { BlockTag } from '@aztec/stdlib/block';
|
|
7
8
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
8
9
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
9
10
|
|
|
@@ -33,6 +34,7 @@ export class Bot extends BaseBot {
|
|
|
33
34
|
aztecNode: AztecNode,
|
|
34
35
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
35
36
|
store: BotStore,
|
|
37
|
+
syncChainTip?: BlockTag,
|
|
36
38
|
): Promise<Bot> {
|
|
37
39
|
const { defaultAccountAddress, token, recipient } = await new BotFactory(
|
|
38
40
|
config,
|
|
@@ -40,6 +42,7 @@ export class Bot extends BaseBot {
|
|
|
40
42
|
store,
|
|
41
43
|
aztecNode,
|
|
42
44
|
aztecNodeAdmin,
|
|
45
|
+
syncChainTip,
|
|
43
46
|
).setup();
|
|
44
47
|
return new Bot(aztecNode, wallet, defaultAccountAddress, token, recipient, config);
|
|
45
48
|
}
|
package/src/config.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
SecretValue,
|
|
4
4
|
booleanConfigHelper,
|
|
5
|
+
floatConfigHelper,
|
|
5
6
|
getConfigFromMappings,
|
|
6
7
|
getDefaultConfig,
|
|
7
8
|
numberConfigHelper,
|
|
@@ -103,7 +104,7 @@ export const BotConfigSchema = zodFor<BotConfig>()(
|
|
|
103
104
|
privateTransfersPerTx: z.number().int().nonnegative(),
|
|
104
105
|
publicTransfersPerTx: z.number().int().nonnegative(),
|
|
105
106
|
feePaymentMethod: z.literal('fee_juice'),
|
|
106
|
-
minFeePadding: z.number().
|
|
107
|
+
minFeePadding: z.number().nonnegative(),
|
|
107
108
|
noStart: z.boolean(),
|
|
108
109
|
txMinedWaitSeconds: z.number(),
|
|
109
110
|
followChain: z.enum(BotFollowChain),
|
|
@@ -204,7 +205,7 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
204
205
|
minFeePadding: {
|
|
205
206
|
env: 'BOT_MIN_FEE_PADDING',
|
|
206
207
|
description: 'How much is the bot willing to overpay vs. the current base fee',
|
|
207
|
-
...
|
|
208
|
+
...floatConfigHelper(3),
|
|
208
209
|
},
|
|
209
210
|
noStart: {
|
|
210
211
|
env: 'BOT_NO_START',
|