@blazephoenix/sdk 1.2.0 → 1.2.1

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.cts CHANGED
@@ -183,8 +183,10 @@ interface ExactQuote {
183
183
  tokenIn: Address;
184
184
  tokenOut: Address;
185
185
  amountIn: bigint;
186
- /** Execution-grade NET output (every concentrated leg dry-run on the pool). */
186
+ /** Execution-grade NET output (every concentrated leg dry-run on its venue), net of the protocol fee. */
187
187
  exactOut: bigint;
188
+ /** The scalar exactly as the Quoter returned it (gross of the fee on 1.x Quoters). */
189
+ quoterOut: bigint;
188
190
  route: Route;
189
191
  quotedAt: number;
190
192
  }
package/dist/index.d.ts CHANGED
@@ -183,8 +183,10 @@ interface ExactQuote {
183
183
  tokenIn: Address;
184
184
  tokenOut: Address;
185
185
  amountIn: bigint;
186
- /** Execution-grade NET output (every concentrated leg dry-run on the pool). */
186
+ /** Execution-grade NET output (every concentrated leg dry-run on its venue), net of the protocol fee. */
187
187
  exactOut: bigint;
188
+ /** The scalar exactly as the Quoter returned it (gross of the fee on 1.x Quoters). */
189
+ quoterOut: bigint;
188
190
  route: Route;
189
191
  quotedAt: number;
190
192
  }
package/dist/index.js CHANGED
@@ -4766,7 +4766,8 @@ var CHAINS = {
4766
4766
  explorer: "https://robinhoodchain.blockscout.com",
4767
4767
  weth: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",
4768
4768
  usdc: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
4769
- blockTime: 2
4769
+ blockTime: 0.104
4770
+ // measured ~0.104 s/block
4770
4771
  }
4771
4772
  };
4772
4773
  var ALIASES = {
@@ -4831,7 +4832,7 @@ function urlTransport(url, o) {
4831
4832
  throw new BlazeError("bad_request", `refusing RPC URL "${redact(url)}": use https:// or wss:// (http/ws only for localhost)`);
4832
4833
  }
4833
4834
  const u = url.trim();
4834
- return u.startsWith("ws") ? webSocket(u, { timeout: o.timeoutMs, retryCount: o.retries }) : http(u, { timeout: o.timeoutMs, retryCount: o.retries, batch: o.batch });
4835
+ return u.startsWith("ws") ? webSocket(u, { timeout: o.timeoutMs, retryCount: o.retries }) : http(u, { timeout: o.timeoutMs, retryCount: o.retries, batch: o.batch, fetchOptions: { redirect: "error" } });
4835
4836
  }
4836
4837
  function redact(url) {
4837
4838
  try {
@@ -4979,6 +4980,9 @@ function scrubCause(c, depth = 0) {
4979
4980
  out.name = c.name;
4980
4981
  return out;
4981
4982
  }
4983
+ function untrustedText(t, max = 120) {
4984
+ return (t ?? "").replace(/[^\x20-\x7e]+/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
4985
+ }
4982
4986
  var BlazeError = class extends Error {
4983
4987
  code;
4984
4988
  details;
@@ -5810,6 +5814,20 @@ var BlazePhoenix = class {
5810
5814
  if (typeof req.amountIn === "bigint") v = req.amountIn;
5811
5815
  else if (INT.test(String(req.amountIn).trim())) v = BigInt(String(req.amountIn).trim());
5812
5816
  else throw new BlazeError("bad_request", 'amountIn must be an integer in base units \u2014 use `amount` for human units ("1.5")');
5817
+ if (req.amount !== void 0 && req.amount !== null && req.amount !== "") {
5818
+ const d = await this.decimalsOf(client, chainId, tIn).catch((e) => {
5819
+ throw new BlazeError("bad_request", "amount and amountIn are both set and the decimals could not be read to compare them \u2014 pass only one", { cause: e });
5820
+ });
5821
+ let human;
5822
+ try {
5823
+ human = toBaseUnits(req.amount, d);
5824
+ } catch (e) {
5825
+ throw new BlazeError("bad_request", e.message);
5826
+ }
5827
+ if (human !== v) {
5828
+ throw new BlazeError("bad_request", `amount and amountIn disagree (${human} vs ${v} base units): pass only one`);
5829
+ }
5830
+ }
5813
5831
  } else if (req.amount !== void 0) {
5814
5832
  const d = await this.decimalsOf(client, chainId, tIn).catch((e) => {
5815
5833
  throw new BlazeError("bad_request", `could not read decimals of ${tIn.address} on your RPC \u2014 pass amountIn in base units`, { cause: e });
@@ -5917,13 +5935,15 @@ var BlazePhoenix = class {
5917
5935
  args: [tIn.address, tOut.address, amountIn],
5918
5936
  ...req.blockNumber !== void 0 ? { blockNumber: req.blockNumber } : {}
5919
5937
  });
5938
+ const net = featuresOf(ctx.dep.version).previewAndEncode ? exactOut : exactOut - (exactOut * BigInt(FEE_BPS) + 9999n) / 10000n;
5920
5939
  return {
5921
5940
  chainId: ctx.chainId,
5922
5941
  version: ctx.dep.version,
5923
5942
  tokenIn: tIn.address,
5924
5943
  tokenOut: tOut.address,
5925
5944
  amountIn,
5926
- exactOut,
5945
+ exactOut: net,
5946
+ quoterOut: exactOut,
5927
5947
  route,
5928
5948
  quotedAt: Date.now()
5929
5949
  };
@@ -6188,7 +6208,7 @@ var BlazePhoenix = class {
6188
6208
  } catch (e) {
6189
6209
  if (isTransportError(e)) throw new BlazeError("rpc_error", `simulation: your RPC failed (${e?.message?.split("\n")[0]})`, { cause: e });
6190
6210
  const d = decodeBlazeError(e);
6191
- return { ok: false, error: d ?? { contract: "unknown", name: "revert", reason: e?.message?.split("\n")[0] ?? "execution reverted" } };
6211
+ return { ok: false, error: d ?? { contract: "unknown", name: "revert", reason: untrustedText(e?.message?.split("\n")[0]) || "execution reverted" } };
6192
6212
  }
6193
6213
  }
6194
6214
  /**