@oracle-agent/oracle 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oracle-agent/oracle",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Oracle: prepare-only multichain agent control plane. Policy-bounded intents for a user-signed wallet. Self-custody by default — the public package never takes your key. Built for Hermes; no model key required.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -6,6 +6,7 @@
6
6
  import { Interface, getAddress, isAddress } from "ethers";
7
7
  import { rpcCall } from "./evm-rpc.mjs";
8
8
  import { attachAutoSlippage, bindAutoSlippageGuardToCall } from "../../auto-slippage.mjs";
9
+ import { stampPrepared } from "../../prepare-envelope.mjs";
9
10
 
10
11
  /** @type {Record<number, { name: string, quoter: string, router: string, factory: string, weth: string, usdc: string }>} */
11
12
  export const AERODROME_CHAINS = {
@@ -172,7 +173,7 @@ export async function aerodromePrepareExactIn(q = {}, opts = {}) {
172
173
  sqrtPriceLimitX96: 0n,
173
174
  },
174
175
  ]);
175
- return {
176
+ return stampPrepared({
176
177
  provider: "aerodrome",
177
178
  calldataReady: true,
178
179
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -201,7 +202,7 @@ export async function aerodromePrepareExactIn(q = {}, opts = {}) {
201
202
  value: nativeInput ? quote.amountIn : "0",
202
203
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: meta.router, data }),
203
204
  },
204
- };
205
+ }, { provider: "aerodrome", kind: "aerodrome-exact-in" });
205
206
  }
206
207
 
207
208
  export async function aerodromeHealth(opts = {}) {
@@ -3,6 +3,7 @@ import { Interface, getAddress, isAddress } from "ethers";
3
3
  import { httpJson } from "../http.mjs";
4
4
  import { rpcCall as defaultRpcCall } from "./evm-rpc.mjs";
5
5
  import { attachAutoSlippage, bindAutoSlippageGuardToCall } from "../../auto-slippage.mjs";
6
+ import { stampPrepared } from "../../prepare-envelope.mjs";
6
7
 
7
8
  export const BALANCER_API = "https://api-v3.balancer.fi/";
8
9
  const endpoint = (o = {}) => o.baseUrl || process.env.BALANCER_API_URL || BALANCER_API;
@@ -177,7 +178,7 @@ export async function balancerPrepare(q = {}, opts = {}) {
177
178
  wethIsEth,
178
179
  userData(q.userData),
179
180
  ]);
180
- return {
181
+ return stampPrepared({
181
182
  provider: "balancer",
182
183
  calldataReady: true,
183
184
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -204,5 +205,5 @@ export async function balancerPrepare(q = {}, opts = {}) {
204
205
  value: nativeInput ? quote.amountIn : "0",
205
206
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId: meta.chainId, venue: meta.router, data }),
206
207
  },
207
- };
208
+ }, { provider: "balancer", kind: "balancer-tx" });
208
209
  }
@@ -3,6 +3,7 @@
3
3
  import { httpJson } from "../http.mjs";
4
4
  import { attachAutoSlippage, bindAutoSlippageGuardToCall, resolveAutoSlippage } from "../../auto-slippage.mjs";
5
5
  import { QUOTE_PLACEHOLDER_ADDRESS, quoteAddress } from "../quote-placeholder.mjs";
6
+ import { stampPrepared } from "../../prepare-envelope.mjs";
6
7
 
7
8
  export const ACROSS_API = "https://across.to/api";
8
9
  export const HOP_API = "https://api.hop.exchange/v1";
@@ -223,7 +224,7 @@ export async function relayPrepare(q = {}, opts = {}) {
223
224
  ...(tx.gasLimit != null || tx.gas != null ? { gasLimit: tx.gasLimit ?? tx.gas } : {}),
224
225
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: tx.to, data: tx.data }),
225
226
  }));
226
- return {
227
+ return stampPrepared({
227
228
  provider: "relay",
228
229
  calldataReady: true,
229
230
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -237,5 +238,5 @@ export async function relayPrepare(q = {}, opts = {}) {
237
238
  quote,
238
239
  autoSlippage: quote.autoSlippage,
239
240
  transactions,
240
- };
241
+ }, { provider: "relay", kind: "relay-tx" });
241
242
  }
