@aegis-engine/core 0.11.0 → 0.13.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 CHANGED
@@ -583,6 +583,16 @@ const quote = await fetchAggregatedSwapQuote(
583
583
  )
584
584
  ```
585
585
 
586
+ `AggregatedSwapQuote.priceImpact` is `number | null`: an omitted provider impact
587
+ remains unavailable, while an explicitly reported zero remains zero. Kyber routes
588
+ report no impact field, so it is derived from Kyber's USD values as
589
+ `(amountInUsd - grossOutUsd) / amountInUsd`, where `grossOutUsd` adds the Aegis
590
+ output fee back to `amountOutUsd` (covers market impact and pool fees; excludes
591
+ the Aegis fee and gas)
592
+ and is `null` when either value is missing or zero. Hosts must handle `null`
593
+ before formatting the value. The Widget displays it as “Unavailable” with a
594
+ warning tone.
595
+
586
596
  For a display-only quote, omit the account. For executable calldata, pass the
587
597
  user account:
588
598
 
@@ -616,17 +626,32 @@ carry the `uniswap-v4-aegis` tag. It checks this before build and, in
616
626
  hop is tagged with any other source, it throws `NoAegisRouteError`
617
627
  (`reason: 'no-route' | 'non-aegis-leg'`).
618
628
 
629
+ Mainnet and Ink charge an output fee. Pass the deployment's `/v1/config`
630
+ `fee.outputFeeBps` as `outputFeeBps` in the same options object (an integer from
631
+ 0 to 200; `0` charges no fee) and to `executeKyberSwap`; the route request,
632
+ build and calldata check all use it. `executeKyberSwap` rejects a displayed
633
+ quote at any other fee before any wallet prompt, approval or signature, and
634
+ refuses to sign if the submitted fee differs. Omit it when config is
635
+ unavailable to keep the bundled 50 bps (`AGGREGATED_SWAP_FEE_BPS`).
636
+
619
637
  Ink (57073) has no Kyber coverage, so it uses an in-house provider that accepts
620
638
  only `liquiditySources: 'aegis'` (`'any'` is rejected). It enumerates every path
621
639
  of up to three hops through the shipped Ink pool catalogue, quotes all of them
622
640
  (at most 32) in one Multicall3 `eth_call` to the V4 quoter, and takes the best
623
- output net of the 50 bps fee. Pass a `publicClient` (the eighth argument) to
641
+ output net of the output fee. Pass a `publicClient` (the eighth argument) to
624
642
  reuse your RPC. The swap goes to the Aegis router, which pulls input through
625
643
  Permit2: `executeKyberSwap` approves Permit2 for the exact input, signs a
626
644
  Permit2 grant for the router, re-quotes, and simulates before sending. The
627
645
  calldata ends with a fixed `TAKE` of the reviewed minimum, so a short fill
628
646
  reverts.
629
647
 
648
+ Quotes carry `routePaths` for display: each path's input share (`amountIn`) and
649
+ its legs (`pool`, `tokenIn`, `tokenOut`, `source`), as the provider reported
650
+ them. It is omitted unless every path is complete, its legs chain, and its
651
+ endpoints match the quoted assets up to canonical native/wrapped aliases. Known
652
+ input allocations must sum to the quoted input. Invalid metadata is omitted
653
+ without rejecting the display quote. Execution never reads it.
654
+
630
655
  ## KyberSwap Execution
631
656
 
632
657
  ```ts
@@ -728,7 +753,13 @@ pnpm pack:check
728
753
 
729
754
  ## Engine account portfolio and activity
730
755
 
