@aztec/bot 0.0.1-commit.96bb3f7 → 0.0.1-commit.9d2bcf6d
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 +3 -4
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +5 -1
- package/dest/base_bot.d.ts +3 -3
- package/dest/base_bot.d.ts.map +1 -1
- package/dest/base_bot.js +3 -3
- package/dest/bot.d.ts +3 -3
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +5 -2
- package/dest/factory.d.ts +1 -6
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +82 -57
- 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 +4 -4
- package/src/base_bot.ts +4 -8
- package/src/bot.ts +4 -3
- package/src/factory.ts +61 -37
package/dest/amm_bot.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
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';
|
|
@@ -18,7 +17,7 @@ export declare class AmmBot extends BaseBot {
|
|
|
18
17
|
readonly token1: TokenContract;
|
|
19
18
|
protected constructor(node: AztecNode, wallet: TestWallet, defaultAccountAddress: AztecAddress, amm: AMMContract, token0: TokenContract, token1: TokenContract, config: BotConfig);
|
|
20
19
|
static create(config: BotConfig, wallet: TestWallet, aztecNode: AztecNode, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore): Promise<AmmBot>;
|
|
21
|
-
protected createAndSendTx(logCtx: object): Promise<
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1tX2JvdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FtbV9ib3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3pELE9BQU8sRUFBRSxNQUFNLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFdkQsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLGNBQWMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pGLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTVELE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDeEMsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBRTdDLE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBS2pELEtBQUss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7S0FBRSxDQUFDLENBTXRHO1lBRWEsbUJBQW1CO1lBTW5CLG9CQUFvQjtDQU1uQyJ9
|
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,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,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,UAAU,EAClB,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,UAAU,EAClB,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,5 +1,5 @@
|
|
|
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
5
|
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
@@ -14,8 +14,8 @@ export declare abstract class BaseBot {
|
|
|
14
14
|
protected successes: number;
|
|
15
15
|
protected constructor(node: AztecNode, wallet: TestWallet, 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV9ib3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9iYXNlX2JvdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDekQsT0FBTyxFQUNMLFNBQVMsRUFDVCwyQkFBMkIsRUFDM0IsS0FBSyxzQkFBc0IsRUFFNUIsTUFBTSwyQkFBMkIsQ0FBQztBQUduQyxPQUFPLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXZELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQ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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,5 +1,5 @@
|
|
|
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';
|
|
@@ -13,7 +13,7 @@ export declare class Bot extends BaseBot {
|
|
|
13
13
|
protected constructor(node: AztecNode, wallet: TestWallet, defaultAccountAddress: AztecAddress, token: TokenContract | PrivateTokenContract, recipient: AztecAddress, config: BotConfig);
|
|
14
14
|
static create(config: BotConfig, wallet: TestWallet, 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTlELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU1QyxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQ2xGLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQzt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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
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3Rv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M7UUFDbkIscUJBQXFCLEVBQUUsWUFBWSxDQUFDO1FBQ3BDLEtBQUssRUFBRSxhQUFhLEdBQUcsb0JBQW9CLENBQUM7UUFDNUMsSUFBSSxFQUFFLFNBQVMsQ0FBQztRQUNoQixTQUFTLEVBQUUsWUFBWSxDQUFDO0tBQ3pCLENBQUMsQ0FNRDtJQUVZLFFBQVEsSUFBSSxPQUFPLENBQUM7UUFDL0IsTUFBTSxFQUFFLFVBQVUsQ0FBQztRQUNuQixxQkFBcUIsRUFBRSxZQUFZLENBQUM7UUFDcEMsR0FBRyxFQUFFLFdBQVcsQ0FBQztRQUNqQixNQUFNLEVBQUUsYUFBYSxDQUFDO1FBQ3RCLE1BQU0sRUFBRSxhQUFhLENBQUM7UUFDdEIsSUFBSSxFQUFFLFNBQVMsQ0FBQztLQUNqQixDQUFDLENBc0JEO1lBTWEsWUFBWTtZQVdaLDBCQUEwQjtZQThDMUIsZ0JBQWdCO1lBZ0JoQixVQUFVO1lBb0RWLGtCQUFrQjtZQWFsQixnQkFBZ0I7WUFzQmhCLE9BQU87WUE2RVAsd0JBQXdCO1lBMEJ4QixVQUFVO1lBMENWLHNCQUFzQjtZQTRCdEIsZ0JBQWdCO1lBZ0NoQixvQkFBb0I7Q0FlbkMifQ==
|
package/dest/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAoBzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gC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A0CV,sBAAsB;YA4BtB,gBAAgB;YAgChB,oBAAoB;CAenC"}
|
package/dest/factory.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
2
2
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
3
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
-
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
5
5
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
6
6
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
7
7
|
import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
8
8
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
9
9
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
10
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
10
11
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
11
12
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
12
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -39,8 +40,8 @@ export class BotFactory {
|
|
|
39
40
|
* Initializes a new bot by setting up the sender account, registering the recipient,
|
|
40
41
|
* deploying the token contract, and minting tokens if necessary.
|
|
41
42
|
*/ async setup() {
|
|
42
|
-
const recipient = (await this.wallet.createAccount()).address;
|
|
43
43
|
const defaultAccountAddress = await this.setupAccount();
|
|
44
|
+
const recipient = (await this.wallet.createAccount()).address;
|
|
44
45
|
const token = await this.setupToken(defaultAccountAddress);
|
|
45
46
|
await this.mintTokens(token, defaultAccountAddress);
|
|
46
47
|
return {
|
|
@@ -90,8 +91,8 @@ export class BotFactory {
|
|
|
90
91
|
contract: new SchnorrAccountContract(signingKey)
|
|
91
92
|
};
|
|
92
93
|
const accountManager = await this.wallet.createAccount(accountData);
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
94
|
+
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
95
|
+
if (metadata.isContractInitialized) {
|
|
95
96
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
96
97
|
const timer = new Timer();
|
|
97
98
|
const address = accountManager.address;
|
|
@@ -108,18 +109,20 @@ export class BotFactory {
|
|
|
108
109
|
const gasSettings = GasSettings.default({
|
|
109
110
|
maxFeesPerGas
|
|
110
111
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
113
|
+
const txHash = await deployMethod.send({
|
|
114
|
+
from: AztecAddress.ZERO,
|
|
115
|
+
fee: {
|
|
116
|
+
gasSettings,
|
|
117
|
+
paymentMethod
|
|
118
|
+
},
|
|
119
|
+
wait: NO_WAIT
|
|
120
|
+
});
|
|
121
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
122
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
121
123
|
timeout: this.config.txMinedWaitSeconds
|
|
122
|
-
})
|
|
124
|
+
});
|
|
125
|
+
});
|
|
123
126
|
this.log.info(`Account deployed at ${address}`);
|
|
124
127
|
// Clean up the consumed bridge claim
|
|
125
128
|
await this.store.deleteBridgeClaim(address);
|
|
@@ -148,8 +151,11 @@ export class BotFactory {
|
|
|
148
151
|
contractAddressSalt: this.config.tokenSalt,
|
|
149
152
|
universalDeploy: true
|
|
150
153
|
};
|
|
154
|
+
let token;
|
|
151
155
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
152
156
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
157
|
+
tokenInstance = await deploy.getInstance(deployOpts);
|
|
158
|
+
token = TokenContract.at(tokenInstance.address, this.wallet);
|
|
153
159
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
154
160
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
155
161
|
const tokenSecretKey = Fr.random();
|
|
@@ -160,36 +166,45 @@ export class BotFactory {
|
|
|
160
166
|
deployOpts.skipInitialization = false;
|
|
161
167
|
// Register the contract with the secret key before deployment
|
|
162
168
|
tokenInstance = await deploy.getInstance(deployOpts);
|
|
169
|
+
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
163
170
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
164
171
|
} else {
|
|
165
172
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
166
173
|
}
|
|
167
174
|
const address = tokenInstance?.address ?? (await deploy.getInstance(deployOpts)).address;
|
|
168
|
-
|
|
175
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
176
|
+
if (metadata.isContractPublished) {
|
|
169
177
|
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
170
|
-
|
|
178
|
+
await deploy.register();
|
|
171
179
|
} else {
|
|
172
180
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
173
|
-
const
|
|
174
|
-
|
|
181
|
+
const txHash = await deploy.send({
|
|
182
|
+
...deployOpts,
|
|
183
|
+
wait: NO_WAIT
|
|
184
|
+
});
|
|
175
185
|
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
176
|
-
|
|
186
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
187
|
+
await waitForTx(this.aztecNode, txHash, {
|
|
177
188
|
timeout: this.config.txMinedWaitSeconds
|
|
178
|
-
})
|
|
189
|
+
});
|
|
190
|
+
return token;
|
|
191
|
+
});
|
|
179
192
|
}
|
|
193
|
+
return token;
|
|
180
194
|
}
|
|
181
195
|
/**
|
|
182
196
|
* Checks if the token contract is deployed and deploys it if necessary.
|
|
183
197
|
* @param wallet - Wallet to deploy the token contract from.
|
|
184
198
|
* @returns The TokenContract instance.
|
|
185
|
-
*/ setupTokenContract(deployer, contractAddressSalt, name, ticker, decimals = 18) {
|
|
199
|
+
*/ async setupTokenContract(deployer, contractAddressSalt, name, ticker, decimals = 18) {
|
|
186
200
|
const deployOpts = {
|
|
187
201
|
from: deployer,
|
|
188
202
|
contractAddressSalt,
|
|
189
203
|
universalDeploy: true
|
|
190
204
|
};
|
|
191
205
|
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals);
|
|
192
|
-
|
|
206
|
+
const instance = await this.registerOrDeployContract('Token - ' + name, deploy, deployOpts);
|
|
207
|
+
return TokenContract.at(instance.address, this.wallet);
|
|
193
208
|
}
|
|
194
209
|
async setupAmmContract(deployer, contractAddressSalt, token0, token1, lpToken) {
|
|
195
210
|
const deployOpts = {
|
|
@@ -198,15 +213,16 @@ export class BotFactory {
|
|
|
198
213
|
universalDeploy: true
|
|
199
214
|
};
|
|
200
215
|
const deploy = AMMContract.deploy(this.wallet, token0.address, token1.address, lpToken.address);
|
|
201
|
-
const
|
|
216
|
+
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
217
|
+
const amm = AMMContract.at(instance.address, this.wallet);
|
|
202
218
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
203
|
-
const
|
|
204
|
-
from: deployer
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
timeout: this.config.txMinedWaitSeconds
|
|
219
|
+
const minterReceipt = await lpToken.methods.set_minter(amm.address, true).send({
|
|
220
|
+
from: deployer,
|
|
221
|
+
wait: {
|
|
222
|
+
timeout: this.config.txMinedWaitSeconds
|
|
223
|
+
}
|
|
209
224
|
});
|
|
225
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`);
|
|
210
226
|
this.log.info(`Liquidity token initialized`);
|
|
211
227
|
return amm;
|
|
212
228
|
}
|
|
@@ -239,45 +255,52 @@ export class BotFactory {
|
|
|
239
255
|
caller: amm.address,
|
|
240
256
|
call: await token1.methods.transfer_to_public_and_prepare_private_balance_increase(liquidityProvider, amm.address, amount1Max, authwitNonce).getFunctionCall()
|
|
241
257
|
});
|
|
242
|
-
const
|
|
258
|
+
const mintReceipt = await new BatchCall(this.wallet, [
|
|
243
259
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
244
260
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE)
|
|
245
261
|
]).send({
|
|
246
|
-
from: liquidityProvider
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
timeout: this.config.txMinedWaitSeconds
|
|
262
|
+
from: liquidityProvider,
|
|
263
|
+
wait: {
|
|
264
|
+
timeout: this.config.txMinedWaitSeconds
|
|
265
|
+
}
|
|
251
266
|
});
|
|
252
|
-
|
|
267
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
268
|
+
const addLiquidityReceipt = await amm.methods.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce).send({
|
|
253
269
|
from: liquidityProvider,
|
|
254
270
|
authWitnesses: [
|
|
255
271
|
token0Authwit,
|
|
256
272
|
token1Authwit
|
|
257
|
-
]
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
timeout: this.config.txMinedWaitSeconds
|
|
273
|
+
],
|
|
274
|
+
wait: {
|
|
275
|
+
timeout: this.config.txMinedWaitSeconds
|
|
276
|
+
}
|
|
262
277
|
});
|
|
278
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
263
279
|
this.log.info(`Liquidity added`);
|
|
264
280
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
265
281
|
this.log.info(`Updated private balances of ${defaultAccountAddress} after minting and funding AMM: token0=${newT0Bal}, token1=${newT1Bal}, lp=${newLPBal}`);
|
|
266
282
|
}
|
|
267
283
|
async registerOrDeployContract(name, deploy, deployOpts) {
|
|
268
|
-
const
|
|
269
|
-
|
|
284
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
285
|
+
const address = instance.address;
|
|
286
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
287
|
+
if (metadata.isContractPublished) {
|
|
270
288
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
271
|
-
|
|
289
|
+
await deploy.register();
|
|
272
290
|
} else {
|
|
273
291
|
this.log.info(`Deploying contract ${name} at ${address.toString()}`);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
292
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
293
|
+
const txHash = await deploy.send({
|
|
294
|
+
...deployOpts,
|
|
295
|
+
wait: NO_WAIT
|
|
296
|
+
});
|
|
297
|
+
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
298
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
278
299
|
timeout: this.config.txMinedWaitSeconds
|
|
279
|
-
})
|
|
300
|
+
});
|
|
301
|
+
});
|
|
280
302
|
}
|
|
303
|
+
return instance;
|
|
281
304
|
}
|
|
282
305
|
/**
|
|
283
306
|
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
@@ -304,14 +327,16 @@ export class BotFactory {
|
|
|
304
327
|
this.log.info(`Skipping minting as ${minter.toString()} has enough tokens`);
|
|
305
328
|
return;
|
|
306
329
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
330
|
+
await this.withNoMinTxsPerBlock(async ()=>{
|
|
331
|
+
const txHash = await new BatchCall(token.wallet, calls).send({
|
|
332
|
+
from: minter,
|
|
333
|
+
wait: NO_WAIT
|
|
334
|
+
});
|
|
335
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`);
|
|
336
|
+
return waitForTx(this.aztecNode, txHash, {
|
|
313
337
|
timeout: this.config.txMinedWaitSeconds
|
|
314
|
-
})
|
|
338
|
+
});
|
|
339
|
+
});
|
|
315
340
|
}
|
|
316
341
|
/**
|
|
317
342
|
* Gets or creates a bridge claim for the recipient.
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RvcmUvYm90X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUU5RCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFFeEUsTUFBTSxXQUFXLGVBQWU7SUFDOUIsS0FBSyxFQUFFLGFBQWEsQ0FBQztJQUNyQixTQUFTLEVBQUUsTUFBTSxDQUFDO0lBQ2xCLFNBQVMsRUFBRSxNQUFNLENBQUM7Q0FDbkI7QUFFRDs7R0FFRztBQUNILHFCQUFhLFFBQVE7SUFLakIsT0FBTyxDQUFDLF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AS,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.9d2bcf6d",
|
|
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/test-wallet": "0.0.1-commit.
|
|
57
|
+
"@aztec/accounts": "0.0.1-commit.9d2bcf6d",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.9d2bcf6d",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.9d2bcf6d",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.9d2bcf6d",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.9d2bcf6d",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.9d2bcf6d",
|
|
63
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.9d2bcf6d",
|
|
64
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.9d2bcf6d",
|
|
65
|
+
"@aztec/protocol-contracts": "0.0.1-commit.9d2bcf6d",
|
|
66
|
+
"@aztec/stdlib": "0.0.1-commit.9d2bcf6d",
|
|
67
|
+
"@aztec/telemetry-client": "0.0.1-commit.9d2bcf6d",
|
|
68
|
+
"@aztec/test-wallet": "0.0.1-commit.9d2bcf6d",
|
|
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,7 +1,7 @@
|
|
|
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';
|
|
@@ -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,10 +3,10 @@ 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';
|
|
@@ -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,5 +1,6 @@
|
|
|
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';
|
|
@@ -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
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ContractFunctionInteraction,
|
|
8
8
|
type DeployMethod,
|
|
9
9
|
type DeployOptions,
|
|
10
|
+
NO_WAIT,
|
|
10
11
|
} from '@aztec/aztec.js/contracts';
|
|
11
12
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
12
13
|
import type { L2AmountClaim } from '@aztec/aztec.js/ethereum';
|
|
@@ -14,6 +15,7 @@ import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
|
14
15
|
import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
15
16
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
16
17
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
18
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
17
19
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
18
20
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
19
21
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -56,8 +58,8 @@ export class BotFactory {
|
|
|
56
58
|
node: AztecNode;
|
|
57
59
|
recipient: AztecAddress;
|
|
58
60
|
}> {
|
|
59
|
-
const recipient = (await this.wallet.createAccount()).address;
|
|
60
61
|
const defaultAccountAddress = await this.setupAccount();
|
|
62
|
+
const recipient = (await this.wallet.createAccount()).address;
|
|
61
63
|
const token = await this.setupToken(defaultAccountAddress);
|
|
62
64
|
await this.mintTokens(token, defaultAccountAddress);
|
|
63
65
|
return { wallet: this.wallet, defaultAccountAddress, token, node: this.aztecNode, recipient };
|
|
@@ -118,8 +120,8 @@ export class BotFactory {
|
|
|
118
120
|
contract: new SchnorrAccountContract(signingKey!),
|
|
119
121
|
};
|
|
120
122
|
const accountManager = await this.wallet.createAccount(accountData);
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
+
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
124
|
+
if (metadata.isContractInitialized) {
|
|
123
125
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
124
126
|
const timer = new Timer();
|
|
125
127
|
const address = accountManager.address;
|
|
@@ -136,10 +138,16 @@ export class BotFactory {
|
|
|
136
138
|
const deployMethod = await accountManager.getDeployMethod();
|
|
137
139
|
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
138
140
|
const gasSettings = GasSettings.default({ maxFeesPerGas });
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
|
|
142
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
143
|
+
const txHash = await deployMethod.send({
|
|
144
|
+
from: AztecAddress.ZERO,
|
|
145
|
+
fee: { gasSettings, paymentMethod },
|
|
146
|
+
wait: NO_WAIT,
|
|
147
|
+
});
|
|
148
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
|
|
149
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
150
|
+
});
|
|
143
151
|
this.log.info(`Account deployed at ${address}`);
|
|
144
152
|
|
|
145
153
|
// Clean up the consumed bridge claim
|
|
@@ -173,8 +181,11 @@ export class BotFactory {
|
|
|
173
181
|
contractAddressSalt: this.config.tokenSalt,
|
|
174
182
|
universalDeploy: true,
|
|
175
183
|
};
|
|
184
|
+
let token: TokenContract | PrivateTokenContract;
|
|
176
185
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
177
186
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
187
|
+
tokenInstance = await deploy.getInstance(deployOpts);
|
|
188
|
+
token = TokenContract.at(tokenInstance.address, this.wallet);
|
|
178
189
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
179
190
|
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
180
191
|
const tokenSecretKey = Fr.random();
|
|
@@ -186,22 +197,27 @@ export class BotFactory {
|
|
|
186
197
|
|
|
187
198
|
// Register the contract with the secret key before deployment
|
|
188
199
|
tokenInstance = await deploy.getInstance(deployOpts);
|
|
200
|
+
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
189
201
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
190
202
|
} else {
|
|
191
203
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
192
204
|
}
|
|
193
205
|
|
|
194
206
|
const address = tokenInstance?.address ?? (await deploy.getInstance(deployOpts)).address;
|
|
195
|
-
|
|
207
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
208
|
+
if (metadata.isContractPublished) {
|
|
196
209
|
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
197
|
-
|
|
210
|
+
await deploy.register();
|
|
198
211
|
} else {
|
|
199
212
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
200
|
-
const
|
|
201
|
-
const txHash = await sentTx.getTxHash();
|
|
213
|
+
const txHash = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
202
214
|
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`);
|
|
203
|
-
|
|
215
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
216
|
+
await waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
217
|
+
return token;
|
|
218
|
+
});
|
|
204
219
|
}
|
|
220
|
+
return token;
|
|
205
221
|
}
|
|
206
222
|
|
|
207
223
|
/**
|
|
@@ -209,7 +225,7 @@ export class BotFactory {
|
|
|
209
225
|
* @param wallet - Wallet to deploy the token contract from.
|
|
210
226
|
* @returns The TokenContract instance.
|
|
211
227
|
*/
|
|
212
|
-
private setupTokenContract(
|
|
228
|
+
private async setupTokenContract(
|
|
213
229
|
deployer: AztecAddress,
|
|
214
230
|
contractAddressSalt: Fr,
|
|
215
231
|
name: string,
|
|
@@ -218,7 +234,8 @@ export class BotFactory {
|
|
|
218
234
|
): Promise<TokenContract> {
|
|
219
235
|
const deployOpts: DeployOptions = { from: deployer, contractAddressSalt, universalDeploy: true };
|
|
220
236
|
const deploy = TokenContract.deploy(this.wallet, deployer, name, ticker, decimals);
|
|
221
|
-
|
|
237
|
+
const instance = await this.registerOrDeployContract('Token - ' + name, deploy, deployOpts);
|
|
238
|
+
return TokenContract.at(instance.address, this.wallet);
|
|
222
239
|
}
|
|
223
240
|
|
|
224
241
|
private async setupAmmContract(
|
|
@@ -230,12 +247,14 @@ export class BotFactory {
|
|
|
230
247
|
): Promise<AMMContract> {
|
|
231
248
|
const deployOpts: DeployOptions = { from: deployer, contractAddressSalt, universalDeploy: true };
|
|
232
249
|
const deploy = AMMContract.deploy(this.wallet, token0.address, token1.address, lpToken.address);
|
|
233
|
-
const
|
|
250
|
+
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
251
|
+
const amm = AMMContract.at(instance.address, this.wallet);
|
|
234
252
|
|
|
235
253
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
254
|
+
const minterReceipt = await lpToken.methods
|
|
255
|
+
.set_minter(amm.address, true)
|
|
256
|
+
.send({ from: deployer, wait: { timeout: this.config.txMinedWaitSeconds } });
|
|
257
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`);
|
|
239
258
|
this.log.info(`Liquidity token initialized`);
|
|
240
259
|
|
|
241
260
|
return amm;
|
|
@@ -294,23 +313,22 @@ export class BotFactory {
|
|
|
294
313
|
.getFunctionCall(),
|
|
295
314
|
});
|
|
296
315
|
|
|
297
|
-
const
|
|
316
|
+
const mintReceipt = await new BatchCall(this.wallet, [
|
|
298
317
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
299
318
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
300
|
-
]).send({ from: liquidityProvider });
|
|
319
|
+
]).send({ from: liquidityProvider, wait: { timeout: this.config.txMinedWaitSeconds } });
|
|
301
320
|
|
|
302
|
-
this.log.info(`Sent mint tx: ${
|
|
303
|
-
await mintTx.wait({ timeout: this.config.txMinedWaitSeconds });
|
|
321
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`);
|
|
304
322
|
|
|
305
|
-
const
|
|
323
|
+
const addLiquidityReceipt = await amm.methods
|
|
306
324
|
.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce)
|
|
307
325
|
.send({
|
|
308
326
|
from: liquidityProvider,
|
|
309
327
|
authWitnesses: [token0Authwit, token1Authwit],
|
|
328
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
310
329
|
});
|
|
311
330
|
|
|
312
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${
|
|
313
|
-
await addLiquidityTx.wait({ timeout: this.config.txMinedWaitSeconds });
|
|
331
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`);
|
|
314
332
|
this.log.info(`Liquidity added`);
|
|
315
333
|
|
|
316
334
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
@@ -323,18 +341,22 @@ export class BotFactory {
|
|
|
323
341
|
name: string,
|
|
324
342
|
deploy: DeployMethod<T>,
|
|
325
343
|
deployOpts: DeployOptions,
|
|
326
|
-
): Promise<
|
|
327
|
-
const
|
|
328
|
-
|
|
344
|
+
): Promise<ContractInstanceWithAddress> {
|
|
345
|
+
const instance = await deploy.getInstance(deployOpts);
|
|
346
|
+
const address = instance.address;
|
|
347
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
348
|
+
if (metadata.isContractPublished) {
|
|
329
349
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
330
|
-
|
|
350
|
+
await deploy.register();
|
|
331
351
|
} else {
|
|
332
352
|
this.log.info(`Deploying contract ${name} at ${address.toString()}`);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
353
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
354
|
+
const txHash = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
355
|
+
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
356
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
357
|
+
});
|
|
337
358
|
}
|
|
359
|
+
return instance;
|
|
338
360
|
}
|
|
339
361
|
|
|
340
362
|
/**
|
|
@@ -370,10 +392,12 @@ export class BotFactory {
|
|
|
370
392
|
this.log.info(`Skipping minting as ${minter.toString()} has enough tokens`);
|
|
371
393
|
return;
|
|
372
394
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
395
|
+
|
|
396
|
+
await this.withNoMinTxsPerBlock(async () => {
|
|
397
|
+
const txHash = await new BatchCall(token.wallet, calls).send({ from: minter, wait: NO_WAIT });
|
|
398
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`);
|
|
399
|
+
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
400
|
+
});
|
|
377
401
|
}
|
|
378
402
|
|
|
379
403
|
/**
|