@aegis-engine/core 0.6.0 → 0.8.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 +232 -7
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/account.d.ts +11 -0
- package/dist/account.js +129 -0
- package/dist/actions/allowance.d.ts +94 -0
- package/dist/actions/directPoolSwap.d.ts +10 -1
- package/dist/actions/kyberSwap.d.ts +2 -0
- package/dist/actions/types.d.ts +10 -3
- package/dist/actions/wallet.d.ts +1 -0
- package/dist/aegis-core.js +9653 -200
- package/dist/backendAdapters.d.ts +3 -1
- package/dist/config/chains.d.ts +1 -0
- package/dist/config/constants.d.ts +4 -0
- package/dist/config/tokens.d.ts +2 -1
- package/dist/config/types.d.ts +8 -0
- package/dist/contract/backendClient.d.ts +3 -1
- package/dist/contract/generated/aegis-swap.d.ts +6337 -1377
- package/dist/contract/generated/market-data.d.ts +8286 -0
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/responseBudget.d.ts +9 -0
- package/dist/contract/schemas.d.ts +13 -3
- package/dist/engine/account/accounting.d.ts +24 -0
- package/dist/engine/account/accountingSchemas.d.ts +2056 -0
- package/dist/engine/account/activity.d.ts +42 -0
- package/dist/engine/account/activitySchemas.d.ts +327 -0
- package/dist/engine/account/amountSchemas.d.ts +9 -0
- package/dist/engine/account/catalogSchemas.d.ts +108 -0
- package/dist/engine/account/client.d.ts +14 -0
- package/dist/engine/account/history.d.ts +40 -0
- package/dist/engine/account/historySchemas.d.ts +251 -0
- package/dist/engine/account/management.d.ts +13 -0
- package/dist/engine/account/portfolioSchemas.d.ts +712 -0
- package/dist/engine/account/positionPerformance.d.ts +18 -0
- package/dist/engine/account/positionPerformanceSchemas.d.ts +101 -0
- package/dist/engine/account/positionPnl.d.ts +18 -0
- package/dist/engine/account/positionPnlSchemas.d.ts +149 -0
- package/dist/engine/account/transactionHistory.d.ts +50 -0
- package/dist/engine/account/transactionSchemas.d.ts +101 -0
- package/dist/engine/account/transactions.d.ts +26 -0
- package/dist/engine/account/transport.d.ts +31 -0
- package/dist/engine/account/types.d.ts +39 -0
- package/dist/engine/actions.d.ts +14 -4
- package/dist/engine/adaptiveFee.d.ts +14 -0
- package/dist/engine/balancedLending.d.ts +82 -0
- package/dist/engine/borrowCollateralFloor.d.ts +3 -0
- package/dist/engine/borrowLimits.d.ts +18 -0
- package/dist/engine/dataSource.d.ts +2 -0
- package/dist/engine/index.d.ts +20 -0
- package/dist/engine/marketAdapter.d.ts +3 -0
- package/dist/engine/marketSeries.d.ts +61 -0
- package/dist/engine/marketSeriesSchemas.d.ts +312 -0
- package/dist/engine/marketTrust.d.ts +26 -0
- package/dist/engine/openingEntry.d.ts +41 -0
- package/dist/engine/rateHistorySchemas.d.ts +88 -0
- package/dist/engine/reads.d.ts +1 -1
- package/dist/engine/registry.d.ts +1 -1
- package/dist/engine/restSchemas.d.ts +59 -1
- package/dist/engine/tradeExecutionSession.d.ts +155 -0
- package/dist/engine/types.d.ts +169 -15
- package/dist/engine/v4Quote.d.ts +5 -0
- package/dist/index.d.ts +13 -8
- package/dist/internal/guardedWalletTransaction.d.ts +31 -0
- package/dist/permit.d.ts +80 -6
- package/dist/quote/aggregatedSwapQuote.d.ts +5 -1
- package/dist/quote/kyberCalldata.d.ts +5 -1
- package/dist/{sdkRuntime-C_vaU-0g.js → sdkRuntime-3aRt_g55.js} +3385 -2957
- package/dist/services/kyberSwap.d.ts +12 -0
- package/dist/swap/authorizePermit.d.ts +11 -9
- package/dist/swap/executeSwapTransaction.d.ts +5 -1
- package/dist/swap/receiptWait.d.ts +9 -0
- package/dist/swap/sendSwapTransaction.d.ts +7 -0
- package/dist/swap/settlement.d.ts +4 -0
- package/dist/swap/trustedMarket.d.ts +25 -0
- package/dist/transactionHistory-1Zl2KCcV.js +5915 -0
- package/dist/transactionProgress.d.ts +41 -2
- package/dist/wallet.d.ts +5 -1
- package/package.json +12 -5
- package/dist/index-D9EfUokZ.js +0 -11031
|
@@ -80,6 +80,18 @@ export declare class KyberSwapContractError extends Error {
|
|
|
80
80
|
issues: z.core.$ZodIssue[];
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
+
export declare class KyberSwapResourceLimitError extends Error {
|
|
84
|
+
readonly ruleId = "REMOTE-LIMIT-001";
|
|
85
|
+
readonly endpoint: string;
|
|
86
|
+
readonly limit: number;
|
|
87
|
+
readonly actual?: number;
|
|
88
|
+
constructor({ endpoint, limit, actual, resource }: {
|
|
89
|
+
endpoint: string;
|
|
90
|
+
limit: number;
|
|
91
|
+
actual?: number;
|
|
92
|
+
resource: string;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
83
95
|
export declare function isRetryableKyberSwapError(error: unknown): boolean;
|
|
84
96
|
export declare function fetchKyberSwapRoute({ tokenIn, tokenOut, amountIn, chainId, origin, fee, signal, timeoutMs }: {
|
|
85
97
|
tokenIn: Address;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address, PublicClient } from 'viem';
|
|
1
|
+
import type { Address, Hex, PublicClient } from 'viem';
|
|
2
2
|
import type { AegisSwapChainConfig } from '../config/index.js';
|
|
3
3
|
import type { SignedPermitBatch } from '../encoding.js';
|
|
4
4
|
import { readPermit2RouterAllowance } from '../permit.js';
|
|
@@ -9,14 +9,14 @@ import type { AegisSwapApprovalMode, WalletSession } from './types.js';
|
|
|
9
9
|
* Produces the Permit2 authorization the swap calldata needs.
|
|
10
10
|
*
|
|
11
11
|
* Tries an off-chain Permit2 signature first (`null` calldata permit when the
|
|
12
|
-
* on-chain allowance already covers the spend)
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* on-chain
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* on-chain allowance already covers the spend), then checks the resolved
|
|
13
|
+
* signature the way Permit2 will — see `isPermit2AcceptableSignature` for the
|
|
14
|
+
* shapes that fail. Only explicit typed-data unsupported-method errors use the
|
|
15
|
+
* on-chain spending-cap fallback. A returned but invalid signature, a user
|
|
16
|
+
* rejection, or any transport/internal RPC failure stops the attempt; none of
|
|
17
|
+
* those proves the wallet lacks typed-data support.
|
|
18
18
|
*/
|
|
19
|
-
export declare function authorizePermit({ wallet, publicClient, activeChain, permit2, router, token, amount, approvalMode, allowanceRead, setStatus, onAuthorizationProgress, onWalletRequest, onHash }: {
|
|
19
|
+
export declare function authorizePermit({ wallet, publicClient, activeChain, permit2, router, token, amount, approvalMode, allowanceRead, signal, setStatus, onAuthorizationProgress, onWalletRequest, onHash }: {
|
|
20
20
|
wallet: WalletSession;
|
|
21
21
|
publicClient: PublicClient;
|
|
22
22
|
activeChain: AegisSwapChainConfig;
|
|
@@ -26,8 +26,10 @@ export declare function authorizePermit({ wallet, publicClient, activeChain, per
|
|
|
26
26
|
amount: bigint;
|
|
27
27
|
approvalMode: AegisSwapApprovalMode;
|
|
28
28
|
allowanceRead: ReturnType<typeof readPermit2RouterAllowance>;
|
|
29
|
+
/** Stops preparation before a signature or approval reaches the wallet. */
|
|
30
|
+
signal?: AbortSignal;
|
|
29
31
|
setStatus: (status: SubmitStatus) => void;
|
|
30
32
|
onAuthorizationProgress?: (progress: AegisSwapAuthorizationProgress) => void;
|
|
31
33
|
onWalletRequest?: () => void;
|
|
32
|
-
onHash?: (hash:
|
|
34
|
+
onHash?: (hash: Hex) => void;
|
|
33
35
|
}): Promise<SignedPermitBatch | null>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AegisTransactionObservation } from './receiptWait.js';
|
|
1
2
|
import { type Hex, type PublicClient } from 'viem';
|
|
2
3
|
import type { AegisSwapChainConfig, AegisSwapMarket, AegisSwapToken } from '../config/index.js';
|
|
3
4
|
import { type SignedPermitBatch } from '../encoding.js';
|
|
@@ -22,7 +23,7 @@ export type SwapExecutionResult = {
|
|
|
22
23
|
* or reverted receipt. Setting the success status and the post-success refreshes
|
|
23
24
|
* stay with the caller.
|
|
24
25
|
*/
|
|
25
|
-
export declare function executeSwapTransaction({ wallet, publicClient, activeChain, market, inputToken, outputToken, swapQuote, permit, setStatus, setTxHash, onSubmitted }: {
|
|
26
|
+
export declare function executeSwapTransaction({ wallet, publicClient, activeChain, market, inputToken, outputToken, swapQuote, permit, signal, setStatus, setTxHash, onSubmitted, onTransactionObservation }: {
|
|
26
27
|
wallet: WalletSession;
|
|
27
28
|
publicClient: PublicClient;
|
|
28
29
|
activeChain: AegisSwapChainConfig;
|
|
@@ -31,7 +32,10 @@ export declare function executeSwapTransaction({ wallet, publicClient, activeCha
|
|
|
31
32
|
outputToken: AegisSwapToken;
|
|
32
33
|
swapQuote: DirectSwapQuote;
|
|
33
34
|
permit: SignedPermitBatch | null;
|
|
35
|
+
/** Cancels preparation before the swap transaction is broadcast. */
|
|
36
|
+
signal?: AbortSignal;
|
|
34
37
|
setStatus: (status: SubmitStatus) => void;
|
|
35
38
|
setTxHash: (hash: Hex | null) => void;
|
|
39
|
+
onTransactionObservation?: (event: AegisTransactionObservation) => void;
|
|
36
40
|
onSubmitted?: (hash: Hex, swap?: AegisSwapSubmitDetails) => void;
|
|
37
41
|
}): Promise<SwapExecutionResult>;
|
|
@@ -14,15 +14,24 @@ export declare function waitForReceiptWithTimeout(args: {
|
|
|
14
14
|
timeoutMs: number;
|
|
15
15
|
onReplaced?: OnReplacedParameter;
|
|
16
16
|
}): Promise<TransactionReceipt>;
|
|
17
|
+
/** Read-only execution evidence. It contains identity, never executable intent. */
|
|
18
|
+
export type AegisTransactionObservation = Readonly<{
|
|
19
|
+
executionChanged?: boolean;
|
|
20
|
+
hash: Hex;
|
|
21
|
+
status: 'submitted' | 'confirmed' | 'reverted' | 'cancelled';
|
|
22
|
+
replacesHash?: Hex;
|
|
23
|
+
}>;
|
|
17
24
|
export type SubmittedReceiptOutcome = Readonly<{
|
|
18
25
|
status: 'confirmed' | 'reverted' | 'cancelled';
|
|
19
26
|
hash: Hex;
|
|
20
27
|
replacesHash?: Hex;
|
|
28
|
+
executionChanged?: boolean;
|
|
21
29
|
receipt: TransactionReceipt;
|
|
22
30
|
}> | Readonly<{
|
|
23
31
|
status: 'unresolved';
|
|
24
32
|
hash: Hex;
|
|
25
33
|
replacesHash?: Hex;
|
|
34
|
+
executionChanged?: boolean;
|
|
26
35
|
}>;
|
|
27
36
|
/**
|
|
28
37
|
* Reconciles one already-submitted transaction without any broadcast path.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Address, type Chain, type Hex, type PublicClient, type TransactionReceipt } from 'viem';
|
|
2
2
|
import type { AegisSwapReceiptSummary } from '../transactionProgress.js';
|
|
3
|
+
import { type AegisTransactionObservation } from './receiptWait.js';
|
|
3
4
|
import { type SwapSettlementContext } from './settlement.js';
|
|
4
5
|
import type { AegisSwapSubmitDetails, WalletSession } from './types.js';
|
|
5
6
|
/**
|
|
@@ -47,6 +48,8 @@ export declare function sendGuardedTransactionAndAwait(args: {
|
|
|
47
48
|
signal?: AbortSignal;
|
|
48
49
|
cancelledMessage: string;
|
|
49
50
|
revertedMessage: string;
|
|
51
|
+
onTransactionObservation?: (event: AegisTransactionObservation) => void;
|
|
52
|
+
onWalletRequest?: () => void;
|
|
50
53
|
onHash?: (hash: Hex | null) => void;
|
|
51
54
|
onSubmitted?: (hash: Hex) => void;
|
|
52
55
|
}): Promise<{
|
|
@@ -62,6 +65,8 @@ export declare function sendSwapTransactionAndAwait(args: {
|
|
|
62
65
|
data: Hex;
|
|
63
66
|
value: bigint;
|
|
64
67
|
gas?: bigint;
|
|
68
|
+
/** Cancels only before a transaction hash exists. */
|
|
69
|
+
signal?: AbortSignal;
|
|
65
70
|
swapDetails: AegisSwapSubmitDetails;
|
|
66
71
|
/**
|
|
67
72
|
* When provided, the summary also carries `settledAmountOut` decoded from
|
|
@@ -69,6 +74,8 @@ export declare function sendSwapTransactionAndAwait(args: {
|
|
|
69
74
|
* native). Best-effort: decoding failures leave the field undefined.
|
|
70
75
|
*/
|
|
71
76
|
settlement?: SwapSettlementContext;
|
|
77
|
+
onTransactionObservation?: (event: AegisTransactionObservation) => void;
|
|
78
|
+
onWalletRequest?: () => void;
|
|
72
79
|
onHash?: (hash: Hex | null) => void;
|
|
73
80
|
onSubmitted?: (hash: Hex, swap?: AegisSwapSubmitDetails) => void;
|
|
74
81
|
}): Promise<{
|
|
@@ -4,6 +4,7 @@ export type SwapSettlementContext = {
|
|
|
4
4
|
recipient: Address;
|
|
5
5
|
/** Output token address; zero address or the 0xEeee… sentinel means native. */
|
|
6
6
|
outputToken: Address;
|
|
7
|
+
inputToken?: Address;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Best-effort decode of what the swap actually settled to the recipient:
|
|
@@ -13,3 +14,6 @@ export type SwapSettlementContext = {
|
|
|
13
14
|
* never failed retroactively over display data.
|
|
14
15
|
*/
|
|
15
16
|
export declare function resolveSettledAmountOut(publicClient: PublicClient, receipt: TransactionReceipt, settlement: SwapSettlementContext): Promise<bigint | undefined>;
|
|
17
|
+
/** Receipt-local input transfers, net of token refunds. Native spends have no
|
|
18
|
+
* Transfer logs and remain unknown here rather than using a block balance guess. */
|
|
19
|
+
export declare function resolveSettledAmountIn(receipt: TransactionReceipt, settlement: SwapSettlementContext): bigint | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AegisPoolKey, AegisSwapMarket } from '../config/index.js';
|
|
2
|
+
import { UserFacingError } from '../errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* DIRECT-MARKET-001
|
|
5
|
+
*
|
|
6
|
+
* Backend market DTOs are discovery data, not execution authorization. This
|
|
7
|
+
* catalogue is shipped with Core so a coherently malicious `/v1/config` plus
|
|
8
|
+
* `/v1/markets` response cannot introduce a new token pair, pool key, hook, or
|
|
9
|
+
* signing target. Adding a backend-executable pool therefore requires a
|
|
10
|
+
* reviewed SDK release.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DIRECT_SWAP_MARKET_TRUST_RULE_ID: "DIRECT-MARKET-001";
|
|
13
|
+
export declare class DirectSwapMarketTrustError extends UserFacingError {
|
|
14
|
+
readonly ruleId: "DIRECT-MARKET-001";
|
|
15
|
+
constructor(detail?: string);
|
|
16
|
+
}
|
|
17
|
+
export declare function isDirectSwapMarketTrusted(market: AegisSwapMarket): boolean;
|
|
18
|
+
export declare function assertDirectSwapMarketTrusted(market: AegisSwapMarket): void;
|
|
19
|
+
export declare function assertDirectSwapPoolKeyMatchesMarket(market: AegisSwapMarket, poolKey: AegisPoolKey): void;
|
|
20
|
+
/**
|
|
21
|
+
* Explicit exception path for an embedding application's own static pool
|
|
22
|
+
* configuration. Never call this for network or storage data. The returned
|
|
23
|
+
* object is the same identity that Core must receive at quote and send time.
|
|
24
|
+
*/
|
|
25
|
+
export declare function authorizeHostDirectSwapMarket<T extends AegisSwapMarket>(market: T): T;
|