@aztec/bot 0.0.1-commit.f295ac2 → 0.0.1-commit.f8ca9b2f3
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 +78 -66
- package/dest/runner.d.ts +3 -3
- package/dest/runner.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/amm_bot.ts +7 -7
- package/src/base_bot.ts +6 -10
- package/src/bot.ts +7 -6
- package/src/factory.ts +65 -50
- 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1tX2JvdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FtbV9ib3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3pELE9BQU8sRUFBRSxNQUFNLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFdkQsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLGNBQWMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FB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UFBRSxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FHcEY7SUFFTSxjQUFjLElBQUksT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUV6QztJQUVZLFdBQVcsSUFBSSxPQUFPLENBQUM7UUFBRSxZQUFZLEVBQUUsUUFBUSxDQUFDO1FBQUMsYUFBYSxFQUFFLFFBQVEsQ0FBQztRQUFDLEdBQUcsRUFBRSxRQUFRLENBQUE7S0FBRSxDQUFDLENBTXRHO1lBRWEsbUJBQW1CO1lBTW5CLG9CQUFvQjtDQU1uQyJ9
|
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>;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TLEdBQUcsSUFBSSxPQUFPLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxDQThCOUM7SUFFRCxTQUFTLENBQUMsUUFBUSxDQUFDLGVBQWUsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUVwRSxTQUFTLENBQUMsU0FBUyxDQUFDLFFBQVEsRUFBRSxTQUFTLEVBQUUsT0FBTyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBR3ZFO0lBRUQsVUFBZ0IsaUJBQWlCLENBQy9CLFdBQVcsRUFBRSwyQkFBMkIsR0FBRyxTQUFTLEdBQ25ELE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQW9CakM7Q0FDRiJ9
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBb0J6RCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDM0QsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sdUNBQXVDLENBQUM7QUFDN0UsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRy9ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVqRixPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFekQsT0F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VMsQ0FBQztLQUNqQixDQUFDLENBc0JEO1lBTWEsWUFBWTtZQVdaLDBCQUEwQjtZQXlDMUIsZ0JBQWdCO1lBZWhCLFVBQVU7WUFvRFYsa0JBQWtCO1lBYWxCLGdCQUFnQjtZQXNCaEIsT0FBTztZQTZFUCx3QkFBd0I7WUEwQnhCLFVBQVU7WUEwQ1Ysc0JBQXNCO1lBNEJ0QixnQkFBZ0I7WUFnQ2hCLG9CQUFvQjtDQWVuQyJ9
|
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';
|
|
@@ -40,7 +40,7 @@ export class BotFactory {
|
|
|
40
40
|
* deploying the token contract, and minting tokens if necessary.
|
|
41
41
|
*/ async setup() {
|
|
42
42
|
const defaultAccountAddress = await this.setupAccount();
|
|
43
|
-
const recipient = (await this.wallet.
|
|
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,12 +84,7 @@ 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
|
-
secret,
|
|
89
|
-
salt,
|
|
90
|
-
contract: new SchnorrAccountContract(signingKey)
|
|
91
|
-
};
|
|
92
|
-
const accountManager = await this.wallet.createAccount(accountData);
|
|
87
|
+
const accountManager = await this.wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
93
88
|
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
94
89
|
if (metadata.isContractInitialized) {
|
|
95
90
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
@@ -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,6 +155,7 @@ 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}`);
|
|
@@ -168,29 +164,36 @@ export class BotFactory {
|
|
|
168
164
|
const metadata = await this.wallet.getContractMetadata(address);
|
|
169
165
|
if (metadata.isContractPublished) {
|
|
170
166
|
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
171
|
-
|
|
167
|
+
await deploy.register();
|
|
172
168
|
} else {
|
|
173
169
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
174
|
-
const
|
|
175
|
-
|
|
170
|
+
const txHash = await deploy.send({
|
|
171
|
+
...deployOpts,
|
|
172
|
+
wait: NO_WAIT
|
|
173
|
+
});
|
|
176
174
|
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
177
|
-
|
|
175
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
176
|
+
await waitForTx(this.aztecNode, txHash, {
|
|
178
177
|
timeout: this.config.txMinedWaitSeconds
|
|
179
|
-
})
|
|
178
|
+
});
|
|
179
|
+
return token;
|
|
180
|
+
});
|
|
180
181
|
}
|
|
182
|
+
return token;
|
|
181
183
|
}
|
|
182
184
|
/**
|
|
183
185
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
184
186
|
* @param wallet - Wallet to deploy the token contract from.
|
|
185
187
|
* @returns The TokenContract instance.
|
|
186
|
-
*/ setupTokenContract(deployer, contractAddressSalt, name, ticker, decimals = 18) {
|
|
188
|
+
*/ async setupTokenContract(deployer, contractAddressSalt, name, ticker, decimals = 18) {
|
|
187
189
|
const deployOpts = {
|
|
188
190
|
from: deployer,
|
|
189
191
|
contractAddressSalt,
|
|
190
192
|
universalDeploy: true
|
|
191
193
|
};
|
|
192
194
|
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals);
|
|
193
|
-
|
|
195
|
+
const instance = await this.registerOrDeployContract('Token - ' + name, deploy, deployOpts);
|
|
196
|
+
return TokenContract.at(instance.address, this.wallet);
|
|
194
197
|
}
|
|
195
198
|
async setupAmmContract(deployer, contractAddressSalt, token0, token1, lpToken) {
|
|
196
199
|
const deployOpts = {
|
|
@@ -199,15 +202,16 @@ export class BotFactory {
|
|
|
199
202
|
universalDeploy: true
|
|
200
203
|
};
|
|
201
204
|
const deploy = AMMContract.deploy(this.wallet, token0.address, token1.address, lpToken.address);
|
|
202
|
-
const
|
|
205
|
+
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
206
|
+
const amm = AMMContract.at(instance.address, this.wallet);
|
|
203
207
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
204
|
-
const
|
|
205
|
-
from: deployer
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
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
|
+
}
|
|
210
213
|
});
|
|
214
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`);
|
|
211
215
|
this.log.info(`Liquidity token initialized`);
|
|
212
216
|
return amm;
|
|
213
217
|
}
|
|
@@ -240,46 +244,52 @@ export class BotFactory {
|
|
|
240
244
|
caller: amm.address,
|
|
241
245
|
call: await token1.methods.transfer_to_public_and_prepare_private_balance_increase(liquidityProvider, amm.address, amount1Max, authwitNonce).getFunctionCall()
|
|
242
246
|
});
|
|
243
|
-
const
|
|
247
|
+
const mintReceipt = await new BatchCall(this.wallet, [
|
|
244
248
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
245
249
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE)
|
|
246
250
|
]).send({
|
|
247
|
-
from: liquidityProvider
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
timeout: this.config.txMinedWaitSeconds
|
|
251
|
+
from: liquidityProvider,
|
|
252
|
+
wait: {
|
|
253
|
+
timeout: this.config.txMinedWaitSeconds
|
|
254
|
+
}
|
|
252
255
|
});
|
|
253
|
-
|
|
256
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
257
|
+
const addLiquidityReceipt = await amm.methods.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce).send({
|
|
254
258
|
from: liquidityProvider,
|
|
255
259
|
authWitnesses: [
|
|
256
260
|
token0Authwit,
|
|
257
261
|
token1Authwit
|
|
258
|
-
]
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
timeout: this.config.txMinedWaitSeconds
|
|
262
|
+
],
|
|
263
|
+
wait: {
|
|
264
|
+
timeout: this.config.txMinedWaitSeconds
|
|
265
|
+
}
|
|
263
266
|
});
|
|
267
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
264
268
|
this.log.info(`Liquidity added`);
|
|
265
269
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
266
270
|
this.log.info(`Updated private balances of ${defaultAccountAddress} after minting and funding AMM: token0=${newT0Bal}, token1=${newT1Bal}, lp=${newLPBal}`);
|
|
267
271
|
}
|
|
268
272
|
async registerOrDeployContract(name, deploy, deployOpts) {
|
|
269
|
-
const
|
|
273
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
274
|
+
const address = instance.address;
|
|
270
275
|
const metadata = await this.wallet.getContractMetadata(address);
|
|
271
276
|
if (metadata.isContractPublished) {
|
|
272
277
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
273
|
-
|
|
278
|
+
await deploy.register();
|
|
274
279
|
} else {
|
|
275
280
|
this.log.info(`Deploying contract ${name} at ${address.toString()}`);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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, {
|
|
280
288
|
timeout: this.config.txMinedWaitSeconds
|
|
281
|
-
})
|
|
289
|
+
});
|
|
290
|
+
});
|
|
282
291
|
}
|
|
292
|
+
return instance;
|
|
283
293
|
}
|
|
284
294
|
/**
|
|
285
295
|
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
@@ -306,14 +316,16 @@ export class BotFactory {
|
|
|
306
316
|
this.log.info(`Skipping minting as ${minter.toString()} has enough tokens`);
|
|
307
317
|
return;
|
|
308
318
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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, {
|
|
315
326
|
timeout: this.config.txMinedWaitSeconds
|
|
316
|
-
})
|
|
327
|
+
});
|
|
328
|
+
});
|
|
317
329
|
}
|
|
318
330
|
/**
|
|
319
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
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVubmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcnVubmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBR3RELE9BQU8sS0FBSyxFQUFFLGNBQ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UFDMUIsY0FBYyxFQUFFLGNBQWMsR0FBRyxTQUFTLEVBQzFDLEtBQUssRUFBRSxRQUFRLEVBS2pDO0lBRUQsNkVBQTZFO0lBQ2hFLEtBQUssa0JBSWpCO1lBR2EsT0FBTztJQU1yQjs7O09BR0c7SUFDVSxLQUFLLGtCQU1qQjtJQUVEOztPQUVHO0lBQ1UsSUFBSSxrQkFPaEI7SUFFTSxTQUFTLFlBRWY7SUFFRCwwQ0FBMEM7SUFDbkMsU0FBUyxZQUVmO0lBRUQ7OztPQUdHO0lBQ1UsTUFBTSxDQUFDLE1BQU0sRUFBRSxTQUFTLGlCQWFwQztJQUVEOzs7T0FHRztJQUNVLEdBQUcsa0JBc0JmO0lBRUQscURBQXFEO0lBQzlDLFNBQVMsdUJBR2Y7SUFFRCxzQ0FBc0M7SUFDekIsT0FBTyxJQUFJLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FNdkM7Q0F1Q0YifQ==
|
package/dest/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAa,MAAM,yBAAyB,CAAC;AACvG,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAa,MAAM,yBAAyB,CAAC;AACvG,OAA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ED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bot",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.f8ca9b2f3",
|
|
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.f8ca9b2f3",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.f8ca9b2f3",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.f8ca9b2f3",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.f8ca9b2f3",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.f8ca9b2f3",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.f8ca9b2f3",
|
|
63
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.f8ca9b2f3",
|
|
64
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.f8ca9b2f3",
|
|
65
|
+
"@aztec/protocol-contracts": "0.0.1-commit.f8ca9b2f3",
|
|
66
|
+
"@aztec/stdlib": "0.0.1-commit.f8ca9b2f3",
|
|
67
|
+
"@aztec/telemetry-client": "0.0.1-commit.f8ca9b2f3",
|
|
68
|
+
"@aztec/wallets": "0.0.1-commit.f8ca9b2f3",
|
|
69
69
|
"source-map-support": "^0.5.21",
|
|
70
70
|
"tslib": "^2.4.0",
|
|
71
71
|
"zod": "^3.23.8"
|
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
60
|
const defaultAccountAddress = await this.setupAccount();
|
|
60
|
-
const recipient = (await this.wallet.
|
|
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,12 +113,7 @@ 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
|
-
secret,
|
|
117
|
-
salt,
|
|
118
|
-
contract: new SchnorrAccountContract(signingKey!),
|
|
119
|
-
};
|
|
120
|
-
const accountManager = await this.wallet.createAccount(accountData);
|
|
116
|
+
const accountManager = await this.wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
121
117
|
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
122
118
|
if (metadata.isContractInitialized) {
|
|
123
119
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
@@ -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,6 +190,7 @@ 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}`);
|
|
@@ -195,14 +200,17 @@ export class BotFactory {
|
|
|
195
200
|
const metadata = await this.wallet.getContractMetadata(address);
|
|
196
201
|
if (metadata.isContractPublished) {
|
|
197
202
|
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
198
|
-
|
|
203
|
+
await deploy.register();
|
|
199
204
|
} else {
|
|
200
205
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
201
|
-
const
|
|
202
|
-
const txHash = await sentTx.getTxHash();
|
|
206
|
+
const txHash = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
203
207
|
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
204
|
-
|
|
208
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
209
|
+
await waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
210
|
+
return token;
|
|
211
|
+
});
|
|
205
212
|
}
|
|
213
|
+
return token;
|
|
206
214
|
}
|
|
207
215
|
|
|
208
216
|
/**
|
|
@@ -210,7 +218,7 @@ export class BotFactory {
|
|
|
210
218
|
* @param wallet - Wallet to deploy the token contract from.
|
|
211
219
|
* @returns The TokenContract instance.
|
|
212
220
|
*/
|
|
213
|
-
private setupTokenContract(
|
|
221
|
+
private async setupTokenContract(
|
|
214
222
|
deployer: AztecAddress,
|
|
215
223
|
contractAddressSalt: Fr,
|
|
216
224
|
name: string,
|
|
@@ -219,7 +227,8 @@ export class BotFactory {
|
|
|
219
227
|
): Promise<TokenContract> {
|
|
220
228
|
const deployOpts: DeployOptions = { from: deployer, contractAddressSalt, universalDeploy: true };
|
|
221
229
|
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals);
|
|
222
|
-
|
|
230
|
+
const instance = await this.registerOrDeployContract('Token - ' + name, deploy, deployOpts);
|
|
231
|
+
return TokenContract.at(instance.address, this.wallet);
|
|
223
232
|
}
|
|
224
233
|
|
|
225
234
|
private async setupAmmContract(
|
|
@@ -231,12 +240,14 @@ export class BotFactory {
|
|
|
231
240
|
): Promise<AMMContract> {
|
|
232
241
|
const deployOpts: DeployOptions = { from: deployer, contractAddressSalt, universalDeploy: true };
|
|
233
242
|
const deploy = AMMContract.deploy(this.wallet, token0.address, token1.address, lpToken.address);
|
|
234
|
-
const
|
|
243
|
+
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
244
|
+
const amm = AMMContract.at(instance.address, this.wallet);
|
|
235
245
|
|
|
236
246
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
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()}`);
|
|
240
251
|
this.log.info(`Liquidity token initialized`);
|
|
241
252
|
|
|
242
253
|
return amm;
|
|
@@ -295,23 +306,22 @@ export class BotFactory {
|
|
|
295
306
|
.getFunctionCall(),
|
|
296
307
|
});
|
|
297
308
|
|
|
298
|
-
const
|
|
309
|
+
const mintReceipt = await new BatchCall(this.wallet, [
|
|
299
310
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
300
311
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
301
|
-
]).send({ from: liquidityProvider });
|
|
312
|
+
]).send({ from: liquidityProvider, wait: { timeout: this.config.txMinedWaitSeconds } });
|
|
302
313
|
|
|
303
|
-
this.log.info(`Sent mint tx: ${
|
|
304
|
-
await mintTx.wait({ timeout: this.config.txMinedWaitSeconds });
|
|
314
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
305
315
|
|
|
306
|
-
const
|
|
316
|
+
const addLiquidityReceipt = await amm.methods
|
|
307
317
|
.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce)
|
|
308
318
|
.send({
|
|
309
319
|
from: liquidityProvider,
|
|
310
320
|
authWitnesses: [token0Authwit, token1Authwit],
|
|
321
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
311
322
|
});
|
|
312
323
|
|
|
313
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${
|
|
314
|
-
await addLiquidityTx.wait({ timeout: this.config.txMinedWaitSeconds });
|
|
324
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
315
325
|
this.log.info(`Liquidity added`);
|
|
316
326
|
|
|
317
327
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
@@ -324,19 +334,22 @@ export class BotFactory {
|
|
|
324
334
|
name: string,
|
|
325
335
|
deploy: DeployMethod<T>,
|
|
326
336
|
deployOpts: DeployOptions,
|
|
327
|
-
): Promise<
|
|
328
|
-
const
|
|
337
|
+
): Promise<ContractInstanceWithAddress> {
|
|
338
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
339
|
+
const address = instance.address;
|
|
329
340
|
const metadata = await this.wallet.getContractMetadata(address);
|
|
330
341
|
if (metadata.isContractPublished) {
|
|
331
342
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
332
|
-
|
|
343
|
+
await deploy.register();
|
|
333
344
|
} else {
|
|
334
345
|
this.log.info(`Deploying contract ${name} at ${address.toString()}`);
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
+
});
|
|
339
351
|
}
|
|
352
|
+
return instance;
|
|
340
353
|
}
|
|
341
354
|
|
|
342
355
|
/**
|
|
@@ -372,10 +385,12 @@ export class BotFactory {
|
|
|
372
385
|
this.log.info(`Skipping minting as ${minter.toString()} has enough tokens`);
|
|
373
386
|
return;
|
|
374
387
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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
|
+
});
|
|
379
394
|
}
|
|
380
395
|
|
|
381
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,
|