@aegis-engine/core 0.5.0 → 0.7.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 +71 -3
- package/dist/actions/directPoolSwap.d.ts +3 -0
- package/dist/actions/kyberSwap.d.ts +1 -0
- package/dist/actions/types.d.ts +60 -0
- package/dist/aegis-core.js +165 -155
- package/dist/engine/actions.d.ts +7 -2
- package/dist/engine/borrowCollateralFloor.d.ts +3 -0
- package/dist/engine/borrowLimits.d.ts +18 -0
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/lendHistory.d.ts +21 -0
- package/dist/engine/simpleYield.d.ts +39 -0
- package/dist/engine/types.d.ts +63 -1
- package/dist/errors.d.ts +13 -2
- package/dist/{index-DuoaODpB.js → index-DofKgro2.js} +4204 -3703
- package/dist/index.d.ts +8 -4
- package/dist/permit.d.ts +6 -0
- package/dist/{sdkRuntime-DeaRALj3.js → sdkRuntime-BE3ZMb5o.js} +370 -369
- package/dist/swap/authorizePermit.d.ts +5 -1
- package/dist/swap/receiptWait.d.ts +26 -3
- package/dist/swap/sendSwapTransaction.d.ts +13 -0
- package/dist/swap/settlement.d.ts +4 -0
- package/dist/transactionProgress.d.ts +80 -3
- package/dist/wallet.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AegisEngineLendPositionHydration, AegisEngineLendSharesPosition, AegisEngineMarket, AegisEngineMetricHistory } from './types.js';
|
|
2
|
+
export type AegisEngineSimpleYieldPositionSummaryInput = Readonly<{
|
|
3
|
+
position: AegisEngineLendSharesPosition | null;
|
|
4
|
+
market: AegisEngineMarket;
|
|
5
|
+
hydration?: AegisEngineLendPositionHydration;
|
|
6
|
+
history?: AegisEngineMetricHistory | null;
|
|
7
|
+
additionalValueUsd?: number | null;
|
|
8
|
+
/** Override the current time for deterministic freshness checks. */
|
|
9
|
+
nowMs?: number;
|
|
10
|
+
}>;
|
|
11
|
+
export type AegisEngineSimpleYieldPositionSummary = Readonly<{
|
|
12
|
+
hasPosition: boolean;
|
|
13
|
+
valuation: Readonly<{
|
|
14
|
+
shareFraction: number;
|
|
15
|
+
suppliedUsd: number;
|
|
16
|
+
currentValueUsd: number;
|
|
17
|
+
source: 'live-shares' | 'indexed-shares';
|
|
18
|
+
}> | null;
|
|
19
|
+
projection: Readonly<{
|
|
20
|
+
addedValueUsd: number;
|
|
21
|
+
projectedValueUsd: number;
|
|
22
|
+
}> | null;
|
|
23
|
+
growth: Readonly<{
|
|
24
|
+
weeklyEarningsPer100Usd: number;
|
|
25
|
+
currentWeeklyEarningsUsd: number | null;
|
|
26
|
+
projectedWeeklyEarningsUsd: number | null;
|
|
27
|
+
coverageSeconds: number;
|
|
28
|
+
stale: boolean;
|
|
29
|
+
}> | null;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Summarizes an Engine lend-share position for a simple-yield surface.
|
|
33
|
+
*
|
|
34
|
+
* Live share hydration wins over indexed share balances. Realized weekly
|
|
35
|
+
* growth comes only from share-price history, never from the market's modeled
|
|
36
|
+
* `lendApyPct`. Existing positions fail closed when their value is unavailable,
|
|
37
|
+
* so an add-funds preview cannot accidentally present them as a fresh deposit.
|
|
38
|
+
*/
|
|
39
|
+
export declare function summarizeEngineSimpleYieldPosition(input: AegisEngineSimpleYieldPositionSummaryInput): AegisEngineSimpleYieldPositionSummary;
|
package/dist/engine/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address, Hex, PublicClient, TransactionReceipt } from 'viem';
|
|
2
2
|
import type { AegisSwapChainConfig, AegisSwapToken } from '../config/index.js';
|
|
3
3
|
import type { SignedPermitBatch } from '../encoding.js';
|
|
4
|
+
import type { ClassifiedError } from '../errors.js';
|
|
4
5
|
import type { WalletSession } from '../swap/types.js';
|
|
5
6
|
import type { AegisEngineTapInfeasibleReason, AegisEngineTapRootPolicy } from './trade/sizing.js';
|
|
6
7
|
export type AegisEngineMode = 'lend' | 'borrow' | 'positions';
|
|
@@ -455,6 +456,9 @@ export type AegisEngineRestSource = {
|
|
|
455
456
|
*/
|
|
456
457
|
export type AegisEngineStaticSource = {
|
|
457
458
|
kind: 'static';
|
|
459
|
+
/** Read current balances and vault state for supplied positions through the
|
|
460
|
+
* host's public client. Opt in for interactive simulation or host indexes. */
|
|
461
|
+
hydratePositions?: boolean;
|
|
458
462
|
markets: AegisEngineMarket[];
|
|
459
463
|
positions?: AegisEnginePosition[];
|
|
460
464
|
lendPositions?: AegisEngineLendSharesPosition[];
|
|
@@ -631,6 +635,10 @@ export type AegisEngineBorrowCapacityInput = Omit<AegisEngineQuoteBase, 'owner'
|
|
|
631
635
|
/** Optional output-first target. When supplied, the result includes the
|
|
632
636
|
* collateral floor for the deterministic no-swap path. */
|
|
633
637
|
borrowOut?: bigint;
|
|
638
|
+
/** Include wallet and market quick-fill limits in this same live frame. */
|
|
639
|
+
includeBorrowLimits?: boolean;
|
|
640
|
+
/** Spendable collateral after the native gas reserve; omitted when unknown. */
|
|
641
|
+
walletCollateralIn?: bigint;
|
|
634
642
|
tauPips?: number;
|
|
635
643
|
/** See `AegisEngineBorrowQuoteInput.tauPercentOfMaxLtv`. */
|
|
636
644
|
tauPercentOfMaxLtv?: number;
|
|
@@ -1119,6 +1127,24 @@ export type AegisEngineVaultActivityEntry = {
|
|
|
1119
1127
|
receivedRaw: bigint | null;
|
|
1120
1128
|
receivedIsToken0: boolean | null;
|
|
1121
1129
|
};
|
|
1130
|
+
/** Settled sizing result. A floor is planning data, never execution permission. */
|
|
1131
|
+
export type AegisEngineBorrowCollateralFloor = {
|
|
1132
|
+
status: 'not-requested';
|
|
1133
|
+
} | {
|
|
1134
|
+
status: 'ready-positive';
|
|
1135
|
+
amountIn: bigint;
|
|
1136
|
+
} | {
|
|
1137
|
+
status: 'ready-zero';
|
|
1138
|
+
amountIn: 0n;
|
|
1139
|
+
outputSource: 'existing-idle' | 'new-debt' | 'unknown';
|
|
1140
|
+
} | {
|
|
1141
|
+
status: 'infeasible';
|
|
1142
|
+
reason: 'utilization-capped';
|
|
1143
|
+
} | {
|
|
1144
|
+
status: 'unavailable';
|
|
1145
|
+
reason: 'closed-form-not-applicable' | 'forward-validation-unavailable' | 'legacy-no-floor';
|
|
1146
|
+
retryable: boolean;
|
|
1147
|
+
};
|
|
1122
1148
|
export type AegisEngineBorrowCapacity = {
|
|
1123
1149
|
kind: 'borrow-capacity';
|
|
1124
1150
|
market: AegisEngineMarket;
|
|
@@ -1134,16 +1160,25 @@ export type AegisEngineBorrowCapacity = {
|
|
|
1134
1160
|
tauPercentOfMaxLtv: number | null;
|
|
1135
1161
|
/** Echoed output target used to derive `minimumNoSwapCollateralIn`. */
|
|
1136
1162
|
borrowOut: bigint | null;
|
|
1137
|
-
/** Minimum
|
|
1163
|
+
/** Minimum deposit for the supplied vault that crosses the SDK's integer no-swap
|
|
1138
1164
|
* boundary. Null when no output target was supplied, no closed-form
|
|
1139
1165
|
* no-swap solution exists, or the market is utilization-capped. */
|
|
1140
1166
|
minimumNoSwapCollateralIn: bigint | null;
|
|
1167
|
+
/** Always emitted by quoteEngineBorrowCapacity; optional for older host snapshots. */
|
|
1168
|
+
collateralFloor?: AegisEngineBorrowCollateralFloor;
|
|
1169
|
+
/** Market frame used for sizing; vault inputs still need executable revalidation. */
|
|
1170
|
+
frame?: AegisEngineReadFrame;
|
|
1141
1171
|
/** Equals `capacity.utilizationPre >= capacity.utilizationCap` at quote
|
|
1142
1172
|
* time. Named (rather than derived by consumers) because the SDK's stage
|
|
1143
1173
|
* classifier can mask a cap block behind preserve-vs-allow reachability
|
|
1144
1174
|
* (`preserve-collateral-blocked`), so `bindingConstraint`/quote reasons
|
|
1145
1175
|
* can't be trusted for it. When true no borrow executes for any deposit
|
|
1146
1176
|
* and no collateral floor is published. */
|
|
1177
|
+
borrowLimits?: {
|
|
1178
|
+
walletCollateralIn: bigint | null;
|
|
1179
|
+
walletBorrowOut: bigint | null;
|
|
1180
|
+
marketBorrowOut: bigint;
|
|
1181
|
+
};
|
|
1147
1182
|
utilizationCapped: boolean;
|
|
1148
1183
|
capacity: {
|
|
1149
1184
|
yMaxLtv: bigint;
|
|
@@ -1228,6 +1263,12 @@ export type AegisEngineAuthorizationPlan = {
|
|
|
1228
1263
|
token: AegisEngineToken;
|
|
1229
1264
|
amount: bigint;
|
|
1230
1265
|
approvalMode: 'exact' | 'max';
|
|
1266
|
+
/** Read observations drive permission presentation only, never submission authority. */
|
|
1267
|
+
observations?: {
|
|
1268
|
+
erc20Allowance: bigint | null;
|
|
1269
|
+
permit2Allowance: readonly [bigint, number, number] | null;
|
|
1270
|
+
permit2AuthorizationMode: 'signature' | 'spending-cap';
|
|
1271
|
+
};
|
|
1231
1272
|
router: Address;
|
|
1232
1273
|
permit2: Address;
|
|
1233
1274
|
vaultRegistry: Address;
|
|
@@ -1256,6 +1297,25 @@ export type AegisEngineAuthorizationProgress = {
|
|
|
1256
1297
|
kind: AegisEngineAuthorizationStepKind;
|
|
1257
1298
|
status: 'requesting' | 'confirmed';
|
|
1258
1299
|
};
|
|
1300
|
+
/** Lifecycle evidence for one Engine permission request. */
|
|
1301
|
+
export type AegisEngineAuthorizationExecutionEvent = Readonly<{
|
|
1302
|
+
kind: AegisEngineAuthorizationStepKind;
|
|
1303
|
+
status: 'wallet-requested';
|
|
1304
|
+
hash: null;
|
|
1305
|
+
}> | Readonly<{
|
|
1306
|
+
kind: AegisEngineAuthorizationStepKind;
|
|
1307
|
+
status: 'submitted';
|
|
1308
|
+
hash: Hex;
|
|
1309
|
+
}> | Readonly<{
|
|
1310
|
+
kind: AegisEngineAuthorizationStepKind;
|
|
1311
|
+
status: 'confirmed';
|
|
1312
|
+
hash: Hex | null;
|
|
1313
|
+
}> | Readonly<{
|
|
1314
|
+
kind: AegisEngineAuthorizationStepKind;
|
|
1315
|
+
status: 'cancelled' | 'failed';
|
|
1316
|
+
hash: Hex | null;
|
|
1317
|
+
error: ClassifiedError;
|
|
1318
|
+
}>;
|
|
1259
1319
|
export type AegisEngineApprovalInput = {
|
|
1260
1320
|
wallet: AegisEngineWalletSession;
|
|
1261
1321
|
publicClient: PublicClient;
|
|
@@ -1271,6 +1331,8 @@ export type AegisEngineApprovalInput = {
|
|
|
1271
1331
|
onStatus?: AegisEngineActionCallbacks['onStatus'];
|
|
1272
1332
|
/** Fine-grained prerequisite progress for truthful wallet onboarding. */
|
|
1273
1333
|
onAuthorizationProgress?: (progress: AegisEngineAuthorizationProgress) => void;
|
|
1334
|
+
/** Full prerequisite lifecycle at the wallet and receipt boundaries. */
|
|
1335
|
+
onAuthorizationExecution?: (event: AegisEngineAuthorizationExecutionEvent) => void;
|
|
1274
1336
|
/** Awaited after each prerequisite receipt and before another wallet request. */
|
|
1275
1337
|
onAuthorizationCheckpoint?: () => Promise<void>;
|
|
1276
1338
|
};
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Hex } from 'viem';
|
|
2
2
|
/** Failure families the widget surfaces reason about (retry affordances,
|
|
3
3
|
toast dwell, explorer-link degradation) without string comparison. */
|
|
4
|
-
export type UserFacingErrorKind = 'rpc' | 'quote' | 'backend' | 'wallet-rejected' | 'wrong-chain' | 'tx-reverted' | 'tx-timeout' | 'market-not-ready' | 'validation' | 'unknown';
|
|
4
|
+
export type UserFacingErrorKind = 'rpc' | 'quote' | 'backend' | 'wallet-rejected' | 'tx-cancelled' | 'wrong-chain' | 'tx-reverted' | 'tx-timeout' | 'market-not-ready' | 'validation' | 'unknown';
|
|
5
5
|
export type ClassifiedError = {
|
|
6
6
|
message: string;
|
|
7
7
|
kind: UserFacingErrorKind;
|
|
@@ -15,8 +15,19 @@ export declare class UserFacingError extends Error {
|
|
|
15
15
|
retryable?: boolean;
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
export declare class
|
|
18
|
+
export declare class SubmittedTransactionReceiptError extends UserFacingError {
|
|
19
19
|
readonly hash: Hex;
|
|
20
|
+
readonly cause: unknown;
|
|
21
|
+
constructor({ hash, cause, message, kind }: {
|
|
22
|
+
hash: Hex;
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
message?: string;
|
|
25
|
+
kind?: UserFacingErrorKind;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** True only for Core receipt failures that happened after a known broadcast. */
|
|
29
|
+
export declare function isSubmittedTransactionReceiptError(error: unknown): error is SubmittedTransactionReceiptError;
|
|
30
|
+
export declare class TransactionReceiptTimeoutError extends SubmittedTransactionReceiptError {
|
|
20
31
|
constructor({ hash }: {
|
|
21
32
|
hash: Hex;
|
|
22
33
|
});
|