731
- `fetchEngineAccountPortfolio({ source, account, chainIds, signal })` reads one complete, bounded account snapshot from the versioned portfolio API. The returned positions, totals, prices and per-chain frames belong to the same snapshot. A failed or expired page rejects the read instead of mixing snapshots. Supported chain IDs are 1, 130, 8453 and 4663; pass the distinct host-selected set.
756
+ `fetchEngineAccountPortfolio({ source, account, chainIds, signal })` reads one complete, bounded account snapshot from the versioned portfolio API. The returned positions, totals, prices and per-chain frames belong to the same snapshot. A failed or expired page rejects the read instead of mixing snapshots. Supported chain IDs are 1, 56, 130, 8453, 4663 and 57073 (Ink); pass the distinct host-selected set. The complete read is bounded to 300 positions, matching the backend's six-chain maximum of 50 positions per chain, with the existing 25-position page requests, response byte limits and shared deadline.
757
+
758
+ Portfolio, paged activity and transaction acknowledgement reads are available through the existing `@aegis-engine/core/account` entrypoint. Ink support admits the source contract; it does not enable borrowing, activate an operator or establish a live wallet/accounting result. Hosts retain their existing action gates and must qualify the deployed backend separately.
759
+
760
+ Ink account reads require a deployed Engine account API that supports Ink and
761
+ the six-chain, 300-position contract. Hosts must qualify that backend before
762
+ enabling the integration and retain their existing action gates.
732
763
 
733
764
  Metrics keep `usd: null`, a `knownUsd` subtotal and reasons when coverage is incomplete. Gross assets include supplied value; adding supply again would double count it. Debt and net equity remain separate. NFT principal, fees, unknown prices and unavailable chains retain their coverage reasons. `performance` explicitly reports unavailable cash-flow and cost-basis evidence.
734
765
 
@@ -755,6 +786,9 @@ change does not claim it is already available through the accounting endpoint.
755
786
 
756
787
  `fetchEngineMarketCandles`, `fetchEngineMarketReferenceHistory`, and
757
788
  `fetchEngineRateHistory` read public market data with a shared, bounded REST request.
789
+ These display reads admit Ink (`57073`) through the same market identity, asset,
790
+ coverage and provenance guards. Admission does not establish live source coverage;
791
+ an unavailable history remains unavailable rather than falling back to another feed.
758
792
  Validated responses are cached for 30 seconds with at most 16 entries, keyed by
759
793
  endpoint, request headers, timeout, market, series and window. A missing endpoint
760
794
  backs off for 60 seconds; 429/503 responses back off for at least 30 seconds and
package/dist/account.js CHANGED
@@ -1,5 +1,5 @@
1
- import { w as u, o as b, n as A, s as I, l as P, E as g, A as h, r as f, a as x, i as c, b as E, c as S, d as C, e as _, P as T, f as D } from "./transactionHistory-B-F6o9hW.js";
2
- import { g as M, h as j, j as J, k as O, m as U, p as G, q as Z, t as Q, u as V, v as W, x as X, y as Y, z as ee, B as ae, C as oe, D as se, F as ne, G as te, H as re } from "./transactionHistory-B-F6o9hW.js";
1
+ import { w as u, o as b, n as A, s as I, l as P, E as g, A as h, r as f, a as x, i as c, b as E, c as S, d as C, e as _, P as T, f as D } from "./transactionHistory-CFVVYJeo.js";
2
+ import { g as M, h as j, j as J, k as O, m as U, p as G, q as Z, t as Q, u as V, v as W, x as X, y as Y, z as ee, B as ae, C as oe, D as se, F as ne, G as te, H as re } from "./transactionHistory-CFVVYJeo.js";
3
3
  import { keccak256 as k, encodeAbiParameters as y } from "viem";
4
4
  const H = b({ version: P(1), snapshotId: I().uuid(), page: A().int().min(1).max(95) }).strict();
5
5
  function v(e) {
@@ -39,6 +39,11 @@ export declare function executeKyberSwap(args: {
39
39
  approvalMode?: AegisSwapApprovalMode;
40
40
  /** `'aegis'` routes only through Aegis pools and fails closed otherwise. Defaults to `'any'`. */
41
41
  liquiditySources?: AggregatedSwapLiquiditySources;
42
+ /**
43
+ * Output fee in bps from `/v1/config` (`fee.outputFeeBps`). Pass the value
44
+ * the displayed quote was fetched with; omit it to keep the bundled default.
45
+ */
46
+ outputFeeBps?: number;
42
47
  signal?: AbortSignal;
43
48
  onWalletChainId?: (chainId: number | null) => void;
44
49
  } & AegisSwapActionCallbacks): Promise<AegisSwapActionResult<AggregatedSwapQuote>>;