@aztec/bot 0.0.1-commit.cb6bed7c2 → 0.0.1-commit.cbf2c2d5d
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/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +101 -15
- package/package.json +15 -15
- package/src/factory.ts +65 -24
package/dest/factory.d.ts
CHANGED
|
@@ -61,4 +61,4 @@ export declare class BotFactory {
|
|
|
61
61
|
private bridgeL1FeeJuice;
|
|
62
62
|
private withNoMinTxsPerBlock;
|
|
63
63
|
}
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBbUJ6RCxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBSXRFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUMzRCxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUM3RSxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDL0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBR2xFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVqRixPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFekQsT0FBTyxFQUFFLEtBQUssU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AQ,IAAI,OAAO,CAAC;QAC/B,MAAM,EAAE,cAAc,CAAC;QACvB,qBAAqB,EAAE,YAAY,CAAC;QACpC,GAAG,EAAE,WAAW,CAAC;QACjB,MAAM,EAAE,aAAa,CAAC;QACtB,MAAM,EAAE,aAAa,CAAC;QACtB,IAAI,EAAE,SAAS,CAAC;KACjB,CAAC,CAsBD;IAED;;;OAGG;IACU,eAAe,IAAI,OAAO,CAAC;QACtC,MAAM,EAAE,cAAc,CAAC;QACvB,qBAAqB,EAAE,YAAY,CAAC;QACpC,QAAQ,EAAE,YAAY,CAAC;QACvB,IAAI,EAAE,SAAS,CAAC;QAChB,QAAQ,EAAE,wBAAwB,CAAC;QACnC,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC,CA2DD;YAEa,iBAAiB;YAejB,YAAY;YAWZ,0BAA0B;YA8C1B,gBAAgB;YAehB,UAAU;YAuDV,kBAAkB;YAalB,gBAAgB;YA+BhB,OAAO;YA4GP,wBAAwB;YA2BxB,UAAU;YAmDV,sBAAsB;YA2BtB,gBAAgB;YA+BhB,oBAAoB;CAenC"}
|
package/dest/factory.js
CHANGED
|
@@ -17,7 +17,7 @@ import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
|
17
17
|
import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
18
18
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
19
19
|
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
20
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
20
|
+
import { GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
21
21
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
22
22
|
import { SupportedTokenContracts } from './config.js';
|
|
23
23
|
import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
@@ -166,8 +166,17 @@ export class BotFactory {
|
|
|
166
166
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
167
167
|
const deployMethod = await accountManager.getDeployMethod();
|
|
168
168
|
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
169
|
-
const
|
|
170
|
-
|
|
169
|
+
const { estimatedGas } = await deployMethod.simulate({
|
|
170
|
+
from: AztecAddress.ZERO,
|
|
171
|
+
fee: {
|
|
172
|
+
estimateGas: true,
|
|
173
|
+
paymentMethod
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
const gasSettings = GasSettings.from({
|
|
177
|
+
...estimatedGas,
|
|
178
|
+
maxFeesPerGas,
|
|
179
|
+
maxPriorityFeesPerGas: GasFees.empty()
|
|
171
180
|
});
|
|
172
181
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
173
182
|
const { txHash } = await deployMethod.send({
|
|
@@ -178,7 +187,9 @@ export class BotFactory {
|
|
|
178
187
|
},
|
|
179
188
|
wait: NO_WAIT
|
|
180
189
|
});
|
|
181
|
-
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}
|
|
190
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`, {
|
|
191
|
+
gasSettings
|
|
192
|
+
});
|
|
182
193
|
return waitForTx(this.aztecNode, txHash, {
|
|
183
194
|
timeout: this.config.txMinedWaitSeconds
|
|
184
195
|
});
|
|
@@ -237,11 +248,22 @@ export class BotFactory {
|
|
|
237
248
|
await deploy.register();
|
|
238
249
|
} else {
|
|
239
250
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
251
|
+
const { estimatedGas } = await deploy.simulate({
|
|
252
|
+
...deployOpts,
|
|
253
|
+
fee: {
|
|
254
|
+
estimateGas: true
|
|
255
|
+
}
|
|
256
|
+
});
|
|
240
257
|
const { txHash } = await deploy.send({
|
|
241
258
|
...deployOpts,
|
|
259
|
+
fee: {
|
|
260
|
+
gasSettings: estimatedGas
|
|
261
|
+
},
|
|
242
262
|
wait: NO_WAIT
|
|
243
263
|
});
|
|
244
|
-
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}
|
|
264
|
+
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`, {
|
|
265
|
+
estimatedGas
|
|
266
|
+
});
|
|
245
267
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
246
268
|
await waitForTx(this.aztecNode, txHash, {
|
|
247
269
|
timeout: this.config.txMinedWaitSeconds
|
|
@@ -275,13 +297,25 @@ export class BotFactory {
|
|
|
275
297
|
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
276
298
|
const amm = AMMContract.at(instance.address, this.wallet);
|
|
277
299
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
278
|
-
const
|
|
300
|
+
const setMinterInteraction = lpToken.methods.set_minter(amm.address, true);
|
|
301
|
+
const { estimatedGas: setMinterGas } = await setMinterInteraction.simulate({
|
|
279
302
|
from: deployer,
|
|
303
|
+
fee: {
|
|
304
|
+
estimateGas: true
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
const { receipt: minterReceipt } = await setMinterInteraction.send({
|
|
308
|
+
from: deployer,
|
|
309
|
+
fee: {
|
|
310
|
+
gasSettings: setMinterGas
|
|
311
|
+
},
|
|
280
312
|
wait: {
|
|
281
313
|
timeout: this.config.txMinedWaitSeconds
|
|
282
314
|
}
|
|
283
315
|
});
|
|
284
|
-
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}
|
|
316
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`, {
|
|
317
|
+
estimatedGas: setMinterGas
|
|
318
|
+
});
|
|
285
319
|
this.log.info(`Liquidity token initialized`);
|
|
286
320
|
return amm;
|
|
287
321
|
}
|
|
@@ -314,18 +348,44 @@ export class BotFactory {
|
|
|
314
348
|
caller: amm.address,
|
|
315
349
|
call: await token1.methods.transfer_to_public_and_prepare_private_balance_increase(liquidityProvider, amm.address, amount1Max, authwitNonce).getFunctionCall()
|
|
316
350
|
});
|
|
317
|
-
const
|
|
351
|
+
const mintBatch = new BatchCall(this.wallet, [
|
|
318
352
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
319
353
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE)
|
|
320
|
-
])
|
|
354
|
+
]);
|
|
355
|
+
const { estimatedGas: mintGas } = await mintBatch.simulate({
|
|
356
|
+
from: liquidityProvider,
|
|
357
|
+
fee: {
|
|
358
|
+
estimateGas: true
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
const { receipt: mintReceipt } = await mintBatch.send({
|
|
321
362
|
from: liquidityProvider,
|
|
363
|
+
fee: {
|
|
364
|
+
gasSettings: mintGas
|
|
365
|
+
},
|
|
322
366
|
wait: {
|
|
323
367
|
timeout: this.config.txMinedWaitSeconds
|
|
324
368
|
}
|
|
325
369
|
});
|
|
326
|
-
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}
|
|
327
|
-
|
|
370
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`, {
|
|
371
|
+
estimatedGas: mintGas
|
|
372
|
+
});
|
|
373
|
+
const addLiquidityInteraction = amm.methods.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce);
|
|
374
|
+
const { estimatedGas: addLiquidityGas } = await addLiquidityInteraction.simulate({
|
|
328
375
|
from: liquidityProvider,
|
|
376
|
+
fee: {
|
|
377
|
+
estimateGas: true
|
|
378
|
+
},
|
|
379
|
+
authWitnesses: [
|
|
380
|
+
token0Authwit,
|
|
381
|
+
token1Authwit
|
|
382
|
+
]
|
|
383
|
+
});
|
|
384
|
+
const { receipt: addLiquidityReceipt } = await addLiquidityInteraction.send({
|
|
385
|
+
from: liquidityProvider,
|
|
386
|
+
fee: {
|
|
387
|
+
gasSettings: addLiquidityGas
|
|
388
|
+
},
|
|
329
389
|
authWitnesses: [
|
|
330
390
|
token0Authwit,
|
|
331
391
|
token1Authwit
|
|
@@ -334,7 +394,9 @@ export class BotFactory {
|
|
|
334
394
|
timeout: this.config.txMinedWaitSeconds
|
|
335
395
|
}
|
|
336
396
|
});
|
|
337
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}
|
|
397
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`, {
|
|
398
|
+
estimatedGas: addLiquidityGas
|
|
399
|
+
});
|
|
338
400
|
this.log.info(`Liquidity added`);
|
|
339
401
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
340
402
|
this.log.info(`Updated private balances of ${defaultAccountAddress} after minting and funding AMM: token0=${newT0Bal}, token1=${newT1Bal}, lp=${newLPBal}`);
|
|
@@ -347,10 +409,21 @@ export class BotFactory {
|
|
|
347
409
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
348
410
|
await deploy.register();
|
|
349
411
|
} else {
|
|
350
|
-
|
|
412
|
+
const { estimatedGas } = await deploy.simulate({
|
|
413
|
+
...deployOpts,
|
|
414
|
+
fee: {
|
|
415
|
+
estimateGas: true
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
this.log.info(`Deploying contract ${name} at ${address.toString()}`, {
|
|
419
|
+
estimatedGas
|
|
420
|
+
});
|
|
351
421
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
352
422
|
const { txHash } = await deploy.send({
|
|
353
423
|
...deployOpts,
|
|
424
|
+
fee: {
|
|
425
|
+
gasSettings: estimatedGas
|
|
426
|
+
},
|
|
354
427
|
wait: NO_WAIT
|
|
355
428
|
});
|
|
356
429
|
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
@@ -390,13 +463,26 @@ export class BotFactory {
|
|
|
390
463
|
const additionalScopes = isStandardToken ? undefined : [
|
|
391
464
|
token.address
|
|
392
465
|
];
|
|
466
|
+
const mintBatch = new BatchCall(token.wallet, calls);
|
|
467
|
+
const { estimatedGas } = await mintBatch.simulate({
|
|
468
|
+
from: minter,
|
|
469
|
+
fee: {
|
|
470
|
+
estimateGas: true
|
|
471
|
+
},
|
|
472
|
+
additionalScopes
|
|
473
|
+
});
|
|
393
474
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
394
|
-
const { txHash } = await
|
|
475
|
+
const { txHash } = await mintBatch.send({
|
|
395
476
|
from: minter,
|
|
396
477
|
additionalScopes,
|
|
478
|
+
fee: {
|
|
479
|
+
gasSettings: estimatedGas
|
|
480
|
+
},
|
|
397
481
|
wait: NO_WAIT
|
|
398
482
|
});
|
|
399
|
-
this.log.info(`Sent token mint tx with hash ${txHash.toString()}
|
|
483
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`, {
|
|
484
|
+
estimatedGas
|
|
485
|
+
});
|
|
400
486
|
return waitForTx(this.aztecNode, txHash, {
|
|
401
487
|
timeout: this.config.txMinedWaitSeconds
|
|
402
488
|
});
|
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.cbf2c2d5d",
|
|
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": "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.cbf2c2d5d",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.cbf2c2d5d",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.cbf2c2d5d",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.cbf2c2d5d",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.cbf2c2d5d",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.cbf2c2d5d",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.cbf2c2d5d",
|
|
64
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.cbf2c2d5d",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.cbf2c2d5d",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.cbf2c2d5d",
|
|
67
|
+
"@aztec/protocol-contracts": "0.0.1-commit.cbf2c2d5d",
|
|
68
|
+
"@aztec/stdlib": "0.0.1-commit.cbf2c2d5d",
|
|
69
|
+
"@aztec/telemetry-client": "0.0.1-commit.cbf2c2d5d",
|
|
70
|
+
"@aztec/wallets": "0.0.1-commit.cbf2c2d5d",
|
|
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/factory.ts
CHANGED
|
@@ -27,7 +27,7 @@ import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
|
27
27
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
28
28
|
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
29
29
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
30
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
30
|
+
import { GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
31
31
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
32
32
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
33
33
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
@@ -223,7 +223,12 @@ export class BotFactory {
|
|
|
223
223
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
224
224
|
const deployMethod = await accountManager.getDeployMethod();
|
|
225
225
|
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
226
|
-
|
|
226
|
+
|
|
227
|
+
const { estimatedGas } = await deployMethod.simulate({
|
|
228
|
+
from: AztecAddress.ZERO,
|
|
229
|
+
fee: { estimateGas: true, paymentMethod },
|
|
230
|
+
});
|
|
231
|
+
const gasSettings = GasSettings.from({ ...estimatedGas!, maxFeesPerGas, maxPriorityFeesPerGas: GasFees.empty() });
|
|
227
232
|
|
|
228
233
|
await this.withNoMinTxsPerBlock(async () => {
|
|
229
234
|
const { txHash } = await deployMethod.send({
|
|
@@ -231,7 +236,7 @@ export class BotFactory {
|
|
|
231
236
|
fee: { gasSettings, paymentMethod },
|
|
232
237
|
wait: NO_WAIT,
|
|
233
238
|
});
|
|
234
|
-
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}
|
|
239
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`, { gasSettings });
|
|
235
240
|
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
236
241
|
});
|
|
237
242
|
this.log.info(`Account deployed at ${address}`);
|
|
@@ -297,8 +302,9 @@ export class BotFactory {
|
|
|
297
302
|
await deploy.register();
|
|
298
303
|
} else {
|
|
299
304
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
300
|
-
const {
|
|
301
|
-
|
|
305
|
+
const { estimatedGas } = await deploy.simulate({ ...deployOpts, fee: { estimateGas: true } });
|
|
306
|
+
const { txHash } = await deploy.send({ ...deployOpts, fee: { gasSettings: estimatedGas }, wait: NO_WAIT });
|
|
307
|
+
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`, { estimatedGas });
|
|
302
308
|
await this.withNoMinTxsPerBlock(async () => {
|
|
303
309
|
await waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
304
310
|
return token;
|
|
@@ -338,10 +344,19 @@ export class BotFactory {
|
|
|
338
344
|
const amm = AMMContract.at(instance.address, this.wallet);
|
|
339
345
|
|
|
340
346
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
347
|
+
const setMinterInteraction = lpToken.methods.set_minter(amm.address, true);
|
|
348
|
+
const { estimatedGas: setMinterGas } = await setMinterInteraction.simulate({
|
|
349
|
+
from: deployer,
|
|
350
|
+
fee: { estimateGas: true },
|
|
351
|
+
});
|
|
352
|
+
const { receipt: minterReceipt } = await setMinterInteraction.send({
|
|
353
|
+
from: deployer,
|
|
354
|
+
fee: { gasSettings: setMinterGas },
|
|
355
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
356
|
+
});
|
|
357
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`, {
|
|
358
|
+
estimatedGas: setMinterGas,
|
|
359
|
+
});
|
|
345
360
|
this.log.info(`Liquidity token initialized`);
|
|
346
361
|
|
|
347
362
|
return amm;
|
|
@@ -409,22 +424,44 @@ export class BotFactory {
|
|
|
409
424
|
.getFunctionCall(),
|
|
410
425
|
});
|
|
411
426
|
|
|
412
|
-
const
|
|
427
|
+
const mintBatch = new BatchCall(this.wallet, [
|
|
413
428
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
414
429
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
415
|
-
])
|
|
430
|
+
]);
|
|
431
|
+
const { estimatedGas: mintGas } = await mintBatch.simulate({
|
|
432
|
+
from: liquidityProvider,
|
|
433
|
+
fee: { estimateGas: true },
|
|
434
|
+
});
|
|
435
|
+
const { receipt: mintReceipt } = await mintBatch.send({
|
|
436
|
+
from: liquidityProvider,
|
|
437
|
+
fee: { gasSettings: mintGas },
|
|
438
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
439
|
+
});
|
|
416
440
|
|
|
417
|
-
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}
|
|
441
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`, { estimatedGas: mintGas });
|
|
418
442
|
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
443
|
+
const addLiquidityInteraction = amm.methods.add_liquidity(
|
|
444
|
+
amount0Max,
|
|
445
|
+
amount1Max,
|
|
446
|
+
amount0Min,
|
|
447
|
+
amount1Min,
|
|
448
|
+
authwitNonce,
|
|
449
|
+
);
|
|
450
|
+
const { estimatedGas: addLiquidityGas } = await addLiquidityInteraction.simulate({
|
|
451
|
+
from: liquidityProvider,
|
|
452
|
+
fee: { estimateGas: true },
|
|
453
|
+
authWitnesses: [token0Authwit, token1Authwit],
|
|
454
|
+
});
|
|
455
|
+
const { receipt: addLiquidityReceipt } = await addLiquidityInteraction.send({
|
|
456
|
+
from: liquidityProvider,
|
|
457
|
+
fee: { gasSettings: addLiquidityGas },
|
|
458
|
+
authWitnesses: [token0Authwit, token1Authwit],
|
|
459
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
460
|
+
});
|
|
426
461
|
|
|
427
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}
|
|
462
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`, {
|
|
463
|
+
estimatedGas: addLiquidityGas,
|
|
464
|
+
});
|
|
428
465
|
this.log.info(`Liquidity added`);
|
|
429
466
|
|
|
430
467
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
@@ -445,9 +482,10 @@ export class BotFactory {
|
|
|
445
482
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
446
483
|
await deploy.register();
|
|
447
484
|
} else {
|
|
448
|
-
|
|
485
|
+
const { estimatedGas } = await deploy.simulate({ ...deployOpts, fee: { estimateGas: true } });
|
|
486
|
+
this.log.info(`Deploying contract ${name} at ${address.toString()}`, { estimatedGas });
|
|
449
487
|
await this.withNoMinTxsPerBlock(async () => {
|
|
450
|
-
const { txHash } = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
488
|
+
const { txHash } = await deploy.send({ ...deployOpts, fee: { gasSettings: estimatedGas }, wait: NO_WAIT });
|
|
451
489
|
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
452
490
|
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
453
491
|
});
|
|
@@ -491,13 +529,16 @@ export class BotFactory {
|
|
|
491
529
|
|
|
492
530
|
// PrivateToken's mint accesses contract-level private storage vars (admin, total_supply).
|
|
493
531
|
const additionalScopes = isStandardToken ? undefined : [token.address];
|
|
532
|
+
const mintBatch = new BatchCall(token.wallet, calls);
|
|
533
|
+
const { estimatedGas } = await mintBatch.simulate({ from: minter, fee: { estimateGas: true }, additionalScopes });
|
|
494
534
|
await this.withNoMinTxsPerBlock(async () => {
|
|
495
|
-
const { txHash } = await
|
|
535
|
+
const { txHash } = await mintBatch.send({
|
|
496
536
|
from: minter,
|
|
497
537
|
additionalScopes,
|
|
538
|
+
fee: { gasSettings: estimatedGas },
|
|
498
539
|
wait: NO_WAIT,
|
|
499
540
|
});
|
|
500
|
-
this.log.info(`Sent token mint tx with hash ${txHash.toString()}
|
|
541
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`, { estimatedGas });
|
|
501
542
|
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
502
543
|
});
|
|
503
544
|
}
|