@@ -7,6 +7,7 @@ import { httpJson } from "../http.mjs";
7
7
  import { attachAutoSlippage } from "../../auto-slippage.mjs";
8
8
  import { autonomousTradingEnabled } from "../../capability-posture.mjs";
9
9
  import { QUOTE_PLACEHOLDER_ADDRESS, quoteAddress } from "../quote-placeholder.mjs";
10
+ import { stampPrepared } from "../../prepare-envelope.mjs";
10
11
 
11
12
  export const COW_HOSTS = {
12
13
  1: "https://api.cow.fi/mainnet/api/v1",
@@ -263,7 +264,7 @@ export async function cowPrepareOrder(q = {}, opts = {}) {
263
264
  const typedDataHash = TypedDataEncoder.hash(domain, COW_ORDER_TYPES, order);
264
265
  const relayer = COW_VAULT_RELAYER[chainId];
265
266
  if (!relayer) throw new Error(`cowswap: vault relayer not registered for chain ${chainId}`);
266
- return {
267
+ return stampPrepared({
267
268
  provider: "cowswap",
268
269
  orderReady: true,
269
270
  executionReady: false,
@@ -298,7 +299,7 @@ export async function cowPrepareOrder(q = {}, opts = {}) {
298
299
  spender: getAddress(relayer).toLowerCase(),
299
300
  amount: order.sellAmount,
300
301
  },
301
- };
302
+ }, { provider: "cowswap", kind: "cow-order" });
302
303
  }
303
304
 
304
305
  export async function cowOrderStatus(q = {}, opts = {}) {
@@ -346,7 +347,7 @@ export function cowPrepareCancel(q = {}) {
346
347
  if (!orderUids.length) throw new Error("cowswap: orderUids required");
347
348
  const domain = orderDomain(chainId);
348
349
  const message = { orderUids };
349
- return {
350
+ return stampPrepared({
350
351
  provider: "cowswap",
351
352
  chainId,
352
353
  owner,
@@ -355,7 +356,7 @@ export function cowPrepareCancel(q = {}) {
355
356
  typedData: { domain, types: COW_CANCEL_TYPES, primaryType: "OrderCancellations", message },
356
357
  cancelReady: true,
357
358
  executableArtifact: true,
358
- };
359
+ }, { provider: "cowswap", kind: "cow-cancel" });
359
360
  }
360
361
 
361
362
  export async function cowSignCancel(_a = {}, _o = {}) {
@@ -3,6 +3,7 @@ import { Interface, getAddress, isAddress } from "ethers";
3
3
  import { httpJson } from "../http.mjs";
4
4
  import { rpcCall as defaultRpcCall } from "./evm-rpc.mjs";
5
5
  import { attachAutoSlippage, bindAutoSlippageGuardToCall } from "../../auto-slippage.mjs";
6
+ import { stampPrepared } from "../../prepare-envelope.mjs";
6
7
 
7
8
  export const CURVE_API = "https://api.curve.finance/v1";
8
9
  const base = (o = {}) => (o.baseUrl || process.env.CURVE_API_URL || CURVE_API).replace(/\/$/, "");
@@ -170,7 +171,7 @@ export async function curvePrepare(q = {}, opts = {}) {
170
171
  pools,
171
172
  receiver,
172
173
  ]);
173
- return {
174
+ return stampPrepared({
174
175
  provider: "curve",
175
176
  calldataReady: true,
176
177
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -196,5 +197,5 @@ export async function curvePrepare(q = {}, opts = {}) {
196
197
  value: "0",
197
198
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: router, data }),
198
199
  },
199
- };
200
+ }, { provider: "curve", kind: "curve-tx" });
200
201
  }
@@ -4,6 +4,7 @@
4
4
  import { Interface, getAddress, isAddress } from "ethers";
5
5
  import { httpJson } from "../http.mjs";
6
6
  import { rpcCall as defaultRpcCall, transactionReceipt } from "./evm-rpc.mjs";
7
+ import { stampPrepared } from "../../prepare-envelope.mjs";
7
8
 
