@aegis-engine/core 0.1.1 → 0.1.3

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.
@@ -0,0 +1,201 @@
1
+ import type { Address, Hex } from 'viem';
2
+ import type { z } from 'zod';
3
+ import type { AegisPoolKey } from './config';
4
+ export type AegisBackendSwapProvider = 'aegis-direct-v4' | 'kyber';
5
+ export type AegisBackendQuoteMode = 'exactIn' | 'exactOut';
6
+ export type AegisBackendMarketStatus = 'enabled' | 'disabled';
7
+ export type AegisBackendTxStatus = 'pending' | 'success' | 'reverted' | 'not_found';
8
+ export type AegisBackendChain = {
9
+ chainId: number;
10
+ slug: string;
11
+ name: string;
12
+ };
13
+ export type AegisBackendQuoteDefaults = {
14
+ ttlSeconds: number;
15
+ defaultSlippageBps: number;
16
+ maxSlippageBps: number;
17
+ };
18
+ export type AegisBackendContractRegistry = {
19
+ aegisRouter?: Address;
20
+ permit2?: Address;
21
+ v4Quoter?: Address;
22
+ v4PoolManager?: Address;
23
+ [contractName: string]: Address | undefined;
24
+ };
25
+ export type AegisBackendAddressAllowlist = {
26
+ routers: Address[];
27
+ spenders: Address[];
28
+ };
29
+ export type AegisBackendFeeConfig = {
30
+ outputFeeBps: number;
31
+ recipient: Address;
32
+ };
33
+ export type AegisBackendConfig = {
34
+ schemaVersion: string;
35
+ chains: AegisBackendChain[];
36
+ providers: AegisBackendSwapProvider[];
37
+ quote: AegisBackendQuoteDefaults;
38
+ contracts: Record<string, AegisBackendContractRegistry>;
39
+ allowlists: Record<string, AegisBackendAddressAllowlist>;
40
+ fee: AegisBackendFeeConfig;
41
+ };
42
+ export type AegisBackendToken = {
43
+ id: string;
44
+ chainId: number;
45
+ address: Address;
46
+ symbol: string;
47
+ displayName: string;
48
+ fullName: string;
49
+ decimals: number;
50
+ priceUsd?: number | null;
51
+ iconUrl?: string | null;
52
+ stable?: boolean;
53
+ };
54
+ export type AegisBackendMarketMetrics = {
55
+ tvlUsd?: number | null;
56
+ volumeUsd7d?: number | null;
57
+ feeApr7d?: number | null;
58
+ };
59
+ export type AegisBackendMarket = {
60
+ id: string;
61
+ chainId: number;
62
+ status: AegisBackendMarketStatus;
63
+ kind: AegisBackendSwapProvider;
64
+ label: string;
65
+ baseToken: Address;
66
+ quoteToken: Address;
67
+ poolId: Hex;
68
+ poolKey: AegisPoolKey;
69
+ metrics?: AegisBackendMarketMetrics;
70
+ warnings: string[];
71
+ };
72
+ type AegisBackendSwapQuoteRequestBase = {
73
+ chainId: number;
74
+ provider: AegisBackendSwapProvider;
75
+ marketId?: string;
76
+ tokenIn: Address;
77
+ tokenOut: Address;
78
+ slippageBps: number;
79
+ account?: Address | null;
80
+ };
81
+ export type AegisBackendSwapQuoteRequest = (AegisBackendSwapQuoteRequestBase & {
82
+ mode: 'exactIn';
83
+ amountIn: string;
84
+ amountOut?: never;
85
+ }) | (AegisBackendSwapQuoteRequestBase & {
86
+ mode: 'exactOut';
87
+ amountOut: string;
88
+ amountIn?: never;
89
+ });
90
+ export type AegisBackendSwapApproval = {
91
+ required: boolean;
92
+ model: 'permit2' | 'erc20' | 'native' | 'none';
93
+ spender?: Address | null;
94
+ };
95
+ export type AegisBackendSwapQuoteResponse = {
96
+ quoteId: string;
97
+ quoteHash: Hex;
98
+ routeHash: Hex;
99
+ expiresAt: string;
100
+ quoteBlockNumber: string;
101
+ provider: AegisBackendSwapProvider;
102
+ marketId?: string;
103
+ amountIn: string;
104
+ amountOut: string;
105
+ minAmountOut: string;
106
+ gasEstimate?: string | null;
107
+ approval: AegisBackendSwapApproval;
108
+ fee: AegisBackendFeeConfig;
109
+ warnings: string[];
110
+ };
111
+ export type AegisBackendSwapBuildRequest = {
112
+ quoteId: string;
113
+ account: Address;
114
+ recipient: Address;
115
+ permitSignature?: Hex;
116
+ };
117
+ export type AegisBackendUnsignedSwapTx = {
118
+ chainId: number;
119
+ to: Address;
120
+ data: Hex;
121
+ value: string;
122
+ };
123
+ export type AegisBackendSwapBuildResponse = {
124
+ buildId: string;
125
+ quoteId: string;
126
+ routeHash: Hex;
127
+ expectedCalldataHash: Hex;
128
+ expiresAt: string;
129
+ tx: AegisBackendUnsignedSwapTx;
130
+ allowance: {
131
+ spender: Address;
132
+ permit2Required: boolean;
133
+ };
134
+ simulation: {
135
+ ok: boolean;
136
+ blockNumber?: string;
137
+ };
138
+ warnings: string[];
139
+ };
140
+ export type AegisBackendTxStatusResponse = {
141
+ status: AegisBackendTxStatus;
142
+ blockNumber?: string | null;
143
+ gasUsed?: string | null;
144
+ effectiveGasPrice?: string | null;
145
+ feeWei?: string | null;
146
+ explorerUrl?: string | null;
147
+ };
148
+ export type AegisBackendApiClientOptions = {
149
+ baseUrl: string;
150
+ fetch?: typeof fetch;
151
+ headers?: Record<string, string>;
152
+ validate?: boolean;
153
+ };
154
+ export type AegisBackendRequestOptions = {
155
+ signal?: AbortSignal;
156
+ headers?: Record<string, string>;
157
+ timeoutMs?: number;
158
+ };
159
+ export declare class AegisBackendApiError extends Error {
160
+ readonly status: number;
161
+ readonly statusText: string;
162
+ readonly body: unknown;
163
+ constructor({ status, statusText, body }: {
164
+ status: number;
165
+ statusText: string;
166
+ body: unknown;
167
+ });
168
+ }
169
+ export declare class AegisBackendContractError extends Error {
170
+ readonly endpoint: string;
171
+ readonly issues: z.core.$ZodIssue[];
172
+ constructor({ endpoint, issues }: {
173
+ endpoint: string;
174
+ issues: z.core.$ZodIssue[];
175
+ });
176
+ }
177
+ export declare function isRetryableAegisBackendApiError(error: unknown): boolean;
178
+ export type AegisBackendApiClient = {
179
+ health: (options?: AegisBackendRequestOptions) => Promise<{
180
+ ok: boolean;
181
+ }>;
182
+ config: (options?: AegisBackendRequestOptions) => Promise<AegisBackendConfig>;
183
+ tokens: (args: {
184
+ chainId: number;
185
+ }, options?: AegisBackendRequestOptions) => Promise<AegisBackendToken[]>;
186
+ tokensByAddress: (args: {
187
+ chainId: number;
188
+ addresses: Address[];
189
+ }, options?: AegisBackendRequestOptions) => Promise<AegisBackendToken[]>;
190
+ markets: (args: {
191
+ chainId: number;
192
+ }, options?: AegisBackendRequestOptions) => Promise<AegisBackendMarket[]>;
193
+ quote: (args: AegisBackendSwapQuoteRequest, options?: AegisBackendRequestOptions) => Promise<AegisBackendSwapQuoteResponse>;
194
+ build: (args: AegisBackendSwapBuildRequest, options?: AegisBackendRequestOptions) => Promise<AegisBackendSwapBuildResponse>;
195
+ txStatus: (args: {
196
+ chainId: number;
197
+ txHash: Hex;
198
+ }, options?: AegisBackendRequestOptions) => Promise<AegisBackendTxStatusResponse>;
199
+ };
200
+ export declare function createAegisBackendApiClient(options: AegisBackendApiClientOptions): AegisBackendApiClient;
201
+ export {};
@@ -0,0 +1,9 @@
1
+ import { type Hex } from 'viem';
2
+ import type { AegisSwapChainConfig, AegisSwapChainConfigInput } from './types';
3
+ export declare function getExplorerUrl(hash: Hex, chain: AegisSwapChainConfig): string;
4
+ export declare const AEGIS_SWAP_MAINNET_CHAIN: AegisSwapChainConfig;
5
+ export declare const AEGIS_SWAP_CHAINS: Record<number, AegisSwapChainConfig>;
6
+ export declare function createAegisSwapChainConfig(input: AegisSwapChainConfigInput & {
7
+ chainId: number;
8
+ }, base?: AegisSwapChainConfig): AegisSwapChainConfig;
9
+ export declare function createAegisSwapChains(chains?: Partial<Record<number, AegisSwapChainConfigInput>>): Record<number, AegisSwapChainConfig>;
@@ -0,0 +1,10 @@
1
+ export declare const AEGIS_SWAP_CHAIN_ID = 1;
2
+ export declare const AEGIS_SWAP_ROUTER: `0x${string}`;
3
+ export declare const AEGIS_SWAP_HOOK: `0x${string}`;
4
+ export declare const AEGIS_DYNAMIC_FEE_FLAG = 8388608;
5
+ export declare const AEGIS_SWAP_DEFAULT_FEE_BPS = 50;
6
+ export declare const AEGIS_SWAP_DEFAULT_FEE_RECIPIENT: `0x${string}`;
7
+ export declare const AEGIS_SWAP_DEFAULT_RPC_URLS: string[];
8
+ export declare const AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT = "https://aegis.markets/graphql/meta";
9
+ export declare const AGGREGATED_SWAP_FEE_BPS = 50;
10
+ export declare const AGGREGATED_SWAP_FEE_RECIPIENT: `0x${string}`;
@@ -0,0 +1,6 @@
1
+ import type { AegisSwapUniswapV4Contracts, AegisSwapUniswapV4ContractsInput } from './types';
2
+ export declare function createAegisSwapUniswapV4Contracts(input: AegisSwapUniswapV4ContractsInput): AegisSwapUniswapV4Contracts;
3
+ export declare const UNISWAP_V4_CONTRACTS_BY_CHAIN: Record<number, AegisSwapUniswapV4Contracts>;
4
+ export declare const AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS: AegisSwapUniswapV4Contracts;
5
+ export declare const AEGIS_SWAP_PERMIT2: `0x${string}`;
6
+ export declare const AEGIS_SWAP_V4_QUOTER: `0x${string}`;
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+ export * from './constants';
3
+ export * from './contracts';
4
+ export * from './chains';
5
+ export * from './tokens';
6
+ export * from './markets';
@@ -0,0 +1,3 @@
1
+ import type { AegisSwapChainConfig, AegisSwapMarket, AegisSwapPoolConfig } from './types';
2
+ export declare function createAegisSwapPoolMarket(input: AegisSwapPoolConfig, chains?: Record<number, AegisSwapChainConfig>): AegisSwapMarket;
3
+ export declare function createAegisSwapMarketsFromPools(pools: AegisSwapPoolConfig[] | undefined, chains?: Record<number, AegisSwapChainConfig>): Record<string, AegisSwapMarket>;
@@ -0,0 +1,11 @@
1
+ import type { AegisSwapBuiltInTokenSymbol, AegisSwapToken, AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken, AggregatedSwapWolfGameTokenSymbol } from './types';
2
+ export declare const AEGIS_SWAP_TOKENS: Record<AegisSwapBuiltInTokenSymbol, AegisSwapToken>;
3
+ export declare const AGGREGATED_SWAP_DEFAULT_TOKENS: Record<AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken>;
4
+ export declare const AGGREGATED_SWAP_WOLFGAME_TOKENS: Record<AggregatedSwapWolfGameTokenSymbol, AggregatedSwapToken>;
5
+ export declare const AGGREGATED_SWAP_DEFAULT_TOKEN_LIST: AegisSwapToken[];
6
+ export declare const AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST: AegisSwapToken[];
7
+ export declare const AGGREGATED_SWAP_TOKEN_PRESETS: {
8
+ readonly default: AegisSwapToken[];
9
+ readonly wolfgame: AegisSwapToken[];
10
+ };
11
+ export declare const AGGREGATED_SWAP_CURATED_TOKENS: Record<AggregatedSwapDefaultTokenSymbol, AegisSwapToken>;
@@ -0,0 +1,81 @@
1
+ import type { Address, Chain, Hex } from 'viem';
2
+ export type AegisSwapBuiltInTokenSymbol = 'USDC' | 'WATER' | 'WOOD' | 'GRASS' | 'STONE';
3
+ export type AegisSwapTokenSymbol = string;
4
+ export type AegisSwapFeeConfig = {
5
+ bps: number;
6
+ recipient: Address;
7
+ };
8
+ export type AegisSwapToken = {
9
+ chainId: number;
10
+ address: Address;
11
+ name: string;
12
+ symbol: AegisSwapTokenSymbol;
13
+ decimals: number;
14
+ iconUrl?: string | null;
15
+ };
16
+ export type AegisPoolKey = {
17
+ currency0: Address;
18
+ currency1: Address;
19
+ fee: number;
20
+ tickSpacing: number;
21
+ hooks: Address;
22
+ };
23
+ export type AegisSwapUniswapV4Contracts = {
24
+ permit2: Address;
25
+ quoter: Address;
26
+ poolManager?: Address;
27
+ positionDescriptor?: Address;
28
+ positionManager?: Address;
29
+ stateView?: Address;
30
+ universalRouter?: Address;
31
+ universalRouterV2_1_1?: Address;
32
+ };
33
+ export type AegisSwapUniswapV4ContractsInput = Partial<AegisSwapUniswapV4Contracts>;
34
+ export type AegisSwapMarket = {
35
+ id: string;
36
+ chainId: number;
37
+ symbol: AegisSwapTokenSymbol;
38
+ poolId: Hex;
39
+ poolKey: AegisPoolKey;
40
+ token: AegisSwapToken;
41
+ counterToken: AegisSwapToken;
42
+ router: Address;
43
+ permit2: Address;
44
+ quoter: Address;
45
+ label?: string;
46
+ };
47
+ export type AegisSwapChainConfig = {
48
+ chainId: number;
49
+ chain: Chain;
50
+ name: string;
51
+ router: Address;
52
+ permit2: Address;
53
+ quoter: Address;
54
+ v4Contracts: AegisSwapUniswapV4Contracts;
55
+ rpcUrls: string[];
56
+ explorerTxUrl?: (hash: Hex) => string;
57
+ poolExplorerUrl?: (poolId: Hex, market: AegisSwapMarket) => string;
58
+ metadataEndpoint?: string | null;
59
+ fee?: AegisSwapFeeConfig;
60
+ };
61
+ export type AegisSwapChainConfigInput = Partial<Omit<AegisSwapChainConfig, 'chainId' | 'v4Contracts' | 'fee'>> & {
62
+ chainId?: number;
63
+ v4Contracts?: AegisSwapUniswapV4ContractsInput;
64
+ };
65
+ export type AegisSwapPoolConfig = {
66
+ id: string;
67
+ symbol?: AegisSwapTokenSymbol;
68
+ chainId?: number;
69
+ poolKey: AegisPoolKey;
70
+ poolId?: Hex;
71
+ token: AegisSwapToken;
72
+ counterToken: AegisSwapToken;
73
+ router?: Address;
74
+ permit2?: Address;
75
+ quoter?: Address;
76
+ label?: string;
77
+ };
78
+ export type AggregatedSwapToken = AegisSwapToken;
79
+ export type AggregatedSwapDefaultTokenSymbol = 'USDC' | 'USDT' | 'WETH' | 'ETH' | 'WBTC' | 'STETH';
80
+ export type AggregatedSwapWolfGameTokenSymbol = AegisSwapBuiltInTokenSymbol | 'ETH';
81
+ export type AggregatedSwapTokenSymbol = AggregatedSwapDefaultTokenSymbol | AggregatedSwapWolfGameTokenSymbol;
@@ -0,0 +1,13 @@
1
+ import type { Address, Hex } from 'viem';
2
+ export type AegisContractGuardCode = 'QUOTE_EXPIRED' | 'ROUTER_NOT_ALLOWLISTED' | 'SPENDER_NOT_ALLOWLISTED' | 'CALLDATA_HASH_MISMATCH' | 'CHAIN_MISMATCH';
3
+ export declare class AegisContractGuardError extends Error {
4
+ readonly code: AegisContractGuardCode;
5
+ constructor(code: AegisContractGuardCode, message: string);
6
+ }
7
+ export declare function assertQuoteFresh(quote: {
8
+ expiresAt: string;
9
+ }, nowMs?: number): void;
10
+ export declare function assertRouterAllowlisted(to: Address, allowlistedRouters: readonly Address[]): void;
11
+ export declare function assertSpenderAllowlisted(spender: Address, allowlistedSpenders: readonly Address[]): void;
12
+ export declare function assertCalldataHash(data: Hex, expectedCalldataHash: Hex): void;
13
+ export declare function assertChainMatches(walletChainId: number, txChainId: number): void;
@@ -0,0 +1,2 @@
1
+ export * from './guards';
2
+ export * from './schemas';
@@ -0,0 +1,282 @@
1
+ import { z } from 'zod';
2
+ export declare const aegisBackendAddressSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
3
+ export declare const aegisBackendHexSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
4
+ export declare const aegisBackendDecimalStringSchema: z.ZodString;
5
+ export declare const aegisBackendIsoDateTimeSchema: z.ZodISODateTime;
6
+ export declare const aegisBackendSwapProviderSchema: z.ZodEnum<{
7
+ "aegis-direct-v4": "aegis-direct-v4";
8
+ kyber: "kyber";
9
+ }>;
10
+ export declare const aegisBackendQuoteModeSchema: z.ZodEnum<{
11
+ exactIn: "exactIn";
12
+ exactOut: "exactOut";
13
+ }>;
14
+ export declare const aegisBackendMarketStatusSchema: z.ZodEnum<{
15
+ enabled: "enabled";
16
+ disabled: "disabled";
17
+ }>;
18
+ export declare const aegisBackendTxStatusSchema: z.ZodEnum<{
19
+ pending: "pending";
20
+ success: "success";
21
+ reverted: "reverted";
22
+ not_found: "not_found";
23
+ }>;
24
+ export declare const aegisBackendChainSchema: z.ZodObject<{
25
+ chainId: z.ZodNumber;
26
+ slug: z.ZodString;
27
+ name: z.ZodString;
28
+ }, z.core.$strip>;
29
+ export declare const aegisBackendQuoteDefaultsSchema: z.ZodObject<{
30
+ ttlSeconds: z.ZodNumber;
31
+ defaultSlippageBps: z.ZodNumber;
32
+ maxSlippageBps: z.ZodNumber;
33
+ }, z.core.$strip>;
34
+ export declare const aegisBackendContractRegistrySchema: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
35
+ export declare const aegisBackendAddressAllowlistSchema: z.ZodObject<{
36
+ routers: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
37
+ spenders: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
38
+ }, z.core.$strip>;
39
+ export declare const aegisBackendFeeConfigSchema: z.ZodObject<{
40
+ outputFeeBps: z.ZodNumber;
41
+ recipient: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
42
+ }, z.core.$strip>;
43
+ export declare const aegisBackendConfigSchema: z.ZodObject<{
44
+ schemaVersion: z.ZodString;
45
+ chains: z.ZodArray<z.ZodObject<{
46
+ chainId: z.ZodNumber;
47
+ slug: z.ZodString;
48
+ name: z.ZodString;
49
+ }, z.core.$strip>>;
50
+ providers: z.ZodArray<z.ZodEnum<{
51
+ "aegis-direct-v4": "aegis-direct-v4";
52
+ kyber: "kyber";
53
+ }>>;
54
+ quote: z.ZodObject<{
55
+ ttlSeconds: z.ZodNumber;
56
+ defaultSlippageBps: z.ZodNumber;
57
+ maxSlippageBps: z.ZodNumber;
58
+ }, z.core.$strip>;
59
+ contracts: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>;
60
+ allowlists: z.ZodRecord<z.ZodString, z.ZodObject<{
61
+ routers: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
62
+ spenders: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
63
+ }, z.core.$strip>>;
64
+ fee: z.ZodObject<{
65
+ outputFeeBps: z.ZodNumber;
66
+ recipient: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
67
+ }, z.core.$strip>;
68
+ }, z.core.$strip>;
69
+ export declare const aegisBackendTokenSchema: z.ZodObject<{
70
+ id: z.ZodString;
71
+ chainId: z.ZodNumber;
72
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
73
+ symbol: z.ZodString;
74
+ displayName: z.ZodString;
75
+ fullName: z.ZodString;
76
+ decimals: z.ZodNumber;
77
+ priceUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
78
+ iconUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ stable: z.ZodOptional<z.ZodBoolean>;
80
+ }, z.core.$strip>;
81
+ export declare const aegisBackendMarketMetricsSchema: z.ZodObject<{
82
+ tvlUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
83
+ volumeUsd7d: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
84
+ feeApr7d: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
85
+ }, z.core.$strip>;
86
+ export declare const aegisPoolKeySchema: z.ZodObject<{
87
+ currency0: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
88
+ currency1: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
89
+ fee: z.ZodNumber;
90
+ tickSpacing: z.ZodNumber;
91
+ hooks: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
92
+ }, z.core.$strip>;
93
+ export declare const aegisBackendMarketSchema: z.ZodObject<{
94
+ id: z.ZodString;
95
+ chainId: z.ZodNumber;
96
+ status: z.ZodEnum<{
97
+ enabled: "enabled";
98
+ disabled: "disabled";
99
+ }>;
100
+ kind: z.ZodEnum<{
101
+ "aegis-direct-v4": "aegis-direct-v4";
102
+ kyber: "kyber";
103
+ }>;
104
+ label: z.ZodString;
105
+ baseToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
106
+ quoteToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
107
+ poolId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
108
+ poolKey: z.ZodObject<{
109
+ currency0: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
110
+ currency1: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
111
+ fee: z.ZodNumber;
112
+ tickSpacing: z.ZodNumber;
113
+ hooks: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
114
+ }, z.core.$strip>;
115
+ metrics: z.ZodOptional<z.ZodObject<{
116
+ tvlUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
117
+ volumeUsd7d: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
118
+ feeApr7d: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
119
+ }, z.core.$strip>>;
120
+ warnings: z.ZodArray<z.ZodString>;
121
+ }, z.core.$strip>;
122
+ export declare const aegisBackendSwapQuoteRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
123
+ mode: z.ZodLiteral<"exactIn">;
124
+ amountIn: z.ZodString;
125
+ amountOut: z.ZodOptional<z.ZodNever>;
126
+ chainId: z.ZodNumber;
127
+ provider: z.ZodEnum<{
128
+ "aegis-direct-v4": "aegis-direct-v4";
129
+ kyber: "kyber";
130
+ }>;
131
+ marketId: z.ZodOptional<z.ZodString>;
132
+ tokenIn: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
133
+ tokenOut: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
134
+ slippageBps: z.ZodNumber;
135
+ account: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
136
+ }, z.core.$strip>, z.ZodObject<{
137
+ mode: z.ZodLiteral<"exactOut">;
138
+ amountOut: z.ZodString;
139
+ amountIn: z.ZodOptional<z.ZodNever>;
140
+ chainId: z.ZodNumber;
141
+ provider: z.ZodEnum<{
142
+ "aegis-direct-v4": "aegis-direct-v4";
143
+ kyber: "kyber";
144
+ }>;
145
+ marketId: z.ZodOptional<z.ZodString>;
146
+ tokenIn: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
147
+ tokenOut: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
148
+ slippageBps: z.ZodNumber;
149
+ account: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
150
+ }, z.core.$strip>], "mode">;
151
+ export declare const aegisBackendSwapApprovalSchema: z.ZodObject<{
152
+ required: z.ZodBoolean;
153
+ model: z.ZodEnum<{
154
+ permit2: "permit2";
155
+ erc20: "erc20";
156
+ native: "native";
157
+ none: "none";
158
+ }>;
159
+ spender: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
160
+ }, z.core.$strip>;
161
+ export declare const aegisBackendSwapQuoteResponseSchema: z.ZodObject<{
162
+ quoteId: z.ZodString;
163
+ quoteHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
164
+ routeHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
165
+ expiresAt: z.ZodISODateTime;
166
+ quoteBlockNumber: z.ZodString;
167
+ provider: z.ZodEnum<{
168
+ "aegis-direct-v4": "aegis-direct-v4";
169
+ kyber: "kyber";
170
+ }>;
171
+ marketId: z.ZodOptional<z.ZodString>;
172
+ amountIn: z.ZodString;
173
+ amountOut: z.ZodString;
174
+ minAmountOut: z.ZodString;
175
+ gasEstimate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
176
+ approval: z.ZodObject<{
177
+ required: z.ZodBoolean;
178
+ model: z.ZodEnum<{
179
+ permit2: "permit2";
180
+ erc20: "erc20";
181
+ native: "native";
182
+ none: "none";
183
+ }>;
184
+ spender: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
185
+ }, z.core.$strip>;
186
+ fee: z.ZodObject<{
187
+ outputFeeBps: z.ZodNumber;
188
+ recipient: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
189
+ }, z.core.$strip>;
190
+ warnings: z.ZodArray<z.ZodString>;
191
+ }, z.core.$strip>;
192
+ export declare const aegisBackendSwapBuildRequestSchema: z.ZodObject<{
193
+ quoteId: z.ZodString;
194
+ account: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
195
+ recipient: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
196
+ permitSignature: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
197
+ }, z.core.$strip>;
198
+ export declare const aegisBackendUnsignedSwapTxSchema: z.ZodObject<{
199
+ chainId: z.ZodNumber;
200
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
201
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
202
+ value: z.ZodString;
203
+ }, z.core.$strip>;
204
+ export declare const aegisBackendSwapBuildResponseSchema: z.ZodObject<{
205
+ buildId: z.ZodString;
206
+ quoteId: z.ZodString;
207
+ routeHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
208
+ expectedCalldataHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
209
+ expiresAt: z.ZodISODateTime;
210
+ tx: z.ZodObject<{
211
+ chainId: z.ZodNumber;
212
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
213
+ data: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
214
+ value: z.ZodString;
215
+ }, z.core.$strip>;
216
+ allowance: z.ZodObject<{
217
+ spender: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
218
+ permit2Required: z.ZodBoolean;
219
+ }, z.core.$strip>;
220
+ simulation: z.ZodObject<{
221
+ ok: z.ZodBoolean;
222
+ blockNumber: z.ZodOptional<z.ZodString>;
223
+ }, z.core.$strip>;
224
+ warnings: z.ZodArray<z.ZodString>;
225
+ }, z.core.$strip>;
226
+ export declare const aegisBackendTxStatusResponseSchema: z.ZodObject<{
227
+ status: z.ZodEnum<{
228
+ pending: "pending";
229
+ success: "success";
230
+ reverted: "reverted";
231
+ not_found: "not_found";
232
+ }>;
233
+ blockNumber: z.ZodOptional<z.ZodNullable<z.ZodString>>;
234
+ gasUsed: z.ZodOptional<z.ZodNullable<z.ZodString>>;
235
+ effectiveGasPrice: z.ZodOptional<z.ZodNullable<z.ZodString>>;
236
+ feeWei: z.ZodOptional<z.ZodNullable<z.ZodString>>;
237
+ explorerUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
238
+ }, z.core.$strip>;
239
+ export declare const aegisBackendHealthResponseSchema: z.ZodObject<{
240
+ ok: z.ZodBoolean;
241
+ }, z.core.$strip>;
242
+ export declare const aegisBackendTokensResponseSchema: z.ZodArray<z.ZodObject<{
243
+ id: z.ZodString;
244
+ chainId: z.ZodNumber;
245
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
246
+ symbol: z.ZodString;
247
+ displayName: z.ZodString;
248
+ fullName: z.ZodString;
249
+ decimals: z.ZodNumber;
250
+ priceUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
251
+ iconUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
252
+ stable: z.ZodOptional<z.ZodBoolean>;
253
+ }, z.core.$strip>>;
254
+ export declare const aegisBackendMarketsResponseSchema: z.ZodArray<z.ZodObject<{
255
+ id: z.ZodString;
256
+ chainId: z.ZodNumber;
257
+ status: z.ZodEnum<{
258
+ enabled: "enabled";
259
+ disabled: "disabled";
260
+ }>;
261
+ kind: z.ZodEnum<{
262
+ "aegis-direct-v4": "aegis-direct-v4";
263
+ kyber: "kyber";
264
+ }>;
265
+ label: z.ZodString;
266
+ baseToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
267
+ quoteToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
268
+ poolId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
269
+ poolKey: z.ZodObject<{
270
+ currency0: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
271
+ currency1: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
272
+ fee: z.ZodNumber;
273
+ tickSpacing: z.ZodNumber;
274
+ hooks: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
275
+ }, z.core.$strip>;
276
+ metrics: z.ZodOptional<z.ZodObject<{
277
+ tvlUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
278
+ volumeUsd7d: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
279
+ feeApr7d: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
280
+ }, z.core.$strip>>;
281
+ warnings: z.ZodArray<z.ZodString>;
282
+ }, z.core.$strip>>;
package/dist/index.d.ts CHANGED
@@ -26,3 +26,7 @@ export { errorMessage, isUserRejectedError } from './errors';
26
26
  export { isBusy, transactionProgressView } from './transactionProgress';
