@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.
- package/README.md +109 -4
- package/THIRD_PARTY_NOTICES.md +211 -0
- package/dist/actions/kyberSwap.d.ts +3 -2
- package/dist/address.d.ts +3 -1
- package/dist/aegis-core.js +8421 -5279
- package/dist/backendAdapters.d.ts +25 -1
- package/dist/config/constants.d.ts +4 -0
- package/dist/config/types.d.ts +5 -0
- package/dist/contract/backendClient.d.ts +16 -6
- package/dist/contract/generated/aegis-swap.d.ts +2682 -96
- package/dist/contract/schemas.d.ts +27 -20
- 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 +13 -8
- package/dist/internal/requestSignal.d.ts +9 -0
- package/dist/internal/ttlCache.d.ts +19 -0
- package/dist/metadata.d.ts +4 -0
- package/dist/permit.d.ts +1 -0
- package/dist/quote/aggregatedSwapQuote.d.ts +12 -0
- package/dist/quote/kyberCalldata.d.ts +211 -0
- package/dist/quote.d.ts +1 -0
- package/dist/sdkRuntime-CCRVvSwD.js +16052 -0
- package/dist/services/kyberSwap.d.ts +22 -2
- package/dist/swap/receiptWait.d.ts +17 -0
- package/dist/swap/sendSwapTransaction.d.ts +40 -6
- package/dist/swap/settlement.d.ts +15 -0
- package/dist/transactionProgress.d.ts +8 -1
- package/dist/types/aggregatedSwap.d.ts +18 -0
- package/package.json +15 -7
package/dist/errors.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
export declare class UserFacingError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class TransactionReceiptTimeoutError extends UserFacingError {
|
|
6
|
+
readonly hash: Hex;
|
|
7
|
+
constructor({ hash }: {
|
|
8
|
+
hash: Hex;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
1
11
|
export declare function isUserRejectedError(error: unknown): boolean;
|
|
2
12
|
export declare const USER_REJECTED_MESSAGE = "Request rejected.";
|
|
3
13
|
export declare function errorMessage(error: unknown, fallbackMessage: string): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export type AegisTokenPriceHistoryWindow = '7d' | '30d' | '90d' | '180d';
|
|
4
|
+
export type AegisTokenPriceHistoryStatus = 'ready' | 'warming_up' | 'no_data';
|
|
5
|
+
export type AegisTokenPricePoint = {
|
|
6
|
+
/** Unix timestamp in seconds. */
|
|
7
|
+
timestamp: number;
|
|
8
|
+
/** USD price observed at this timestamp. */
|
|
9
|
+
priceUsd: number;
|
|
10
|
+
};
|
|
11
|
+
export type AegisTokenPriceHistory = {
|
|
12
|
+
networkType: 'evm';
|
|
13
|
+
chainId: number;
|
|
14
|
+
/** Caller-facing address. Native-token sentinels are retained here. */
|
|
15
|
+
tokenAddress: Address;
|
|
16
|
+
symbol: string | null;
|
|
17
|
+
resolution: '12h';
|
|
18
|
+
window: AegisTokenPriceHistoryWindow;
|
|
19
|
+
status: AegisTokenPriceHistoryStatus;
|
|
20
|
+
points: AegisTokenPricePoint[];
|
|
21
|
+
pointCount: number;
|
|
22
|
+
updatedAt: string | null;
|
|
23
|
+
};
|
|
24
|
+
export declare const tokenPriceHistoryRestResponseSchema: z.ZodObject<{
|
|
25
|
+
chainId: z.ZodNumber;
|
|
26
|
+
address: z.ZodString;
|
|
27
|
+
symbol: z.ZodNullable<z.ZodString>;
|
|
28
|
+
resolution: z.ZodLiteral<"12h">;
|
|
29
|
+
window: z.ZodEnum<{
|
|
30
|
+
"7d": "7d";
|
|
31
|
+
"30d": "30d";
|
|
32
|
+
"90d": "90d";
|
|
33
|
+
"180d": "180d";
|
|
34
|
+
}>;
|
|
35
|
+
status: z.ZodEnum<{
|
|
36
|
+
ready: "ready";
|
|
37
|
+
warming_up: "warming_up";
|
|
38
|
+
no_data: "no_data";
|
|
39
|
+
}>;
|
|
40
|
+
points: z.ZodArray<z.ZodObject<{
|
|
41
|
+
t: z.ZodNumber;
|
|
42
|
+
p: z.ZodNumber;
|
|
43
|
+
}, z.core.$strict>>;
|
|
44
|
+
pointCount: z.ZodNumber;
|
|
45
|
+
updatedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
46
|
+
}, z.core.$strict>;
|
|
47
|
+
export declare function clearTokenPriceHistoryCache(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Synchronous view of the shared TTL cache: the settled, unexpired history the
|
|
50
|
+
* same-argument {@link fetchTokenPriceHistory} would resolve from cache, else
|
|
51
|
+
* null. Lets a render seed itself in the same commit instead of waiting a
|
|
52
|
+
* microtask for the cached promise to replay.
|
|
53
|
+
*/
|
|
54
|
+
export declare function peekTokenPriceHistory(args: {
|
|
55
|
+
baseUrl: string;
|
|
56
|
+
chainId: number;
|
|
57
|
+
tokenAddress: Address;
|
|
58
|
+
window?: AegisTokenPriceHistoryWindow;
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
}): AegisTokenPriceHistory | null;
|
|
61
|
+
/**
|
|
62
|
+
* Fetches one token's display-only USD history from the public REST backend.
|
|
63
|
+
* Native-token sentinels are looked up under the zero address used by the
|
|
64
|
+
* writer, while the returned domain object retains the caller's token address.
|
|
65
|
+
* Concurrent callers join one shared in-flight load per cache key, so the
|
|
66
|
+
* consumer's signal wraps the shared promise instead of cancelling the fetch
|
|
67
|
+
* for other consumers.
|
|
68
|
+
*/
|
|
69
|
+
export declare function fetchTokenPriceHistory(args: {
|
|
70
|
+
baseUrl: string;
|
|
71
|
+
chainId: number;
|
|
72
|
+
tokenAddress: Address;
|
|
73
|
+
window?: AegisTokenPriceHistoryWindow;
|
|
74
|
+
headers?: Record<string, string>;
|
|
75
|
+
signal?: AbortSignal;
|
|
76
|
+
/** Abort after this many ms (composes with `signal`); defaults to 15s. */
|
|
77
|
+
timeoutMs?: number;
|
|
78
|
+
}): Promise<AegisTokenPriceHistory | null>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
export { AEGIS_DYNAMIC_FEE_FLAG, AEGIS_SWAP_CHAINS, AEGIS_SWAP_CHAIN_ID, AEGIS_SWAP_DEFAULT_FEE_BPS, AEGIS_SWAP_DEFAULT_FEE_RECIPIENT, AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT, AEGIS_SWAP_DEFAULT_RPC_URLS, AEGIS_SWAP_HOOK, AEGIS_SWAP_MAINNET_CHAIN, AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS, AEGIS_SWAP_PERMIT2, AEGIS_SWAP_ROUTER, AEGIS_SWAP_TOKENS, AEGIS_SWAP_V4_QUOTER, AGGREGATED_SWAP_CURATED_TOKENS, AGGREGATED_SWAP_DEFAULT_TOKEN_LIST, AGGREGATED_SWAP_DEFAULT_TOKENS, AGGREGATED_SWAP_TOKEN_PRESETS, AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST, AGGREGATED_SWAP_WOLFGAME_TOKENS, UNISWAP_V4_CONTRACTS_BY_CHAIN, createAegisSwapChainConfig, createAegisSwapChains, createAegisSwapMarketsFromPools, createAegisSwapPoolMarket, createAegisSwapUniswapV4Contracts, getExplorerUrl } from './config/index.js';
|
|
1
|
+
export { AEGIS_DYNAMIC_FEE_FLAG, AEGIS_SWAP_CHAINS, AEGIS_SWAP_CHAIN_ID, AEGIS_SWAP_DEFAULT_FEE_BPS, AEGIS_SWAP_DEFAULT_FEE_RECIPIENT, AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT, AEGIS_SWAP_DEFAULT_RPC_URLS, AEGIS_SWAP_HOOK, AEGIS_SWAP_MAINNET_CHAIN, AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS, AEGIS_SWAP_PERMIT2, AEGIS_SWAP_ROUTER, AEGIS_SWAP_TOKENS, AEGIS_SWAP_TRUSTED_ROUTERS_BY_CHAIN, AEGIS_SWAP_V4_QUOTER, AGGREGATED_SWAP_CURATED_TOKENS, AGGREGATED_SWAP_DEFAULT_TOKEN_LIST, AGGREGATED_SWAP_DEFAULT_TOKENS, AGGREGATED_SWAP_SUPPORTED_CHAIN_IDS, AGGREGATED_SWAP_TOKEN_PRESETS, AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST, AGGREGATED_SWAP_WOLFGAME_TOKENS, UNISWAP_V4_CONTRACTS_BY_CHAIN, createAegisSwapChainConfig, createAegisSwapChains, createAegisSwapMarketsFromPools, createAegisSwapPoolMarket, createAegisSwapUniswapV4Contracts, getExplorerUrl } from './config/index.js';
|
|
2
2
|
export type { AegisPoolKey, AegisSwapBuiltInTokenSymbol, AegisSwapChainConfig, AegisSwapChainConfigInput, AegisSwapFeeConfig, AegisSwapMarket, AegisSwapPoolConfig, AegisSwapToken, AegisSwapTokenSymbol, AegisSwapUniswapV4Contracts, AegisSwapUniswapV4ContractsInput, AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken, AggregatedSwapTokenSymbol, AggregatedSwapWolfGameTokenSymbol } from './config/index.js';
|
|
3
3
|
export { assertUint128, buildExactInSwapTransaction, buildExactOutSwapTransaction, computePoolId, MAX_UINT128 } from './encoding.js';
|
|
4
4
|
export type { BuiltSwapTransaction, ExecutionBatch, PermitBatch, PermitDetails, SignedPermitBatch, SwapOutputFee } from './encoding.js';
|
|
5
5
|
export { getZeroForOne, outputFeeForQuote, quoteSpendAmount, reconcileSubmitQuote, sameQuote } from './quote.js';
|
|
6
6
|
export type { DirectSwapQuote, ReconciledSubmitQuote, SwapQuoteMode } from './quote.js';
|
|
7
|
-
export { aggregatedSwapErrorMessage, fetchAggregatedSwapQuote } from './quote/aggregatedSwapQuote.js';
|
|
7
|
+
export { AggregatedSwapBuildMismatchError, aggregatedSwapErrorMessage, fetchAggregatedSwapQuote } from './quote/aggregatedSwapQuote.js';
|
|
8
|
+
export { AggregatedSwapCalldataError } from './quote/kyberCalldata.js';
|
|
8
9
|
export type { AggregatedSwapQuote, AggregatedSwapRoute, HopInfo } from './types/aggregatedSwap.js';
|
|
9
|
-
export { KyberSwapApiError, buildKyberSwapRoute, fetchKyberSwapRoute, isRetryableKyberSwapError } from './services/kyberSwap.js';
|
|
10
|
+
export { KyberSwapApiError, KyberSwapContractError, buildKyberSwapRoute, fetchKyberSwapRoute, isRetryableKyberSwapError } from './services/kyberSwap.js';
|
|
10
11
|
export type { KyberSwapBuild, KyberSwapError, KyberSwapFeeParams, KyberSwapRoute, KyberSwapRouteLeg, KyberSwapRouteSummary } from './services/kyberSwap.js';
|
|
11
12
|
export { approveErc20Spender, approveErc20ToPermit2, approvePermit2ToRouter, buildSignedPermitBatch, DEFAULT_PERMIT_EXPIRATION_SECONDS, MAX_UINT160, MAX_UINT256, PERMIT2_FAR_FUTURE_EXPIRATION, readErc20Allowance, readPermit2RouterAllowance, SWAP_TX_DEADLINE_SECONDS } from './permit.js';
|
|
12
|
-
export { fetchGlobalTokenMetadata,
|
|
13
|
+
export { fetchGlobalTokenMetadata, resolveTokenIconUrl } from './metadata.js';
|
|
13
14
|
export type { AegisSwapGlobalTokenMetadata, TokenMetadataByAddress } from './metadata.js';
|
|
15
|
+
export { clearTokenPriceHistoryCache, fetchTokenPriceHistory, peekTokenPriceHistory } from './historicalPrices.js';
|
|
16
|
+
export type { AegisTokenPriceHistory, AegisTokenPriceHistoryStatus, AegisTokenPriceHistoryWindow, AegisTokenPricePoint } from './historicalPrices.js';
|
|
14
17
|
export { createSwapPublicClient, getInjectedProvider, getProviderAccount, getProviderChainId, isEip1193Provider, normalizeAccount, normalizeWalletConnection, requestProviderAccount, subscribeProvider, switchProviderChain } from './wallet.js';
|
|
15
18
|
export type { AegisSwapProviderResolver, AegisSwapWalletConnection, Eip1193Provider, ProviderChainConfig } from './wallet.js';
|
|
16
19
|
export { approveDirectPoolSwapInput, DirectPoolSwapPriceMovedError, executeDirectPoolSwap, fetchDirectPoolSwapQuote } from './actions/directPoolSwap.js';
|
|
17
20
|
export type { DirectPoolSwapApprovalResult } from './actions/directPoolSwap.js';
|
|
21
|
+
export { isNativeAssetAddress } from './address.js';
|
|
18
22
|
export { approveKyberSwapInput, executeKyberSwap, isNativeToken, KyberSwapPriceMovedError, NATIVE_TOKEN_ADDRESS } from './actions/kyberSwap.js';
|
|
19
23
|
export type { KyberSwapApprovalResult } from './actions/kyberSwap.js';
|
|
20
24
|
export { ensureWalletChain, resolveWalletSession, waitForProviderChain } from './actions/wallet.js';
|
|
@@ -22,13 +26,14 @@ export type { AegisSwapActionCallbacks, AegisSwapActionResult } from './actions/
|
|
|
22
26
|
export { estimateSwapGasWithBuffer } from './swap/gas.js';
|
|
23
27
|
export type { SwapGasRequest } from './swap/gas.js';
|
|
24
28
|
export type { AegisSwapApprovalMode, AegisSwapSubmitDetails, WalletSession } from './swap/types.js';
|
|
25
|
-
export { errorMessage, isUserRejectedError } from './errors.js';
|
|
29
|
+
export { errorMessage, isUserRejectedError, TransactionReceiptTimeoutError, UserFacingError } from './errors.js';
|
|
26
30
|
export { isBusy, transactionProgressView } from './transactionProgress.js';
|
|
27
31
|
export type { AegisSwapReceiptSummary, AegisSwapStatusSnapshot, AegisSwapWalletPromptProgress, SubmitStatus, TransactionProgressState, TransactionProgressView } from './transactionProgress.js';
|
|
28
32
|
export { isDocumentVisible, pollUntil, retryOnError } from './polling.js';
|
|
29
|
-
export { AEGIS_BACKEND_PROD_BASE_URL, AegisBackendApiError, AegisBackendContractError, createAegisBackendApiClient, isRetryableAegisBackendApiError } from './contract/backendClient.js';
|
|
30
|
-
export type { AegisBackendAddressAllowlist, AegisBackendAllowlistsByChain, AegisBackendApiClient, AegisBackendApiClientOptions, AegisBackendChain, AegisBackendConfig, AegisBackendContractRegistry, AegisBackendContractsByChain, AegisBackendFeeConfig, AegisBackendMarket, AegisBackendMarketMetrics, AegisBackendMarketStatus, AegisBackendQuoteDefaults, AegisBackendQuoteMode, AegisBackendRequestOptions, AegisBackendSwapProvider, AegisBackendSwapQuoteRequest, AegisBackendSwapQuoteResponse, AegisBackendToken } from './contract/backendClient.js';
|
|
33
|
+
export { AEGIS_BACKEND_PROD_BASE_URL, AegisBackendApiError, AegisBackendContractError, createAegisBackendApiClient, isRetryableAegisBackendApiError, normalizeAegisBackendBaseUrl } from './contract/backendClient.js';
|
|
34
|
+
export type { AegisBackendAddressAllowlist, AegisBackendAllowlistsByChain, AegisBackendApiClient, AegisBackendApiClientOptions, AegisBackendChain, AegisBackendConfig, AegisBackendContractRegistry, AegisBackendContractsByChain, AegisBackendFeeConfig, AegisBackendMarket, AegisBackendMarketMetrics, AegisBackendMarketStatus, AegisBackendOpenApiComponents, AegisBackendOpenApiPaths, AegisBackendQuoteDefaults, AegisBackendQuoteMode, AegisBackendRequestOptions, AegisBackendSwapProvider, AegisBackendSwapQuoteRequest, AegisBackendSwapQuoteResponse, AegisBackendToken } from './contract/backendClient.js';
|
|
31
35
|
export { backendTokenToAegisSwapToken, backendTokensToAegisSwapTokens, createAegisSwapChainsFromBackendConfig, createAegisSwapPoolsFromBackendMarkets } from './backendAdapters.js';
|
|
32
|
-
export type { AegisBackendChainOptions } from './backendAdapters.js';
|
|
36
|
+
export type { AegisBackendAdapterSkip, AegisBackendAdapterSkipHandler, AegisBackendChainOptions } from './backendAdapters.js';
|
|
33
37
|
export { aegisBackendAddressAllowlistSchema, aegisBackendAddressSchema, aegisBackendAllowlistsByChainSchema, aegisBackendChainSchema, aegisBackendChainIdSchema, aegisBackendConfigSchema, aegisBackendContractsByChainSchema, aegisBackendContractRegistrySchema, aegisBackendDecimalStringSchema, aegisBackendFeeConfigSchema, aegisBackendHealthResponseSchema, aegisBackendHexSchema, aegisBackendIsoDateTimeSchema, aegisBackendMarketMetricsSchema, aegisBackendMarketSchema, aegisBackendMarketStatusSchema, aegisBackendMarketsResponseSchema, aegisBackendQuoteDefaultsSchema, aegisBackendQuoteModeSchema, aegisBackendSwapProviderSchema, aegisBackendSwapQuoteRequestSchema, aegisBackendSwapQuoteResponseSchema, aegisBackendTokenSchema, aegisBackendTokensResponseSchema, aegisPoolKeySchema, AegisContractGuardError, assertCalldataHash, assertChainMatches, assertQuoteFresh, assertRouterAllowlisted, assertSpenderAllowlisted } from './contract/index.js';
|
|
34
38
|
export type { AegisContractGuardCode } from './contract/index.js';
|
|
39
|
+
export * from './engine/index.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type TtlPromiseCache<T> = {
|
|
2
|
+
read(key: string, load: () => Promise<T>, force?: boolean): Promise<T>;
|
|
3
|
+
/** Resolved value of a settled, unexpired entry — the synchronous view a
|
|
4
|
+
* render can use without waiting a microtask for the cached promise. */
|
|
5
|
+
peek(key: string): T | undefined;
|
|
6
|
+
clear(): void;
|
|
7
|
+
};
|
|
8
|
+
export declare function createTtlPromiseCache<T>(config: {
|
|
9
|
+
ttlMs: number;
|
|
10
|
+
/** Oldest-first eviction bound; omit for an unbounded cache. */
|
|
11
|
+
maxEntries?: number;
|
|
12
|
+
}): TtlPromiseCache<T>;
|
|
13
|
+
/** Canonical cache-key serialization for optional request headers. */
|
|
14
|
+
export declare function stableHeadersKey(headers?: Record<string, string>): string;
|
|
15
|
+
/**
|
|
16
|
+
* Wraps a shared in-flight promise for one consumer: an abort rejects only
|
|
17
|
+
* that consumer's view, never the underlying load other consumers still join.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withAbort<T>(promise: Promise<T>, signal: AbortSignal | undefined, abortMessage: string): Promise<T>;
|
package/dist/metadata.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type AegisSwapGlobalTokenMetadata = {
|
|
|
8
8
|
fullName: string | null;
|
|
9
9
|
decimals: number | null;
|
|
10
10
|
iconURL: string | null;
|
|
11
|
+
/** USD price the metadata service tracks; lets consumers refresh stale priceUsd. */
|
|
12
|
+
price?: number | null;
|
|
11
13
|
};
|
|
12
14
|
export declare function getIchiIconGuess(symbol: string | null | undefined): string | null;
|
|
13
15
|
export type TokenMetadataByAddress = Record<string, AegisSwapGlobalTokenMetadata>;
|
|
@@ -22,4 +24,6 @@ export declare function fetchGlobalTokenMetadata(args: {
|
|
|
22
24
|
chainId: number;
|
|
23
25
|
addresses: Address[];
|
|
24
26
|
signal?: AbortSignal;
|
|
27
|
+
/** Abort after this many ms (composes with `signal`); defaults to 15s. */
|
|
28
|
+
timeoutMs?: number;
|
|
25
29
|
}): Promise<Map<string, AegisSwapGlobalTokenMetadata>>;
|
package/dist/permit.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export declare function readPermit2RouterAllowance(args: {
|
|
|
48
48
|
token: Address;
|
|
49
49
|
router: Address;
|
|
50
50
|
}): Promise<readonly [amount: bigint, expiration: number, nonce: number]>;
|
|
51
|
+
export declare function hasUsablePermit2Allowance(allowance: Awaited<ReturnType<typeof readPermit2RouterAllowance>>, amount: bigint): boolean;
|
|
51
52
|
export declare function buildSignedPermitBatch(args: {
|
|
52
53
|
provider: Eip1193Provider;
|
|
53
54
|
publicClient: PublicClient;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { type Address, type PublicClient } from 'viem';
|
|
2
2
|
import { type AegisSwapToken } from '../config/index.js';
|
|
3
|
+
import { UserFacingError } from '../errors.js';
|
|
3
4
|
import type { AggregatedSwapQuote } from '../types/aggregatedSwap.js';
|
|
4
5
|
export declare function aggregatedSwapErrorMessage(error: unknown, fallbackMessage: string): string;
|
|
6
|
+
export declare class AggregatedSwapBuildMismatchError extends UserFacingError {
|
|
7
|
+
readonly field: 'amountIn' | 'amountOut';
|
|
8
|
+
readonly expected: bigint;
|
|
9
|
+
readonly actual: bigint;
|
|
10
|
+
constructor({ field, expected, actual }: {
|
|
11
|
+
field: 'amountIn' | 'amountOut';
|
|
12
|
+
expected: bigint;
|
|
13
|
+
actual: bigint;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export declare function assertAggregatedRouterTrusted(router: Address, chainId: number): void;
|
|
5
17
|
export declare function fetchAggregatedSwapQuote(inputToken: AegisSwapToken, outputToken: AegisSwapToken, amount: bigint, slippageBps: number, mode?: 'exactIn' | 'exactOut', account?: Address | null, signal?: AbortSignal, _publicClient?: PublicClient): Promise<AggregatedSwapQuote>;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
import { UserFacingError } from '../errors.js';
|
|
3
|
+
export declare const KYBER_META_AGGREGATION_ROUTER_V2_ABI: readonly [{
|
|
4
|
+
readonly type: "function";
|
|
5
|
+
readonly name: "swap";
|
|
6
|
+
readonly stateMutability: "payable";
|
|
7
|
+
readonly inputs: readonly [{
|
|
8
|
+
readonly name: "execution";
|
|
9
|
+
readonly type: "tuple";
|
|
10
|
+
readonly components: readonly [{
|
|
11
|
+
readonly name: "callTarget";
|
|
12
|
+
readonly type: "address";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "approveTarget";
|
|
15
|
+
readonly type: "address";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "targetData";
|
|
18
|
+
readonly type: "bytes";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "desc";
|
|
21
|
+
readonly type: "tuple";
|
|
22
|
+
readonly components: readonly [{
|
|
23
|
+
readonly name: "srcToken";
|
|
24
|
+
readonly type: "address";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "dstToken";
|
|
27
|
+
readonly type: "address";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "srcReceivers";
|
|
30
|
+
readonly type: "address[]";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "srcAmounts";
|
|
33
|
+
readonly type: "uint256[]";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "feeReceivers";
|
|
36
|
+
readonly type: "address[]";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "feeAmounts";
|
|
39
|
+
readonly type: "uint256[]";
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: "dstReceiver";
|
|
42
|
+
readonly type: "address";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "amount";
|
|
45
|
+
readonly type: "uint256";
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "minReturnAmount";
|
|
48
|
+
readonly type: "uint256";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "flags";
|
|
51
|
+
readonly type: "uint256";
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "permit";
|
|
54
|
+
readonly type: "bytes";
|
|
55
|
+
}];
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "clientData";
|
|
58
|
+
readonly type: "bytes";
|
|
59
|
+
}];
|
|
60
|
+
}];
|
|
61
|
+
readonly outputs: readonly [{
|
|
62
|
+
readonly name: "returnAmount";
|
|
63
|
+
readonly type: "uint256";
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "gasUsed";
|
|
66
|
+
readonly type: "uint256";
|
|
67
|
+
}];
|
|
68
|
+
}, {
|
|
69
|
+
readonly type: "function";
|
|
70
|
+
readonly name: "swapGeneric";
|
|
71
|
+
readonly stateMutability: "payable";
|
|
72
|
+
readonly inputs: readonly [{
|
|
73
|
+
readonly name: "execution";
|
|
74
|
+
readonly type: "tuple";
|
|
75
|
+
readonly components: readonly [{
|
|
76
|
+
readonly name: "callTarget";
|
|
77
|
+
readonly type: "address";
|
|
78
|
+
}, {
|
|
79
|
+
readonly name: "approveTarget";
|
|
80
|
+
readonly type: "address";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "targetData";
|
|
83
|
+
readonly type: "bytes";
|
|
84
|
+
}, {
|
|
85
|
+
readonly name: "desc";
|
|
86
|
+
readonly type: "tuple";
|
|
87
|
+
readonly components: readonly [{
|
|
88
|
+
readonly name: "srcToken";
|
|
89
|
+
readonly type: "address";
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "dstToken";
|
|
92
|
+
readonly type: "address";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "srcReceivers";
|
|
95
|
+
readonly type: "address[]";
|
|
96
|
+
}, {
|
|
97
|
+
readonly name: "srcAmounts";
|
|
98
|
+
readonly type: "uint256[]";
|
|
99
|
+
}, {
|
|
100
|
+
readonly name: "feeReceivers";
|
|
101
|
+
readonly type: "address[]";
|
|
102
|
+
}, {
|
|
103
|
+
readonly name: "feeAmounts";
|
|
104
|
+
readonly type: "uint256[]";
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "dstReceiver";
|
|
107
|
+
readonly type: "address";
|
|
108
|
+
}, {
|
|
109
|
+
readonly name: "amount";
|
|
110
|
+
readonly type: "uint256";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "minReturnAmount";
|
|
113
|
+
readonly type: "uint256";
|
|
114
|
+
}, {
|
|
115
|
+
readonly name: "flags";
|
|
116
|
+
readonly type: "uint256";
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "permit";
|
|
119
|
+
readonly type: "bytes";
|
|
120
|
+
}];
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: "clientData";
|
|
123
|
+
readonly type: "bytes";
|
|
124
|
+
}];
|
|
125
|
+
}];
|
|
126
|
+
readonly outputs: readonly [{
|
|
127
|
+
readonly name: "returnAmount";
|
|
128
|
+
readonly type: "uint256";
|
|
129
|
+
}, {
|
|
130
|
+
readonly name: "gasUsed";
|
|
131
|
+
readonly type: "uint256";
|
|
132
|
+
}];
|
|
133
|
+
}, {
|
|
134
|
+
readonly type: "function";
|
|
135
|
+
readonly name: "swapSimpleMode";
|
|
136
|
+
readonly stateMutability: "nonpayable";
|
|
137
|
+
readonly inputs: readonly [{
|
|
138
|
+
readonly name: "caller";
|
|
139
|
+
readonly type: "address";
|
|
140
|
+
}, {
|
|
141
|
+
readonly name: "desc";
|
|
142
|
+
readonly type: "tuple";
|
|
143
|
+
readonly components: readonly [{
|
|
144
|
+
readonly name: "srcToken";
|
|
145
|
+
readonly type: "address";
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "dstToken";
|
|
148
|
+
readonly type: "address";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "srcReceivers";
|
|
151
|
+
readonly type: "address[]";
|
|
152
|
+
}, {
|
|
153
|
+
readonly name: "srcAmounts";
|
|
154
|
+
readonly type: "uint256[]";
|
|
155
|
+
}, {
|
|
156
|
+
readonly name: "feeReceivers";
|
|
157
|
+
readonly type: "address[]";
|
|
158
|
+
}, {
|
|
159
|
+
readonly name: "feeAmounts";
|
|
160
|
+
readonly type: "uint256[]";
|
|
161
|
+
}, {
|
|
162
|
+
readonly name: "dstReceiver";
|
|
163
|
+
readonly type: "address";
|
|
164
|
+
}, {
|
|
165
|
+
readonly name: "amount";
|
|
166
|
+
readonly type: "uint256";
|
|
167
|
+
}, {
|
|
168
|
+
readonly name: "minReturnAmount";
|
|
169
|
+
readonly type: "uint256";
|
|
170
|
+
}, {
|
|
171
|
+
readonly name: "flags";
|
|
172
|
+
readonly type: "uint256";
|
|
173
|
+
}, {
|
|
174
|
+
readonly name: "permit";
|
|
175
|
+
readonly type: "bytes";
|
|
176
|
+
}];
|
|
177
|
+
}, {
|
|
178
|
+
readonly name: "executorData";
|
|
179
|
+
readonly type: "bytes";
|
|
180
|
+
}, {
|
|
181
|
+
readonly name: "clientData";
|
|
182
|
+
readonly type: "bytes";
|
|
183
|
+
}];
|
|
184
|
+
readonly outputs: readonly [{
|
|
185
|
+
readonly name: "returnAmount";
|
|
186
|
+
readonly type: "uint256";
|
|
187
|
+
}, {
|
|
188
|
+
readonly name: "gasUsed";
|
|
189
|
+
readonly type: "uint256";
|
|
190
|
+
}];
|
|
191
|
+
}];
|
|
192
|
+
export declare class AggregatedSwapCalldataError extends UserFacingError {
|
|
193
|
+
readonly reason: string;
|
|
194
|
+
constructor(reason: string);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Decodes the /route/build calldata and asserts its settlement invariants
|
|
198
|
+
* match the quote the user reviewed: tokens, pulled amount, payout receiver,
|
|
199
|
+
* the embedded slippage floor, and (for fee-charged routes) that every fee
|
|
200
|
+
* receiver is the pinned recipient. Fails closed on unknown entrypoints.
|
|
201
|
+
*/
|
|
202
|
+
export declare function assertKyberCalldataMatchesQuote(args: {
|
|
203
|
+
data: Hex;
|
|
204
|
+
inputToken: Address;
|
|
205
|
+
outputToken: Address;
|
|
206
|
+
amount: bigint;
|
|
207
|
+
recipient: Address;
|
|
208
|
+
/** Lowest acceptable value for the calldata's embedded minReturnAmount. */
|
|
209
|
+
minReturnFloor: bigint;
|
|
210
|
+
feeRecipient: Address | null;
|
|
211
|
+
}): void;
|
package/dist/quote.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type DirectSwapQuote = {
|
|
|
29
29
|
feeRecipient: Address | null;
|
|
30
30
|
gasEstimate: bigint;
|
|
31
31
|
};
|
|
32
|
+
export declare function outputSlippageFloor(amountOut: bigint, slippageBps: number): bigint;
|
|
32
33
|
export declare function getZeroForOne(poolKey: AegisPoolKey, tokenIn: AegisSwapToken): boolean;
|
|
33
34
|
export declare function fetchDirectSwapQuote(args: {
|
|
34
35
|
publicClient: PublicClient;
|