@aegis-engine/core 0.2.0 → 0.3.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.
Files changed (41) hide show
  1. package/README.md +109 -4
  2. package/THIRD_PARTY_NOTICES.md +211 -0
  3. package/dist/actions/kyberSwap.d.ts +3 -2
  4. package/dist/address.d.ts +3 -1
  5. package/dist/aegis-core.js +8421 -5279
  6. package/dist/backendAdapters.d.ts +25 -1
  7. package/dist/config/constants.d.ts +4 -0
  8. package/dist/config/types.d.ts +5 -0
  9. package/dist/contract/backendClient.d.ts +16 -6
  10. package/dist/contract/generated/aegis-swap.d.ts +2682 -96
  11. package/dist/contract/schemas.d.ts +27 -20
  12. package/dist/engine/actions.d.ts +56 -0
  13. package/dist/engine/borrowCostProjection.d.ts +1 -0
  14. package/dist/engine/dataSource.d.ts +63 -0
  15. package/dist/engine/index.d.ts +7 -0
  16. package/dist/engine/marketAdapter.d.ts +8 -0
  17. package/dist/engine/quotes.d.ts +8 -0
  18. package/dist/engine/reads.d.ts +41 -0
  19. package/dist/engine/registry.d.ts +27 -0
  20. package/dist/engine/restSchemas.d.ts +409 -0
  21. package/dist/engine/sdk.d.ts +1 -0
  22. package/dist/engine/sdkRuntime.d.ts +1 -0
  23. package/dist/engine/types.d.ts +992 -0
  24. package/dist/errors.d.ts +10 -0
  25. package/dist/historicalPrices.d.ts +78 -0
  26. package/dist/index.d.ts +13 -8
  27. package/dist/internal/requestSignal.d.ts +9 -0
  28. package/dist/internal/ttlCache.d.ts +19 -0
  29. package/dist/metadata.d.ts +4 -0
  30. package/dist/permit.d.ts +1 -0
  31. package/dist/quote/aggregatedSwapQuote.d.ts +12 -0
  32. package/dist/quote/kyberCalldata.d.ts +211 -0
  33. package/dist/quote.d.ts +1 -0
  34. package/dist/sdkRuntime-CCRVvSwD.js +16052 -0
  35. package/dist/services/kyberSwap.d.ts +22 -2
  36. package/dist/swap/receiptWait.d.ts +17 -0
  37. package/dist/swap/sendSwapTransaction.d.ts +40 -6
  38. package/dist/swap/settlement.d.ts +15 -0
  39. package/dist/transactionProgress.d.ts +8 -1
  40. package/dist/types/aggregatedSwap.d.ts +18 -0
  41. package/package.json +15 -7
@@ -1,17 +1,41 @@
1
1
  import type { AegisBackendConfig, AegisBackendMarket, AegisBackendToken } from './contract/backendClient.js';
2
2
  import { type AegisSwapChainConfig, type AegisSwapChainConfigInput, type AegisSwapPoolConfig, type AegisSwapToken } from './config/index.js';
3
+ /**
4
+ * The adapters below drop chains/markets that arrive incomplete or inconsistent
5
+ * (missing contracts, no RPC, or a poolKey that doesn't hash to its poolId).
6
+ * Two visibility channels:
7
+ * - `onSkip` (per call, additive): structured diagnostics so hosts can emit
8
+ * telemetry and distinguish "backend returned nothing" from "client dropped
9
+ * everything".
10
+ * - `globalThis.__AEGIS_SWAP_DEBUG__ = true`: opt-in console breadcrumb for
11
+ * local debugging. Off by default, so production stays silent.
12
+ */
13
+ export type AegisBackendAdapterSkip = {
14
+ kind: 'chain' | 'market';
15
+ chainId: number;
16
+ /** Present for market skips only. */
17
+ marketId?: string;
18
+ reason: string;
19
+ /** The raw breadcrumb payload (booleans/messages behind the reason). */
20
+ context: Record<string, unknown>;
21
+ };
22
+ export type AegisBackendAdapterSkipHandler = (skip: AegisBackendAdapterSkip) => void;
3
23
  export type AegisBackendChainOptions = {
4
24
  rpcUrls?: readonly string[] | Partial<Record<number, readonly string[]>>;
5
25
  metadataEndpoint?: string | null;
6
26
  /** Backend chain ids the host project exposes. Omit to use every backend chain. */
7
27
  enabledChainIds?: readonly number[];
28
+ /** Structured diagnostics for every chain the adapter drops. */
29
+ onSkip?: AegisBackendAdapterSkipHandler;
8
30
  };
