@anywalletkit/protocol-swap2-0x 0.2.0 → 0.3.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/protocol.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ZeroExSwap2Protocol
3
- } from "./chunk-VPQZVV5O.js";
4
- import "./chunk-PLQSYP6W.js";
3
+ } from "./chunk-KYVRMBZG.js";
4
+ import "./chunk-S2RUUV3X.js";
5
5
  import "./chunk-V4HUFBY2.js";
6
6
  import "./chunk-YHRPT6BS.js";
7
7
  import "./chunk-AMZ5DXN2.js";
package/dist/provider.cjs CHANGED
@@ -23,6 +23,7 @@ __export(provider_exports, {
23
23
  ZEROEX_DEFAULT_BASE_URL: () => ZEROEX_DEFAULT_BASE_URL,
24
24
  ZEROEX_PROVIDER: () => ZEROEX_PROVIDER,
25
25
  zeroExFees: () => zeroExFees,
26
+ zeroExGasEstimate: () => zeroExGasEstimate,
26
27
  zeroExPreflightDeposit: () => zeroExPreflightDeposit,
27
28
  zeroExProvider: () => zeroExProvider
28
29
  });
@@ -527,6 +528,10 @@ function zeroExFees(response, gas) {
527
528
  if (network !== null) out.push({ type: "network", amount: network.toString(), token: "native", included: false, description: "Estimated network fee (gas \xD7 gas price, as 0x reports it)" });
528
529
  return { fees: out, networkFeeKnown: network !== null };
529
530
  }
531
+ function zeroExGasEstimate(gas) {
532
+ const units = uint(gas);
533
+ return units !== null && units > 0n && units < 10000000000n ? units.toString() : void 0;
534
+ }
530
535
  function taxBps(v) {
531
536
  if (v === null || v === void 0) return null;
532
537
  if (typeof v === "number" && Number.isFinite(v) && v >= 0) return v;
@@ -699,6 +704,7 @@ function zeroExProvider(config) {
699
704
  const tx = plain(transaction) ? transaction : void 0;
700
705
  const parsedFees = zeroExFees(r, tx ? { gas: own(tx, "gas"), gasPrice: own(tx, "gasPrice") } : { gas: own(r, "gas"), gasPrice: own(r, "gasPrice") });
701
706
  if (typeof parsedFees === "string") return refuse2(parsedFees, parsedFees === UNASKED_INTEGRATOR_FEE ? "policy_refused" : "upstream_unavailable");
707
+ const gasEstimate = zeroExGasEstimate(tx ? own(tx, "gas") : own(r, "gas"));
702
708
  const flags = [];
703
709
  const issues = own(r, "issues");
704
710
  if (plain(issues)) {
@@ -814,6 +820,7 @@ function zeroExProvider(config) {
814
820
  minDestAmount: minBuyAmount.toString(),
815
821
  feeUsd: 0,
816
822
  fees: parsedFees.fees,
823
+ ...gasEstimate !== void 0 ? { gasEstimate, gasEstimateSource: "venue" } : {},
817
824
  etaSeconds: 15,
818
825
  reliability: 0.96,
819
826
  validUntilMs,