@aztec/bot 0.0.1-commit.cd76b27 → 0.0.1-commit.ce4f8c4f2
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 +1 -1
- package/dest/amm_bot.d.ts.map +1 -1
- package/dest/amm_bot.js +23 -16
- package/dest/bot.d.ts +1 -1
- package/dest/bot.d.ts.map +1 -1
- package/dest/bot.js +2 -1
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -2
- package/dest/cross_chain_bot.d.ts +1 -1
- package/dest/cross_chain_bot.d.ts.map +1 -1
- package/dest/cross_chain_bot.js +3 -9
- package/dest/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +126 -34
- package/dest/utils.js +3 -3
- package/package.json +15 -15
- package/src/amm_bot.ts +20 -15
- package/src/bot.ts +2 -1
- package/src/config.ts +1 -2
- package/src/cross_chain_bot.ts +3 -9
- package/src/factory.ts +95 -38
- package/src/utils.ts +3 -3
package/dest/amm_bot.d.ts
CHANGED
|
@@ -29,4 +29,4 @@ export declare class AmmBot extends BaseBot {
|
|
|
29
29
|
private getPrivateBalanceFor;
|
|
30
30
|
}
|
|
31
31
|
export {};
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1tX2JvdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FtbV9ib3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3pELE9BQU8sRUFBRSxNQUFNLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFdkQsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU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,CAAC;AAKjD,KAAK,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,qBAAa,MAAO,SAAQ,OAAO;aAKf,GAAG,EAAE,WAAW;aAChB,MAAM,EAAE,aAAa;aACrB,MAAM,EAAE,aAAa;IANvC,SAAS,aACP,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,cAAc,EACtB,qBAAqB,EAAE,YAAY,EACnB,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,EACrC,MAAM,EAAE,SAAS,EAGlB;IAED,OAAa,MAAM,CACjB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,KAAK,EAAE,QAAQ,GACd,OAAO,CAAC,MAAM,CAAC,CASjB;IAED,UAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA6C/D;IAED,UAAyB,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpF;IAEM,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CAEzC;IAEY,WAAW,IAAI,OAAO,CAAC;QAAE,YAAY,EAAE,QAAQ,CAAC;QAAC,aAAa,EAAE,QAAQ,CAAC;QAAC,GAAG,EAAE,QAAQ,CAAA;KAAE,CAAC,CAMtG;YAEa,mBAAmB;YAKnB,oBAAoB;CASnC"}
|
package/dest/amm_bot.js
CHANGED
|
@@ -38,11 +38,13 @@ export class AmmBot extends BaseBot {
|
|
|
38
38
|
caller: amm.address,
|
|
39
39
|
call: await tokenIn.methods.transfer_to_public(this.defaultAccountAddress, amm.address, amountIn, authwitNonce).getFunctionCall()
|
|
40
40
|
});
|
|
41
|
-
const
|
|
41
|
+
const { result: tokenInBalance } = await tokenIn.methods.balance_of_public(amm.address).simulate({
|
|
42
42
|
from: this.defaultAccountAddress
|
|
43
|
-
})
|
|
43
|
+
});
|
|
44
|
+
const { result: tokenOutBalance } = await tokenOut.methods.balance_of_public(amm.address).simulate({
|
|
44
45
|
from: this.defaultAccountAddress
|
|
45
|
-
})
|
|
46
|
+
});
|
|
47
|
+
const { result: amountOutMin } = await amm.methods.get_amount_out_for_exact_in(tokenInBalance, tokenOutBalance, amountIn).simulate({
|
|
46
48
|
from: this.defaultAccountAddress
|
|
47
49
|
});
|
|
48
50
|
const swapExactTokensInteraction = amm.methods.swap_exact_tokens_for_tokens(tokenIn.address, tokenOut.address, amountIn, amountOutMin, authwitNonce).with({
|
|
@@ -56,10 +58,11 @@ export class AmmBot extends BaseBot {
|
|
|
56
58
|
...logCtx,
|
|
57
59
|
balances
|
|
58
60
|
});
|
|
59
|
-
|
|
61
|
+
const { txHash } = await swapExactTokensInteraction.send({
|
|
60
62
|
...opts,
|
|
61
63
|
wait: NO_WAIT
|
|
62
64
|
});
|
|
65
|
+
return txHash;
|
|
63
66
|
}
|
|
64
67
|
async onTxMined(receipt, logCtx) {
|
|
65
68
|
const balances = await this.getBalances();
|
|
@@ -79,23 +82,27 @@ export class AmmBot extends BaseBot {
|
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
84
|
async getPublicBalanceFor(address, from) {
|
|
85
|
+
const { result: token0 } = await this.token0.methods.balance_of_public(address).simulate({
|
|
86
|
+
from: from ?? address
|
|
87
|
+
});
|
|
88
|
+
const { result: token1 } = await this.token1.methods.balance_of_public(address).simulate({
|
|
89
|
+
from: from ?? address
|
|
90
|
+
});
|
|
82
91
|
return {
|
|
83
|
-
token0
|
|
84
|
-
|
|
85
|
-
}),
|
|
86
|
-
token1: await this.token1.methods.balance_of_public(address).simulate({
|
|
87
|
-
from: from ?? address
|
|
88
|
-
})
|
|
92
|
+
token0,
|
|
93
|
+
token1
|
|
89
94
|
};
|
|
90
95
|
}
|
|
91
96
|
async getPrivateBalanceFor(address, from) {
|
|
97
|
+
const { result: token0 } = await this.token0.methods.balance_of_private(address).simulate({
|
|
98
|
+
from: from ?? address
|
|
99
|
+
});
|
|
100
|
+
const { result: token1 } = await this.token1.methods.balance_of_private(address).simulate({
|
|
101
|
+
from: from ?? address
|
|
102
|
+
});
|
|
92
103
|
return {
|
|
93
|
-
token0
|
|
94
|
-
|
|
95
|
-
}),
|
|
96
|
-
token1: await this.token1.methods.balance_of_private(address).simulate({
|
|
97
|
-
from: from ?? address
|
|
98
|
-
})
|
|
104
|
+
token0,
|
|
105
|
+
token1
|
|
99
106
|
};
|
|
100
107
|
}
|
|
101
108
|
}
|
package/dest/bot.d.ts
CHANGED
|
@@ -25,4 +25,4 @@ export declare class Bot extends BaseBot {
|
|
|
25
25
|
};
|
|
26
26
|
}>;
|
|
27
27
|
}
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTlELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU1QyxPQUFPLEtBQUssRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQ2xGLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUU5RCxPQUFPLEV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EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD,qBAAa,GAAI,SAAQ,OAAO;aAKZ,KAAK,EAAE,aAAa,GAAG,oBAAoB;aAC3C,SAAS,EAAE,YAAY;IALzC,SAAS,aACP,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,cAAc,EACtB,qBAAqB,EAAE,YAAY,EACnB,KAAK,EAAE,aAAa,GAAG,oBAAoB,EAC3C,SAAS,EAAE,YAAY,EACvC,MAAM,EAAE,SAAS,EAGlB;IAED,OAAa,MAAM,CACjB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,KAAK,EAAE,QAAQ,GACd,OAAO,CAAC,GAAG,CAAC,CASd;IAEM,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,QAG7C;IAED,UAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA6B/D;IAEY,WAAW;;;;;;;;;OAkBvB;CACF"}
|
package/dest/bot.js
CHANGED
|
@@ -36,10 +36,11 @@ export class Bot extends BaseBot {
|
|
|
36
36
|
from: this.defaultAccountAddress
|
|
37
37
|
});
|
|
38
38
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
39
|
-
|
|
39
|
+
const { txHash } = await batch.send({
|
|
40
40
|
...opts,
|
|
41
41
|
wait: NO_WAIT
|
|
42
42
|
});
|
|
43
|
+
return txHash;
|
|
43
44
|
}
|
|
44
45
|
async getBalances() {
|
|
45
46
|
if (isStandardTokenContract(this.token)) {
|
package/dest/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ConfigMappingsType, SecretValue } from '@aztec/foundation/config';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { type DataStoreConfig } from '@aztec/kv-store
|
|
3
|
+
import { type DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
4
4
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
declare const BotFollowChain: readonly ["NONE", "PROPOSED", "CHECKPOINTED", "PROVEN"];
|
|
@@ -176,6 +176,7 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
176
176
|
botMode: "amm" | "crosschain" | "transfer";
|
|
177
177
|
l2ToL1MessagesPerTx: number;
|
|
178
178
|
l1ToL2SeedCount: number;
|
|
179
|
+
dataDirectory?: string | undefined;
|
|
179
180
|
nodeUrl: string | undefined;
|
|
180
181
|
nodeAdminUrl: string | undefined;
|
|
181
182
|
l1RpcUrls: string[] | undefined;
|
|
@@ -185,7 +186,6 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
185
186
|
l1Mnemonic: SecretValue<string> | undefined;
|
|
186
187
|
l1PrivateKey: SecretValue<string> | undefined;
|
|
187
188
|
senderPrivateKey: SecretValue<Fr> | undefined;
|
|
188
|
-
dataDirectory: string | undefined;
|
|
189
189
|
dataStoreMapSizeKb: number;
|
|
190
190
|
}, {
|
|
191
191
|
nodeUrl?: string | undefined;
|
|
@@ -223,4 +223,4 @@ export declare function getBotConfigFromEnv(): BotConfig;
|
|
|
223
223
|
export declare function getBotDefaultConfig(): BotConfig;
|
|
224
224
|
export declare function getVersions(): Partial<ComponentsVersions>;
|
|
225
225
|
export {};
|
|
226
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
226
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLGtCQUFrQixFQUN2QixXQUFXLEVBU1osTUFBTSwwQkFBMEIsQ0FBQztBQUNsQyxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFHcEQsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFzQixNQUFNLHdCQUF3QixDQUFDO0FBRWxGLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFbkUsT0FBTyxFQUFFLENBQUMsRUFBRSxNQUFNLEtBQUssQ0FBQztBQUV4QixRQUFBLE1BQU0sY0FBYyx5REFBMEQsQ0FBQztBQUMvRSxLQUFLLGNBQWMsR0FBRyxDQUFDLE9BQU8sY0FBYyxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUM7QUFFdEQsUUFBQSxNQUFNLE9BQU8sNENBQTZDLENBQUM7QUFDM0QsS0FBSyxPQUFPLEdBQUcsQ0FBQyxPQUFPLE9BQU8sQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBRXhDLG9CQUFZLHVCQUF1QjtJQUNqQyxhQUFhLGtCQUFrQjtJQUMvQixvQkFBb0IseUJBQXlCO0NBQzlDO0FBRUQsTUFBTSxNQUFNLFNBQVMsR0FBRztJQUN0Qiw2REFBNkQ7SUFDN0QsT0FBTyxFQUFFLE1BQU0sR0FBRyxTQUFTLENBQUM7SUFDNUIsNEVBQTRFO0lBQzVFLFlBQVksRUFBRSxNQUFNL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BVyxJQUFJLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUt6RCJ9
|
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,EASZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,EASZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,cAAc,yDAA0D,CAAC;AAC/E,KAAK,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,QAAA,MAAM,OAAO,4CAA6C,CAAC;AAC3D,KAAK,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAExC,oBAAY,uBAAuB;IACjC,aAAa,kBAAkB;IAC/B,oBAAoB,yBAAyB;CAC9C;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,4EAA4E;IAC5E,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,gCAAgC;IAChC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAChC,gEAAgE;IAChE,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,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e,GAAG,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8C3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CAmK3D,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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { booleanConfigHelper, getConfigFromMappings, getDefaultConfig, numberConfigHelper, optionalNumberConfigHelper, pickConfigMappings, secretFrConfigHelper, secretStringConfigHelper } from '@aztec/foundation/config';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
4
3
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
5
4
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
5
|
+
import { dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
6
6
|
import { schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
const BotFollowChain = [
|
|
@@ -61,7 +61,6 @@ export const BotConfigSchema = zodFor()(z.object({
|
|
|
61
61
|
l1Mnemonic: undefined,
|
|
62
62
|
l1PrivateKey: undefined,
|
|
63
63
|
senderPrivateKey: undefined,
|
|
64
|
-
dataDirectory: undefined,
|
|
65
64
|
dataStoreMapSizeKb: 1_024 * 1_024,
|
|
66
65
|
...config
|
|
67
66
|
})));
|
|
@@ -51,4 +51,4 @@ export declare class CrossChainBot extends BaseBot {
|
|
|
51
51
|
private getReadyL1ToL2Message;
|
|
52
52
|
private seedNewL1ToL2Message;
|
|
53
53
|
}
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3Jvc3NfY2hhaW5fYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY3Jvc3NfY2hhaW5fYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0F3Qkc7QUFDSCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFHekQsT0FBTyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUN2RCxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRXRFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUMzRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxvQ0FBb0MsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsY0FBYyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakYsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFOUQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUN4QyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFHN0MsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUF3QixNQUFNLGtCQUFrQixDQUFDO0FBS3ZFLHlFQUFxRTtBQUNyRSxxQkFBYSxhQUFjLFNBQVEsT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E;AACrE,qBAAa,aAAc,SAAQ,OAAO;IAStC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAbxB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,kBAAkB,CAA4B;IAEtD,SAAS,aACP,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,cAAc,EACtB,qBAAqB,EAAE,YAAY,EAClB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,UAAU,EACvB,YAAY,EAAE,UAAU,EACxB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,QAAQ,EAChC,MAAM,EAAE,SAAS,EAGlB;IAED,OAAa,MAAM,CACjB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,KAAK,EAAE,QAAQ,GACd,OAAO,CAAC,aAAa,CAAC,CAqBxB;IAED,UAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiD/D;IAED,UAAyB,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBpF;YAGa,qBAAqB;YAoBrB,oBAAoB;CAUnC"}
|
package/dest/cross_chain_bot.js
CHANGED
|
@@ -84,10 +84,11 @@ import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
|
84
84
|
const batch = new BatchCall(this.wallet, calls);
|
|
85
85
|
const opts = await this.getSendMethodOpts(batch);
|
|
86
86
|
this.log.verbose(`Sending cross-chain batch with ${calls.length} calls`, logCtx);
|
|
87
|
-
|
|
87
|
+
const { txHash } = await batch.send({
|
|
88
88
|
...opts,
|
|
89
89
|
wait: NO_WAIT
|
|
90
90
|
});
|
|
91
|
+
return txHash;
|
|
91
92
|
}
|
|
92
93
|
async onTxMined(receipt, logCtx) {
|
|
93
94
|
// Verify L2→L1 messages appeared in this tx's effects
|
|
@@ -115,14 +116,7 @@ import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
|
115
116
|
/** Finds the oldest pending message that is ready for consumption. */ async getReadyL1ToL2Message(pendingMessages) {
|
|
116
117
|
const now = Date.now();
|
|
117
118
|
for (const msg of pendingMessages){
|
|
118
|
-
const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash)
|
|
119
|
-
// Use forPublicConsumption: false so we wait until blockNumber >= messageBlockNumber.
|
|
120
|
-
// With forPublicConsumption: true, the check returns true one block early (the sequencer
|
|
121
|
-
// includes L1→L2 messages before executing the block's txs), but gas estimation simulates
|
|
122
|
-
// against the current world state which doesn't yet have the message.
|
|
123
|
-
// See https://linear.app/aztec-labs/issue/A-548 for details.
|
|
124
|
-
forPublicConsumption: false
|
|
125
|
-
});
|
|
119
|
+
const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash));
|
|
126
120
|
if (ready) {
|
|
127
121
|
return msg;
|
|
128
122
|
}
|
package/dest/factory.d.ts
CHANGED
|
@@ -61,4 +61,4 @@ export declare class BotFactory {
|
|
|
61
61
|
private bridgeL1FeeJuice;
|
|
62
62
|
private withNoMinTxsPerBlock;
|
|
63
63
|
}
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncy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O0NBZW5DIn0=
|
package/dest/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAoBzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAItE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAGlE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMjD,qBAAa,UAAU;IAInB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAPlC,OAAO,CAAC,GAAG,CAAuB;IAElC,YACmB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,SAAS,EACpB,cAAc,CAAC,4BAAgB,EAKjD;IAED;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC;QACvB,qBAAqB,EAAE,YAAY,CAAC;QACpC,KAAK,EAAE,aAAa,GAAG,oBAAoB,CAAC;QAC5C,IAAI,EAAE,SAAS,CAAC;QAChB,SAAS,EAAE,YAAY,CAAC;KACzB,CAAC,CAMD;IAEY,QAAQ,IAAI,OAAO,CAAC;QAC/B,MAAM,EAAE,cAAc,CAAC;QACvB,qBAAqB,EAAE,YAAY,CAAC;QACpC,GAAG,EAAE,WAAW,CAAC;QACjB,MAAM,EAAE,aAAa,CAAC;QACtB,MAAM,EAAE,aAAa,CAAC;QACtB,IAAI,EAAE,SAAS,CAAC;KACjB,CAAC,CAsBD;IAED;;;OAGG;IACU,eAAe,IAAI,OAAO,CAAC;QACtC,MAAM,EAAE,cAAc,CAAC;QACvB,qBAAqB,EAAE,YAAY,CAAC;QACpC,QAAQ,EAAE,YAAY,CAAC;QACvB,IAAI,EAAE,SAAS,CAAC;QAChB,QAAQ,EAAE,wBAAwB,CAAC;QACnC,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC,CA2DD;YAEa,iBAAiB;YAejB,YAAY;YAWZ,0BAA0B;YA8C1B,gBAAgB;YAehB,UAAU;YAuDV,kBAAkB;YAalB,gBAAgB;YA+BhB,OAAO;YA4GP,wBAAwB;YA2BxB,UAAU;YAmDV,sBAAsB;YA2BtB,gBAAgB;YA+BhB,oBAAoB;CAenC"}
|
package/dest/factory.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
-
import {
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
3
3
|
import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
5
5
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
@@ -7,6 +7,7 @@ import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
|
7
7
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
8
8
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
9
9
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
10
|
+
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
10
11
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
11
12
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
12
13
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
@@ -17,7 +18,7 @@ import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
|
17
18
|
import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
18
19
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
19
20
|
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
20
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
21
|
+
import { GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
21
22
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
22
23
|
import { SupportedTokenContracts } from './config.js';
|
|
23
24
|
import { seedL1ToL2Message } from './l1_to_l2_seeding.js';
|
|
@@ -38,6 +39,9 @@ export class BotFactory {
|
|
|
38
39
|
this.aztecNode = aztecNode;
|
|
39
40
|
this.aztecNodeAdmin = aztecNodeAdmin;
|
|
40
41
|
this.log = createLogger('bot');
|
|
42
|
+
// Set fee padding on the wallet so that all transactions during setup
|
|
43
|
+
// (token deploy, minting, etc.) use the configured padding, not the default.
|
|
44
|
+
this.wallet.setMinFeePadding(config.minFeePadding);
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* Initializes a new bot by setting up the sender account, registering the recipient,
|
|
@@ -108,12 +112,7 @@ export class BotFactory {
|
|
|
108
112
|
this.log.info(`Waiting for first L1→L2 message to be ready...`);
|
|
109
113
|
const firstMsg = allMessages[0];
|
|
110
114
|
await waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(firstMsg.msgHash), {
|
|
111
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
112
|
-
// Use forPublicConsumption: false so we wait until the message is in the current world
|
|
113
|
-
// state. With true, it returns one block early which causes gas estimation simulation to
|
|
114
|
-
// fail since it runs against the current state.
|
|
115
|
-
// See https://linear.app/aztec-labs/issue/A-548 for details.
|
|
116
|
-
forPublicConsumption: false
|
|
115
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
117
116
|
});
|
|
118
117
|
this.log.info(`First L1→L2 message is ready`);
|
|
119
118
|
}
|
|
@@ -154,7 +153,7 @@ export class BotFactory {
|
|
|
154
153
|
const signingKey = deriveSigningKey(secret);
|
|
155
154
|
const accountManager = await this.wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
156
155
|
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
157
|
-
if (metadata.
|
|
156
|
+
if (metadata.initializationStatus === ContractInitializationStatus.INITIALIZED) {
|
|
158
157
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
159
158
|
const timer = new Timer();
|
|
160
159
|
const address = accountManager.address;
|
|
@@ -168,19 +167,30 @@ export class BotFactory {
|
|
|
168
167
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
169
168
|
const deployMethod = await accountManager.getDeployMethod();
|
|
170
169
|
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
171
|
-
const
|
|
172
|
-
|
|
170
|
+
const { estimatedGas } = await deployMethod.simulate({
|
|
171
|
+
from: NO_FROM,
|
|
172
|
+
fee: {
|
|
173
|
+
estimateGas: true,
|
|
174
|
+
paymentMethod
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
const gasSettings = GasSettings.from({
|
|
178
|
+
...estimatedGas,
|
|
179
|
+
maxFeesPerGas,
|
|
180
|
+
maxPriorityFeesPerGas: GasFees.empty()
|
|
173
181
|
});
|
|
174
182
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
175
|
-
const txHash = await deployMethod.send({
|
|
176
|
-
from:
|
|
183
|
+
const { txHash } = await deployMethod.send({
|
|
184
|
+
from: NO_FROM,
|
|
177
185
|
fee: {
|
|
178
186
|
gasSettings,
|
|
179
187
|
paymentMethod
|
|
180
188
|
},
|
|
181
189
|
wait: NO_WAIT
|
|
182
190
|
});
|
|
183
|
-
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}
|
|
191
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`, {
|
|
192
|
+
gasSettings
|
|
193
|
+
});
|
|
184
194
|
return waitForTx(this.aztecNode, txHash, {
|
|
185
195
|
timeout: this.config.txMinedWaitSeconds
|
|
186
196
|
});
|
|
@@ -225,6 +235,10 @@ export class BotFactory {
|
|
|
225
235
|
tokenInstance = await deploy.getInstance(deployOpts);
|
|
226
236
|
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
227
237
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
238
|
+
// The contract constructor initializes private storage vars that need the contract's own nullifier key.
|
|
239
|
+
deployOpts.additionalScopes = [
|
|
240
|
+
tokenInstance.address
|
|
241
|
+
];
|
|
228
242
|
} else {
|
|
229
243
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
230
244
|
}
|
|
@@ -235,11 +249,22 @@ export class BotFactory {
|
|
|
235
249
|
await deploy.register();
|
|
236
250
|
} else {
|
|
237
251
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
238
|
-
const
|
|
252
|
+
const { estimatedGas } = await deploy.simulate({
|
|
253
|
+
...deployOpts,
|
|
254
|
+
fee: {
|
|
255
|
+
estimateGas: true
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
const { txHash } = await deploy.send({
|
|
239
259
|
...deployOpts,
|
|
260
|
+
fee: {
|
|
261
|
+
gasSettings: estimatedGas
|
|
262
|
+
},
|
|
240
263
|
wait: NO_WAIT
|
|
241
264
|
});
|
|
242
|
-
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}
|
|
265
|
+
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`, {
|
|
266
|
+
estimatedGas
|
|
267
|
+
});
|
|
243
268
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
244
269
|
await waitForTx(this.aztecNode, txHash, {
|
|
245
270
|
timeout: this.config.txMinedWaitSeconds
|
|
@@ -273,13 +298,25 @@ export class BotFactory {
|
|
|
273
298
|
const instance = await this.registerOrDeployContract('AMM', deploy, deployOpts);
|
|
274
299
|
const amm = AMMContract.at(instance.address, this.wallet);
|
|
275
300
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
276
|
-
const
|
|
301
|
+
const setMinterInteraction = lpToken.methods.set_minter(amm.address, true);
|
|
302
|
+
const { estimatedGas: setMinterGas } = await setMinterInteraction.simulate({
|
|
277
303
|
from: deployer,
|
|
304
|
+
fee: {
|
|
305
|
+
estimateGas: true
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
const { receipt: minterReceipt } = await setMinterInteraction.send({
|
|
309
|
+
from: deployer,
|
|
310
|
+
fee: {
|
|
311
|
+
gasSettings: setMinterGas
|
|
312
|
+
},
|
|
278
313
|
wait: {
|
|
279
314
|
timeout: this.config.txMinedWaitSeconds
|
|
280
315
|
}
|
|
281
316
|
});
|
|
282
|
-
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}
|
|
317
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`, {
|
|
318
|
+
estimatedGas: setMinterGas
|
|
319
|
+
});
|
|
283
320
|
this.log.info(`Liquidity token initialized`);
|
|
284
321
|
return amm;
|
|
285
322
|
}
|
|
@@ -287,13 +324,13 @@ export class BotFactory {
|
|
|
287
324
|
const getPrivateBalances = ()=>Promise.all([
|
|
288
325
|
token0.methods.balance_of_private(liquidityProvider).simulate({
|
|
289
326
|
from: liquidityProvider
|
|
290
|
-
}),
|
|
327
|
+
}).then((r)=>r.result),
|
|
291
328
|
token1.methods.balance_of_private(liquidityProvider).simulate({
|
|
292
329
|
from: liquidityProvider
|
|
293
|
-
}),
|
|
330
|
+
}).then((r)=>r.result),
|
|
294
331
|
lpToken.methods.balance_of_private(liquidityProvider).simulate({
|
|
295
332
|
from: liquidityProvider
|
|
296
|
-
})
|
|
333
|
+
}).then((r)=>r.result)
|
|
297
334
|
]);
|
|
298
335
|
const authwitNonce = Fr.random();
|
|
299
336
|
// keep some tokens for swapping
|
|
@@ -312,18 +349,44 @@ export class BotFactory {
|
|
|
312
349
|
caller: amm.address,
|
|
313
350
|
call: await token1.methods.transfer_to_public_and_prepare_private_balance_increase(liquidityProvider, amm.address, amount1Max, authwitNonce).getFunctionCall()
|
|
314
351
|
});
|
|
315
|
-
const
|
|
352
|
+
const mintBatch = new BatchCall(this.wallet, [
|
|
316
353
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
317
354
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE)
|
|
318
|
-
])
|
|
355
|
+
]);
|
|
356
|
+
const { estimatedGas: mintGas } = await mintBatch.simulate({
|
|
357
|
+
from: liquidityProvider,
|
|
358
|
+
fee: {
|
|
359
|
+
estimateGas: true
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
const { receipt: mintReceipt } = await mintBatch.send({
|
|
319
363
|
from: liquidityProvider,
|
|
364
|
+
fee: {
|
|
365
|
+
gasSettings: mintGas
|
|
366
|
+
},
|
|
320
367
|
wait: {
|
|
321
368
|
timeout: this.config.txMinedWaitSeconds
|
|
322
369
|
}
|
|
323
370
|
});
|
|
324
|
-
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}
|
|
325
|
-
|
|
371
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`, {
|
|
372
|
+
estimatedGas: mintGas
|
|
373
|
+
});
|
|
374
|
+
const addLiquidityInteraction = amm.methods.add_liquidity(amount0Max, amount1Max, amount0Min, amount1Min, authwitNonce);
|
|
375
|
+
const { estimatedGas: addLiquidityGas } = await addLiquidityInteraction.simulate({
|
|
326
376
|
from: liquidityProvider,
|
|
377
|
+
fee: {
|
|
378
|
+
estimateGas: true
|
|
379
|
+
},
|
|
380
|
+
authWitnesses: [
|
|
381
|
+
token0Authwit,
|
|
382
|
+
token1Authwit
|
|
383
|
+
]
|
|
384
|
+
});
|
|
385
|
+
const { receipt: addLiquidityReceipt } = await addLiquidityInteraction.send({
|
|
386
|
+
from: liquidityProvider,
|
|
387
|
+
fee: {
|
|
388
|
+
gasSettings: addLiquidityGas
|
|
389
|
+
},
|
|
327
390
|
authWitnesses: [
|
|
328
391
|
token0Authwit,
|
|
329
392
|
token1Authwit
|
|
@@ -332,7 +395,9 @@ export class BotFactory {
|
|
|
332
395
|
timeout: this.config.txMinedWaitSeconds
|
|
333
396
|
}
|
|
334
397
|
});
|
|
335
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}
|
|
398
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`, {
|
|
399
|
+
estimatedGas: addLiquidityGas
|
|
400
|
+
});
|
|
336
401
|
this.log.info(`Liquidity added`);
|
|
337
402
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
338
403
|
this.log.info(`Updated private balances of ${defaultAccountAddress} after minting and funding AMM: token0=${newT0Bal}, token1=${newT1Bal}, lp=${newLPBal}`);
|
|
@@ -345,10 +410,21 @@ export class BotFactory {
|
|
|
345
410
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
346
411
|
await deploy.register();
|
|
347
412
|
} else {
|
|
348
|
-
|
|
413
|
+
const { estimatedGas } = await deploy.simulate({
|
|
414
|
+
...deployOpts,
|
|
415
|
+
fee: {
|
|
416
|
+
estimateGas: true
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
this.log.info(`Deploying contract ${name} at ${address.toString()}`, {
|
|
420
|
+
estimatedGas
|
|
421
|
+
});
|
|
349
422
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
350
|
-
const txHash = await deploy.send({
|
|
423
|
+
const { txHash } = await deploy.send({
|
|
351
424
|
...deployOpts,
|
|
425
|
+
fee: {
|
|
426
|
+
gasSettings: estimatedGas
|
|
427
|
+
},
|
|
352
428
|
wait: NO_WAIT
|
|
353
429
|
});
|
|
354
430
|
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
@@ -384,12 +460,30 @@ export class BotFactory {
|
|
|
384
460
|
this.log.info(`Skipping minting as ${minter.toString()} has enough tokens`);
|
|
385
461
|
return;
|
|
386
462
|
}
|
|
463
|
+
// PrivateToken's mint accesses contract-level private storage vars (admin, total_supply).
|
|
464
|
+
const additionalScopes = isStandardToken ? undefined : [
|
|
465
|
+
token.address
|
|
466
|
+
];
|
|
467
|
+
const mintBatch = new BatchCall(token.wallet, calls);
|
|
468
|
+
const { estimatedGas } = await mintBatch.simulate({
|
|
469
|
+
from: minter,
|
|
470
|
+
fee: {
|
|
471
|
+
estimateGas: true
|
|
472
|
+
},
|
|
473
|
+
additionalScopes
|
|
474
|
+
});
|
|
387
475
|
await this.withNoMinTxsPerBlock(async ()=>{
|
|
388
|
-
const txHash = await
|
|
476
|
+
const { txHash } = await mintBatch.send({
|
|
389
477
|
from: minter,
|
|
478
|
+
additionalScopes,
|
|
479
|
+
fee: {
|
|
480
|
+
gasSettings: estimatedGas
|
|
481
|
+
},
|
|
390
482
|
wait: NO_WAIT
|
|
391
483
|
});
|
|
392
|
-
this.log.info(`Sent token mint tx with hash ${txHash.toString()}
|
|
484
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`, {
|
|
485
|
+
estimatedGas
|
|
486
|
+
});
|
|
393
487
|
return waitForTx(this.aztecNode, txHash, {
|
|
394
488
|
timeout: this.config.txMinedWaitSeconds
|
|
395
489
|
});
|
|
@@ -408,8 +502,7 @@ export class BotFactory {
|
|
|
408
502
|
try {
|
|
409
503
|
const messageHash = Fr.fromHexString(existingClaim.claim.messageHash);
|
|
410
504
|
await this.withNoMinTxsPerBlock(()=>waitForL1ToL2MessageReady(this.aztecNode, messageHash, {
|
|
411
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
412
|
-
forPublicConsumption: false
|
|
505
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
413
506
|
}));
|
|
414
507
|
return existingClaim.claim;
|
|
415
508
|
} catch (err) {
|
|
@@ -437,8 +530,7 @@ export class BotFactory {
|
|
|
437
530
|
const mintAmount = await portal.getTokenManager().getMintAmount();
|
|
438
531
|
const claim = await portal.bridgeTokensPublic(recipient, mintAmount, true);
|
|
439
532
|
await this.withNoMinTxsPerBlock(()=>waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(claim.messageHash), {
|
|
440
|
-
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
441
|
-
forPublicConsumption: false
|
|
533
|
+
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds
|
|
442
534
|
}));
|
|
443
535
|
this.log.info(`Created a claim for ${mintAmount} L1 fee juice to ${recipient}.`, claim);
|
|
444
536
|
return claim;
|
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": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.ce4f8c4f2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
58
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
59
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
60
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
61
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
62
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
63
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
64
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
65
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
66
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
67
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
68
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
69
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
-
"@aztec/wallets": "0.0.1-commit.
|
|
57
|
+
"@aztec/accounts": "0.0.1-commit.ce4f8c4f2",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.ce4f8c4f2",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.ce4f8c4f2",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.ce4f8c4f2",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.ce4f8c4f2",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.ce4f8c4f2",
|
|
63
|
+
"@aztec/l1-artifacts": "0.0.1-commit.ce4f8c4f2",
|
|
64
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.ce4f8c4f2",
|
|
65
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.ce4f8c4f2",
|
|
66
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.ce4f8c4f2",
|
|
67
|
+
"@aztec/protocol-contracts": "0.0.1-commit.ce4f8c4f2",
|
|
68
|
+
"@aztec/stdlib": "0.0.1-commit.ce4f8c4f2",
|
|
69
|
+
"@aztec/telemetry-client": "0.0.1-commit.ce4f8c4f2",
|
|
70
|
+
"@aztec/wallets": "0.0.1-commit.ce4f8c4f2",
|
|
71
71
|
"source-map-support": "^0.5.21",
|
|
72
72
|
"tslib": "^2.4.0",
|
|
73
73
|
"viem": "npm:@aztec/viem@2.38.2",
|
package/src/amm_bot.ts
CHANGED
|
@@ -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/bot.ts
CHANGED
|
@@ -76,7 +76,8 @@ export class Bot extends BaseBot {
|
|
|
76
76
|
await batch.simulate({ from: this.defaultAccountAddress });
|
|
77
77
|
|
|
78
78
|
this.log.verbose(`Sending transaction`, logCtx);
|
|
79
|
-
|
|
79
|
+
const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
|
|
80
|
+
return txHash;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
public async getBalances() {
|
package/src/config.ts
CHANGED
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
secretStringConfigHelper,
|
|
12
12
|
} from '@aztec/foundation/config';
|
|
13
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
15
14
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
16
15
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
16
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
17
17
|
import { schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
18
18
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
19
19
|
|
|
@@ -130,7 +130,6 @@ export const BotConfigSchema = zodFor<BotConfig>()(
|
|
|
130
130
|
l1Mnemonic: undefined,
|
|
131
131
|
l1PrivateKey: undefined,
|
|
132
132
|
senderPrivateKey: undefined,
|
|
133
|
-
dataDirectory: undefined,
|
|
134
133
|
dataStoreMapSizeKb: 1_024 * 1_024,
|
|
135
134
|
...config,
|
|
136
135
|
})),
|
package/src/cross_chain_bot.ts
CHANGED
|
@@ -140,7 +140,8 @@ export class CrossChainBot extends BaseBot {
|
|
|
140
140
|
const opts = await this.getSendMethodOpts(batch);
|
|
141
141
|
|
|
142
142
|
this.log.verbose(`Sending cross-chain batch with ${calls.length} calls`, logCtx);
|
|
143
|
-
|
|
143
|
+
const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
|
|
144
|
+
return txHash;
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
|
|
@@ -174,14 +175,7 @@ export class CrossChainBot extends BaseBot {
|
|
|
174
175
|
): Promise<PendingL1ToL2Message | undefined> {
|
|
175
176
|
const now = Date.now();
|
|
176
177
|
for (const msg of pendingMessages) {
|
|
177
|
-
const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash)
|
|
178
|
-
// Use forPublicConsumption: false so we wait until blockNumber >= messageBlockNumber.
|
|
179
|
-
// With forPublicConsumption: true, the check returns true one block early (the sequencer
|
|
180
|
-
// includes L1→L2 messages before executing the block's txs), but gas estimation simulates
|
|
181
|
-
// against the current world state which doesn't yet have the message.
|
|
182
|
-
// See https://linear.app/aztec-labs/issue/A-548 for details.
|
|
183
|
-
forPublicConsumption: false,
|
|
184
|
-
});
|
|
178
|
+
const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash));
|
|
185
179
|
if (ready) {
|
|
186
180
|
return msg;
|
|
187
181
|
}
|
package/src/factory.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
3
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
4
|
import {
|
|
4
5
|
BatchCall,
|
|
@@ -15,6 +16,7 @@ import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
|
15
16
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
16
17
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
17
18
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
19
|
+
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
18
20
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
19
21
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
20
22
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
@@ -27,7 +29,7 @@ import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
|
27
29
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
28
30
|
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
29
31
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
30
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
32
|
+
import { GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
31
33
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
32
34
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
33
35
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
@@ -49,7 +51,11 @@ export class BotFactory {
|
|
|
49
51
|
private readonly store: BotStore,
|
|
50
52
|
private readonly aztecNode: AztecNode,
|
|
51
53
|
private readonly aztecNodeAdmin?: AztecNodeAdmin,
|
|
52
|
-
) {
|
|
54
|
+
) {
|
|
55
|
+
// Set fee padding on the wallet so that all transactions during setup
|
|
56
|
+
// (token deploy, minting, etc.) use the configured padding, not the default.
|
|
57
|
+
this.wallet.setMinFeePadding(config.minFeePadding);
|
|
58
|
+
}
|
|
53
59
|
|
|
54
60
|
/**
|
|
55
61
|
* Initializes a new bot by setting up the sender account, registering the recipient,
|
|
@@ -158,11 +164,6 @@ export class BotFactory {
|
|
|
158
164
|
const firstMsg = allMessages[0];
|
|
159
165
|
await waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(firstMsg.msgHash), {
|
|
160
166
|
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
161
|
-
// Use forPublicConsumption: false so we wait until the message is in the current world
|
|
162
|
-
// state. With true, it returns one block early which causes gas estimation simulation to
|
|
163
|
-
// fail since it runs against the current state.
|
|
164
|
-
// See https://linear.app/aztec-labs/issue/A-548 for details.
|
|
165
|
-
forPublicConsumption: false,
|
|
166
167
|
});
|
|
167
168
|
this.log.info(`First L1→L2 message is ready`);
|
|
168
169
|
}
|
|
@@ -208,7 +209,7 @@ export class BotFactory {
|
|
|
208
209
|
const signingKey = deriveSigningKey(secret);
|
|
209
210
|
const accountManager = await this.wallet.createSchnorrAccount(secret, salt, signingKey);
|
|
210
211
|
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
211
|
-
if (metadata.
|
|
212
|
+
if (metadata.initializationStatus === ContractInitializationStatus.INITIALIZED) {
|
|
212
213
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
213
214
|
const timer = new Timer();
|
|
214
215
|
const address = accountManager.address;
|
|
@@ -224,15 +225,20 @@ export class BotFactory {
|
|
|
224
225
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
225
226
|
const deployMethod = await accountManager.getDeployMethod();
|
|
226
227
|
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
227
|
-
|
|
228
|
+
|
|
229
|
+
const { estimatedGas } = await deployMethod.simulate({
|
|
230
|
+
from: NO_FROM,
|
|
231
|
+
fee: { estimateGas: true, paymentMethod },
|
|
232
|
+
});
|
|
233
|
+
const gasSettings = GasSettings.from({ ...estimatedGas!, maxFeesPerGas, maxPriorityFeesPerGas: GasFees.empty() });
|
|
228
234
|
|
|
229
235
|
await this.withNoMinTxsPerBlock(async () => {
|
|
230
|
-
const txHash = await deployMethod.send({
|
|
231
|
-
from:
|
|
236
|
+
const { txHash } = await deployMethod.send({
|
|
237
|
+
from: NO_FROM,
|
|
232
238
|
fee: { gasSettings, paymentMethod },
|
|
233
239
|
wait: NO_WAIT,
|
|
234
240
|
});
|
|
235
|
-
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}
|
|
241
|
+
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`, { gasSettings });
|
|
236
242
|
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
237
243
|
});
|
|
238
244
|
this.log.info(`Account deployed at ${address}`);
|
|
@@ -285,6 +291,8 @@ export class BotFactory {
|
|
|
285
291
|
tokenInstance = await deploy.getInstance(deployOpts);
|
|
286
292
|
token = PrivateTokenContract.at(tokenInstance.address, this.wallet);
|
|
287
293
|
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
294
|
+
// The contract constructor initializes private storage vars that need the contract's own nullifier key.
|
|
295
|
+
deployOpts.additionalScopes = [tokenInstance.address];
|
|
288
296
|
} else {
|
|
289
297
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
290
298
|
}
|
|
@@ -296,8 +304,9 @@ export class BotFactory {
|
|
|
296
304
|
await deploy.register();
|
|
297
305
|
} else {
|
|
298
306
|
this.log.info(`Deploying token contract at ${address.toString()}`);
|
|
299
|
-
const
|
|
300
|
-
|
|
307
|
+
const { estimatedGas } = await deploy.simulate({ ...deployOpts, fee: { estimateGas: true } });
|
|
308
|
+
const { txHash } = await deploy.send({ ...deployOpts, fee: { gasSettings: estimatedGas }, wait: NO_WAIT });
|
|
309
|
+
this.log.info(`Sent tx for token setup with hash ${txHash.toString()}`, { estimatedGas });
|
|
301
310
|
await this.withNoMinTxsPerBlock(async () => {
|
|
302
311
|
await waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
303
312
|
return token;
|
|
@@ -337,10 +346,19 @@ export class BotFactory {
|
|
|
337
346
|
const amm = AMMContract.at(instance.address, this.wallet);
|
|
338
347
|
|
|
339
348
|
this.log.info(`AMM deployed at ${amm.address}`);
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
349
|
+
const setMinterInteraction = lpToken.methods.set_minter(amm.address, true);
|
|
350
|
+
const { estimatedGas: setMinterGas } = await setMinterInteraction.simulate({
|
|
351
|
+
from: deployer,
|
|
352
|
+
fee: { estimateGas: true },
|
|
353
|
+
});
|
|
354
|
+
const { receipt: minterReceipt } = await setMinterInteraction.send({
|
|
355
|
+
from: deployer,
|
|
356
|
+
fee: { gasSettings: setMinterGas },
|
|
357
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
358
|
+
});
|
|
359
|
+
this.log.info(`Set LP token minter to AMM txHash=${minterReceipt.txHash.toString()}`, {
|
|
360
|
+
estimatedGas: setMinterGas,
|
|
361
|
+
});
|
|
344
362
|
this.log.info(`Liquidity token initialized`);
|
|
345
363
|
|
|
346
364
|
return amm;
|
|
@@ -356,9 +374,18 @@ export class BotFactory {
|
|
|
356
374
|
): Promise<void> {
|
|
357
375
|
const getPrivateBalances = () =>
|
|
358
376
|
Promise.all([
|
|
359
|
-
token0.methods
|
|
360
|
-
|
|
361
|
-
|
|
377
|
+
token0.methods
|
|
378
|
+
.balance_of_private(liquidityProvider)
|
|
379
|
+
.simulate({ from: liquidityProvider })
|
|
380
|
+
.then(r => r.result),
|
|
381
|
+
token1.methods
|
|
382
|
+
.balance_of_private(liquidityProvider)
|
|
383
|
+
.simulate({ from: liquidityProvider })
|
|
384
|
+
.then(r => r.result),
|
|
385
|
+
lpToken.methods
|
|
386
|
+
.balance_of_private(liquidityProvider)
|
|
387
|
+
.simulate({ from: liquidityProvider })
|
|
388
|
+
.then(r => r.result),
|
|
362
389
|
]);
|
|
363
390
|
|
|
364
391
|
const authwitNonce = Fr.random();
|
|
@@ -399,22 +426,44 @@ export class BotFactory {
|
|
|
399
426
|
.getFunctionCall(),
|
|
400
427
|
});
|
|
401
428
|
|
|
402
|
-
const
|
|
429
|
+
const mintBatch = new BatchCall(this.wallet, [
|
|
403
430
|
token0.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
404
431
|
token1.methods.mint_to_private(liquidityProvider, MINT_BALANCE),
|
|
405
|
-
])
|
|
432
|
+
]);
|
|
433
|
+
const { estimatedGas: mintGas } = await mintBatch.simulate({
|
|
434
|
+
from: liquidityProvider,
|
|
435
|
+
fee: { estimateGas: true },
|
|
436
|
+
});
|
|
437
|
+
const { receipt: mintReceipt } = await mintBatch.send({
|
|
438
|
+
from: liquidityProvider,
|
|
439
|
+
fee: { gasSettings: mintGas },
|
|
440
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
441
|
+
});
|
|
406
442
|
|
|
407
|
-
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}
|
|
443
|
+
this.log.info(`Sent mint tx: ${mintReceipt.txHash.toString()}`, { estimatedGas: mintGas });
|
|
408
444
|
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
445
|
+
const addLiquidityInteraction = amm.methods.add_liquidity(
|
|
446
|
+
amount0Max,
|
|
447
|
+
amount1Max,
|
|
448
|
+
amount0Min,
|
|
449
|
+
amount1Min,
|
|
450
|
+
authwitNonce,
|
|
451
|
+
);
|
|
452
|
+
const { estimatedGas: addLiquidityGas } = await addLiquidityInteraction.simulate({
|
|
453
|
+
from: liquidityProvider,
|
|
454
|
+
fee: { estimateGas: true },
|
|
455
|
+
authWitnesses: [token0Authwit, token1Authwit],
|
|
456
|
+
});
|
|
457
|
+
const { receipt: addLiquidityReceipt } = await addLiquidityInteraction.send({
|
|
458
|
+
from: liquidityProvider,
|
|
459
|
+
fee: { gasSettings: addLiquidityGas },
|
|
460
|
+
authWitnesses: [token0Authwit, token1Authwit],
|
|
461
|
+
wait: { timeout: this.config.txMinedWaitSeconds },
|
|
462
|
+
});
|
|
416
463
|
|
|
417
|
-
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}
|
|
464
|
+
this.log.info(`Sent tx to add liquidity to the AMM: ${addLiquidityReceipt.txHash.toString()}`, {
|
|
465
|
+
estimatedGas: addLiquidityGas,
|
|
466
|
+
});
|
|
418
467
|
this.log.info(`Liquidity added`);
|
|
419
468
|
|
|
420
469
|
const [newT0Bal, newT1Bal, newLPBal] = await getPrivateBalances();
|
|
@@ -435,9 +484,10 @@ export class BotFactory {
|
|
|
435
484
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
436
485
|
await deploy.register();
|
|
437
486
|
} else {
|
|
438
|
-
|
|
487
|
+
const { estimatedGas } = await deploy.simulate({ ...deployOpts, fee: { estimateGas: true } });
|
|
488
|
+
this.log.info(`Deploying contract ${name} at ${address.toString()}`, { estimatedGas });
|
|
439
489
|
await this.withNoMinTxsPerBlock(async () => {
|
|
440
|
-
const txHash = await deploy.send({ ...deployOpts, wait: NO_WAIT });
|
|
490
|
+
const { txHash } = await deploy.send({ ...deployOpts, fee: { gasSettings: estimatedGas }, wait: NO_WAIT });
|
|
441
491
|
this.log.info(`Sent contract ${name} setup tx with hash ${txHash.toString()}`);
|
|
442
492
|
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
443
493
|
});
|
|
@@ -479,9 +529,18 @@ export class BotFactory {
|
|
|
479
529
|
return;
|
|
480
530
|
}
|
|
481
531
|
|
|
532
|
+
// PrivateToken's mint accesses contract-level private storage vars (admin, total_supply).
|
|
533
|
+
const additionalScopes = isStandardToken ? undefined : [token.address];
|
|
534
|
+
const mintBatch = new BatchCall(token.wallet, calls);
|
|
535
|
+
const { estimatedGas } = await mintBatch.simulate({ from: minter, fee: { estimateGas: true }, additionalScopes });
|
|
482
536
|
await this.withNoMinTxsPerBlock(async () => {
|
|
483
|
-
const txHash = await
|
|
484
|
-
|
|
537
|
+
const { txHash } = await mintBatch.send({
|
|
538
|
+
from: minter,
|
|
539
|
+
additionalScopes,
|
|
540
|
+
fee: { gasSettings: estimatedGas },
|
|
541
|
+
wait: NO_WAIT,
|
|
542
|
+
});
|
|
543
|
+
this.log.info(`Sent token mint tx with hash ${txHash.toString()}`, { estimatedGas });
|
|
485
544
|
return waitForTx(this.aztecNode, txHash, { timeout: this.config.txMinedWaitSeconds });
|
|
486
545
|
});
|
|
487
546
|
}
|
|
@@ -503,7 +562,6 @@ export class BotFactory {
|
|
|
503
562
|
await this.withNoMinTxsPerBlock(() =>
|
|
504
563
|
waitForL1ToL2MessageReady(this.aztecNode, messageHash, {
|
|
505
564
|
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
506
|
-
forPublicConsumption: false,
|
|
507
565
|
}),
|
|
508
566
|
);
|
|
509
567
|
return existingClaim.claim;
|
|
@@ -542,7 +600,6 @@ export class BotFactory {
|
|
|
542
600
|
await this.withNoMinTxsPerBlock(() =>
|
|
543
601
|
waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(claim.messageHash), {
|
|
544
602
|
timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds,
|
|
545
|
-
forPublicConsumption: false,
|
|
546
603
|
}),
|
|
547
604
|
);
|
|
548
605
|
|
package/src/utils.ts
CHANGED
|
@@ -15,8 +15,8 @@ export async function getBalances(
|
|
|
15
15
|
who: AztecAddress,
|
|
16
16
|
from?: AztecAddress,
|
|
17
17
|
): Promise<{ privateBalance: bigint; publicBalance: bigint }> {
|
|
18
|
-
const privateBalance = await token.methods.balance_of_private(who).simulate({ from: from ?? who });
|
|
19
|
-
const publicBalance = await token.methods.balance_of_public(who).simulate({ from: from ?? who });
|
|
18
|
+
const { result: privateBalance } = await token.methods.balance_of_private(who).simulate({ from: from ?? who });
|
|
19
|
+
const { result: publicBalance } = await token.methods.balance_of_public(who).simulate({ from: from ?? who });
|
|
20
20
|
return { privateBalance, publicBalance };
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -25,7 +25,7 @@ export async function getPrivateBalance(
|
|
|
25
25
|
who: AztecAddress,
|
|
26
26
|
from?: AztecAddress,
|
|
27
27
|
): Promise<bigint> {
|
|
28
|
-
const privateBalance = await token.methods.get_balance(who).simulate({ from: from ?? who });
|
|
28
|
+
const { result: privateBalance } = await token.methods.get_balance(who).simulate({ from: from ?? who });
|
|
29
29
|
return privateBalance;
|
|
30
30
|
}
|
|
31
31
|
|