9
31
  export declare function backendTokenToAegisSwapToken(token: AegisBackendToken): AegisSwapToken;
10
32
  export declare function backendTokensToAegisSwapTokens(tokens: readonly AegisBackendToken[]): AegisSwapToken[];
11
33
  export declare function createAegisSwapChainsFromBackendConfig(config: AegisBackendConfig, hostChains?: Partial<Record<number, AegisSwapChainConfigInput>>, options?: AegisBackendChainOptions): Record<number, AegisSwapChainConfig>;
12
- export declare function createAegisSwapPoolsFromBackendMarkets({ config, markets, tokens, enabledOnly }: {
34
+ export declare function createAegisSwapPoolsFromBackendMarkets({ config, markets, tokens, enabledOnly, onSkip }: {
13
35
  config: AegisBackendConfig;
14
36
  markets: readonly AegisBackendMarket[];
15
37
  tokens: readonly AegisBackendToken[];
16
38
  enabledOnly?: boolean;
39
+ /** Structured diagnostics for every market the adapter drops. */
40
+ onSkip?: AegisBackendAdapterSkipHandler;
17
41
  }): AegisSwapPoolConfig[];
@@ -1,5 +1,7 @@
1
+ import { type Address } from 'viem';
1
2
  export declare const AEGIS_SWAP_CHAIN_ID = 1;
2
3
  export declare const AEGIS_SWAP_ROUTER: `0x${string}`;
4
+ export declare const AEGIS_SWAP_TRUSTED_ROUTERS_BY_CHAIN: Partial<Record<number, readonly Address[]>>;
3
5
  export declare const AEGIS_SWAP_HOOK: `0x${string}`;
4
6
  export declare const AEGIS_DYNAMIC_FEE_FLAG = 8388608;
5
7
  export declare const AEGIS_SWAP_DEFAULT_FEE_BPS = 50;
@@ -8,3 +10,5 @@ export declare const AEGIS_SWAP_DEFAULT_RPC_URLS: string[];
8
10
  export declare const AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT = "https://aegis.markets/graphql/meta";
9
11
  export declare const AGGREGATED_SWAP_FEE_BPS = 50;
10
12
  export declare const AGGREGATED_SWAP_FEE_RECIPIENT: `0x${string}`;
13
+ export declare const AGGREGATED_SWAP_KYBER_ROUTER: `0x${string}`;
14
+ export declare const AGGREGATED_SWAP_SUPPORTED_CHAIN_IDS: readonly [1];
@@ -12,6 +12,11 @@ export type AegisSwapToken = {
12
12
  symbol: AegisSwapTokenSymbol;
13
13
  decimals: number;
14
14
  iconUrl?: string | null;
15
+ /** Spot USD price per whole token, when the source provides one. Optional so
16
+ host-supplied token lists without pricing still type-check. */
17
+ priceUsd?: number;
18
+ /** Marks a USD-pegged stablecoin (from the backend); presentational only. */
19
+ stable?: boolean;
15
20
  };
16
21
  export type AegisPoolKey = {
17
22
  currency0: Address;
@@ -14,8 +14,12 @@ export type AegisBackendSwapProvider = AegisBackendWireConfig['providers'][numbe
14
14
  export type AegisBackendQuoteMode = AegisBackendWireSwapQuoteRequest['mode'];
15
15
  export type AegisBackendMarketStatus = AegisBackendWireMarket['status'];
16
16
  export declare const AEGIS_BACKEND_PROD_BASE_URL = "https://nlkvpvkx9h.execute-api.us-east-1.amazonaws.com/prod";
17
- export type AegisBackendChain = AegisBackendWireConfig['chains'][number];
18
- export type AegisBackendQuoteDefaults = AegisBackendWireConfig['quote'];
17
+ export type AegisBackendChain = Omit<AegisBackendWireConfig['chains'][number], 'chainId'> & {
18
+ chainId: number;
19
+ };
20
+ export type AegisBackendQuoteDefaults = {
21
+ [Field in keyof AegisBackendWireConfig['quote']]: number;
22
+ };
19
23
  export type AegisBackendContractRegistry = {
20
24
  aegisRouter?: Address;
21
25
  permit2?: Address;
@@ -33,23 +37,28 @@ export type AegisBackendContractsByChain = {
33
37
  export type AegisBackendAllowlistsByChain = {
34
38
  [ChainId in keyof AegisBackendWireConfig['allowlists']]: AegisBackendAddressAllowlist;
35
39
  };
36
- export type AegisBackendFeeConfig = Omit<AegisBackendWireConfig['fee'], 'recipient'> & {
40
+ export type AegisBackendFeeConfig = Omit<AegisBackendWireConfig['fee'], 'recipient' | 'outputFeeBps'> & {
37
41
  recipient: Address;
42
+ outputFeeBps: number;
38
43
  };
39
- export type AegisBackendConfig = Omit<AegisBackendWireConfig, 'contracts' | 'allowlists' | 'fee'> & {
44
+ export type AegisBackendConfig = Omit<AegisBackendWireConfig, 'chains' | 'quote' | 'contracts' | 'allowlists' | 'fee'> & {
45
+ chains: AegisBackendChain[];
46
+ quote: AegisBackendQuoteDefaults;
40
47
  contracts: AegisBackendContractsByChain;
41
48
  allowlists: AegisBackendAllowlistsByChain;
42
49
  fee: AegisBackendFeeConfig;
43
50
  };
44
- export type AegisBackendToken = Omit<AegisBackendWireToken, 'address'> & {
51
+ export type AegisBackendToken = Omit<AegisBackendWireToken, 'address' | 'chainId'> & {
45
52
  address: Address;
53
+ chainId: number;
46
54
  };
47
55
  export type AegisBackendMarketMetrics = AegisBackendWireMarket['metrics'];
48
- export type AegisBackendMarket = Omit<AegisBackendWireMarket, 'baseToken' | 'quoteToken' | 'poolId' | 'poolKey'> & {
56
+ export type AegisBackendMarket = Omit<AegisBackendWireMarket, 'baseToken' | 'quoteToken' | 'poolId' | 'poolKey' | 'chainId'> & {
49
57
  baseToken: Address;
50
58
  quoteToken: Address;
51
59
  poolId: Hex;
52
60
  poolKey: AegisPoolKey;
61
+ chainId: number;
53
62
  };
54
63
  export type AegisBackendSwapQuoteRequest = z.infer<typeof aegisBackendSwapQuoteRequestSchema>;
55
64
  export type AegisBackendSwapQuoteResponse = Omit<AegisBackendWireSwapQuoteResponse, 'tokenIn' | 'tokenOut' | 'fee'> & {
@@ -104,5 +113,6 @@ export type AegisBackendApiClient = {
104
113
  }, options?: AegisBackendRequestOptions) => Promise<AegisBackendMarket[]>;
105
114
  quote: (args: AegisBackendSwapQuoteRequest, options?: AegisBackendRequestOptions) => Promise<AegisBackendSwapQuoteResponse>;
106
115
  };
116
+ export declare function normalizeAegisBackendBaseUrl(baseUrl: string): string;
107
117
  export declare function createAegisBackendApiClient(options: AegisBackendApiClientOptions): AegisBackendApiClient;
108
118
  export {};