@aztec/bot 0.0.1-commit.7b97ef96e → 0.0.1-commit.7cbc774

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/bot",
3
- "version": "0.0.1-commit.7b97ef96e",
3
+ "version": "0.0.1-commit.7cbc774",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -54,24 +54,24 @@
54
54
  ]
55
55
  },
56
56
  "dependencies": {
57
- "@aztec/accounts": "0.0.1-commit.7b97ef96e",
58
- "@aztec/aztec.js": "0.0.1-commit.7b97ef96e",
59
- "@aztec/entrypoints": "0.0.1-commit.7b97ef96e",
60
- "@aztec/ethereum": "0.0.1-commit.7b97ef96e",
61
- "@aztec/foundation": "0.0.1-commit.7b97ef96e",
62
- "@aztec/kv-store": "0.0.1-commit.7b97ef96e",
63
- "@aztec/l1-artifacts": "0.0.1-commit.7b97ef96e",
64
- "@aztec/noir-contracts.js": "0.0.1-commit.7b97ef96e",
65
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.7b97ef96e",
66
- "@aztec/noir-test-contracts.js": "0.0.1-commit.7b97ef96e",
67
- "@aztec/protocol-contracts": "0.0.1-commit.7b97ef96e",
68
- "@aztec/stdlib": "0.0.1-commit.7b97ef96e",
69
- "@aztec/telemetry-client": "0.0.1-commit.7b97ef96e",
70
- "@aztec/wallets": "0.0.1-commit.7b97ef96e",
57
+ "@aztec/accounts": "0.0.1-commit.7cbc774",
58
+ "@aztec/aztec.js": "0.0.1-commit.7cbc774",
59
+ "@aztec/entrypoints": "0.0.1-commit.7cbc774",
60
+ "@aztec/ethereum": "0.0.1-commit.7cbc774",
61
+ "@aztec/foundation": "0.0.1-commit.7cbc774",
62
+ "@aztec/kv-store": "0.0.1-commit.7cbc774",
63
+ "@aztec/l1-artifacts": "0.0.1-commit.7cbc774",
64
+ "@aztec/noir-contracts.js": "0.0.1-commit.7cbc774",
65
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.7cbc774",
66
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.7cbc774",
67
+ "@aztec/protocol-contracts": "0.0.1-commit.7cbc774",
68
+ "@aztec/stdlib": "0.0.1-commit.7cbc774",
69
+ "@aztec/telemetry-client": "0.0.1-commit.7cbc774",
70
+ "@aztec/wallets": "0.0.1-commit.7cbc774",
71
71
  "source-map-support": "^0.5.21",
72
72
  "tslib": "^2.4.0",
73
73
  "viem": "npm:@aztec/viem@2.38.2",
74
- "zod": "^3.23.8"
74
+ "zod": "^4"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@jest/globals": "^30.0.0",
package/src/amm_bot.ts CHANGED
@@ -71,12 +71,14 @@ export class AmmBot extends BaseBot {
71
71
  .getFunctionCall(),
72
72
  });
73
73
 
74
- const amountOutMin = await amm.methods
75
- .get_amount_out_for_exact_in(
76
- await tokenIn.methods.balance_of_public(amm.address).simulate({ from: this.defaultAccountAddress }),
77
- await tokenOut.methods.balance_of_public(amm.address).simulate({ from: this.defaultAccountAddress }),
78
- amountIn,
79
- )
74
+ const { result: tokenInBalance } = await tokenIn.methods
75
+ .balance_of_public(amm.address)
76
+ .simulate({ from: this.defaultAccountAddress });
77
+ const { result: tokenOutBalance } = await tokenOut.methods
78
+ .balance_of_public(amm.address)
79
+ .simulate({ from: this.defaultAccountAddress });
80
+ const { result: amountOutMin } = await amm.methods
81
+ .get_amount_out_for_exact_in(tokenInBalance, tokenOutBalance, amountIn)
80
82
  .simulate({ from: this.defaultAccountAddress });
81
83
 
82
84
  const swapExactTokensInteraction = amm.methods
@@ -85,11 +87,12 @@ export class AmmBot extends BaseBot {
85
87
  authWitnesses: [swapAuthwit],
86
88
  });
