@aztec/bot 0.0.1-commit.ef17749e1 → 0.0.1-commit.f103f88
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.js +1 -1
- 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 +1 -5
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -2
- package/dest/cross_chain_bot.js +1 -1
- package/dest/factory.d.ts +6 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +209 -50
- package/package.json +15 -15
- package/src/amm_bot.ts +1 -1
- package/src/base_bot.ts +8 -16
- package/src/bot.ts +1 -4
- package/src/config.ts +4 -4
- package/src/cross_chain_bot.ts +1 -1
- package/src/factory.ts +224 -47
package/dest/amm_bot.js
CHANGED
|
@@ -52,7 +52,7 @@ export class AmmBot extends BaseBot {
|
|
|
52
52
|
swapAuthwit
|
|
53
53
|
]
|
|
54
54
|
});
|
|
55
|
-
const opts =
|
|
55
|
+
const opts = this.getSendMethodOpts();
|
|
56
56
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
57
57
|
this.log.info(`Tx. Balances: ${jsonStringify(balances)}`, {
|
|
58
58
|
...logCtx,
|
package/dest/base_bot.d.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 { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
4
4
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
5
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
@@ -16,6 +16,6 @@ export declare abstract class BaseBot {
|
|
|
16
16
|
run(): Promise<TxReceipt | TxHash>;
|
|
17
17
|
protected abstract createAndSendTx(logCtx: object): Promise<TxHash>;
|
|
18
18
|
protected onTxMined(_receipt: TxReceipt, _logCtx: object): Promise<void>;
|
|
19
|
-
protected getSendMethodOpts(
|
|
19
|
+
protected getSendMethodOpts(): SendInteractionOptions;
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV9ib3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9iYXNlX2JvdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUd4RSxPQUFPLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBWSxNQUFNLG9CQUFvQixDQUFDO0FBRWpFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUU3Qyw4QkFBc0IsT0FBTzthQU9ULElBQUksRUFBRSxTQUFTO2FBQ2YsTUFBTSxFQUFFLGNBQWM7YUFDdEIscUJBQXFCLEVBQUUsWUFBWTtJQUM1QyxNQUFNLEVBQUUsU0FBUztJQVQxQixTQUFTLENBQUMsR0FBRyx1Q0FBdUI7SUFFcEMsU0FBUyxDQUFDLFFBQVEsRUFBRSxNQUFNLENBQUs7SUFDL0IsU0FBUyxDQUFDLFNBQVMsRUFBRSxNQUFNLENBQUs7SUFFaEMsU0FBUyxhQUNTLElBQUksRUFBRSxTQUFTLEVBQ2YsTUFBTSxFQUFFLGNBQWMsRUFDdEIscUJBQXFCLEVBQUUsWUFBWSxFQUM1QyxNQUFNLEVBQUUsU0FBUyxFQUN0QjtJQUVTLEdBQUcsSUFBSSxPQUFPLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxDQXlCOUM7SUFFRCxTQUFTLENBQUMsUUFBUSxDQUFDLGVBQWUsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUVwRSxTQUFTLENBQUMsU0FBUyxDQUFDLFFBQVEsRUFBRSxTQUFTLEVBQUUsT0FBTyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBR3ZFO0lBRUQsU0FBUyxDQUFDLGlCQUFpQixJQUFJLHNCQUFzQixDQWNwRDtDQUNGIn0=
|
package/dest/base_bot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_bot.d.ts","sourceRoot":"","sources":["../src/base_bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"base_bot.d.ts","sourceRoot":"","sources":["../src/base_bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAGxE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAY,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,8BAAsB,OAAO;aAOT,IAAI,EAAE,SAAS;aACf,MAAM,EAAE,cAAc;aACtB,qBAAqB,EAAE,YAAY;IAC5C,MAAM,EAAE,SAAS;IAT1B,SAAS,CAAC,GAAG,uCAAuB;IAEpC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAK;IAC/B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAK;IAEhC,SAAS,aACS,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,cAAc,EACtB,qBAAqB,EAAE,YAAY,EAC5C,MAAM,EAAE,SAAS,EACtB;IAES,GAAG,IAAI,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,CAyB9C;IAED,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpE,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvE;IAED,SAAS,CAAC,iBAAiB,IAAI,sBAAsB,CAcpD;CACF"}
|
package/dest/base_bot.js
CHANGED
|
@@ -48,32 +48,22 @@ export class BaseBot {
|
|
|
48
48
|
// no-op
|
|
49
49
|
return Promise.resolve();
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
getSendMethodOpts() {
|
|
52
52
|
const { l2GasLimit, daGasLimit, minFeePadding } = this.config;
|
|
53
53
|
this.wallet.setMinFeePadding(minFeePadding);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
};
|
|
62
|
-
this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
|
|
63
|
-
} else {
|
|
64
|
-
this.log.verbose(`Estimating gas for transaction`);
|
|
65
|
-
({ estimatedGas: gasSettings } = await interaction.simulate({
|
|
66
|
-
fee: {
|
|
67
|
-
estimateGas: true
|
|
68
|
-
},
|
|
69
|
-
from: this.defaultAccountAddress
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
54
|
+
const gasSettings = l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0 ? {
|
|
55
|
+
gasLimits: Gas.from({
|
|
56
|
+
l2Gas: l2GasLimit,
|
|
57
|
+
daGas: daGasLimit
|
|
58
|
+
})
|
|
59
|
+
} : undefined;
|
|
72
60
|
return {
|
|
73
61
|
from: this.defaultAccountAddress,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
...gasSettings ? {
|
|
63
|
+
fee: {
|
|
64
|
+
gasSettings
|
|
65
|
+
}
|
|
66
|
+
} : {}
|
|
77
67
|
};
|
|
78
68
|
}
|
|
79
69
|
}
|
package/dest/bot.d.ts
CHANGED
|
@@ -25,4 +25,4 @@ export declare class Bot extends BaseBot {
|
|
|
25
25
|
};
|
|
26
26
|
}>;
|
|
27
27
|
}
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTlELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU1QyxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQ2xGLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxjQUFjLEV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in_public(this.defaultAccountAddress, recipient, TRANSFER_AMOUNT, 0))
|
|
31
31
|
].flat() : times(privateTransfersPerTx, ()=>token.methods.transfer(TRANSFER_AMOUNT, this.defaultAccountAddress, recipient));
|
|
32
32
|
const batch = new BatchCall(wallet, calls);
|
|
33
|
-
const opts =
|
|
34
|
-
this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx);
|
|
35
|
-
await batch.simulate({
|
|
36
|
-
from: this.defaultAccountAddress
|
|
37
|
-
});
|
|
33
|
+
const opts = this.getSendMethodOpts();
|
|
38
34
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
39
35
|
const { txHash } = await batch.send({
|
|
40
36
|
...opts,
|
package/dest/config.d.ts
CHANGED
|
@@ -50,9 +50,9 @@ export type BotConfig = {
|
|
|
50
50
|
maxPendingTxs: number;
|
|
51
51
|
/** Whether to flush after sending each 'setup' transaction */
|
|
52
52
|
flushSetupTransactions: boolean;
|
|
53
|
-
/** L2 gas limit for the tx (empty to
|
|
53
|
+
/** L2 gas limit for the tx (empty to let the bot's wallet estimate). */
|
|
54
54
|
l2GasLimit: number | undefined;
|
|
55
|
-
/** DA gas limit for the tx (empty to
|
|
55
|
+
/** DA gas limit for the tx (empty to let the bot's wallet estimate). */
|
|
56
56
|
daGasLimit: number | undefined;
|
|
57
57
|
/** Token contract to use */
|
|
58
58
|
contract: SupportedTokenContracts;
|
|
@@ -223,4 +223,4 @@ export declare function getBotConfigFromEnv(): BotConfig;
|
|
|
223
223
|
export declare function getBotDefaultConfig(): BotConfig;
|
|
224
224
|
export declare function getVersions(): Partial<ComponentsVersions>;
|
|
225
225
|
export {};
|
|
226
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
226
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3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C,eAAe,EAAE,eAAe,GAAG,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8C3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CAmK3D,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,WAAW,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAKzD"}
|
package/dest/config.js
CHANGED
|
@@ -172,12 +172,12 @@ export const botConfigMappings = {
|
|
|
172
172
|
},
|
|
173
173
|
l2GasLimit: {
|
|
174
174
|
env: 'BOT_L2_GAS_LIMIT',
|
|
175
|
-
description:
|
|
175
|
+
description: "L2 gas limit for the tx (empty to let the bot's wallet estimate).",
|
|
176
176
|
...optionalNumberConfigHelper()
|
|
177
177
|
},
|
|
178
178
|
daGasLimit: {
|
|
179
179
|
env: 'BOT_DA_GAS_LIMIT',
|
|
180
|
-
description:
|
|
180
|
+
description: "DA gas limit for the tx (empty to let the bot's wallet estimate).",
|
|
181
181
|
...optionalNumberConfigHelper()
|
|
182
182
|
},
|
|
183
183
|
contract: {
|
package/dest/cross_chain_bot.js
CHANGED
|
@@ -82,7 +82,7 @@ import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
const batch = new BatchCall(this.wallet, calls);
|
|
85
|
-
const opts =
|
|
85
|
+
const opts = this.getSendMethodOpts();
|
|
86
86
|
this.log.verbose(`Sending cross-chain batch with ${calls.length} calls`, logCtx);
|
|
87
87
|
const { txHash } = await batch.send({
|
|
88
88
|
...opts,
|
package/dest/factory.d.ts
CHANGED
|
@@ -51,14 +51,19 @@ export declare class BotFactory {
|
|
|
51
51
|
private setupAccount;
|
|
52
52
|
private setupAccountWithPrivateKey;
|
|
53
53
|
private setupTestAccount;
|
|
54
|
+
private setupTokenWithOptionalEarlyRefuel;
|
|
55
|
+
private setupTokenContractWithOptionalEarlyRefuel;
|
|
56
|
+
private getTokenInstance;
|
|
54
57
|
private setupToken;
|
|
55
58
|
private setupTokenContract;
|
|
56
59
|
private setupAmmContract;
|
|
57
60
|
private fundAmm;
|
|
58
61
|
private registerOrDeployContract;
|
|
62
|
+
private ensureFeeJuiceBalance;
|
|
59
63
|
private mintTokens;
|
|
60
64
|
private getOrCreateBridgeClaim;
|
|
61
65
|
private bridgeL1FeeJuice;
|
|
66
|
+
private getMinFees;
|
|
62
67
|
private withNoMinTxsPerBlock;
|
|
63
68
|
}
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
69
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBcUJ6RCxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBSXRFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUMzRCxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUM3RSxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDL0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBR2xFLE9BQU8sS0FBSyxFQUFFLFNBQV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FFLFdBQVcsQ0FBQztRQUNqQixNQUFNLEVBQUUsYUFBYSxDQUFDO1FBQ3RCLE1BQU0sRUFBRSxhQUFhLENBQUM7UUFDdEIsSUFBSSxFQUFFLFNBQVMsQ0FBQztLQUNqQixDQUFDLENBNEJEO0lBRUQ7OztPQUdHO0lBQ1UsZUFBZSxJQUFJLE9BQU8sQ0FBQztRQUN0QyxNQUFNLEVBQUUsY0FBYyxDQUFDO1FBQ3ZCLHFCQUFxQixFQUFFLFlBQVksQ0FBQztRQUNwQyxRQUFRLEVBQUUsWUFBWSxDQUFDO1FBQ3ZCLElBQUksRUFBRSxTQUFTLENBQUM7UUFDaEIsUUFBUSxFQUFFLHdCQUF3QixDQUFDO1FBQ25DLGFBQWEsRUFBRSxNQUFNLENBQUM7S0FDdkIsQ0FBQyxDQTJERDtZQUVhLGlCQUFpQjtZQWVqQixZQUFZO1lBV1osMEJBQTBCO1lBdUMxQixnQkFBZ0I7WUFlaEIsaUNBQWlDO1lBY2pDLHlDQUF5QztZQW1CekMsZ0JBQWdCO1lBaUNoQixVQUFVO1lBd0NWLGtCQUFrQjtZQWFsQixnQkFBZ0I7WUF3QmhCLE9BQU87WUErRlAsd0JBQXdCO1lBNkR4QixxQkFBcUI7WUF1RHJCLFVBQVU7WUFpRFYsc0JBQXNCO1lBMkJ0QixnQkFBZ0I7WUFnQ2hCLFVBQVU7WUFZVixvQkFBb0I7Q0FlbkMifQ==
|
package/dest/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAqBzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAItE,OAAO,EAAE,WAAW,EAAE,MAAM,8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AC;KACjB,CAAC,CA4BD;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;YAuC1B,gBAAgB;YAehB,iCAAiC;YAcjC,yCAAyC;YAmBzC,gBAAgB;YAiChB,UAAU;YAwCV,kBAAkB;YAalB,gBAAgB;YAwBhB,OAAO;YA+FP,wBAAwB;YA6DxB,qBAAqB;YAuDrB,UAAU;YAiDV,sBAAsB;YA2BtB,gBAAgB;YAgChB,UAAU;YAYV,oBAAoB;CAenC"}
|
package/dest/factory.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
-
import {
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
3
3
|
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
5
5
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
@@ -7,6 +7,8 @@ import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
|
7
7
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
8
8
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
9
9
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
10
|
+
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
11
|
+
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
10
12
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
11
13
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
12
14
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
@@ -17,13 +19,15 @@ import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
|
17
19
|
import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
18
20
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
19
21
|
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
20
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
22
|
+
import { GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
21
23
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
22
24
|
import { SupportedTokenContracts } from './config.js';
|
|
23
25
|
import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
24
26
|
import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils.js';
|
|
25
27
|
const MINT_BALANCE = 1e12;
|
|
26
28
|
const MIN_BALANCE = 1e3;
|
|
29
|
+
const FEE_JUICE_TOP_UP_THRESHOLD = 100n * 10n ** 18n;
|
|
30
|
+
const FEE_JUICE_TOP_UP_TARGET = 10_000n * 10n ** 18n;
|
|
27
31
|
export class BotFactory {
|
|
28
32
|
config;
|
|
29
33
|
wallet;
|
|
@@ -48,7 +52,8 @@ export class BotFactory {
|
|
|
48
52
|
*/ async setup() {
|
|
49
53
|
const defaultAccountAddress = await this.setupAccount();
|
|
50
54
|
const recipient = (await this.wallet.createSchnorrAccount(Fr.random(), Fr.random())).address;
|
|
51
|
-
const token = await this.
|
|
55
|
+
const token = await this.setupTokenWithOptionalEarlyRefuel(defaultAccountAddress);
|
|
56
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress, token);
|
|
52
57
|
await this.mintTokens(token, defaultAccountAddress);
|
|
53
58
|
return {
|
|
54
59
|
wallet: this.wallet,
|
|
@@ -60,7 +65,8 @@ export class BotFactory {
|
|
|
60
65
|
}
|
|
61
66
|
async setupAmm() {
|
|
62
67
|
const defaultAccountAddress = await this.setupAccount();
|
|
63
|
-
const token0 = await this.
|
|
68
|
+
const token0 = await this.setupTokenContractWithOptionalEarlyRefuel(defaultAccountAddress, this.config.tokenSalt, 'BotToken0', 'BOT0');
|
|
69
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress, token0);
|
|
64
70
|
const token1 = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotToken1', 'BOT1');
|
|
65
71
|
const liquidityToken = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotLPToken', 'BOTLP');
|
|
66
72
|
const amm = await this.setupAmmContract(defaultAccountAddress, this.config.tokenSalt, token0, token1, liquidityToken);
|
|
@@ -152,7 +158,7 @@ export class BotFactory {
|
|
|
152
158
|
const signingKey = deriveSigningKey(secret);
|
|
153
159
|
const accountManager = await this.wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
154
160
|
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
155
|
-
if (metadata.
|
|
161
|
+
if (metadata.initializationStatus === ContractInitializationStatus.INITIALIZED) {
|
|
156
162
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
157
163
|
const timer = new Timer();
|
|
158
164
|
const address = accountManager.address;
|
|
@@ -165,15 +171,10 @@ export class BotFactory {
|
|
|
165
171
|
const claim = await this.getOrCreateBridgeClaim(address);
|
|
166
172
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
167
173
|
const deployMethod = await accountManager.getDeployMethod();
|
|
168
|
-
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
169
|
-
const gasSettings = GasSettings.default({
|
|
170
|
-
maxFeesPerGas
|
|
171
|
-
});
|
|
172
174
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
173
175
|
const { txHash } = await deployMethod.send({
|
|
174
|
-
from:
|
|
176
|
+
from: NO_FROM,
|
|
175
177
|
fee: {
|
|
176
|
-
gasSettings,
|
|
177
178
|
paymentMethod
|
|
178
179
|
},
|
|
179
180
|
wait: NO_WAIT
|
|
@@ -195,12 +196,70 @@ export class BotFactory {
|
|
|
195
196
|
return accountManager.address;
|
|
196
197
|
}
|
|
197
198
|
/**
|
|
199
|
+
* Setup token and refuel first: if the token already exists (restart scenario),
|
|
200
|
+
* run ensureFeeJuiceBalance before any step that might need fee juice. When deploying,
|
|
201
|
+
* use a bridge claim if balance is below threshold.
|
|
202
|
+
*/ async setupTokenWithOptionalEarlyRefuel(sender) {
|
|
203
|
+
const token = await this.getTokenInstance(sender);
|
|
204
|
+
const address = token.address;
|
|
205
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
206
|
+
if (metadata.isContractPublished) {
|
|
207
|
+
this.log.info(`Token at ${address.toString()} already deployed, refueling before setup`);
|
|
208
|
+
await this.ensureFeeJuiceBalance(sender, token);
|
|
209
|
+
}
|
|
210
|
+
return this.setupToken(sender);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Setup token0 for AMM with refuel-first behaviour when token already exists.
|
|
214
|
+
*/ async setupTokenContractWithOptionalEarlyRefuel(deployer, contractAddressSalt, name, ticker, decimals = 18) {
|
|
215
|
+
const deployOpts = {
|
|
216
|
+
from: deployer,
|
|
217
|
+
contractAddressSalt,
|
|
218
|
+
universalDeploy: true
|
|
219
|
+
};
|
|
220
|
+
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals);
|
|
221
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
222
|
+
const metadata = await this.wallet.getContractMetadata(instance.address);
|
|
223
|
+
if (metadata.isContractPublished) {
|
|
224
|
+
this.log.info(`Token ${name} at ${instance.address.toString()} already deployed, refueling before setup`);
|
|
225
|
+
const token = TokenContract.at(instance.address, this.wallet);
|
|
226
|
+
await this.ensureFeeJuiceBalance(deployer, token);
|
|
227
|
+
}
|
|
228
|
+
return this.setupTokenContract(deployer, contractAddressSalt, name, ticker, decimals);
|
|
229
|
+
}
|
|
230
|
+
async getTokenInstance(sender) {
|
|
231
|
+
const deployOpts = {
|
|
232
|
+
from: sender,
|
|
233
|
+
contractAddressSalt: this.config.tokenSalt,
|
|
234
|
+
universalDeploy: true
|
|
235
|
+
};
|
|
236
|
+
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
237
|
+
const deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
238
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
239
|
+
return TokenContract.at(instance.address, this.wallet);
|
|
240
|
+
}
|
|
241
|
+
if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
242
|
+
const tokenSecretKey = Fr.random();
|
|
243
|
+
const tokenPublicKeys = (await deriveKeys(tokenSecretKey)).publicKeys;
|
|
244
|
+
const deploy = PrivateTokenContract.deployWithPublicKeys(tokenPublicKeys, this.wallet, MINT_BALANCE, sender);
|
|
245
|
+
const instance = await deploy.getInstance({
|
|
246
|
+
...deployOpts,
|
|
247
|
+
skipInstancePublication: true,
|
|
248
|
+
skipClassPublication: true,
|
|
249
|
+
skipInitialization: false
|
|
250
|
+
});
|
|
251
|
+
return PrivateTokenContract.at(instance.address, this.wallet);
|
|
252
|
+
}
|
|
253
|
+
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
198
256
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
199
|
-
*
|
|
200
|
-
* @
|
|
257
|
+
* Uses a bridge claim for deploy when balance is below threshold to avoid failing before refuel.
|
|
258
|
+
* @param sender - Aztec address to deploy the token contract from.
|
|
259
|
+
* @param existingToken - Optional token instance when called from setupTokenWithOptionalEarlyRefuel.
|
|
260
|
+
* @returns The TokenContract or PrivateTokenContract instance.
|
|
201
261
|
*/ async setupToken(sender) {
|
|
202
262
|
let deploy;
|
|
203
|
-
let tokenInstance;
|
|
204
263
|
const deployOpts = {
|
|
205
264
|
from: sender,
|
|
206
265
|
contractAddressSalt: this.config.tokenSalt,
|
|
@@ -209,8 +268,8 @@ export class BotFactory {
|
|
|
209
268
|
let token;
|
|
210
269
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
211
270
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
212
|
-
|
|
213
|
-
token = TokenContract.at(
|
|
271
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
272
|
+
token = TokenContract.at(instance.address, this.wallet);
|
|
214
273
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
215
274
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
216
275
|
const tokenSecretKey = Fr.random();
|
|
@@ -220,7 +279,7 @@ export class BotFactory {
|
|
|
220
279
|
deployOpts.skipClassPublication = true;
|
|
221
280
|
deployOpts.skipInitialization = false;
|
|
222
281
|
// Register the contract with the secret key before deployment
|
|
223
|
-
tokenInstance = await deploy.getInstance(deployOpts);
|
|
282
|
+
const tokenInstance = await deploy.getInstance(deployOpts);
|
|
224
283
|
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
225
284
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
226
285
|
// The contract constructor initializes private storage vars that need the contract's own nullifier key.
|
|
@@ -230,25 +289,7 @@ export class BotFactory {
|
|
|
230
289
|
} else {
|
|
231
290
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
232
291
|
}
|
|
233
|
-
|
|
234
|
-
const metadata = await this.wallet.getContractMetadata(address);
|
|
235
|
-
if (metadata.isContractPublished) {
|
|
236
|
-
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
237
|
-
await deploy.register();
|
|
238
|
-
} else {
|
|
239
|
-
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
240
|
-
const { txHash } = await deploy.send({
|
|
241
|
-
...deployOpts,
|
|
242
|
-
wait: NO_WAIT
|
|
243
|
-
});
|
|
244
|
-
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
245
|
-
await this.withNoMinTxsPerBlock(async ()=>{
|
|
246
|
-
await waitForTx(this.aztecNode, txHash, {
|
|
247
|
-
timeout: this.config.txMinedWaitSeconds
|
|
248
|
-
});
|
|
249
|
-
return token;
|
|
250
|
-
});
|
|
251
|
-
}
|
|
292
|
+
await this.registerOrDeployContract('token', deploy, deployOpts);
|
|
252
293
|
return token;
|
|
253
294
|
}
|
|
254
295
|
/**
|
|
@@ -275,7 +316,8 @@ export class BotFactory {
|
|
|
275
316
|
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
276
317
|
const amm = AMMContract.at(instance.address, this.wallet);
|
|
277
318
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
278
|
-
const
|
|
319
|
+
const setMinterInteraction = lpToken.methods.set_minter(amm.address, true);
|
|
320
|
+
const { receipt: minterReceipt } = await setMinterInteraction.send({
|
|
279
321
|
from: deployer,
|
|
280
322
|
wait: {
|
|
281
323
|
timeout: this.config.txMinedWaitSeconds
|
|
@@ -314,17 +356,19 @@ export class BotFactory {
|
|
|
314
356
|
caller: amm.address,
|
|
315
357
|
call: await token1.methods.transfer_to_public_and_prepare_private_balance_increase(liquidityProvider, amm.address, amount1Max, authwitNonce).getFunctionCall()
|
|
316
358
|
});
|
|
317
|
-
const
|
|
359
|
+
const mintBatch = new BatchCall(this.wallet, [
|
|
318
360
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
319
361
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE)
|
|
320
|
-
])
|
|
362
|
+
]);
|
|
363
|
+
const { receipt: mintReceipt } = await mintBatch.send({
|
|
321
364
|
from: liquidityProvider,
|
|
322
365
|
wait: {
|
|
323
366
|
timeout: this.config.txMinedWaitSeconds
|
|
324
367
|
}
|
|
325
368
|
});
|
|
326
369
|
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
327
|
-
const
|
|
370
|
+
const addLiquidityInteraction = amm.methods.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce);
|
|
371
|
+
const { receipt: addLiquidityReceipt } = await addLiquidityInteraction.send({
|
|
328
372
|
from: liquidityProvider,
|
|
329
373
|
authWitnesses: [
|
|
330
374
|
token0Authwit,
|
|
@@ -347,24 +391,127 @@ export class BotFactory {
|
|
|
347
391
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
348
392
|
await deploy.register();
|
|
349
393
|
} else {
|
|
350
|
-
|
|
351
|
-
await this.
|
|
352
|
-
|
|
394
|
+
const sender = deployOpts.from === NO_FROM ? undefined : deployOpts.from;
|
|
395
|
+
const balance = sender ? await getFeeJuiceBalance(sender, this.aztecNode) : 0n;
|
|
396
|
+
const useClaim = sender && balance < FEE_JUICE_TOP_UP_THRESHOLD && this.config.feePaymentMethod === 'fee_juice' && !!this.config.l1RpcUrls?.length;
|
|
397
|
+
const mnemonicOrPrivateKey = this.config.l1PrivateKey?.getValue() ?? this.config.l1Mnemonic?.getValue();
|
|
398
|
+
if (useClaim && mnemonicOrPrivateKey) {
|
|
399
|
+
const claim = await this.getOrCreateBridgeClaim(sender);
|
|
400
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(sender, claim);
|
|
401
|
+
const { estimatedGas } = await deploy.simulate({
|
|
353
402
|
...deployOpts,
|
|
354
|
-
|
|
403
|
+
fee: {
|
|
404
|
+
estimateGas: true,
|
|
405
|
+
paymentMethod
|
|
406
|
+
}
|
|
355
407
|
});
|
|
356
|
-
this.
|
|
357
|
-
|
|
358
|
-
|
|
408
|
+
const maxFeesPerGas = (await this.getMinFees()).mul(1 + this.config.minFeePadding);
|
|
409
|
+
const gasSettings = GasSettings.from({
|
|
410
|
+
...estimatedGas,
|
|
411
|
+
maxFeesPerGas,
|
|
412
|
+
maxPriorityFeesPerGas: GasFees.empty()
|
|
359
413
|
});
|
|
360
|
-
|
|
414
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
415
|
+
const { txHash } = await deploy.send({
|
|
416
|
+
...deployOpts,
|
|
417
|
+
fee: {
|
|
418
|
+
gasSettings,
|
|
419
|
+
paymentMethod
|
|
420
|
+
},
|
|
421
|
+
wait: NO_WAIT
|
|
422
|
+
});
|
|
423
|
+
this.log.info(`Sent contract ${name} deploy tx ${txHash.toString()} (using bridge claim, balance was ${balance})`);
|
|
424
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
425
|
+
timeout: this.config.txMinedWaitSeconds
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
await this.store.deleteBridgeClaim(sender);
|
|
429
|
+
} else {
|
|
430
|
+
const { estimatedGas } = await deploy.simulate({
|
|
431
|
+
...deployOpts,
|
|
432
|
+
fee: {
|
|
433
|
+
estimateGas: true
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
this.log.info(`Deploying contract ${name} at ${address.toString()}`, {
|
|
437
|
+
estimatedGas
|
|
438
|
+
});
|
|
439
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
440
|
+
const { txHash } = await deploy.send({
|
|
441
|
+
...deployOpts,
|
|
442
|
+
fee: {
|
|
443
|
+
gasSettings: estimatedGas
|
|
444
|
+
},
|
|
445
|
+
wait: NO_WAIT
|
|
446
|
+
});
|
|
447
|
+
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
448
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
449
|
+
timeout: this.config.txMinedWaitSeconds
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
}
|
|
361
453
|
}
|
|
362
454
|
return instance;
|
|
363
455
|
}
|
|
364
456
|
/**
|
|
365
457
|
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
366
458
|
* @param token - Token contract.
|
|
367
|
-
*/
|
|
459
|
+
*/ /**
|
|
460
|
+
* Ensures the account has sufficient fee juice by bridging from L1 if balance is below threshold.
|
|
461
|
+
* Bridges repeatedly until balance reaches the target (10k FJ).
|
|
462
|
+
* Used on startup/restart to top up when the account has run out after previous runs.
|
|
463
|
+
*/ async ensureFeeJuiceBalance(account, token) {
|
|
464
|
+
const { feePaymentMethod, l1RpcUrls } = this.config;
|
|
465
|
+
if (feePaymentMethod !== 'fee_juice' || !l1RpcUrls?.length) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const mnemonicOrPrivateKey = this.config.l1PrivateKey?.getValue() ?? this.config.l1Mnemonic?.getValue();
|
|
469
|
+
if (!mnemonicOrPrivateKey) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
let balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
473
|
+
if (balance >= FEE_JUICE_TOP_UP_THRESHOLD) {
|
|
474
|
+
this.log.info(`Fee juice balance ${balance} above threshold ${FEE_JUICE_TOP_UP_THRESHOLD}, skipping top-up`);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
this.log.info(`Fee juice balance ${balance} below threshold ${FEE_JUICE_TOP_UP_THRESHOLD}, bridging from L1 until ${FEE_JUICE_TOP_UP_TARGET}`);
|
|
478
|
+
const maxFeesPerGas = (await this.getMinFees()).mul(1 + this.config.minFeePadding);
|
|
479
|
+
const minimalInteraction = isStandardTokenContract(token) ? token.methods.transfer_in_public(account, account, 0n, 0) : token.methods.transfer(0n, account, account);
|
|
480
|
+
while(balance < FEE_JUICE_TOP_UP_TARGET){
|
|
481
|
+
const claim = await this.bridgeL1FeeJuice(account);
|
|
482
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(account, claim);
|
|
483
|
+
const { estimatedGas } = await minimalInteraction.simulate({
|
|
484
|
+
from: account,
|
|
485
|
+
fee: {
|
|
486
|
+
estimateGas: true,
|
|
487
|
+
paymentMethod
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
const gasSettings = GasSettings.from({
|
|
491
|
+
...estimatedGas,
|
|
492
|
+
maxFeesPerGas,
|
|
493
|
+
maxPriorityFeesPerGas: GasFees.empty()
|
|
494
|
+
});
|
|
495
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
496
|
+
const { txHash } = await minimalInteraction.send({
|
|
497
|
+
from: account,
|
|
498
|
+
fee: {
|
|
499
|
+
gasSettings,
|
|
500
|
+
paymentMethod
|
|
501
|
+
},
|
|
502
|
+
wait: NO_WAIT
|
|
503
|
+
});
|
|
504
|
+
this.log.info(`Sent fee juice top-up tx ${txHash.toString()}`);
|
|
505
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
506
|
+
timeout: this.config.txMinedWaitSeconds
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
510
|
+
this.log.info(`Fee juice balance after top-up: ${balance}`);
|
|
511
|
+
}
|
|
512
|
+
this.log.info(`Fee juice top-up complete for ${account.toString()}`);
|
|
513
|
+
}
|
|
514
|
+
async mintTokens(token, minter) {
|
|
368
515
|
const isStandardToken = isStandardTokenContract(token);
|
|
369
516
|
let privateBalance = 0n;
|
|
370
517
|
let publicBalance = 0n;
|
|
@@ -390,8 +537,9 @@ export class BotFactory {
|
|
|
390
537
|
const additionalScopes = isStandardToken ? undefined : [
|
|
391
538
|
token.address
|
|
392
539
|
];
|
|
540
|
+
const mintBatch = new BatchCall(token.wallet, calls);
|
|
393
541
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
394
|
-
const { txHash } = await
|
|
542
|
+
const { txHash } = await mintBatch.send({
|
|
395
543
|
from: minter,
|
|
396
544
|
additionalScopes,
|
|
397
545
|
wait: NO_WAIT
|
|
@@ -448,6 +596,17 @@ export class BotFactory {
|
|
|
448
596
|
this.log.info(`Created a claim for ${mintAmount} L1 fee juice to ${recipient}.`, claim);
|
|
449
597
|
return claim;
|
|
450
598
|
}
|
|
599
|
+
/** Returns worst-case min fees across predicted slots, with fallback to current min fees. */ async getMinFees() {
|
|
600
|
+
try {
|
|
601
|
+
const predicted = await this.aztecNode.getPredictedMinFees(ManaUsageEstimate.Limit);
|
|
602
|
+
if (predicted.length === 0) {
|
|
603
|
+
return this.aztecNode.getCurrentMinFees();
|
|
604
|
+
}
|
|
605
|
+
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
606
|
+
} catch {
|
|
607
|
+
return this.aztecNode.getCurrentMinFees();
|
|
608
|
+
}
|
|
609
|
+
}
|
|
451
610
|
async withNoMinTxsPerBlock(fn) {
|
|
452
611
|
if (!this.aztecNodeAdmin || !this.config.flushSetupTransactions) {
|
|
453
612
|
this.log.verbose(`No node admin client or flushing not requested (not setting minTxsPerBlock to 0)`);
|
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.f103f88",
|
|
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.f103f88",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.f103f88",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.f103f88",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.f103f88",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.f103f88",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.f103f88",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.f103f88",
|
|
64
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.f103f88",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.f103f88",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.f103f88",
|
|
67
|
+
"@aztec/protocol-contracts": "0.0.1-commit.f103f88",
|
|
68
|
+
"@aztec/stdlib": "0.0.1-commit.f103f88",
|
|
69
|
+
"@aztec/telemetry-client": "0.0.1-commit.f103f88",
|
|
70
|
+
"@aztec/wallets": "0.0.1-commit.f103f88",
|
|
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/amm_bot.ts
CHANGED
|
@@ -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,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,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
|
@@ -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 });
|
package/src/factory.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
3
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
4
|
import {
|
|
4
5
|
BatchCall,
|
|
@@ -15,6 +16,8 @@ import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
|
15
16
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
16
17
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
17
18
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
19
|
+
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
20
|
+
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
18
21
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
19
22
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
20
23
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
@@ -27,7 +30,7 @@ import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
|
27
30
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
28
31
|
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
29
32
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
30
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
33
|
+
import { GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
31
34
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
32
35
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
33
36
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
@@ -39,6 +42,8 @@ import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils
|
|
|
39
42
|
|
|
40
43
|
const MINT_BALANCE = 1e12;
|
|
41
44
|
const MIN_BALANCE = 1e3;
|
|
45
|
+
const FEE_JUICE_TOP_UP_THRESHOLD = 100n * 10n ** 18n;
|
|
46
|
+
const FEE_JUICE_TOP_UP_TARGET = 10_000n * 10n ** 18n;
|
|
42
47
|
|
|
43
48
|
export class BotFactory {
|
|
44
49
|
private log = createLogger('bot');
|
|
@@ -68,7 +73,8 @@ export class BotFactory {
|
|
|
68
73
|
}> {
|
|
69
74
|
const defaultAccountAddress = await this.setupAccount();
|
|
70
75
|
const recipient = (await this.wallet.createSchnorrAccount(Fr.random(), Fr.random())).address;
|
|
71
|
-
const token = await this.
|
|
76
|
+
const token = await this.setupTokenWithOptionalEarlyRefuel(defaultAccountAddress);
|
|
77
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress, token);
|
|
72
78
|
await this.mintTokens(token, defaultAccountAddress);
|
|
73
79
|
return { wallet: this.wallet, defaultAccountAddress, token, node: this.aztecNode, recipient };
|
|
74
80
|
}
|
|
@@ -82,7 +88,13 @@ export class BotFactory {
|
|
|
82
88
|
node: AztecNode;
|
|
83
89
|
}> {
|
|
84
90
|
const defaultAccountAddress = await this.setupAccount();
|
|
85
|
-
const token0 = await this.
|
|
91
|
+
const token0 = await this.setupTokenContractWithOptionalEarlyRefuel(
|
|
92
|
+
defaultAccountAddress,
|
|
93
|
+
this.config.tokenSalt,
|
|
94
|
+
'BotToken0',
|
|
95
|
+
'BOT0',
|
|
96
|
+
);
|
|
97
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress, token0);
|
|
86
98
|
const token1 = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotToken1', 'BOT1');
|
|
87
99
|
const liquidityToken = await this.setupTokenContract(
|
|
88
100
|
defaultAccountAddress,
|
|
@@ -207,7 +219,7 @@ export class BotFactory {
|
|
|
207
219
|
const signingKey = deriveSigningKey(secret);
|
|
208
220
|
const accountManager = await this.wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
209
221
|
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
210
|
-
if (metadata.
|
|
222
|
+
if (metadata.initializationStatus === ContractInitializationStatus.INITIALIZED) {
|
|
211
223
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
212
224
|
const timer = new Timer();
|
|
213
225
|
const address = accountManager.address;
|
|
@@ -222,13 +234,11 @@ export class BotFactory {
|
|
|
222
234
|
|
|
223
235
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
224
236
|
const deployMethod = await accountManager.getDeployMethod();
|
|
225
|
-
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
226
|
-
const gasSettings = GasSettings.default({ maxFeesPerGas });
|
|
227
237
|
|
|
228
238
|
await this.withNoMinTxsPerBlock(async () => {
|
|
229
239
|
const { txHash } = await deployMethod.send({
|
|
230
|
-
from:
|
|
231
|
-
fee: {
|
|
240
|
+
from: NO_FROM,
|
|
241
|
+
fee: { paymentMethod },
|
|
232
242
|
wait: NO_WAIT,
|
|
233
243
|
});
|
|
234
244
|
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
@@ -253,14 +263,79 @@ export class BotFactory {
|
|
|
253
263
|
return accountManager.address;
|
|
254
264
|
}
|
|
255
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Setup token and refuel first: if the token already exists (restart scenario),
|
|
268
|
+
* run ensureFeeJuiceBalance before any step that might need fee juice. When deploying,
|
|
269
|
+
* use a bridge claim if balance is below threshold.
|
|
270
|
+
*/
|
|
271
|
+
private async setupTokenWithOptionalEarlyRefuel(sender: AztecAddress): Promise<TokenContract | PrivateTokenContract> {
|
|
272
|
+
const token = await this.getTokenInstance(sender);
|
|
273
|
+
const address = token.address;
|
|
274
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
275
|
+
if (metadata.isContractPublished) {
|
|
276
|
+
this.log.info(`Token at ${address.toString()} already deployed, refueling before setup`);
|
|
277
|
+
await this.ensureFeeJuiceBalance(sender, token);
|
|
278
|
+
}
|
|
279
|
+
return this.setupToken(sender);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Setup token0 for AMM with refuel-first behaviour when token already exists.
|
|
284
|
+
*/
|
|
285
|
+
private async setupTokenContractWithOptionalEarlyRefuel(
|
|
286
|
+
deployer: AztecAddress,
|
|
287
|
+
contractAddressSalt: Fr,
|
|
288
|
+
name: string,
|
|
289
|
+
ticker: string,
|
|
290
|
+
decimals = 18,
|
|
291
|
+
): Promise<TokenContract> {
|
|
292
|
+
const deployOpts: DeployOptions = { from: deployer, contractAddressSalt, universalDeploy: true };
|
|
293
|
+
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals);
|
|
294
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
295
|
+
const metadata = await this.wallet.getContractMetadata(instance.address);
|
|
296
|
+
if (metadata.isContractPublished) {
|
|
297
|
+
this.log.info(`Token ${name} at ${instance.address.toString()} already deployed, refueling before setup`);
|
|
298
|
+
const token = TokenContract.at(instance.address, this.wallet);
|
|
299
|
+
await this.ensureFeeJuiceBalance(deployer, token);
|
|
300
|
+
}
|
|
301
|
+
return this.setupTokenContract(deployer, contractAddressSalt, name, ticker, decimals);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
private async getTokenInstance(sender: AztecAddress): Promise<TokenContract | PrivateTokenContract> {
|
|
305
|
+
const deployOpts: DeployOptions = {
|
|
306
|
+
from: sender,
|
|
307
|
+
contractAddressSalt: this.config.tokenSalt,
|
|
308
|
+
universalDeploy: true,
|
|
309
|
+
};
|
|
310
|
+
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
311
|
+
const deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
312
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
313
|
+
return TokenContract.at(instance.address, this.wallet);
|
|
314
|
+
}
|
|
315
|
+
if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
316
|
+
const tokenSecretKey = Fr.random();
|
|
317
|
+
const tokenPublicKeys = (await deriveKeys(tokenSecretKey)).publicKeys;
|
|
318
|
+
const deploy = PrivateTokenContract.deployWithPublicKeys(tokenPublicKeys, this.wallet, MINT_BALANCE, sender);
|
|
319
|
+
const instance = await deploy.getInstance({
|
|
320
|
+
...deployOpts,
|
|
321
|
+
skipInstancePublication: true,
|
|
322
|
+
skipClassPublication: true,
|
|
323
|
+
skipInitialization: false,
|
|
324
|
+
});
|
|
325
|
+
return PrivateTokenContract.at(instance.address, this.wallet);
|
|
326
|
+
}
|
|
327
|
+
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
328
|
+
}
|
|
329
|
+
|
|
256
330
|
/**
|
|
257
331
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
258
|
-
*
|
|
259
|
-
* @
|
|
332
|
+
* Uses a bridge claim for deploy when balance is below threshold to avoid failing before refuel.
|
|
333
|
+
* @param sender - Aztec address to deploy the token contract from.
|
|
334
|
+
* @param existingToken - Optional token instance when called from setupTokenWithOptionalEarlyRefuel.
|
|
335
|
+
* @returns The TokenContract or PrivateTokenContract instance.
|
|
260
336
|
*/
|
|
261
337
|
private async setupToken(sender: AztecAddress): Promise<TokenContract | PrivateTokenContract> {
|
|
262
338
|
let deploy: DeployMethod<TokenContract | PrivateTokenContract>;
|
|
263
|
-
let tokenInstance: ContractInstanceWithAddress | undefined;
|
|
264
339
|
const deployOpts: DeployOptions = {
|
|
265
340
|
from: sender,
|
|
266
341
|
contractAddressSalt: this.config.tokenSalt,
|
|
@@ -269,8 +344,8 @@ export class BotFactory {
|
|
|
269
344
|
let token: TokenContract | PrivateTokenContract;
|
|
270
345
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
271
346
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
272
|
-
|
|
273
|
-
token = TokenContract.at(
|
|
347
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
348
|
+
token = TokenContract.at(instance.address, this.wallet);
|
|
274
349
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
275
350
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
276
351
|
const tokenSecretKey = Fr.random();
|
|
@@ -281,7 +356,7 @@ export class BotFactory {
|
|
|
281
356
|
deployOpts.skipInitialization = false;
|
|
282
357
|
|
|
283
358
|
// Register the contract with the secret key before deployment
|
|
284
|
-
tokenInstance = await deploy.getInstance(deployOpts);
|
|
359
|
+
const tokenInstance = await deploy.getInstance(deployOpts);
|
|
285
360
|
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
286
361
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
287
362
|
// The contract constructor initializes private storage vars that need the contract's own nullifier key.
|
|
@@ -290,20 +365,7 @@ export class BotFactory {
|
|
|
290
365
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
291
366
|
}
|
|
292
367
|
|
|
293
|
-
|
|
294
|
-
const metadata = await this.wallet.getContractMetadata(address);
|
|
295
|
-
if (metadata.isContractPublished) {
|
|
296
|
-
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
297
|
-
await deploy.register();
|
|
298
|
-
} else {
|
|
299
|
-
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
300
|
-
const { txHash } = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
301
|
-
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
302
|
-
await this.withNoMinTxsPerBlock(async () => {
|
|
303
|
-
await waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
304
|
-
return token;
|
|
305
|
-
});
|
|
306
|
-
}
|
|
368
|
+
await this.registerOrDeployContract('token', deploy, deployOpts);
|
|
307
369
|
return token;
|
|
308
370
|
}
|
|
309
371
|
|
|
@@ -338,9 +400,11 @@ export class BotFactory {
|
|
|
338
400
|
const amm = AMMContract.at(instance.address, this.wallet);
|
|
339
401
|
|
|
340
402
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
403
|
+
const setMinterInteraction = lpToken.methods.set_minter(amm.address, true);
|
|
404
|
+
const { receipt: minterReceipt } = await setMinterInteraction.send({
|
|
405
|
+
from: deployer,
|
|
406
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
407
|
+
});
|
|
344
408
|
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`);
|
|
345
409
|
this.log.info(`Liquidity token initialized`);
|
|
346
410
|
|
|
@@ -409,20 +473,29 @@ export class BotFactory {
|
|
|
409
473
|
.getFunctionCall(),
|
|
410
474
|
});
|
|
411
475
|
|
|
412
|
-
const
|
|
476
|
+
const mintBatch = new BatchCall(this.wallet, [
|
|
413
477
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
414
478
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
415
|
-
])
|
|
479
|
+
]);
|
|
480
|
+
const { receipt: mintReceipt } = await mintBatch.send({
|
|
481
|
+
from: liquidityProvider,
|
|
482
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
483
|
+
});
|
|
416
484
|
|
|
417
485
|
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
418
486
|
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
487
|
+
const addLiquidityInteraction = amm.methods.add_liquidity(
|
|
488
|
+
amount0Max,
|
|
489
|
+
amount1Max,
|
|
490
|
+
amount0Min,
|
|
491
|
+
amount1Min,
|
|
492
|
+
authwitNonce,
|
|
493
|
+
);
|
|
494
|
+
const { receipt: addLiquidityReceipt } = await addLiquidityInteraction.send({
|
|
495
|
+
from: liquidityProvider,
|
|
496
|
+
authWitnesses: [token0Authwit, token1Authwit],
|
|
497
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
498
|
+
});
|
|
426
499
|
|
|
427
500
|
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
428
501
|
this.log.info(`Liquidity added`);
|
|
@@ -445,12 +518,42 @@ export class BotFactory {
|
|
|
445
518
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
446
519
|
await deploy.register();
|
|
447
520
|
} else {
|
|
448
|
-
|
|
449
|
-
await this.
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
521
|
+
const sender = deployOpts.from === NO_FROM ? undefined : deployOpts.from;
|
|
522
|
+
const balance = sender ? await getFeeJuiceBalance(sender, this.aztecNode) : 0n;
|
|
523
|
+
const useClaim =
|
|
524
|
+
sender &&
|
|
525
|
+
balance < FEE_JUICE_TOP_UP_THRESHOLD &&
|
|
526
|
+
this.config.feePaymentMethod === 'fee_juice' &&
|
|
527
|
+
!!this.config.l1RpcUrls?.length;
|
|
528
|
+
const mnemonicOrPrivateKey = this.config.l1PrivateKey?.getValue() ?? this.config.l1Mnemonic?.getValue();
|
|
529
|
+
|
|
530
|
+
if (useClaim && mnemonicOrPrivateKey) {
|
|
531
|
+
const claim = await this.getOrCreateBridgeClaim(sender!);
|
|
532
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(sender!, claim);
|
|
533
|
+
const { estimatedGas } = await deploy.simulate({ ...deployOpts, fee: { estimateGas: true, paymentMethod } });
|
|
534
|
+
const maxFeesPerGas = (await this.getMinFees()).mul(1 + this.config.minFeePadding);
|
|
535
|
+
const gasSettings = GasSettings.from({
|
|
536
|
+
...estimatedGas!,
|
|
537
|
+
maxFeesPerGas,
|
|
538
|
+
maxPriorityFeesPerGas: GasFees.empty(),
|
|
539
|
+
});
|
|
540
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
541
|
+
const { txHash } = await deploy.send({ ...deployOpts, fee: { gasSettings, paymentMethod }, wait: NO_WAIT });
|
|
542
|
+
this.log.info(
|
|
543
|
+
`Sent contract ${name} deploy tx ${txHash.toString()} (using bridge claim, balance was ${balance})`,
|
|
544
|
+
);
|
|
545
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
546
|
+
});
|
|
547
|
+
await this.store.deleteBridgeClaim(sender!);
|
|
548
|
+
} else {
|
|
549
|
+
const { estimatedGas } = await deploy.simulate({ ...deployOpts, fee: { estimateGas: true } });
|
|
550
|
+
this.log.info(`Deploying contract ${name} at ${address.toString()}`, { estimatedGas });
|
|
551
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
552
|
+
const { txHash } = await deploy.send({ ...deployOpts, fee: { gasSettings: estimatedGas }, wait: NO_WAIT });
|
|
553
|
+
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
554
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
555
|
+
});
|
|
556
|
+
}
|
|
454
557
|
}
|
|
455
558
|
return instance;
|
|
456
559
|
}
|
|
@@ -459,6 +562,66 @@ export class BotFactory {
|
|
|
459
562
|
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
460
563
|
* @param token - Token contract.
|
|
461
564
|
*/
|
|
565
|
+
/**
|
|
566
|
+
* Ensures the account has sufficient fee juice by bridging from L1 if balance is below threshold.
|
|
567
|
+
* Bridges repeatedly until balance reaches the target (10k FJ).
|
|
568
|
+
* Used on startup/restart to top up when the account has run out after previous runs.
|
|
569
|
+
*/
|
|
570
|
+
private async ensureFeeJuiceBalance(
|
|
571
|
+
account: AztecAddress,
|
|
572
|
+
token: TokenContract | PrivateTokenContract,
|
|
573
|
+
): Promise<void> {
|
|
574
|
+
const { feePaymentMethod, l1RpcUrls } = this.config;
|
|
575
|
+
if (feePaymentMethod !== 'fee_juice' || !l1RpcUrls?.length) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const mnemonicOrPrivateKey = this.config.l1PrivateKey?.getValue() ?? this.config.l1Mnemonic?.getValue();
|
|
579
|
+
if (!mnemonicOrPrivateKey) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
let balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
584
|
+
if (balance >= FEE_JUICE_TOP_UP_THRESHOLD) {
|
|
585
|
+
this.log.info(`Fee juice balance ${balance} above threshold ${FEE_JUICE_TOP_UP_THRESHOLD}, skipping top-up`);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
this.log.info(
|
|
590
|
+
`Fee juice balance ${balance} below threshold ${FEE_JUICE_TOP_UP_THRESHOLD}, bridging from L1 until ${FEE_JUICE_TOP_UP_TARGET}`,
|
|
591
|
+
);
|
|
592
|
+
const maxFeesPerGas = (await this.getMinFees()).mul(1 + this.config.minFeePadding);
|
|
593
|
+
const minimalInteraction = isStandardTokenContract(token)
|
|
594
|
+
? token.methods.transfer_in_public(account, account, 0n, 0)
|
|
595
|
+
: token.methods.transfer(0n, account, account);
|
|
596
|
+
|
|
597
|
+
while (balance < FEE_JUICE_TOP_UP_TARGET) {
|
|
598
|
+
const claim = await this.bridgeL1FeeJuice(account);
|
|
599
|
+
const paymentMethod = new FeeJuicePaymentMethodWithClaim(account, claim);
|
|
600
|
+
const { estimatedGas } = await minimalInteraction.simulate({
|
|
601
|
+
from: account,
|
|
602
|
+
fee: { estimateGas: true, paymentMethod },
|
|
603
|
+
});
|
|
604
|
+
const gasSettings = GasSettings.from({
|
|
605
|
+
...estimatedGas!,
|
|
606
|
+
maxFeesPerGas,
|
|
607
|
+
maxPriorityFeesPerGas: GasFees.empty(),
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
611
|
+
const { txHash } = await minimalInteraction.send({
|
|
612
|
+
from: account,
|
|
613
|
+
fee: { gasSettings, paymentMethod },
|
|
614
|
+
wait: NO_WAIT,
|
|
615
|
+
});
|
|
616
|
+
this.log.info(`Sent fee juice top-up tx ${txHash.toString()}`);
|
|
617
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
618
|
+
});
|
|
619
|
+
balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
620
|
+
this.log.info(`Fee juice balance after top-up: ${balance}`);
|
|
621
|
+
}
|
|
622
|
+
this.log.info(`Fee juice top-up complete for ${account.toString()}`);
|
|
623
|
+
}
|
|
624
|
+
|
|
462
625
|
private async mintTokens(token: TokenContract | PrivateTokenContract, minter: AztecAddress) {
|
|
463
626
|
const isStandardToken = isStandardTokenContract(token);
|
|
464
627
|
let privateBalance = 0n;
|
|
@@ -491,8 +654,9 @@ export class BotFactory {
|
|
|
491
654
|
|
|
492
655
|
// PrivateToken's mint accesses contract-level private storage vars (admin, total_supply).
|
|
493
656
|
const additionalScopes = isStandardToken ? undefined : [token.address];
|
|
657
|
+
const mintBatch = new BatchCall(token.wallet, calls);
|
|
494
658
|
await this.withNoMinTxsPerBlock(async () => {
|
|
495
|
-
const { txHash } = await
|
|
659
|
+
const { txHash } = await mintBatch.send({
|
|
496
660
|
from: minter,
|
|
497
661
|
additionalScopes,
|
|
498
662
|
wait: NO_WAIT,
|
|
@@ -565,6 +729,19 @@ export class BotFactory {
|
|
|
565
729
|
return claim as L2AmountClaim;
|
|
566
730
|
}
|
|
567
731
|
|
|
732
|
+
/** Returns worst-case min fees across predicted slots, with fallback to current min fees. */
|
|
733
|
+
private async getMinFees(): Promise<GasFees> {
|
|
734
|
+
try {
|
|
735
|
+
const predicted = await this.aztecNode.getPredictedMinFees(ManaUsageEstimate.Limit);
|
|
736
|
+
if (predicted.length === 0) {
|
|
737
|
+
return this.aztecNode.getCurrentMinFees();
|
|
738
|
+
}
|
|
739
|
+
return predicted.reduce((worst, fees) => (fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst));
|
|
740
|
+
} catch {
|
|
741
|
+
return this.aztecNode.getCurrentMinFees();
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
568
745
|
private async withNoMinTxsPerBlock<T>(fn: () => Promise<T>): Promise<T> {
|
|
569
746
|
if (!this.aztecNodeAdmin || !this.config.flushSetupTransactions) {
|
|
570
747
|
this.log.verbose(`No node admin client or flushing not requested (not setting minTxsPerBlock to 0)`);
|