@aegis-engine/core 0.1.3 → 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.
- package/README.md +124 -33
- package/THIRD_PARTY_NOTICES.md +211 -0
- package/dist/actions/directPoolSwap.d.ts +4 -4
- package/dist/actions/kyberSwap.d.ts +7 -6
- package/dist/actions/types.d.ts +4 -4
- package/dist/actions/wallet.d.ts +3 -3
- package/dist/address.d.ts +3 -1
- package/dist/aegis-core.js +8459 -4741
- package/dist/backendAdapters.d.ts +41 -0
- package/dist/config/chains.d.ts +1 -1
- package/dist/config/constants.d.ts +4 -0
- package/dist/config/contracts.d.ts +1 -1
- package/dist/config/index.d.ts +6 -6
- package/dist/config/markets.d.ts +1 -1
- package/dist/config/tokens.d.ts +1 -1
- package/dist/config/types.d.ts +5 -0
- package/dist/contract/backendClient.d.ts +118 -0
- package/dist/contract/generated/aegis-swap.d.ts +3306 -0
- package/dist/contract/index.d.ts +3 -2
- package/dist/contract/schemas.d.ts +95 -127
- package/dist/encoding.d.ts +1 -1
- package/dist/engine/actions.d.ts +56 -0
- package/dist/engine/borrowCostProjection.d.ts +1 -0
- package/dist/engine/dataSource.d.ts +63 -0
- package/dist/engine/index.d.ts +7 -0
- package/dist/engine/marketAdapter.d.ts +8 -0
- package/dist/engine/quotes.d.ts +8 -0
- package/dist/engine/reads.d.ts +41 -0
- package/dist/engine/registry.d.ts +27 -0
- package/dist/engine/restSchemas.d.ts +409 -0
- package/dist/engine/sdk.d.ts +1 -0
- package/dist/engine/sdkRuntime.d.ts +1 -0
- package/dist/engine/types.d.ts +992 -0
- package/dist/errors.d.ts +10 -0
- package/dist/historicalPrices.d.ts +78 -0
- package/dist/index.d.ts +39 -32
- package/dist/internal/requestSignal.d.ts +9 -0
- package/dist/internal/ttlCache.d.ts +19 -0
- package/dist/metadata.d.ts +5 -1
- package/dist/permit.d.ts +3 -2
- package/dist/quote/aggregatedSwapQuote.d.ts +14 -2
- package/dist/quote/kyberCalldata.d.ts +211 -0
- package/dist/quote.d.ts +3 -2
- package/dist/sdkRuntime-CCRVvSwD.js +16052 -0
- package/dist/services/kyberSwap.d.ts +22 -2
- package/dist/swap/authorizePermit.d.ts +5 -5
- package/dist/swap/executeSwapTransaction.d.ts +5 -5
- package/dist/swap/receiptWait.d.ts +17 -0
- package/dist/swap/sendSwapTransaction.d.ts +42 -8
- package/dist/swap/settlement.d.ts +15 -0
- package/dist/swap/types.d.ts +2 -2
- package/dist/transactionProgress.d.ts +8 -1
- package/dist/types/aggregatedSwap.d.ts +19 -1
- package/package.json +20 -8
- package/dist/backendApi.d.ts +0 -201
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AegisBackendConfig, AegisBackendMarket, AegisBackendToken } from './contract/backendClient.js';
|
|
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;
|
|
23
|
+
export type AegisBackendChainOptions = {
|
|
24
|
+
rpcUrls?: readonly string[] | Partial<Record<number, readonly string[]>>;
|
|
25
|
+
metadataEndpoint?: string | null;
|
|
26
|
+
/** Backend chain ids the host project exposes. Omit to use every backend chain. */
|
|
27
|
+
enabledChainIds?: readonly number[];
|
|
28
|
+
/** Structured diagnostics for every chain the adapter drops. */
|
|
29
|
+
onSkip?: AegisBackendAdapterSkipHandler;
|
|
30
|
+
};
|
|
31
|
+
export declare function backendTokenToAegisSwapToken(token: AegisBackendToken): AegisSwapToken;
|
|
32
|
+
export declare function backendTokensToAegisSwapTokens(tokens: readonly AegisBackendToken[]): AegisSwapToken[];
|
|
33
|
+
export declare function createAegisSwapChainsFromBackendConfig(config: AegisBackendConfig, hostChains?: Partial<Record<number, AegisSwapChainConfigInput>>, options?: AegisBackendChainOptions): Record<number, AegisSwapChainConfig>;
|
|
34
|
+
export declare function createAegisSwapPoolsFromBackendMarkets({ config, markets, tokens, enabledOnly, onSkip }: {
|
|
35
|
+
config: AegisBackendConfig;
|
|
36
|
+
markets: readonly AegisBackendMarket[];
|
|
37
|
+
tokens: readonly AegisBackendToken[];
|
|
38
|
+
enabledOnly?: boolean;
|
|
39
|
+
/** Structured diagnostics for every market the adapter drops. */
|
|
40
|
+
onSkip?: AegisBackendAdapterSkipHandler;
|
|
41
|
+
}): AegisSwapPoolConfig[];
|
package/dist/config/chains.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Hex } from 'viem';
|
|
2
|
-
import type { AegisSwapChainConfig, AegisSwapChainConfigInput } from './types';
|
|
2
|
+
import type { AegisSwapChainConfig, AegisSwapChainConfigInput } from './types.js';
|
|
3
3
|
export declare function getExplorerUrl(hash: Hex, chain: AegisSwapChainConfig): string;
|
|
4
4
|
export declare const AEGIS_SWAP_MAINNET_CHAIN: AegisSwapChainConfig;
|
|
5
5
|
export declare const AEGIS_SWAP_CHAINS: Record<number, AegisSwapChainConfig>;
|
|
@@ -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];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AegisSwapUniswapV4Contracts, AegisSwapUniswapV4ContractsInput } from './types';
|
|
1
|
+
import type { AegisSwapUniswapV4Contracts, AegisSwapUniswapV4ContractsInput } from './types.js';
|
|
2
2
|
export declare function createAegisSwapUniswapV4Contracts(input: AegisSwapUniswapV4ContractsInput): AegisSwapUniswapV4Contracts;
|
|
3
3
|
export declare const UNISWAP_V4_CONTRACTS_BY_CHAIN: Record<number, AegisSwapUniswapV4Contracts>;
|
|
4
4
|
export declare const AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS: AegisSwapUniswapV4Contracts;
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,6 +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';
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './constants.js';
|
|
3
|
+
export * from './contracts.js';
|
|
4
|
+
export * from './chains.js';
|
|
5
|
+
export * from './tokens.js';
|
|
6
|
+
export * from './markets.js';
|
package/dist/config/markets.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AegisSwapChainConfig, AegisSwapMarket, AegisSwapPoolConfig } from './types';
|
|
1
|
+
import type { AegisSwapChainConfig, AegisSwapMarket, AegisSwapPoolConfig } from './types.js';
|
|
2
2
|
export declare function createAegisSwapPoolMarket(input: AegisSwapPoolConfig, chains?: Record<number, AegisSwapChainConfig>): AegisSwapMarket;
|
|
3
3
|
export declare function createAegisSwapMarketsFromPools(pools: AegisSwapPoolConfig[] | undefined, chains?: Record<number, AegisSwapChainConfig>): Record<string, AegisSwapMarket>;
|
package/dist/config/tokens.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AegisSwapBuiltInTokenSymbol, AegisSwapToken, AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken, AggregatedSwapWolfGameTokenSymbol } from './types';
|
|
1
|
+
import type { AegisSwapBuiltInTokenSymbol, AegisSwapToken, AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken, AggregatedSwapWolfGameTokenSymbol } from './types.js';
|
|
2
2
|
export declare const AEGIS_SWAP_TOKENS: Record<AegisSwapBuiltInTokenSymbol, AegisSwapToken>;
|
|
3
3
|
export declare const AGGREGATED_SWAP_DEFAULT_TOKENS: Record<AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken>;
|
|
4
4
|
export declare const AGGREGATED_SWAP_WOLFGAME_TOKENS: Record<AggregatedSwapWolfGameTokenSymbol, AggregatedSwapToken>;
|
package/dist/config/types.d.ts
CHANGED
|
@@ -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;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { Address, Hex } from 'viem';
|
|
3
|
+
import type { AegisPoolKey } from '../config/index.js';
|
|
4
|
+
import { aegisBackendSwapQuoteRequestSchema } from './schemas.js';
|
|
5
|
+
import type { components, paths } from './generated/aegis-swap.js';
|
|
6
|
+
export type AegisBackendOpenApiPaths = paths;
|
|
7
|
+
export type AegisBackendOpenApiComponents = components;
|
|
8
|
+
type AegisBackendWireConfig = components['schemas']['SwapConfig'];
|
|
9
|
+
type AegisBackendWireToken = components['schemas']['Token'];
|
|
10
|
+
type AegisBackendWireMarket = components['schemas']['Market'];
|
|
11
|
+
type AegisBackendWireSwapQuoteRequest = components['schemas']['SwapQuoteRequest'];
|
|
12
|
+
type AegisBackendWireSwapQuoteResponse = components['schemas']['SwapQuoteResponse'];
|
|
13
|
+
export type AegisBackendSwapProvider = AegisBackendWireConfig['providers'][number];
|
|
14
|
+
export type AegisBackendQuoteMode = AegisBackendWireSwapQuoteRequest['mode'];
|
|
15
|
+
export type AegisBackendMarketStatus = AegisBackendWireMarket['status'];
|
|
16
|
+
export declare const AEGIS_BACKEND_PROD_BASE_URL = "https://nlkvpvkx9h.execute-api.us-east-1.amazonaws.com/prod";
|
|
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
|
+
};
|
|
23
|
+
export type AegisBackendContractRegistry = {
|
|
24
|
+
aegisRouter?: Address;
|
|
25
|
+
permit2?: Address;
|
|
26
|
+
v4Quoter?: Address;
|
|
27
|
+
v4PoolManager?: Address;
|
|
28
|
+
[contractName: string]: Address | undefined;
|
|
29
|
+
};
|
|
30
|
+
export type AegisBackendAddressAllowlist = {
|
|
31
|
+
routers: Address[];
|
|
32
|
+
spenders: Address[];
|
|
33
|
+
};
|
|
34
|
+
export type AegisBackendContractsByChain = {
|
|
35
|
+
[ChainId in keyof AegisBackendWireConfig['contracts']]: AegisBackendContractRegistry;
|
|
36
|
+
};
|
|
37
|
+
export type AegisBackendAllowlistsByChain = {
|
|
38
|
+
[ChainId in keyof AegisBackendWireConfig['allowlists']]: AegisBackendAddressAllowlist;
|
|
39
|
+
};
|
|
40
|
+
export type AegisBackendFeeConfig = Omit<AegisBackendWireConfig['fee'], 'recipient' | 'outputFeeBps'> & {
|
|
41
|
+
recipient: Address;
|
|
42
|
+
outputFeeBps: number;
|
|
43
|
+
};
|
|
44
|
+
export type AegisBackendConfig = Omit<AegisBackendWireConfig, 'chains' | 'quote' | 'contracts' | 'allowlists' | 'fee'> & {
|
|
45
|
+
chains: AegisBackendChain[];
|
|
46
|
+
quote: AegisBackendQuoteDefaults;
|
|
47
|
+
contracts: AegisBackendContractsByChain;
|
|
48
|
+
allowlists: AegisBackendAllowlistsByChain;
|
|
49
|
+
fee: AegisBackendFeeConfig;
|
|
50
|
+
};
|
|
51
|
+
export type AegisBackendToken = Omit<AegisBackendWireToken, 'address' | 'chainId'> & {
|
|
52
|
+
address: Address;
|
|
53
|
+
chainId: number;
|
|
54
|
+
};
|
|
55
|
+
export type AegisBackendMarketMetrics = AegisBackendWireMarket['metrics'];
|
|
56
|
+
export type AegisBackendMarket = Omit<AegisBackendWireMarket, 'baseToken' | 'quoteToken' | 'poolId' | 'poolKey' | 'chainId'> & {
|
|
57
|
+
baseToken: Address;
|
|
58
|
+
quoteToken: Address;
|
|
59
|
+
poolId: Hex;
|
|
60
|
+
poolKey: AegisPoolKey;
|
|
61
|
+
chainId: number;
|
|
62
|
+
};
|
|
63
|
+
export type AegisBackendSwapQuoteRequest = z.infer<typeof aegisBackendSwapQuoteRequestSchema>;
|
|
64
|
+
export type AegisBackendSwapQuoteResponse = Omit<AegisBackendWireSwapQuoteResponse, 'tokenIn' | 'tokenOut' | 'fee'> & {
|
|
65
|
+
tokenIn: Address;
|
|
66
|
+
tokenOut: Address;
|
|
67
|
+
fee: AegisBackendFeeConfig;
|
|
68
|
+
};
|
|
69
|
+
export type AegisBackendApiClientOptions = {
|
|
70
|
+
baseUrl: string;
|
|
71
|
+
fetch?: typeof fetch;
|
|
72
|
+
headers?: Record<string, string>;
|
|
73
|
+
validate?: boolean;
|
|
74
|
+
};
|
|
75
|
+
export type AegisBackendRequestOptions = {
|
|
76
|
+
signal?: AbortSignal;
|
|
77
|
+
headers?: Record<string, string>;
|
|
78
|
+
timeoutMs?: number;
|
|
79
|
+
};
|
|
80
|
+
export declare class AegisBackendApiError extends Error {
|
|
81
|
+
readonly status: number;
|
|
82
|
+
readonly statusText: string;
|
|
83
|
+
readonly body: unknown;
|
|
84
|
+
constructor({ status, statusText, body }: {
|
|
85
|
+
status: number;
|
|
86
|
+
statusText: string;
|
|
87
|
+
body: unknown;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export declare class AegisBackendContractError extends Error {
|
|
91
|
+
readonly endpoint: string;
|
|
92
|
+
readonly issues: z.core.$ZodIssue[];
|
|
93
|
+
constructor({ endpoint, issues }: {
|
|
94
|
+
endpoint: string;
|
|
95
|
+
issues: z.core.$ZodIssue[];
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
export declare function isRetryableAegisBackendApiError(error: unknown): boolean;
|
|
99
|
+
export type AegisBackendApiClient = {
|
|
100
|
+
health: (options?: AegisBackendRequestOptions) => Promise<{
|
|
101
|
+
ok: boolean;
|
|
102
|
+
}>;
|
|
103
|
+
config: (options?: AegisBackendRequestOptions) => Promise<AegisBackendConfig>;
|
|
104
|
+
tokens: (args: {
|
|
105
|
+
chainId: number;
|
|
106
|
+
}, options?: AegisBackendRequestOptions) => Promise<AegisBackendToken[]>;
|
|
107
|
+
tokensByAddress: (args: {
|
|
108
|
+
chainId: number;
|
|
109
|
+
addresses: Address[];
|
|
110
|
+
}, options?: AegisBackendRequestOptions) => Promise<AegisBackendToken[]>;
|
|
111
|
+
markets: (args: {
|
|
112
|
+
chainId: number;
|
|
113
|
+
}, options?: AegisBackendRequestOptions) => Promise<AegisBackendMarket[]>;
|
|
114
|
+
quote: (args: AegisBackendSwapQuoteRequest, options?: AegisBackendRequestOptions) => Promise<AegisBackendSwapQuoteResponse>;
|
|
115
|
+
};
|
|
116
|
+
export declare function normalizeAegisBackendBaseUrl(baseUrl: string): string;
|
|
117
|
+
export declare function createAegisBackendApiClient(options: AegisBackendApiClientOptions): AegisBackendApiClient;
|
|
118
|
+
export {};
|