@aegis-engine/core 0.9.2 → 0.11.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 +32 -0
- package/dist/abis.d.ts +57 -0
- package/dist/account.js +2 -2
- package/dist/actions/kyberSwap.d.ts +3 -0
- package/dist/aegis-core.js +3963 -3530
- package/dist/config/constants.d.ts +1 -1
- package/dist/encoding.d.ts +106 -0
- package/dist/index.d.ts +5 -3
- package/dist/quote/aegisRouteProvider.d.ts +43 -0
- package/dist/quote/aggregatedSwapQuote.d.ts +15 -1
- package/dist/quote/routeProvider.d.ts +79 -0
- package/dist/{sdkRuntime-UJvZ2vPs.js → sdkRuntime-Dcfu-Hbw.js} +1 -1
- package/dist/services/kyberSwap.d.ts +11 -1
- package/dist/swap/trustedMarket.d.ts +23 -0
- package/dist/{transactionHistory-D3PDVGkr.js → transactionHistory-B-F6o9hW.js} +3 -3
- package/dist/types/aggregatedSwap.d.ts +7 -0
- package/package.json +1 -1
|
@@ -19,4 +19,4 @@ export declare const AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT = "https://aegis.marke
|
|
|
19
19
|
export declare const AGGREGATED_SWAP_FEE_BPS = 50;
|
|
20
20
|
export declare const AGGREGATED_SWAP_FEE_RECIPIENT: `0x${string}`;
|
|
21
21
|
export declare const AGGREGATED_SWAP_KYBER_ROUTER: `0x${string}`;
|
|
22
|
-
export declare const AGGREGATED_SWAP_SUPPORTED_CHAIN_IDS: readonly [1];
|
|
22
|
+
export declare const AGGREGATED_SWAP_SUPPORTED_CHAIN_IDS: readonly [1, 56, 130, 8453];
|
package/dist/encoding.d.ts
CHANGED
|
@@ -33,8 +33,114 @@ export type BuiltSwapTransaction = {
|
|
|
33
33
|
value: bigint;
|
|
34
34
|
};
|
|
35
35
|
export declare const MAX_UINT128: bigint;
|
|
36
|
+
export declare const AEGIS_ACTION: {
|
|
37
|
+
readonly SWAP_EXACT_IN_SINGLE: 6;
|
|
38
|
+
readonly SWAP_EXACT_IN: 7;
|
|
39
|
+
readonly SWAP_EXACT_OUT_SINGLE: 8;
|
|
40
|
+
readonly SETTLE: 11;
|
|
41
|
+
readonly TAKE: 14;
|
|
42
|
+
readonly TAKE_PORTION: 16;
|
|
43
|
+
readonly SWEEP: 20;
|
|
44
|
+
};
|
|
45
|
+
export declare const SWAP_EXACT_IN_ABI: readonly [{
|
|
46
|
+
readonly name: "params";
|
|
47
|
+
readonly type: "tuple";
|
|
48
|
+
readonly components: readonly [{
|
|
49
|
+
readonly name: "currencyIn";
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "path";
|
|
53
|
+
readonly type: "tuple[]";
|
|
54
|
+
readonly components: readonly [{
|
|
55
|
+
readonly name: "intermediateCurrency";
|
|
56
|
+
readonly type: "address";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "fee";
|
|
59
|
+
readonly type: "uint24";
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "tickSpacing";
|
|
62
|
+
readonly type: "int24";
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "hooks";
|
|
65
|
+
readonly type: "address";
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "hookData";
|
|
68
|
+
readonly type: "bytes";
|
|
69
|
+
}];
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "amountIn";
|
|
72
|
+
readonly type: "uint128";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "amountOutMinimum";
|
|
75
|
+
readonly type: "uint128";
|
|
76
|
+
}];
|
|
77
|
+
}];
|
|
78
|
+
export declare const SETTLE_ABI: readonly [{
|
|
79
|
+
readonly name: "currency";
|
|
80
|
+
readonly type: "address";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "amount";
|
|
83
|
+
readonly type: "uint256";
|
|
84
|
+
}, {
|
|
85
|
+
readonly name: "payerIsUser";
|
|
86
|
+
readonly type: "bool";
|
|
87
|
+
}];
|
|
88
|
+
export declare const TAKE_ABI: readonly [{
|
|
89
|
+
readonly name: "currency";
|
|
90
|
+
readonly type: "address";
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "recipient";
|
|
93
|
+
readonly type: "address";
|
|
94
|
+
}, {
|
|
95
|
+
readonly name: "amount";
|
|
96
|
+
readonly type: "uint256";
|
|
97
|
+
}];
|
|
98
|
+
export declare const TAKE_PORTION_ABI: readonly [{
|
|
99
|
+
readonly name: "currency";
|
|
100
|
+
readonly type: "address";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "recipient";
|
|
103
|
+
readonly type: "address";
|
|
104
|
+
}, {
|
|
105
|
+
readonly name: "bips";
|
|
106
|
+
readonly type: "uint256";
|
|
107
|
+
}];
|
|
36
108
|
export declare function assertUint128(value: bigint, label?: string): void;
|
|
37
109
|
export declare function computePoolId(poolKey: AegisPoolKey): Hex;
|
|
110
|
+
/** One hop of an exact-input path: the pool and the currency it pays out. */
|
|
111
|
+
export type AegisPathHop = {
|
|
112
|
+
poolKey: AegisPoolKey;
|
|
113
|
+
currencyOut: Address;
|
|
114
|
+
};
|
|
115
|
+
/** V4 PathKeys for a hop list; the quoter and the router read the same shape. */
|
|
116
|
+
export declare function v4PathKeys(path: readonly AegisPathHop[]): {
|
|
117
|
+
intermediateCurrency: `0x${string}`;
|
|
118
|
+
fee: number;
|
|
119
|
+
tickSpacing: number;
|
|
120
|
+
hooks: `0x${string}`;
|
|
121
|
+
hookData: Hex;
|
|
122
|
+
}[];
|
|
123
|
+
/**
|
|
124
|
+
* Multi-hop exact input through the deployed Aegis router: SWAP_EXACT_IN,
|
|
125
|
+
* SETTLE, optional fee TAKE_PORTION, a fixed TAKE of the net minimum (reverts
|
|
126
|
+
* the whole swap on a shortfall), then TAKE(OPEN_DELTA) for any surplus.
|
|
127
|
+
*/
|
|
128
|
+
export declare function buildExactInPathTransaction(args: {
|
|
129
|
+
currencyIn: Address;
|
|
130
|
+
path: readonly AegisPathHop[];
|
|
131
|
+
amountIn: bigint;
|
|
132
|
+
/** Gross floor for the swap action, before the fee portion. */
|
|
133
|
+
amountOutMinimum: bigint;
|
|
134
|
+
/** Net payout the recipient must receive after the fee. */
|
|
135
|
+
amountOutNetMinimum: bigint;
|
|
136
|
+
recipient: Address;
|
|
137
|
+
deadline: bigint;
|
|
138
|
+
permit?: SignedPermitBatch | null;
|
|
139
|
+
fee?: {
|
|
140
|
+
recipient: Address;
|
|
141
|
+
bips: number;
|
|
142
|
+
} | null;
|
|
143
|
+
}): BuiltSwapTransaction;
|
|
38
144
|
export declare function buildExactInSwapTransaction(args: {
|
|
39
145
|
poolKey: AegisPoolKey;
|
|
40
146
|
zeroForOne: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,12 +4,14 @@ export { assertUint128, buildExactInSwapTransaction, buildExactOutSwapTransactio
|
|
|
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 { AggregatedSwapBuildMismatchError, aggregatedSwapErrorMessage, fetchAggregatedSwapQuote } from './quote/aggregatedSwapQuote.js';
|
|
7
|
+
export { AggregatedSwapBuildMismatchError, aggregatedSwapErrorMessage, assertAggregatedQuoteLiquidity, fetchAggregatedSwapQuote } from './quote/aggregatedSwapQuote.js';
|
|
8
|
+
export { NoAegisRouteError, assertAegisOnlyRouteLegs } from './quote/routeProvider.js';
|
|
9
|
+
export type { NoAegisRouteReason } from './quote/routeProvider.js';
|
|
8
10
|
export type { AggregatedSwapExecutionIntent } from './quote/aggregatedSwapQuote.js';
|
|
9
11
|
export { AggregatedSwapCalldataError } from './quote/kyberCalldata.js';
|
|
10
12
|
export type { AggregatedSwapQuote, AggregatedSwapRoute, HopInfo } from './types/aggregatedSwap.js';
|
|
11
|
-
export { KyberSwapApiError, KyberSwapContractError, KyberSwapResourceLimitError, buildKyberSwapRoute, fetchKyberSwapRoute, isRetryableKyberSwapError } from './services/kyberSwap.js';
|
|
12
|
-
export type { KyberSwapBuild, KyberSwapError, KyberSwapFeeParams, KyberSwapRoute, KyberSwapRouteLeg, KyberSwapRouteSummary } from './services/kyberSwap.js';
|
|
13
|
+
export { KYBER_AEGIS_LIQUIDITY_SOURCE, KyberSwapApiError, KyberSwapContractError, KyberSwapResourceLimitError, buildKyberSwapRoute, fetchKyberSwapRoute, isRetryableKyberSwapError } from './services/kyberSwap.js';
|
|
14
|
+
export type { AggregatedSwapLiquiditySources, KyberSwapBuild, KyberSwapError, KyberSwapFeeParams, KyberSwapRoute, KyberSwapRouteLeg, KyberSwapRouteSummary } from './services/kyberSwap.js';
|
|
13
15
|
export { approveErc20Spender, approveErc20ToPermit2, approvePermit2ToRouter, buildSignedPermitBatch, DEFAULT_PERMIT_EXPIRATION_SECONDS, hasUsablePermit2Allowance, isUnlimitedErc20Approval, isUnlimitedPermit2Approval, MAX_UINT160, MAX_UINT256, PERMIT2_FAR_FUTURE_EXPIRATION, readErc20Allowance, readPermit2RouterAllowance, SWAP_TX_DEADLINE_SECONDS, UNLIMITED_ERC20_FLOOR, UNLIMITED_PERMIT2_FLOOR } from './permit.js';
|
|
14
16
|
export { fetchGlobalTokenMetadata, resolveTokenIconUrl } from './metadata.js';
|
|
15
17
|
export type { AegisSwapGlobalTokenMetadata, TokenMetadataByAddress } from './metadata.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Address, type PublicClient } from 'viem';
|
|
2
|
+
import { type TrustedSwapPool } from '../swap/trustedMarket.js';
|
|
3
|
+
import { type AggregatedRouteProvider } from './routeProvider.js';
|
|
4
|
+
/** Canonical Multicall3; its runtime code is live on Ink (57073). */
|
|
5
|
+
export declare const MULTICALL3_ADDRESS: Address;
|
|
6
|
+
export declare const AEGIS_ROUTE_MAX_HOPS = 3;
|
|
7
|
+
type AegisRouteLeg = {
|
|
8
|
+
pool: TrustedSwapPool;
|
|
9
|
+
currencyIn: Address;
|
|
10
|
+
currencyOut: Address;
|
|
11
|
+
};
|
|
12
|
+
export type AegisRouteCandidate = readonly AegisRouteLeg[];
|
|
13
|
+
export type AegisRouteQuote = {
|
|
14
|
+
route: AegisRouteCandidate;
|
|
15
|
+
/** Gross pool output, before the app fee. */
|
|
16
|
+
amountOut: bigint;
|
|
17
|
+
gasEstimate: bigint;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Every simple exact-input path of one to three hops between two tokens, over
|
|
21
|
+
* the chain's shipped pool catalogue only. Breadth-first, so the direct pool
|
|
22
|
+
* comes first and shorter paths survive the candidate cap.
|
|
23
|
+
*/
|
|
24
|
+
export declare function enumerateAegisRoutes(chainId: number, tokenIn: Address, tokenOut: Address, maxCandidates?: number): AegisRouteCandidate[];
|
|
25
|
+
/**
|
|
26
|
+
* Quotes every candidate in ONE eth_call: Multicall3 `aggregate3` with
|
|
27
|
+
* `allowFailure` over V4Quoter `quoteExactInput`, plus Multicall3's own
|
|
28
|
+
* `getBlockNumber`, so all results (and the block they share) come from one
|
|
29
|
+
* state. A failed or malformed sub-call yields `null` for that candidate.
|
|
30
|
+
*/
|
|
31
|
+
export declare function quoteAegisRoutes(publicClient: Pick<PublicClient, 'call'>, routes: readonly AegisRouteCandidate[], amountIn: bigint): Promise<{
|
|
32
|
+
blockNumber: bigint;
|
|
33
|
+
quotes: (AegisRouteQuote | null)[];
|
|
34
|
+
}>;
|
|
35
|
+
/** Highest gross output; ties keep the earlier (shorter) candidate. */
|
|
36
|
+
export declare function bestAegisRouteQuote(quotes: readonly (AegisRouteQuote | null)[]): AegisRouteQuote | null;
|
|
37
|
+
/**
|
|
38
|
+
* In-house provider for chains Kyber does not cover. Routes only through the
|
|
39
|
+
* shipped pool catalogue and settles on the deployed Aegis router, whose
|
|
40
|
+
* input is pulled through Permit2.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createAegisRouteProvider(chainId: number): AggregatedRouteProvider;
|
|
43
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type Address, type PublicClient } from 'viem';
|
|
2
2
|
import { type AegisSwapToken } from '../config/index.js';
|
|
3
|
+
import type { SignedPermitBatch } from '../encoding.js';
|
|
3
4
|
import { UserFacingError } from '../errors.js';
|
|
5
|
+
import { type AggregatedSwapLiquiditySources } from '../services/kyberSwap.js';
|
|
4
6
|
import type { AggregatedSwapQuote } from '../types/aggregatedSwap.js';
|
|
5
7
|
export declare function aggregatedSwapErrorMessage(error: unknown, fallbackMessage: string): string;
|
|
6
8
|
export declare class AggregatedSwapBuildMismatchError extends UserFacingError {
|
|
@@ -16,6 +18,18 @@ export declare class AggregatedSwapBuildMismatchError extends UserFacingError {
|
|
|
16
18
|
/** Absolute settlement floor established by the quote the user approved. */
|
|
17
19
|
export type AggregatedSwapExecutionIntent = Readonly<{
|
|
18
20
|
reviewedAmountOutMinimum: bigint;
|
|
21
|
+
/** Signed Permit2 grant for routers that pull input through Permit2. */
|
|
22
|
+
permit?: SignedPermitBatch | null;
|
|
19
23
|
}>;
|
|
20
24
|
export declare function assertAggregatedRouterTrusted(router: Address, chainId: number): void;
|
|
21
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Re-checks, immediately before signing, that an executable quote was built
|
|
27
|
+
* under Aegis-only routing and that every hop it reports is an Aegis pool.
|
|
28
|
+
* Host-constructed quotes without the commitment fail closed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function assertAggregatedQuoteLiquidity(quote: Pick<AggregatedSwapQuote, 'hops' | 'liquiditySources'>, liquiditySources: AggregatedSwapLiquiditySources): void;
|
|
31
|
+
export declare function fetchAggregatedSwapQuote(inputToken: AegisSwapToken, outputToken: AegisSwapToken, amount: bigint, slippageBps: number, mode?: 'exactIn' | 'exactOut', account?: Address | null, signal?: AbortSignal,
|
|
32
|
+
/** Read client; the on-chain Ink provider quotes through it. */
|
|
33
|
+
publicClient?: PublicClient, executionIntent?: AggregatedSwapExecutionIntent, options?: {
|
|
34
|
+
liquiditySources?: AggregatedSwapLiquiditySources;
|
|
35
|
+
}): Promise<AggregatedSwapQuote>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Address, PublicClient } from 'viem';
|
|
2
|
+
import type { SignedPermitBatch } from '../encoding.js';
|
|
3
|
+
import { UserFacingError } from '../errors.js';
|
|
4
|
+
import { type AggregatedSwapLiquiditySources, type KyberSwapBuild, type KyberSwapFeeParams, type KyberSwapRoute, type KyberSwapRouteSummary } from '../services/kyberSwap.js';
|
|
5
|
+
import { assertKyberCalldataMatchesQuote } from './kyberCalldata.js';
|
|
6
|
+
export type NoAegisRouteReason = 'no-route' | 'non-aegis-leg';
|
|
7
|
+
/**
|
|
8
|
+
* Aegis-only routing found no executable path. `reason` separates "the
|
|
9
|
+
* provider has no all-Aegis path" from "the provider answered with a path that
|
|
10
|
+
* leaves Aegis pools", which is refused rather than trusted.
|
|
11
|
+
*/
|
|
12
|
+
export declare class NoAegisRouteError extends UserFacingError {
|
|
13
|
+
readonly reason: NoAegisRouteReason;
|
|
14
|
+
readonly detail?: string;
|
|
15
|
+
constructor(reason: NoAegisRouteReason, detail?: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Fails closed unless the route is non-empty and every hop of every split is
|
|
19
|
+
* tagged with Kyber's Aegis source. The tag is Kyber's own attribution; there
|
|
20
|
+
* is deliberately no pool-id allowlist on top of it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function assertAegisOnlyRouteLegs(route: KyberSwapRouteSummary['route']): void;
|
|
23
|
+
/** Maps a provider "no route under these sources" failure to NoAegisRouteError. */
|
|
24
|
+
export declare function toNoAegisRouteError(error: unknown): unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Provider-neutral route and build shapes. Kyber's wire layout is the
|
|
27
|
+
* canonical one; another provider fills only the fields it can attest (an
|
|
28
|
+
* in-house route has no USD values, request id or route composition).
|
|
29
|
+
*/
|
|
30
|
+
export type AggregatedRoute = KyberSwapRoute & {
|
|
31
|
+
/** Block the route was quoted at, when the provider quotes on-chain. */
|
|
32
|
+
blockNumber?: bigint;
|
|
33
|
+
};
|
|
34
|
+
type AggregatedRouteBuild = KyberSwapBuild;
|
|
35
|
+
/**
|
|
36
|
+
* Internal seam behind fetchAggregatedSwapQuote: quote → build → validate.
|
|
37
|
+
* KyberSwap serves Ethereum, BSC, Unichain and Base; the in-house Aegis
|
|
38
|
+
* provider serves Ink, where Kyber has no coverage.
|
|
39
|
+
*/
|
|
40
|
+
export type AggregatedRouteProvider = {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
/** Names the route source in user-facing trust errors. */
|
|
43
|
+
readonly label: string;
|
|
44
|
+
trustedRouter(chainId: number): Address | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Set when the router pulls input through Permit2 (ERC-20 approval to
|
|
47
|
+
* Permit2, then a Permit2 grant to the router) rather than a direct ERC-20
|
|
48
|
+
* allowance to the router.
|
|
49
|
+
*/
|
|
50
|
+
permit2?(chainId: number): Address | undefined;
|
|
51
|
+
quote(args: {
|
|
52
|
+
chainId: number;
|
|
53
|
+
tokenIn: Address;
|
|
54
|
+
tokenOut: Address;
|
|
55
|
+
amountIn: bigint;
|
|
56
|
+
origin?: Address | null;
|
|
57
|
+
fee: KyberSwapFeeParams | null;
|
|
58
|
+
liquiditySources: AggregatedSwapLiquiditySources;
|
|
59
|
+
/** Read client for providers that quote on-chain. */
|
|
60
|
+
publicClient?: PublicClient;
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
}): Promise<AggregatedRoute>;
|
|
63
|
+
build(args: {
|
|
64
|
+
chainId: number;
|
|
65
|
+
route: AggregatedRoute;
|
|
66
|
+
sender: Address;
|
|
67
|
+
recipient: Address;
|
|
68
|
+
slippageBps: number;
|
|
69
|
+
/** Absolute net floor the calldata must enforce (Kyber derives it from slippageBps). */
|
|
70
|
+
amountOutMinimum: bigint;
|
|
71
|
+
/** Signed Permit2 grant to embed, for Permit2 providers. */
|
|
72
|
+
permit?: SignedPermitBatch | null;
|
|
73
|
+
signal?: AbortSignal;
|
|
74
|
+
}): Promise<AggregatedRouteBuild>;
|
|
75
|
+
validateRoute(route: AggregatedRoute, liquiditySources: AggregatedSwapLiquiditySources): void;
|
|
76
|
+
validateCalldata(args: Parameters<typeof assertKyberCalldataMatchesQuote>[0]): void;
|
|
77
|
+
};
|
|
78
|
+
export declare function aggregatedRouteProviderForChain(chainId: number): AggregatedRouteProvider;
|
|
79
|
+
export {};
|
|
@@ -3,7 +3,7 @@ var _s = (e, t, n) => t in e ? Ps(e, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var ie = (e, t, n) => _s(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { keccak256 as Et, zeroAddress as Ee, erc721Abi as Wt, hashTypedData as Cs, isAddress as on, erc20Abi as Or, encodeFunctionData as Dn, BaseError as ra, ContractFunctionRevertedError as Qi, numberToHex as Ms, encodeAbiParameters as Xi, parseAbiParameters as Rs, RpcRequestError as Zi, isHex as Ji, decodeErrorResult as Ss, ExecutionRevertedError as Ga, getEventSelector as Ze, getAbiItem as Je, parseAbi as aa, toEventSelector as Os } from "viem";
|
|
5
5
|
import "viem/actions";
|
|
6
|
-
import { X as ja, J as Ka } from "./transactionHistory-
|
|
6
|
+
import { X as ja, J as Ka } from "./transactionHistory-B-F6o9hW.js";
|
|
7
7
|
class f extends Array {
|
|
8
8
|
constructor(t, n) {
|
|
9
9
|
if (super(t), this.sign = n, t > f.__kMaxLength) throw new RangeError("Maximum BigInt size exceeded");
|
|
@@ -55,6 +55,14 @@ export type KyberSwapBuild = {
|
|
|
55
55
|
*/
|
|
56
56
|
deadline?: number;
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Liquidity the aggregator may route through. `'aegis'` restricts Kyber to the
|
|
60
|
+
* Aegis-hooked Uniswap v4 pools it indexes as {@link KYBER_AEGIS_LIQUIDITY_SOURCE};
|
|
61
|
+
* `'any'` leaves source selection to Kyber.
|
|
62
|
+
*/
|
|
63
|
+
export type AggregatedSwapLiquiditySources = 'aegis' | 'any';
|
|
64
|
+
/** Kyber's liquidity-source id for Uniswap v4 pools that use the Aegis hook. */
|
|
65
|
+
export declare const KYBER_AEGIS_LIQUIDITY_SOURCE = "uniswap-v4-aegis";
|
|
58
66
|
export type KyberSwapError = {
|
|
59
67
|
code?: number;
|
|
60
68
|
message?: string;
|
|
@@ -93,13 +101,15 @@ export declare class KyberSwapResourceLimitError extends Error {
|
|
|
93
101
|
});
|
|
94
102
|
}
|
|
95
103
|
export declare function isRetryableKyberSwapError(error: unknown): boolean;
|
|
96
|
-
export declare function fetchKyberSwapRoute({ tokenIn, tokenOut, amountIn, chainId, origin, fee, signal, timeoutMs }: {
|
|
104
|
+
export declare function fetchKyberSwapRoute({ tokenIn, tokenOut, amountIn, chainId, origin, fee, liquiditySources, signal, timeoutMs }: {
|
|
97
105
|
tokenIn: Address;
|
|
98
106
|
tokenOut: Address;
|
|
99
107
|
amountIn: string;
|
|
100
108
|
chainId?: number;
|
|
101
109
|
origin?: Address | null;
|
|
102
110
|
fee?: KyberSwapFeeParams | null;
|
|
111
|
+
/** `'aegis'` sends `includedSources=uniswap-v4-aegis`; defaults to `'any'`. */
|
|
112
|
+
liquiditySources?: AggregatedSwapLiquiditySources;
|
|
103
113
|
signal?: AbortSignal;
|
|
104
114
|
/** Abort after this many ms (composes with `signal`); defaults to 20s. */
|
|
105
115
|
timeoutMs?: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
1
2
|
import type { AegisPoolKey, AegisSwapMarket } from '../config/index.js';
|
|
2
3
|
import { UserFacingError } from '../errors.js';
|
|
3
4
|
/**
|
|
@@ -10,6 +11,19 @@ import { UserFacingError } from '../errors.js';
|
|
|
10
11
|
* reviewed SDK release.
|
|
11
12
|
*/
|
|
12
13
|
export declare const DIRECT_SWAP_MARKET_TRUST_RULE_ID: "DIRECT-MARKET-001";
|
|
14
|
+
type TrustedTokenIdentity = {
|
|
15
|
+
address: Address;
|
|
16
|
+
decimals: number;
|
|
17
|
+
};
|
|
18
|
+
type TrustedDirectSwapMarketIdentity = {
|
|
19
|
+
chainId: number;
|
|
20
|
+
poolId: Hex;
|
|
21
|
+
poolKey: AegisPoolKey;
|
|
22
|
+
tokens: readonly [TrustedTokenIdentity, TrustedTokenIdentity];
|
|
23
|
+
router: Address;
|
|
24
|
+
permit2: Address;
|
|
25
|
+
quoter: Address;
|
|
26
|
+
};
|
|
13
27
|
export declare class DirectSwapMarketTrustError extends UserFacingError {
|
|
14
28
|
readonly ruleId: "DIRECT-MARKET-001";
|
|
15
29
|
constructor(detail?: string);
|
|
@@ -23,3 +37,12 @@ export declare function assertDirectSwapPoolKeyMatchesMarket(market: AegisSwapMa
|
|
|
23
37
|
* object is the same identity that Core must receive at quote and send time.
|
|
24
38
|
*/
|
|
25
39
|
export declare function authorizeHostDirectSwapMarket<T extends AegisSwapMarket>(market: T): T;
|
|
40
|
+
/** A reviewed pool from the shipped catalogue, as multi-hop routing sees it. */
|
|
41
|
+
export type TrustedSwapPool = Pick<TrustedDirectSwapMarketIdentity, 'chainId' | 'poolId' | 'poolKey' | 'router' | 'permit2' | 'quoter'>;
|
|
42
|
+
/**
|
|
43
|
+
* DIRECT-MARKET-001 applied to routed swaps: the only pools a multi-hop route
|
|
44
|
+
* may touch are the shipped catalogue's pools on that chain. Host-authorized
|
|
45
|
+
* markets are deliberately excluded; routing never widens the catalogue.
|
|
46
|
+
*/
|
|
47
|
+
export declare function trustedSwapPoolsForChain(chainId: number): readonly TrustedSwapPool[];
|
|
48
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Address, Hex } from 'viem';
|
|
2
2
|
import type { AegisSwapToken } from '../config/index.js';
|
|
3
|
+
import type { AggregatedSwapLiquiditySources } from '../services/kyberSwap.js';
|
|
3
4
|
export type HopInfo = {
|
|
4
5
|
dex: string;
|
|
5
6
|
inputToken: AegisSwapToken;
|
|
@@ -13,6 +14,12 @@ export type AggregatedSwapQuote = {
|
|
|
13
14
|
amountOut: bigint;
|
|
14
15
|
gasEstimate: bigint;
|
|
15
16
|
hops: HopInfo[];
|
|
17
|
+
/**
|
|
18
|
+
* Liquidity set the route was requested and validated under. `'aegis'`
|
|
19
|
+
* quotes passed the all-Aegis leg check; execution in Aegis-only mode
|
|
20
|
+
* re-checks it (and every hop) before signing.
|
|
21
|
+
*/
|
|
22
|
+
liquiditySources?: AggregatedSwapLiquiditySources;
|
|
16
23
|
routerAddress: Address;
|
|
17
24
|
calldata: Hex | null;
|
|
18
25
|
/**
|