@seekdaseek/plugin-agentfeed 0.1.1 → 0.2.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/index.d.ts CHANGED
@@ -18,6 +18,8 @@ declare class AgentFeedService extends Service {
18
18
  private payerAddress;
19
19
  /** path -> { usd, checkedAt } of last approved quote */
20
20
  private approvedQuotes;
21
+ /** requirements that survived the spend policy on the most recent payment */
22
+ private lastSurvivingReqs;
21
23
  /** lifetime spend counter for this process (informational) */
22
24
  private totalSpentUsd;
23
25
  constructor(runtime: IAgentRuntime);
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { ExactSvmScheme } from "@x402/svm/exact/client";
6
6
  import { wrapFetchWithPaymentFromConfig, decodePaymentResponseHeader } from "@x402/fetch";
7
7
  import bs58 from "bs58";
8
8
  var DEFAULT_BASE_URL = "https://x402.ochinimus.app";
9
- var DEFAULT_MAX_SPEND_USD = 0.02;
9
+ var DEFAULT_MAX_SPEND_USD = 0.05;
10
10
  var QUOTE_TTL_MS = 10 * 60 * 1e3;
11
11
  var USDC_DECIMALS = 6;
12
12
  var AgentFeedService = class _AgentFeedService extends Service {
@@ -23,6 +23,8 @@ var AgentFeedService = class _AgentFeedService extends Service {
23
23
  payerAddress = "";
24
24
  /** path -> { usd, checkedAt } of last approved quote */
25
25
  approvedQuotes = /* @__PURE__ */ new Map();
26
+ /** requirements that survived the spend policy on the most recent payment */
27
+ lastSurvivingReqs = [];
26
28
  /** lifetime spend counter for this process (informational) */
27
29
  totalSpentUsd = 0;
28
30
  static async start(runtime) {
@@ -51,10 +53,14 @@ var AgentFeedService = class _AgentFeedService extends Service {
51
53
  this.payerAddress = keypair.address;
52
54
  const signer = toClientSvmSigner(keypair);
53
55
  const capBaseUnits = Math.round(this.maxSpendUsd * 10 ** USDC_DECIMALS);
54
- const maxSpendPolicy = (_v, reqs) => reqs.filter((r) => {
55
- const raw = Number(r?.maxAmountRequired ?? r?.amount ?? r?.maxAmount);
56
- return Number.isFinite(raw) && raw > 0 && raw <= capBaseUnits;
57
- });
56
+ const maxSpendPolicy = (_v, reqs) => {
57
+ const surviving = reqs.filter((r) => {
58
+ const raw = Number(r?.maxAmountRequired ?? r?.amount ?? r?.maxAmount);
59
+ return Number.isFinite(raw) && raw > 0 && raw <= capBaseUnits;
60
+ });
61
+ this.lastSurvivingReqs = surviving;
62
+ return surviving;
63
+ };
58
64
  this.payFetch = wrapFetchWithPaymentFromConfig(fetch, {
59
65
  schemes: [{ network: "solana:*", client: new ExactSvmScheme(signer) }],
60
66
  policies: [maxSpendPolicy]
@@ -132,8 +138,19 @@ var AgentFeedService = class _AgentFeedService extends Service {
132
138
  if (!res.ok) {
133
139
  return { ok: false, status: res.status, data, error: `AgentFeed HTTP ${res.status}` };
134
140
  }
135
- if (settlement) this.totalSpentUsd += quotedUsd;
136
- return { ok: true, status: res.status, data, paidUsd: settlement ? quotedUsd : 0, settlement };
141
+ let paidUsd = 0;
142
+ if (settlement) {
143
+ const s = settlement;
144
+ let raw = Number(s?.amount ?? s?.paidAmount);
145
+ if (!Number.isFinite(raw) || raw <= 0) {
146
+ const net = String(s?.network ?? "");
147
+ const req = this.lastSurvivingReqs.find((r) => String(r?.network ?? "") === net) ?? this.lastSurvivingReqs[0];
148
+ raw = Number(req?.maxAmountRequired ?? req?.amount ?? req?.maxAmount);
149
+ }
150
+ paidUsd = Number.isFinite(raw) && raw > 0 ? raw / 10 ** USDC_DECIMALS : quotedUsd;
151
+ this.totalSpentUsd += paidUsd;
152
+ }
153
+ return { ok: true, status: res.status, data, paidUsd, settlement };
137
154
  } catch (e) {
138
155
  return { ok: false, status: 0, data: null, error: e?.message || String(e) };
139
156
  }
@@ -157,6 +174,43 @@ function parseKey(raw) {
157
174
 
158
175
  // src/endpoints.ts
159
176
  var ENDPOINTS = [
177
+ {
178
+ path: "/api/cascade-scan",
179
+ usd: 0.05,
180
+ action: "AGENTFEED_GET_CASCADE_SCAN",
181
+ similes: ["CASCADE_SCAN", "FULL_CASCADE_SCAN", "SCAN_ALL_LIQUIDATIONS", "WHAT_IS_CASCADING"],
182
+ description: "Scan for liquidation cascades across the FULL universe of ~600 USDT perps on Bybit, OKX and Binance simultaneously ($0.05) \u2014 not just the majors. Returns each active cascade: symbol, side liquidated, USD total, print count, duration, severity (minor/major/extreme). Bybit is the only complete unthrottled liquidation tape in crypto and no exchange publishes history of it, so this coverage is not available anywhere else. Use when the agent needs to know what is blowing up across the whole market, including alts it is not already watching.",
183
+ triggers: [
184
+ "is anything cascading right now",
185
+ "scan the whole market for liquidation cascades",
186
+ "what alts are getting liquidated hard",
187
+ "any cascades outside the majors"
188
+ ]
189
+ },
190
+ {
191
+ path: "/api/liquidation-leaders",
192
+ usd: 0.02,
193
+ action: "AGENTFEED_GET_LIQUIDATION_LEADERS",
194
+ similes: ["LIQUIDATION_LEADERS", "WHATS_GETTING_REKT", "TOP_LIQUIDATIONS"],
195
+ description: "Rank the top symbols by liquidation USD right now across ~600 USDT perps on Bybit, OKX and Binance ($0.02). Per symbol: total liquidated, long vs short split, biggest single print, venue count, dominant side. The fastest read on where leverage is being flushed.",
196
+ triggers: [
197
+ "what is getting rekt right now",
198
+ "which coins have the most liquidations today",
199
+ "where is leverage being flushed"
200
+ ]
201
+ },
202
+ {
203
+ path: "/api/cascade",
204
+ usd: 0.01,
205
+ action: "AGENTFEED_GET_CASCADE_ALERT",
206
+ similes: ["CASCADE_ALERT", "IS_THERE_A_CASCADE"],
207
+ description: "Liquidation cascade detector for the 5 majors \u2014 SOL, BTC, ETH, XRP, DOGE \u2014 across Bybit, OKX and Binance ($0.01). Returns cascades active NOW: clustered same-side liquidations with symbol, side, USD total, prints, duration, severity. Empty array = no cascade in the window. For all ~600 perps use AGENTFEED_GET_CASCADE_SCAN instead.",
208
+ triggers: [
209
+ "is SOL cascading",
210
+ "is there a liquidation cascade on BTC right now",
211
+ "check for a cascade before I enter"
212
+ ]
213
+ },
160
214
  {
161
215
  path: "/api/trade-context",
162
216
  usd: 0.01,
@@ -175,7 +229,7 @@ var ENDPOINTS = [
175
229
  usd: 3e-3,
176
230
  action: "AGENTFEED_GET_LIQUIDATIONS",
177
231
  similes: ["GET_RECENT_LIQUIDATIONS", "RECENT_LIQUIDATIONS", "LIQUIDATION_FEED"],
178
- description: "Fetch recent SOL/BTC perp liquidation prints ($0.003): side, size, price, exchange, timestamp. Use for questions about recent liquidations, cascades, or big liquidation prints.",
232
+ description: "Fetch recent perp liquidation prints ($0.003) across ~600 USDT perps on Bybit (complete unthrottled tape), OKX and Binance: side, size, price, exchange, timestamp. Filterable by symbol \u2014 any USDT perp, not just majors. Use for questions about recent liquidations or big prints.",
179
233
  triggers: [
180
234
  "any big liquidations in the last hour",
181
235
  "show me recent SOL liquidations",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@seekdaseek/plugin-agentfeed",
3
- "version": "0.1.1",
4
- "description": "elizaOS plugin for AgentFeed — paid crypto market data (liquidations, positioning, funding, token risk) over x402 micropayments on Solana. $0.001–$0.01 per call in USDC, no API keys, no subscriptions.",
3
+ "version": "0.2.0",
4
+ "description": "elizaOS plugin for AgentFeed — paid crypto liquidation data over x402 micropayments on Solana. Full-universe cascade detection across ~600 USDT perps on Bybit, OKX and Binance, plus positioning, funding, prices and token risk. $0.001–$0.05 per call in USDC, no API keys, no subscriptions.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "AGENTFEED_MAX_SPEND_PER_CALL": {
67
67
  "type": "string",
68
- "description": "Safety cap in USD per single API call. Any 402 quote above this is refused. Default: 0.02"
68
+ "description": "Safety cap in USD per single API call. Any 402 quote above this is refused. Default: 0.05 (the price of the most expensive tool, get_cascade_scan). Lower it to restrict spend; raise it only if AgentFeed adds a pricier tool."
69
69
  }
70
70
  }
71
71
  }