27
27
  export type { AegisSwapReceiptSummary, AegisSwapStatusSnapshot, AegisSwapWalletPromptProgress, SubmitStatus, TransactionProgressState, TransactionProgressView } from './transactionProgress';
28
28
  export { isDocumentVisible, pollUntil, retryOnError } from './polling';
29
+ export { AegisBackendApiError, AegisBackendContractError, createAegisBackendApiClient, isRetryableAegisBackendApiError } from './backendApi';
30
+ export type { AegisBackendAddressAllowlist, AegisBackendApiClient, AegisBackendApiClientOptions, AegisBackendChain, AegisBackendConfig, AegisBackendContractRegistry, AegisBackendFeeConfig, AegisBackendMarket, AegisBackendMarketMetrics, AegisBackendMarketStatus, AegisBackendQuoteDefaults, AegisBackendQuoteMode, AegisBackendRequestOptions, AegisBackendSwapApproval, AegisBackendSwapBuildRequest, AegisBackendSwapBuildResponse, AegisBackendSwapProvider, AegisBackendSwapQuoteRequest, AegisBackendSwapQuoteResponse, AegisBackendToken, AegisBackendTxStatus, AegisBackendTxStatusResponse, AegisBackendUnsignedSwapTx } from './backendApi';
31
+ export { aegisBackendAddressAllowlistSchema, aegisBackendAddressSchema, aegisBackendChainSchema, aegisBackendConfigSchema, aegisBackendContractRegistrySchema, aegisBackendDecimalStringSchema, aegisBackendFeeConfigSchema, aegisBackendHealthResponseSchema, aegisBackendHexSchema, aegisBackendIsoDateTimeSchema, aegisBackendMarketMetricsSchema, aegisBackendMarketSchema, aegisBackendMarketStatusSchema, aegisBackendMarketsResponseSchema, aegisBackendQuoteDefaultsSchema, aegisBackendQuoteModeSchema, aegisBackendSwapApprovalSchema, aegisBackendSwapBuildRequestSchema, aegisBackendSwapBuildResponseSchema, aegisBackendSwapProviderSchema, aegisBackendSwapQuoteRequestSchema, aegisBackendSwapQuoteResponseSchema, aegisBackendTokenSchema, aegisBackendTokensResponseSchema, aegisBackendTxStatusResponseSchema, aegisBackendTxStatusSchema, aegisBackendUnsignedSwapTxSchema, aegisPoolKeySchema, AegisContractGuardError, assertCalldataHash, assertChainMatches, assertQuoteFresh, assertRouterAllowlisted, assertSpenderAllowlisted } from './contract';
32
+ export type { AegisContractGuardCode } from './contract';
@@ -16,12 +16,11 @@ export type SwapExecutionResult = {
16
16
  /**
17
17
  * Builds the swap calldata, sends it, and waits for the receipt.
18
18
  *
19
- * Estimates gas with a 20% headroom bump, surfaces the optimistic hash through
20
- * `setTxHash` (and `onSubmitted`) before mining, then tracks replacements: a
21
- * wallet speed-up swaps in the hash that actually mines, while a wallet cancel
22
- * mines a no-op whose "successful" receipt must not count as a swap — so a
23
- * cancelled or reverted receipt throws. Setting the success status and the
24
- * post-success refreshes stay with the caller.
19
+ * Estimates gas with a 20% headroom bump, then hands off to
20
+ * `sendSwapTransactionAndAwait`, which surfaces the optimistic hash through
21
+ * `setTxHash`/`onSubmitted`, tracks wallet replacements, and rejects a cancelled
22
+ * or reverted receipt. Setting the success status and the post-success refreshes
23
+ * stay with the caller.
25
24
  */
26
25
  export declare function executeSwapTransaction({ wallet, publicClient, activeChain, market, inputToken, outputToken, swapQuote, permit, setStatus, setTxHash, onSubmitted }: {
27
26
  wallet: WalletSession;