8
9
  export const GMX_API = Object.freeze({
9
10
  42161: "https://arbitrum-api.gmxinfra.io",
@@ -468,7 +469,7 @@ export async function gmxPrepareOrder(args = {}, opts = {}) {
468
469
  asyncExecution: true,
469
470
  issuedAtMs: Number(opts.nowMs ?? Date.now()),
470
471
  };
471
- return {
472
+ return stampPrepared({
472
473
  provider: "gmx",
473
474
  chainId: meta.chainId,
474
475
  chain: meta.name,
@@ -491,5 +492,5 @@ export async function gmxPrepareOrder(args = {}, opts = {}) {
491
492
  value: executionFee.toString(),
492
493
  gmxGuard,
493
494
  },
494
- };
495
+ }, { provider: "gmx", kind: "gmx-order" });
495
496
  }
@@ -10,6 +10,7 @@
10
10
  // validator -> staking balance : tokenDelegate (isUndelegate=true) [1 day validator lockup]
11
11
  // staking balance -> spot : cWithdraw [7 day unstaking queue]
12
12
 
13
+ import { stampPrepared } from "../../prepare-envelope.mjs";
13
14
  import { httpJson } from "../http.mjs";
14
15
  import { hlInfo } from "./hl-info.mjs";
15
16
  export const HYPE_STAKING_DECIMALS = 8;
@@ -171,7 +172,7 @@ function eip712Domain(opts = {}) {
171
172
  }
172
173
 
173
174
  function preparedAction({ kind, action, types, primaryType, message, opts, notes, caps }) {
174
- return {
175
+ return stampPrepared({
175
176
  provider: "hl-staking",
176
177
  venue: "hypercore",
177
178
  chain: hyperliquidChain(opts),
@@ -194,7 +195,7 @@ function preparedAction({ kind, action, types, primaryType, message, opts, notes
194
195
  caps: caps || null,
195
196
  notes,
196
197
  exec: false,
197
- };
198
+ }, { provider: "hl-staking", kind });
198
199
  }
199
200
 
200
201
  /** spot HYPE -> staking balance. Instant. */
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { httpJson } from "../http.mjs";
5
5
  import { solanaPubkey } from "./solana-rpc.mjs";
6
+ import { stampPrepared } from "../../prepare-envelope.mjs";
6
7
 
7
8
  export const JUPITER_SWAP_API = "https://lite-api.jup.ag/swap/v1";
8
9
  export const SOL_MINT = "So11111111111111111111111111111111111111112";
@@ -158,7 +159,7 @@ export async function jupiterPrepareSwap(args = {}, opts = {}) {
158
159
  }
159
160
  }
160
161
 
161
- return {
162
+ return stampPrepared({
162
163
  provider: "jupiter",
163
164
  chain: "solana-mainnet-beta",
164
165
  prepareReady: true,
@@ -178,5 +179,5 @@ export async function jupiterPrepareSwap(args = {}, opts = {}) {
178
179
  prioritizationFeeLamports: response?.prioritizationFeeLamports ?? null,
179
180
  computeUnitLimit: response?.computeUnitLimit ?? null,
180
181
  raw: response,
181
- };
182
+ }, { provider: "jupiter", kind: "jupiter-swap" });
182
183
  }
@@ -3,6 +3,7 @@
3
3
  import { httpJson } from "../http.mjs";
4
4
  import { attachAutoSlippage, bindAutoSlippageGuardToCall, resolveAutoSlippage } from "../../auto-slippage.mjs";
5
5
  import { QUOTE_PLACEHOLDER_ADDRESS, quoteAddress } from "../quote-placeholder.mjs";
6
+ import { stampPrepared } from "../../prepare-envelope.mjs";
6
7
 
7
8
  export const LIFI_API = "https://li.quest/v1";
8
9
 
@@ -116,7 +117,7 @@ export async function lifiPrepare(q = {}, opts = {}) {
116
117
  amount: String(q.fromAmount),
117
118
  };
118
119
  }
119
- return {
120
+ return stampPrepared({
120
121
  provider: "lifi",
121
122
  calldataReady: true,
122
123
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -139,7 +140,7 @@ export async function lifiPrepare(q = {}, opts = {}) {
139
140
  ...(tx.gasLimit != null ? { gasLimit: tx.gasLimit } : {}),
140
141
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: tx.to, data: tx.data }),
141
142
  },
142
- };
143
+ }, { provider: "lifi", kind: "lifi-tx" });
143
144
  }