87
89
 
88
- const opts = await this.getSendMethodOpts(swapExactTokensInteraction);
90
+ const opts = this.getSendMethodOpts();
89
91
 
90
92
  this.log.verbose(`Sending transaction`, logCtx);
91
93
  this.log.info(`Tx. Balances: ${jsonStringify(balances)}`, { ...logCtx, balances });
92
- return swapExactTokensInteraction.send({ ...opts, wait: NO_WAIT });
94
+ const { txHash } = await swapExactTokensInteraction.send({ ...opts, wait: NO_WAIT });
95
+ return txHash;
93
96
  }
94
97
 
95
98
  protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
@@ -110,15 +113,17 @@ export class AmmBot extends BaseBot {
110
113
  }
111
114
 
112
115
  private async getPublicBalanceFor(address: AztecAddress, from?: AztecAddress): Promise<Balances> {
113
- return {
114
- token0: await this.token0.methods.balance_of_public(address).simulate({ from: from ?? address }),
115
- token1: await this.token1.methods.balance_of_public(address).simulate({ from: from ?? address }),
116
- };
116
+ const { result: token0 } = await this.token0.methods.balance_of_public(address).simulate({ from: from ?? address });
117
+ const { result: token1 } = await this.token1.methods.balance_of_public(address).simulate({ from: from ?? address });
118
+ return { token0, token1 };
117
119
  }
118
120
  private async getPrivateBalanceFor(address: AztecAddress, from?: AztecAddress): Promise<Balances> {
119
- return {
120
- token0: await this.token0.methods.balance_of_private(address).simulate({ from: from ?? address }),
121
- token1: await this.token1.methods.balance_of_private(address).simulate({ from: from ?? address }),
122
- };
121
+ const { result: token0 } = await this.token0.methods
122
+ .balance_of_private(address)
123
+ .simulate({ from: from ?? address });
124
+ const { result: token1 } = await this.token1.methods
125
+ .balance_of_private(address)
126
+ .simulate({ from: from ?? address });
127
+ return { token0, token1 };
123
128
  }
124
129
  }
package/src/base_bot.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import { BatchCall, ContractFunctionInteraction, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
2
+ import type { SendInteractionOptions } from '@aztec/aztec.js/contracts';
3
3
  import { createLogger } from '@aztec/aztec.js/log';
4
4
  import { waitForTx } from '@aztec/aztec.js/node';
5
5
  import { TxHash, TxReceipt, TxStatus } from '@aztec/aztec.js/tx';
@@ -56,27 +56,19 @@ export abstract class BaseBot {
56
56
  return Promise.resolve();
57
57
  }
58
58
 
59
- protected async getSendMethodOpts(
60
- interaction: ContractFunctionInteraction | BatchCall,
61
- ): Promise<SendInteractionOptions> {
59
+ protected getSendMethodOpts(): SendInteractionOptions {
62
60
  const { l2GasLimit, daGasLimit, minFeePadding } = this.config;
63
61
 
64
62
  this.wallet.setMinFeePadding(minFeePadding);
65
63
 
66
- let gasSettings;
67
- if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
68
- gasSettings = { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) };
69
- this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
70
- } else {
71
- this.log.verbose(`Estimating gas for transaction`);
72
- ({ estimatedGas: gasSettings } = await interaction.simulate({
73
- fee: { estimateGas: true },
74
- from: this.defaultAccountAddress,
75
- }));
76
- }
64
+ const gasSettings =
65
+ l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0
66
+ ? { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) }
67
+ : undefined;
68
+
77
69
  return {
78
70
  from: this.defaultAccountAddress,
79
- fee: { gasSettings },
71
+ ...(gasSettings ? { fee: { gasSettings } } : {}),
80
72
  };
81
73
  }
82
74
  }
package/src/bot.ts CHANGED
@@ -70,13 +70,11 @@ export class Bot extends BaseBot {
70
70
  );
71
71
 
72
72
  const batch = new BatchCall(wallet, calls);
73
- const opts = await this.getSendMethodOpts(batch);
74
-
75
- this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx);
76
- await batch.simulate({ from: this.defaultAccountAddress });
73
+ const opts = this.getSendMethodOpts();
77
74
 
