@aegis-engine/core 0.1.2 → 0.2.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.
@@ -1,201 +0,0 @@
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 {};