144
145
 
145
146
  export async function lifiChains(opts = {}) {
@@ -16,6 +16,7 @@
16
16
  import { isAddress } from "ethers";
17
17
  import { httpJson } from "../http.mjs";
18
18
  import { attachAutoSlippage, bindAutoSlippageGuardToCall, resolveAutoSlippage } from "../../auto-slippage.mjs";
19
+ import { stampPrepared } from "../../prepare-envelope.mjs";
19
20
 
20
21
  export const ODOS_API = "https://api.odos.xyz";
21
22
  const base = (o = {}) => (o.baseUrl || process.env.ODOS_API_URL || ODOS_API).replace(/\/$/, "");
@@ -121,7 +122,7 @@ export async function odosPrepare(args = {}, opts = {}) {
121
122
  const approvals = args.inputTokens
122
123
  .filter((item) => ![native, zeroNative].includes(String(item.tokenAddress).toLowerCase()))
123
124
  .map((item) => ({ token: item.tokenAddress, spender: tx.to, amount: String(item.amount) }));
124
- return {
125
+ return stampPrepared({
125
126
  provider: "odos",
126
127
  calldataReady: true,
127
128
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -146,7 +147,7 @@ export async function odosPrepare(args = {}, opts = {}) {
146
147
  ...(tx.nonce != null ? { nonce: tx.nonce } : {}),
147
148
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: tx.to, data: tx.data }),
148
149
  },
149
- };
150
+ }, { provider: "odos", kind: "odos-tx" });
150
151
  }
151
152
 
152
153
  export async function odosHealth(opts = {}) {
@@ -3,6 +3,7 @@
3
3
  import { httpJson } from "../http.mjs";
4
4
  import { attachAutoSlippage, bindAutoSlippageGuardToCall, resolveAutoSlippage } from "../../auto-slippage.mjs";
5
5
  import { resolveProviderEndpoint, credentialedHeaders } from "../provider-endpoint.mjs";
6
+ import { stampPrepared } from "../../prepare-envelope.mjs";
6
7
 
7
8
  export const ONEINCH_API = "https://api.1inch.dev/swap/v6.0";
8
9
 
@@ -146,7 +147,7 @@ export async function oneinchPrepare(q = {}, opts = {}) {
146
147
  if (!spender) throw new Error("1inch: ERC-20 route missing approval spender");
147
148
  requiresApproval = { token: src, spender, amount: String(amount) };
148
149
  }
149
- return {
150
+ return stampPrepared({
150
151
  provider: "oneinch",
151
152
  calldataReady: true,
152
153
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -169,5 +170,5 @@ export async function oneinchPrepare(q = {}, opts = {}) {
169
170
  ...(tx.gas != null ? { gasLimit: tx.gas } : {}),
170
171
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: tx.to, data: tx.data }),
171
172
  },
172
- };
173
+ }, { provider: "oneinch", kind: "oneinch-tx" });
173
174
  }
@@ -1,6 +1,7 @@
1
1
  // ParaSwap/Velora public market API — keyless price routes, quote-only here.
2
2
  import { httpJson } from "../http.mjs";
3
3
  import { attachAutoSlippage, bindAutoSlippageGuardToCall } from "../../auto-slippage.mjs";
4
+ import { stampPrepared } from "../../prepare-envelope.mjs";
4
5
 
5
6
  export const PARASWAP_API = "https://api.paraswap.io";
6
7
  const base = (o = {}) => (o.baseUrl || process.env.PARASWAP_API_URL || PARASWAP_API).replace(/\/$/, "");
@@ -82,7 +83,7 @@ export async function paraswapPrepare(args = {}, opts = {}) {
82
83
  if (Number(tx.chainId ?? chainId) !== chainId) throw new Error("paraswap: transaction chain mismatch");
83
84
  if (String(tx.to || "").toLowerCase() !== expectedTarget) throw new Error("paraswap: transaction target mismatch");
84
85
  if (tx.from && String(tx.from).toLowerCase() !== userAddress) throw new Error("paraswap: transaction sender mismatch");
85
- return {
86
+ return stampPrepared({
86
87
  provider: "paraswap",
87
88
  calldataReady: true,
88
89
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -107,7 +108,7 @@ export async function paraswapPrepare(args = {}, opts = {}) {
107
108
  ...(tx.gas != null ? { gasLimit: tx.gas } : {}),
108
109
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: tx.to, data: tx.data }),
109
110
  },
110
- };
111
+ }, { provider: "paraswap", kind: "paraswap-tx" });
111
112
  }
