@aegis-engine/core 0.3.0 → 0.3.1

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.
@@ -5,3 +5,4 @@ export * from './registry.js';
5
5
  export * from './reads.js';
6
6
  export * from './quotes.js';
7
7
  export * from './actions.js';
8
+ export * from './positionAmounts.js';
@@ -0,0 +1,37 @@
1
+ /** Conservative cap to size a withdrawal preview against. */
2
+ export declare function enginePreviewMaxLtvPips(marketMaxLtvPips: number): number;
3
+ export type AegisEngineIdleWithdrawSide = 'token0' | 'token1';
4
+ export type AegisEngineIdleWithdrawAmountInput = {
5
+ /** Same-frame live idle token amounts. */
6
+ idle0: bigint;
7
+ idle1: bigint;
8
+ /**
9
+ * Same-frame accrued debt in L units, rounded up by position hydration.
10
+ * Using the rounded-up value makes this preview no less conservative than
11
+ * the Engine's exact rL × borrow-index residual check.
12
+ */
13
+ debtLLatest: bigint;
14
+ maxLtvPips: number;
15
+ side: AegisEngineIdleWithdrawSide;
16
+ };
17
+ /**
18
+ * Mirrors the idle-only residual-LTV inequality used by the Engine lifecycle
19
+ * quote. Engine idle balances are int128-packed, so their product fits uint256
20
+ * and `floor(sqrt(idle0 × idle1)) >= requiredFloor` is exactly equivalent to
21
+ * `idle0 × idle1 >= requiredFloor²`.
22
+ */
23
+ export declare function engineIdleWithdrawPassesResidualLtv(input: AegisEngineIdleWithdrawAmountInput): boolean;
24
+ /**
25
+ * Maximum independently withdrawable idle amount for one selected token.
26
+ * The opposite token remains untouched. This is a conservative preview; the
27
+ * exact amount is always re-quoted from a fresh block before submission.
28
+ */
29
+ export declare function computeEngineMaxIdleWithdraw(input: AegisEngineIdleWithdrawAmountInput): bigint;
30
+ /**
31
+ * Projected idle-only LTV after one exact withdrawal. Returns null for a
32
+ * debt-free vault or an invalid/zero-collateral post-state. The exact action
33
+ * remains quote-driven; this is display math over the same hydrated frame.
34
+ */
35
+ export declare function computeEngineIdleWithdrawPostLtvPips(input: AegisEngineIdleWithdrawAmountInput & {
36
+ withdrawAmount: bigint;
37
+ }): number | null;
@@ -1,6 +1,7 @@
1
- import type { AegisEngineBorrowCapacity, AegisEngineBorrowCapacityInput, AegisEngineBorrowQuote, AegisEngineBorrowQuoteInput, AegisEngineCloseQuoteInput, AegisEngineDepositQuote, AegisEngineDepositQuoteInput, AegisEngineIdleWithdrawQuoteInput, AegisEnginePositionActionQuote, AegisEngineRedeemQuoteInput, AegisEngineRepayQuoteInput } from './types.js';
1
+ import type { AegisEngineBorrowCapacity, AegisEngineBorrowCapacityInput, AegisEngineBorrowQuote, AegisEngineBorrowQuoteInput, AegisEngineAddCollateralQuoteInput, AegisEngineCloseQuoteInput, AegisEngineDepositQuote, AegisEngineDepositQuoteInput, AegisEngineIdleWithdrawQuoteInput, AegisEnginePositionActionQuote, AegisEngineRedeemQuoteInput, AegisEngineRepayQuoteInput } from './types.js';
2
2
  export declare function quoteEngineDeposit(input: AegisEngineDepositQuoteInput): Promise<AegisEngineDepositQuote>;
3
3
  export declare function quoteEngineBorrow(input: AegisEngineBorrowQuoteInput): Promise<AegisEngineBorrowQuote>;
4
+ export declare function quoteEngineAddCollateral(input: AegisEngineAddCollateralQuoteInput): Promise<AegisEnginePositionActionQuote>;
4
5
  export declare function quoteEngineBorrowCapacity(input: AegisEngineBorrowCapacityInput): Promise<AegisEngineBorrowCapacity>;
5
6
  export declare function quoteEngineRepay(input: AegisEngineRepayQuoteInput): Promise<AegisEnginePositionActionQuote>;
6
7
  export declare function quoteEngineCloseVault(input: AegisEngineCloseQuoteInput): Promise<AegisEnginePositionActionQuote>;
@@ -9,6 +9,8 @@ export declare function readEngineMarketSnapshot(input: AegisEngineMarketReadInp
9
9
  export declare function readEngineBorrowQuoteContext(input: AegisEngineMarketReadInput, execution?: {
10
10
  owner: Address;
11
11
  vaultId?: bigint;
12
+ }, options?: {
13
+ forceRefresh?: boolean;
12
14
  }): Promise<AegisEngineBorrowQuoteContext>;
13
15
  /**
14
16
  * Hydrates REST/subgraph-discovered borrow and lender positions in one
@@ -681,7 +681,7 @@ export type AegisEngineBorrowQuote = {
681
681
  costProjection: AegisEngineBorrowCostProjection;
682
682
  tx: AegisEnginePreparedTransaction | null;
683
683
  };
684
- export type AegisEnginePositionActionKind = 'repay' | 'close' | 'withdraw' | 'redeem';
684
+ export type AegisEnginePositionActionKind = 'add-collateral' | 'repay' | 'close' | 'withdraw' | 'redeem';
685
685
  export type AegisEngineBorrowPositionTarget = {
686
686
  kind: 'borrow_vault';
687
687
  positionId: string;
@@ -780,6 +780,14 @@ export type AegisEngineRepayQuoteInput = AegisEnginePositionActionQuoteBase & {
780
780
  repayRl?: bigint | 'full';
781
781
  slippageBps: number;
782
782
  };
783
+ export type AegisEngineAddCollateralQuoteInput = AegisEngineQuoteBase & {
784
+ target: AegisEngineBorrowPositionTarget;
785
+ /** Live existing-vault state. Add collateral never opens a fresh vault. */
786
+ vault: AegisEngineBorrowVaultContext;
787
+ collateralIn: bigint;
788
+ /** Bypass the short read cache after an authorization transaction lands. */
789
+ forceExecutionEvidenceRefresh?: boolean;
790
+ };
783
791
  export type AegisEngineCloseQuoteInput = AegisEnginePositionActionQuoteBase & {
784
792
  target: AegisEngineBorrowPositionTarget;
785
793
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aegis-engine/core",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "React-free Aegis Swap and Engine quoting, risk, approval, and execution operations.",
5
5
  "license": "MIT",
6
6
  "type": "module",