@aztec/bot 0.0.1-commit.72dcdcda8 → 0.0.1-commit.7689c7f
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 +1 -1
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +24 -17
- package/dest/base_bot.d.ts +3 -3
- 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 +3 -6
- package/dest/config.d.ts +31 -82
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +3 -4
- package/dest/cross_chain_bot.d.ts +1 -1
- package/dest/cross_chain_bot.d.ts.map +1 -1
- package/dest/cross_chain_bot.js +4 -10
- package/dest/factory.d.ts +6 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +244 -84
- package/dest/interface.d.ts +2 -6
- package/dest/interface.d.ts.map +1 -1
- package/dest/interface.js +30 -7
- package/dest/utils.js +3 -3
- package/package.json +16 -16
- package/src/amm_bot.ts +21 -16
- package/src/base_bot.ts +8 -16
- package/src/bot.ts +3 -5
- package/src/config.ts +5 -6
- package/src/cross_chain_bot.ts +4 -10
- package/src/factory.ts +260 -79
- package/src/interface.ts +7 -7
- package/src/utils.ts +3 -3
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.7689c7f",
|
|
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.7689c7f",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.7689c7f",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.7689c7f",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.7689c7f",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.7689c7f",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.7689c7f",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.7689c7f",
|
|
64
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.7689c7f",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.7689c7f",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.7689c7f",
|
|
67
|
+
"@aztec/protocol-contracts": "0.0.1-commit.7689c7f",
|
|
68
|
+
"@aztec/stdlib": "0.0.1-commit.7689c7f",
|
|
69
|
+
"@aztec/telemetry-client": "0.0.1-commit.7689c7f",
|
|
70
|
+
"@aztec/wallets": "0.0.1-commit.7689c7f",
|
|
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
|
@@ -71,12 +71,14 @@ export class AmmBot extends BaseBot {
|
|
|
71
71
|
.getFunctionCall(),
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
const
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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
|
-
}
|
|
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 =
|
|
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 });
|
|
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
|
|
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;
|
|
@@ -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:
|
|
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:
|
|
251
|
+
description: "DA gas limit for the tx (empty to let the bot's wallet estimate).",
|
|
253
252
|
...optionalNumberConfigHelper(),
|
|
254
253
|
},
|
|
255
254
|
contract: {
|
package/src/cross_chain_bot.ts
CHANGED
|
@@ -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 =
|
|
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 });
|
|
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
|
}
|