112
113
 
113
114
  export async function paraswapHealth(opts = {}) {
@@ -3,6 +3,7 @@
3
3
  import { httpJson } from "../http.mjs";
4
4
  import { attachAutoSlippage, bindAutoSlippageGuardToCall, resolveAutoSlippage } from "../../auto-slippage.mjs";
5
5
  import { resolveProviderEndpoint, credentialedHeaders } from "../provider-endpoint.mjs";
6
+ import { stampPrepared } from "../../prepare-envelope.mjs";
6
7
 
7
8
  export const ZEROX_API = "https://api.0x.org";
8
9
 
@@ -137,7 +138,7 @@ export async function zeroxPrepare(q = {}, opts = {}) {
137
138
  if (!tx?.to || !tx?.data) throw new Error("0x: firm quote returned no transaction");
138
139
  const chainId = Number(q.chainId ?? 8453);
139
140
  const spender = quote?.issues?.allowance?.spender || quote?.allowanceTarget;
140
- return {
141
+ return stampPrepared({
141
142
  provider: "zerox",
142
143
  calldataReady: true,
143
144
  // NOT executable authority. The bytes are assembled but nothing is signed:
@@ -162,5 +163,5 @@ export async function zeroxPrepare(q = {}, opts = {}) {
162
163
  ...(tx.gas != null ? { gasLimit: tx.gas } : {}),
163
164
  slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: tx.to, data: tx.data }),
164
165
  },
165
- };
166
+ }, { provider: "zerox", kind: "zerox-tx" });
166
167
  }
@@ -23,6 +23,7 @@
23
23
  // Custody is unchanged: artifacts only. This module cannot sign or broadcast.
24
24
 
25
25
  import { bestBridgeRoute } from "./index.mjs";
26
+ import { stampPrepared } from "../prepare-envelope.mjs";
26
27
 
27
28
  const ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
28
29
 
@@ -249,7 +250,7 @@ export async function prepareBestBridgeRoute(p, opts = {}) {
249
250
  );
250
251
  }
251
252
 
252
- return {
253
+ return stampPrepared({
253
254
  ok: true,
254
255
  chosen: {
255
256
  source: chosenSource,
@@ -284,5 +285,5 @@ export async function prepareBestBridgeRoute(p, opts = {}) {
284
285
  note:
285
286
  `UNSIGNED. ${txs.length} transaction(s) on chain ${fromChainId}, crediting ` +
286
287
  `chain ${toChainId}. Verify every destination address before signing.`,
287
- };
288
+ }, { provider: "router", kind: "best-bridge" });
288
289
  }
@@ -26,6 +26,7 @@
26
26
  // Custody is unchanged: this returns artifacts to sign. It cannot sign or broadcast.
27
27
 
28
28
  import { bestSwapRoute } from "./index.mjs";
29
+ import { stampPrepared } from "../prepare-envelope.mjs";
29
30
 
30
31
  export const ARTIFACT = Object.freeze({
31
32
  /** Unsigned EVM transaction: wallet signs and broadcasts it. */
@@ -298,7 +299,7 @@ export async function prepareBestRoute(p, opts = {}) {
298
299
  .filter((r) => r.source !== chosenSource)
299
300
  .map((r) => ({ source: r.source, netOut: r.netOut, gasUsd: r.gasUsd }));
300
301
 
301
- return {
302
+ return stampPrepared({
302
303
  ok: true,
303
304
  chosen: {
304
305
  source: chosenSource,
@@ -337,5 +338,5 @@ export async function prepareBestRoute(p, opts = {}) {
337
338
  "UNSIGNED. Verify the destination address and minOut against a fresh quote " +
338
339
  "immediately before signing -- a quote-time minimum is not a minimum at " +
339
340
  "broadcast time.",
340
- };
341
+ }, { provider: "router", kind: "best-route" });
341
342
  }