@aztec/bot 0.81.0 → 0.82.0
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 +32 -0
- package/dest/amm_bot.d.ts.map +1 -0
- package/dest/amm_bot.js +56 -0
- package/dest/base_bot.d.ts +16 -0
- package/dest/base_bot.d.ts.map +1 -0
- package/dest/base_bot.js +74 -0
- package/dest/bot.d.ts +8 -12
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +11 -70
- package/dest/config.d.ts +21 -0
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +20 -1
- package/dest/factory.d.ts +22 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +112 -9
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/runner.d.ts +3 -0
- package/dest/runner.d.ts.map +1 -1
- package/dest/runner.js +15 -4
- package/dest/utils.d.ts +4 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +3 -0
- package/package.json +11 -11
- package/src/amm_bot.ts +93 -0
- package/src/base_bot.ts +75 -0
- package/src/bot.ts +19 -71
- package/src/config.ts +25 -0
- package/src/factory.ts +133 -10
- package/src/index.ts +1 -0
- package/src/runner.ts +15 -5
- package/src/utils.ts +7 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SentTx, type Wallet } from '@aztec/aztec.js';
|
|
2
|
+
import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
3
|
+
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
|
+
import type { AztecNode, AztecNodeAdmin, PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import { BaseBot } from './base_bot.js';
|
|
6
|
+
import type { BotConfig } from './config.js';
|
|
7
|
+
type Balances = {
|
|
8
|
+
token0: bigint;
|
|
9
|
+
token1: bigint;
|
|
10
|
+
};
|
|
11
|
+
export declare class AmmBot extends BaseBot {
|
|
12
|
+
readonly amm: AMMContract;
|
|
13
|
+
readonly token0: TokenContract;
|
|
14
|
+
readonly token1: TokenContract;
|
|
15
|
+
protected constructor(pxe: PXE, wallet: Wallet, amm: AMMContract, token0: TokenContract, token1: TokenContract, config: BotConfig);
|
|
16
|
+
static create(config: BotConfig, dependencies: {
|
|
17
|
+
pxe?: PXE;
|
|
18
|
+
node?: AztecNode;
|
|
19
|
+
nodeAdmin?: AztecNodeAdmin;
|
|
20
|
+
}): Promise<AmmBot>;
|
|
21
|
+
protected createAndSendTx(logCtx: object): Promise<SentTx>;
|
|
22
|
+
getAmmBalances(): Promise<Balances>;
|
|
23
|
+
getBalances(): Promise<{
|
|
24
|
+
senderPublic: Balances;
|
|
25
|
+
senderPrivate: Balances;
|
|
26
|
+
amm: Balances;
|
|
27
|
+
}>;
|
|
28
|
+
private getPublicBalanceFor;
|
|
29
|
+
private getPrivateBalanceFor;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=amm_bot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amm_bot.d.ts","sourceRoot":"","sources":["../src/amm_bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACxE,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,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,KAAK,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,qBAAa,MAAO,SAAQ,OAAO;aAIf,GAAG,EAAE,WAAW;aAChB,MAAM,EAAE,aAAa;aACrB,MAAM,EAAE,aAAa;IALvC,SAAS,aACP,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACE,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,EACrC,MAAM,EAAE,SAAS;WAKN,MAAM,CACjB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE;QAAE,GAAG,CAAC,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,CAAC;QAAC,SAAS,CAAC,EAAE,cAAc,CAAA;KAAE,GACxE,OAAO,CAAC,MAAM,CAAC;cAKF,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmCzD,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
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Fr } from '@aztec/aztec.js';
|
|
2
|
+
import { BaseBot } from './base_bot.js';
|
|
3
|
+
import { BotFactory } from './factory.js';
|
|
4
|
+
const TRANSFER_AMOUNT = 1_000;
|
|
5
|
+
export class AmmBot extends BaseBot {
|
|
6
|
+
amm;
|
|
7
|
+
token0;
|
|
8
|
+
token1;
|
|
9
|
+
constructor(pxe, wallet, amm, token0, token1, config){
|
|
10
|
+
super(pxe, wallet, config), this.amm = amm, this.token0 = token0, this.token1 = token1;
|
|
11
|
+
}
|
|
12
|
+
static async create(config, dependencies) {
|
|
13
|
+
const { pxe, wallet, token0, token1, amm } = await new BotFactory(config, dependencies).setupAmm();
|
|
14
|
+
return new AmmBot(pxe, wallet, amm, token0, token1, config);
|
|
15
|
+
}
|
|
16
|
+
async createAndSendTx(logCtx) {
|
|
17
|
+
const { feePaymentMethod } = this.config;
|
|
18
|
+
const { wallet, amm, token0, token1 } = this;
|
|
19
|
+
this.log.verbose(`Preparing tx with ${feePaymentMethod} fee to swap tokens`, logCtx);
|
|
20
|
+
const ammBalances = await this.getAmmBalances();
|
|
21
|
+
const amountIn = TRANSFER_AMOUNT;
|
|
22
|
+
const nonce = Fr.random();
|
|
23
|
+
const swapAuthwit = await wallet.createAuthWit({
|
|
24
|
+
caller: amm.address,
|
|
25
|
+
action: token0.methods.transfer_to_public(wallet.getAddress(), amm.address, amountIn, nonce)
|
|
26
|
+
});
|
|
27
|
+
const amountOutMin = await amm.methods.get_amount_out_for_exact_in(ammBalances.token0, ammBalances.token1, amountIn).simulate();
|
|
28
|
+
const swapExactTokensInteraction = amm.methods.swap_exact_tokens_for_tokens(token0.address, token1.address, amountIn, amountOutMin, nonce);
|
|
29
|
+
const opts = this.getSendMethodOpts(swapAuthwit);
|
|
30
|
+
this.log.verbose(`Proving transaction`, logCtx);
|
|
31
|
+
const tx = await swapExactTokensInteraction.prove(opts);
|
|
32
|
+
return tx.send();
|
|
33
|
+
}
|
|
34
|
+
getAmmBalances() {
|
|
35
|
+
return this.getPublicBalanceFor(this.amm.address);
|
|
36
|
+
}
|
|
37
|
+
async getBalances() {
|
|
38
|
+
return {
|
|
39
|
+
senderPublic: await this.getPublicBalanceFor(this.wallet.getAddress()),
|
|
40
|
+
senderPrivate: await this.getPrivateBalanceFor(this.wallet.getAddress()),
|
|
41
|
+
amm: await this.getPublicBalanceFor(this.amm.address)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async getPublicBalanceFor(address) {
|
|
45
|
+
return {
|
|
46
|
+
token0: await this.token0.methods.balance_of_public(address).simulate(),
|
|
47
|
+
token1: await this.token1.methods.balance_of_public(address).simulate()
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async getPrivateBalanceFor(address) {
|
|
51
|
+
return {
|
|
52
|
+
token0: await this.token0.methods.balance_of_private(address).simulate(),
|
|
53
|
+
token1: await this.token1.methods.balance_of_private(address).simulate()
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthWitness, type SendMethodOptions, SentTx, type Wallet } from '@aztec/aztec.js';
|
|
2
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import type { BotConfig } from './config.js';
|
|
4
|
+
export declare abstract class BaseBot {
|
|
5
|
+
readonly pxe: PXE;
|
|
6
|
+
readonly wallet: Wallet;
|
|
7
|
+
config: BotConfig;
|
|
8
|
+
protected log: import("@aztec/aztec.js").Logger;
|
|
9
|
+
protected attempts: number;
|
|
10
|
+
protected successes: number;
|
|
11
|
+
protected constructor(pxe: PXE, wallet: Wallet, config: BotConfig);
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
protected abstract createAndSendTx(logCtx: object): Promise<SentTx>;
|
|
14
|
+
protected getSendMethodOpts(...authWitnesses: AuthWitness[]): SendMethodOptions;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=base_bot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_bot.d.ts","sourceRoot":"","sources":["../src/base_bot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,KAAK,iBAAiB,EACtB,MAAM,EACN,KAAK,MAAM,EAGZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,8BAAsB,OAAO;aAMW,GAAG,EAAE,GAAG;aAAkB,MAAM,EAAE,MAAM;IAAS,MAAM,EAAE,SAAS;IALxG,SAAS,CAAC,GAAG,mCAAuB;IAEpC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAK;IAC/B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAK;IAEhC,SAAS,aAA6B,GAAG,EAAE,GAAG,EAAkB,MAAM,EAAE,MAAM,EAAS,MAAM,EAAE,SAAS;IAE3F,GAAG;IAgChB,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEnE,SAAS,CAAC,iBAAiB,CAAC,GAAG,aAAa,EAAE,WAAW,EAAE,GAAG,iBAAiB;CAkBhF"}
|
package/dest/base_bot.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FeeJuicePaymentMethod, createLogger, waitForProven } from '@aztec/aztec.js';
|
|
2
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
3
|
+
export class BaseBot {
|
|
4
|
+
pxe;
|
|
5
|
+
wallet;
|
|
6
|
+
config;
|
|
7
|
+
log;
|
|
8
|
+
attempts;
|
|
9
|
+
successes;
|
|
10
|
+
constructor(pxe, wallet, config){
|
|
11
|
+
this.pxe = pxe;
|
|
12
|
+
this.wallet = wallet;
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.log = createLogger('bot');
|
|
15
|
+
this.attempts = 0;
|
|
16
|
+
this.successes = 0;
|
|
17
|
+
}
|
|
18
|
+
async run() {
|
|
19
|
+
this.attempts++;
|
|
20
|
+
const logCtx = {
|
|
21
|
+
runId: Date.now() * 1000 + Math.floor(Math.random() * 1000)
|
|
22
|
+
};
|
|
23
|
+
const { followChain, txMinedWaitSeconds } = this.config;
|
|
24
|
+
this.log.verbose(`Creating tx`, logCtx);
|
|
25
|
+
const tx = await this.createAndSendTx(logCtx);
|
|
26
|
+
const txHash = await tx.getTxHash();
|
|
27
|
+
if (followChain === 'NONE') {
|
|
28
|
+
this.log.info(`Transaction ${txHash} sent, not waiting for it to be mined`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.log.verbose(`Awaiting tx ${txHash} to be on the ${followChain} chain (timeout ${txMinedWaitSeconds}s)`, logCtx);
|
|
32
|
+
const receipt = await tx.wait({
|
|
33
|
+
timeout: txMinedWaitSeconds
|
|
34
|
+
});
|
|
35
|
+
if (followChain === 'PROVEN') {
|
|
36
|
+
await waitForProven(this.pxe, receipt, {
|
|
37
|
+
provenTimeout: txMinedWaitSeconds
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
this.successes++;
|
|
41
|
+
this.log.info(`Tx #${this.attempts} ${receipt.txHash} successfully mined in block ${receipt.blockNumber} (stats: ${this.successes}/${this.attempts} success)`, logCtx);
|
|
42
|
+
}
|
|
43
|
+
getSendMethodOpts(...authWitnesses) {
|
|
44
|
+
const sender = this.wallet.getAddress();
|
|
45
|
+
const { l2GasLimit, daGasLimit, skipPublicSimulation } = this.config;
|
|
46
|
+
const paymentMethod = new FeeJuicePaymentMethod(sender);
|
|
47
|
+
let gasSettings, estimateGas;
|
|
48
|
+
if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
|
|
49
|
+
gasSettings = {
|
|
50
|
+
gasLimits: Gas.from({
|
|
51
|
+
l2Gas: l2GasLimit,
|
|
52
|
+
daGas: daGasLimit
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
estimateGas = false;
|
|
56
|
+
this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
|
|
57
|
+
} else {
|
|
58
|
+
estimateGas = true;
|
|
59
|
+
this.log.verbose(`Estimating gas for transaction`);
|
|
60
|
+
}
|
|
61
|
+
const baseFeePadding = 2; // Send 3x the current base fee
|
|
62
|
+
this.log.verbose(skipPublicSimulation ? `Skipping public simulation` : `Simulating public transfers`);
|
|
63
|
+
return {
|
|
64
|
+
fee: {
|
|
65
|
+
estimateGas,
|
|
66
|
+
paymentMethod,
|
|
67
|
+
gasSettings,
|
|
68
|
+
baseFeePadding
|
|
69
|
+
},
|
|
70
|
+
skipPublicSimulation,
|
|
71
|
+
authWitnesses
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
package/dest/bot.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { type AztecAddress, type Wallet } from '@aztec/aztec.js';
|
|
1
|
+
import { type AztecAddress, SentTx, type Wallet } from '@aztec/aztec.js';
|
|
2
2
|
import type { EasyPrivateTokenContract } from '@aztec/noir-contracts.js/EasyPrivateToken';
|
|
3
3
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
|
-
import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import type { AztecNode, AztecNodeAdmin, PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import { BaseBot } from './base_bot.js';
|
|
5
6
|
import type { BotConfig } from './config.js';
|
|
6
|
-
export declare class Bot {
|
|
7
|
-
readonly wallet: Wallet;
|
|
7
|
+
export declare class Bot extends BaseBot {
|
|
8
8
|
readonly token: TokenContract | EasyPrivateTokenContract;
|
|
9
9
|
readonly recipient: AztecAddress;
|
|
10
|
-
config: BotConfig;
|
|
11
|
-
|
|
12
|
-
private attempts;
|
|
13
|
-
private successes;
|
|
14
|
-
protected constructor(wallet: Wallet, token: TokenContract | EasyPrivateTokenContract, recipient: AztecAddress, config: BotConfig);
|
|
15
|
-
static create(config: BotConfig, dependencies?: {
|
|
10
|
+
protected constructor(pxe: PXE, wallet: Wallet, token: TokenContract | EasyPrivateTokenContract, recipient: AztecAddress, config: BotConfig);
|
|
11
|
+
static create(config: BotConfig, dependencies: {
|
|
16
12
|
pxe?: PXE;
|
|
17
13
|
node?: AztecNode;
|
|
14
|
+
nodeAdmin?: AztecNodeAdmin;
|
|
18
15
|
}): Promise<Bot>;
|
|
19
16
|
updateConfig(config: Partial<BotConfig>): void;
|
|
20
|
-
|
|
17
|
+
protected createAndSendTx(logCtx: object): Promise<SentTx>;
|
|
21
18
|
getBalances(): Promise<{
|
|
22
19
|
sender: {
|
|
23
20
|
privateBalance: bigint;
|
|
@@ -28,6 +25,5 @@ export declare class Bot {
|
|
|
28
25
|
publicBalance: bigint;
|
|
29
26
|
};
|
|
30
27
|
}>;
|
|
31
|
-
private getSendMethodOpts;
|
|
32
28
|
}
|
|
33
29
|
//# sourceMappingURL=bot.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../src/bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEpF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C,qBAAa,GAAI,SAAQ,OAAO;aAIZ,KAAK,EAAE,aAAa,GAAG,wBAAwB;aAC/C,SAAS,EAAE,YAAY;IAJzC,SAAS,aACP,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACE,KAAK,EAAE,aAAa,GAAG,wBAAwB,EAC/C,SAAS,EAAE,YAAY,EACvC,MAAM,EAAE,SAAS;WAKN,MAAM,CACjB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE;QAAE,GAAG,CAAC,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,CAAC;QAAC,SAAS,CAAC,EAAE,cAAc,CAAA;KAAE,GACxE,OAAO,CAAC,GAAG,CAAC;IAKR,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC;cAK9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BnD,WAAW;;;;;;;;;;CAmBzB"}
|
package/dest/bot.js
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
import { BatchCall
|
|
1
|
+
import { BatchCall } from '@aztec/aztec.js';
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseBot } from './base_bot.js';
|
|
4
4
|
import { BotFactory } from './factory.js';
|
|
5
5
|
import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils.js';
|
|
6
6
|
const TRANSFER_AMOUNT = 1;
|
|
7
|
-
export class Bot {
|
|
8
|
-
wallet;
|
|
7
|
+
export class Bot extends BaseBot {
|
|
9
8
|
token;
|
|
10
9
|
recipient;
|
|
11
|
-
config
|
|
12
|
-
|
|
13
|
-
attempts;
|
|
14
|
-
successes;
|
|
15
|
-
constructor(wallet, token, recipient, config){
|
|
16
|
-
this.wallet = wallet;
|
|
17
|
-
this.token = token;
|
|
18
|
-
this.recipient = recipient;
|
|
19
|
-
this.config = config;
|
|
20
|
-
this.log = createLogger('bot');
|
|
21
|
-
this.attempts = 0;
|
|
22
|
-
this.successes = 0;
|
|
10
|
+
constructor(pxe, wallet, token, recipient, config){
|
|
11
|
+
super(pxe, wallet, config), this.token = token, this.recipient = recipient;
|
|
23
12
|
}
|
|
24
|
-
static async create(config, dependencies
|
|
25
|
-
const { wallet, token, recipient } = await new BotFactory(config, dependencies).setup();
|
|
26
|
-
return new Bot(wallet, token, recipient, config);
|
|
13
|
+
static async create(config, dependencies) {
|
|
14
|
+
const { pxe, wallet, token, recipient } = await new BotFactory(config, dependencies).setup();
|
|
15
|
+
return new Bot(pxe, wallet, token, recipient, config);
|
|
27
16
|
}
|
|
28
17
|
updateConfig(config) {
|
|
29
18
|
this.log.info(`Updating bot config ${Object.keys(config).join(', ')}`);
|
|
@@ -32,12 +21,8 @@ export class Bot {
|
|
|
32
21
|
...config
|
|
33
22
|
};
|
|
34
23
|
}
|
|
35
|
-
async
|
|
36
|
-
this.
|
|
37
|
-
const logCtx = {
|
|
38
|
-
runId: Date.now() * 1000 + Math.floor(Math.random() * 1000)
|
|
39
|
-
};
|
|
40
|
-
const { privateTransfersPerTx, publicTransfersPerTx, feePaymentMethod, followChain, txMinedWaitSeconds } = this.config;
|
|
24
|
+
async createAndSendTx(logCtx) {
|
|
25
|
+
const { privateTransfersPerTx, publicTransfersPerTx, feePaymentMethod } = this.config;
|
|
41
26
|
const { token, recipient, wallet } = this;
|
|
42
27
|
const sender = wallet.getAddress();
|
|
43
28
|
this.log.verbose(`Preparing tx with ${feePaymentMethod} fee with ${privateTransfersPerTx} private and ${publicTransfersPerTx} public transfers`, logCtx);
|
|
@@ -51,21 +36,7 @@ export class Bot {
|
|
|
51
36
|
await batch.simulate();
|
|
52
37
|
this.log.verbose(`Proving transaction`, logCtx);
|
|
53
38
|
const provenTx = await batch.prove(opts);
|
|
54
|
-
|
|
55
|
-
const tx = provenTx.send();
|
|
56
|
-
const txHash = await tx.getTxHash();
|
|
57
|
-
if (followChain === 'NONE') {
|
|
58
|
-
this.log.info(`Transaction ${txHash} sent, not waiting for it to be mined`);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.log.verbose(`Awaiting tx ${txHash} to be on the ${followChain} chain (timeout ${txMinedWaitSeconds}s)`, logCtx);
|
|
62
|
-
const receipt = await tx.wait({
|
|
63
|
-
timeout: txMinedWaitSeconds,
|
|
64
|
-
provenTimeout: txMinedWaitSeconds,
|
|
65
|
-
proven: followChain === 'PROVEN'
|
|
66
|
-
});
|
|
67
|
-
this.log.info(`Tx #${this.attempts} ${receipt.txHash} successfully mined in block ${receipt.blockNumber} (stats: ${this.successes}/${this.attempts} success)`, logCtx);
|
|
68
|
-
this.successes++;
|
|
39
|
+
return provenTx.send();
|
|
69
40
|
}
|
|
70
41
|
async getBalances() {
|
|
71
42
|
if (isStandardTokenContract(this.token)) {
|
|
@@ -86,34 +57,4 @@ export class Bot {
|
|
|
86
57
|
};
|
|
87
58
|
}
|
|
88
59
|
}
|
|
89
|
-
getSendMethodOpts() {
|
|
90
|
-
const sender = this.wallet.getAddress();
|
|
91
|
-
const { l2GasLimit, daGasLimit, skipPublicSimulation } = this.config;
|
|
92
|
-
const paymentMethod = new FeeJuicePaymentMethod(sender);
|
|
93
|
-
let gasSettings, estimateGas;
|
|
94
|
-
if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
|
|
95
|
-
gasSettings = {
|
|
96
|
-
gasLimits: Gas.from({
|
|
97
|
-
l2Gas: l2GasLimit,
|
|
98
|
-
daGas: daGasLimit
|
|
99
|
-
})
|
|
100
|
-
};
|
|
101
|
-
estimateGas = false;
|
|
102
|
-
this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
|
|
103
|
-
} else {
|
|
104
|
-
estimateGas = true;
|
|
105
|
-
this.log.verbose(`Estimating gas for transaction`);
|
|
106
|
-
}
|
|
107
|
-
const baseFeePadding = 2; // Send 3x the current base fee
|
|
108
|
-
this.log.verbose(skipPublicSimulation ? `Skipping public simulation` : `Simulating public transfers`);
|
|
109
|
-
return {
|
|
110
|
-
fee: {
|
|
111
|
-
estimateGas,
|
|
112
|
-
paymentMethod,
|
|
113
|
-
gasSettings,
|
|
114
|
-
baseFeePadding
|
|
115
|
-
},
|
|
116
|
-
skipPublicSimulation
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
60
|
}
|
package/dest/config.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare enum SupportedTokenContracts {
|
|
|
12
12
|
export type BotConfig = {
|
|
13
13
|
/** The URL to the Aztec node to check for tx pool status. */
|
|
14
14
|
nodeUrl: string | undefined;
|
|
15
|
+
/** The URL to the Aztec node admin API to force-flush txs if configured. */
|
|
16
|
+
nodeAdminUrl: string | undefined;
|
|
15
17
|
/** URL to the PXE for sending txs, or undefined if an in-proc PXE is used. */
|
|
16
18
|
pxeUrl: string | undefined;
|
|
17
19
|
/** Url of the ethereum host. */
|
|
@@ -22,6 +24,8 @@ export type BotConfig = {
|
|
|
22
24
|
l1PrivateKey: string | undefined;
|
|
23
25
|
/** Signing private key for the sender account. */
|
|
24
26
|
senderPrivateKey: Fr | undefined;
|
|
27
|
+
/** Optional salt to use to deploy the sender account */
|
|
28
|
+
senderSalt: Fr | undefined;
|
|
25
29
|
/** Encryption secret for a recipient account. */
|
|
26
30
|
recipientEncryptionSecret: Fr;
|
|
27
31
|
/** Salt for the token contract deployment. */
|
|
@@ -56,14 +60,18 @@ export type BotConfig = {
|
|
|
56
60
|
maxConsecutiveErrors: number;
|
|
57
61
|
/** Stops the bot if service becomes unhealthy */
|
|
58
62
|
stopWhenUnhealthy: boolean;
|
|
63
|
+
/** Deploy an AMM contract and do swaps instead of transfers */
|
|
64
|
+
ammTxs: boolean;
|
|
59
65
|
};
|
|
60
66
|
export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
61
67
|
nodeUrl: z.ZodOptional<z.ZodString>;
|
|
68
|
+
nodeAdminUrl: z.ZodOptional<z.ZodString>;
|
|
62
69
|
pxeUrl: z.ZodOptional<z.ZodString>;
|
|
63
70
|
l1RpcUrls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
64
71
|
l1Mnemonic: z.ZodOptional<z.ZodString>;
|
|
65
72
|
l1PrivateKey: z.ZodOptional<z.ZodString>;
|
|
66
73
|
senderPrivateKey: z.ZodOptional<ZodFor<Fr>>;
|
|
74
|
+
senderSalt: z.ZodOptional<ZodFor<Fr>>;
|
|
67
75
|
recipientEncryptionSecret: ZodFor<Fr>;
|
|
68
76
|
tokenSalt: ZodFor<Fr>;
|
|
69
77
|
txIntervalSeconds: z.ZodNumber;
|
|
@@ -81,6 +89,7 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
81
89
|
contract: z.ZodNativeEnum<typeof SupportedTokenContracts>;
|
|
82
90
|
maxConsecutiveErrors: z.ZodNumber;
|
|
83
91
|
stopWhenUnhealthy: z.ZodBoolean;
|
|
92
|
+
ammTxs: z.ZodDefault<z.ZodBoolean>;
|
|
84
93
|
}, "strip", z.ZodTypeAny, {
|
|
85
94
|
recipientEncryptionSecret: Fr;
|
|
86
95
|
tokenSalt: Fr;
|
|
@@ -97,12 +106,15 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
97
106
|
contract: SupportedTokenContracts;
|
|
98
107
|
maxConsecutiveErrors: number;
|
|
99
108
|
stopWhenUnhealthy: boolean;
|
|
109
|
+
ammTxs: boolean;
|
|
100
110
|
nodeUrl?: string | undefined;
|
|
111
|
+
nodeAdminUrl?: string | undefined;
|
|
101
112
|
pxeUrl?: string | undefined;
|
|
102
113
|
l1RpcUrls?: string[] | undefined;
|
|
103
114
|
l1Mnemonic?: string | undefined;
|
|
104
115
|
l1PrivateKey?: string | undefined;
|
|
105
116
|
senderPrivateKey?: Fr | undefined;
|
|
117
|
+
senderSalt?: Fr | undefined;
|
|
106
118
|
l2GasLimit?: number | undefined;
|
|
107
119
|
daGasLimit?: number | undefined;
|
|
108
120
|
}, {
|
|
@@ -120,15 +132,18 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
120
132
|
maxConsecutiveErrors: number;
|
|
121
133
|
stopWhenUnhealthy: boolean;
|
|
122
134
|
nodeUrl?: string | undefined;
|
|
135
|
+
nodeAdminUrl?: string | undefined;
|
|
123
136
|
pxeUrl?: string | undefined;
|
|
124
137
|
l1RpcUrls?: string[] | undefined;
|
|
125
138
|
l1Mnemonic?: string | undefined;
|
|
126
139
|
l1PrivateKey?: string | undefined;
|
|
127
140
|
senderPrivateKey?: any;
|
|
141
|
+
senderSalt?: any;
|
|
128
142
|
recipientEncryptionSecret?: any;
|
|
129
143
|
tokenSalt?: any;
|
|
130
144
|
l2GasLimit?: number | undefined;
|
|
131
145
|
daGasLimit?: number | undefined;
|
|
146
|
+
ammTxs?: boolean | undefined;
|
|
132
147
|
}>, {
|
|
133
148
|
recipientEncryptionSecret: Fr;
|
|
134
149
|
tokenSalt: Fr;
|
|
@@ -145,12 +160,15 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
145
160
|
contract: SupportedTokenContracts;
|
|
146
161
|
maxConsecutiveErrors: number;
|
|
147
162
|
stopWhenUnhealthy: boolean;
|
|
163
|
+
ammTxs: boolean;
|
|
148
164
|
nodeUrl: string | undefined;
|
|
165
|
+
nodeAdminUrl: string | undefined;
|
|
149
166
|
pxeUrl: string | undefined;
|
|
150
167
|
l1RpcUrls: string[] | undefined;
|
|
151
168
|
l1Mnemonic: string | undefined;
|
|
152
169
|
l1PrivateKey: string | undefined;
|
|
153
170
|
senderPrivateKey: Fr | undefined;
|
|
171
|
+
senderSalt: Fr | undefined;
|
|
154
172
|
l2GasLimit: number | undefined;
|
|
155
173
|
daGasLimit: number | undefined;
|
|
156
174
|
}, {
|
|
@@ -168,15 +186,18 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
168
186
|
maxConsecutiveErrors: number;
|
|
169
187
|
stopWhenUnhealthy: boolean;
|
|
170
188
|
nodeUrl?: string | undefined;
|
|
189
|
+
nodeAdminUrl?: string | undefined;
|
|
171
190
|
pxeUrl?: string | undefined;
|
|
172
191
|
l1RpcUrls?: string[] | undefined;
|
|
173
192
|
l1Mnemonic?: string | undefined;
|
|
174
193
|
l1PrivateKey?: string | undefined;
|
|
175
194
|
senderPrivateKey?: any;
|
|
195
|
+
senderSalt?: any;
|
|
176
196
|
recipientEncryptionSecret?: any;
|
|
177
197
|
tokenSalt?: any;
|
|
178
198
|
l2GasLimit?: number | undefined;
|
|
179
199
|
daGasLimit?: number | undefined;
|
|
200
|
+
ammTxs?: boolean | undefined;
|
|
180
201
|
}>;
|
|
181
202
|
export declare const botConfigMappings: ConfigMappingsType<BotConfig>;
|
|
182
203
|
export declare function getBotConfigFromEnv(): BotConfig;
|
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,EAMxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,cAAc,wCAAyC,CAAC;AAC9D,KAAK,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,oBAAY,uBAAuB;IACjC,aAAa,kBAAkB;IAC/B,wBAAwB,6BAA6B;CACtD;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,8EAA8E;IAC9E,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,gCAAgC;IAChC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAChC,gEAAgE;IAChE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,mEAAmE;IACnE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,kDAAkD;IAClD,gBAAgB,EAAE,EAAE,GAAG,SAAS,CAAC;IACjC,iDAAiD;IACjD,yBAAyB,EAAE,EAAE,CAAC;IAC9B,8CAA8C;IAC9C,SAAS,EAAE,EAAE,CAAC;IACd,sDAAsD;IACtD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,4DAA4D;IAC5D,qBAAqB,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kCAAkC;IAClC,gBAAgB,EAAE,WAAW,CAAC;IAC9B,0EAA0E;IAC1E,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,WAAW,EAAE,cAAc,CAAC;IAC5B,gFAAgF;IAChF,aAAa,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,sBAAsB,EAAE,OAAO,CAAC;IAChC,oEAAoE;IACpE,oBAAoB,EAAE,OAAO,CAAC;IAC9B,+EAA+E;IAC/E,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,+EAA+E;IAC/E,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,4BAA4B;IAC5B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,yEAAyE;IACzE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iDAAiD;IACjD,iBAAiB,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,cAAc,wCAAyC,CAAC;AAC9D,KAAK,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,oBAAY,uBAAuB;IACjC,aAAa,kBAAkB;IAC/B,wBAAwB,6BAA6B;CACtD;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,4EAA4E;IAC5E,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,8EAA8E;IAC9E,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,gCAAgC;IAChC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAChC,gEAAgE;IAChE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,mEAAmE;IACnE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,kDAAkD;IAClD,gBAAgB,EAAE,EAAE,GAAG,SAAS,CAAC;IACjC,wDAAwD;IACxD,UAAU,EAAE,EAAE,GAAG,SAAS,CAAC;IAC3B,iDAAiD;IACjD,yBAAyB,EAAE,EAAE,CAAC;IAC9B,8CAA8C;IAC9C,SAAS,EAAE,EAAE,CAAC;IACd,sDAAsD;IACtD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,4DAA4D;IAC5D,qBAAqB,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kCAAkC;IAClC,gBAAgB,EAAE,WAAW,CAAC;IAC9B,0EAA0E;IAC1E,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,WAAW,EAAE,cAAc,CAAC;IAC5B,gFAAgF;IAChF,aAAa,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,sBAAsB,EAAE,OAAO,CAAC;IAChC,oEAAoE;IACpE,oBAAoB,EAAE,OAAO,CAAC;IAC9B,+EAA+E;IAC/E,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,+EAA+E;IAC/E,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,4BAA4B;IAC5B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,yEAAyE;IACzE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iDAAiD;IACjD,iBAAiB,EAAE,OAAO,CAAC;IAC3B,+DAA+D;IAC/D,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCK,CAAC;AAElC,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CAiJ3D,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,WAAW,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAKzD"}
|
package/dest/config.js
CHANGED
|
@@ -16,11 +16,13 @@ export var SupportedTokenContracts = /*#__PURE__*/ function(SupportedTokenContra
|
|
|
16
16
|
}({});
|
|
17
17
|
export const BotConfigSchema = z.object({
|
|
18
18
|
nodeUrl: z.string().optional(),
|
|
19
|
+
nodeAdminUrl: z.string().optional(),
|
|
19
20
|
pxeUrl: z.string().optional(),
|
|
20
21
|
l1RpcUrls: z.array(z.string()).optional(),
|
|
21
22
|
l1Mnemonic: z.string().optional(),
|
|
22
23
|
l1PrivateKey: z.string().optional(),
|
|
23
24
|
senderPrivateKey: schemas.Fr.optional(),
|
|
25
|
+
senderSalt: schemas.Fr.optional(),
|
|
24
26
|
recipientEncryptionSecret: schemas.Fr,
|
|
25
27
|
tokenSalt: schemas.Fr,
|
|
26
28
|
txIntervalSeconds: z.number(),
|
|
@@ -37,14 +39,17 @@ export const BotConfigSchema = z.object({
|
|
|
37
39
|
daGasLimit: z.number().int().nonnegative().optional(),
|
|
38
40
|
contract: z.nativeEnum(SupportedTokenContracts),
|
|
39
41
|
maxConsecutiveErrors: z.number().int().nonnegative(),
|
|
40
|
-
stopWhenUnhealthy: z.boolean()
|
|
42
|
+
stopWhenUnhealthy: z.boolean(),
|
|
43
|
+
ammTxs: z.boolean().default(false)
|
|
41
44
|
}).transform((config)=>({
|
|
42
45
|
nodeUrl: undefined,
|
|
46
|
+
nodeAdminUrl: undefined,
|
|
43
47
|
pxeUrl: undefined,
|
|
44
48
|
l1RpcUrls: undefined,
|
|
45
49
|
l1Mnemonic: undefined,
|
|
46
50
|
l1PrivateKey: undefined,
|
|
47
51
|
senderPrivateKey: undefined,
|
|
52
|
+
senderSalt: undefined,
|
|
48
53
|
l2GasLimit: undefined,
|
|
49
54
|
daGasLimit: undefined,
|
|
50
55
|
...config
|
|
@@ -54,6 +59,10 @@ export const botConfigMappings = {
|
|
|
54
59
|
env: 'AZTEC_NODE_URL',
|
|
55
60
|
description: 'The URL to the Aztec node to check for tx pool status.'
|
|
56
61
|
},
|
|
62
|
+
nodeAdminUrl: {
|
|
63
|
+
env: 'AZTEC_NODE_ADMIN_URL',
|
|
64
|
+
description: 'The URL to the Aztec node admin API to force-flush txs if configured.'
|
|
65
|
+
},
|
|
57
66
|
pxeUrl: {
|
|
58
67
|
env: 'BOT_PXE_URL',
|
|
59
68
|
description: 'URL to the PXE for sending txs, or undefined if an in-proc PXE is used.'
|
|
@@ -76,6 +85,11 @@ export const botConfigMappings = {
|
|
|
76
85
|
description: 'Signing private key for the sender account.',
|
|
77
86
|
parseEnv: (val)=>val ? Fr.fromHexString(val) : undefined
|
|
78
87
|
},
|
|
88
|
+
senderSalt: {
|
|
89
|
+
env: 'BOT_ACCOUNT_SALT',
|
|
90
|
+
description: 'The salt to use to deploys the sender account.',
|
|
91
|
+
parseEnv: (val)=>val ? Fr.fromHexString(val) : undefined
|
|
92
|
+
},
|
|
79
93
|
recipientEncryptionSecret: {
|
|
80
94
|
env: 'BOT_RECIPIENT_ENCRYPTION_SECRET',
|
|
81
95
|
description: 'Encryption secret for a recipient account.',
|
|
@@ -175,6 +189,11 @@ export const botConfigMappings = {
|
|
|
175
189
|
env: 'BOT_STOP_WHEN_UNHEALTHY',
|
|
176
190
|
description: 'Stops the bot if service becomes unhealthy',
|
|
177
191
|
...booleanConfigHelper(false)
|
|
192
|
+
},
|
|
193
|
+
ammTxs: {
|
|
194
|
+
env: 'BOT_AMM_TXS',
|
|
195
|
+
description: 'Deploy an AMM and send swaps to it',
|
|
196
|
+
...booleanConfigHelper(false)
|
|
178
197
|
}
|
|
179
198
|
};
|
|
180
199
|
export function getBotConfigFromEnv() {
|
package/dest/factory.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { AztecAddress, type
|
|
1
|
+
import { AztecAddress, type PXE } from '@aztec/aztec.js';
|
|
2
|
+
import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
2
3
|
import { EasyPrivateTokenContract } from '@aztec/noir-contracts.js/EasyPrivateToken';
|
|
3
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
|
+
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
4
6
|
import { type BotConfig } from './config.js';
|
|
5
7
|
export declare class BotFactory {
|
|
6
8
|
private readonly config;
|
|
7
9
|
private pxe;
|
|
8
10
|
private node?;
|
|
11
|
+
private nodeAdmin?;
|
|
9
12
|
private log;
|
|
10
|
-
constructor(config: BotConfig, dependencies
|
|
13
|
+
constructor(config: BotConfig, dependencies: {
|
|
11
14
|
pxe?: PXE;
|
|
15
|
+
nodeAdmin?: AztecNodeAdmin;
|
|
12
16
|
node?: AztecNode;
|
|
13
17
|
});
|
|
14
18
|
/**
|
|
@@ -21,6 +25,13 @@ export declare class BotFactory {
|
|
|
21
25
|
pxe: PXE;
|
|
22
26
|
recipient: AztecAddress;
|
|
23
27
|
}>;
|
|
28
|
+
setupAmm(): Promise<{
|
|
29
|
+
wallet: import("@aztec/aztec.js").AccountWalletWithSecretKey;
|
|
30
|
+
amm: AMMContract;
|
|
31
|
+
token0: TokenContract;
|
|
32
|
+
token1: TokenContract;
|
|
33
|
+
pxe: PXE;
|
|
34
|
+
}>;
|
|
24
35
|
/**
|
|
25
36
|
* Checks if the sender account contract is initialized, and initializes it if necessary.
|
|
26
37
|
* @returns The sender wallet.
|
|
@@ -38,6 +49,15 @@ export declare class BotFactory {
|
|
|
38
49
|
* @returns The TokenContract instance.
|
|
39
50
|
*/
|
|
40
51
|
private setupToken;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if the token contract is deployed and deploys it if necessary.
|
|
54
|
+
* @param wallet - Wallet to deploy the token contract from.
|
|
55
|
+
* @returns The TokenContract instance.
|
|
56
|
+
*/
|
|
57
|
+
private setupTokenContract;
|
|
58
|
+
private setupAmmContract;
|
|
59
|
+
private fundAmm;
|
|
60
|
+
private registerOrDeployContract;
|
|
41
61
|
/**
|
|
42
62
|
* Mints private and public tokens for the sender if their balance is below the minimum.
|
|
43
63
|
* @param token - Token contract.
|
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,EAEL,YAAY,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAQZ,KAAK,GAAG,EAIT,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAIjF,OAAO,EAAE,KAAK,SAAS,EAAwC,MAAM,aAAa,CAAC;AAMnF,qBAAa,UAAU;IAOnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,IAAI,CAAC,CAAY;IACzB,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,OAAO,CAAC,GAAG,CAAuB;gBAGf,MAAM,EAAE,SAAS,EAClC,YAAY,EAAE;QAAE,GAAG,CAAC,EAAE,GAAG,CAAC;QAAC,SAAS,CAAC,EAAE,cAAc,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,CAAA;KAAE;IA4B3E;;;OAGG;IACU,KAAK;;;;;;IAQL,QAAQ;;;;;;;IAarB;;;OAGG;YACW,YAAY;YAQZ,0BAA0B;YA8B1B,gBAAgB;IAc9B;;OAEG;YACW,iBAAiB;IAK/B;;;;OAIG;YACW,UAAU;IA8BxB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;YAYZ,gBAAgB;YAoBhB,OAAO;YAyCP,wBAAwB;IAoBtC;;;OAGG;YACW,UAAU;YAuCV,gBAAgB;YAgChB,cAAc;YAMd,WAAW;CAU1B"}
|