@oracle-agent/oracle 0.3.3 → 0.3.5
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 +5 -12
- package/SETUP.md +1 -35
- package/artifacts/specialist-packs/oracle-full-crypto.json +9 -31
- package/bin/oracle-data-mcp.mjs +74 -247
- package/bin/oracle-init.mjs +27 -100
- package/docs/profiles.md +7 -27
- package/package.json +1 -1
- package/profiles/_template/SOUL.md +1 -8
- package/profiles/oracle/SOUL.md +1 -8
- package/profiles/oracle/profile.json +2 -5
- package/profiles/protocol-builder/SOUL.md +6 -13
- package/profiles/protocol-builder/profile.json +1 -3
- package/src/cards.mjs +369 -0
- package/src/data/catalog.mjs +3 -27
- package/src/data/desk-data.mjs +4 -34
- package/src/data/providers/magiceden-sol.mjs +2 -21
- package/src/data/providers/opensea-nft.mjs +0 -272
- package/src/data/providers/satflow.mjs +0 -1
- package/src/data/providers/uniswap-v3.mjs +17 -1
- package/src/exec-policy.mjs +0 -5
- package/src/gmx-attestation.mjs +0 -1
- package/src/router/prepare-route.mjs +23 -0
- package/src/router/route-sources.mjs +37 -0
- package/src/scanner/chains.config.mjs +48 -1
- package/src/vault-attestation.mjs +0 -1
- package/skills/balance/SKILL.md +0 -176
- package/skills/oracle-multichain-nft-launch/SKILL.md +0 -338
- package/skills/oracle-multichain-token-launch/SKILL.md +0 -300
- package/src/data/providers/nft-gallery.mjs +0 -163
- package/src/data/providers/nft-portfolio.mjs +0 -494
- package/src/data/providers/portfolio-history.mjs +0 -394
- package/src/data/providers/portfolio.mjs +0 -594
package/src/cards.mjs
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
// Telegram card TEXT renderers.
|
|
2
|
+
//
|
|
3
|
+
// Implements skills/oracle-chain-graphs-telegram-cards/SKILL.md. That spec has
|
|
4
|
+
// existed with no code behind it, so Oracle users were getting raw JSON instead
|
|
5
|
+
// of readable alert cards. This module is the text half only: chart/image
|
|
6
|
+
// rendering lives elsewhere and MUST NOT be required for a card to send.
|
|
7
|
+
//
|
|
8
|
+
// Contract for every exported renderer:
|
|
9
|
+
// - pure, synchronous, string in / string out
|
|
10
|
+
// - NO network, NO signing, NO filesystem, NO env reads, NO mutation of input
|
|
11
|
+
// - unknown data renders as the literal string UNKNOWN — never blank, never
|
|
12
|
+
// guessed, never interpolated from a neighbouring field
|
|
13
|
+
// - the only identifier (contract address / mint / market id) is NEVER
|
|
14
|
+
// truncated: a half-address is worse than no address because it still looks
|
|
15
|
+
// actionable
|
|
16
|
+
// - chart failure is cosmetic: the text card always returns
|
|
17
|
+
// - buy/sell affordances only when a valid local grant/session is supplied
|
|
18
|
+
//
|
|
19
|
+
// Markdown dialect: Telegram *legacy* Markdown. Values are escaped for `_`,
|
|
20
|
+
// `*`, `[`, `]` and backtick; card chrome supplies its own markers. We never
|
|
21
|
+
// emit `$` at all (the spec calls out repeated `$` spans as a formatting trap)
|
|
22
|
+
// — amounts are suffixed with USD instead.
|
|
23
|
+
|
|
24
|
+
import { chainById } from "./chains.mjs";
|
|
25
|
+
|
|
26
|
+
/** The one and only stand-in for missing data. */
|
|
27
|
+
export const UNKNOWN = "UNKNOWN";
|
|
28
|
+
|
|
29
|
+
export const CARD_KINDS = Object.freeze(["token", "launch", "hip3", "hip4", "polymarket"]);
|
|
30
|
+
|
|
31
|
+
const LEGACY_MD_SPECIALS = /[_*[\]`]/g;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Escape Telegram legacy-Markdown control characters in a *value*.
|
|
35
|
+
* Card chrome (bold headers) is written unescaped by the renderers themselves.
|
|
36
|
+
* @param {unknown} value
|
|
37
|
+
* @returns {string} escaped text, or UNKNOWN when there is nothing to show
|
|
38
|
+
*/
|
|
39
|
+
export function escapeMd(value) {
|
|
40
|
+
if (!isPresent(value)) return UNKNOWN;
|
|
41
|
+
return String(value).replace(LEGACY_MD_SPECIALS, (c) => `\\${c}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function isPresent(value) {
|
|
45
|
+
if (value === null || value === undefined) return false;
|
|
46
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
47
|
+
if (typeof value === "string") return value.trim() !== "";
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A value that must survive verbatim (addresses, mints, market ids). */
|
|
52
|
+
function code(value) {
|
|
53
|
+
if (!isPresent(value)) return UNKNOWN;
|
|
54
|
+
// Backticks would close the span; strip rather than truncate the identifier.
|
|
55
|
+
const raw = String(value).replace(/`/g, "");
|
|
56
|
+
return raw === "" ? UNKNOWN : `\`${raw}\``;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function num(value, { decimals = 2 } = {}) {
|
|
60
|
+
if (!isPresent(value)) return UNKNOWN;
|
|
61
|
+
const n = typeof value === "bigint" ? Number(value) : Number(value);
|
|
62
|
+
if (!Number.isFinite(n)) return UNKNOWN;
|
|
63
|
+
return n.toLocaleString("en-US", { minimumFractionDigits: 0, maximumFractionDigits: decimals });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Money. Deliberately no `$` — repeated dollar spans break Telegram parsing. */
|
|
67
|
+
function usd(value, { decimals = 2 } = {}) {
|
|
68
|
+
const n = num(value, { decimals });
|
|
69
|
+
return n === UNKNOWN ? UNKNOWN : `${n} USD`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function pct(value, { decimals = 2 } = {}) {
|
|
73
|
+
const n = num(value, { decimals });
|
|
74
|
+
return n === UNKNOWN ? UNKNOWN : `${n}%`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function bps(value) {
|
|
78
|
+
const n = num(value, { decimals: 0 });
|
|
79
|
+
return n === UNKNOWN ? UNKNOWN : `${n} bps`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Exact base-unit -> decimal string. BigInt only: a raw quote like
|
|
84
|
+
* 24325001237995579150138 loses precision the moment it touches a float.
|
|
85
|
+
*/
|
|
86
|
+
export function formatUnits(raw, decimals) {
|
|
87
|
+
if (!isPresent(raw)) return UNKNOWN;
|
|
88
|
+
const d = Number(decimals);
|
|
89
|
+
if (!Number.isInteger(d) || d < 0 || d > 77) return UNKNOWN;
|
|
90
|
+
let value;
|
|
91
|
+
try {
|
|
92
|
+
value = BigInt(typeof raw === "string" ? raw.trim() : raw);
|
|
93
|
+
} catch {
|
|
94
|
+
return UNKNOWN;
|
|
95
|
+
}
|
|
96
|
+
const neg = value < 0n;
|
|
97
|
+
const abs = neg ? -value : value;
|
|
98
|
+
const base = 10n ** BigInt(d);
|
|
99
|
+
const whole = (abs / base).toString();
|
|
100
|
+
const frac = (abs % base).toString().padStart(d, "0").replace(/0+$/, "");
|
|
101
|
+
return `${neg ? "-" : ""}${whole}${frac ? `.${frac}` : ""}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Normalize confidence to a stated band. Every card must state one. */
|
|
105
|
+
export function normalizeConfidence(value) {
|
|
106
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
107
|
+
if (value < 0 || value > 1) return UNKNOWN;
|
|
108
|
+
if (value >= 0.75) return "HIGH";
|
|
109
|
+
if (value >= 0.4) return "MEDIUM";
|
|
110
|
+
return "LOW";
|
|
111
|
+
}
|
|
112
|
+
if (typeof value === "string") {
|
|
113
|
+
const v = value.trim().toUpperCase();
|
|
114
|
+
if (v === "HIGH" || v === "MEDIUM" || v === "LOW") return v;
|
|
115
|
+
}
|
|
116
|
+
return UNKNOWN;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function chainLine(data = {}) {
|
|
120
|
+
const id = data.chainId;
|
|
121
|
+
if (!isPresent(id) || !Number.isFinite(Number(id))) {
|
|
122
|
+
return isPresent(data.chain) ? escapeMd(data.chain) : UNKNOWN;
|
|
123
|
+
}
|
|
124
|
+
const known = chainById(id);
|
|
125
|
+
const name = known?.name || (isPresent(data.chain) ? String(data.chain) : UNKNOWN);
|
|
126
|
+
return `${escapeMd(name)} (chainId ${Number(id)})`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function venueLine(data = {}) {
|
|
130
|
+
return escapeMd(data.venue ?? data.dex ?? data.pool?.venue);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Chart status. A graph is evidence, not a dependency — if the image failed we
|
|
135
|
+
* say so and the text card still stands.
|
|
136
|
+
*/
|
|
137
|
+
function chartLine(chart) {
|
|
138
|
+
if (chart === null || chart === undefined) return "NONE (text card only)";
|
|
139
|
+
if (typeof chart === "string") return chart.trim() ? code(chart) : "NONE (text card only)";
|
|
140
|
+
if (chart.error || chart.ok === false || chart.available === false) {
|
|
141
|
+
const why = isPresent(chart.error) ? ` — ${escapeMd(chart.error)}` : "";
|
|
142
|
+
return `UNAVAILABLE${why} (text card stands)`;
|
|
143
|
+
}
|
|
144
|
+
if (isPresent(chart.url)) return code(chart.url);
|
|
145
|
+
return "NONE (text card only)";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Buy/sell affordances are gated on a valid LOCAL grant or session. Absent or
|
|
150
|
+
* expired grant => prepare-only. This function is the single gate; renderers
|
|
151
|
+
* never decide on their own.
|
|
152
|
+
* @returns {{ allowed: boolean, reason: string, actions: string[] }}
|
|
153
|
+
*/
|
|
154
|
+
export function cardActions(data = {}, { now = Date.now() } = {}) {
|
|
155
|
+
const grant = data.grant ?? data.session ?? null;
|
|
156
|
+
if (!grant || typeof grant !== "object") {
|
|
157
|
+
return { allowed: false, reason: "no local grant/session", actions: [] };
|
|
158
|
+
}
|
|
159
|
+
if (grant.local === false) {
|
|
160
|
+
return { allowed: false, reason: "grant is not local", actions: [] };
|
|
161
|
+
}
|
|
162
|
+
if (grant.revoked === true) {
|
|
163
|
+
return { allowed: false, reason: "grant revoked", actions: [] };
|
|
164
|
+
}
|
|
165
|
+
const expiry = grant.expiresAt ?? grant.expiry;
|
|
166
|
+
if (isPresent(expiry)) {
|
|
167
|
+
const at = typeof expiry === "number" ? expiry : Date.parse(expiry);
|
|
168
|
+
if (!Number.isFinite(at)) return { allowed: false, reason: "grant expiry unreadable", actions: [] };
|
|
169
|
+
if (at <= now) return { allowed: false, reason: "grant expired", actions: [] };
|
|
170
|
+
}
|
|
171
|
+
const actions = Array.isArray(grant.actions) && grant.actions.length ? grant.actions.slice() : ["BUY", "SELL"];
|
|
172
|
+
return { allowed: true, reason: "valid local grant", actions };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function actionsLine(data) {
|
|
176
|
+
const gate = cardActions(data);
|
|
177
|
+
return gate.allowed
|
|
178
|
+
? `${gate.actions.map((a) => escapeMd(a)).join(" / ")} (${escapeMd(gate.reason)})`
|
|
179
|
+
: `prepare-only — ${escapeMd(gate.reason)}`;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function build(title, rows, data = {}) {
|
|
183
|
+
const lines = [`*${title}*`];
|
|
184
|
+
for (const [label, value] of rows) {
|
|
185
|
+
// Labels are authored here and contain no markdown specials by construction.
|
|
186
|
+
lines.push(`${label}: ${value === undefined || value === null || value === "" ? UNKNOWN : value}`);
|
|
187
|
+
}
|
|
188
|
+
lines.push(`Chart: ${chartLine(data.chart)}`);
|
|
189
|
+
lines.push(`Actions: ${actionsLine(data)}`);
|
|
190
|
+
if (Array.isArray(data.warnings) && data.warnings.length) {
|
|
191
|
+
lines.push(`Warnings: ${data.warnings.map((w) => escapeMd(w)).join("; ")}`);
|
|
192
|
+
}
|
|
193
|
+
if (isPresent(data.source) || isPresent(data.fetchedAt)) {
|
|
194
|
+
lines.push(`Source: ${escapeMd(data.source)} at ${escapeMd(data.fetchedAt)}`);
|
|
195
|
+
}
|
|
196
|
+
return lines.join("\n");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function confidenceRow(data) {
|
|
200
|
+
return ["Confidence", normalizeConfidence(data.confidence)];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function quoteRows(data) {
|
|
204
|
+
const q = data.quote;
|
|
205
|
+
if (!q || typeof q !== "object") return [];
|
|
206
|
+
const human = isPresent(q.decimals) ? formatUnits(q.amountOutRaw ?? q.out ?? q.raw, q.decimals) : UNKNOWN;
|
|
207
|
+
return [
|
|
208
|
+
["Quote out (raw)", code(q.amountOutRaw ?? q.out ?? q.raw)],
|
|
209
|
+
["Quote out", human === UNKNOWN ? UNKNOWN : `${escapeMd(human)} ${escapeMd(q.symbol ?? "")}`.trim()],
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function slippageRow(data) {
|
|
214
|
+
const s = data.autoSlippage;
|
|
215
|
+
if (!s || typeof s !== "object") return ["Auto-slippage", UNKNOWN];
|
|
216
|
+
const sel = bps(s.selectedBps);
|
|
217
|
+
const cap = bps(s.capBps);
|
|
218
|
+
return ["Auto-slippage", sel === UNKNOWN && cap === UNKNOWN ? UNKNOWN : `${sel} selected, cap ${cap}`];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Per-chain token card: price, volume, liquidity, market cap, age, venue. */
|
|
222
|
+
export function renderTokenCard(data = {}) {
|
|
223
|
+
const d = data || {};
|
|
224
|
+
return build(
|
|
225
|
+
`ORACLE TOKEN — ${escapeMd(d.symbol ?? d.token ?? d.name)}`,
|
|
226
|
+
[
|
|
227
|
+
["Chain", chainLine(d)],
|
|
228
|
+
["Venue", venueLine(d)],
|
|
229
|
+
["Name", escapeMd(d.name)],
|
|
230
|
+
["Address", code(d.address ?? d.mint ?? d.contract)],
|
|
231
|
+
["Price", usd(d.priceUsd, { decimals: 8 })],
|
|
232
|
+
["Market cap", usd(d.marketCapUsd)],
|
|
233
|
+
["Liquidity", usd(d.liquidityUsd)],
|
|
234
|
+
["Volume 24h", usd(d.volume24hUsd)],
|
|
235
|
+
["Change 24h", pct(d.priceChange24h)],
|
|
236
|
+
["Fee tier", isPresent(d.feeTier) ? `${bps(Number(d.feeTier) / 100)} (${num(d.feeTier, { decimals: 0 })})` : UNKNOWN],
|
|
237
|
+
["Age", escapeMd(d.age)],
|
|
238
|
+
...quoteRows(d),
|
|
239
|
+
slippageRow(d),
|
|
240
|
+
confidenceRow(d),
|
|
241
|
+
],
|
|
242
|
+
d,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Launch/sniper card: route readiness, sellability, overlap, risk, ticket. */
|
|
247
|
+
export function renderLaunchCard(data = {}) {
|
|
248
|
+
const d = data || {};
|
|
249
|
+
return build(
|
|
250
|
+
`ORACLE LAUNCH — ${escapeMd(d.symbol ?? d.token ?? d.name)}`,
|
|
251
|
+
[
|
|
252
|
+
["Chain", chainLine(d)],
|
|
253
|
+
["Venue", venueLine(d)],
|
|
254
|
+
["Address", code(d.address ?? d.mint ?? d.contract)],
|
|
255
|
+
["Pool", code(d.pool?.address ?? d.poolAddress ?? d.pool)],
|
|
256
|
+
["Liquidity", usd(d.liquidityUsd)],
|
|
257
|
+
["Route ready", escapeMd(d.routeReady)],
|
|
258
|
+
["Sellable", escapeMd(d.sellable)],
|
|
259
|
+
["Sell sim", escapeMd(d.sellSimulation ?? d.sellSim)],
|
|
260
|
+
["Smart wallets", escapeMd(d.smartWalletOverlap)],
|
|
261
|
+
["Risk", escapeMd(d.risk ?? d.riskStatus)],
|
|
262
|
+
["Prepared ticket", escapeMd(d.preparedTicket ?? d.ticketStatus)],
|
|
263
|
+
slippageRow(d),
|
|
264
|
+
confidenceRow(d),
|
|
265
|
+
],
|
|
266
|
+
d,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Hyperliquid HIP-3 builder-dex card. Requires perpDexs + metaAndAssetCtxs. */
|
|
271
|
+
export function renderHip3Card(data = {}) {
|
|
272
|
+
const d = data || {};
|
|
273
|
+
return build(
|
|
274
|
+
`ORACLE HIP-3 — ${escapeMd(d.market ?? d.coin ?? d.name)}`,
|
|
275
|
+
[
|
|
276
|
+
["Venue", `Hyperliquid builder-dex ${escapeMd(d.dex)}`],
|
|
277
|
+
["Market", escapeMd(d.market ?? d.coin)],
|
|
278
|
+
["Mark", usd(d.markPx, { decimals: 6 })],
|
|
279
|
+
["Oracle", usd(d.oraclePx, { decimals: 6 })],
|
|
280
|
+
["Funding", pct(d.funding, { decimals: 6 })],
|
|
281
|
+
["Open interest", usd(d.openInterestUsd)],
|
|
282
|
+
["Depth", escapeMd(d.depth)],
|
|
283
|
+
["Liquidation notes", escapeMd(d.liquidationNotes ?? d.riskNotes)],
|
|
284
|
+
["Account context", escapeMd(d.accountContext)],
|
|
285
|
+
confidenceRow(d),
|
|
286
|
+
],
|
|
287
|
+
d,
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Hyperliquid HIP-4 outcome-market card. Public reads are keyless. */
|
|
292
|
+
export function renderHip4Card(data = {}) {
|
|
293
|
+
const d = data || {};
|
|
294
|
+
return build(
|
|
295
|
+
`ORACLE HIP-4 — ${escapeMd(d.event ?? d.market ?? d.name)}`,
|
|
296
|
+
[
|
|
297
|
+
["Venue", `Hyperliquid HIP-4 ${escapeMd(d.dex ?? "outcome")}`],
|
|
298
|
+
["Event", escapeMd(d.event)],
|
|
299
|
+
["Outcome", escapeMd(d.outcome)],
|
|
300
|
+
["Market id", code(d.marketId ?? d.market)],
|
|
301
|
+
["Bid", usd(d.bid, { decimals: 6 })],
|
|
302
|
+
["Ask", usd(d.ask, { decimals: 6 })],
|
|
303
|
+
["Depth", escapeMd(d.depth)],
|
|
304
|
+
["Edge", pct(d.edge)],
|
|
305
|
+
["Position", escapeMd(d.position)],
|
|
306
|
+
confidenceRow(d),
|
|
307
|
+
],
|
|
308
|
+
d,
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Polymarket card. Public reads keyless; orders stay prepared/user-signed. */
|
|
313
|
+
export function renderPolymarketCard(data = {}) {
|
|
314
|
+
const d = data || {};
|
|
315
|
+
return build(
|
|
316
|
+
`ORACLE POLYMARKET — ${escapeMd(d.event ?? d.market ?? d.name)}`,
|
|
317
|
+
[
|
|
318
|
+
["Venue", "Polymarket CLOB"],
|
|
319
|
+
["Event", escapeMd(d.event)],
|
|
320
|
+
["Market", escapeMd(d.market)],
|
|
321
|
+
["Market id", code(d.marketId ?? d.conditionId ?? d.tokenId)],
|
|
322
|
+
["Yes", usd(d.yesPrice, { decimals: 4 })],
|
|
323
|
+
["No", usd(d.noPrice, { decimals: 4 })],
|
|
324
|
+
["Best bid / ask", `${usd(d.bestBid, { decimals: 4 })} / ${usd(d.bestAsk, { decimals: 4 })}`],
|
|
325
|
+
["Volume", usd(d.volumeUsd)],
|
|
326
|
+
["Resolution risk", escapeMd(d.resolutionRisk)],
|
|
327
|
+
["Order intent", escapeMd(d.orderIntent)],
|
|
328
|
+
confidenceRow(d),
|
|
329
|
+
],
|
|
330
|
+
d,
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const RENDERERS = Object.freeze({
|
|
335
|
+
token: renderTokenCard,
|
|
336
|
+
launch: renderLaunchCard,
|
|
337
|
+
hip3: renderHip3Card,
|
|
338
|
+
hip4: renderHip4Card,
|
|
339
|
+
polymarket: renderPolymarketCard,
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Dispatch by surface kind.
|
|
344
|
+
* @param {"token"|"launch"|"hip3"|"hip4"|"polymarket"} kind
|
|
345
|
+
*/
|
|
346
|
+
export function renderCard(kind, data = {}) {
|
|
347
|
+
const fn = RENDERERS[String(kind)];
|
|
348
|
+
if (!fn) throw new Error(`unknown card kind: ${kind} (expected one of ${CARD_KINDS.join(", ")})`);
|
|
349
|
+
return fn(data);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Total soft-fail wrapper. An alert that cannot render is still an alert the
|
|
354
|
+
* user needs to see, so a malformed payload degrades to a minimal card rather
|
|
355
|
+
* than throwing and dropping the notification.
|
|
356
|
+
*/
|
|
357
|
+
export function safeRenderCard(kind, data = {}) {
|
|
358
|
+
try {
|
|
359
|
+
return renderCard(kind, data);
|
|
360
|
+
} catch (error) {
|
|
361
|
+
return [
|
|
362
|
+
`*ORACLE CARD — DEGRADED*`,
|
|
363
|
+
`Kind: ${escapeMd(kind)}`,
|
|
364
|
+
`Chain: ${UNKNOWN}`,
|
|
365
|
+
`Confidence: ${UNKNOWN}`,
|
|
366
|
+
`Render error: ${escapeMd(error?.message)}`,
|
|
367
|
+
].join("\n");
|
|
368
|
+
}
|
|
369
|
+
}
|
package/src/data/catalog.mjs
CHANGED
|
@@ -98,29 +98,6 @@ registerProvider({
|
|
|
98
98
|
description: "RH agent local HTTP (unauthenticated read routes)",
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
registerProvider({
|
|
102
|
-
id: "portfolio",
|
|
103
|
-
venue: "multichain-wallet",
|
|
104
|
-
chainIds: [1, 10, 56, 137, 988, 999, 2741, 4663, 8453, 42161, 43114],
|
|
105
|
-
auth: "none",
|
|
106
|
-
ops: ["health", "balances", "snapshot", "history", "valueGraph"],
|
|
107
|
-
execution: "read-only",
|
|
108
|
-
description:
|
|
109
|
-
"Read-only balance aggregation across configured EVM chains, Solana, Bitcoin, and Hyperliquid, plus profile-local observation snapshots, history, and value graphs with explicit partial coverage.",
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
registerProvider({
|
|
113
|
-
id: "nft-portfolio",
|
|
114
|
-
venue: "multichain-nft-wallet",
|
|
115
|
-
chainIds: [1, 10, 137, 988, 999, 2741, 4663, 8453, 42161, 43114],
|
|
116
|
-
auth: "optionalApiKey",
|
|
117
|
-
ops: ["health", "inventory", "gallery", "pnl", "prepareList"],
|
|
118
|
-
execution: "prepare",
|
|
119
|
-
baseEnv: ["OPENSEA_API_KEY", "MAGICEDEN_API_KEY", "SATFLOW_API_KEY"],
|
|
120
|
-
description:
|
|
121
|
-
"Normalized EVM, Solana, and Bitcoin NFT inventory, static contact-sheet galleries, explicit PnL coverage, and user-confirmed unsigned listing preparation.",
|
|
122
|
-
});
|
|
123
|
-
|
|
124
101
|
registerProvider({
|
|
125
102
|
id: "evm-rpc",
|
|
126
103
|
venue: "evm",
|
|
@@ -404,12 +381,11 @@ registerProvider({
|
|
|
404
381
|
registerProvider({
|
|
405
382
|
id: "opensea-nft",
|
|
406
383
|
venue: "nft",
|
|
407
|
-
chainIds: [1
|
|
384
|
+
chainIds: [1],
|
|
408
385
|
auth: "apiKey",
|
|
409
|
-
ops: ["health", "collection", "floor"
|
|
410
|
-
execution: "prepare",
|
|
386
|
+
ops: ["health", "collection", "floor"],
|
|
411
387
|
baseEnv: ["OPENSEA_API_KEY", "OPENSEA_ENV_FILE"],
|
|
412
|
-
description: "OpenSea
|
|
388
|
+
description: "OpenSea collection + floor (OPENSEA_API_KEY)",
|
|
413
389
|
});
|
|
414
390
|
|
|
415
391
|
registerProvider({
|
package/src/data/desk-data.mjs
CHANGED
|
@@ -40,9 +40,6 @@ import * as balancer from "./providers/balancer.mjs";
|
|
|
40
40
|
import * as pendle from "./providers/pendle.mjs";
|
|
41
41
|
import * as odos from "./providers/odos.mjs";
|
|
42
42
|
import * as blockscout from "./providers/blockscout.mjs";
|
|
43
|
-
import * as portfolio from "./providers/portfolio.mjs";
|
|
44
|
-
import * as portfolioHistory from "./providers/portfolio-history.mjs";
|
|
45
|
-
import * as nftPortfolio from "./providers/nft-portfolio.mjs";
|
|
46
43
|
import * as paraswap from "./providers/paraswap.mjs";
|
|
47
44
|
|
|
48
45
|
const OPS = {
|
|
@@ -93,20 +90,6 @@ const OPS = {
|
|
|
93
90
|
erc20Balance: (o, a = {}) => rpc.erc20BalanceOf(a, o),
|
|
94
91
|
transactionReceipt: (o, a = {}) => rpc.transactionReceipt(a, o),
|
|
95
92
|
},
|
|
96
|
-
portfolio: {
|
|
97
|
-
health: (o) => portfolio.portfolioHealth(o),
|
|
98
|
-
balances: (o, a = {}) => portfolio.portfolioBalance(a, o),
|
|
99
|
-
snapshot: (o, a = {}) => portfolioHistory.portfolioSnapshot(a, o),
|
|
100
|
-
history: (o, a = {}) => portfolioHistory.portfolioHistory(a, o),
|
|
101
|
-
valueGraph: (o, a = {}) => portfolioHistory.portfolioValueGraph(a, o),
|
|
102
|
-
},
|
|
103
|
-
"nft-portfolio": {
|
|
104
|
-
health: (o) => nftPortfolio.nftHealth(o),
|
|
105
|
-
inventory: (o, a = {}) => nftPortfolio.nftInventory(a, o),
|
|
106
|
-
gallery: (o, a = {}) => nftPortfolio.nftPortfolioGallery(a, o),
|
|
107
|
-
pnl: (o, a = {}) => nftPortfolio.nftPnl(a, o),
|
|
108
|
-
prepareList: (o, a = {}) => nftPortfolio.nftPrepareList(a, o),
|
|
109
|
-
},
|
|
110
93
|
"solana-rpc": {
|
|
111
94
|
health: (o) => solana.solanaHealth(o),
|
|
112
95
|
latestBlockhash: (o, a = {}) => solana.solanaLatestBlockhash(a, o),
|
|
@@ -230,9 +213,6 @@ const OPS = {
|
|
|
230
213
|
health: (o) => osnft.openseaHealth(o),
|
|
231
214
|
collection: (o, a = {}) => osnft.openseaCollection(a.slug, o),
|
|
232
215
|
floor: (o, a = {}) => osnft.openseaFloor(a.slug, o),
|
|
233
|
-
accountNfts: (o, a = {}) => osnft.openseaAccountNfts(a, o),
|
|
234
|
-
accountPnl: (o, a = {}) => osnft.openseaAccountPnl(a, o),
|
|
235
|
-
prepareList: (o, a = {}) => osnft.openseaPrepareList(a, o),
|
|
236
216
|
},
|
|
237
217
|
|
|
238
218
|
"hl-outcome": {
|
|
@@ -590,20 +570,6 @@ export const data = {
|
|
|
590
570
|
call: (chainId, method, params, o) =>
|
|
591
571
|
dataCall("evm-rpc", "call", { chainId, method, params }, o),
|
|
592
572
|
},
|
|
593
|
-
portfolio: {
|
|
594
|
-
balance: (a, o) => dataCall("portfolio", "balances", a || {}, o),
|
|
595
|
-
snapshot: (a, o) => dataCall("portfolio", "snapshot", a || {}, o),
|
|
596
|
-
history: (a, o) => dataCall("portfolio", "history", a || {}, o),
|
|
597
|
-
valueGraph: (a, o) => dataCall("portfolio", "valueGraph", a || {}, o),
|
|
598
|
-
},
|
|
599
|
-
nft: {
|
|
600
|
-
inventory: (a, o) => dataCall("nft-portfolio", "inventory", a || {}, o),
|
|
601
|
-
gallery: (a, o) => dataCall("nft-portfolio", "gallery", a || {}, o),
|
|
602
|
-
pnl: (a, o) => dataCall("nft-portfolio", "pnl", a || {}, o),
|
|
603
|
-
prepareList: (a, o) => dataCall("nft-portfolio", "prepareList", a || {}, o),
|
|
604
|
-
floor: (slug, o) => dataCall("opensea-nft", "floor", { slug }, o),
|
|
605
|
-
collection: (slug, o) => dataCall("opensea-nft", "collection", { slug }, o),
|
|
606
|
-
},
|
|
607
573
|
solana: {
|
|
608
574
|
health: (o) => dataCall("solana-rpc", "health", {}, o),
|
|
609
575
|
latestBlockhash: (a, o) => dataCall("solana-rpc", "latestBlockhash", a || {}, o),
|
|
@@ -667,6 +633,10 @@ export const data = {
|
|
|
667
633
|
cow: {
|
|
668
634
|
quote: (a, o) => dataCall("cowswap", "quote", a || {}, o),
|
|
669
635
|
},
|
|
636
|
+
nft: {
|
|
637
|
+
floor: (slug, o) => dataCall("opensea-nft", "floor", { slug }, o),
|
|
638
|
+
collection: (slug, o) => dataCall("opensea-nft", "collection", { slug }, o),
|
|
639
|
+
},
|
|
670
640
|
hlWs: {
|
|
671
641
|
allMids: (o) => dataCall("hl-ws", "allMids", {}, o),
|
|
672
642
|
l2Book: (coin, o) => dataCall("hl-ws", "l2Book", { coin }, o),
|
|
@@ -89,18 +89,6 @@ function lamports(sol) {
|
|
|
89
89
|
return Math.round(positiveNumber(sol, "priceSol") * LAMPORTS_PER_SOL);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function listingExpiry(value) {
|
|
93
|
-
if (value == null || value === "") return null;
|
|
94
|
-
const expiry = Number(value);
|
|
95
|
-
if (!Number.isSafeInteger(expiry) || expiry < 0) {
|
|
96
|
-
throw new Error("magiceden: expiry must be a whole Unix timestamp in seconds or 0");
|
|
97
|
-
}
|
|
98
|
-
if (expiry !== 0 && expiry <= Math.floor(Date.now() / 1000)) {
|
|
99
|
-
throw new Error("magiceden: expiry must be in the future or 0 for no expiry");
|
|
100
|
-
}
|
|
101
|
-
return expiry;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
92
|
export async function magicEdenSolHealth(opts = {}) {
|
|
105
93
|
try {
|
|
106
94
|
const stats = await magicEdenSolStats({ symbol: "mad_lads" }, opts);
|
|
@@ -268,26 +256,20 @@ export async function magicEdenSolPrepareList(args = {}, opts = {}) {
|
|
|
268
256
|
const tokenATA = solanaPubkey(args.tokenATA || args.tokenAddress, "tokenATA");
|
|
269
257
|
const auctionHouse = solanaPubkey(args.auctionHouse, "auctionHouse");
|
|
270
258
|
const priceSol = positiveNumber(args.priceSol ?? args.price, "priceSol");
|
|
271
|
-
const expiry = listingExpiry(args.expiry);
|
|
272
259
|
const url = new URL(`${base(opts)}/instructions/sell`);
|
|
273
260
|
url.searchParams.set("seller", seller);
|
|
274
261
|
url.searchParams.set("auctionHouseAddress", auctionHouse);
|
|
275
262
|
url.searchParams.set("tokenMint", tokenMint);
|
|
276
263
|
url.searchParams.set("tokenAccount", tokenATA);
|
|
277
264
|
url.searchParams.set("price", String(priceSol));
|
|
278
|
-
if (args.sellerReferral) url.searchParams.set("sellerReferral", solanaPubkey(args.sellerReferral, "sellerReferral"));
|
|
279
|
-
if (expiry != null) url.searchParams.set("expiry", String(expiry));
|
|
280
265
|
const raw = await httpJson(url.toString(), {
|
|
281
266
|
headers: headers(opts),
|
|
282
267
|
fetchImpl: opts.fetchImpl,
|
|
283
268
|
timeoutMs: opts.timeoutMs ?? 15_000,
|
|
284
269
|
});
|
|
285
270
|
const data = raw?.v0?.tx?.data ?? raw?.tx?.data ?? null;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
throw new Error("magiceden: sell returned no unsigned transaction payload");
|
|
289
|
-
}
|
|
290
|
-
const transaction = Buffer.from(data).toString("base64");
|
|
271
|
+
const transaction = Array.isArray(data) ? Buffer.from(data).toString("base64") : null;
|
|
272
|
+
if (!transaction) throw new Error("magiceden: sell returned no transaction payload");
|
|
291
273
|
return stampPrepared({
|
|
292
274
|
provider: "magiceden-sol",
|
|
293
275
|
chain: "solana-mainnet-beta",
|
|
@@ -300,7 +282,6 @@ export async function magicEdenSolPrepareList(args = {}, opts = {}) {
|
|
|
300
282
|
seller,
|
|
301
283
|
tokenMint,
|
|
302
284
|
priceSol,
|
|
303
|
-
expiry,
|
|
304
285
|
transaction,
|
|
305
286
|
transactionEncoding: "base64",
|
|
306
287
|
raw,
|