@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/README.md +19 -0
- package/dist/{chunk-SAI3RXOP.js → chunk-ABT2WYBK.js} +2 -2
- package/dist/{chunk-VPQZVV5O.js → chunk-KYVRMBZG.js} +2 -2
- package/dist/{chunk-PLQSYP6W.js → chunk-S2RUUV3X.js} +8 -1
- package/dist/chunk-S2RUUV3X.js.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -3
- package/dist/protocol.cjs +6 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.js +2 -2
- package/dist/provider.cjs +7 -0
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.d.cts +8 -1
- package/dist/provider.d.ts +8 -1
- package/dist/provider.js +3 -1
- package/dist/remote.cjs.map +1 -1
- package/dist/remote.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-PLQSYP6W.js.map +0 -1
- /package/dist/{chunk-SAI3RXOP.js.map → chunk-ABT2WYBK.js.map} +0 -0
- /package/dist/{chunk-VPQZVV5O.js.map → chunk-KYVRMBZG.js.map} +0 -0
package/dist/protocol.js
CHANGED
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,
|