@aztec/bot 0.0.1-commit.e0f15ab9b → 0.0.1-commit.e304674f1
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 +5 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +183 -122
- 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 +186 -65
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTlELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU1QyxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQ2xGLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxjQUFjL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er_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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ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AAC,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,18 @@ 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;
|
|
62
66
|
private withNoMinTxsPerBlock;
|
|
63
67
|
}
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
68
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBcUJ6RCxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBSXRFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUMzRCxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUM3RSxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDL0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBR2xFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLE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ztRQUNqQixNQUFNLEVBQUUsYUFBYSxDQUFDO1FBQ3RCLE1BQU0sRUFBRSxhQUFhLENBQUM7UUFDdEIsSUFBSSxFQUFFLFNBQVMsQ0FBQztLQUNqQixDQUFDLENBNEJEO0lBRUQ7OztPQUdHO0lBQ1UsZUFBZSxJQUFJLE9BQU8sQ0FBQztRQUN0QyxNQUFNLEVBQUUsY0FBYyxDQUFDO1FBQ3ZCLHFCQUFxQixFQUFFLFlBQVksQ0FBQztRQUNwQyxRQUFRLEVBQUUsWUFBWSxDQUFDO1FBQ3ZCLElBQUksRUFBRSxTQUFTLENBQUM7UUFDaEIsUUFBUSxFQUFFLHdCQUF3QixDQUFDO1FBQ25DLGFBQWEsRUFBRSxNQUFNLENBQUM7S0FDdkIsQ0FBQyxDQTJERDtZQUVhLGlCQUFpQjtZQWVqQixZQUFZO1lBV1osMEJBQTBCO1lBdUMxQixnQkFBZ0I7WUFlaEIsaUNBQWlDO1lBY2pDLHlDQUF5QztZQW1CekMsZ0JBQWdCO1lBaUNoQixVQUFVO1lBd0NWLGtCQUFrQjtZQWFsQixnQkFBZ0I7WUF3QmhCLE9BQU87WUErRlAsd0JBQXdCO1lBNkR4QixxQkFBcUI7WUF1RHJCLFVBQVU7WUFpRFYsc0JBQXNCO1lBMkJ0QixnQkFBZ0I7WUErQmhCLG9CQUFvQjtDQWVuQyJ9
|
package/dest/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
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,E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AE,SAAS,CAAC;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;YA+BhB,oBAAoB;CAenC"}
|
package/dest/factory.js
CHANGED
|
@@ -7,6 +7,7 @@ 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';
|
|
10
11
|
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
11
12
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
12
13
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
@@ -25,6 +26,8 @@ import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
|
25
26
|
import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils.js';
|
|
26
27
|
const MINT_BALANCE = 1e12;
|
|
27
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;
|
|
28
31
|
export class BotFactory {
|
|
29
32
|
config;
|
|
30
33
|
wallet;
|
|
@@ -49,7 +52,8 @@ export class BotFactory {
|
|
|
49
52
|
*/ async setup() {
|
|
50
53
|
const defaultAccountAddress = await this.setupAccount();
|
|
51
54
|
const recipient = (await this.wallet.createSchnorrAccount(Fr.random(), Fr.random())).address;
|
|
52
|
-
const token = await this.
|
|
55
|
+
const token = await this.setupTokenWithOptionalEarlyRefuel(defaultAccountAddress);
|
|
56
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress, token);
|
|
53
57
|
await this.mintTokens(token, defaultAccountAddress);
|
|
54
58
|
return {
|
|
55
59
|
wallet: this.wallet,
|
|
@@ -61,7 +65,8 @@ export class BotFactory {
|
|
|
61
65
|
}
|
|
62
66
|
async setupAmm() {
|
|
63
67
|
const defaultAccountAddress = await this.setupAccount();
|
|
64
|
-
const token0 = await this.
|
|
68
|
+
const token0 = await this.setupTokenContractWithOptionalEarlyRefuel(defaultAccountAddress, this.config.tokenSalt, 'BotToken0', 'BOT0');
|
|
69
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress, token0);
|
|
65
70
|
const token1 = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotToken1', 'BOT1');
|
|
66
71
|
const liquidityToken = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotLPToken', 'BOTLP');
|
|
67
72
|
const amm = await this.setupAmmContract(defaultAccountAddress, this.config.tokenSalt, token0, token1, liquidityToken);
|
|
@@ -166,31 +171,15 @@ export class BotFactory {
|
|
|
166
171
|
const claim = await this.getOrCreateBridgeClaim(address);
|
|
167
172
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
168
173
|
const deployMethod = await accountManager.getDeployMethod();
|
|
169
|
-
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
170
|
-
const { estimatedGas } = await deployMethod.simulate({
|
|
171
|
-
from: NO_FROM,
|
|
172
|
-
fee: {
|
|
173
|
-
estimateGas: true,
|
|
174
|
-
paymentMethod
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
const gasSettings = GasSettings.from({
|
|
178
|
-
...estimatedGas,
|
|
179
|
-
maxFeesPerGas,
|
|
180
|
-
maxPriorityFeesPerGas: GasFees.empty()
|
|
181
|
-
});
|
|
182
174
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
183
175
|
const { txHash } = await deployMethod.send({
|
|
184
176
|
from: NO_FROM,
|
|
185
177
|
fee: {
|
|
186
|
-
gasSettings,
|
|
187
178
|
paymentMethod
|
|
188
179
|
},
|
|
189
180
|
wait: NO_WAIT
|
|
190
181
|
});
|
|
191
|
-
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}
|
|
192
|
-
gasSettings
|
|
193
|
-
});
|
|
182
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
194
183
|
return waitForTx(this.aztecNode, txHash, {
|
|
195
184
|
timeout: this.config.txMinedWaitSeconds
|
|
196
185
|
});
|
|
@@ -207,12 +196,70 @@ export class BotFactory {
|
|
|
207
196
|
return accountManager.address;
|
|
208
197
|
}
|
|
209
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
|
+
/**
|
|
210
256
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
211
|
-
*
|
|
212
|
-
* @
|
|
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.
|
|
213
261
|
*/ async setupToken(sender) {
|
|
214
262
|
let deploy;
|
|
215
|
-
let tokenInstance;
|
|
216
263
|
const deployOpts = {
|
|
217
264
|
from: sender,
|
|
218
265
|
contractAddressSalt: this.config.tokenSalt,
|
|
@@ -221,8 +268,8 @@ export class BotFactory {
|
|
|
221
268
|
let token;
|
|
222
269
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
223
270
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
224
|
-
|
|
225
|
-
token = TokenContract.at(
|
|
271
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
272
|
+
token = TokenContract.at(instance.address, this.wallet);
|
|
226
273
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
227
274
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
228
275
|
const tokenSecretKey = Fr.random();
|
|
@@ -232,7 +279,7 @@ export class BotFactory {
|
|
|
232
279
|
deployOpts.skipClassPublication = true;
|
|
233
280
|
deployOpts.skipInitialization = false;
|
|
234
281
|
// Register the contract with the secret key before deployment
|
|
235
|
-
tokenInstance = await deploy.getInstance(deployOpts);
|
|
282
|
+
const tokenInstance = await deploy.getInstance(deployOpts);
|
|
236
283
|
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
237
284
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
238
285
|
// The contract constructor initializes private storage vars that need the contract's own nullifier key.
|
|
@@ -242,36 +289,7 @@ export class BotFactory {
|
|
|
242
289
|
} else {
|
|
243
290
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
244
291
|
}
|
|
245
|
-
|
|
246
|
-
const metadata = await this.wallet.getContractMetadata(address);
|
|
247
|
-
if (metadata.isContractPublished) {
|
|
248
|
-
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
249
|
-
await deploy.register();
|
|
250
|
-
} else {
|
|
251
|
-
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
252
|
-
const { estimatedGas } = await deploy.simulate({
|
|
253
|
-
...deployOpts,
|
|
254
|
-
fee: {
|
|
255
|
-
estimateGas: true
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
const { txHash } = await deploy.send({
|
|
259
|
-
...deployOpts,
|
|
260
|
-
fee: {
|
|
261
|
-
gasSettings: estimatedGas
|
|
262
|
-
},
|
|
263
|
-
wait: NO_WAIT
|
|
264
|
-
});
|
|
265
|
-
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`, {
|
|
266
|
-
estimatedGas
|
|
267
|
-
});
|
|
268
|
-
await this.withNoMinTxsPerBlock(async ()=>{
|
|
269
|
-
await waitForTx(this.aztecNode, txHash, {
|
|
270
|
-
timeout: this.config.txMinedWaitSeconds
|
|
271
|
-
});
|
|
272
|
-
return token;
|
|
273
|
-
});
|
|
274
|
-
}
|
|
292
|
+
await this.registerOrDeployContract('token', deploy, deployOpts);
|
|
275
293
|
return token;
|
|
276
294
|
}
|
|
277
295
|
/**
|
|
@@ -299,24 +317,13 @@ export class BotFactory {
|
|
|
299
317
|
const amm = AMMContract.at(instance.address, this.wallet);
|
|
300
318
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
301
319
|
const setMinterInteraction = lpToken.methods.set_minter(amm.address, true);
|
|
302
|
-
const { estimatedGas: setMinterGas } = await setMinterInteraction.simulate({
|
|
303
|
-
from: deployer,
|
|
304
|
-
fee: {
|
|
305
|
-
estimateGas: true
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
320
|
const { receipt: minterReceipt } = await setMinterInteraction.send({
|
|
309
321
|
from: deployer,
|
|
310
|
-
fee: {
|
|
311
|
-
gasSettings: setMinterGas
|
|
312
|
-
},
|
|
313
322
|
wait: {
|
|
314
323
|
timeout: this.config.txMinedWaitSeconds
|
|
315
324
|
}
|
|
316
325
|
});
|
|
317
|
-
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}
|
|
318
|
-
estimatedGas: setMinterGas
|
|
319
|
-
});
|
|
326
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`);
|
|
320
327
|
this.log.info(`Liquidity token initialized`);
|
|
321
328
|
return amm;
|
|
322
329
|
}
|
|
@@ -353,40 +360,16 @@ export class BotFactory {
|
|
|
353
360
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
354
361
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE)
|
|
355
362
|
]);
|
|
356
|
-
const { estimatedGas: mintGas } = await mintBatch.simulate({
|
|
357
|
-
from: liquidityProvider,
|
|
358
|
-
fee: {
|
|
359
|
-
estimateGas: true
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
363
|
const { receipt: mintReceipt } = await mintBatch.send({
|
|
363
364
|
from: liquidityProvider,
|
|
364
|
-
fee: {
|
|
365
|
-
gasSettings: mintGas
|
|
366
|
-
},
|
|
367
365
|
wait: {
|
|
368
366
|
timeout: this.config.txMinedWaitSeconds
|
|
369
367
|
}
|
|
370
368
|
});
|
|
371
|
-
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}
|
|
372
|
-
estimatedGas: mintGas
|
|
373
|
-
});
|
|
369
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
374
370
|
const addLiquidityInteraction = amm.methods.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce);
|
|
375
|
-
const { estimatedGas: addLiquidityGas } = await addLiquidityInteraction.simulate({
|
|
376
|
-
from: liquidityProvider,
|
|
377
|
-
fee: {
|
|
378
|
-
estimateGas: true
|
|
379
|
-
},
|
|
380
|
-
authWitnesses: [
|
|
381
|
-
token0Authwit,
|
|
382
|
-
token1Authwit
|
|
383
|
-
]
|
|
384
|
-
});
|
|
385
371
|
const { receipt: addLiquidityReceipt } = await addLiquidityInteraction.send({
|
|
386
372
|
from: liquidityProvider,
|
|
387
|
-
fee: {
|
|
388
|
-
gasSettings: addLiquidityGas
|
|
389
|
-
},
|
|
390
373
|
authWitnesses: [
|
|
391
374
|
token0Authwit,
|
|
392
375
|
token1Authwit
|
|
@@ -395,9 +378,7 @@ export class BotFactory {
|
|
|
395
378
|
timeout: this.config.txMinedWaitSeconds
|
|
396
379
|
}
|
|
397
380
|
});
|
|
398
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}
|
|
399
|
-
estimatedGas: addLiquidityGas
|
|
400
|
-
});
|
|
381
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
401
382
|
this.log.info(`Liquidity added`);
|
|
402
383
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
403
384
|
this.log.info(`Updated private balances of ${defaultAccountAddress} after minting and funding AMM: token0=${newT0Bal}, token1=${newT1Bal}, lp=${newLPBal}`);
|
|
@@ -410,35 +391,127 @@ export class BotFactory {
|
|
|
410
391
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
411
392
|
await deploy.register();
|
|
412
393
|
} else {
|
|
413
|
-
const
|
|
414
|
-
|
|
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({
|
|
402
|
+
...deployOpts,
|
|
403
|
+
fee: {
|
|
404
|
+
estimateGas: true,
|
|
405
|
+
paymentMethod
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
409
|
+
const gasSettings = GasSettings.from({
|
|
410
|
+
...estimatedGas,
|
|
411
|
+
maxFeesPerGas,
|
|
412
|
+
maxPriorityFeesPerGas: GasFees.empty()
|
|
413
|
+
});
|
|
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
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return instance;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
458
|
+
* @param token - Token contract.
|
|
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.aztecNode.getCurrentMinFees()).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,
|
|
415
485
|
fee: {
|
|
416
|
-
estimateGas: true
|
|
486
|
+
estimateGas: true,
|
|
487
|
+
paymentMethod
|
|
417
488
|
}
|
|
418
489
|
});
|
|
419
|
-
|
|
420
|
-
estimatedGas
|
|
490
|
+
const gasSettings = GasSettings.from({
|
|
491
|
+
...estimatedGas,
|
|
492
|
+
maxFeesPerGas,
|
|
493
|
+
maxPriorityFeesPerGas: GasFees.empty()
|
|
421
494
|
});
|
|
422
495
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
423
|
-
const { txHash } = await
|
|
424
|
-
|
|
496
|
+
const { txHash } = await minimalInteraction.send({
|
|
497
|
+
from: account,
|
|
425
498
|
fee: {
|
|
426
|
-
gasSettings
|
|
499
|
+
gasSettings,
|
|
500
|
+
paymentMethod
|
|
427
501
|
},
|
|
428
502
|
wait: NO_WAIT
|
|
429
503
|
});
|
|
430
|
-
this.log.info(`Sent
|
|
504
|
+
this.log.info(`Sent fee juice top-up tx ${txHash.toString()}`);
|
|
431
505
|
return waitForTx(this.aztecNode, txHash, {
|
|
432
506
|
timeout: this.config.txMinedWaitSeconds
|
|
433
507
|
});
|
|
434
508
|
});
|
|
509
|
+
balance = await getFeeJuiceBalance(account, this.aztecNode);
|
|
510
|
+
this.log.info(`Fee juice balance after top-up: ${balance}`);
|
|
435
511
|
}
|
|
436
|
-
|
|
512
|
+
this.log.info(`Fee juice top-up complete for ${account.toString()}`);
|
|
437
513
|
}
|
|
438
|
-
|
|
439
|
-
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
440
|
-
* @param token - Token contract.
|
|
441
|
-
*/ async mintTokens(token, minter) {
|
|
514
|
+
async mintTokens(token, minter) {
|
|
442
515
|
const isStandardToken = isStandardTokenContract(token);
|
|
443
516
|
let privateBalance = 0n;
|
|
444
517
|
let publicBalance = 0n;
|
|
@@ -465,25 +538,13 @@ export class BotFactory {
|
|
|
465
538
|
token.address
|
|
466
539
|
];
|
|
467
540
|
const mintBatch = new BatchCall(token.wallet, calls);
|
|
468
|
-
const { estimatedGas } = await mintBatch.simulate({
|
|
469
|
-
from: minter,
|
|
470
|
-
fee: {
|
|
471
|
-
estimateGas: true
|
|
472
|
-
},
|
|
473
|
-
additionalScopes
|
|
474
|
-
});
|
|
475
541
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
476
542
|
const { txHash } = await mintBatch.send({
|
|
477
543
|
from: minter,
|
|
478
544
|
additionalScopes,
|
|
479
|
-
fee: {
|
|
480
|
-
gasSettings: estimatedGas
|
|
481
|
-
},
|
|
482
545
|
wait: NO_WAIT
|
|
483
546
|
});
|
|
484
|
-
this.log.info(`Sent token mint tx with hash ${txHash.toString()}
|
|
485
|
-
estimatedGas
|
|
486
|
-
});
|
|
547
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`);
|
|
487
548
|
return waitForTx(this.aztecNode, txHash, {
|
|
488
549
|
timeout: this.config.txMinedWaitSeconds
|
|
489
550
|
});
|
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.e304674f1",
|
|
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.e304674f1",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.e304674f1",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.e304674f1",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.e304674f1",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.e304674f1",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.e304674f1",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.e304674f1",
|
|
64
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.e304674f1",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.e304674f1",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.e304674f1",
|
|
67
|
+
"@aztec/protocol-contracts": "0.0.1-commit.e304674f1",
|
|
68
|
+
"@aztec/stdlib": "0.0.1-commit.e304674f1",
|
|
69
|
+
"@aztec/telemetry-client": "0.0.1-commit.e304674f1",
|
|
70
|
+
"@aztec/wallets": "0.0.1-commit.e304674f1",
|
|
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
|
@@ -16,6 +16,7 @@ import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
|
16
16
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
17
17
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
18
18
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
19
|
+
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
19
20
|
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
20
21
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
21
22
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
@@ -41,6 +42,8 @@ import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils
|
|
|
41
42
|
|
|
42
43
|
const MINT_BALANCE = 1e12;
|
|
43
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;
|
|
44
47
|
|
|
45
48
|
export class BotFactory {
|
|
46
49
|
private log = createLogger('bot');
|
|
@@ -70,7 +73,8 @@ export class BotFactory {
|
|
|
70
73
|
}> {
|
|
71
74
|
const defaultAccountAddress = await this.setupAccount();
|
|
72
75
|
const recipient = (await this.wallet.createSchnorrAccount(Fr.random(), Fr.random())).address;
|
|
73
|
-
const token = await this.
|
|
76
|
+
const token = await this.setupTokenWithOptionalEarlyRefuel(defaultAccountAddress);
|
|
77
|
+
await this.ensureFeeJuiceBalance(defaultAccountAddress, token);
|
|
74
78
|
await this.mintTokens(token, defaultAccountAddress);
|
|
75
79
|
return { wallet: this.wallet, defaultAccountAddress, token, node: this.aztecNode, recipient };
|
|
76
80
|
}
|
|
@@ -84,7 +88,13 @@ export class BotFactory {
|
|
|
84
88
|
node: AztecNode;
|
|
85
89
|
}> {
|
|
86
90
|
const defaultAccountAddress = await this.setupAccount();
|
|
87
|
-
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);
|
|
88
98
|
const token1 = await this.setupTokenContract(defaultAccountAddress, this.config.tokenSalt, 'BotToken1', 'BOT1');
|
|
89
99
|
const liquidityToken = await this.setupTokenContract(
|
|
90
100
|
defaultAccountAddress,
|
|
@@ -224,21 +234,14 @@ export class BotFactory {
|
|
|
224
234
|
|
|
225
235
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
226
236
|
const deployMethod = await accountManager.getDeployMethod();
|
|
227
|
-
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
228
|
-
|
|
229
|
-
const { estimatedGas } = await deployMethod.simulate({
|
|
230
|
-
from: NO_FROM,
|
|
231
|
-
fee: { estimateGas: true, paymentMethod },
|
|
232
|
-
});
|
|
233
|
-
const gasSettings = GasSettings.from({ ...estimatedGas!, maxFeesPerGas, maxPriorityFeesPerGas: GasFees.empty() });
|
|
234
237
|
|
|
235
238
|
await this.withNoMinTxsPerBlock(async () => {
|
|
236
239
|
const { txHash } = await deployMethod.send({
|
|
237
240
|
from: NO_FROM,
|
|
238
|
-
fee: {
|
|
241
|
+
fee: { paymentMethod },
|
|
239
242
|
wait: NO_WAIT,
|
|
240
243
|
});
|
|
241
|
-
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}
|
|
244
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
242
245
|
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
243
246
|
});
|
|
244
247
|
this.log.info(`Account deployed at ${address}`);
|
|
@@ -260,14 +263,79 @@ export class BotFactory {
|
|
|
260
263
|
return accountManager.address;
|
|
261
264
|
}
|
|
262
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
|
+
|
|
263
330
|
/**
|
|
264
331
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
265
|
-
*
|
|
266
|
-
* @
|
|
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.
|
|
267
336
|
*/
|
|
268
337
|
private async setupToken(sender: AztecAddress): Promise<TokenContract | PrivateTokenContract> {
|
|
269
338
|
let deploy: DeployMethod<TokenContract | PrivateTokenContract>;
|
|
270
|
-
let tokenInstance: ContractInstanceWithAddress | undefined;
|
|
271
339
|
const deployOpts: DeployOptions = {
|
|
272
340
|
from: sender,
|
|
273
341
|
contractAddressSalt: this.config.tokenSalt,
|
|
@@ -276,8 +344,8 @@ export class BotFactory {
|
|
|
276
344
|
let token: TokenContract | PrivateTokenContract;
|
|
277
345
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
278
346
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
279
|
-
|
|
280
|
-
token = TokenContract.at(
|
|
347
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
348
|
+
token = TokenContract.at(instance.address, this.wallet);
|
|
281
349
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
282
350
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
283
351
|
const tokenSecretKey = Fr.random();
|
|
@@ -288,7 +356,7 @@ export class BotFactory {
|
|
|
288
356
|
deployOpts.skipInitialization = false;
|
|
289
357
|
|
|
290
358
|
// Register the contract with the secret key before deployment
|
|
291
|
-
tokenInstance = await deploy.getInstance(deployOpts);
|
|
359
|
+
const tokenInstance = await deploy.getInstance(deployOpts);
|
|
292
360
|
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
293
361
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
294
362
|
// The contract constructor initializes private storage vars that need the contract's own nullifier key.
|
|
@@ -297,21 +365,7 @@ export class BotFactory {
|
|
|
297
365
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
298
366
|
}
|
|
299
367
|
|
|
300
|
-
|
|
301
|
-
const metadata = await this.wallet.getContractMetadata(address);
|
|
302
|
-
if (metadata.isContractPublished) {
|
|
303
|
-
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
304
|
-
await deploy.register();
|
|
305
|
-
} else {
|
|
306
|
-
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
307
|
-
const { estimatedGas } = await deploy.simulate({ ...deployOpts, fee: { estimateGas: true } });
|
|
308
|
-
const { txHash } = await deploy.send({ ...deployOpts, fee: { gasSettings: estimatedGas }, wait: NO_WAIT });
|
|
309
|
-
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`, { estimatedGas });
|
|
310
|
-
await this.withNoMinTxsPerBlock(async () => {
|
|
311
|
-
await waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
312
|
-
return token;
|
|
313
|
-
});
|
|
314
|
-
}
|
|
368
|
+
await this.registerOrDeployContract('token', deploy, deployOpts);
|
|
315
369
|
return token;
|
|
316
370
|
}
|
|
317
371
|
|
|
@@ -347,18 +401,11 @@ export class BotFactory {
|
|
|
347
401
|
|
|
348
402
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
349
403
|
const setMinterInteraction = lpToken.methods.set_minter(amm.address, true);
|
|
350
|
-
const { estimatedGas: setMinterGas } = await setMinterInteraction.simulate({
|
|
351
|
-
from: deployer,
|
|
352
|
-
fee: { estimateGas: true },
|
|
353
|
-
});
|
|
354
404
|
const { receipt: minterReceipt } = await setMinterInteraction.send({
|
|
355
405
|
from: deployer,
|
|
356
|
-
fee: { gasSettings: setMinterGas },
|
|
357
406
|
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
358
407
|
});
|
|
359
|
-
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}
|
|
360
|
-
estimatedGas: setMinterGas,
|
|
361
|
-
});
|
|
408
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`);
|
|
362
409
|
this.log.info(`Liquidity token initialized`);
|
|
363
410
|
|
|
364
411
|
return amm;
|
|
@@ -430,17 +477,12 @@ export class BotFactory {
|
|
|
430
477
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
431
478
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
432
479
|
]);
|
|
433
|
-
const { estimatedGas: mintGas } = await mintBatch.simulate({
|
|
434
|
-
from: liquidityProvider,
|
|
435
|
-
fee: { estimateGas: true },
|
|
436
|
-
});
|
|
437
480
|
const { receipt: mintReceipt } = await mintBatch.send({
|
|
438
481
|
from: liquidityProvider,
|
|
439
|
-
fee: { gasSettings: mintGas },
|
|
440
482
|
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
441
483
|
});
|
|
442
484
|
|
|
443
|
-
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}
|
|
485
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
444
486
|
|
|
445
487
|
const addLiquidityInteraction = amm.methods.add_liquidity(
|
|
446
488
|
amount0Max,
|
|
@@ -449,21 +491,13 @@ export class BotFactory {
|
|
|
449
491
|
amount1Min,
|
|
450
492
|
authwitNonce,
|
|
451
493
|
);
|
|
452
|
-
const { estimatedGas: addLiquidityGas } = await addLiquidityInteraction.simulate({
|
|
453
|
-
from: liquidityProvider,
|
|
454
|
-
fee: { estimateGas: true },
|
|
455
|
-
authWitnesses: [token0Authwit, token1Authwit],
|
|
456
|
-
});
|
|
457
494
|
const { receipt: addLiquidityReceipt } = await addLiquidityInteraction.send({
|
|
458
495
|
from: liquidityProvider,
|
|
459
|
-
fee: { gasSettings: addLiquidityGas },
|
|
460
496
|
authWitnesses: [token0Authwit, token1Authwit],
|
|
461
497
|
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
462
498
|
});
|
|
463
499
|
|
|
464
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}
|
|
465
|
-
estimatedGas: addLiquidityGas,
|
|
466
|
-
});
|
|
500
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
467
501
|
this.log.info(`Liquidity added`);
|
|
468
502
|
|
|
469
503
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
@@ -484,13 +518,42 @@ export class BotFactory {
|
|
|
484
518
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
485
519
|
await deploy.register();
|
|
486
520
|
} else {
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
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.aztecNode.getCurrentMinFees()).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
|
+
}
|
|
494
557
|
}
|
|
495
558
|
return instance;
|
|
496
559
|
}
|
|
@@ -499,6 +562,66 @@ export class BotFactory {
|
|
|
499
562
|
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
500
563
|
* @param token - Token contract.
|
|
501
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.aztecNode.getCurrentMinFees()).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
|
+
|
|
502
625
|
private async mintTokens(token: TokenContract | PrivateTokenContract, minter: AztecAddress) {
|
|
503
626
|
const isStandardToken = isStandardTokenContract(token);
|
|
504
627
|
let privateBalance = 0n;
|
|
@@ -532,15 +655,13 @@ export class BotFactory {
|
|
|
532
655
|
// PrivateToken's mint accesses contract-level private storage vars (admin, total_supply).
|
|
533
656
|
const additionalScopes = isStandardToken ? undefined : [token.address];
|
|
534
657
|
const mintBatch = new BatchCall(token.wallet, calls);
|
|
535
|
-
const { estimatedGas } = await mintBatch.simulate({ from: minter, fee: { estimateGas: true }, additionalScopes });
|
|
536
658
|
await this.withNoMinTxsPerBlock(async () => {
|
|
537
659
|
const { txHash } = await mintBatch.send({
|
|
538
660
|
from: minter,
|
|
539
661
|
additionalScopes,
|
|
540
|
-
fee: { gasSettings: estimatedGas },
|
|
541
662
|
wait: NO_WAIT,
|
|
542
663
|
});
|
|
543
|
-
this.log.info(`Sent token mint tx with hash ${txHash.toString()}
|
|
664
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`);
|
|
544
665
|
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
545
666
|
});
|
|
546
667
|
}
|