@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.
Files changed (78) hide show
  1. package/README.md +232 -7
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/account.d.ts +11 -0
  4. package/dist/account.js +129 -0
  5. package/dist/actions/allowance.d.ts +94 -0
  6. package/dist/actions/directPoolSwap.d.ts +10 -1
  7. package/dist/actions/kyberSwap.d.ts +2 -0
  8. package/dist/actions/types.d.ts +10 -3
  9. package/dist/actions/wallet.d.ts +1 -0
  10. package/dist/aegis-core.js +9653 -200
  11. package/dist/backendAdapters.d.ts +3 -1
  12. package/dist/config/chains.d.ts +1 -0
  13. package/dist/config/constants.d.ts +4 -0
  14. package/dist/config/tokens.d.ts +2 -1
  15. package/dist/config/types.d.ts +8 -0
  16. package/dist/contract/backendClient.d.ts +3 -1
  17. package/dist/contract/generated/aegis-swap.d.ts +6337 -1377
  18. package/dist/contract/generated/market-data.d.ts +8286 -0
  19. package/dist/contract/index.d.ts +1 -0
  20. package/dist/contract/responseBudget.d.ts +9 -0
  21. package/dist/contract/schemas.d.ts +13 -3
  22. package/dist/engine/account/accounting.d.ts +24 -0
  23. package/dist/engine/account/accountingSchemas.d.ts +2056 -0
  24. package/dist/engine/account/activity.d.ts +42 -0
  25. package/dist/engine/account/activitySchemas.d.ts +327 -0
  26. package/dist/engine/account/amountSchemas.d.ts +9 -0
  27. package/dist/engine/account/catalogSchemas.d.ts +108 -0
  28. package/dist/engine/account/client.d.ts +14 -0
  29. package/dist/engine/account/history.d.ts +40 -0
  30. package/dist/engine/account/historySchemas.d.ts +251 -0
  31. package/dist/engine/account/management.d.ts +13 -0
  32. package/dist/engine/account/portfolioSchemas.d.ts +712 -0
  33. package/dist/engine/account/positionPerformance.d.ts +18 -0
  34. package/dist/engine/account/positionPerformanceSchemas.d.ts +101 -0
  35. package/dist/engine/account/positionPnl.d.ts +18 -0
  36. package/dist/engine/account/positionPnlSchemas.d.ts +149 -0
  37. package/dist/engine/account/transactionHistory.d.ts +50 -0
  38. package/dist/engine/account/transactionSchemas.d.ts +101 -0
  39. package/dist/engine/account/transactions.d.ts +26 -0
  40. package/dist/engine/account/transport.d.ts +31 -0
  41. package/dist/engine/account/types.d.ts +39 -0
  42. package/dist/engine/actions.d.ts +14 -4
  43. package/dist/engine/adaptiveFee.d.ts +14 -0
  44. package/dist/engine/balancedLending.d.ts +82 -0
  45. package/dist/engine/borrowCollateralFloor.d.ts +3 -0
  46. package/dist/engine/borrowLimits.d.ts +18 -0
  47. package/dist/engine/dataSource.d.ts +2 -0
  48. package/dist/engine/index.d.ts +20 -0
  49. package/dist/engine/marketAdapter.d.ts +3 -0
  50. package/dist/engine/marketSeries.d.ts +61 -0
  51. package/dist/engine/marketSeriesSchemas.d.ts +312 -0
  52. package/dist/engine/marketTrust.d.ts +26 -0
  53. package/dist/engine/openingEntry.d.ts +41 -0
  54. package/dist/engine/rateHistorySchemas.d.ts +88 -0
  55. package/dist/engine/reads.d.ts +1 -1
  56. package/dist/engine/registry.d.ts +1 -1
  57. package/dist/engine/restSchemas.d.ts +59 -1
  58. package/dist/engine/tradeExecutionSession.d.ts +155 -0
  59. package/dist/engine/types.d.ts +169 -15
  60. package/dist/engine/v4Quote.d.ts +5 -0
  61. package/dist/index.d.ts +13 -8
  62. package/dist/internal/guardedWalletTransaction.d.ts +31 -0
  63. package/dist/permit.d.ts +80 -6
  64. package/dist/quote/aggregatedSwapQuote.d.ts +5 -1
  65. package/dist/quote/kyberCalldata.d.ts +5 -1
  66. package/dist/{sdkRuntime-C_vaU-0g.js → sdkRuntime-3aRt_g55.js} +3385 -2957
  67. package/dist/services/kyberSwap.d.ts +12 -0
  68. package/dist/swap/authorizePermit.d.ts +11 -9
  69. package/dist/swap/executeSwapTransaction.d.ts +5 -1
  70. package/dist/swap/receiptWait.d.ts +9 -0
  71. package/dist/swap/sendSwapTransaction.d.ts +7 -0
  72. package/dist/swap/settlement.d.ts +4 -0
  73. package/dist/swap/trustedMarket.d.ts +25 -0
  74. package/dist/transactionHistory-1Zl2KCcV.js +5915 -0
  75. package/dist/transactionProgress.d.ts +41 -2
  76. package/dist/wallet.d.ts +5 -1
  77. package/package.json +12 -5
  78. package/dist/index-D9EfUokZ.js +0 -11031
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import type { Address, Hex } from 'viem';
3
+ import type { AegisEngineRestSource } from '../types.js';
4
+ import { PositionPerformanceResponseSchema } from './positionPerformanceSchemas.js';
5
+ export type AegisEnginePositionPerformance = z.infer<typeof PositionPerformanceResponseSchema>;
6
+ export type AegisEnginePositionPerformanceInput = {
7
+ source: AegisEngineRestSource;
8
+ account: Address;
9
+ chainId: number;
10
+ poolId: Hex;
11
+ vaultId: string;
12
+ snapshotId: string;
13
+ portfolioSnapshotId?: string;
14
+ signal?: AbortSignal;
15
+ };
16
+ /** One frozen accounting/portfolio pair. The caller captures portfolio first
17
+ * for an open position and never substitutes local mark-price calculations. */
18
+ export declare function fetchEnginePositionPerformance(input: AegisEnginePositionPerformanceInput): Promise<AegisEnginePositionPerformance>;
@@ -0,0 +1,101 @@
1
+ import { z } from 'zod';
2
+ export declare const PositionPerformanceResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ status: z.ZodLiteral<"unavailable">;
4
+ reason: z.ZodString;
5
+ schemaVersion: z.ZodLiteral<"1">;
6
+ modelVersion: z.ZodLiteral<"position-usd-performance-v1">;
7
+ snapshotId: z.ZodString;
8
+ portfolioSnapshotId: z.ZodNullable<z.ZodString>;
9
+ chainId: z.ZodNumber;
10
+ account: z.ZodString;
11
+ poolId: z.ZodString;
12
+ vaultId: z.ZodString;
13
+ capturedAt: z.ZodString;
14
+ expiresAt: z.ZodString;
15
+ canonicality: z.ZodLiteral<"rpc-checked-at-capture">;
16
+ finality: z.ZodLiteral<"not-a-finality-verdict">;
17
+ }, z.core.$strict>, z.ZodObject<{
18
+ status: z.ZodLiteral<"estimated">;
19
+ positionStatus: z.ZodEnum<{
20
+ open: "open";
21
+ closed: "closed";
22
+ }>;
23
+ denomination: z.ZodLiteral<"USD">;
24
+ basis: z.ZodLiteral<"equity-plus-withdrawals-minus-contributions">;
25
+ roiBasis: z.ZodLiteral<"initial-net-contribution">;
26
+ asOf: z.ZodString;
27
+ equityUsd: z.ZodString;
28
+ contributionUsd: z.ZodString;
29
+ withdrawalsUsd: z.ZodString;
30
+ pnlUsd: z.ZodString;
31
+ roiPercent: z.ZodString;
32
+ costs: z.ZodObject<{
33
+ tradingAndBorrowing: z.ZodLiteral<"embedded-in-equity-and-cashflows">;
34
+ gas: z.ZodLiteral<"excluded">;
35
+ }, z.core.$strict>;
36
+ coverage: z.ZodLiteral<"single-opening-no-intermediate-mutations">;
37
+ equityFrame: z.ZodNullable<z.ZodObject<{
38
+ blockNumber: z.ZodNumber;
39
+ blockHash: z.ZodString;
40
+ blockTimestamp: z.ZodNumber;
41
+ deployment: z.ZodString;
42
+ }, z.core.$strict>>;
43
+ currentPrices: z.ZodArray<z.ZodObject<{
44
+ id: z.ZodString;
45
+ chainId: z.ZodNumber;
46
+ address: z.ZodString;
47
+ decimals: z.ZodNullable<z.ZodNumber>;
48
+ symbol: z.ZodNullable<z.ZodString>;
49
+ status: z.ZodEnum<{
50
+ unavailable: "unavailable";
51
+ observed: "observed";
52
+ assumed: "assumed";
53
+ }>;
54
+ priceUsd: z.ZodNullable<z.ZodString>;
55
+ reasons: z.ZodArray<z.ZodString>;
56
+ source: z.ZodNullable<z.ZodEnum<{
57
+ custom: "custom";
58
+ coingecko: "coingecko";
59
+ configured_peg: "configured_peg";
60
+ pool: "pool";
61
+ cross_chain: "cross_chain";
62
+ }>>;
63
+ observedAt: z.ZodNullable<z.ZodString>;
64
+ fetchedAt: z.ZodNullable<z.ZodString>;
65
+ resolvedAt: z.ZodNullable<z.ZodString>;
66
+ recordedAt: z.ZodNullable<z.ZodString>;
67
+ effectiveObservedAt: z.ZodNullable<z.ZodString>;
68
+ assumptions: z.ZodArray<z.ZodString>;
69
+ dependencies: z.ZodArray<z.ZodObject<{
70
+ tokenId: z.ZodString;
71
+ effectiveObservedAt: z.ZodNullable<z.ZodString>;
72
+ }, z.core.$strict>>;
73
+ }, z.core.$strict>>;
74
+ historicalPrices: z.ZodArray<z.ZodObject<{
75
+ phase: z.ZodEnum<{
76
+ open: "open";
77
+ close: "close";
78
+ }>;
79
+ address: z.ZodString;
80
+ decimals: z.ZodNumber;
81
+ priceUsd: z.ZodString;
82
+ transactionTimestamp: z.ZodNumber;
83
+ bucketStart: z.ZodNumber;
84
+ bucketSeconds: z.ZodLiteral<43200>;
85
+ source: z.ZodLiteral<"historical-token-prices">;
86
+ observationTime: z.ZodNull;
87
+ }, z.core.$strict>>;
88
+ assumptions: z.ZodArray<z.ZodString>;
89
+ schemaVersion: z.ZodLiteral<"1">;
90
+ modelVersion: z.ZodLiteral<"position-usd-performance-v1">;
91
+ snapshotId: z.ZodString;
92
+ portfolioSnapshotId: z.ZodNullable<z.ZodString>;
93
+ chainId: z.ZodNumber;
94
+ account: z.ZodString;
95
+ poolId: z.ZodString;
96
+ vaultId: z.ZodString;
97
+ capturedAt: z.ZodString;
98
+ expiresAt: z.ZodString;
99
+ canonicality: z.ZodLiteral<"rpc-checked-at-capture">;
100
+ finality: z.ZodLiteral<"not-a-finality-verdict">;
101
+ }, z.core.$strict>], "status">;
@@ -0,0 +1,18 @@
1
+ import { type Address, type Hex } from 'viem';
2
+ import { z } from 'zod';
3
+ import type { AegisEngineRestSource } from '../types.js';
4
+ import { PositionPnlResponseSchema } from './positionPnlSchemas.js';
5
+ export type AegisEnginePositionPnl = z.infer<typeof PositionPnlResponseSchema>;
6
+ export type AegisEnginePositionPnlInput = {
7
+ source: AegisEngineRestSource;
8
+ account: Address;
9
+ chainId: number;
10
+ poolId: Hex;
11
+ vaultId: string;
12
+ /** A retained snapshot returned by fetchEnginePositionAccounting for this vault. */
13
+ snapshotId: string;
14
+ signal?: AbortSignal;
15
+ };
16
+ /** One bounded read of closed-trade token cash flows. Does not refresh accounting,
17
+ * poll, fetch prices or turn partial fee coverage into total economic PnL. */
18
+ export declare function fetchEnginePositionPnl(input: AegisEnginePositionPnlInput): Promise<AegisEnginePositionPnl>;
@@ -0,0 +1,149 @@
1
+ import { z } from 'zod';
2
+ export declare const PositionPnlSettlementSchema: z.ZodObject<{
3
+ phase: z.ZodEnum<{
4
+ open: "open";
5
+ close: "close";
6
+ }>;
7
+ transactionHash: z.ZodString;
8
+ block: z.ZodObject<{
9
+ number: z.ZodNumber;
10
+ hash: z.ZodString;
11
+ timestamp: z.ZodNumber;
12
+ transactionIndex: z.ZodNumber;
13
+ }, z.core.$strict>;
14
+ paid: z.ZodObject<{
15
+ amount0Raw: z.ZodString;
16
+ amount1Raw: z.ZodString;
17
+ }, z.core.$strict>;
18
+ received: z.ZodObject<{
19
+ amount0Raw: z.ZodString;
20
+ amount1Raw: z.ZodString;
21
+ }, z.core.$strict>;
22
+ net: z.ZodObject<{
23
+ amount0Raw: z.ZodString;
24
+ amount1Raw: z.ZodString;
25
+ }, z.core.$strict>;
26
+ executionGasFeeWei: z.ZodString;
27
+ }, z.core.$strict>;
28
+ export declare const PositionPnlResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ status: z.ZodLiteral<"unavailable">;
30
+ reason: z.ZodEnum<{
31
+ "incomplete-accounting": "incomplete-accounting";
32
+ "incomplete-ownership": "incomplete-ownership";
33
+ "position-not-closed": "position-not-closed";
34
+ "unsupported-lifecycle": "unsupported-lifecycle";
35
+ "settlement-unavailable": "settlement-unavailable";
36
+ "native-settlement-unavailable": "native-settlement-unavailable";
37
+ }>;
38
+ schemaVersion: z.ZodLiteral<"1">;
39
+ modelVersion: z.ZodLiteral<"closed-tap-token-pnl-v1">;
40
+ snapshotId: z.ZodString;
41
+ chainId: z.ZodNumber;
42
+ account: z.ZodString;
43
+ poolId: z.ZodString;
44
+ vaultId: z.ZodString;
45
+ capturedAt: z.ZodString;
46
+ expiresAt: z.ZodString;
47
+ canonicality: z.ZodLiteral<"rpc-checked-at-capture">;
48
+ finality: z.ZodLiteral<"not-a-finality-verdict">;
49
+ }, z.core.$strict>, z.ZodObject<{
50
+ status: z.ZodLiteral<"token-pnl">;
51
+ basis: z.ZodLiteral<"closed-position-wallet-cashflows">;
52
+ key: z.ZodObject<{
53
+ currency0: z.ZodString;
54
+ currency1: z.ZodString;
55
+ fee: z.ZodNumber;
56
+ tickSpacing: z.ZodNumber;
57
+ hooks: z.ZodString;
58
+ }, z.core.$strict>;
59
+ opening: z.ZodObject<{
60
+ phase: z.ZodEnum<{
61
+ open: "open";
62
+ close: "close";
63
+ }>;
64
+ transactionHash: z.ZodString;
65
+ block: z.ZodObject<{
66
+ number: z.ZodNumber;
67
+ hash: z.ZodString;
68
+ timestamp: z.ZodNumber;
69
+ transactionIndex: z.ZodNumber;
70
+ }, z.core.$strict>;
71
+ paid: z.ZodObject<{
72
+ amount0Raw: z.ZodString;
73
+ amount1Raw: z.ZodString;
74
+ }, z.core.$strict>;
75
+ received: z.ZodObject<{
76
+ amount0Raw: z.ZodString;
77
+ amount1Raw: z.ZodString;
78
+ }, z.core.$strict>;
79
+ net: z.ZodObject<{
80
+ amount0Raw: z.ZodString;
81
+ amount1Raw: z.ZodString;
82
+ }, z.core.$strict>;
83
+ executionGasFeeWei: z.ZodString;
84
+ }, z.core.$strict>;
85
+ closing: z.ZodObject<{
86
+ phase: z.ZodEnum<{
87
+ open: "open";
88
+ close: "close";
89
+ }>;
90
+ transactionHash: z.ZodString;
91
+ block: z.ZodObject<{
92
+ number: z.ZodNumber;
93
+ hash: z.ZodString;
94
+ timestamp: z.ZodNumber;
95
+ transactionIndex: z.ZodNumber;
96
+ }, z.core.$strict>;
97
+ paid: z.ZodObject<{
98
+ amount0Raw: z.ZodString;
99
+ amount1Raw: z.ZodString;
100
+ }, z.core.$strict>;
101
+ received: z.ZodObject<{
102
+ amount0Raw: z.ZodString;
103
+ amount1Raw: z.ZodString;
104
+ }, z.core.$strict>;
105
+ net: z.ZodObject<{
106
+ amount0Raw: z.ZodString;
107
+ amount1Raw: z.ZodString;
108
+ }, z.core.$strict>;
109
+ executionGasFeeWei: z.ZodString;
110
+ }, z.core.$strict>;
111
+ totals: z.ZodObject<{
112
+ paid: z.ZodObject<{
113
+ amount0Raw: z.ZodString;
114
+ amount1Raw: z.ZodString;
115
+ }, z.core.$strict>;
116
+ received: z.ZodObject<{
117
+ amount0Raw: z.ZodString;
118
+ amount1Raw: z.ZodString;
119
+ }, z.core.$strict>;
120
+ net: z.ZodObject<{
121
+ amount0Raw: z.ZodString;
122
+ amount1Raw: z.ZodString;
123
+ }, z.core.$strict>;
124
+ executionGasFeeWei: z.ZodString;
125
+ }, z.core.$strict>;
126
+ costs: z.ZodObject<{
127
+ tradingAndBorrowing: z.ZodLiteral<"embedded-in-cashflows">;
128
+ gasCoverage: z.ZodLiteral<"opening-and-closing-execution-only">;
129
+ totalTransactionCost: z.ZodLiteral<"unavailable">;
130
+ }, z.core.$strict>;
131
+ historicalUsdPnl: z.ZodNull;
132
+ netEconomicPnl: z.ZodLiteral<"unavailable">;
133
+ schemaVersion: z.ZodLiteral<"1">;
134
+ modelVersion: z.ZodLiteral<"closed-tap-token-pnl-v1">;
135
+ snapshotId: z.ZodString;
136
+ chainId: z.ZodNumber;
137
+ account: z.ZodString;
138
+ poolId: z.ZodString;
139
+ vaultId: z.ZodString;
140
+ capturedAt: z.ZodString;
141
+ expiresAt: z.ZodString;
142
+ canonicality: z.ZodLiteral<"rpc-checked-at-capture">;
143
+ finality: z.ZodLiteral<"not-a-finality-verdict">;
144
+ }, z.core.$strict>], "status">;
145
+ export type PositionPnlResponse = z.infer<typeof PositionPnlResponseSchema>;
146
+ export declare const PositionPnlErrorSchema: z.ZodObject<{
147
+ error: z.ZodLiteral<"Engine PnL unavailable">;
148
+ code: z.ZodString;
149
+ }, z.core.$strict>;
@@ -0,0 +1,50 @@
1
+ import type { Hex, PublicClient } from 'viem';
2
+ import { type AegisEngineTransactionRecord, type AegisEngineTransactionScope } from './transactions.js';
3
+ /** Metadata only. Browser Storage and synchronous host stores use the same contract. */
4
+ export type AegisEngineTransactionStorage = {
5
+ getItem(key: string): string | null;
6
+ setItem(key: string, value: string): void;
7
+ };
8
+ export type AegisEngineTransactionHistorySnapshot = Readonly<{
9
+ records: readonly AegisEngineTransactionRecord[];
10
+ pending: readonly AegisEngineTransactionRecord[];
11
+ blockingPending: readonly AegisEngineTransactionRecord[];
12
+ acknowledgeable: readonly AegisEngineTransactionRecord[];
13
+ restored: boolean;
14
+ error: boolean;
15
+ checking: boolean;
16
+ }>;
17
+ type ReceiptClient = Pick<PublicClient, 'chain' | 'waitForTransactionReceipt'>;
18
+ export declare function serializeEngineTransactionRecords(records: readonly AegisEngineTransactionRecord[], scope: AegisEngineTransactionScope): string;
19
+ /** A fixed wallet/chain owns this history for its entire lifetime. Restores,
20
+ * replacement chains and read-only receipt recovery share the same rules in
21
+ * React, server/Node and custom browser consumers. No send/sign path exists. */
22
+ export declare function createEngineTransactionHistory({ scope: inputScope, storage: initialStorage }: {
23
+ scope: AegisEngineTransactionScope;
24
+ storage?: AegisEngineTransactionStorage | null;
25
+ }): {
26
+ key: string;
27
+ getSnapshot: () => Readonly<{
28
+ records: readonly AegisEngineTransactionRecord[];
29
+ pending: readonly AegisEngineTransactionRecord[];
30
+ blockingPending: readonly AegisEngineTransactionRecord[];
31
+ acknowledgeable: readonly AegisEngineTransactionRecord[];
32
+ restored: boolean;
33
+ error: boolean;
34
+ checking: boolean;
35
+ }>;
36
+ subscribe: (listener: () => void) => () => void;
37
+ restore: (eventValue?: string | null) => void;
38
+ setStorage: (next: AegisEngineTransactionStorage | null) => void;
39
+ upsert: (record: AegisEngineTransactionRecord) => void;
40
+ checkPendingTransactions: (publicClient: ReceiptClient, { signal, timeoutMs }?: {
41
+ signal?: AbortSignal;
42
+ timeoutMs?: number;
43
+ }) => Promise<{
44
+ checked: number;
45
+ settled: number;
46
+ }>;
47
+ acknowledgeUnresolvedTransaction: (hash: Hex) => boolean;
48
+ };
49
+ export type AegisEngineTransactionHistory = ReturnType<typeof createEngineTransactionHistory>;
50
+ export {};
@@ -0,0 +1,101 @@
1
+ import { z } from 'zod';
2
+ export declare const TransactionQuerySchema: z.ZodObject<{
3
+ account: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4
+ chainIds: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number[], string>>, z.ZodTransform<number[], number[]>>;
5
+ chainId: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
6
+ txHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
7
+ observedBlockNumber: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
8
+ observedBlockHash: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
9
+ }, z.core.$strip>;
10
+ export type TransactionQuery = z.infer<typeof TransactionQuerySchema>;
11
+ export declare const TransactionReceiptSchema: z.ZodObject<{
12
+ transactionHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
13
+ from: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
14
+ to: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
15
+ blockNumber: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
16
+ blockHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
17
+ transactionIndex: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
18
+ status: z.ZodEnum<{
19
+ "0x0": "0x0";
20
+ "0x1": "0x1";
21
+ }>;
22
+ logs: z.ZodArray<z.ZodObject<{
23
+ address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
24
+ topics: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
25
+ data: z.ZodString;
26
+ blockNumber: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
27
+ blockHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
28
+ transactionHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
29
+ transactionIndex: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
30
+ logIndex: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
31
+ removed: z.ZodLiteral<false>;
32
+ }, z.core.$strip>>;
33
+ }, z.core.$strip>;
34
+ export type TransactionReceipt = z.infer<typeof TransactionReceiptSchema>;
35
+ export declare const TransactionStatusSchema: z.ZodObject<{
36
+ schemaVersion: z.ZodLiteral<"1">;
37
+ chainId: z.ZodNumber;
38
+ txHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
39
+ account: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
40
+ chainIds: z.ZodArray<z.ZodNumber>;
41
+ status: z.ZodEnum<{
42
+ unknown: "unknown";
43
+ reverted: "reverted";
44
+ confirmed: "confirmed";
45
+ ready: "ready";
46
+ indexing: "indexing";
47
+ reorged: "reorged";
48
+ unsupported: "unsupported";
49
+ }>;
50
+ checkedAt: z.ZodString;
51
+ retryAfterSeconds: z.ZodLiteral<5>;
52
+ reasons: z.ZodArray<z.ZodString>;
53
+ receipt: z.ZodNullable<z.ZodObject<{
54
+ blockNumber: z.ZodNumber;
55
+ blockHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
56
+ transactionIndex: z.ZodNumber;
57
+ from: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
58
+ to: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
59
+ succeeded: z.ZodBoolean;
60
+ canonicality: z.ZodEnum<{
61
+ "checked-at-read": "checked-at-read";
62
+ changed: "changed";
63
+ }>;
64
+ }, z.core.$strict>>;
65
+ indexed: z.ZodNullable<z.ZodObject<{
66
+ frame: z.ZodObject<{
67
+ blockNumber: z.ZodNumber;
68
+ blockHash: z.ZodString;
69
+ blockTimestamp: z.ZodNumber;
70
+ deployment: z.ZodString;
71
+ }, z.core.$strict>;
72
+ expectedEvents: z.ZodNumber;
73
+ acknowledgedEvents: z.ZodNumber;
74
+ }, z.core.$strict>>;
75
+ portfolio: z.ZodNullable<z.ZodObject<{
76
+ snapshotId: z.ZodString;
77
+ createdAt: z.ZodString;
78
+ expiresAt: z.ZodString;
79
+ status: z.ZodEnum<{
80
+ partial: "partial";
81
+ complete: "complete";
82
+ }>;
83
+ chainIds: z.ZodArray<z.ZodNumber>;
84
+ frame: z.ZodObject<{
85
+ blockNumber: z.ZodNumber;
86
+ blockHash: z.ZodString;
87
+ blockTimestamp: z.ZodNumber;
88
+ deployment: z.ZodString;
89
+ }, z.core.$strict>;
90
+ acknowledged: z.ZodBoolean;
91
+ }, z.core.$strict>>;
92
+ finality: z.ZodLiteral<"checked-at-read-not-finalized">;
93
+ }, z.core.$strict>;
94
+ export declare const TransactionStatusErrorSchema: z.ZodObject<{
95
+ error: z.ZodLiteral<"Engine transaction status unavailable">;
96
+ code: z.ZodString;
97
+ status: z.ZodEnum<{
98
+ unavailable: "unavailable";
99
+ rate_limited: "rate_limited";
100
+ }>;
101
+ }, z.core.$strict>;
@@ -0,0 +1,26 @@
1
+ import type { Address, Hex } from 'viem';
2
+ export type AegisEngineTransactionScope = {
3
+ chainId: number;
4
+ account: Address;
5
+ };
6
+ export type AegisEngineTransactionRecord = AegisEngineTransactionScope & {
7
+ hash: Hex;
8
+ /** Superseded hashes preserve identity across replacement and storage merges. */
9
+ replacedHashes?: Hex[];
10
+ stage?: 'authorization' | 'action';
11
+ /** User accepted the risk of starting new actions while this hash is unresolved. */
12
+ recoveryAcknowledgedAt?: number;
13
+ executionChanged?: boolean;
14
+ kind: 'swap' | 'lend' | 'borrow' | 'trade';
15
+ status: 'submitted' | 'success' | 'reverted' | 'cancelled';
16
+ title: string;
17
+ detail: string;
18
+ createdAt: number;
19
+ };
20
+ export declare function engineTransactionStorageKey(scope: AegisEngineTransactionScope): string;
21
+ /** Display metadata and identity only. Unknown fields, including signatures,
22
+ * permits and calldata, are rejected before the record reaches a consumer. */
23
+ export declare function parseEngineTransactionRecords(value: string | null, scope: AegisEngineTransactionScope): AegisEngineTransactionRecord[];
24
+ /** Pending identities are never evicted for completed history. A repeated
25
+ * submitted notification cannot weaken a receipt-backed outcome. */
26
+ export declare function mergeEngineTransactionRecord(records: readonly AegisEngineTransactionRecord[], next: AegisEngineTransactionRecord): AegisEngineTransactionRecord[];
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ import type { AegisEngineAccountReadInput } from './types.js';
3
+ export declare class AegisEngineAccountReadError extends Error {
4
+ readonly code: string;
5
+ readonly status: number;
6
+ readonly retryAfterSeconds: number | null;
7
+ readonly name = "AegisEngineAccountReadError";
8
+ constructor(code: string, status?: number, retryAfterSeconds?: number | null);
9
+ }
10
+ export declare function parseEngineRetryAfter(retryHeader: string | null, cap?: number): number | null;
11
+ export type ReadContext = {
12
+ input: AegisEngineAccountReadInput;
13
+ query: {
14
+ account: string;
15
+ chainIds: number[];
16
+ };
17
+ baseUrl: string;
18
+ signal: AbortSignal | undefined;
19
+ remainingBytes: number;
20
+ };
21
+ export declare function invalidResponse(): never;
22
+ export declare function sameChains(actual: readonly number[], expected: readonly number[]): boolean;
23
+ export declare function withAccountRead<T>(input: AegisEngineAccountReadInput, read: (context: ReadContext) => Promise<T>): Promise<T>;
24
+ export declare function readResponse<T>(context: ReadContext, path: string, extra: Record<string, string>, schema: z.ZodType<T>, options?: {
25
+ omitChainIds?: boolean;
26
+ responseLimit?: number;
27
+ }): Promise<T>;
28
+ export declare function assertScope(context: ReadContext, payload: {
29
+ account: string;
30
+ chainIds: number[];
31
+ }): void;
@@ -0,0 +1,39 @@
1
+ import type { z } from 'zod';
2
+ import type { Address, Hex } from 'viem';
3
+ import type { AegisEngineRestSource } from '../types.js';
4
+ import type { ActivityPageResponseSchema, ActivityEventSchema } from './activitySchemas.js';
5
+ import type { PortfolioResponseSchema, PortfolioPositionSchema, PortfolioMetricSchema, PortfolioPriceMarkSchema } from './portfolioSchemas.js';
6
+ import type { TransactionStatusSchema } from './transactionSchemas.js';
7
+ export type AegisEnginePortfolioPosition = z.output<typeof PortfolioPositionSchema>;
8
+ export type AegisEnginePortfolioMetric = z.output<typeof PortfolioMetricSchema>;
9
+ export type AegisEnginePortfolioPrice = z.output<typeof PortfolioPriceMarkSchema>;
10
+ export type AegisEngineAccountPortfolio = Omit<z.output<typeof PortfolioResponseSchema>, 'page'> & {
11
+ /** Every page belongs to this snapshot; no partial page accumulation is returned. */
12
+ positions: AegisEnginePortfolioPosition[];
13
+ performance: {
14
+ status: 'unavailable';
15
+ reason: 'cashflow-cost-basis-unavailable';
16
+ };
17
+ };
18
+ export type AegisEngineAccountActivityEvent = z.output<typeof ActivityEventSchema>;
19
+ export type AegisEngineAccountActivityPage = z.output<typeof ActivityPageResponseSchema>;
20
+ export type AegisEngineTransactionStatus = z.output<typeof TransactionStatusSchema>;
21
+ export type AegisEngineAccountReadInput = {
22
+ source: AegisEngineRestSource;
23
+ account: Address;
24
+ /** Distinct host-selected Engine chains. Each is retained in coverage. */
25
+ chainIds: readonly number[];
26
+ signal?: AbortSignal;
27
+ };
28
+ export type AegisEngineTransactionStatusInput = AegisEngineAccountReadInput & {
29
+ chainId: number;
30
+ txHash: Hex;
31
+ /** Optional previously observed receipt identity. Supply both fields together. */
32
+ observedReceipt?: {
33
+ blockNumber: number;
34
+ blockHash: Hex;
35
+ };
36
+ };
37
+ /** Identity for a persisted transaction; hashes alone are not cross-chain identities. */
38
+ export declare function engineAccountTransactionKey(chainId: number, txHash: string): string;
39
+ export declare function engineAccountPositionKey(position: Pick<AegisEnginePortfolioPosition, 'kind' | 'chainId' | 'engine' | 'vaultRegistry' | 'vaultId' | 'poolId'>, account: string): string;
@@ -12,8 +12,11 @@ export declare function engineTokenGrantSatisfies(args: {
12
12
  spendAmount: bigint;
13
13
  approvalMode: 'exact' | 'max';
14
14
  }): boolean;
