@aztec/bot 2.1.0-rc.9 → 3.0.0-devnet.2
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 +8 -8
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +23 -20
- package/dest/base_bot.d.ts +10 -7
- package/dest/base_bot.d.ts.map +1 -1
- package/dest/base_bot.js +18 -18
- package/dest/bot.d.ts +7 -8
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +11 -12
- package/dest/config.d.ts +19 -15
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +22 -20
- package/dest/factory.d.ts +18 -17
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +122 -102
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/interface.d.ts +1 -1
- package/dest/interface.d.ts.map +1 -1
- package/dest/interface.js +1 -1
- package/dest/runner.d.ts +11 -12
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +18 -32
- package/dest/store/bot_store.d.ts +44 -0
- package/dest/store/bot_store.d.ts.map +1 -0
- package/dest/store/bot_store.js +107 -0
- package/dest/store/index.d.ts +2 -0
- package/dest/store/index.d.ts.map +1 -0
- package/dest/store/index.js +1 -0
- package/dest/utils.d.ts +3 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +5 -5
- package/package.json +13 -11
- package/src/amm_bot.ts +39 -31
- package/src/base_bot.ts +24 -22
- package/src/bot.ts +25 -14
- package/src/config.ts +20 -22
- package/src/factory.ts +138 -140
- package/src/index.ts +1 -0
- package/src/interface.ts +1 -1
- package/src/runner.ts +19 -23
- package/src/store/bot_store.ts +141 -0
- package/src/store/index.ts +1 -0
- package/src/utils.ts +10 -5
package/dest/amm_bot.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { AztecAddress
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { SentTx } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { TxReceipt } from '@aztec/aztec.js/tx';
|
|
2
4
|
import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
3
5
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
|
-
import type { AztecNode, AztecNodeAdmin
|
|
6
|
+
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
7
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
5
8
|
import { BaseBot } from './base_bot.js';
|
|
6
9
|
import type { BotConfig } from './config.js';
|
|
10
|
+
import type { BotStore } from './store/index.js';
|
|
7
11
|
type Balances = {
|
|
8
12
|
token0: bigint;
|
|
9
13
|
token1: bigint;
|
|
@@ -12,12 +16,8 @@ export declare class AmmBot extends BaseBot {
|
|
|
12
16
|
readonly amm: AMMContract;
|
|
13
17
|
readonly token0: TokenContract;
|
|
14
18
|
readonly token1: TokenContract;
|
|
15
|
-
protected constructor(
|
|
16
|
-
static create(config: BotConfig,
|
|
17
|
-
pxe?: PXE;
|
|
18
|
-
node?: AztecNode;
|
|
19
|
-
nodeAdmin?: AztecNodeAdmin;
|
|
20
|
-
}): Promise<AmmBot>;
|
|
19
|
+
protected constructor(node: AztecNode, wallet: TestWallet, defaultAccountAddress: AztecAddress, amm: AMMContract, token0: TokenContract, token1: TokenContract, config: BotConfig);
|
|
20
|
+
static create(config: BotConfig, wallet: TestWallet, aztecNode: AztecNode, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore): Promise<AmmBot>;
|
|
21
21
|
protected createAndSendTx(logCtx: object): Promise<SentTx>;
|
|
22
22
|
protected onTxMined(receipt: TxReceipt, logCtx: object): Promise<void>;
|
|
23
23
|
getAmmBalances(): Promise<Balances>;
|
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,
|
|
1
|
+
{"version":3,"file":"amm_bot.d.ts","sourceRoot":"","sources":["../src/amm_bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,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;WAKN,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;cAWF,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;cA4CvC,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9E,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC;IAI7B,WAAW,IAAI,OAAO,CAAC;QAAE,YAAY,EAAE,QAAQ,CAAC;QAAC,aAAa,EAAE,QAAQ,CAAC;QAAC,GAAG,EAAE,QAAQ,CAAA;KAAE,CAAC;YAQzF,mBAAmB;YAMnB,oBAAoB;CAMnC"}
|
package/dest/amm_bot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/aztec.js';
|
|
1
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
2
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
3
|
import { BaseBot } from './base_bot.js';
|
|
4
4
|
import { BotFactory } from './factory.js';
|
|
@@ -8,12 +8,12 @@ export class AmmBot extends BaseBot {
|
|
|
8
8
|
amm;
|
|
9
9
|
token0;
|
|
10
10
|
token1;
|
|
11
|
-
constructor(
|
|
12
|
-
super(
|
|
11
|
+
constructor(node, wallet, defaultAccountAddress, amm, token0, token1, config){
|
|
12
|
+
super(node, wallet, defaultAccountAddress, config), this.amm = amm, this.token0 = token0, this.token1 = token1;
|
|
13
13
|
}
|
|
14
|
-
static async create(config,
|
|
15
|
-
const {
|
|
16
|
-
return new AmmBot(
|
|
14
|
+
static async create(config, wallet, aztecNode, aztecNodeAdmin, store) {
|
|
15
|
+
const { defaultAccountAddress, token0, token1, amm } = await new BotFactory(config, wallet, store, aztecNode, aztecNodeAdmin).setupAmm();
|
|
16
|
+
return new AmmBot(aztecNode, wallet, defaultAccountAddress, amm, token0, token1, config);
|
|
17
17
|
}
|
|
18
18
|
async createAndSendTx(logCtx) {
|
|
19
19
|
const { feePaymentMethod } = this.config;
|
|
@@ -33,9 +33,9 @@ export class AmmBot extends BaseBot {
|
|
|
33
33
|
token1,
|
|
34
34
|
token0
|
|
35
35
|
];
|
|
36
|
-
const swapAuthwit = await wallet.createAuthWit({
|
|
36
|
+
const swapAuthwit = await wallet.createAuthWit(this.defaultAccountAddress, {
|
|
37
37
|
caller: amm.address,
|
|
38
|
-
|
|
38
|
+
call: await tokenIn.methods.transfer_to_public(this.defaultAccountAddress, amm.address, amountIn, authwitNonce).getFunctionCall()
|
|
39
39
|
});
|
|
40
40
|
const amountOutMin = await amm.methods.get_amount_out_for_exact_in(await tokenIn.methods.balance_of_public(amm.address).simulate({
|
|
41
41
|
from: this.defaultAccountAddress
|
|
@@ -44,15 +44,18 @@ export class AmmBot extends BaseBot {
|
|
|
44
44
|
}), amountIn).simulate({
|
|
45
45
|
from: this.defaultAccountAddress
|
|
46
46
|
});
|
|
47
|
-
const swapExactTokensInteraction = amm.methods.swap_exact_tokens_for_tokens(tokenIn.address, tokenOut.address, amountIn, amountOutMin, authwitNonce)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const swapExactTokensInteraction = amm.methods.swap_exact_tokens_for_tokens(tokenIn.address, tokenOut.address, amountIn, amountOutMin, authwitNonce).with({
|
|
48
|
+
authWitnesses: [
|
|
49
|
+
swapAuthwit
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
const opts = await this.getSendMethodOpts(swapExactTokensInteraction);
|
|
53
|
+
this.log.verbose(`Sending transaction`, logCtx);
|
|
51
54
|
this.log.info(`Tx. Balances: ${jsonStringify(balances)}`, {
|
|
52
55
|
...logCtx,
|
|
53
56
|
balances
|
|
54
57
|
});
|
|
55
|
-
return
|
|
58
|
+
return swapExactTokensInteraction.send(opts);
|
|
56
59
|
}
|
|
57
60
|
async onTxMined(receipt, logCtx) {
|
|
58
61
|
const balances = await this.getBalances();
|
|
@@ -68,26 +71,26 @@ export class AmmBot extends BaseBot {
|
|
|
68
71
|
return {
|
|
69
72
|
senderPublic: await this.getPublicBalanceFor(this.defaultAccountAddress),
|
|
70
73
|
senderPrivate: await this.getPrivateBalanceFor(this.defaultAccountAddress),
|
|
71
|
-
amm: await this.getPublicBalanceFor(this.amm.address)
|
|
74
|
+
amm: await this.getPublicBalanceFor(this.amm.address, this.defaultAccountAddress)
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
|
-
async getPublicBalanceFor(address) {
|
|
77
|
+
async getPublicBalanceFor(address, from) {
|
|
75
78
|
return {
|
|
76
79
|
token0: await this.token0.methods.balance_of_public(address).simulate({
|
|
77
|
-
from: address
|
|
80
|
+
from: from ?? address
|
|
78
81
|
}),
|
|
79
82
|
token1: await this.token1.methods.balance_of_public(address).simulate({
|
|
80
|
-
from: address
|
|
83
|
+
from: from ?? address
|
|
81
84
|
})
|
|
82
85
|
};
|
|
83
86
|
}
|
|
84
|
-
async getPrivateBalanceFor(address) {
|
|
87
|
+
async getPrivateBalanceFor(address, from) {
|
|
85
88
|
return {
|
|
86
89
|
token0: await this.token0.methods.balance_of_private(address).simulate({
|
|
87
|
-
from: address
|
|
90
|
+
from: from ?? address
|
|
88
91
|
}),
|
|
89
92
|
token1: await this.token1.methods.balance_of_private(address).simulate({
|
|
90
|
-
from: address
|
|
93
|
+
from: from ?? address
|
|
91
94
|
})
|
|
92
95
|
};
|
|
93
96
|
}
|
package/dest/base_bot.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { BatchCall, ContractFunctionInteraction, type SendInteractionOptions, SentTx } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
|
|
4
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
3
6
|
import type { BotConfig } from './config.js';
|
|
4
7
|
export declare abstract class BaseBot {
|
|
5
|
-
readonly
|
|
6
|
-
readonly wallet:
|
|
8
|
+
readonly node: AztecNode;
|
|
9
|
+
readonly wallet: TestWallet;
|
|
7
10
|
readonly defaultAccountAddress: AztecAddress;
|
|
8
11
|
config: BotConfig;
|
|
9
|
-
protected log: import("@aztec/aztec.js").Logger;
|
|
12
|
+
protected log: import("@aztec/aztec.js/log").Logger;
|
|
10
13
|
protected attempts: number;
|
|
11
14
|
protected successes: number;
|
|
12
|
-
protected constructor(
|
|
15
|
+
protected constructor(node: AztecNode, wallet: TestWallet, defaultAccountAddress: AztecAddress, config: BotConfig);
|
|
13
16
|
run(): Promise<TxReceipt | TxHash>;
|
|
14
17
|
protected abstract createAndSendTx(logCtx: object): Promise<SentTx>;
|
|
15
18
|
protected onTxMined(_receipt: TxReceipt, _logCtx: object): Promise<void>;
|
|
16
|
-
protected getSendMethodOpts(
|
|
19
|
+
protected getSendMethodOpts(interaction: ContractFunctionInteraction | BatchCall): Promise<SendInteractionOptions>;
|
|
17
20
|
}
|
|
18
21
|
//# sourceMappingURL=base_bot.d.ts.map
|
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,EACL,
|
|
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,EAC3B,MAAM,EAEP,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,8BAAsB,OAAO;aAOT,IAAI,EAAE,SAAS;aACf,MAAM,EAAE,UAAU;aAClB,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,UAAU,EAClB,qBAAqB,EAAE,YAAY,EAC5C,MAAM,EAAE,SAAS;IAGb,GAAG,IAAI,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC;IAoC/C,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEnE,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;cAKxD,iBAAiB,CAC/B,WAAW,EAAE,2BAA2B,GAAG,SAAS,GACnD,OAAO,CAAC,sBAAsB,CAAC;CAqBnC"}
|
package/dest/base_bot.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { waitForProven } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
3
|
import { Gas } from '@aztec/stdlib/gas';
|
|
3
4
|
export class BaseBot {
|
|
4
|
-
|
|
5
|
+
node;
|
|
5
6
|
wallet;
|
|
6
7
|
defaultAccountAddress;
|
|
7
8
|
config;
|
|
8
9
|
log;
|
|
9
10
|
attempts;
|
|
10
11
|
successes;
|
|
11
|
-
constructor(
|
|
12
|
-
this.
|
|
12
|
+
constructor(node, wallet, defaultAccountAddress, config){
|
|
13
|
+
this.node = node;
|
|
13
14
|
this.wallet = wallet;
|
|
14
15
|
this.defaultAccountAddress = defaultAccountAddress;
|
|
15
16
|
this.config = config;
|
|
@@ -35,7 +36,7 @@ export class BaseBot {
|
|
|
35
36
|
timeout: txMinedWaitSeconds
|
|
36
37
|
});
|
|
37
38
|
if (followChain === 'PROVEN') {
|
|
38
|
-
await waitForProven(this.
|
|
39
|
+
await waitForProven(this.node, receipt, {
|
|
39
40
|
provenTimeout: txMinedWaitSeconds
|
|
40
41
|
});
|
|
41
42
|
}
|
|
@@ -48,10 +49,10 @@ export class BaseBot {
|
|
|
48
49
|
// no-op
|
|
49
50
|
return Promise.resolve();
|
|
50
51
|
}
|
|
51
|
-
getSendMethodOpts(
|
|
52
|
-
const { l2GasLimit, daGasLimit } = this.config;
|
|
53
|
-
|
|
54
|
-
let gasSettings
|
|
52
|
+
async getSendMethodOpts(interaction) {
|
|
53
|
+
const { l2GasLimit, daGasLimit, baseFeePadding } = this.config;
|
|
54
|
+
this.wallet.setBaseFeePadding(baseFeePadding);
|
|
55
|
+
let gasSettings;
|
|
55
56
|
if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
|
|
56
57
|
gasSettings = {
|
|
57
58
|
gasLimits: Gas.from({
|
|
@@ -59,22 +60,21 @@ export class BaseBot {
|
|
|
59
60
|
daGas: daGasLimit
|
|
60
61
|
})
|
|
61
62
|
};
|
|
62
|
-
estimateGas = false;
|
|
63
63
|
this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
|
|
64
64
|
} else {
|
|
65
|
-
estimateGas = true;
|
|
66
65
|
this.log.verbose(`Estimating gas for transaction`);
|
|
66
|
+
({ estimatedGas: gasSettings } = await interaction.simulate({
|
|
67
|
+
fee: {
|
|
68
|
+
estimateGas: true
|
|
69
|
+
},
|
|
70
|
+
from: this.defaultAccountAddress
|
|
71
|
+
}));
|
|
67
72
|
}
|
|
68
|
-
const baseFeePadding = 2; // Send 3x the current base fee
|
|
69
73
|
return {
|
|
70
74
|
from: this.defaultAccountAddress,
|
|
71
75
|
fee: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
gasSettings,
|
|
75
|
-
baseFeePadding
|
|
76
|
-
},
|
|
77
|
-
authWitnesses
|
|
76
|
+
gasSettings
|
|
77
|
+
}
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
}
|
package/dest/bot.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { SentTx } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
3
4
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
|
-
import type { AztecNode, AztecNodeAdmin
|
|
5
|
+
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
6
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
5
7
|
import { BaseBot } from './base_bot.js';
|
|
6
8
|
import type { BotConfig } from './config.js';
|
|
9
|
+
import type { BotStore } from './store/index.js';
|
|
7
10
|
export declare class Bot extends BaseBot {
|
|
8
11
|
readonly token: TokenContract | PrivateTokenContract;
|
|
9
12
|
readonly recipient: AztecAddress;
|
|
10
|
-
protected constructor(
|
|
11
|
-
static create(config: BotConfig,
|
|
12
|
-
pxe?: PXE;
|
|
13
|
-
node?: AztecNode;
|
|
14
|
-
nodeAdmin?: AztecNodeAdmin;
|
|
15
|
-
}): Promise<Bot>;
|
|
13
|
+
protected constructor(node: AztecNode, wallet: TestWallet, defaultAccountAddress: AztecAddress, token: TokenContract | PrivateTokenContract, recipient: AztecAddress, config: BotConfig);
|
|
14
|
+
static create(config: BotConfig, wallet: TestWallet, aztecNode: AztecNode, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore): Promise<Bot>;
|
|
16
15
|
updateConfig(config: Partial<BotConfig>): void;
|
|
17
16
|
protected createAndSendTx(logCtx: object): Promise<SentTx>;
|
|
18
17
|
getBalances(): Promise<{
|
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,EAAE,
|
|
1
|
+
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../src/bot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAa,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAE9D,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,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,qBAAa,GAAI,SAAQ,OAAO;aAKZ,KAAK,EAAE,aAAa,GAAG,oBAAoB;aAC3C,SAAS,EAAE,YAAY;IALzC,SAAS,aACP,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,UAAU,EAClB,qBAAqB,EAAE,YAAY,EACnB,KAAK,EAAE,aAAa,GAAG,oBAAoB,EAC3C,SAAS,EAAE,YAAY,EACvC,MAAM,EAAE,SAAS;WAKN,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,GAAG,CAAC;IAWR,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC;cAK9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BnD,WAAW;;;;;;;;;;CAmBzB"}
|
package/dest/bot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchCall } from '@aztec/aztec.js';
|
|
1
|
+
import { BatchCall } 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';
|
|
@@ -7,12 +7,12 @@ const TRANSFER_AMOUNT = 1;
|
|
|
7
7
|
export class Bot extends BaseBot {
|
|
8
8
|
token;
|
|
9
9
|
recipient;
|
|
10
|
-
constructor(
|
|
11
|
-
super(
|
|
10
|
+
constructor(node, wallet, defaultAccountAddress, token, recipient, config){
|
|
11
|
+
super(node, wallet, defaultAccountAddress, config), this.token = token, this.recipient = recipient;
|
|
12
12
|
}
|
|
13
|
-
static async create(config,
|
|
14
|
-
const {
|
|
15
|
-
return new Bot(
|
|
13
|
+
static async create(config, wallet, aztecNode, aztecNodeAdmin, store) {
|
|
14
|
+
const { defaultAccountAddress, token, recipient } = await new BotFactory(config, wallet, store, aztecNode, aztecNodeAdmin).setup();
|
|
15
|
+
return new Bot(aztecNode, wallet, defaultAccountAddress, token, recipient, config);
|
|
16
16
|
}
|
|
17
17
|
updateConfig(config) {
|
|
18
18
|
this.log.info(`Updating bot config ${Object.keys(config).join(', ')}`);
|
|
@@ -29,21 +29,20 @@ export class Bot extends BaseBot {
|
|
|
29
29
|
times(privateTransfersPerTx, ()=>token.methods.transfer(recipient, TRANSFER_AMOUNT)),
|
|
30
30
|
times(publicTransfersPerTx, ()=>token.methods.transfer_in_public(this.defaultAccountAddress, recipient, TRANSFER_AMOUNT, 0))
|
|
31
31
|
].flat() : times(privateTransfersPerTx, ()=>token.methods.transfer(TRANSFER_AMOUNT, this.defaultAccountAddress, recipient));
|
|
32
|
-
const opts = this.getSendMethodOpts();
|
|
33
32
|
const batch = new BatchCall(wallet, calls);
|
|
33
|
+
const opts = await this.getSendMethodOpts(batch);
|
|
34
34
|
this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx);
|
|
35
35
|
await batch.simulate({
|
|
36
36
|
from: this.defaultAccountAddress
|
|
37
37
|
});
|
|
38
|
-
this.log.verbose(`
|
|
39
|
-
|
|
40
|
-
return provenTx.send();
|
|
38
|
+
this.log.verbose(`Sending transaction`, logCtx);
|
|
39
|
+
return batch.send(opts);
|
|
41
40
|
}
|
|
42
41
|
async getBalances() {
|
|
43
42
|
if (isStandardTokenContract(this.token)) {
|
|
44
43
|
return {
|
|
45
44
|
sender: await getBalances(this.token, this.defaultAccountAddress),
|
|
46
|
-
recipient: await getBalances(this.token, this.recipient)
|
|
45
|
+
recipient: await getBalances(this.token, this.recipient, this.defaultAccountAddress)
|
|
47
46
|
};
|
|
48
47
|
} else {
|
|
49
48
|
return {
|
|
@@ -52,7 +51,7 @@ export class Bot extends BaseBot {
|
|
|
52
51
|
publicBalance: 0n
|
|
53
52
|
},
|
|
54
53
|
recipient: {
|
|
55
|
-
privateBalance: await getPrivateBalance(this.token, this.recipient),
|
|
54
|
+
privateBalance: await getPrivateBalance(this.token, this.recipient, this.defaultAccountAddress),
|
|
56
55
|
publicBalance: 0n
|
|
57
56
|
}
|
|
58
57
|
};
|
package/dest/config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ConfigMappingsType, SecretValue } from '@aztec/foundation/config';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
3
4
|
import { type ZodFor } from '@aztec/stdlib/schemas';
|
|
4
5
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
5
6
|
import { z } from 'zod';
|
|
@@ -14,8 +15,6 @@ export type BotConfig = {
|
|
|
14
15
|
nodeUrl: string | undefined;
|
|
15
16
|
/** The URL to the Aztec node admin API to force-flush txs if configured. */
|
|
16
17
|
nodeAdminUrl: string | undefined;
|
|
17
|
-
/** URL to the PXE for sending txs, or undefined if an in-proc PXE is used. */
|
|
18
|
-
pxeUrl: string | undefined;
|
|
19
18
|
/** Url of the ethereum host. */
|
|
20
19
|
l1RpcUrls: string[] | undefined;
|
|
21
20
|
/** The mnemonic for the account to bridge fee juice from L1. */
|
|
@@ -28,8 +27,6 @@ export type BotConfig = {
|
|
|
28
27
|
senderPrivateKey: SecretValue<Fr> | undefined;
|
|
29
28
|
/** Optional salt to use to instantiate the sender account */
|
|
30
29
|
senderSalt: Fr | undefined;
|
|
31
|
-
/** Encryption secret for a recipient account. */
|
|
32
|
-
recipientEncryptionSecret: SecretValue<Fr>;
|
|
33
30
|
/** Salt for the token contract instantiation. */
|
|
34
31
|
tokenSalt: Fr;
|
|
35
32
|
/** Every how many seconds should a new tx be sent. */
|
|
@@ -40,6 +37,8 @@ export type BotConfig = {
|
|
|
40
37
|
publicTransfersPerTx: number;
|
|
41
38
|
/** How to handle fee payments. */
|
|
42
39
|
feePaymentMethod: 'fee_juice';
|
|
40
|
+
/** 'How much is the bot willing to overpay vs. the current base fee' */
|
|
41
|
+
baseFeePadding: number;
|
|
43
42
|
/** True to not automatically setup or start the bot on initialization. */
|
|
44
43
|
noStart: boolean;
|
|
45
44
|
/** How long to wait for a tx to be mined before reporting an error. */
|
|
@@ -62,23 +61,22 @@ export type BotConfig = {
|
|
|
62
61
|
stopWhenUnhealthy: boolean;
|
|
63
62
|
/** Deploy an AMM contract and do swaps instead of transfers */
|
|
64
63
|
ammTxs: boolean;
|
|
65
|
-
}
|
|
64
|
+
} & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'>;
|
|
66
65
|
export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
67
66
|
nodeUrl: z.ZodOptional<z.ZodString>;
|
|
68
67
|
nodeAdminUrl: z.ZodOptional<z.ZodString>;
|
|
69
|
-
pxeUrl: z.ZodOptional<z.ZodString>;
|
|
70
68
|
l1RpcUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
71
69
|
l1Mnemonic: z.ZodOptional<z.ZodType<SecretValue<string>, any, any>>;
|
|
72
70
|
l1PrivateKey: z.ZodOptional<z.ZodType<SecretValue<string>, any, any>>;
|
|
73
71
|
l1ToL2MessageTimeoutSeconds: z.ZodNumber;
|
|
74
72
|
senderPrivateKey: z.ZodOptional<z.ZodType<SecretValue<Fr>, any, any>>;
|
|
75
73
|
senderSalt: z.ZodOptional<ZodFor<Fr>>;
|
|
76
|
-
recipientEncryptionSecret: z.ZodType<SecretValue<Fr>, any, any>;
|
|
77
74
|
tokenSalt: ZodFor<Fr>;
|
|
78
75
|
txIntervalSeconds: z.ZodNumber;
|
|
79
76
|
privateTransfersPerTx: z.ZodNumber;
|
|
80
77
|
publicTransfersPerTx: z.ZodNumber;
|
|
81
78
|
feePaymentMethod: z.ZodLiteral<"fee_juice">;
|
|
79
|
+
baseFeePadding: z.ZodNumber;
|
|
82
80
|
noStart: z.ZodBoolean;
|
|
83
81
|
txMinedWaitSeconds: z.ZodNumber;
|
|
84
82
|
followChain: z.ZodEnum<["NONE", "PENDING", "PROVEN"]>;
|
|
@@ -90,14 +88,16 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
90
88
|
maxConsecutiveErrors: z.ZodNumber;
|
|
91
89
|
stopWhenUnhealthy: z.ZodBoolean;
|
|
92
90
|
ammTxs: z.ZodDefault<z.ZodBoolean>;
|
|
91
|
+
dataDirectory: z.ZodOptional<z.ZodString>;
|
|
92
|
+
dataStoreMapSizeKb: z.ZodOptional<z.ZodNumber>;
|
|
93
93
|
}, "strip", z.ZodTypeAny, {
|
|
94
94
|
l1ToL2MessageTimeoutSeconds: number;
|
|
95
|
-
recipientEncryptionSecret: SecretValue<Fr>;
|
|
96
95
|
tokenSalt: Fr;
|
|
97
96
|
txIntervalSeconds: number;
|
|
98
97
|
privateTransfersPerTx: number;
|
|
99
98
|
publicTransfersPerTx: number;
|
|
100
99
|
feePaymentMethod: "fee_juice";
|
|
100
|
+
baseFeePadding: number;
|
|
101
101
|
noStart: boolean;
|
|
102
102
|
txMinedWaitSeconds: number;
|
|
103
103
|
followChain: "NONE" | "PENDING" | "PROVEN";
|
|
@@ -107,9 +107,10 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
107
107
|
maxConsecutiveErrors: number;
|
|
108
108
|
stopWhenUnhealthy: boolean;
|
|
109
109
|
ammTxs: boolean;
|
|
110
|
+
dataDirectory?: string | undefined;
|
|
111
|
+
dataStoreMapSizeKb?: number | undefined;
|
|
110
112
|
nodeUrl?: string | undefined;
|
|
111
113
|
nodeAdminUrl?: string | undefined;
|
|
112
|
-
pxeUrl?: string | undefined;
|
|
113
114
|
l1RpcUrls?: string[] | undefined;
|
|
114
115
|
l1Mnemonic?: SecretValue<string> | undefined;
|
|
115
116
|
l1PrivateKey?: SecretValue<string> | undefined;
|
|
@@ -123,6 +124,7 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
123
124
|
privateTransfersPerTx: number;
|
|
124
125
|
publicTransfersPerTx: number;
|
|
125
126
|
feePaymentMethod: "fee_juice";
|
|
127
|
+
baseFeePadding: number;
|
|
126
128
|
noStart: boolean;
|
|
127
129
|
txMinedWaitSeconds: number;
|
|
128
130
|
followChain: "NONE" | "PENDING" | "PROVEN";
|
|
@@ -131,27 +133,27 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
131
133
|
contract: SupportedTokenContracts;
|
|
132
134
|
maxConsecutiveErrors: number;
|
|
133
135
|
stopWhenUnhealthy: boolean;
|
|
136
|
+
dataDirectory?: string | undefined;
|
|
137
|
+
dataStoreMapSizeKb?: number | undefined;
|
|
134
138
|
nodeUrl?: string | undefined;
|
|
135
139
|
nodeAdminUrl?: string | undefined;
|
|
136
|
-
pxeUrl?: string | undefined;
|
|
137
140
|
l1RpcUrls?: string[] | undefined;
|
|
138
141
|
l1Mnemonic?: any;
|
|
139
142
|
l1PrivateKey?: any;
|
|
140
143
|
senderPrivateKey?: any;
|
|
141
144
|
senderSalt?: any;
|
|
142
|
-
recipientEncryptionSecret?: any;
|
|
143
145
|
tokenSalt?: any;
|
|
144
146
|
l2GasLimit?: number | undefined;
|
|
145
147
|
daGasLimit?: number | undefined;
|
|
146
148
|
ammTxs?: boolean | undefined;
|
|
147
149
|
}>, {
|
|
148
150
|
l1ToL2MessageTimeoutSeconds: number;
|
|
149
|
-
recipientEncryptionSecret: SecretValue<Fr>;
|
|
150
151
|
tokenSalt: Fr;
|
|
151
152
|
txIntervalSeconds: number;
|
|
152
153
|
privateTransfersPerTx: number;
|
|
153
154
|
publicTransfersPerTx: number;
|
|
154
155
|
feePaymentMethod: "fee_juice";
|
|
156
|
+
baseFeePadding: number;
|
|
155
157
|
noStart: boolean;
|
|
156
158
|
txMinedWaitSeconds: number;
|
|
157
159
|
followChain: "NONE" | "PENDING" | "PROVEN";
|
|
@@ -161,9 +163,10 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
161
163
|
maxConsecutiveErrors: number;
|
|
162
164
|
stopWhenUnhealthy: boolean;
|
|
163
165
|
ammTxs: boolean;
|
|
166
|
+
dataDirectory: string | undefined;
|
|
167
|
+
dataStoreMapSizeKb: number;
|
|
164
168
|
nodeUrl: string | undefined;
|
|
165
169
|
nodeAdminUrl: string | undefined;
|
|
166
|
-
pxeUrl: string | undefined;
|
|
167
170
|
l1RpcUrls: string[] | undefined;
|
|
168
171
|
l1Mnemonic: SecretValue<string> | undefined;
|
|
169
172
|
l1PrivateKey: SecretValue<string> | undefined;
|
|
@@ -177,6 +180,7 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
177
180
|
privateTransfersPerTx: number;
|
|
178
181
|
publicTransfersPerTx: number;
|
|
179
182
|
feePaymentMethod: "fee_juice";
|
|
183
|
+
baseFeePadding: number;
|
|
180
184
|
noStart: boolean;
|
|
181
185
|
txMinedWaitSeconds: number;
|
|
182
186
|
followChain: "NONE" | "PENDING" | "PROVEN";
|
|
@@ -185,15 +189,15 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
185
189
|
contract: SupportedTokenContracts;
|
|
186
190
|
maxConsecutiveErrors: number;
|
|
187
191
|
stopWhenUnhealthy: boolean;
|
|
192
|
+
dataDirectory?: string | undefined;
|
|
193
|
+
dataStoreMapSizeKb?: number | undefined;
|
|
188
194
|
nodeUrl?: string | undefined;
|
|
189
195
|
nodeAdminUrl?: string | undefined;
|
|
190
|
-
pxeUrl?: string | undefined;
|
|
191
196
|
l1RpcUrls?: string[] | undefined;
|
|
192
197
|
l1Mnemonic?: any;
|
|
193
198
|
l1PrivateKey?: any;
|
|
194
199
|
senderPrivateKey?: any;
|
|
195
200
|
senderSalt?: any;
|
|
196
|
-
recipientEncryptionSecret?: any;
|
|
197
201
|
tokenSalt?: any;
|
|
198
202
|
l2GasLimit?: number | undefined;
|
|
199
203
|
daGasLimit?: number | undefined;
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"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"}
|
package/dest/config.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { booleanConfigHelper, getConfigFromMappings, getDefaultConfig, numberConfigHelper, optionalNumberConfigHelper, secretFrConfigHelper, secretStringConfigHelper } from '@aztec/foundation/config';
|
|
1
|
+
import { booleanConfigHelper, getConfigFromMappings, getDefaultConfig, numberConfigHelper, optionalNumberConfigHelper, pickConfigMappings, secretFrConfigHelper, secretStringConfigHelper } from '@aztec/foundation/config';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
3
4
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
-
import {
|
|
5
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
5
6
|
import { schemas } from '@aztec/stdlib/schemas';
|
|
6
7
|
import { z } from 'zod';
|
|
7
8
|
const BotFollowChain = [
|
|
@@ -17,19 +18,18 @@ export var SupportedTokenContracts = /*#__PURE__*/ function(SupportedTokenContra
|
|
|
17
18
|
export const BotConfigSchema = z.object({
|
|
18
19
|
nodeUrl: z.string().optional(),
|
|
19
20
|
nodeAdminUrl: z.string().optional(),
|
|
20
|
-
pxeUrl: z.string().optional(),
|
|
21
21
|
l1RpcUrls: z.array(z.string()).optional(),
|
|
22
22
|
l1Mnemonic: schemas.SecretValue(z.string()).optional(),
|
|
23
23
|
l1PrivateKey: schemas.SecretValue(z.string()).optional(),
|
|
24
24
|
l1ToL2MessageTimeoutSeconds: z.number(),
|
|
25
25
|
senderPrivateKey: schemas.SecretValue(schemas.Fr).optional(),
|
|
26
26
|
senderSalt: schemas.Fr.optional(),
|
|
27
|
-
recipientEncryptionSecret: schemas.SecretValue(schemas.Fr),
|
|
28
27
|
tokenSalt: schemas.Fr,
|
|
29
28
|
txIntervalSeconds: z.number(),
|
|
30
29
|
privateTransfersPerTx: z.number().int().nonnegative(),
|
|
31
30
|
publicTransfersPerTx: z.number().int().nonnegative(),
|
|
32
31
|
feePaymentMethod: z.literal('fee_juice'),
|
|
32
|
+
baseFeePadding: z.number().int().nonnegative(),
|
|
33
33
|
noStart: z.boolean(),
|
|
34
34
|
txMinedWaitSeconds: z.number(),
|
|
35
35
|
followChain: z.enum(BotFollowChain),
|
|
@@ -40,11 +40,12 @@ export const BotConfigSchema = z.object({
|
|
|
40
40
|
contract: z.nativeEnum(SupportedTokenContracts),
|
|
41
41
|
maxConsecutiveErrors: z.number().int().nonnegative(),
|
|
42
42
|
stopWhenUnhealthy: z.boolean(),
|
|
43
|
-
ammTxs: z.boolean().default(false)
|
|
43
|
+
ammTxs: z.boolean().default(false),
|
|
44
|
+
dataDirectory: z.string().optional(),
|
|
45
|
+
dataStoreMapSizeKb: z.number().optional()
|
|
44
46
|
}).transform((config)=>({
|
|
45
47
|
nodeUrl: undefined,
|
|
46
48
|
nodeAdminUrl: undefined,
|
|
47
|
-
pxeUrl: undefined,
|
|
48
49
|
l1RpcUrls: undefined,
|
|
49
50
|
senderSalt: undefined,
|
|
50
51
|
l2GasLimit: undefined,
|
|
@@ -52,6 +53,8 @@ export const BotConfigSchema = z.object({
|
|
|
52
53
|
l1Mnemonic: undefined,
|
|
53
54
|
l1PrivateKey: undefined,
|
|
54
55
|
senderPrivateKey: undefined,
|
|
56
|
+
dataDirectory: undefined,
|
|
57
|
+
dataStoreMapSizeKb: 1_024 * 1_024,
|
|
55
58
|
...config
|
|
56
59
|
}));
|
|
57
60
|
export const botConfigMappings = {
|
|
@@ -63,10 +66,6 @@ export const botConfigMappings = {
|
|
|
63
66
|
env: 'AZTEC_NODE_ADMIN_URL',
|
|
64
67
|
description: 'The URL to the Aztec node admin API to force-flush txs if configured.'
|
|
65
68
|
},
|
|
66
|
-
pxeUrl: {
|
|
67
|
-
env: 'BOT_PXE_URL',
|
|
68
|
-
description: 'URL to the PXE for sending txs, or undefined if an in-proc PXE is used.'
|
|
69
|
-
},
|
|
70
69
|
l1RpcUrls: {
|
|
71
70
|
env: 'ETHEREUM_HOSTS',
|
|
72
71
|
description: 'URL of the ethereum host.',
|
|
@@ -94,18 +93,12 @@ export const botConfigMappings = {
|
|
|
94
93
|
},
|
|
95
94
|
senderSalt: {
|
|
96
95
|
env: 'BOT_ACCOUNT_SALT',
|
|
97
|
-
description: 'The salt to use to
|
|
96
|
+
description: 'The salt to use to deploy the sender account.',
|
|
98
97
|
parseEnv: (val)=>val ? Fr.fromHexString(val) : undefined
|
|
99
98
|
},
|
|
100
|
-
recipientEncryptionSecret: {
|
|
101
|
-
env: 'BOT_RECIPIENT_ENCRYPTION_SECRET',
|
|
102
|
-
description: 'Encryption secret for a recipient account.',
|
|
103
|
-
printDefault: (sv)=>sv?.getValue(),
|
|
104
|
-
...secretFrConfigHelper(Fr.fromHexString('0xcafecafe'))
|
|
105
|
-
},
|
|
106
99
|
tokenSalt: {
|
|
107
100
|
env: 'BOT_TOKEN_SALT',
|
|
108
|
-
description: '
|
|
101
|
+
description: 'The salt to use to deploy the token contract.',
|
|
109
102
|
parseEnv: (val)=>Fr.fromHexString(val),
|
|
110
103
|
defaultValue: Fr.fromHexString('1')
|
|
111
104
|
},
|
|
@@ -130,6 +123,11 @@ export const botConfigMappings = {
|
|
|
130
123
|
parseEnv: (val)=>val || undefined,
|
|
131
124
|
defaultValue: 'fee_juice'
|
|
132
125
|
},
|
|
126
|
+
baseFeePadding: {
|
|
127
|
+
env: 'BOT_BASE_FEE_PADDING',
|
|
128
|
+
description: 'How much is the bot willing to overpay vs. the current base fee',
|
|
129
|
+
...numberConfigHelper(3)
|
|
130
|
+
},
|
|
133
131
|
noStart: {
|
|
134
132
|
env: 'BOT_NO_START',
|
|
135
133
|
description: 'True to not automatically setup or start the bot on initialization.',
|
|
@@ -196,7 +194,11 @@ export const botConfigMappings = {
|
|
|
196
194
|
env: 'BOT_AMM_TXS',
|
|
197
195
|
description: 'Deploy an AMM and send swaps to it',
|
|
198
196
|
...booleanConfigHelper(false)
|
|
199
|
-
}
|
|
197
|
+
},
|
|
198
|
+
...pickConfigMappings(dataConfigMappings, [
|
|
199
|
+
'dataStoreMapSizeKb',
|
|
200
|
+
'dataDirectory'
|
|
201
|
+
])
|
|
200
202
|
};
|
|
201
203
|
export function getBotConfigFromEnv() {
|
|
202
204
|
return getConfigFromMappings(botConfigMappings);
|
|
@@ -206,7 +208,7 @@ export function getBotDefaultConfig() {
|
|
|
206
208
|
}
|
|
207
209
|
export function getVersions() {
|
|
208
210
|
return {
|
|
209
|
-
|
|
211
|
+
l2ProtocolContractsHash: protocolContractsHash.toString(),
|
|
210
212
|
l2CircuitsVkTreeRoot: getVKTreeRoot().toString()
|
|
211
213
|
};
|
|
212
214
|
}
|