@aegis-engine/core 0.13.0 → 0.14.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/dist/account.js +1 -129
- package/dist/aegis-core.js +71 -10384
- package/dist/contract/generated/aegis-swap.d.ts +310 -5
- package/dist/contract/generated/market-data.d.ts +310 -5
- package/dist/engine/account/activitySchemas.d.ts +1 -0
- package/dist/engine/account/discoverySchemas.d.ts +101 -0
- package/dist/engine/account/portfolioSchemas.d.ts +2 -0
- package/dist/engine/account/transactionSchemas.d.ts +1 -0
- package/dist/engine/account/transport.d.ts +6 -0
- package/dist/engine/account/types.d.ts +1 -0
- package/dist/engine/dataSource.d.ts +4 -1
- package/dist/engine/registry.d.ts +15 -0
- package/dist/engine/sdkDeployment.d.ts +16 -0
- package/dist/engine/types.d.ts +5 -1
- package/dist/index.d.ts +2 -0
- package/dist/sdkRuntime-CvLRgf5w.js +1593 -0
- package/dist/transactionHistory-BGpe2c7k.js +149 -0
- package/package.json +2 -2
- package/dist/sdkRuntime-Dra77GTA.js +0 -18757
- package/dist/transactionHistory-CFVVYJeo.js +0 -6994
package/dist/account.js
CHANGED
|
@@ -1,129 +1 @@
|
|
|
1
|
-
import
|
|
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
|
-
import { keccak256 as k, encodeAbiParameters as y } from "viem";
|
|
4
|
-
const H = b({ version: P(1), snapshotId: I().uuid(), page: A().int().min(1).max(95) }).strict();
|
|
5
|
-
function v(e) {
|
|
6
|
-
if (!/^[A-Za-z0-9_-]{1,256}$/.test(e)) throw new Error("invalid-cursor");
|
|
7
|
-
return H.parse(JSON.parse(atob(e.replace(/-/g, "+").replace(/_/g, "/"))));
|
|
8
|
-
}
|
|
9
|
-
function L(e) {
|
|
10
|
-
return u({ ...e, chainIds: [e.chainId] }, async (r) => {
|
|
11
|
-
let o;
|
|
12
|
-
try {
|
|
13
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(e.poolId) || !["lend_shares", "borrow_vault"].includes(e.kind) || (e.kind === "borrow_vault" ? !g.safeParse(e.vaultId).success : e.vaultId !== void 0)) throw new Error("invalid-query");
|
|
14
|
-
e.cursor !== void 0 && (o = v(e.cursor));
|
|
15
|
-
} catch {
|
|
16
|
-
throw new h("invalid-query", 400);
|
|
17
|
-
}
|
|
18
|
-
const a = await f(r, "positions/accounting", {
|
|
19
|
-
chainId: String(e.chainId),
|
|
20
|
-
poolId: e.poolId.toLowerCase(),
|
|
21
|
-
kind: e.kind,
|
|
22
|
-
...e.kind === "borrow_vault" ? { vaultId: e.vaultId } : {},
|
|
23
|
-
...e.cursor ? { cursor: e.cursor } : {}
|
|
24
|
-
}, x, { omitChainIds: !0, responseLimit: 256 * 1024 });
|
|
25
|
-
if (Date.parse(a.expiresAt) <= Date.now()) throw new h("snapshot-expired", 410);
|
|
26
|
-
const n = a.position, l = n.key;
|
|
27
|
-
if ((n.account !== r.query.account || n.chainId !== e.chainId || n.poolId !== e.poolId.toLowerCase() || n.kind !== e.kind || n.vaultId !== (e.vaultId ?? null) || n.scope !== (e.kind === "lend_shares" ? "account-lending" : "vault-lifetime") || a.page.snapshotId !== a.snapshotId || a.page.page !== ((o == null ? void 0 : o.page) ?? 0) || o && o.snapshotId !== a.snapshotId || a.page.page >= a.pageCount || a.recordCount > 0 && a.page.records.length === 0 || a.page.records.length > a.recordCount || a.pageCount === 1 && a.page.records.length !== a.recordCount || Date.parse(a.expiresAt) - Date.parse(a.createdAt) !== 6e5 || l.currency0 >= l.currency1 || k(y(
|
|
28
|
-
[{ type: "address" }, { type: "address" }, { type: "uint24" }, { type: "int24" }, { type: "address" }],
|
|
29
|
-
[l.currency0, l.currency1, l.fee, l.tickSpacing, l.hooks]
|
|
30
|
-
)) !== n.poolId) && c(), a.page.page + 1 < a.pageCount != (a.nextCursor !== null) && c(), a.nextCursor !== null)
|
|
31
|
-
try {
|
|
32
|
-
const t = v(a.nextCursor);
|
|
33
|
-
(t.snapshotId !== a.snapshotId || t.page !== a.page.page + 1) && c();
|
|
34
|
-
} catch {
|
|
35
|
-
c();
|
|
36
|
-
}
|
|
37
|
-
const m = /* @__PURE__ */ new Map();
|
|
38
|
-
let i;
|
|
39
|
-
for (const t of a.page.records) {
|
|
40
|
-
const s = t.event, p = m.get(s.transactionHash);
|
|
41
|
-
if ((s.blockNumber > a.frame.blockNumber || s.blockTimestamp > a.frame.blockTimestamp || i && (s.blockNumber < i.blockNumber || s.blockTimestamp < i.blockTimestamp || s.blockNumber === i.blockNumber && (s.logIndex <= i.logIndex || s.blockTimestamp !== i.blockTimestamp || s.transactionIndex < i.transactionIndex || s.transactionIndex === i.transactionIndex != (s.transactionHash === i.transactionHash))) || p && (p.blockNumber !== s.blockNumber || p.blockTimestamp !== s.blockTimestamp || p.transactionIndex !== s.transactionIndex)) && c(), t.type === "ownership")
|
|
42
|
-
(e.kind !== "borrow_vault" || t.event.vaultId !== e.vaultId || t.event.registry !== n.registry || s.id !== `vault-transfer:${n.chainId}:${n.registry}:${s.transactionHash}:${s.logIndex}` || s.blockNumber === a.frame.blockNumber && t.event.blockHash !== a.frame.blockHash) && c();
|
|
43
|
-
else {
|
|
44
|
-
const d = t.event, w = ["liquidity_modified", "share_transfer", "protocol_fee_minted"].includes(d.kind);
|
|
45
|
-
(e.kind === "lend_shares" !== w || d.kind === "liquidity_modified" && d.details.account !== n.account || d.kind === "protocol_fee_minted" && d.details.recipient !== n.account || d.kind === "share_transfer" && d.details.from !== n.account && d.details.to !== n.account) && c(), (t.event.id !== `engine-event:${n.chainId}:${n.engine}:${s.transactionHash}:${s.logIndex}` || t.event.sourceId !== `${s.transactionHash}-${s.logIndex}` || e.kind === "lend_shares" && t.ownershipAtEvent.status !== "not-applicable" || e.kind === "borrow_vault" && (a.ownership.status !== "complete" ? t.ownershipAtEvent.status !== "unavailable" : !["known", "inactive"].includes(t.ownershipAtEvent.status))) && c();
|
|
46
|
-
}
|
|
47
|
-
m.set(s.transactionHash, s), i = s;
|
|
48
|
-
}
|
|
49
|
-
return a;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const R = _({ ttlMs: 0, maxEntries: 64 });
|
|
53
|
-
async function F(e) {
|
|
54
|
-
var n;
|
|
55
|
-
(n = e.signal) == null || n.throwIfAborted();
|
|
56
|
-
const r = { ...e.source, headers: { ...e.source.headers } }, o = JSON.stringify([
|
|
57
|
-
E(r.baseUrl),
|
|
58
|
-
S(r.headers),
|
|
59
|
-
r.timeoutMs,
|
|
60
|
-
e.account,
|
|
61
|
-
e.chainId,
|
|
62
|
-
e.poolId,
|
|
63
|
-
e.vaultId,
|
|
64
|
-
e.snapshotId
|
|
65
|
-
]), a = R.read(o, () => $({ ...e, source: r, signal: void 0 }));
|
|
66
|
-
return structuredClone(await C(a, e.signal, "Position PnL read aborted."));
|
|
67
|
-
}
|
|
68
|
-
function $(e) {
|
|
69
|
-
return u({ ...e, chainIds: [e.chainId] }, async (r) => {
|
|
70
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(e.poolId) || !g.safeParse(e.vaultId).success || !I().uuid().safeParse(e.snapshotId).success) throw new h("invalid-query", 400);
|
|
71
|
-
const o = await f(r, "positions/pnl", {
|
|
72
|
-
chainId: String(e.chainId),
|
|
73
|
-
poolId: e.poolId.toLowerCase(),
|
|
74
|
-
kind: "borrow_vault",
|
|
75
|
-
vaultId: e.vaultId,
|
|
76
|
-
snapshotId: e.snapshotId
|
|
77
|
-
}, T, { omitChainIds: !0, responseLimit: 32 * 1024 });
|
|
78
|
-
if (Date.parse(o.expiresAt) <= Date.now()) throw new h("snapshot-expired", 410);
|
|
79
|
-
if ((o.account !== r.query.account || o.chainId !== e.chainId || o.poolId !== e.poolId.toLowerCase() || o.vaultId !== e.vaultId || o.snapshotId !== e.snapshotId || Date.parse(o.capturedAt) > Date.now() + 6e4 || Date.parse(o.expiresAt) - Date.parse(o.capturedAt) > 6e5) && c(), o.status === "token-pnl") {
|
|
80
|
-
const a = o.key;
|
|
81
|
-
k(y(
|
|
82
|
-
[{ type: "address" }, { type: "address" }, { type: "uint24" }, { type: "int24" }, { type: "address" }],
|
|
83
|
-
[a.currency0, a.currency1, a.fee, a.tickSpacing, a.hooks]
|
|
84
|
-
)) !== o.poolId && c();
|
|
85
|
-
}
|
|
86
|
-
return o;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function z(e) {
|
|
90
|
-
return u({ ...e, chainIds: [e.chainId] }, async (r) => {
|
|
91
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(e.poolId) || !g.safeParse(e.vaultId).success || !I().uuid().safeParse(e.snapshotId).success || e.portfolioSnapshotId !== void 0 && !I().uuid().safeParse(e.portfolioSnapshotId).success)
|
|
92
|
-
throw new h("invalid-query", 400);
|
|
93
|
-
const o = await f(r, "positions/performance", {
|
|
94
|
-
chainId: String(e.chainId),
|
|
95
|
-
poolId: e.poolId.toLowerCase(),
|
|
96
|
-
kind: "borrow_vault",
|
|
97
|
-
vaultId: e.vaultId,
|
|
98
|
-
snapshotId: e.snapshotId,
|
|
99
|
-
...e.portfolioSnapshotId ? { portfolioSnapshotId: e.portfolioSnapshotId } : {}
|
|
100
|
-
}, D, { omitChainIds: !0, responseLimit: 32 * 1024 });
|
|
101
|
-
if (Date.parse(o.expiresAt) <= Date.now()) throw new h("snapshot-expired", 410);
|
|
102
|
-
return (o.account !== r.query.account || o.chainId !== e.chainId || o.poolId !== e.poolId.toLowerCase() || o.vaultId !== e.vaultId || o.snapshotId !== e.snapshotId || o.portfolioSnapshotId !== (e.portfolioSnapshotId ?? null) || Date.parse(o.capturedAt) > Date.now() + 6e4 || Date.parse(o.expiresAt) - Date.parse(o.capturedAt) > 6e5) && c(), o;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
export {
|
|
106
|
-
h as AegisEngineAccountReadError,
|
|
107
|
-
M as createEngineTransactionHistory,
|
|
108
|
-
j as engineAccountPositionKey,
|
|
109
|
-
J as engineAccountTransactionKey,
|
|
110
|
-
O as engineHistoryCatalogResponseSchema,
|
|
111
|
-
U as enginePortfolioPriceFor,
|
|
112
|
-
G as enginePositionHistoryResponseSchema,
|
|
113
|
-
Z as engineTransactionStorageKey,
|
|
114
|
-
Q as fetchEngineAccountActivity,
|
|
115
|
-
V as fetchEngineAccountPortfolio,
|
|
116
|
-
W as fetchEngineHistoryPositions,
|
|
117
|
-
L as fetchEnginePositionAccounting,
|
|
118
|
-
X as fetchEnginePositionHistory,
|
|
119
|
-
z as fetchEnginePositionPerformance,
|
|
120
|
-
F as fetchEnginePositionPnl,
|
|
121
|
-
Y as fetchEngineTransactionStatus,
|
|
122
|
-
ee as formatEngineAccountTokenAmount,
|
|
123
|
-
ae as groupEngineAccountActivity,
|
|
124
|
-
oe as groupEnginePortfolioPositions,
|
|
125
|
-
se as mergeEngineTransactionRecord,
|
|
126
|
-
ne as parseEngineTransactionRecords,
|
|
127
|
-
te as resolveEngineAccountPositionTarget,
|
|
128
|
-
re as serializeEngineTransactionRecords
|
|
129
|
-
};
|
|
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-BGpe2c7k.js";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-BGpe2c7k.js";import{keccak256 as k,encodeAbiParameters as y}from"viem";const H=b({version:P(1),snapshotId:I().uuid(),page:A().int().min(1).max(95)}).strict();function v(e){if(!/^[A-Za-z0-9_-]{1,256}$/.test(e))throw new Error("invalid-cursor");return H.parse(JSON.parse(atob(e.replace(/-/g,"+").replace(/_/g,"/"))));}function L(e){return u({...e,chainIds:[e.chainId]},async r=>{let o;try{if(!/^0x[0-9a-fA-F]{64}$/.test(e.poolId)||!["lend_shares","borrow_vault"].includes(e.kind)||(e.kind==="borrow_vault"?!g.safeParse(e.vaultId).success:e.vaultId!==void 0))throw new Error("invalid-query");e.cursor!==void 0&&(o=v(e.cursor));}catch{throw new h("invalid-query",400);}const a=await f(r,"positions/accounting",{chainId:String(e.chainId),poolId:e.poolId.toLowerCase(),kind:e.kind,...(e.kind==="borrow_vault"?{vaultId:e.vaultId}:{}),...(e.cursor?{cursor:e.cursor}:{})},x,{omitChainIds:!0,responseLimit:256*1024});if(Date.parse(a.expiresAt)<=Date.now())throw new h("snapshot-expired",410);const n=a.position,l=n.key;if((n.account!==r.query.account||n.chainId!==e.chainId||n.poolId!==e.poolId.toLowerCase()||n.kind!==e.kind||n.vaultId!==(e.vaultId??null)||n.scope!==(e.kind==="lend_shares"?"account-lending":"vault-lifetime")||a.page.snapshotId!==a.snapshotId||a.page.page!==((o==null?void 0:o.page)??0)||o&&o.snapshotId!==a.snapshotId||a.page.page>=a.pageCount||a.recordCount>0&&a.page.records.length===0||a.page.records.length>a.recordCount||a.pageCount===1&&a.page.records.length!==a.recordCount||Date.parse(a.expiresAt)-Date.parse(a.createdAt)!==6e5||l.currency0>=l.currency1||k(y([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[l.currency0,l.currency1,l.fee,l.tickSpacing,l.hooks]))!==n.poolId)&&c(),a.page.page+1<a.pageCount!=(a.nextCursor!==null)&&c(),a.nextCursor!==null)try{const t=v(a.nextCursor);(t.snapshotId!==a.snapshotId||t.page!==a.page.page+1)&&c();}catch{c();}const m=/* @__PURE__ */new Map();let i;for(const t of a.page.records){const s=t.event,p=m.get(s.transactionHash);if((s.blockNumber>a.frame.blockNumber||s.blockTimestamp>a.frame.blockTimestamp||i&&(s.blockNumber<i.blockNumber||s.blockTimestamp<i.blockTimestamp||s.blockNumber===i.blockNumber&&(s.logIndex<=i.logIndex||s.blockTimestamp!==i.blockTimestamp||s.transactionIndex<i.transactionIndex||s.transactionIndex===i.transactionIndex!=(s.transactionHash===i.transactionHash)))||p&&(p.blockNumber!==s.blockNumber||p.blockTimestamp!==s.blockTimestamp||p.transactionIndex!==s.transactionIndex))&&c(),t.type==="ownership")(e.kind!=="borrow_vault"||t.event.vaultId!==e.vaultId||t.event.registry!==n.registry||s.id!==`vault-transfer:${n.chainId}:${n.registry}:${s.transactionHash}:${s.logIndex}`||s.blockNumber===a.frame.blockNumber&&t.event.blockHash!==a.frame.blockHash)&&c();else{const d=t.event,w=["liquidity_modified","share_transfer","protocol_fee_minted"].includes(d.kind);(e.kind==="lend_shares"!==w||d.kind==="liquidity_modified"&&d.details.account!==n.account||d.kind==="protocol_fee_minted"&&d.details.recipient!==n.account||d.kind==="share_transfer"&&d.details.from!==n.account&&d.details.to!==n.account)&&c(),(t.event.id!==`engine-event:${n.chainId}:${n.engine}:${s.transactionHash}:${s.logIndex}`||t.event.sourceId!==`${s.transactionHash}-${s.logIndex}`||e.kind==="lend_shares"&&t.ownershipAtEvent.status!=="not-applicable"||e.kind==="borrow_vault"&&(a.ownership.status!=="complete"?t.ownershipAtEvent.status!=="unavailable":!["known","inactive"].includes(t.ownershipAtEvent.status)))&&c();}m.set(s.transactionHash,s),i=s;}return a;});}const R=_({ttlMs:0,maxEntries:64});async function F(e){var n;(n=e.signal)==null||n.throwIfAborted();const r={...e.source,headers:{...e.source.headers}},o=JSON.stringify([E(r.baseUrl),S(r.headers),r.timeoutMs,e.account,e.chainId,e.poolId,e.vaultId,e.snapshotId]),a=R.read(o,()=>$({...e,source:r,signal:void 0}));return structuredClone(await C(a,e.signal,"Position PnL read aborted."));}function $(e){return u({...e,chainIds:[e.chainId]},async r=>{if(!/^0x[0-9a-fA-F]{64}$/.test(e.poolId)||!g.safeParse(e.vaultId).success||!I().uuid().safeParse(e.snapshotId).success)throw new h("invalid-query",400);const o=await f(r,"positions/pnl",{chainId:String(e.chainId),poolId:e.poolId.toLowerCase(),kind:"borrow_vault",vaultId:e.vaultId,snapshotId:e.snapshotId},T,{omitChainIds:!0,responseLimit:32*1024});if(Date.parse(o.expiresAt)<=Date.now())throw new h("snapshot-expired",410);if((o.account!==r.query.account||o.chainId!==e.chainId||o.poolId!==e.poolId.toLowerCase()||o.vaultId!==e.vaultId||o.snapshotId!==e.snapshotId||Date.parse(o.capturedAt)>Date.now()+6e4||Date.parse(o.expiresAt)-Date.parse(o.capturedAt)>6e5)&&c(),o.status==="token-pnl"){const a=o.key;k(y([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[a.currency0,a.currency1,a.fee,a.tickSpacing,a.hooks]))!==o.poolId&&c();}return o;});}function z(e){return u({...e,chainIds:[e.chainId]},async r=>{if(!/^0x[0-9a-fA-F]{64}$/.test(e.poolId)||!g.safeParse(e.vaultId).success||!I().uuid().safeParse(e.snapshotId).success||e.portfolioSnapshotId!==void 0&&!I().uuid().safeParse(e.portfolioSnapshotId).success)throw new h("invalid-query",400);const o=await f(r,"positions/performance",{chainId:String(e.chainId),poolId:e.poolId.toLowerCase(),kind:"borrow_vault",vaultId:e.vaultId,snapshotId:e.snapshotId,...(e.portfolioSnapshotId?{portfolioSnapshotId:e.portfolioSnapshotId}:{})},D,{omitChainIds:!0,responseLimit:32*1024});if(Date.parse(o.expiresAt)<=Date.now())throw new h("snapshot-expired",410);return(o.account!==r.query.account||o.chainId!==e.chainId||o.poolId!==e.poolId.toLowerCase()||o.vaultId!==e.vaultId||o.snapshotId!==e.snapshotId||o.portfolioSnapshotId!==(e.portfolioSnapshotId??null)||Date.parse(o.capturedAt)>Date.now()+6e4||Date.parse(o.expiresAt)-Date.parse(o.capturedAt)>6e5)&&c(),o;});}export{h as AegisEngineAccountReadError,M as createEngineTransactionHistory,j as engineAccountPositionKey,J as engineAccountTransactionKey,O as engineHistoryCatalogResponseSchema,U as enginePortfolioPriceFor,G as enginePositionHistoryResponseSchema,Z as engineTransactionStorageKey,Q as fetchEngineAccountActivity,V as fetchEngineAccountPortfolio,W as fetchEngineHistoryPositions,L as fetchEnginePositionAccounting,X as fetchEnginePositionHistory,z as fetchEnginePositionPerformance,F as fetchEnginePositionPnl,Y as fetchEngineTransactionStatus,ee as formatEngineAccountTokenAmount,ae as groupEngineAccountActivity,oe as groupEnginePortfolioPositions,se as mergeEngineTransactionRecord,ne as parseEngineTransactionRecords,te as resolveEngineAccountPositionTarget,re as serializeEngineTransactionRecords};
|