@aztec/bot 0.0.1-commit.9ef841308 → 0.0.1-commit.a4600f49
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 +4 -3
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +2 -2
- package/dest/base_bot.d.ts +2 -2
- package/dest/base_bot.d.ts.map +1 -1
- 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 +28 -79
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +3 -3
- package/dest/cross_chain_bot.d.ts +6 -4
- package/dest/cross_chain_bot.d.ts.map +1 -1
- package/dest/cross_chain_bot.js +13 -9
- package/dest/factory.d.ts +7 -3
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +121 -105
- package/dest/interface.d.ts +2 -6
- package/dest/interface.d.ts.map +1 -1
- package/dest/interface.js +30 -7
- package/dest/runner.d.ts +3 -2
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +6 -4
- package/package.json +16 -16
- package/src/amm_bot.ts +4 -1
- package/src/base_bot.ts +2 -1
- package/src/bot.ts +3 -0
- package/src/config.ts +3 -2
- package/src/cross_chain_bot.ts +11 -6
- package/src/factory.ts +114 -100
- package/src/interface.ts +7 -7
- 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';
|
|
@@ -7,13 +6,12 @@ import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
|
7
6
|
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
|
-
import {
|
|
9
|
+
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
11
10
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
12
11
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
13
12
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
14
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
15
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
16
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
17
15
|
import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
18
16
|
import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
19
17
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
@@ -24,19 +22,22 @@ import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
|
24
22
|
import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils.js';
|
|
25
23
|
const MINT_BALANCE = 1e12;
|
|
26
24
|
const MIN_BALANCE = 1e3;
|
|
25
|
+
const FEE_JUICE_TOP_UP_THRESHOLD = 100n * 10n ** 18n;
|
|
27
26
|
export class BotFactory {
|
|
28
27
|
config;
|
|
29
28
|
wallet;
|
|
30
29
|
store;
|
|
31
30
|
aztecNode;
|
|
32
31
|
aztecNodeAdmin;
|
|
32
|
+
syncChainTip;
|
|
33
33
|
log;
|
|
34
|
-
constructor(config, wallet, store, aztecNode, aztecNodeAdmin){
|
|
34
|
+
constructor(config, wallet, store, aztecNode, aztecNodeAdmin, syncChainTip){
|
|
35
35
|
this.config = config;
|
|
36
36
|
this.wallet = wallet;
|
|
37
37
|
this.store = store;
|
|
38
38
|
this.aztecNode = aztecNode;
|
|
39
39
|
this.aztecNodeAdmin = aztecNodeAdmin;
|
|
40
|
+
this.syncChainTip = syncChainTip;
|
|
40
41
|
this.log = createLogger('bot');
|
|
41
42
|
// Set fee padding on the wallet so that all transactions during setup
|
|
42
43
|
// (token deploy, minting, etc.) use the configured padding, not the default.
|
|
@@ -48,6 +49,7 @@ export class BotFactory {
|
|
|
48
49
|
*/ async setup() {
|
|
49
50
|
const defaultAccountAddress = await this.setupAccount();
|
|
50
51
|
const recipient = (await this.wallet.createSchnorrAccount(Fr.random(), Fr.random())).address;
|
|
52
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress);
|
|
51
53
|
const token = await this.setupToken(defaultAccountAddress);
|
|
52
54
|
await this.mintTokens(token, defaultAccountAddress);
|
|
53
55
|
return {
|
|
@@ -60,6 +62,7 @@ export class BotFactory {
|
|
|
60
62
|
}
|
|
61
63
|
async setupAmm() {
|
|
62
64
|
const defaultAccountAddress = await this.setupAccount();
|
|
65
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress);
|
|
63
66
|
const token0 = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotToken0', 'BOT0');
|
|
64
67
|
const token1 = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotToken1', 'BOT1');
|
|
65
68
|
const liquidityToken = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotLPToken', 'BOTLP');
|
|
@@ -80,6 +83,7 @@ export class BotFactory {
|
|
|
80
83
|
* seeding initial L1→L2 messages, and waiting for the first to be ready.
|
|
81
84
|
*/ async setupCrossChain() {
|
|
82
85
|
const defaultAccountAddress = await this.setupAccount();
|
|
86
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress);
|
|
83
87
|
// Create L1 client (same pattern as bridgeL1FeeJuice)
|
|
84
88
|
const l1RpcUrls = this.config.l1RpcUrls;
|
|
85
89
|
if (!l1RpcUrls?.length) {
|
|
@@ -95,7 +99,7 @@ export class BotFactory {
|
|
|
95
99
|
// Fetch Rollup version (needed for Inbox L2Actor struct)
|
|
96
100
|
const rollupContract = new RollupContract(l1Client, l1ContractAddresses.rollupAddress.toString());
|
|
97
101
|
const rollupVersion = await rollupContract.getVersion();
|
|
98
|
-
// Deploy TestContract
|
|
102
|
+
// Deploy TestContract (pays from the standing balance funded above).
|
|
99
103
|
const contract = await this.setupTestContract(defaultAccountAddress);
|
|
100
104
|
// Recover any pending messages from store (clean up stale ones first)
|
|
101
105
|
await this.store.cleanupOldPendingMessages();
|
|
@@ -111,7 +115,8 @@ export class BotFactory {
|
|
|
111
115
|
this.log.info(`Waiting for first L1→L2 message to be ready...`);
|
|
112
116
|
const firstMsg = allMessages[0];
|
|
113
117
|
await waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(firstMsg.msgHash), {
|
|
114
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
118
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
119
|
+
chainTip: this.syncChainTip
|
|
115
120
|
});
|
|
116
121
|
this.log.info(`First L1→L2 message is ready`);
|
|
117
122
|
}
|
|
@@ -126,11 +131,12 @@ export class BotFactory {
|
|
|
126
131
|
}
|
|
127
132
|
async setupTestContract(deployer) {
|
|
128
133
|
const deployOpts = {
|
|
129
|
-
from: deployer
|
|
130
|
-
contractAddressSalt: this.config.tokenSalt,
|
|
131
|
-
universalDeploy: true
|
|
134
|
+
from: deployer
|
|
132
135
|
};
|
|
133
|
-
const deploy = TestContract.deploy(this.wallet
|
|
136
|
+
const deploy = TestContract.deploy(this.wallet, {
|
|
137
|
+
salt: this.config.tokenSalt,
|
|
138
|
+
universalDeploy: true
|
|
139
|
+
});
|
|
134
140
|
const instance = await this.registerOrDeployContract('TestContract', deploy, deployOpts);
|
|
135
141
|
return TestContract.at(instance.address, this.wallet);
|
|
136
142
|
}
|
|
@@ -147,75 +153,57 @@ export class BotFactory {
|
|
|
147
153
|
return await this.setupTestAccount();
|
|
148
154
|
}
|
|
149
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
|
+
}
|
|
150
167
|
async setupAccountWithPrivateKey(secret) {
|
|
151
168
|
const salt = this.config.senderSalt ?? Fr.ONE;
|
|
152
169
|
const signingKey = deriveSigningKey(secret);
|
|
153
|
-
const accountManager = await this.wallet.
|
|
154
|
-
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
155
|
-
if (metadata.initializationStatus === ContractInitializationStatus.INITIALIZED) {
|
|
156
|
-
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
157
|
-
const timer = new Timer();
|
|
158
|
-
const address = accountManager.address;
|
|
159
|
-
this.log.info(`Account at ${address} registered. duration=${timer.ms()}`);
|
|
160
|
-
await this.store.deleteBridgeClaim(address);
|
|
161
|
-
return address;
|
|
162
|
-
} else {
|
|
163
|
-
const address = accountManager.address;
|
|
164
|
-
this.log.info(`Deploying account at ${address}`);
|
|
165
|
-
const claim = await this.getOrCreateBridgeClaim(address);
|
|
166
|
-
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
167
|
-
const deployMethod = await accountManager.getDeployMethod();
|
|
168
|
-
await this.withNoMinTxsPerBlock(async ()=>{
|
|
169
|
-
const { txHash } = await deployMethod.send({
|
|
170
|
-
from: NO_FROM,
|
|
171
|
-
fee: {
|
|
172
|
-
paymentMethod
|
|
173
|
-
},
|
|
174
|
-
wait: NO_WAIT
|
|
175
|
-
});
|
|
176
|
-
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
177
|
-
return waitForTx(this.aztecNode, txHash, {
|
|
178
|
-
timeout: this.config.txMinedWaitSeconds
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
this.log.info(`Account deployed at ${address}`);
|
|
182
|
-
// Clean up the consumed bridge claim
|
|
183
|
-
await this.store.deleteBridgeClaim(address);
|
|
184
|
-
return accountManager.address;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
async setupTestAccount() {
|
|
188
|
-
const [initialAccountData] = await getInitialTestAccountsData();
|
|
189
|
-
const accountManager = await this.wallet.createSchnorrAccount(initialAccountData.secret, initialAccountData.salt, initialAccountData.signingKey);
|
|
170
|
+
const accountManager = await this.wallet.createSchnorrInitializerlessAccount(secret, salt, signingKey);
|
|
190
171
|
return accountManager.address;
|
|
191
172
|
}
|
|
192
173
|
/**
|
|
193
174
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
194
|
-
*
|
|
195
|
-
* @
|
|
175
|
+
* Uses a bridge claim for deploy when balance is below threshold to avoid failing before refuel.
|
|
176
|
+
* @param sender - Aztec address to deploy the token contract from.
|
|
177
|
+
* @param existingToken - Optional token instance when called from setupTokenWithOptionalEarlyRefuel.
|
|
178
|
+
* @returns The TokenContract or PrivateTokenContract instance.
|
|
196
179
|
*/ async setupToken(sender) {
|
|
197
180
|
let deploy;
|
|
198
|
-
|
|
181
|
+
const salt = this.config.tokenSalt;
|
|
199
182
|
const deployOpts = {
|
|
200
|
-
from: sender
|
|
201
|
-
contractAddressSalt: this.config.tokenSalt,
|
|
202
|
-
universalDeploy: true
|
|
183
|
+
from: sender
|
|
203
184
|
};
|
|
204
185
|
let token;
|
|
205
186
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
206
|
-
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18
|
|
207
|
-
|
|
208
|
-
|
|
187
|
+
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18, {
|
|
188
|
+
salt,
|
|
189
|
+
universalDeploy: true
|
|
190
|
+
});
|
|
191
|
+
const instance = await deploy.getInstance();
|
|
192
|
+
token = TokenContract.at(instance.address, this.wallet);
|
|
209
193
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
210
194
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
211
195
|
const tokenSecretKey = Fr.random();
|
|
212
196
|
const tokenPublicKeys = (await deriveKeys(tokenSecretKey)).publicKeys;
|
|
213
|
-
deploy = PrivateTokenContract.
|
|
197
|
+
deploy = PrivateTokenContract.deploy(this.wallet, MINT_BALANCE, sender, {
|
|
198
|
+
salt,
|
|
199
|
+
universalDeploy: true,
|
|
200
|
+
publicKeys: tokenPublicKeys
|
|
201
|
+
});
|
|
214
202
|
deployOpts.skipInstancePublication = true;
|
|
215
203
|
deployOpts.skipClassPublication = true;
|
|
216
204
|
deployOpts.skipInitialization = false;
|
|
217
205
|
// Register the contract with the secret key before deployment
|
|
218
|
-
tokenInstance = await deploy.getInstance(
|
|
206
|
+
const tokenInstance = await deploy.getInstance();
|
|
219
207
|
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
220
208
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
221
209
|
// The contract constructor initializes private storage vars that need the contract's own nullifier key.
|
|
@@ -225,48 +213,32 @@ export class BotFactory {
|
|
|
225
213
|
} else {
|
|
226
214
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
227
215
|
}
|
|
228
|
-
|
|
229
|
-
const metadata = await this.wallet.getContractMetadata(address);
|
|
230
|
-
if (metadata.isContractPublished) {
|
|
231
|
-
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
232
|
-
await deploy.register();
|
|
233
|
-
} else {
|
|
234
|
-
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
235
|
-
const { txHash } = await deploy.send({
|
|
236
|
-
...deployOpts,
|
|
237
|
-
wait: NO_WAIT
|
|
238
|
-
});
|
|
239
|
-
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
240
|
-
await this.withNoMinTxsPerBlock(async ()=>{
|
|
241
|
-
await waitForTx(this.aztecNode, txHash, {
|
|
242
|
-
timeout: this.config.txMinedWaitSeconds
|
|
243
|
-
});
|
|
244
|
-
return token;
|
|
245
|
-
});
|
|
246
|
-
}
|
|
216
|
+
await this.registerOrDeployContract('token', deploy, deployOpts);
|
|
247
217
|
return token;
|
|
248
218
|
}
|
|
249
219
|
/**
|
|
250
220
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
251
221
|
* @param wallet - Wallet to deploy the token contract from.
|
|
252
222
|
* @returns The TokenContract instance.
|
|
253
|
-
*/ async setupTokenContract(deployer,
|
|
223
|
+
*/ async setupTokenContract(deployer, salt, name, ticker, decimals = 18) {
|
|
254
224
|
const deployOpts = {
|
|
255
|
-
from: deployer
|
|
256
|
-
contractAddressSalt,
|
|
257
|
-
universalDeploy: true
|
|
225
|
+
from: deployer
|
|
258
226
|
};
|
|
259
|
-
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals
|
|
227
|
+
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals, {
|
|
228
|
+
salt,
|
|
229
|
+
universalDeploy: true
|
|
230
|
+
});
|
|
260
231
|
const instance = await this.registerOrDeployContract('Token - ' + name, deploy, deployOpts);
|
|
261
232
|
return TokenContract.at(instance.address, this.wallet);
|
|
262
233
|
}
|
|
263
|
-
async setupAmmContract(deployer,
|
|
234
|
+
async setupAmmContract(deployer, salt, token0, token1, lpToken) {
|
|
264
235
|
const deployOpts = {
|
|
265
|
-
from: deployer
|
|
266
|
-
contractAddressSalt,
|
|
267
|
-
universalDeploy: true
|
|
236
|
+
from: deployer
|
|
268
237
|
};
|
|
269
|
-
const deploy = AMMContract.deploy(this.wallet, token0.address, token1.address, lpToken.address
|
|
238
|
+
const deploy = AMMContract.deploy(this.wallet, token0.address, token1.address, lpToken.address, {
|
|
239
|
+
salt,
|
|
240
|
+
universalDeploy: true
|
|
241
|
+
});
|
|
270
242
|
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
271
243
|
const amm = AMMContract.at(instance.address, this.wallet);
|
|
272
244
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
@@ -338,31 +310,75 @@ export class BotFactory {
|
|
|
338
310
|
this.log.info(`Updated private balances of ${defaultAccountAddress} after minting and funding AMM: token0=${newT0Bal}, token1=${newT1Bal}, lp=${newLPBal}`);
|
|
339
311
|
}
|
|
340
312
|
async registerOrDeployContract(name, deploy, deployOpts) {
|
|
341
|
-
const instance = await deploy.getInstance(
|
|
313
|
+
const instance = await deploy.getInstance();
|
|
342
314
|
const address = instance.address;
|
|
343
315
|
const metadata = await this.wallet.getContractMetadata(address);
|
|
344
316
|
if (metadata.isContractPublished) {
|
|
345
317
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
346
318
|
await deploy.register();
|
|
347
|
-
|
|
348
|
-
|
|
319
|
+
return instance;
|
|
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
|
+
});
|
|
335
|
+
return instance;
|
|
336
|
+
}
|
|
337
|
+
/** True when the config allows bridging fee juice from L1 (fee_juice mode, an L1 RPC, and an L1 key). */ isL1BridgingConfigured() {
|
|
338
|
+
const mnemonicOrPrivateKey = this.config.l1PrivateKey?.getValue() ?? this.config.l1Mnemonic?.getValue();
|
|
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()) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
let balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
354
|
+
if (balance >= FEE_JUICE_TOP_UP_THRESHOLD) {
|
|
355
|
+
this.log.info(`Fee juice balance ${balance} above threshold ${FEE_JUICE_TOP_UP_THRESHOLD}, skipping top-up`);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
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);
|
|
363
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(account, claim);
|
|
349
364
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
350
|
-
const
|
|
351
|
-
|
|
365
|
+
const executionPayload = await paymentMethod.getExecutionPayload();
|
|
366
|
+
const { txHash } = await this.wallet.sendTx(executionPayload, {
|
|
367
|
+
from: account,
|
|
352
368
|
wait: NO_WAIT
|
|
353
369
|
});
|
|
354
|
-
this.log.info(`Sent
|
|
370
|
+
this.log.info(`Sent fee juice top-up tx ${txHash.toString()}`);
|
|
355
371
|
return waitForTx(this.aztecNode, txHash, {
|
|
356
372
|
timeout: this.config.txMinedWaitSeconds
|
|
357
373
|
});
|
|
358
374
|
});
|
|
375
|
+
await this.store.deleteBridgeClaim(account);
|
|
376
|
+
balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
377
|
+
this.log.info(`Fee juice balance after top-up: ${balance}`);
|
|
359
378
|
}
|
|
360
|
-
|
|
379
|
+
this.log.info(`Fee juice top-up complete for ${account.toString()}`);
|
|
361
380
|
}
|
|
362
|
-
|
|
363
|
-
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
364
|
-
* @param token - Token contract.
|
|
365
|
-
*/ async mintTokens(token, minter) {
|
|
381
|
+
async mintTokens(token, minter) {
|
|
366
382
|
const isStandardToken = isStandardTokenContract(token);
|
|
367
383
|
let privateBalance = 0n;
|
|
368
384
|
let publicBalance = 0n;
|
|
@@ -402,19 +418,18 @@ export class BotFactory {
|
|
|
402
418
|
});
|
|
403
419
|
}
|
|
404
420
|
/**
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
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.
|
|
408
424
|
*/ async getOrCreateBridgeClaim(recipient) {
|
|
409
|
-
// Check if we have an existing claim in the store
|
|
410
425
|
const existingClaim = await this.store.getBridgeClaim(recipient);
|
|
411
426
|
if (existingClaim) {
|
|
412
427
|
this.log.info(`Found existing bridge claim for ${recipient.toString()}, checking validity...`);
|
|
413
|
-
// Check if the message is ready on L2
|
|
414
428
|
try {
|
|
415
429
|
const messageHash = Fr.fromHexString(existingClaim.claim.messageHash);
|
|
416
430
|
await this.withNoMinTxsPerBlock(()=>waitForL1ToL2MessageReady(this.aztecNode, messageHash, {
|
|
417
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
431
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
432
|
+
chainTip: this.syncChainTip
|
|
418
433
|
}));
|
|
419
434
|
return existingClaim.claim;
|
|
420
435
|
} catch (err) {
|
|
@@ -442,7 +457,8 @@ export class BotFactory {
|
|
|
442
457
|
const mintAmount = await portal.getTokenManager().getMintAmount();
|
|
443
458
|
const claim = await portal.bridgeTokensPublic(recipient, mintAmount, true);
|
|
444
459
|
await this.withNoMinTxsPerBlock(()=>waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(claim.messageHash), {
|
|
445
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
460
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
461
|
+
chainTip: this.syncChainTip
|
|
446
462
|
}));
|
|
447
463
|
this.log.info(`Created a claim for ${mintAmount} L1 fee juice to ${recipient}.`, claim);
|
|
448
464
|
return claim;
|
package/dest/interface.d.ts
CHANGED
|
@@ -4,11 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
import { type BotConfig } from './config.js';
|
|
5
5
|
export declare const BotInfoSchema: z.ZodObject<{
|
|
6
6
|
botAddress: import("@aztec/stdlib/schemas").ZodFor<AztecAddress>;
|
|
7
|
-
},
|
|
8
|
-
botAddress: AztecAddress;
|
|
9
|
-
}, {
|
|
10
|
-
botAddress?: any;
|
|
11
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
12
8
|
export type BotInfo = z.infer<typeof BotInfoSchema>;
|
|
13
9
|
export interface BotRunnerApi {
|
|
14
10
|
start(): Promise<void>;
|
|
@@ -20,4 +16,4 @@ export interface BotRunnerApi {
|
|
|
20
16
|
update(config: BotConfig): Promise<void>;
|
|
21
17
|
}
|
|
22
18
|
export declare const BotRunnerApiSchema: ApiSchemaFor<BotRunnerApi>;
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW50ZXJmYWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUUxRCxPQUFPLEVBQUUsQ0FBQyxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBRXhCLE9BQU8sRUFBRSxLQUFLLFNBQVMsRUFBbUIsTUFBTSxhQUFhLENBQUM7QUFFOUQsZUFBTyxNQUFNLGFBQWE7O2lCQUV4QixDQUFDO0FBRUgsTUFBTSxNQUFNLE9BQU8sR0FBRyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sYUFBYSxDQUFDLENBQUM7QUFFcEQsTUFBTSxXQUFXLFlBQVk7SUFDM0IsS0FBSyxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUN2QixJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3RCLEdBQUcsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDckIsS0FBSyxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUN2QixTQUFTLElBQUksT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBQ2hDLE9BQU8sSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7SUFDNUIsTUFBTSxDQUFDLE1BQU0sRUFBRSxTQUFTLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0NBQzFDO0FBRUQsZUFBTyxNQUFNLGtCQUFrQixFQUFFLFlBQVksQ0FBQyxZQUFZLENBUXpELENBQUMifQ==
|
package/dest/interface.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,aAAa,CAAC;AAE9D,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,aAAa,CAAC;AAE9D,eAAO,MAAM,aAAa;;iBAExB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,MAAM,WAAW,YAAY;IAC3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,YAAY,CAQzD,CAAC"}
|
package/dest/interface.js
CHANGED
|
@@ -5,11 +5,34 @@ export const BotInfoSchema = z.object({
|
|
|
5
5
|
botAddress: AztecAddress.schema
|
|
6
6
|
});
|
|
7
7
|
export const BotRunnerApiSchema = {
|
|
8
|
-
start: z.function(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
start: z.function({
|
|
9
|
+
input: z.tuple([]),
|
|
10
|
+
output: z.void()
|
|
11
|
+
}),
|
|
12
|
+
stop: z.function({
|
|
13
|
+
input: z.tuple([]),
|
|
14
|
+
output: z.void()
|
|
15
|
+
}),
|
|
16
|
+
run: z.function({
|
|
17
|
+
input: z.tuple([]),
|
|
18
|
+
output: z.void()
|
|
19
|
+
}),
|
|
20
|
+
setup: z.function({
|
|
21
|
+
input: z.tuple([]),
|
|
22
|
+
output: z.void()
|
|
23
|
+
}),
|
|
24
|
+
getInfo: z.function({
|
|
25
|
+
input: z.tuple([]),
|
|
26
|
+
output: BotInfoSchema
|
|
27
|
+
}),
|
|
28
|
+
getConfig: z.function({
|
|
29
|
+
input: z.tuple([]),
|
|
30
|
+
output: BotConfigSchema
|
|
31
|
+
}),
|
|
32
|
+
update: z.function({
|
|
33
|
+
input: z.tuple([
|
|
34
|
+
BotConfigSchema
|
|
35
|
+
]),
|
|
36
|
+
output: z.void()
|
|
37
|
+
})
|
|
15
38
|
};
|
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": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.a4600f49",
|
|
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.a4600f49",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.a4600f49",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.a4600f49",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.a4600f49",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.a4600f49",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.a4600f49",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.a4600f49",
|
|
64
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.a4600f49",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.a4600f49",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.a4600f49",
|
|
67
|
+
"@aztec/protocol-contracts": "0.0.1-commit.a4600f49",
|
|
68
|
+
"@aztec/stdlib": "0.0.1-commit.a4600f49",
|
|
69
|
+
"@aztec/telemetry-client": "0.0.1-commit.a4600f49",
|
|
70
|
+
"@aztec/wallets": "0.0.1-commit.a4600f49",
|
|
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,10 +1,11 @@
|
|
|
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';
|
|
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/base_bot.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
|
2
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';
|