@aztec/bot 3.0.3 → 3.9.9-nightly.20260312
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 +27 -16
- package/dest/base_bot.d.ts +6 -6
- package/dest/base_bot.d.ts.map +1 -1
- package/dest/base_bot.js +14 -15
- package/dest/bot.d.ts +6 -6
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +8 -4
- package/dest/config.d.ts +39 -24
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +42 -14
- package/dest/cross_chain_bot.d.ts +54 -0
- package/dest/cross_chain_bot.d.ts.map +1 -0
- package/dest/cross_chain_bot.js +134 -0
- package/dest/factory.d.ts +20 -10
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +172 -80
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/l1_to_l2_seeding.d.ts +8 -0
- package/dest/l1_to_l2_seeding.d.ts.map +1 -0
- package/dest/l1_to_l2_seeding.js +63 -0
- package/dest/runner.d.ts +3 -3
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +429 -31
- package/dest/store/bot_store.d.ts +31 -6
- package/dest/store/bot_store.d.ts.map +1 -1
- package/dest/store/bot_store.js +37 -6
- package/dest/store/index.d.ts +2 -2
- package/dest/store/index.d.ts.map +1 -1
- package/dest/utils.js +3 -3
- package/package.json +17 -14
- package/src/amm_bot.ts +26 -21
- package/src/base_bot.ts +13 -27
- package/src/bot.ts +10 -8
- package/src/config.ts +89 -58
- package/src/cross_chain_bot.ts +203 -0
- package/src/factory.ts +193 -63
- package/src/index.ts +1 -0
- package/src/l1_to_l2_seeding.ts +79 -0
- package/src/runner.ts +18 -5
- package/src/store/bot_store.ts +60 -5
- package/src/store/index.ts +1 -1
- package/src/utils.ts +3 -3
package/dest/utils.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* @param who - Address to get the balance for.
|
|
5
5
|
* @returns - Private and public token balances as bigints.
|
|
6
6
|
*/ export async function getBalances(token, who, from) {
|
|
7
|
-
const privateBalance = await token.methods.balance_of_private(who).simulate({
|
|
7
|
+
const { result: privateBalance } = await token.methods.balance_of_private(who).simulate({
|
|
8
8
|
from: from ?? who
|
|
9
9
|
});
|
|
10
|
-
const publicBalance = await token.methods.balance_of_public(who).simulate({
|
|
10
|
+
const { result: publicBalance } = await token.methods.balance_of_public(who).simulate({
|
|
11
11
|
from: from ?? who
|
|
12
12
|
});
|
|
13
13
|
return {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
export async function getPrivateBalance(token, who, from) {
|
|
19
|
-
const privateBalance = await token.methods.get_balance(who).simulate({
|
|
19
|
+
const { result: privateBalance } = await token.methods.get_balance(who).simulate({
|
|
20
20
|
from: from ?? who
|
|
21
21
|
});
|
|
22
22
|
return privateBalance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bot",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.9-nightly.20260312",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -54,20 +54,23 @@
|
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@aztec/accounts": "3.
|
|
58
|
-
"@aztec/aztec.js": "3.
|
|
59
|
-
"@aztec/entrypoints": "3.
|
|
60
|
-
"@aztec/ethereum": "3.
|
|
61
|
-
"@aztec/foundation": "3.
|
|
62
|
-
"@aztec/kv-store": "3.
|
|
63
|
-
"@aztec/
|
|
64
|
-
"@aztec/noir-
|
|
65
|
-
"@aztec/protocol-
|
|
66
|
-
"@aztec/
|
|
67
|
-
"@aztec/
|
|
68
|
-
"@aztec/
|
|
57
|
+
"@aztec/accounts": "3.9.9-nightly.20260312",
|
|
58
|
+
"@aztec/aztec.js": "3.9.9-nightly.20260312",
|
|
59
|
+
"@aztec/entrypoints": "3.9.9-nightly.20260312",
|
|
60
|
+
"@aztec/ethereum": "3.9.9-nightly.20260312",
|
|
61
|
+
"@aztec/foundation": "3.9.9-nightly.20260312",
|
|
62
|
+
"@aztec/kv-store": "3.9.9-nightly.20260312",
|
|
63
|
+
"@aztec/l1-artifacts": "3.9.9-nightly.20260312",
|
|
64
|
+
"@aztec/noir-contracts.js": "3.9.9-nightly.20260312",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "3.9.9-nightly.20260312",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "3.9.9-nightly.20260312",
|
|
67
|
+
"@aztec/protocol-contracts": "3.9.9-nightly.20260312",
|
|
68
|
+
"@aztec/stdlib": "3.9.9-nightly.20260312",
|
|
69
|
+
"@aztec/telemetry-client": "3.9.9-nightly.20260312",
|
|
70
|
+
"@aztec/wallets": "3.9.9-nightly.20260312",
|
|
69
71
|
"source-map-support": "^0.5.21",
|
|
70
72
|
"tslib": "^2.4.0",
|
|
73
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
71
74
|
"zod": "^3.23.8"
|
|
72
75
|
},
|
|
73
76
|
"devDependencies": {
|
|
@@ -75,7 +78,7 @@
|
|
|
75
78
|
"@types/jest": "^30.0.0",
|
|
76
79
|
"@types/node": "^22.15.17",
|
|
77
80
|
"@types/source-map-support": "^0.5.10",
|
|
78
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
81
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
79
82
|
"jest": "^30.0.0",
|
|
80
83
|
"jest-mock-extended": "^4.0.0",
|
|
81
84
|
"ts-node": "^10.9.1",
|
package/src/amm_bot.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import {
|
|
2
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
-
import { TxReceipt } from '@aztec/aztec.js/tx';
|
|
4
|
+
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
5
5
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
6
6
|
import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
7
7
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
8
8
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
9
|
-
import type {
|
|
9
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
10
10
|
|
|
11
11
|
import { BaseBot } from './base_bot.js';
|
|
12
12
|
import type { BotConfig } from './config.js';
|
|
@@ -21,7 +21,7 @@ type Balances = { token0: bigint; token1: bigint };
|
|
|
21
21
|
export class AmmBot extends BaseBot {
|
|
22
22
|
protected constructor(
|
|
23
23
|
node: AztecNode,
|
|
24
|
-
wallet:
|
|
24
|
+
wallet: EmbeddedWallet,
|
|
25
25
|
defaultAccountAddress: AztecAddress,
|
|
26
26
|
public readonly amm: AMMContract,
|
|
27
27
|
public readonly token0: TokenContract,
|
|
@@ -33,7 +33,7 @@ export class AmmBot extends BaseBot {
|
|
|
33
33
|
|
|
34
34
|
static async create(
|
|
35
35
|
config: BotConfig,
|
|
36
|
-
wallet:
|
|
36
|
+
wallet: EmbeddedWallet,
|
|
37
37
|
aztecNode: AztecNode,
|
|
38
38
|
aztecNodeAdmin: AztecNodeAdmin | undefined,
|
|
39
39
|
store: BotStore,
|
|
@@ -48,7 +48,7 @@ export class AmmBot extends BaseBot {
|
|
|
48
48
|
return new AmmBot(aztecNode, wallet, defaultAccountAddress, amm, token0, token1, config);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
protected async createAndSendTx(logCtx: object): Promise<
|
|
51
|
+
protected async createAndSendTx(logCtx: object): Promise<TxHash> {
|
|
52
52
|
const { feePaymentMethod } = this.config;
|
|
53
53
|
const { wallet, amm, token0, token1 } = this;
|
|
54
54
|
|
|
@@ -71,12 +71,14 @@ export class AmmBot extends BaseBot {
|
|
|
71
71
|
.getFunctionCall(),
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
const
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
74
|
+
const { result: tokenInBalance } = await tokenIn.methods
|
|
75
|
+
.balance_of_public(amm.address)
|
|
76
|
+
.simulate({ from: this.defaultAccountAddress });
|
|
77
|
+
const { result: tokenOutBalance } = await tokenOut.methods
|
|
78
|
+
.balance_of_public(amm.address)
|
|
79
|
+
.simulate({ from: this.defaultAccountAddress });
|
|
80
|
+
const { result: amountOutMin } = await amm.methods
|
|
81
|
+
.get_amount_out_for_exact_in(tokenInBalance, tokenOutBalance, amountIn)
|
|
80
82
|
.simulate({ from: this.defaultAccountAddress });
|
|
81
83
|
|
|
82
84
|
const swapExactTokensInteraction = amm.methods
|
|
@@ -89,7 +91,8 @@ export class AmmBot extends BaseBot {
|
|
|
89
91
|
|
|
90
92
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
91
93
|
this.log.info(`Tx. Balances: ${jsonStringify(balances)}`, { ...logCtx, balances });
|
|
92
|
-
|
|
94
|
+
const { txHash } = await swapExactTokensInteraction.send({ ...opts, wait: NO_WAIT });
|
|
95
|
+
return txHash;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
|
|
@@ -110,15 +113,17 @@ export class AmmBot extends BaseBot {
|
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
private async getPublicBalanceFor(address: AztecAddress, from?: AztecAddress): Promise<Balances> {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
116
|
+
const { result: token0 } = await this.token0.methods.balance_of_public(address).simulate({ from: from ?? address });
|
|
117
|
+
const { result: token1 } = await this.token1.methods.balance_of_public(address).simulate({ from: from ?? address });
|
|
118
|
+
return { token0, token1 };
|
|
117
119
|
}
|
|
118
120
|
private async getPrivateBalanceFor(address: AztecAddress, from?: AztecAddress): Promise<Balances> {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
121
|
+
const { result: token0 } = await this.token0.methods
|
|
122
|
+
.balance_of_private(address)
|
|
123
|
+
.simulate({ from: from ?? address });
|
|
124
|
+
const { result: token1 } = await this.token1.methods
|
|
125
|
+
.balance_of_private(address)
|
|
126
|
+
.simulate({ from: from ?? address });
|
|
127
|
+
return { token0, token1 };
|
|
123
128
|
}
|
|
124
129
|
}
|
package/src/base_bot.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import {
|
|
3
|
-
BatchCall,
|
|
4
|
-
ContractFunctionInteraction,
|
|
5
|
-
type SendInteractionOptions,
|
|
6
|
-
SentTx,
|
|
7
|
-
waitForProven,
|
|
8
|
-
} from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { BatchCall, ContractFunctionInteraction, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
|
|
9
3
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
10
|
-
import {
|
|
4
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
5
|
+
import { TxHash, TxReceipt, TxStatus } from '@aztec/aztec.js/tx';
|
|
11
6
|
import { Gas } from '@aztec/stdlib/gas';
|
|
12
7
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
13
|
-
import type {
|
|
8
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
14
9
|
|
|
15
10
|
import type { BotConfig } from './config.js';
|
|
16
11
|
|
|
@@ -22,36 +17,27 @@ export abstract class BaseBot {
|
|
|
22
17
|
|
|
23
18
|
protected constructor(
|
|
24
19
|
public readonly node: AztecNode,
|
|
25
|
-
public readonly wallet:
|
|
20
|
+
public readonly wallet: EmbeddedWallet,
|
|
26
21
|
public readonly defaultAccountAddress: AztecAddress,
|
|
27
22
|
public config: BotConfig,
|
|
28
23
|
) {}
|
|
29
24
|
|
|
30
25
|
public async run(): Promise<TxReceipt | TxHash> {
|
|
31
26
|
this.attempts++;
|
|
32
|
-
const logCtx = { runId: Date.now() * 1000 + Math.floor(Math.random() * 1000) };
|
|
33
27
|
const { followChain, txMinedWaitSeconds } = this.config;
|
|
28
|
+
const logCtx = { runId: Date.now() * 1000 + Math.floor(Math.random() * 1000), followChain, txMinedWaitSeconds };
|
|
34
29
|
|
|
35
30
|
this.log.verbose(`Creating tx`, logCtx);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const txHash = await tx.getTxHash();
|
|
31
|
+
const txHash = await this.createAndSendTx(logCtx);
|
|
39
32
|
|
|
40
33
|
if (followChain === 'NONE') {
|
|
41
34
|
this.log.info(`Transaction ${txHash.toString()} sent, not waiting for it to be mined`);
|
|
42
35
|
return txHash;
|
|
43
36
|
}
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
const receipt = await tx.wait({
|
|
50
|
-
timeout: txMinedWaitSeconds,
|
|
51
|
-
});
|
|
52
|
-
if (followChain === 'PROVEN') {
|
|
53
|
-
await waitForProven(this.node, receipt, { provenTimeout: txMinedWaitSeconds });
|
|
54
|
-
}
|
|
38
|
+
const waitForStatus = TxStatus[followChain];
|
|
39
|
+
this.log.verbose(`Awaiting tx ${txHash.toString()} to be on the ${followChain} chain`, logCtx);
|
|
40
|
+
const receipt = await waitForTx(this.node, txHash, { timeout: txMinedWaitSeconds, waitForStatus });
|
|
55
41
|
this.successes++;
|
|
56
42
|
this.log.info(
|
|
57
43
|
`Tx #${this.attempts} ${receipt.txHash} successfully mined in block ${receipt.blockNumber} (stats: ${this.successes}/${this.attempts} success)`,
|
|
@@ -63,7 +49,7 @@ export abstract class BaseBot {
|
|
|
63
49
|
return receipt;
|
|
64
50
|
}
|
|
65
51
|
|
|
66
|
-
protected abstract createAndSendTx(logCtx: object): Promise<
|
|
52
|
+
protected abstract createAndSendTx(logCtx: object): Promise<TxHash>;
|
|
67
53
|
|
|
68
54
|
protected onTxMined(_receipt: TxReceipt, _logCtx: object): Promise<void> {
|
|
69
55
|
// no-op
|
|
@@ -73,9 +59,9 @@ export abstract class BaseBot {
|
|
|
73
59
|
protected async getSendMethodOpts(
|
|
74
60
|
interaction: ContractFunctionInteraction | BatchCall,
|
|
75
61
|
): Promise<SendInteractionOptions> {
|
|
76
|
-
const { l2GasLimit, daGasLimit,
|
|
62
|
+
const { l2GasLimit, daGasLimit, minFeePadding } = this.config;
|
|
77
63
|
|
|
78
|
-
this.wallet.
|
|
64
|
+
this.wallet.setMinFeePadding(minFeePadding);
|
|
79
65
|
|
|
80
66
|
let gasSettings;
|
|
81
67
|
if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
|
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,14 +76,15 @@ export class Bot extends BaseBot {
|
|
|
75
76
|
await batch.simulate({ from: this.defaultAccountAddress });
|
|
76
77
|
|
|
77
78
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
78
|
-
|
|
79
|
+
const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
|
|
80
|
+
return txHash;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
public async getBalances() {
|
|
82
84
|
if (isStandardTokenContract(this.token)) {
|
|
83
85
|
return {
|
|
84
86
|
sender: await getBalances(this.token, this.defaultAccountAddress),
|
|
85
|
-
recipient: await getBalances(this.token, this.recipient
|
|
87
|
+
recipient: await getBalances(this.token, this.recipient),
|
|
86
88
|
};
|
|
87
89
|
} else {
|
|
88
90
|
return {
|
|
@@ -91,7 +93,7 @@ export class Bot extends BaseBot {
|
|
|
91
93
|
publicBalance: 0n,
|
|
92
94
|
},
|
|
93
95
|
recipient: {
|
|
94
|
-
privateBalance: await getPrivateBalance(this.token, this.recipient
|
|
96
|
+
privateBalance: await getPrivateBalance(this.token, this.recipient),
|
|
95
97
|
publicBalance: 0n,
|
|
96
98
|
},
|
|
97
99
|
};
|
package/src/config.ts
CHANGED
|
@@ -14,14 +14,17 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
14
14
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
15
15
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
16
16
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
17
|
-
import {
|
|
17
|
+
import { schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
18
18
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
19
19
|
|
|
20
20
|
import { z } from 'zod';
|
|
21
21
|
|
|
22
|
-
const BotFollowChain = ['NONE', '
|
|
22
|
+
const BotFollowChain = ['NONE', 'PROPOSED', 'CHECKPOINTED', 'PROVEN'] as const;
|
|
23
23
|
type BotFollowChain = (typeof BotFollowChain)[number];
|
|
24
24
|
|
|
25
|
+
const BotMode = ['transfer', 'amm', 'crosschain'] as const;
|
|
26
|
+
type BotMode = (typeof BotMode)[number];
|
|
27
|
+
|
|
25
28
|
export enum SupportedTokenContracts {
|
|
26
29
|
TokenContract = 'TokenContract',
|
|
27
30
|
PrivateTokenContract = 'PrivateTokenContract',
|
|
@@ -54,8 +57,8 @@ export type BotConfig = {
|
|
|
54
57
|
publicTransfersPerTx: number;
|
|
55
58
|
/** How to handle fee payments. */
|
|
56
59
|
feePaymentMethod: 'fee_juice';
|
|
57
|
-
/** 'How much is the bot willing to overpay vs. the current
|
|
58
|
-
|
|
60
|
+
/** 'How much is the bot willing to overpay vs. the current min fee' */
|
|
61
|
+
minFeePadding: number;
|
|
59
62
|
/** True to not automatically setup or start the bot on initialization. */
|
|
60
63
|
noStart: boolean;
|
|
61
64
|
/** How long to wait for a tx to be mined before reporting an error. */
|
|
@@ -76,54 +79,62 @@ export type BotConfig = {
|
|
|
76
79
|
maxConsecutiveErrors: number;
|
|
77
80
|
/** Stops the bot if service becomes unhealthy */
|
|
78
81
|
stopWhenUnhealthy: boolean;
|
|
79
|
-
/**
|
|
80
|
-
|
|
82
|
+
/** Bot mode: transfer, amm, or crosschain. */
|
|
83
|
+
botMode: BotMode;
|
|
84
|
+
/** Number of L2→L1 messages per tx (crosschain mode). */
|
|
85
|
+
l2ToL1MessagesPerTx: number;
|
|
86
|
+
/** Max L1→L2 messages to keep in-flight (crosschain mode). */
|
|
87
|
+
l1ToL2SeedCount: number;
|
|
81
88
|
} & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'>;
|
|
82
89
|
|
|
83
|
-
export const BotConfigSchema =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
90
|
+
export const BotConfigSchema = zodFor<BotConfig>()(
|
|
91
|
+
z
|
|
92
|
+
.object({
|
|
93
|
+
nodeUrl: z.string().optional(),
|
|
94
|
+
nodeAdminUrl: z.string().optional(),
|
|
95
|
+
l1RpcUrls: z.array(z.string()).optional(),
|
|
96
|
+
l1Mnemonic: schemas.SecretValue(z.string()).optional(),
|
|
97
|
+
l1PrivateKey: schemas.SecretValue(z.string()).optional(),
|
|
98
|
+
l1ToL2MessageTimeoutSeconds: z.number(),
|
|
99
|
+
senderPrivateKey: schemas.SecretValue(schemas.Fr).optional(),
|
|
100
|
+
senderSalt: schemas.Fr.optional(),
|
|
101
|
+
tokenSalt: schemas.Fr,
|
|
102
|
+
txIntervalSeconds: z.number(),
|
|
103
|
+
privateTransfersPerTx: z.number().int().nonnegative(),
|
|
104
|
+
publicTransfersPerTx: z.number().int().nonnegative(),
|
|
105
|
+
feePaymentMethod: z.literal('fee_juice'),
|
|
106
|
+
minFeePadding: z.number().int().nonnegative(),
|
|
107
|
+
noStart: z.boolean(),
|
|
108
|
+
txMinedWaitSeconds: z.number(),
|
|
109
|
+
followChain: z.enum(BotFollowChain),
|
|
110
|
+
maxPendingTxs: z.number().int().nonnegative(),
|
|
111
|
+
flushSetupTransactions: z.boolean(),
|
|
112
|
+
l2GasLimit: z.number().int().nonnegative().optional(),
|
|
113
|
+
daGasLimit: z.number().int().nonnegative().optional(),
|
|
114
|
+
contract: z.nativeEnum(SupportedTokenContracts),
|
|
115
|
+
maxConsecutiveErrors: z.number().int().nonnegative(),
|
|
116
|
+
stopWhenUnhealthy: z.boolean(),
|
|
117
|
+
botMode: z.enum(BotMode).default('transfer'),
|
|
118
|
+
l2ToL1MessagesPerTx: z.number().int().nonnegative().default(1),
|
|
119
|
+
l1ToL2SeedCount: z.number().int().nonnegative().default(1),
|
|
120
|
+
dataDirectory: z.string().optional(),
|
|
121
|
+
dataStoreMapSizeKb: z.number().optional(),
|
|
122
|
+
})
|
|
123
|
+
.transform(config => ({
|
|
124
|
+
nodeUrl: undefined,
|
|
125
|
+
nodeAdminUrl: undefined,
|
|
126
|
+
l1RpcUrls: undefined,
|
|
127
|
+
senderSalt: undefined,
|
|
128
|
+
l2GasLimit: undefined,
|
|
129
|
+
daGasLimit: undefined,
|
|
130
|
+
l1Mnemonic: undefined,
|
|
131
|
+
l1PrivateKey: undefined,
|
|
132
|
+
senderPrivateKey: undefined,
|
|
133
|
+
dataDirectory: undefined,
|
|
134
|
+
dataStoreMapSizeKb: 1_024 * 1_024,
|
|
135
|
+
...config,
|
|
136
|
+
})),
|
|
137
|
+
);
|
|
127
138
|
|
|
128
139
|
export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
129
140
|
nodeUrl: {
|
|
@@ -191,8 +202,8 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
191
202
|
parseEnv: val => (val as 'fee_juice') || undefined,
|
|
192
203
|
defaultValue: 'fee_juice',
|
|
193
204
|
},
|
|
194
|
-
|
|
195
|
-
env: '
|
|
205
|
+
minFeePadding: {
|
|
206
|
+
env: 'BOT_MIN_FEE_PADDING',
|
|
196
207
|
description: 'How much is the bot willing to overpay vs. the current base fee',
|
|
197
208
|
...numberConfigHelper(3),
|
|
198
209
|
},
|
|
@@ -211,10 +222,14 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
211
222
|
description: 'Which chain the bot follows',
|
|
212
223
|
defaultValue: 'NONE',
|
|
213
224
|
parseEnv(val) {
|
|
214
|
-
|
|
225
|
+
const upper = val.toUpperCase();
|
|
226
|
+
if (upper === 'PENDING') {
|
|
227
|
+
return 'CHECKPOINTED';
|
|
228
|
+
}
|
|
229
|
+
if (!(BotFollowChain as readonly string[]).includes(upper)) {
|
|
215
230
|
throw new Error(`Invalid value for BOT_FOLLOW_CHAIN: ${val}`);
|
|
216
231
|
}
|
|
217
|
-
return
|
|
232
|
+
return upper as BotFollowChain;
|
|
218
233
|
},
|
|
219
234
|
},
|
|
220
235
|
maxPendingTxs: {
|
|
@@ -262,10 +277,26 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
262
277
|
description: 'Stops the bot if service becomes unhealthy',
|
|
263
278
|
...booleanConfigHelper(false),
|
|
264
279
|
},
|
|
265
|
-
|
|
266
|
-
env: '
|
|
267
|
-
description: '
|
|
268
|
-
|
|
280
|
+
botMode: {
|
|
281
|
+
env: 'BOT_MODE',
|
|
282
|
+
description: 'Bot mode: transfer, amm, or crosschain',
|
|
283
|
+
defaultValue: 'transfer' as BotMode,
|
|
284
|
+
parseEnv(val: string) {
|
|
285
|
+
if (!(BotMode as readonly string[]).includes(val)) {
|
|
286
|
+
throw new Error(`Invalid value for BOT_MODE: ${val}`);
|
|
287
|
+
}
|
|
288
|
+
return val as BotMode;
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
l2ToL1MessagesPerTx: {
|
|
292
|
+
env: 'BOT_L2_TO_L1_MESSAGES_PER_TX',
|
|
293
|
+
description: 'Number of L2→L1 messages per tx (crosschain mode)',
|
|
294
|
+
...numberConfigHelper(1),
|
|
295
|
+
},
|
|
296
|
+
l1ToL2SeedCount: {
|
|
297
|
+
env: 'BOT_L1_TO_L2_SEED_COUNT',
|
|
298
|
+
description: 'Max L1→L2 messages to keep in-flight (crosschain mode)',
|
|
299
|
+
...numberConfigHelper(1),
|
|
269
300
|
},
|
|
270
301
|
...pickConfigMappings(dataConfigMappings, ['dataStoreMapSizeKb', 'dataDirectory']),
|
|
271
302
|
};
|