15
- /** Mode-aware satisfaction for the Permit2 → router cap. `max` requires an
16
- * effectively unlimited amount that is also not about to expire. */
15
+ /** Mode-aware satisfaction for the Permit2 → router cap, on the same rule the
16
+ * swap path uses: `max` requires an effectively unlimited amount, `exact`
17
+ * requires coverage, and both require a cap that outlives the tx deadline. A
18
+ * zero-amount draft asks only whether any live grant stands, so 1n stands in
19
+ * for the amount and a revoked cap still fails. */
17
20
  export declare function enginePermit2GrantSatisfies(args: {
18
21
  allowance: Awaited<ReturnType<typeof readPermit2RouterAllowance>>;
19
22
  spendAmount: bigint;
@@ -30,7 +33,9 @@ export type AegisEnginePositionRouterAuthorizationInput = {
30
33
  /** Cancels preparation before the authorization transaction is broadcast. */
31
34
  signal?: AegisEngineSendInput['signal'];
32
35
  onStatus?: AegisEngineActionCallbacks['onStatus'];
36
+ onWalletRequest?: AegisEngineActionCallbacks['onWalletRequest'];
33
37
  onTxHash?: AegisEngineActionCallbacks['onTxHash'];
38
+ onTransactionObservation?: AegisEngineActionCallbacks['onTransactionObservation'];
34
39
  };
35
40
  /**
36
41
  * Read the wallet actions required to open a fresh Long/Short position.
@@ -50,12 +55,16 @@ export type AegisEnginePositionRouterAuthorizationInput = {
50
55
  * executable quote after prerequisite receipts are mined.
51
56
  */
52
57
  export declare function readEngineAuthorizationPlan(args: AegisEngineAuthorizationPlanInput): Promise<AegisEngineAuthorizationPlan>;
58
+ type EngineAllowanceUpdateInput = AegisEngineApprovalInput & {
59
+ replaceAllowance?: boolean;
60
+ revokeAllowance?: boolean;
61
+ };
53
62
  /** Grants only the ERC-20 allowance from the token to Permit2. */
54
- export declare function approveEngineTokenToPermit2(args: AegisEngineApprovalInput): Promise<{
63
+ export declare function approveEngineTokenToPermit2(args: EngineAllowanceUpdateInput): Promise<{
55
64
  approvalHash: Hex | null;
56
65
  }>;
57
66
  /** Grants only the Permit2 spending cap from Permit2 to the Engine router. */
58
- export declare function approveEnginePermit2ToRouter(args: AegisEngineApprovalInput): Promise<void>;
67
+ export declare function approveEnginePermit2ToRouter(args: EngineAllowanceUpdateInput): Promise<void>;
59
68
  export declare function prepareEnginePermit(args: AegisEngineApprovalInput): Promise<{
60
69
  approvalHash: Hex | null;
61
70
  permit: AegisEngineSignedPermitBatch | null;
@@ -99,3 +108,4 @@ export declare function missingEngineExecutionReason(market: {
99
108
  v4StateView?: Address;
100
109
  v4Quoter?: Address;
101
110
  }): string | null;
111
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { PublicClient } from 'viem';
2
+ import type { AegisEngineAdaptiveFeeEvidence, AegisEngineMarket } from './types.js';
3
+ /**
4
+ * Read the Engine v1.0.3 dynamic-fee state at the same block as a quote.
5
+ *
6
+ * `adaptiveTickThresholdTicks` is deliberately not called a price limit. The
7
+ * deployed Hook evaluates it after the swap and uses a breach to update surge
8
+ * state; it does not clamp or revert the transaction that crossed it.
9
+ */
10
+ export declare function readEngineAdaptiveFeeEvidence(input: Readonly<{
11
+ publicClient: PublicClient;
12
+ market: AegisEngineMarket;
13
+ blockNumber: bigint;
14
+ }>): Promise<AegisEngineAdaptiveFeeEvidence>;