@aztec/bot 0.0.1-commit.7d4e6cd → 0.0.1-commit.858058eac
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/amm_bot.d.ts +6 -7
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +5 -1
- package/dest/base_bot.d.ts +6 -6
- package/dest/base_bot.d.ts.map +1 -1
- package/dest/base_bot.js +3 -3
- package/dest/bot.d.ts +6 -6
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +5 -2
- package/dest/factory.d.ts +5 -10
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +84 -70
- package/dest/runner.d.ts +3 -3
- package/dest/runner.d.ts.map +1 -1
- package/dest/store/bot_store.d.ts +2 -2
- package/dest/store/bot_store.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/amm_bot.ts +7 -7
- package/src/base_bot.ts +6 -10
- package/src/bot.ts +7 -6
- package/src/factory.ts +71 -54
- package/src/runner.ts +2 -2
package/dest/amm_bot.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import {
|
|
3
|
-
import { TxReceipt } from '@aztec/aztec.js/tx';
|
|
2
|
+
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
4
3
|
import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
5
4
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
5
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
7
|
-
import type {
|
|
6
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
8
7
|
import { BaseBot } from './base_bot.js';
|
|
9
8
|
import type { BotConfig } from './config.js';
|
|
10
9
|
import type { BotStore } from './store/index.js';
|
|
@@ -16,9 +15,9 @@ export declare class AmmBot extends BaseBot {
|
|
|
16
15
|
readonly amm: AMMContract;
|
|
17
16
|
readonly token0: TokenContract;
|
|
18
17
|
readonly token1: TokenContract;
|
|
19
|
-
protected constructor(node: AztecNode, wallet:
|
|
20
|
-
static create(config: BotConfig, wallet:
|
|
21
|
-
protected createAndSendTx(logCtx: object): Promise<
|
|
18
|
+
protected constructor(node: AztecNode, wallet: EmbeddedWallet, defaultAccountAddress: AztecAddress, amm: AMMContract, token0: TokenContract, token1: TokenContract, config: BotConfig);
|
|
19
|
+
static create(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore): Promise<AmmBot>;
|
|
20
|
+
protected createAndSendTx(logCtx: object): Promise<TxHash>;
|
|
22
21
|
protected onTxMined(receipt: TxReceipt, logCtx: object): Promise<void>;
|
|
23
22
|
getAmmBalances(): Promise<Balances>;
|
|
24
23
|
getBalances(): Promise<{
|
|
@@ -30,4 +29,4 @@ export declare class AmmBot extends BaseBot {
|
|
|
30
29
|
private getPrivateBalanceFor;
|
|
31
30
|
}
|
|
32
31
|
export {};
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1tX2JvdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FtbV9ib3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3pELE9BQU8sRUFBRSxNQUFNLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFdkQsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxF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FRCxVQUF5QixTQUFTLENBQUMsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FHcEY7SUFFTSxjQUFjLElBQUksT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUV6QztJQUVZLFdBQVcsSUFBSSxPQUFPLENBQUM7UUFBRSxZQUFZLEVBQUUsUUFBUSxDQUFDO1FBQUMsYUFBYSxFQUFFLFFBQVEsQ0FBQztRQUFDLEdBQUcsRUFBRSxRQUFRLENBQUE7S0FBRSxDQUFDLENBTXRHO1lBRWEsbUJBQW1CO1lBTW5CLG9CQUFvQjtDQU1uQyJ9
|
package/dest/amm_bot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amm_bot.d.ts","sourceRoot":"","sources":["../src/amm_bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"amm_bot.d.ts","sourceRoot":"","sources":["../src/amm_bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD,KAAK,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,qBAAa,MAAO,SAAQ,OAAO;aAKf,GAAG,EAAE,WAAW;aAChB,MAAM,EAAE,aAAa;aACrB,MAAM,EAAE,aAAa;IANvC,SAAS,aACP,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,cAAc,EACtB,qBAAqB,EAAE,YAAY,EACnB,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,EACrC,MAAM,EAAE,SAAS,EAGlB;IAED,OAAa,MAAM,CACjB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,KAAK,EAAE,QAAQ,GACd,OAAO,CAAC,MAAM,CAAC,CASjB;IAED,UAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0C/D;IAED,UAAyB,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpF;IAEM,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CAEzC;IAEY,WAAW,IAAI,OAAO,CAAC;QAAE,YAAY,EAAE,QAAQ,CAAC;QAAC,aAAa,EAAE,QAAQ,CAAC;QAAC,GAAG,EAAE,QAAQ,CAAA;KAAE,CAAC,CAMtG;YAEa,mBAAmB;YAMnB,oBAAoB;CAMnC"}
|
package/dest/amm_bot.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
1
2
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
3
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
4
|
import { BaseBot } from './base_bot.js';
|
|
@@ -55,7 +56,10 @@ export class AmmBot extends BaseBot {
|
|
|
55
56
|
...logCtx,
|
|
56
57
|
balances
|
|
57
58
|
});
|
|
58
|
-
return swapExactTokensInteraction.send(
|
|
59
|
+
return swapExactTokensInteraction.send({
|
|
60
|
+
...opts,
|
|
61
|
+
wait: NO_WAIT
|
|
62
|
+
});
|
|
59
63
|
}
|
|
60
64
|
async onTxMined(receipt, logCtx) {
|
|
61
65
|
const balances = await this.getBalances();
|
package/dest/base_bot.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import { BatchCall, ContractFunctionInteraction, type SendInteractionOptions
|
|
2
|
+
import { BatchCall, ContractFunctionInteraction, 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
|
-
import type {
|
|
5
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
6
6
|
import type { BotConfig } from './config.js';
|
|
7
7
|
export declare abstract class BaseBot {
|
|
8
8
|
readonly node: AztecNode;
|
|
9
|
-
readonly wallet:
|
|
9
|
+
readonly wallet: EmbeddedWallet;
|
|
10
10
|
readonly defaultAccountAddress: AztecAddress;
|
|
11
11
|
config: BotConfig;
|
|
12
12
|
protected log: import("@aztec/aztec.js/log").Logger;
|
|
13
13
|
protected attempts: number;
|
|
14
14
|
protected successes: number;
|
|
15
|
-
protected constructor(node: AztecNode, wallet:
|
|
15
|
+
protected constructor(node: AztecNode, wallet: EmbeddedWallet, defaultAccountAddress: AztecAddress, config: BotConfig);
|
|
16
16
|
run(): Promise<TxReceipt | TxHash>;
|
|
17
|
-
protected abstract createAndSendTx(logCtx: object): Promise<
|
|
17
|
+
protected abstract createAndSendTx(logCtx: object): Promise<TxHash>;
|
|
18
18
|
protected onTxMined(_receipt: TxReceipt, _logCtx: object): Promise<void>;
|
|
19
19
|
protected getSendMethodOpts(interaction: ContractFunctionInteraction | BatchCall): Promise<SendInteractionOptions>;
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV9ib3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9iYXNlX2JvdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDekQsT0FBTyxFQUNMLFNBQVMsRUFDVCwyQkFBMkIsRUFDM0IsS0FBSyxzQkFBc0IsRUFFNUIsTUFBTSwyQkFBMkIsQ0FBQztBQUduQyxPQUFPLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXZELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUU3Qyw4QkFBc0IsT0FBTzthQU9ULElBQUksRUFBRSxTQUFTO2FBQ2YsTUFBTSxFQUFFLGNBQWM7YUFDdEIscUJBQXFCLEVBQUUsWUFBWTtJQUM1QyxNQUFNLEVBQUUsU0FBUztJQVQxQixTQUFTLENBQUMsR0FBRyx1Q0FBdUI7SUFFcEMsU0FBUyxDQUFDLFFBQVEsRUFBRSxNQUFNLENBQUs7SUFDL0IsU0FBUyxDQUFDLFNBQVMsRUFBRSxNQUFNLENBQUs7SUFFaEMsU0FBUyxhQUNTLElBQUksRUFBRSxTQUFTLEVBQ2YsTUFBTSxFQUFFLGNBQWMsRUFDdEIscUJBQXFCLEVBQUUsWUFBWSxFQUM1QyxNQUFNLEVBQUUsU0FBUyxFQUN0QjtJQUVTLEdBQUcsSUFBSSxPQUFPLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxDQThCOUM7SUFFRCxTQUFTLENBQUMsUUFBUSxDQUFDLGVBQWUsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUVwRSxTQUFTLENBQUMsU0FBUyxDQUFDLFFBQVEsRUFBRSxTQUFTLEVBQUUsT0FBTyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBR3ZFO0lBRUQsVUFBZ0IsaUJBQWlCLENBQy9CLFdBQVcsRUFBRSwyQkFBMkIsR0FBRyxTQUFTLEdBQ25ELE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQW9CakM7Q0FDRiJ9
|
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,EACL,SAAS,EACT,2BAA2B,EAC3B,KAAK,sBAAsB,
|
|
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,EACL,SAAS,EACT,2BAA2B,EAC3B,KAAK,sBAAsB,EAE5B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEvD,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,CA8B9C;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,UAAgB,iBAAiB,CAC/B,WAAW,EAAE,2BAA2B,GAAG,SAAS,GACnD,OAAO,CAAC,sBAAsB,CAAC,CAoBjC;CACF"}
|
package/dest/base_bot.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { waitForProven } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
3
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
4
|
import { Gas } from '@aztec/stdlib/gas';
|
|
4
5
|
export class BaseBot {
|
|
5
6
|
node;
|
|
@@ -25,14 +26,13 @@ export class BaseBot {
|
|
|
25
26
|
};
|
|
26
27
|
const { followChain, txMinedWaitSeconds } = this.config;
|
|
27
28
|
this.log.verbose(`Creating tx`, logCtx);
|
|
28
|
-
const
|
|
29
|
-
const txHash = await tx.getTxHash();
|
|
29
|
+
const txHash = await this.createAndSendTx(logCtx);
|
|
30
30
|
if (followChain === 'NONE') {
|
|
31
31
|
this.log.info(`Transaction ${txHash.toString()} sent, not waiting for it to be mined`);
|
|
32
32
|
return txHash;
|
|
33
33
|
}
|
|
34
34
|
this.log.verbose(`Awaiting tx ${txHash.toString()} to be on the ${followChain} chain (timeout ${txMinedWaitSeconds}s)`, logCtx);
|
|
35
|
-
const receipt = await
|
|
35
|
+
const receipt = await waitForTx(this.node, txHash, {
|
|
36
36
|
timeout: txMinedWaitSeconds
|
|
37
37
|
});
|
|
38
38
|
if (followChain === 'PROVEN') {
|
package/dest/bot.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import {
|
|
2
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
3
3
|
import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
4
4
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
5
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
6
|
-
import type {
|
|
6
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
7
7
|
import { BaseBot } from './base_bot.js';
|
|
8
8
|
import type { BotConfig } from './config.js';
|
|
9
9
|
import type { BotStore } from './store/index.js';
|
|
10
10
|
export declare class Bot extends BaseBot {
|
|
11
11
|
readonly token: TokenContract | PrivateTokenContract;
|
|
12
12
|
readonly recipient: AztecAddress;
|
|
13
|
-
protected constructor(node: AztecNode, wallet:
|
|
14
|
-
static create(config: BotConfig, wallet:
|
|
13
|
+
protected constructor(node: AztecNode, wallet: EmbeddedWallet, defaultAccountAddress: AztecAddress, token: TokenContract | PrivateTokenContract, recipient: AztecAddress, config: BotConfig);
|
|
14
|
+
static create(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore): Promise<Bot>;
|
|
15
15
|
updateConfig(config: Partial<BotConfig>): void;
|
|
16
|
-
protected createAndSendTx(logCtx: object): Promise<
|
|
16
|
+
protected createAndSendTx(logCtx: object): Promise<TxHash>;
|
|
17
17
|
getBalances(): Promise<{
|
|
18
18
|
sender: {
|
|
19
19
|
privateBalance: bigint;
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTlELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU1QyxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQ2xGLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUU5RCxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3hDLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUU3QyxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUtqRCxxQkFBYSxHQUFJLFNBQVEsT0FBTzthQUtaLEtBQUssRUFBRSxhQUFhLEdBQUcsb0JBQW9CO2FBQzNDLFNBQVMsRUFBRSxZQUFZO0lBTHpDLFNBQVMsYUFDUCxJQUFJLEVBQUUsU0FBUyxFQUNmLE1BQU0sRUFBRSxjQUFjLEVBQ3RCLHFCQUFxQixFQUFFLFlBQVksRUFDbkIsS0FBSyxFQUFFLGFBQWEsR0FBRyxvQkFBb0IsRUFDM0MsU0FBUyxFQUFFLFlBQVksRUFDdkMsTUFBTSxFQUFFLFNBQVMsRUFHbEI7SUFFRCxPQUFhLE1BQU0sQ0FDakIsTUFBTSxFQUFFLFNBQVMsRUFDakIsTUFBTSxFQUFFLGNBQWMsRUFDdEIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsY0FBYyxFQUFFLGNBQWMsR0FBRyxTQUFTLEVBQzFDLEtBQUssRUFBRSxRQUFRLEdBQ2QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQVNkO0lBRU0sWUFBWSxDQUFDLE1BQU0sRUFBRSxPQUFPLENBQUMsU0FBUyxDQUFDLFFBRzdDO0lBRUQsVUFBZ0IsZUFBZSxDQUFDLE1BQU0sRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQTRCL0Q7SUFFWSxXQUFXOzs7Ozs7Ozs7T0FrQnZCO0NBQ0YifQ==
|
package/dest/bot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../src/bot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../src/bot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD,qBAAa,GAAI,SAAQ,OAAO;aAKZ,KAAK,EAAE,aAAa,GAAG,oBAAoB;aAC3C,SAAS,EAAE,YAAY;IALzC,SAAS,aACP,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,cAAc,EACtB,qBAAqB,EAAE,YAAY,EACnB,KAAK,EAAE,aAAa,GAAG,oBAAoB,EAC3C,SAAS,EAAE,YAAY,EACvC,MAAM,EAAE,SAAS,EAGlB;IAED,OAAa,MAAM,CACjB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,KAAK,EAAE,QAAQ,GACd,OAAO,CAAC,GAAG,CAAC,CASd;IAEM,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,QAG7C;IAED,UAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B/D;IAEY,WAAW;;;;;;;;;OAkBvB;CACF"}
|
package/dest/bot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
1
|
+
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
3
|
import { BaseBot } from './base_bot.js';
|
|
4
4
|
import { BotFactory } from './factory.js';
|
|
@@ -36,7 +36,10 @@ export class Bot extends BaseBot {
|
|
|
36
36
|
from: this.defaultAccountAddress
|
|
37
37
|
});
|
|
38
38
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
39
|
-
return batch.send(
|
|
39
|
+
return batch.send({
|
|
40
|
+
...opts,
|
|
41
|
+
wait: NO_WAIT
|
|
42
|
+
});
|
|
40
43
|
}
|
|
41
44
|
async getBalances() {
|
|
42
45
|
if (isStandardTokenContract(this.token)) {
|
package/dest/factory.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
|
3
3
|
import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
4
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
5
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
6
|
-
import {
|
|
6
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
7
7
|
import { type BotConfig } from './config.js';
|
|
8
8
|
import type { BotStore } from './store/index.js';
|
|
9
9
|
export declare class BotFactory {
|
|
@@ -13,20 +13,20 @@ export declare class BotFactory {
|
|
|
13
13
|
private readonly aztecNode;
|
|
14
14
|
private readonly aztecNodeAdmin?;
|
|
15
15
|
private log;
|
|
16
|
-
constructor(config: BotConfig, wallet:
|
|
16
|
+
constructor(config: BotConfig, wallet: EmbeddedWallet, store: BotStore, aztecNode: AztecNode, aztecNodeAdmin?: AztecNodeAdmin | undefined);
|
|
17
17
|
/**
|
|
18
18
|
* Initializes a new bot by setting up the sender account, registering the recipient,
|
|
19
19
|
* deploying the token contract, and minting tokens if necessary.
|
|
20
20
|
*/
|
|
21
21
|
setup(): Promise<{
|
|
22
|
-
wallet:
|
|
22
|
+
wallet: EmbeddedWallet;
|
|
23
23
|
defaultAccountAddress: AztecAddress;
|
|
24
24
|
token: TokenContract | PrivateTokenContract;
|
|
25
25
|
node: AztecNode;
|
|
26
26
|
recipient: AztecAddress;
|
|
27
27
|
}>;
|
|
28
28
|
setupAmm(): Promise<{
|
|
29
|
-
wallet:
|
|
29
|
+
wallet: EmbeddedWallet;
|
|
30
30
|
defaultAccountAddress: AztecAddress;
|
|
31
31
|
amm: AMMContract;
|
|
32
32
|
token0: TokenContract;
|
|
@@ -37,11 +37,6 @@ export declare class BotFactory {
|
|
|
37
37
|
private setupAccountWithPrivateKey;
|
|
38
38
|
private setupTestAccount;
|
|
39
39
|
private setupToken;
|
|
40
|
-
/**
|
|
41
|
-
* Checks if the token contract is deployed and deploys it if necessary.
|
|
42
|
-
* @param wallet - Wallet to deploy the token contract from.
|
|
43
|
-
* @returns The TokenContract instance.
|
|
44
|
-
*/
|
|
45
40
|
private setupTokenContract;
|
|
46
41
|
private setupAmmContract;
|
|
47
42
|
private fundAmm;
|
|
@@ -51,4 +46,4 @@ export declare class BotFactory {
|
|
|
51
46
|
private bridgeL1FeeJuice;
|
|
52
47
|
private withNoMinTxsPerBlock;
|
|
53
48
|
}
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBb0J6RCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDM0QsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sdUNBQXVDLENBQUM7QUFDN0UsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRy9ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVqRixPQUFPLEVBQUUs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RUFBRSxhQUFhLENBQUM7UUFDdEIsSUFBSSxFQUFFLFNBQVMsQ0FBQztLQUNqQixDQUFDLENBc0JEO1lBTWEsWUFBWTtZQVdaLDBCQUEwQjtZQXlDMUIsZ0JBQWdCO1lBZWhCLFVBQVU7WUFvRFYsa0JBQWtCO1lBYWxCLGdCQUFnQjtZQXNCaEIsT0FBTztZQTZFUCx3QkFBd0I7WUEwQnhCLFVBQVU7WUEwQ1Ysc0JBQXNCO1lBNEJ0QixnQkFBZ0I7WUFnQ2hCLG9CQUFvQjtDQWVuQyJ9
|
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":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAoBzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMjD,qBAAa,UAAU;IAInB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAPlC,OAAO,CAAC,GAAG,CAAuB;IAElC,YACmB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,SAAS,EACpB,cAAc,CAAC,4BAAgB,EAC9C;IAEJ;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC;QACvB,qBAAqB,EAAE,YAAY,CAAC;QACpC,KAAK,EAAE,aAAa,GAAG,oBAAoB,CAAC;QAC5C,IAAI,EAAE,SAAS,CAAC;QAChB,SAAS,EAAE,YAAY,CAAC;KACzB,CAAC,CAMD;IAEY,QAAQ,IAAI,OAAO,CAAC;QAC/B,MAAM,EAAE,cAAc,CAAC;QACvB,qBAAqB,EAAE,YAAY,CAAC;QACpC,GAAG,EAAE,WAAW,CAAC;QACjB,MAAM,EAAE,aAAa,CAAC;QACtB,MAAM,EAAE,aAAa,CAAC;QACtB,IAAI,EAAE,SAAS,CAAC;KACjB,CAAC,CAsBD;YAMa,YAAY;YAWZ,0BAA0B;YAyC1B,gBAAgB;YAehB,UAAU;YAoDV,kBAAkB;YAalB,gBAAgB;YAsBhB,OAAO;YA6EP,wBAAwB;YA0BxB,UAAU;YA0CV,sBAAsB;YA4BtB,gBAAgB;YAgChB,oBAAoB;CAenC"}
|
package/dest/factory.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
2
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
-
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
5
4
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
6
5
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
7
6
|
import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
8
7
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
9
8
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
9
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
10
10
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
11
11
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
12
12
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -39,8 +39,8 @@ export class BotFactory {
|
|
|
39
39
|
* Initializes a new bot by setting up the sender account, registering the recipient,
|
|
40
40
|
* deploying the token contract, and minting tokens if necessary.
|
|
41
41
|
*/ async setup() {
|
|
42
|
-
const recipient = (await this.wallet.createAccount()).address;
|
|
43
42
|
const defaultAccountAddress = await this.setupAccount();
|
|
43
|
+
const recipient = (await this.wallet.createSchnorrAccount(Fr.random(), Fr.random())).address;
|
|
44
44
|
const token = await this.setupToken(defaultAccountAddress);
|
|
45
45
|
await this.mintTokens(token, defaultAccountAddress);
|
|
46
46
|
return {
|
|
@@ -84,14 +84,9 @@ export class BotFactory {
|
|
|
84
84
|
async setupAccountWithPrivateKey(secret) {
|
|
85
85
|
const salt = this.config.senderSalt ?? Fr.ONE;
|
|
86
86
|
const signingKey = deriveSigningKey(secret);
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
contract: new SchnorrAccountContract(signingKey)
|
|
91
|
-
};
|
|
92
|
-
const accountManager = await this.wallet.createAccount(accountData);
|
|
93
|
-
const isInit = (await this.wallet.getContractMetadata(accountManager.address)).isContractInitialized;
|
|
94
|
-
if (isInit) {
|
|
87
|
+
const accountManager = await this.wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
88
|
+
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
89
|
+
if (metadata.isContractInitialized) {
|
|
95
90
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
96
91
|
const timer = new Timer();
|
|
97
92
|
const address = accountManager.address;
|
|
@@ -108,18 +103,20 @@ export class BotFactory {
|
|
|
108
103
|
const gasSettings = GasSettings.default({
|
|
109
104
|
maxFeesPerGas
|
|
110
105
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
107
|
+
const txHash = await deployMethod.send({
|
|
108
|
+
from: AztecAddress.ZERO,
|
|
109
|
+
fee: {
|
|
110
|
+
gasSettings,
|
|
111
|
+
paymentMethod
|
|
112
|
+
},
|
|
113
|
+
wait: NO_WAIT
|
|
114
|
+
});
|
|
115
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
116
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
121
117
|
timeout: this.config.txMinedWaitSeconds
|
|
122
|
-
})
|
|
118
|
+
});
|
|
119
|
+
});
|
|
123
120
|
this.log.info(`Account deployed at ${address}`);
|
|
124
121
|
// Clean up the consumed bridge claim
|
|
125
122
|
await this.store.deleteBridgeClaim(address);
|
|
@@ -128,12 +125,7 @@ export class BotFactory {
|
|
|
128
125
|
}
|
|
129
126
|
async setupTestAccount() {
|
|
130
127
|
const [initialAccountData] = await getInitialTestAccountsData();
|
|
131
|
-
const
|
|
132
|
-
secret: initialAccountData.secret,
|
|
133
|
-
salt: initialAccountData.salt,
|
|
134
|
-
contract: new SchnorrAccountContract(initialAccountData.signingKey)
|
|
135
|
-
};
|
|
136
|
-
const accountManager = await this.wallet.createAccount(accountData);
|
|
128
|
+
const accountManager = await this.wallet.createSchnorrAccount(initialAccountData.secret, initialAccountData.salt, initialAccountData.signingKey);
|
|
137
129
|
return accountManager.address;
|
|
138
130
|
}
|
|
139
131
|
/**
|
|
@@ -148,8 +140,11 @@ export class BotFactory {
|
|
|
148
140
|
contractAddressSalt: this.config.tokenSalt,
|
|
149
141
|
universalDeploy: true
|
|
150
142
|
};
|
|
143
|
+
let token;
|
|
151
144
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
152
145
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
146
|
+
tokenInstance = await deploy.getInstance(deployOpts);
|
|
147
|
+
token = TokenContract.at(tokenInstance.address, this.wallet);
|
|
153
148
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
154
149
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
155
150
|
const tokenSecretKey = Fr.random();
|
|
@@ -160,36 +155,45 @@ export class BotFactory {
|
|
|
160
155
|
deployOpts.skipInitialization = false;
|
|
161
156
|
// Register the contract with the secret key before deployment
|
|
162
157
|
tokenInstance = await deploy.getInstance(deployOpts);
|
|
158
|
+
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
163
159
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
164
160
|
} else {
|
|
165
161
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
166
162
|
}
|
|
167
163
|
const address = tokenInstance?.address ?? (await deploy.getInstance(deployOpts)).address;
|
|
168
|
-
|
|
164
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
165
|
+
if (metadata.isContractPublished) {
|
|
169
166
|
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
170
|
-
|
|
167
|
+
await deploy.register();
|
|
171
168
|
} else {
|
|
172
169
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
173
|
-
const
|
|
174
|
-
|
|
170
|
+
const txHash = await deploy.send({
|
|
171
|
+
...deployOpts,
|
|
172
|
+
wait: NO_WAIT
|
|
173
|
+
});
|
|
175
174
|
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
176
|
-
|
|
175
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
176
|
+
await waitForTx(this.aztecNode, txHash, {
|
|
177
177
|
timeout: this.config.txMinedWaitSeconds
|
|
178
|
-
})
|
|
178
|
+
});
|
|
179
|
+
return token;
|
|
180
|
+
});
|
|
179
181
|
}
|
|
182
|
+
return token;
|
|
180
183
|
}
|
|
181
184
|
/**
|
|
182
185
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
183
186
|
* @param wallet - Wallet to deploy the token contract from.
|
|
184
187
|
* @returns The TokenContract instance.
|
|
185
|
-
*/ setupTokenContract(deployer, contractAddressSalt, name, ticker, decimals = 18) {
|
|
188
|
+
*/ async setupTokenContract(deployer, contractAddressSalt, name, ticker, decimals = 18) {
|
|
186
189
|
const deployOpts = {
|
|
187
190
|
from: deployer,
|
|
188
191
|
contractAddressSalt,
|
|
189
192
|
universalDeploy: true
|
|
190
193
|
};
|
|
191
194
|
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals);
|
|
192
|
-
|
|
195
|
+
const instance = await this.registerOrDeployContract('Token - ' + name, deploy, deployOpts);
|
|
196
|
+
return TokenContract.at(instance.address, this.wallet);
|
|
193
197
|
}
|
|
194
198
|
async setupAmmContract(deployer, contractAddressSalt, token0, token1, lpToken) {
|
|
195
199
|
const deployOpts = {
|
|
@@ -198,15 +202,16 @@ export class BotFactory {
|
|
|
198
202
|
universalDeploy: true
|
|
199
203
|
};
|
|
200
204
|
const deploy = AMMContract.deploy(this.wallet, token0.address, token1.address, lpToken.address);
|
|
201
|
-
const
|
|
205
|
+
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
206
|
+
const amm = AMMContract.at(instance.address, this.wallet);
|
|
202
207
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
203
|
-
const
|
|
204
|
-
from: deployer
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
timeout: this.config.txMinedWaitSeconds
|
|
208
|
+
const minterReceipt = await lpToken.methods.set_minter(amm.address, true).send({
|
|
209
|
+
from: deployer,
|
|
210
|
+
wait: {
|
|
211
|
+
timeout: this.config.txMinedWaitSeconds
|
|
212
|
+
}
|
|
209
213
|
});
|
|
214
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`);
|
|
210
215
|
this.log.info(`Liquidity token initialized`);
|
|
211
216
|
return amm;
|
|
212
217
|
}
|
|
@@ -239,45 +244,52 @@ export class BotFactory {
|
|
|
239
244
|
caller: amm.address,
|
|
240
245
|
call: await token1.methods.transfer_to_public_and_prepare_private_balance_increase(liquidityProvider, amm.address, amount1Max, authwitNonce).getFunctionCall()
|
|
241
246
|
});
|
|
242
|
-
const
|
|
247
|
+
const mintReceipt = await new BatchCall(this.wallet, [
|
|
243
248
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
244
249
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE)
|
|
245
250
|
]).send({
|
|
246
|
-
from: liquidityProvider
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
timeout: this.config.txMinedWaitSeconds
|
|
251
|
+
from: liquidityProvider,
|
|
252
|
+
wait: {
|
|
253
|
+
timeout: this.config.txMinedWaitSeconds
|
|
254
|
+
}
|
|
251
255
|
});
|
|
252
|
-
|
|
256
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
257
|
+
const addLiquidityReceipt = await amm.methods.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce).send({
|
|
253
258
|
from: liquidityProvider,
|
|
254
259
|
authWitnesses: [
|
|
255
260
|
token0Authwit,
|
|
256
261
|
token1Authwit
|
|
257
|
-
]
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
timeout: this.config.txMinedWaitSeconds
|
|
262
|
+
],
|
|
263
|
+
wait: {
|
|
264
|
+
timeout: this.config.txMinedWaitSeconds
|
|
265
|
+
}
|
|
262
266
|
});
|
|
267
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
263
268
|
this.log.info(`Liquidity added`);
|
|
264
269
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
265
270
|
this.log.info(`Updated private balances of ${defaultAccountAddress} after minting and funding AMM: token0=${newT0Bal}, token1=${newT1Bal}, lp=${newLPBal}`);
|
|
266
271
|
}
|
|
267
272
|
async registerOrDeployContract(name, deploy, deployOpts) {
|
|
268
|
-
const
|
|
269
|
-
|
|
273
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
274
|
+
const address = instance.address;
|
|
275
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
276
|
+
if (metadata.isContractPublished) {
|
|
270
277
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
271
|
-
|
|
278
|
+
await deploy.register();
|
|
272
279
|
} else {
|
|
273
280
|
this.log.info(`Deploying contract ${name} at ${address.toString()}`);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
281
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
282
|
+
const txHash = await deploy.send({
|
|
283
|
+
...deployOpts,
|
|
284
|
+
wait: NO_WAIT
|
|
285
|
+
});
|
|
286
|
+
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
287
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
278
288
|
timeout: this.config.txMinedWaitSeconds
|
|
279
|
-
})
|
|
289
|
+
});
|
|
290
|
+
});
|
|
280
291
|
}
|
|
292
|
+
return instance;
|
|
281
293
|
}
|
|
282
294
|
/**
|
|
283
295
|
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
@@ -304,14 +316,16 @@ export class BotFactory {
|
|
|
304
316
|
this.log.info(`Skipping minting as ${minter.toString()} has enough tokens`);
|
|
305
317
|
return;
|
|
306
318
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
319
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
320
|
+
const txHash = await new BatchCall(token.wallet, calls).send({
|
|
321
|
+
from: minter,
|
|
322
|
+
wait: NO_WAIT
|
|
323
|
+
});
|
|
324
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`);
|
|
325
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
313
326
|
timeout: this.config.txMinedWaitSeconds
|
|
314
|
-
})
|
|
327
|
+
});
|
|
328
|
+
});
|
|
315
329
|
}
|
|
316
330
|
/**
|
|
317
331
|
* Gets or creates a bridge claim for the recipient.
|
package/dest/runner.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
2
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
3
3
|
import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
4
|
-
import type {
|
|
4
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
5
5
|
import type { BotConfig } from './config.js';
|
|
6
6
|
import type { BotInfo, BotRunnerApi } from './interface.js';
|
|
7
7
|
import { BotStore } from './store/index.js';
|
|
@@ -19,7 +19,7 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
|
|
|
19
19
|
private consecutiveErrors;
|
|
20
20
|
private healthy;
|
|
21
21
|
readonly tracer: Tracer;
|
|
22
|
-
constructor(config: BotConfig, wallet:
|
|
22
|
+
constructor(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore);
|
|
23
23
|
/** Initializes the bot if needed. Blocks until the bot setup is finished. */
|
|
24
24
|
setup(): Promise<void>;
|
|
25
25
|
private doSetup;
|
|
@@ -50,4 +50,4 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
|
|
|
50
50
|
/** Returns the bot sender address. */
|
|
51
51
|
getInfo(): Promise<BotInfo>;
|
|
52
52
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMapping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AEG;IACU,IAAI,kBAOhB;IAEM,SAAS,YAEf;IAED,0CAA0C;IACnC,SAAS,YAEf;IAED;;;OAGG;IACU,MAAM,CAAC,MAAM,EAAE,SAAS,iBAapC;IAED;;;OAGG;IACU,GAAG,kBAsBf;IAED,qDAAqD;IAC9C,SAAS,uBAGf;IAED,sCAAsC;IACzB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAMvC;CAuCF"}
|
|
@@ -13,7 +13,7 @@ export interface BridgeClaimData {
|
|
|
13
13
|
export declare class BotStore {
|
|
14
14
|
private readonly store;
|
|
15
15
|
private readonly log;
|
|
16
|
-
static readonly SCHEMA_VERSION
|
|
16
|
+
static readonly SCHEMA_VERSION = 1;
|
|
17
17
|
private readonly bridgeClaims;
|
|
18
18
|
constructor(store: AztecAsyncKVStore, log?: Logger);
|
|
19
19
|
/**
|
|
@@ -41,4 +41,4 @@ export declare class BotStore {
|
|
|
41
41
|
*/
|
|
42
42
|
close(): Promise<void>;
|
|
43
43
|
}
|
|
44
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RvcmUvYm90X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUU5RCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFFeEUsTUFBTSxXQUFXLGVBQWU7SUFDOUIsS0FBSyxFQU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AE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBzF;IAED;;OAEG;IACU,cAAc,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAsBzF;IAED;;OAEG;IACU,iBAAiB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrE;IAED;;OAEG;IACU,kBAAkB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAwB5D;IAED;;OAEG;IACU,gBAAgB,CAAC,QAAQ,GAAE,MAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,CAerF;IAED;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAGlC;CACF"}
|
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.858058eac",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -54,18 +54,18 @@
|
|
|
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/noir-contracts.js": "0.0.1-commit.
|
|
64
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
65
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
66
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
67
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
68
|
-
"@aztec/
|
|
57
|
+
"@aztec/accounts": "0.0.1-commit.858058eac",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.858058eac",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.858058eac",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.858058eac",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.858058eac",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.858058eac",
|
|
63
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.858058eac",
|
|
64
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.858058eac",
|
|
65
|
+
"@aztec/protocol-contracts": "0.0.1-commit.858058eac",
|
|
66
|
+
"@aztec/stdlib": "0.0.1-commit.858058eac",
|
|
67
|
+
"@aztec/telemetry-client": "0.0.1-commit.858058eac",
|
|
68
|
+
"@aztec/wallets": "0.0.1-commit.858058eac",
|
|
69
69
|
"source-map-support": "^0.5.21",
|
|
70
70
|
"tslib": "^2.4.0",
|
|
71
71
|
"zod": "^3.23.8"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/jest": "^30.0.0",
|
|
76
76
|
"@types/node": "^22.15.17",
|
|
77
77
|
"@types/source-map-support": "^0.5.10",
|
|
78
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
78
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
79
79
|
"jest": "^30.0.0",
|
|
80
80
|
"jest-mock-extended": "^4.0.0",
|
|
81
81
|
"ts-node": "^10.9.1",
|
package/src/amm_bot.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import {
|
|
2
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
-
import { TxReceipt } from '@aztec/aztec.js/tx';
|
|
4
|
+
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
5
5
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
6
6
|
import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
7
7
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
8
8
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
9
|
-
import type {
|
|
9
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
10
10
|
|
|
11
11
|
import { BaseBot } from './base_bot.js';
|
|
12
12
|
import type { BotConfig } from './config.js';
|
|
@@ -21,7 +21,7 @@ type Balances = { token0: bigint; token1: bigint };
|
|
|
21
21
|
export class AmmBot extends BaseBot {
|
|
22
22
|
protected constructor(
|
|
23
23
|
node: AztecNode,
|
|
24
|
-
wallet:
|
|
24
|
+
wallet: EmbeddedWallet,
|
|
25
25
|
defaultAccountAddress: AztecAddress,
|
|
26
26
|
public readonly amm: AMMContract,
|
|
27
27
|
public readonly token0: TokenContract,
|
|
@@ -33,7 +33,7 @@ export class AmmBot extends BaseBot {
|
|
|
33
33
|
|
|
34
34
|
static async create(
|
|
35
35
|
config: BotConfig,
|
|
36
|
-
wallet:
|
|
36
|
+
wallet: EmbeddedWallet,
|
|
37
37
|
aztecNode: AztecNode,
|
|
38
38
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
39
39
|
store: BotStore,
|
|
@@ -48,7 +48,7 @@ export class AmmBot extends BaseBot {
|
|
|
48
48
|
return new AmmBot(aztecNode, wallet, defaultAccountAddress, amm, token0, token1, config);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
protected async createAndSendTx(logCtx: object): Promise<
|
|
51
|
+
protected async createAndSendTx(logCtx: object): Promise<TxHash> {
|
|
52
52
|
const { feePaymentMethod } = this.config;
|
|
53
53
|
const { wallet, amm, token0, token1 } = this;
|
|
54
54
|
|
|
@@ -89,7 +89,7 @@ export class AmmBot extends BaseBot {
|
|
|
89
89
|
|
|
90
90
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
91
91
|
this.log.info(`Tx. Balances: ${jsonStringify(balances)}`, { ...logCtx, balances });
|
|
92
|
-
return swapExactTokensInteraction.send(opts);
|
|
92
|
+
return swapExactTokensInteraction.send({ ...opts, wait: NO_WAIT });
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
|
package/src/base_bot.ts
CHANGED
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
BatchCall,
|
|
4
4
|
ContractFunctionInteraction,
|
|
5
5
|
type SendInteractionOptions,
|
|
6
|
-
SentTx,
|
|
7
6
|
waitForProven,
|
|
8
7
|
} from '@aztec/aztec.js/contracts';
|
|
9
8
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
9
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
10
10
|
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
11
11
|
import { Gas } from '@aztec/stdlib/gas';
|
|
12
12
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
13
|
-
import type {
|
|
13
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
14
14
|
|
|
15
15
|
import type { BotConfig } from './config.js';
|
|
16
16
|
|
|
@@ -22,7 +22,7 @@ export abstract class BaseBot {
|
|
|
22
22
|
|
|
23
23
|
protected constructor(
|
|
24
24
|
public readonly node: AztecNode,
|
|
25
|
-
public readonly wallet:
|
|
25
|
+
public readonly wallet: EmbeddedWallet,
|
|
26
26
|
public readonly defaultAccountAddress: AztecAddress,
|
|
27
27
|
public config: BotConfig,
|
|
28
28
|
) {}
|
|
@@ -33,9 +33,7 @@ export abstract class BaseBot {
|
|
|
33
33
|
const { followChain, txMinedWaitSeconds } = this.config;
|
|
34
34
|
|
|
35
35
|
this.log.verbose(`Creating tx`, logCtx);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const txHash = await tx.getTxHash();
|
|
36
|
+
const txHash = await this.createAndSendTx(logCtx);
|
|
39
37
|
|
|
40
38
|
if (followChain === 'NONE') {
|
|
41
39
|
this.log.info(`Transaction ${txHash.toString()} sent, not waiting for it to be mined`);
|
|
@@ -46,9 +44,7 @@ export abstract class BaseBot {
|
|
|
46
44
|
`Awaiting tx ${txHash.toString()} to be on the ${followChain} chain (timeout ${txMinedWaitSeconds}s)`,
|
|
47
45
|
logCtx,
|
|
48
46
|
);
|
|
49
|
-
const receipt = await
|
|
50
|
-
timeout: txMinedWaitSeconds,
|
|
51
|
-
});
|
|
47
|
+
const receipt = await waitForTx(this.node, txHash, { timeout: txMinedWaitSeconds });
|
|
52
48
|
if (followChain === 'PROVEN') {
|
|
53
49
|
await waitForProven(this.node, receipt, { provenTimeout: txMinedWaitSeconds });
|
|
54
50
|
}
|
|
@@ -63,7 +59,7 @@ export abstract class BaseBot {
|
|
|
63
59
|
return receipt;
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
protected abstract createAndSendTx(logCtx: object): Promise<
|
|
62
|
+
protected abstract createAndSendTx(logCtx: object): Promise<TxHash>;
|
|
67
63
|
|
|
68
64
|
protected onTxMined(_receipt: TxReceipt, _logCtx: object): Promise<void> {
|
|
69
65
|
// no-op
|
package/src/bot.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import { BatchCall,
|
|
2
|
+
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
3
4
|
import { times } from '@aztec/foundation/collection';
|
|
4
5
|
import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
5
6
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
7
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
7
|
-
import type {
|
|
8
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
8
9
|
|
|
9
10
|
import { BaseBot } from './base_bot.js';
|
|
10
11
|
import type { BotConfig } from './config.js';
|
|
@@ -17,7 +18,7 @@ const TRANSFER_AMOUNT = 1;
|
|
|
17
18
|
export class Bot extends BaseBot {
|
|
18
19
|
protected constructor(
|
|
19
20
|
node: AztecNode,
|
|
20
|
-
wallet:
|
|
21
|
+
wallet: EmbeddedWallet,
|
|
21
22
|
defaultAccountAddress: AztecAddress,
|
|
22
23
|
public readonly token: TokenContract | PrivateTokenContract,
|
|
23
24
|
public readonly recipient: AztecAddress,
|
|
@@ -28,7 +29,7 @@ export class Bot extends BaseBot {
|
|
|
28
29
|
|
|
29
30
|
static async create(
|
|
30
31
|
config: BotConfig,
|
|
31
|
-
wallet:
|
|
32
|
+
wallet: EmbeddedWallet,
|
|
32
33
|
aztecNode: AztecNode,
|
|
33
34
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
34
35
|
store: BotStore,
|
|
@@ -48,7 +49,7 @@ export class Bot extends BaseBot {
|
|
|
48
49
|
this.config = { ...this.config, ...config };
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
protected async createAndSendTx(logCtx: object): Promise<
|
|
52
|
+
protected async createAndSendTx(logCtx: object): Promise<TxHash> {
|
|
52
53
|
const { privateTransfersPerTx, publicTransfersPerTx, feePaymentMethod } = this.config;
|
|
53
54
|
const { token, recipient, wallet } = this;
|
|
54
55
|
|
|
@@ -75,7 +76,7 @@ export class Bot extends BaseBot {
|
|
|
75
76
|
await batch.simulate({ from: this.defaultAccountAddress });
|
|
76
77
|
|
|
77
78
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
78
|
-
return batch.send(opts);
|
|
79
|
+
return batch.send({ ...opts, wait: NO_WAIT });
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
public async getBalances() {
|
package/src/factory.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
2
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
2
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
3
|
import {
|
|
@@ -7,6 +6,7 @@ import {
|
|
|
7
6
|
ContractFunctionInteraction,
|
|
8
7
|
type DeployMethod,
|
|
9
8
|
type DeployOptions,
|
|
9
|
+
NO_WAIT,
|
|
10
10
|
} from '@aztec/aztec.js/contracts';
|
|
11
11
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
12
12
|
import type { L2AmountClaim } from '@aztec/aztec.js/ethereum';
|
|
@@ -14,6 +14,7 @@ import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
|
14
14
|
import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
15
15
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
16
16
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
17
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
17
18
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
18
19
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
19
20
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -25,7 +26,7 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
|
25
26
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
26
27
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
27
28
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
28
|
-
import {
|
|
29
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
29
30
|
|
|
30
31
|
import { type BotConfig, SupportedTokenContracts } from './config.js';
|
|
31
32
|
import type { BotStore } from './store/index.js';
|
|
@@ -39,7 +40,7 @@ export class BotFactory {
|
|
|
39
40
|
|
|
40
41
|
constructor(
|
|
41
42
|
private readonly config: BotConfig,
|
|
42
|
-
private readonly wallet:
|
|
43
|
+
private readonly wallet: EmbeddedWallet,
|
|
43
44
|
private readonly store: BotStore,
|
|
44
45
|
private readonly aztecNode: AztecNode,
|
|
45
46
|
private readonly aztecNodeAdmin?: AztecNodeAdmin,
|
|
@@ -50,21 +51,21 @@ export class BotFactory {
|
|
|
50
51
|
* deploying the token contract, and minting tokens if necessary.
|
|
51
52
|
*/
|
|
52
53
|
public async setup(): Promise<{
|
|
53
|
-
wallet:
|
|
54
|
+
wallet: EmbeddedWallet;
|
|
54
55
|
defaultAccountAddress: AztecAddress;
|
|
55
56
|
token: TokenContract | PrivateTokenContract;
|
|
56
57
|
node: AztecNode;
|
|
57
58
|
recipient: AztecAddress;
|
|
58
59
|
}> {
|
|
59
|
-
const recipient = (await this.wallet.createAccount()).address;
|
|
60
60
|
const defaultAccountAddress = await this.setupAccount();
|
|
61
|
+
const recipient = (await this.wallet.createSchnorrAccount(Fr.random(), Fr.random())).address;
|
|
61
62
|
const token = await this.setupToken(defaultAccountAddress);
|
|
62
63
|
await this.mintTokens(token, defaultAccountAddress);
|
|
63
64
|
return { wallet: this.wallet, defaultAccountAddress, token, node: this.aztecNode, recipient };
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
public async setupAmm(): Promise<{
|
|
67
|
-
wallet:
|
|
68
|
+
wallet: EmbeddedWallet;
|
|
68
69
|
defaultAccountAddress: AztecAddress;
|
|
69
70
|
amm: AMMContract;
|
|
70
71
|
token0: TokenContract;
|
|
@@ -112,14 +113,9 @@ export class BotFactory {
|
|
|
112
113
|
private async setupAccountWithPrivateKey(secret: Fr) {
|
|
113
114
|
const salt = this.config.senderSalt ?? Fr.ONE;
|
|
114
115
|
const signingKey = deriveSigningKey(secret);
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
contract: new SchnorrAccountContract(signingKey!),
|
|
119
|
-
};
|
|
120
|
-
const accountManager = await this.wallet.createAccount(accountData);
|
|
121
|
-
const isInit = (await this.wallet.getContractMetadata(accountManager.address)).isContractInitialized;
|
|
122
|
-
if (isInit) {
|
|
116
|
+
const accountManager = await this.wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
117
|
+
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
118
|
+
if (metadata.isContractInitialized) {
|
|
123
119
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
124
120
|
const timer = new Timer();
|
|
125
121
|
const address = accountManager.address;
|
|
@@ -136,10 +132,16 @@ export class BotFactory {
|
|
|
136
132
|
const deployMethod = await accountManager.getDeployMethod();
|
|
137
133
|
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
138
134
|
const gasSettings = GasSettings.default({ maxFeesPerGas });
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
|
|
136
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
137
|
+
const txHash = await deployMethod.send({
|
|
138
|
+
from: AztecAddress.ZERO,
|
|
139
|
+
fee: { gasSettings, paymentMethod },
|
|
140
|
+
wait: NO_WAIT,
|
|
141
|
+
});
|
|
142
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
143
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
144
|
+
});
|
|
143
145
|
this.log.info(`Account deployed at ${address}`);
|
|
144
146
|
|
|
145
147
|
// Clean up the consumed bridge claim
|
|
@@ -151,12 +153,11 @@ export class BotFactory {
|
|
|
151
153
|
|
|
152
154
|
private async setupTestAccount() {
|
|
153
155
|
const [initialAccountData] = await getInitialTestAccountsData();
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const accountManager = await this.wallet.createAccount(accountData);
|
|
156
|
+
const accountManager = await this.wallet.createSchnorrAccount(
|
|
157
|
+
initialAccountData.secret,
|
|
158
|
+
initialAccountData.salt,
|
|
159
|
+
initialAccountData.signingKey,
|
|
160
|
+
);
|
|
160
161
|
return accountManager.address;
|
|
161
162
|
}
|
|
162
163
|
|
|
@@ -173,8 +174,11 @@ export class BotFactory {
|
|
|
173
174
|
contractAddressSalt: this.config.tokenSalt,
|
|
174
175
|
universalDeploy: true,
|
|
175
176
|
};
|
|
177
|
+
let token: TokenContract | PrivateTokenContract;
|
|
176
178
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
177
179
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
180
|
+
tokenInstance = await deploy.getInstance(deployOpts);
|
|
181
|
+
token = TokenContract.at(tokenInstance.address, this.wallet);
|
|
178
182
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
179
183
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
180
184
|
const tokenSecretKey = Fr.random();
|
|
@@ -186,22 +190,27 @@ export class BotFactory {
|
|
|
186
190
|
|
|
187
191
|
// Register the contract with the secret key before deployment
|
|
188
192
|
tokenInstance = await deploy.getInstance(deployOpts);
|
|
193
|
+
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
189
194
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
190
195
|
} else {
|
|
191
196
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
const address = tokenInstance?.address ?? (await deploy.getInstance(deployOpts)).address;
|
|
195
|
-
|
|
200
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
201
|
+
if (metadata.isContractPublished) {
|
|
196
202
|
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
197
|
-
|
|
203
|
+
await deploy.register();
|
|
198
204
|
} else {
|
|
199
205
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
200
|
-
const
|
|
201
|
-
const txHash = await sentTx.getTxHash();
|
|
206
|
+
const txHash = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
202
207
|
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
203
|
-
|
|
208
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
209
|
+
await waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
210
|
+
return token;
|
|
211
|
+
});
|
|
204
212
|
}
|
|
213
|
+
return token;
|
|
205
214
|
}
|
|
206
215
|
|
|
207
216
|
/**
|
|
@@ -209,7 +218,7 @@ export class BotFactory {
|
|
|
209
218
|
* @param wallet - Wallet to deploy the token contract from.
|
|
210
219
|
* @returns The TokenContract instance.
|
|
211
220
|
*/
|
|
212
|
-
private setupTokenContract(
|
|
221
|
+
private async setupTokenContract(
|
|
213
222
|
deployer: AztecAddress,
|
|
214
223
|
contractAddressSalt: Fr,
|
|
215
224
|
name: string,
|
|
@@ -218,7 +227,8 @@ export class BotFactory {
|
|
|
218
227
|
): Promise<TokenContract> {
|
|
219
228
|
const deployOpts: DeployOptions = { from: deployer, contractAddressSalt, universalDeploy: true };
|
|
220
229
|
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals);
|
|
221
|
-
|
|
230
|
+
const instance = await this.registerOrDeployContract('Token - ' + name, deploy, deployOpts);
|
|
231
|
+
return TokenContract.at(instance.address, this.wallet);
|
|
222
232
|
}
|
|
223
233
|
|
|
224
234
|
private async setupAmmContract(
|
|
@@ -230,12 +240,14 @@ export class BotFactory {
|
|
|
230
240
|
): Promise<AMMContract> {
|
|
231
241
|
const deployOpts: DeployOptions = { from: deployer, contractAddressSalt, universalDeploy: true };
|
|
232
242
|
const deploy = AMMContract.deploy(this.wallet, token0.address, token1.address, lpToken.address);
|
|
233
|
-
const
|
|
243
|
+
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
244
|
+
const amm = AMMContract.at(instance.address, this.wallet);
|
|
234
245
|
|
|
235
246
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
const minterReceipt = await lpToken.methods
|
|
248
|
+
.set_minter(amm.address, true)
|
|
249
|
+
.send({ from: deployer, wait: { timeout: this.config.txMinedWaitSeconds } });
|
|
250
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`);
|
|
239
251
|
this.log.info(`Liquidity token initialized`);
|
|
240
252
|
|
|
241
253
|
return amm;
|
|
@@ -294,23 +306,22 @@ export class BotFactory {
|
|
|
294
306
|
.getFunctionCall(),
|
|
295
307
|
});
|
|
296
308
|
|
|
297
|
-
const
|
|
309
|
+
const mintReceipt = await new BatchCall(this.wallet, [
|
|
298
310
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
299
311
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
300
|
-
]).send({ from: liquidityProvider });
|
|
312
|
+
]).send({ from: liquidityProvider, wait: { timeout: this.config.txMinedWaitSeconds } });
|
|
301
313
|
|
|
302
|
-
this.log.info(`Sent mint tx: ${
|
|
303
|
-
await mintTx.wait({ timeout: this.config.txMinedWaitSeconds });
|
|
314
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
304
315
|
|
|
305
|
-
const
|
|
316
|
+
const addLiquidityReceipt = await amm.methods
|
|
306
317
|
.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce)
|
|
307
318
|
.send({
|
|
308
319
|
from: liquidityProvider,
|
|
309
320
|
authWitnesses: [token0Authwit, token1Authwit],
|
|
321
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
310
322
|
});
|
|
311
323
|
|
|
312
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${
|
|
313
|
-
await addLiquidityTx.wait({ timeout: this.config.txMinedWaitSeconds });
|
|
324
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
314
325
|
this.log.info(`Liquidity added`);
|
|
315
326
|
|
|
316
327
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
@@ -323,18 +334,22 @@ export class BotFactory {
|
|
|
323
334
|
name: string,
|
|
324
335
|
deploy: DeployMethod<T>,
|
|
325
336
|
deployOpts: DeployOptions,
|
|
326
|
-
): Promise<
|
|
327
|
-
const
|
|
328
|
-
|
|
337
|
+
): Promise<ContractInstanceWithAddress> {
|
|
338
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
339
|
+
const address = instance.address;
|
|
340
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
341
|
+
if (metadata.isContractPublished) {
|
|
329
342
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
330
|
-
|
|
343
|
+
await deploy.register();
|
|
331
344
|
} else {
|
|
332
345
|
this.log.info(`Deploying contract ${name} at ${address.toString()}`);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
346
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
347
|
+
const txHash = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
348
|
+
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
349
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
350
|
+
});
|
|
337
351
|
}
|
|
352
|
+
return instance;
|
|
338
353
|
}
|
|
339
354
|
|
|
340
355
|
/**
|
|
@@ -370,10 +385,12 @@ export class BotFactory {
|
|
|
370
385
|
this.log.info(`Skipping minting as ${minter.toString()} has enough tokens`);
|
|
371
386
|
return;
|
|
372
387
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
388
|
+
|
|
389
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
390
|
+
const txHash = await new BatchCall(token.wallet, calls).send({ from: minter, wait: NO_WAIT });
|
|
391
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`);
|
|
392
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
393
|
+
});
|
|
377
394
|
}
|
|
378
395
|
|
|
379
396
|
/**
|
package/src/runner.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { omit } from '@aztec/foundation/collection';
|
|
|
4
4
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
5
5
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
6
6
|
import { type TelemetryClient, type Traceable, type Tracer, trackSpan } from '@aztec/telemetry-client';
|
|
7
|
-
import type {
|
|
7
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
8
8
|
|
|
9
9
|
import { AmmBot } from './amm_bot.js';
|
|
10
10
|
import type { BaseBot } from './base_bot.js';
|
|
@@ -24,7 +24,7 @@ export class BotRunner implements BotRunnerApi, Traceable {
|
|
|
24
24
|
|
|
25
25
|
public constructor(
|
|
26
26
|
private config: BotConfig,
|
|
27
|
-
private readonly wallet:
|
|
27
|
+
private readonly wallet: EmbeddedWallet,
|
|
28
28
|
private readonly aztecNode: AztecNode,
|
|
29
29
|
private readonly telemetry: TelemetryClient,
|
|
30
30
|
private readonly aztecNodeAdmin: AztecNodeAdmin | undefined,
|