@aegis-engine/core 0.5.0 → 0.6.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 +54 -3
- package/dist/actions/directPoolSwap.d.ts +1 -0
- package/dist/actions/types.d.ts +55 -0
- package/dist/aegis-core.js +161 -155
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/lendHistory.d.ts +21 -0
- package/dist/engine/simpleYield.d.ts +39 -0
- package/dist/engine/types.d.ts +22 -0
- package/dist/errors.d.ts +13 -2
- package/dist/{index-DuoaODpB.js → index-D9EfUokZ.js} +3134 -2803
- package/dist/index.d.ts +6 -3
- package/dist/permit.d.ts +5 -0
- package/dist/{sdkRuntime-DeaRALj3.js → sdkRuntime-C_vaU-0g.js} +1 -1
- 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/transactionProgress.d.ts +40 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,6 +122,54 @@ remaining collateral stays in the vault until a separate withdrawal. A
|
|
|
122
122
|
one-token lend is a zap into a two-sided full-range LP, not single-token
|
|
123
123
|
lending.
|
|
124
124
|
|
|
125
|
+
### Simple-yield position summaries
|
|
126
|
+
|
|
127
|
+
Use `summarizeEngineSimpleYieldPosition` when a custom UI needs one honest,
|
|
128
|
+
React-free summary of an Engine lender-share position. The helper values live
|
|
129
|
+
shares first, falls back to trusted indexed shares, projects an optional added
|
|
130
|
+
USD amount, and converts realized share-price growth into a weekly estimate.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import {
|
|
134
|
+
readEnginePositionsHydration,
|
|
135
|
+
summarizeEngineSimpleYieldPosition
|
|
136
|
+
} from '@aegis-engine/core'
|
|
137
|
+
|
|
138
|
+
const market = markets[0]
|
|
139
|
+
const positionsHydration = await readEnginePositionsHydration({
|
|
140
|
+
publicClient,
|
|
141
|
+
chainId: market.chainId,
|
|
142
|
+
expectedAccount: account,
|
|
143
|
+
positions: positions.positions,
|
|
144
|
+
lendPositions: positions.lendPositions
|
|
145
|
+
})
|
|
146
|
+
const position = positions.lendPositions.find(
|
|
147
|
+
(entry) =>
|
|
148
|
+
entry.chainId === market.chainId &&
|
|
149
|
+
entry.poolId.toLowerCase() === market.poolId.toLowerCase()
|
|
150
|
+
) ?? null
|
|
151
|
+
const live = position
|
|
152
|
+
? positionsHydration.lendPositions.find(
|
|
153
|
+
(entry) => entry.positionId === position.id
|
|
154
|
+
)
|
|
155
|
+
: undefined
|
|
156
|
+
|
|
157
|
+
const summary = summarizeEngineSimpleYieldPosition({
|
|
158
|
+
market,
|
|
159
|
+
position,
|
|
160
|
+
hydration: live,
|
|
161
|
+
history: marketHistory,
|
|
162
|
+
additionalValueUsd: 100
|
|
163
|
+
})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`summary.valuation` identifies whether live or indexed shares produced the
|
|
167
|
+
current USD value. `summary.projection` is null when an existing position cannot
|
|
168
|
+
be valued, so an add-funds UI cannot mislabel it as a new deposit.
|
|
169
|
+
`summary.growth.weeklyEarningsPer100Usd` is a historical share-growth estimate,
|
|
170
|
+
not a promise. `market.metrics.lendApyPct` is the current modeled lender rate;
|
|
171
|
+
it is a different metric and is never substituted for realized history.
|
|
172
|
+
|
|
125
173
|
### Directional Engine positions
|
|
126
174
|
|
|
127
175
|
`quoteEngineTradeOpen` sizes a fresh-vault Long or Short against one
|
|
@@ -525,9 +573,12 @@ Execution returns:
|
|
|
525
573
|
|
|
526
574
|
## Publishing
|
|
527
575
|
|
|
528
|
-
|
|
529
|
-
|
|
576
|
+
Releases use Changesets and npm trusted publishing. The release workflow builds
|
|
577
|
+
all publishable packages once, validates their tarballs, then publishes the
|
|
578
|
+
prebuilt artifacts with package lifecycle scripts disabled. This prevents
|
|
579
|
+
concurrent package publishes from rebuilding shared workspace artifacts.
|
|
530
580
|
|
|
531
581
|
```sh
|
|
532
|
-
|
|
582
|
+
pnpm build
|
|
583
|
+
pnpm pack:check
|
|
533
584
|
```
|
|
@@ -32,6 +32,7 @@ export declare function approveDirectPoolSwapInput(args: {
|
|
|
32
32
|
amount: bigint;
|
|
33
33
|
approvalMode?: AegisSwapApprovalMode;
|
|
34
34
|
onStatus?: AegisSwapActionCallbacks['onStatus'];
|
|
35
|
+
onApprovalProgress?: AegisSwapActionCallbacks['onApprovalProgress'];
|
|
35
36
|
}): Promise<DirectPoolSwapApprovalResult>;
|
|
36
37
|
export declare function executeDirectPoolSwap(args: {
|
|
37
38
|
wallet: WalletSession;
|
package/dist/actions/types.d.ts
CHANGED
|
@@ -3,10 +3,65 @@ import type { DirectSwapQuote } from '../quote.js';
|
|
|
3
3
|
import type { AegisSwapReceiptSummary, SubmitStatus } from '../transactionProgress.js';
|
|
4
4
|
import type { AggregatedSwapQuote } from '../types/aggregatedSwap.js';
|
|
5
5
|
import type { AegisSwapSubmitDetails } from '../swap/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* The grant the approval prompt asks for, as the executor resolved it from the
|
|
8
|
+
* sizing rule. It travels with the progress report so a surface renders the
|
|
9
|
+
* number that will actually be signed instead of re-deriving one from form
|
|
10
|
+
* state — the input amount and the requested amount are the same only under
|
|
11
|
+
* 'exact' sizing. There is no `formatted` field: the unlimited case has no
|
|
12
|
+
* honest formatting and has to be rendered as a word.
|
|
13
|
+
*/
|
|
14
|
+
export type AegisSwapApprovalRequest = {
|
|
15
|
+
/** The exact value passed to `approve()`. */
|
|
16
|
+
value: bigint;
|
|
17
|
+
/** Decimals of the approved token, so `value` is renderable on its own. */
|
|
18
|
+
decimals: number;
|
|
19
|
+
/** True when `value` reads as no limit at all; render a word, not `value`. */
|
|
20
|
+
unlimited: boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The approval step's wallet prompts: how many it will open, how many the
|
|
24
|
+
* wallet has already confirmed, and what they ask for. Only the executor can
|
|
25
|
+
* answer any of it — its allowance read decides whether a USDT-style zero-reset
|
|
26
|
+
* adds a second prompt, and only it sees that reset's receipt.
|
|
27
|
+
*/
|
|
28
|
+
export type AegisSwapApprovalProgress = {
|
|
29
|
+
/** Prompts the approval step opens: 0, 1, or 2 when a zero-reset precedes it. */
|
|
30
|
+
planned: number;
|
|
31
|
+
/** How many of `planned` have landed on-chain. */
|
|
32
|
+
completed: number;
|
|
33
|
+
/** Absent exactly when `planned` is 0 — nothing will be approved. */
|
|
34
|
+
request?: AegisSwapApprovalRequest;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Wallet prompts used to authorize Permit2 for the router. Usually this is one
|
|
38
|
+
* typed-data signature. A wallet that explicitly reports typed-data as
|
|
39
|
+
* unsupported uses one on-chain spending-cap prompt instead. Returned invalid
|
|
40
|
+
* signatures fail closed, so this is a count rather than a boolean.
|
|
41
|
+
*/
|
|
42
|
+
export type AegisSwapAuthorizationProgress = {
|
|
43
|
+
/** Prompts this authorization step will open from the executor's live state. */
|
|
44
|
+
planned: number;
|
|
45
|
+
/** Prompts already completed by the wallet/user. */
|
|
46
|
+
completed: number;
|
|
47
|
+
};
|
|
6
48
|
export type AegisSwapActionCallbacks<TSwapDetails = AegisSwapSubmitDetails> = {
|
|
7
49
|
onStatus?: (status: SubmitStatus) => void;
|
|
8
50
|
onTxHash?: (hash: Hex | null) => void;
|
|
9
51
|
onSubmitted?: (hash: Hex, swap?: TSwapDetails) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Fires with the plan before the first approval prompt opens, then again
|
|
54
|
+
* after each approval transaction mines. Once allowance resolution is
|
|
55
|
+
* reached, no required approval reports `{ planned: 0, completed: 0 }`.
|
|
56
|
+
* Earlier chain-validation or quote failures can stop before this callback.
|
|
57
|
+
*/
|
|
58
|
+
onApprovalProgress?: (progress: AegisSwapApprovalProgress) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Fires before the first Permit2 authorization prompt, whenever the plan
|
|
61
|
+
* changes, and after each completed prompt. A reusable standing cap reports
|
|
62
|
+
* `{ planned: 0, completed: 0 }`.
|
|
63
|
+
*/
|
|
64
|
+
onAuthorizationProgress?: (progress: AegisSwapAuthorizationProgress) => void;
|
|
10
65
|
};
|
|
11
66
|
export type AegisSwapActionResult<TQuote = DirectSwapQuote | AggregatedSwapQuote> = {
|
|
12
67
|
hash: Hex;
|
package/dist/aegis-core.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { A as s, b as i, c as r, d as
|
|
1
|
+
import { A as s, b as i, c as r, d as t, e as n, f as o, g as c, h as E, i as S, j as A, k as g, l as d, m as _, n as l, o as p, p as b, q as P, r as T, t as u, u as h, v as m, w as k, x as I, y as R, z as C, B as w, C as G, D as B, E as D, F as N, G as M, H as y, K as v, I as W, J as U, M as O, L as F, N as L, O as f, P as K, S as H, Q as V, T as x, U as Q, R as q, V as z, W as X, X as Y, Y as j, Z, _ as J, $, a0 as aa, a1 as ea, a2 as sa, a3 as ia, a4 as ra, a5 as ta, a6 as na, a7 as oa, a8 as ca, a9 as Ea, aa as Sa, ab as Aa, ac as ga, ad as da, ae as _a, af as la, ag as pa, ah as ba, ai as Pa, aj as Ta, ak as ua, al as ha, am as ma, an as ka, ao as Ia, ap as Ra, aq as Ca, ar as wa, as as Ga, at as Ba, au as Da, av as Na, aw as Ma, ax as ya, ay as va, az as Wa, aA as Ua, aB as Oa, aC as Fa, aD as La, aE as fa, aF as Ka, aG as Ha, aH as Va, aI as xa, aJ as Qa, aK as qa, aL as za, aM as Xa, aN as Ya, aO as ja, aP as Za, aQ as Ja, aR as $a, aS as ae, aT as ee, aU as se, aV as ie, aW as re, aX as te, aY as ne, aZ as oe, a_ as ce, a$ as Ee, b0 as Se, b1 as Ae, b2 as ge, b3 as de, b4 as _e, b5 as le, b6 as pe, b7 as be, b8 as Pe, b9 as Te, ba as ue, bb as he, bc as me, bd as ke, be as Ie, bf as Re, bg as Ce, bh as we, bi as Ge, bj as Be, bk as De, bl as Ne, bm as Me, bn as ye, bo as ve, bp as We, bq as Ue, br as Oe, bs as Fe, bt as Le, bu as fe, bv as Ke, bw as He, bx as Ve, by as xe, bz as Qe, bA as qe, bB as ze, bC as Xe, bD as Ye, bE as je, bF as Ze, bG as Je, bH as $e, bI as as, bJ as es, bK as ss, bL as is, bM as rs, bN as ts, bO as ns, bP as os, bQ as cs, bR as Es, bS as Ss, bT as As, bU as gs, bV as ds, bW as _s, bX as ls, bY as ps, bZ as bs, b_ as Ps, b$ as Ts, c0 as us, c1 as hs, c2 as ms, c3 as ks, c4 as Is, c5 as Rs, c6 as Cs, c7 as ws, c8 as Gs, c9 as Bs, ca as Ds, cb as Ns, cc as Ms, cd as ys, ce as vs, cf as Ws, cg as Us, ch as Os, ci as Fs, cj as Ls } from "./index-D9EfUokZ.js";
|
|
2
2
|
export {
|
|
3
3
|
s as AEGIS_BACKEND_PROD_BASE_URL,
|
|
4
4
|
i as AEGIS_DYNAMIC_FEE_FLAG,
|
|
5
5
|
r as AEGIS_SWAP_CHAINS,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
t as AEGIS_SWAP_CHAIN_ID,
|
|
7
|
+
n as AEGIS_SWAP_DEFAULT_FEE_BPS,
|
|
8
8
|
o as AEGIS_SWAP_DEFAULT_FEE_RECIPIENT,
|
|
9
9
|
c as AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT,
|
|
10
10
|
E as AEGIS_SWAP_DEFAULT_RPC_URLS,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
S as AEGIS_SWAP_HOOK,
|
|
12
|
+
A as AEGIS_SWAP_MAINNET_CHAIN,
|
|
13
13
|
g as AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS,
|
|
14
14
|
d as AEGIS_SWAP_PERMIT2,
|
|
15
15
|
_ as AEGIS_SWAP_ROUTER,
|
|
16
16
|
l as AEGIS_SWAP_TOKENS,
|
|
17
|
-
|
|
17
|
+
p as AEGIS_SWAP_TRUSTED_ROUTERS_BY_CHAIN,
|
|
18
18
|
b as AEGIS_SWAP_V4_QUOTER,
|
|
19
|
-
|
|
19
|
+
P as AGGREGATED_SWAP_CURATED_TOKENS,
|
|
20
20
|
T as AGGREGATED_SWAP_DEFAULT_TOKENS,
|
|
21
21
|
u as AGGREGATED_SWAP_DEFAULT_TOKEN_LIST,
|
|
22
22
|
h as AGGREGATED_SWAP_SUPPORTED_CHAIN_IDS,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
m as AGGREGATED_SWAP_TOKEN_PRESETS,
|
|
24
|
+
k as AGGREGATED_SWAP_WOLFGAME_TOKENS,
|
|
25
|
+
I as AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST,
|
|
26
26
|
R as AegisBackendApiError,
|
|
27
|
-
|
|
27
|
+
C as AegisBackendContractError,
|
|
28
28
|
w as AegisContractGuardError,
|
|
29
29
|
G as AegisEngineMarketNotReadyError,
|
|
30
30
|
B as AggregatedSwapBuildMismatchError,
|
|
@@ -41,157 +41,163 @@ export {
|
|
|
41
41
|
f as NATIVE_TOKEN_ADDRESS,
|
|
42
42
|
K as PERMIT2_FAR_FUTURE_EXPIRATION,
|
|
43
43
|
H as SWAP_TX_DEADLINE_SECONDS,
|
|
44
|
-
V as
|
|
45
|
-
x as
|
|
46
|
-
Q as
|
|
47
|
-
q as
|
|
48
|
-
z as
|
|
49
|
-
X as
|
|
50
|
-
Y as
|
|
51
|
-
j as
|
|
52
|
-
Z as
|
|
53
|
-
J as
|
|
54
|
-
$ as
|
|
55
|
-
aa as
|
|
56
|
-
ea as
|
|
57
|
-
sa as
|
|
58
|
-
ia as
|
|
59
|
-
ra as
|
|
44
|
+
V as SubmittedTransactionReceiptError,
|
|
45
|
+
x as TransactionReceiptTimeoutError,
|
|
46
|
+
Q as UNISWAP_V4_CONTRACTS_BY_CHAIN,
|
|
47
|
+
q as USER_REJECTED_MESSAGE,
|
|
48
|
+
z as UserFacingError,
|
|
49
|
+
X as aegisBackendAddressAllowlistSchema,
|
|
50
|
+
Y as aegisBackendAddressSchema,
|
|
51
|
+
j as aegisBackendAllowlistsByChainSchema,
|
|
52
|
+
Z as aegisBackendChainIdSchema,
|
|
53
|
+
J as aegisBackendChainSchema,
|
|
54
|
+
$ as aegisBackendConfigSchema,
|
|
55
|
+
aa as aegisBackendContractRegistrySchema,
|
|
56
|
+
ea as aegisBackendContractsByChainSchema,
|
|
57
|
+
sa as aegisBackendDecimalStringSchema,
|
|
58
|
+
ia as aegisBackendFeeConfigSchema,
|
|
59
|
+
ra as aegisBackendHealthResponseSchema,
|
|
60
|
+
ta as aegisBackendHexSchema,
|
|
60
61
|
na as aegisBackendIsoDateTimeSchema,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
oa as aegisBackendMarketMetricsSchema,
|
|
63
|
+
ca as aegisBackendMarketSchema,
|
|
64
|
+
Ea as aegisBackendMarketStatusSchema,
|
|
65
|
+
Sa as aegisBackendMarketsResponseSchema,
|
|
65
66
|
Aa as aegisBackendQuoteDefaultsSchema,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
ga as aegisBackendQuoteModeSchema,
|
|
68
|
+
da as aegisBackendSwapProviderSchema,
|
|
69
|
+
_a as aegisBackendSwapQuoteRequestSchema,
|
|
70
|
+
la as aegisBackendSwapQuoteResponseSchema,
|
|
71
|
+
pa as aegisBackendTokenSchema,
|
|
72
|
+
ba as aegisBackendTokensResponseSchema,
|
|
73
|
+
Pa as aegisPoolKeySchema,
|
|
74
|
+
Ta as aggregatedSwapErrorMessage,
|
|
75
|
+
ua as approveDirectPoolSwapInput,
|
|
76
|
+
ha as approveEnginePermit2ToRouter,
|
|
77
|
+
ma as approveEngineTokenToPermit2,
|
|
77
78
|
ka as approveErc20Spender,
|
|
78
79
|
Ia as approveErc20ToPermit2,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
80
|
+
Ra as approveKyberSwapInput,
|
|
81
|
+
Ca as approvePermit2ToRouter,
|
|
82
|
+
wa as assertCalldataHash,
|
|
83
|
+
Ga as assertChainMatches,
|
|
84
|
+
Ba as assertQuoteFresh,
|
|
85
|
+
Da as assertRouterAllowlisted,
|
|
86
|
+
Na as assertSpenderAllowlisted,
|
|
87
|
+
Ma as assertUint128,
|
|
88
|
+
ya as attachEngineActivityLotDisplays,
|
|
89
|
+
va as authorizeEnginePositionRouter,
|
|
90
|
+
Wa as authorizeEngineVaultOperator,
|
|
91
|
+
Ua as backendTokenToAegisSwapToken,
|
|
92
|
+
Oa as backendTokensToAegisSwapTokens,
|
|
93
|
+
Fa as buildExactInSwapTransaction,
|
|
94
|
+
La as buildExactOutSwapTransaction,
|
|
95
|
+
fa as buildKyberSwapRoute,
|
|
96
|
+
Ka as buildSignedPermitBatch,
|
|
97
|
+
Ha as classifyEngineVaultActivity,
|
|
98
|
+
Va as classifyError,
|
|
99
|
+
xa as clearEngineMarketHistoryCache,
|
|
100
|
+
Qa as clearEngineMarketsCache,
|
|
101
|
+
qa as clearEnginePositionActivityCache,
|
|
102
|
+
za as clearEnginePositionsCache,
|
|
103
|
+
Xa as clearEnginePositionsV2ProbeCache,
|
|
104
|
+
Ya as clearEngineReadCaches,
|
|
105
|
+
ja as clearTokenPriceHistoryCache,
|
|
106
|
+
Za as computeEngineIdleWithdrawPostLtvPips,
|
|
107
|
+
Ja as computeEngineMaxIdleWithdraw,
|
|
108
|
+
$a as computePoolId,
|
|
109
|
+
ae as createAegisBackendApiClient,
|
|
110
|
+
ee as createAegisSwapChainConfig,
|
|
111
|
+
se as createAegisSwapChains,
|
|
112
|
+
ie as createAegisSwapChainsFromBackendConfig,
|
|
113
|
+
re as createAegisSwapMarketsFromPools,
|
|
114
|
+
te as createAegisSwapPoolMarket,
|
|
114
115
|
ne as createAegisSwapPoolsFromBackendMarkets,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
oe as createAegisSwapUniswapV4Contracts,
|
|
117
|
+
ce as createSwapPublicClient,
|
|
118
|
+
Ee as deriveEngineActivityLotDisplay,
|
|
119
|
+
Se as deriveEngineTradePositionStrategy,
|
|
119
120
|
Ae as engineIdleWithdrawPassesResidualLtv,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
ge as enginePermit2GrantSatisfies,
|
|
122
|
+
de as enginePreviewMaxLtvPips,
|
|
123
|
+
_e as engineRouterForChain,
|
|
124
|
+
le as engineTokenGrantSatisfies,
|
|
125
|
+
pe as ensureWalletChain,
|
|
126
|
+
be as errorMessage,
|
|
127
|
+
Pe as estimateSwapGasWithBuffer,
|
|
128
|
+
Te as executeDirectPoolSwap,
|
|
129
|
+
ue as executeKyberSwap,
|
|
130
|
+
he as executionLtvGuardPips,
|
|
131
|
+
me as fetchAggregatedSwapQuote,
|
|
131
132
|
ke as fetchDirectPoolSwapQuote,
|
|
132
133
|
Ie as fetchEngineLendActivity,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
ns as
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
As as
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
134
|
+
Re as fetchEngineMarketHistory,
|
|
135
|
+
Ce as fetchEngineMarkets,
|
|
136
|
+
we as fetchEnginePositionActivitySnapshot,
|
|
137
|
+
Ge as fetchEnginePositionsSnapshot,
|
|
138
|
+
Be as fetchEngineVaultActivity,
|
|
139
|
+
De as fetchGlobalTokenMetadata,
|
|
140
|
+
Ne as fetchKyberSwapRoute,
|
|
141
|
+
Me as fetchTokenPriceHistory,
|
|
142
|
+
ye as getExplorerUrl,
|
|
143
|
+
ve as getInjectedProvider,
|
|
144
|
+
We as getProviderAccount,
|
|
145
|
+
Ue as getProviderChainId,
|
|
146
|
+
Oe as getZeroForOne,
|
|
147
|
+
Fe as isAegisEngineTradePositionIntent,
|
|
148
|
+
Le as isBusy,
|
|
149
|
+
fe as isDocumentVisible,
|
|
150
|
+
Ke as isEip1193Provider,
|
|
151
|
+
He as isNativeAssetAddress,
|
|
152
|
+
Ve as isNativeToken,
|
|
153
|
+
xe as isRetryableAegisBackendApiError,
|
|
154
|
+
Qe as isRetryableKyberSwapError,
|
|
155
|
+
qe as isSubmittedTransactionReceiptError,
|
|
156
|
+
ze as isUserRejectedError,
|
|
157
|
+
Xe as missingEngineExecutionReason,
|
|
158
|
+
Ye as normalizeAccount,
|
|
159
|
+
je as normalizeAegisBackendBaseUrl,
|
|
160
|
+
Ze as normalizeEngineMarkets,
|
|
161
|
+
Je as normalizeWalletConnection,
|
|
162
|
+
$e as outputFeeForQuote,
|
|
163
|
+
as as peekTokenPriceHistory,
|
|
164
|
+
es as pollUntil,
|
|
165
|
+
ss as prepareEnginePermit,
|
|
166
|
+
is as quoteEngineAddCollateral,
|
|
167
|
+
rs as quoteEngineBorrow,
|
|
168
|
+
ts as quoteEngineBorrowCapacity,
|
|
169
|
+
ns as quoteEngineCloseVault,
|
|
170
|
+
os as quoteEngineDeposit,
|
|
171
|
+
cs as quoteEngineIdleWithdraw,
|
|
172
|
+
Es as quoteEngineRedeem,
|
|
173
|
+
Ss as quoteEngineRepay,
|
|
174
|
+
As as quoteEngineTradeOpen,
|
|
175
|
+
gs as quoteSpendAmount,
|
|
176
|
+
ds as readEngineAuthorizationPlan,
|
|
177
|
+
_s as readEngineBorrowQuoteContext,
|
|
178
|
+
ls as readEngineLendQuoteContext,
|
|
179
|
+
ps as readEngineMarketMark,
|
|
180
|
+
bs as readEngineMarketSnapshot,
|
|
179
181
|
Ps as readEnginePositionsHydration,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
Cs as
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
Ts as readEngineVaultActivity,
|
|
183
|
+
us as readEngineVaultRouterApproved,
|
|
184
|
+
hs as readErc20Allowance,
|
|
185
|
+
ms as readPermit2RouterAllowance,
|
|
186
|
+
ks as reconcileSubmitQuote,
|
|
187
|
+
Is as reconcileSubmittedReceipt,
|
|
188
|
+
Rs as requestProviderAccount,
|
|
189
|
+
Cs as resolveTokenIconUrl,
|
|
190
|
+
ws as resolveWalletSession,
|
|
191
|
+
Gs as retryOnError,
|
|
192
|
+
Bs as sameQuote,
|
|
193
|
+
Ds as sendEngineTransaction,
|
|
194
|
+
Ns as subscribeProvider,
|
|
195
|
+
Ms as summarizeEngineLendShareGrowth,
|
|
196
|
+
ys as summarizeEngineSimpleYieldPosition,
|
|
197
|
+
vs as summarizeTransactionReceipt,
|
|
198
|
+
Ws as switchProviderChain,
|
|
199
|
+
Us as transactionProgressView,
|
|
200
|
+
Os as trustedEngineRegistryForChain,
|
|
201
|
+
Fs as trustedEngineVersionForChain,
|
|
202
|
+
Ls as waitForProviderChain
|
|
197
203
|
};
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
2
|
export * from './activityLotDisplay.js';
|
|
3
3
|
export * from './dataSource.js';
|
|
4
|
+
export * from './lendHistory.js';
|
|
5
|
+
export * from './simpleYield.js';
|
|
4
6
|
export * from './marketAdapter.js';
|
|
5
7
|
export * from './registry.js';
|
|
6
8
|
export * from './reads.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AegisEngineMetricHistory } from './types.js';
|
|
2
|
+
export type AegisEngineLendShareGrowthSummary = Readonly<{
|
|
3
|
+
startTimestamp: number;
|
|
4
|
+
endTimestamp: number;
|
|
5
|
+
coverageSeconds: number;
|
|
6
|
+
apyPct: number;
|
|
7
|
+
weeklyEarningsPer100Usd: number;
|
|
8
|
+
/** Historical average weekly dollars per $100, recalculated from the first
|
|
9
|
+
* usable share-price observation through each later observation. */
|
|
10
|
+
points: ReadonlyArray<Readonly<{
|
|
11
|
+
t: number;
|
|
12
|
+
v: number;
|
|
13
|
+
}>>;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Converts the Engine history plane's realized share-price growth into a
|
|
17
|
+
* player-readable historical earnings rate. This deliberately does not use
|
|
18
|
+
* `lendApyPct`: that field is the current borrower-interest model, while share
|
|
19
|
+
* growth records what actually accrued to one pool share during the window.
|
|
20
|
+
*/
|
|
21
|
+
export declare function summarizeEngineLendShareGrowth(history: AegisEngineMetricHistory): AegisEngineLendShareGrowthSummary | null;
|
|
@@ -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';
|
|
@@ -1256,6 +1257,25 @@ export type AegisEngineAuthorizationProgress = {
|
|
|
1256
1257
|
kind: AegisEngineAuthorizationStepKind;
|
|
1257
1258
|
status: 'requesting' | 'confirmed';
|
|
1258
1259
|
};
|
|
1260
|
+
/** Lifecycle evidence for one Engine permission request. */
|
|
1261
|
+
export type AegisEngineAuthorizationExecutionEvent = Readonly<{
|
|
1262
|
+
kind: AegisEngineAuthorizationStepKind;
|
|
1263
|
+
status: 'wallet-requested';
|
|
1264
|
+
hash: null;
|
|
1265
|
+
}> | Readonly<{
|
|
1266
|
+
kind: AegisEngineAuthorizationStepKind;
|
|
1267
|
+
status: 'submitted';
|
|
1268
|
+
hash: Hex;
|
|
1269
|
+
}> | Readonly<{
|
|
1270
|
+
kind: AegisEngineAuthorizationStepKind;
|
|
1271
|
+
status: 'confirmed';
|
|
1272
|
+
hash: Hex | null;
|
|
1273
|
+
}> | Readonly<{
|
|
1274
|
+
kind: AegisEngineAuthorizationStepKind;
|
|
1275
|
+
status: 'cancelled' | 'failed';
|
|
1276
|
+
hash: Hex | null;
|
|
1277
|
+
error: ClassifiedError;
|
|
1278
|
+
}>;
|
|
1259
1279
|
export type AegisEngineApprovalInput = {
|
|
1260
1280
|
wallet: AegisEngineWalletSession;
|
|
1261
1281
|
publicClient: PublicClient;
|
|
@@ -1271,6 +1291,8 @@ export type AegisEngineApprovalInput = {
|
|
|
1271
1291
|
onStatus?: AegisEngineActionCallbacks['onStatus'];
|
|
1272
1292
|
/** Fine-grained prerequisite progress for truthful wallet onboarding. */
|
|
1273
1293
|
onAuthorizationProgress?: (progress: AegisEngineAuthorizationProgress) => void;
|
|
1294
|
+
/** Full prerequisite lifecycle at the wallet and receipt boundaries. */
|
|
1295
|
+
onAuthorizationExecution?: (event: AegisEngineAuthorizationExecutionEvent) => void;
|
|
1274
1296
|
/** Awaited after each prerequisite receipt and before another wallet request. */
|
|
1275
1297
|
onAuthorizationCheckpoint?: () => Promise<void>;
|
|
1276
1298
|
};
|
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
|
});
|