@aztec/bot 0.0.1-commit.b6e433891 → 0.0.1-commit.b9865e97
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 +2 -2
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +1 -1
- package/dest/base_bot.d.ts +4 -4
- package/dest/base_bot.d.ts.map +1 -1
- package/dest/base_bot.js +12 -22
- package/dest/bot.d.ts +1 -1
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +1 -5
- package/dest/config.d.ts +30 -81
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -2
- package/dest/cross_chain_bot.d.ts +2 -2
- package/dest/cross_chain_bot.d.ts.map +1 -1
- package/dest/cross_chain_bot.js +7 -4
- package/dest/factory.d.ts +6 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +224 -146
- package/dest/interface.d.ts +2 -6
- package/dest/interface.d.ts.map +1 -1
- package/dest/interface.js +30 -7
- package/package.json +16 -16
- package/src/amm_bot.ts +2 -2
- package/src/base_bot.ts +10 -17
- package/src/bot.ts +1 -4
- package/src/config.ts +4 -4
- package/src/cross_chain_bot.ts +6 -5
- package/src/factory.ts +218 -88
- package/src/interface.ts +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bot",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.b9865e97",
|
|
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.
|
|
58
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
59
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
60
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
61
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
62
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
63
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
64
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
65
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
66
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
67
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
68
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
69
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
-
"@aztec/wallets": "0.0.1-commit.
|
|
57
|
+
"@aztec/accounts": "0.0.1-commit.b9865e97",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.b9865e97",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.b9865e97",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.b9865e97",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.b9865e97",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.b9865e97",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.b9865e97",
|
|
64
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.b9865e97",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.b9865e97",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.b9865e97",
|
|
67
|
+
"@aztec/protocol-contracts": "0.0.1-commit.b9865e97",
|
|
68
|
+
"@aztec/stdlib": "0.0.1-commit.b9865e97",
|
|
69
|
+
"@aztec/telemetry-client": "0.0.1-commit.b9865e97",
|
|
70
|
+
"@aztec/wallets": "0.0.1-commit.b9865e97",
|
|
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": "^
|
|
74
|
+
"zod": "^4"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@jest/globals": "^30.0.0",
|
package/src/amm_bot.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
-
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
4
|
+
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';
|
|
@@ -87,7 +87,7 @@ export class AmmBot extends BaseBot {
|
|
|
87
87
|
authWitnesses: [swapAuthwit],
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
const opts =
|
|
90
|
+
const opts = this.getSendMethodOpts();
|
|
91
91
|
|
|
92
92
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
93
93
|
this.log.info(`Tx. Balances: ${jsonStringify(balances)}`, { ...logCtx, balances });
|
package/src/base_bot.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import {
|
|
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
|
-
import {
|
|
5
|
+
import { TxStatus } from '@aztec/aztec.js/tx';
|
|
6
|
+
import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
6
7
|
import { Gas } from '@aztec/stdlib/gas';
|
|
7
8
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
8
9
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
@@ -56,27 +57,19 @@ export abstract class BaseBot {
|
|
|
56
57
|
return Promise.resolve();
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
protected
|
|
60
|
-
interaction: ContractFunctionInteraction | BatchCall,
|
|
61
|
-
): Promise<SendInteractionOptions> {
|
|
60
|
+
protected getSendMethodOpts(): SendInteractionOptions {
|
|
62
61
|
const { l2GasLimit, daGasLimit, minFeePadding } = this.config;
|
|
63
62
|
|
|
64
63
|
this.wallet.setMinFeePadding(minFeePadding);
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.log.verbose(`Estimating gas for transaction`);
|
|
72
|
-
({ estimatedGas: gasSettings } = await interaction.simulate({
|
|
73
|
-
fee: { estimateGas: true },
|
|
74
|
-
from: this.defaultAccountAddress,
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
65
|
+
const gasSettings =
|
|
66
|
+
l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0
|
|
67
|
+
? { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) }
|
|
68
|
+
: undefined;
|
|
69
|
+
|
|
77
70
|
return {
|
|
78
71
|
from: this.defaultAccountAddress,
|
|
79
|
-
fee: { gasSettings },
|
|
72
|
+
...(gasSettings ? { fee: { gasSettings } } : {}),
|
|
80
73
|
};
|
|
81
74
|
}
|
|
82
75
|
}
|
package/src/bot.ts
CHANGED
|
@@ -70,10 +70,7 @@ export class Bot extends BaseBot {
|
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
const batch = new BatchCall(wallet, calls);
|
|
73
|
-
const opts =
|
|
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
76
|
const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
|
package/src/config.ts
CHANGED
|
@@ -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
|
|
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
|
|
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;
|
|
@@ -243,12 +243,12 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
243
243
|
},
|
|
244
244
|
l2GasLimit: {
|
|
245
245
|
env: 'BOT_L2_GAS_LIMIT',
|
|
246
|
-
description:
|
|
246
|
+
description: "L2 gas limit for the tx (empty to let the bot's wallet estimate).",
|
|
247
247
|
...optionalNumberConfigHelper(),
|
|
248
248
|
},
|
|
249
249
|
daGasLimit: {
|
|
250
250
|
env: 'BOT_DA_GAS_LIMIT',
|
|
251
|
-
description:
|
|
251
|
+
description: "DA gas limit for the tx (empty to let the bot's wallet estimate).",
|
|
252
252
|
...optionalNumberConfigHelper(),
|
|
253
253
|
},
|
|
254
254
|
contract: {
|
package/src/cross_chain_bot.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
27
27
|
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
28
28
|
import { isL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
29
|
-
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
29
|
+
import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
30
30
|
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
31
31
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
32
32
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -137,7 +137,7 @@ export class CrossChainBot extends BaseBot {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
const batch = new BatchCall(this.wallet, calls);
|
|
140
|
-
const opts =
|
|
140
|
+
const opts = this.getSendMethodOpts();
|
|
141
141
|
|
|
142
142
|
this.log.verbose(`Sending cross-chain batch with ${calls.length} calls`, logCtx);
|
|
143
143
|
const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
|
|
@@ -146,9 +146,10 @@ export class CrossChainBot extends BaseBot {
|
|
|
146
146
|
|
|
147
147
|
protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
|
|
148
148
|
// Verify L2→L1 messages appeared in this tx's effects
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
const minedReceipt = await this.node.getTxReceipt(receipt.txHash, { includeTxEffect: true });
|
|
150
|
+
const l2ToL1MsgsRaw = minedReceipt.txEffect?.l2ToL1Msgs;
|
|
151
|
+
if (l2ToL1MsgsRaw) {
|
|
152
|
+
const l2ToL1Msgs = l2ToL1MsgsRaw.filter(m => !m.isZero());
|
|
152
153
|
if (l2ToL1Msgs.length >= this.config.l2ToL1MessagesPerTx) {
|
|
153
154
|
this.l2ToL1Sent += l2ToL1Msgs.length;
|
|
154
155
|
} else {
|