-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoolDeployment.ts
More file actions
54 lines (47 loc) · 1.95 KB
/
poolDeployment.ts
File metadata and controls
54 lines (47 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { z } from 'zod';
import { ethers } from 'ethers';
// Pool type discriminator (matches contract's PoolType enum)
export const poolTypeSchema = z.enum(['BurnMintTokenPool', 'LockReleaseTokenPool']);
// Schema for rate limiter configuration
export const rateLimiterConfigSchema = z.object({
isEnabled: z.boolean(),
capacity: z.string(), // BigNumber as string
rate: z.string(), // BigNumber as string
});
// Schema for remote chain configuration
export const remoteChainConfigSchema = z.object({
remotePoolFactory: z.string(),
remoteRouter: z.string(),
remoteRMNProxy: z.string(),
remoteTokenDecimals: z.number(),
});
// Schema for remote token pool information (user input)
export const remoteTokenPoolInfoSchema = z.object({
remoteChainSelector: z.string(), // BigNumber as string
remotePoolAddress: z.string(),
remotePoolInitCode: z.string(),
remoteChainConfig: remoteChainConfigSchema,
poolType: poolTypeSchema,
remoteTokenAddress: z.string(),
remoteTokenInitCode: z.string(),
rateLimiterConfig: rateLimiterConfigSchema,
});
// Schema for pool deployment parameters (matches contract function parameters)
export const poolDeploymentParamsSchema = z.object({
token: z.string().refine(
(address) => ethers.isAddress(address),
(val) => ({ message: `Invalid token address: ${val}` }),
),
decimals: z.number(),
remoteTokenPools: z.array(remoteTokenPoolInfoSchema).optional().default([]),
poolType: poolTypeSchema,
});
export type PoolType = z.infer<typeof poolTypeSchema>;
export type RateLimiterConfig = z.infer<typeof rateLimiterConfigSchema>;
export type RemoteChainConfig = z.infer<typeof remoteChainConfigSchema>;
export type RemoteTokenPoolInfo = z.infer<typeof remoteTokenPoolInfoSchema>;
export type PoolDeploymentParams = z.infer<typeof poolDeploymentParamsSchema>;
// Contract-specific types (with numeric pool type)
export type ContractRemoteTokenPoolInfo = Omit<RemoteTokenPoolInfo, 'poolType'> & {
poolType: number;
};