78
75
  this.log.verbose(`Sending transaction`, logCtx);
79
- return batch.send({ ...opts, wait: NO_WAIT });
76
+ const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
77
+ return txHash;
80
78
  }
81
79
 
82
80
  public async getBalances() {
package/src/config.ts CHANGED
@@ -11,9 +11,9 @@ import {
11
11
  secretStringConfigHelper,
12
12
  } from '@aztec/foundation/config';
13
13
  import { Fr } from '@aztec/foundation/curves/bn254';
14
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
15
14
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
16
15
  import { protocolContractsHash } from '@aztec/protocol-contracts';
16
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
17
17
  import { schemas, zodFor } from '@aztec/stdlib/schemas';
18
18
  import type { ComponentsVersions } from '@aztec/stdlib/versioning';
19
19
 
@@ -69,9 +69,9 @@ export type BotConfig = {
69
69
  maxPendingTxs: number;
70
70
  /** Whether to flush after sending each 'setup' transaction */
71
71
  flushSetupTransactions: boolean;
72
- /** L2 gas limit for the tx (empty to have the bot trigger an estimate gas). */
72
+ /** L2 gas limit for the tx (empty to let the bot's wallet estimate). */
73
73
  l2GasLimit: number | undefined;
74
- /** DA gas limit for the tx (empty to have the bot trigger an estimate gas). */
74
+ /** DA gas limit for the tx (empty to let the bot's wallet estimate). */
75
75
  daGasLimit: number | undefined;
76
76
  /** Token contract to use */
77
77
  contract: SupportedTokenContracts;
@@ -130,7 +130,6 @@ export const BotConfigSchema = zodFor<BotConfig>()(
130
130
  l1Mnemonic: undefined,
131
131
  l1PrivateKey: undefined,
132
132
  senderPrivateKey: undefined,
133
- dataDirectory: undefined,
134
133
  dataStoreMapSizeKb: 1_024 * 1_024,
135
134
  ...config,
136
135
  })),
@@ -244,12 +243,12 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
244
243
  },
245
244
  l2GasLimit: {
246
245
  env: 'BOT_L2_GAS_LIMIT',
247
- description: 'L2 gas limit for the tx (empty to have the bot trigger an estimate gas).',
246
+ description: "L2 gas limit for the tx (empty to let the bot's wallet estimate).",
248
247
  ...optionalNumberConfigHelper(),
249
248
  },
250
249
  daGasLimit: {
251
250
  env: 'BOT_DA_GAS_LIMIT',
252
- description: 'DA gas limit for the tx (empty to have the bot trigger an estimate gas).',
251
+ description: "DA gas limit for the tx (empty to let the bot's wallet estimate).",
253
252
  ...optionalNumberConfigHelper(),
254
253
  },
255
254
  contract: {
@@ -137,10 +137,11 @@ export class CrossChainBot extends BaseBot {
137
137
  }
138
138
 
139
139
  const batch = new BatchCall(this.wallet, calls);
140
- const opts = await this.getSendMethodOpts(batch);
140
+ const opts = this.getSendMethodOpts();
141
141
 
142
142
  this.log.verbose(`Sending cross-chain batch with ${calls.length} calls`, logCtx);
143
- return batch.send({ ...opts, wait: NO_WAIT });
143
+ const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
144
+ return txHash;
144
145
  }
145
146
 
146
147
  protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
@@ -174,14 +175,7 @@ export class CrossChainBot extends BaseBot {
174
175
  ): Promise<PendingL1ToL2Message | undefined> {
175
176
  const now = Date.now();
176
177
  for (const msg of pendingMessages) {
177
- const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash), {
178
- // Use forPublicConsumption: false so we wait until blockNumber >= messageBlockNumber.
179
- // With forPublicConsumption: true, the check returns true one block early (the sequencer
180
- // includes L1→L2 messages before executing the block's txs), but gas estimation simulates
181
- // against the current world state which doesn't yet have the message.
182
- // See https://linear.app/aztec-labs/issue/A-548 for details.
183
- forPublicConsumption: false,
184
- });
178
+ const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash));
185
179
  if (ready) {
186
180
  return msg;
187
181
  }