@fluent.xyz/connect 0.8.2 → 0.8.3

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.js CHANGED
@@ -5626,7 +5626,7 @@ function createFluentConnectForWidget(config) {
5626
5626
  }
5627
5627
 
5628
5628
  // package.json
5629
- var version = "0.8.2";
5629
+ var version = "0.8.3";
5630
5630
 
5631
5631
  // src/core/analytics.ts
5632
5632
  var INSTANCE_NAME = "fluent";
@@ -9346,6 +9346,10 @@ var TOKENS_BY_NETWORK = {
9346
9346
  function getBridgeTokens(network) {
9347
9347
  return TOKENS_BY_NETWORK[network];
9348
9348
  }
9349
+ function getDefaultBridgeToken(network) {
9350
+ const usdc = getBridgeToken(network, "USDC");
9351
+ return isBridgeTokenAvailable(usdc) ? usdc : getBridgeToken(network, "ETH");
9352
+ }
9349
9353
  function getBridgeToken(network, symbol) {
9350
9354
  const token = TOKENS_BY_NETWORK[network].find((t) => t.symbol === symbol);
9351
9355
  if (!token) throw new Error(`Unknown bridge token ${symbol}`);
@@ -14040,10 +14044,11 @@ function getOrderDepositFeeShare(quote) {
14040
14044
  return Number(bps) / 1e4;
14041
14045
  }
14042
14046
  var ORDER_DEPOSIT_FEE_SHARE_WARNING = 0.05;
14043
- function formatFeeShare(share) {
14044
- const percent = share * 100;
14045
- const rounded = Math.round(percent * 10) / 10;
14046
- return `${Number.isInteger(rounded) ? rounded.toFixed(0) : rounded.toFixed(1)}%`;
14047
+ var ORDER_DEPOSIT_FEE_SHARE_HINT = 0.02;
14048
+ function getOrderDepositFeeNotice(share) {
14049
+ if (share > ORDER_DEPOSIT_FEE_SHARE_WARNING) return "warning";
14050
+ if (share > ORDER_DEPOSIT_FEE_SHARE_HINT) return "hint";
14051
+ return void 0;
14047
14052
  }
14048
14053
 
14049
14054
  // src/bridge/abi.ts
@@ -15211,11 +15216,21 @@ function formatFeeUsd(wei, usdPrice) {
15211
15216
  }
15212
15217
  var SLIPPAGE_LABEL = `${Number(FLUENT_SWAP_SLIPPAGE_BPS) / 100}%`;
15213
15218
  var SLIPPAGE_TOOLTIP = `The swap may settle up to ${SLIPPAGE_LABEL} below its quote. Below that the pool rejects it, and nothing is swapped.`;
15214
- function Notice2({ children }) {
15215
- return /* @__PURE__ */ jsxs("p", { className: "flex gap-2 rounded-xl bg-amber-400/10 p-3 text-xs text-amber-300", role: "status", children: [
15216
- /* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0" }),
15217
- /* @__PURE__ */ jsx("span", { children })
15218
- ] });
15219
+ function Notice2({
15220
+ tone = "warning",
15221
+ children
15222
+ }) {
15223
+ return /* @__PURE__ */ jsxs(
15224
+ "p",
15225
+ {
15226
+ className: `flex gap-2 rounded-xl p-3 text-xs ${tone === "warning" ? "bg-amber-400/10 text-amber-300" : "bg-foreground/[0.06] text-foreground/60"}`,
15227
+ role: "status",
15228
+ children: [
15229
+ tone === "warning" ? /* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0" }) : null,
15230
+ /* @__PURE__ */ jsx("span", { children })
15231
+ ]
15232
+ }
15233
+ );
15219
15234
  }
15220
15235
  function TokenChip({ symbol }) {
15221
15236
  return /* @__PURE__ */ jsxs("span", { className: "flex h-11 shrink-0 items-center gap-2 rounded-full bg-foreground/[0.06] pl-2 pr-3.5 text-foreground", children: [
@@ -15455,7 +15470,9 @@ function BridgeForm({
15455
15470
  onGoHome
15456
15471
  }) {
15457
15472
  const tokens = getBridgeTokens(network);
15458
- const [symbol, setSymbol] = useState("ETH");
15473
+ const [symbol, setSymbol] = useState(
15474
+ () => getDefaultBridgeToken(network).symbol
15475
+ );
15459
15476
  const token = getBridgeToken(network, symbol);
15460
15477
  const handOver = useRef(void 0);
15461
15478
  const bridge = useBridgeDeposit({
@@ -15619,6 +15636,11 @@ function BridgeForm({
15619
15636
  const fillMinutes = Math.max(1, Math.round((bridge.order?.fillSeconds ?? 60) / 60));
15620
15637
  const fillTime = fillMinutes === 1 ? "about a minute" : `about ${fillMinutes} minutes`;
15621
15638
  const minimumOut = twoStep && quote ? applyFluentSwapSlippage(quote.amountOut, FLUENT_SWAP_SLIPPAGE_BPS) : void 0;
15639
+ const feeNoticeTone = bridge.order?.solverFeeShare !== void 0 ? getOrderDepositFeeNotice(bridge.order.solverFeeShare) : void 0;
15640
+ const feeNotice = feeNoticeTone && bridge.order?.solverFee !== void 0 ? {
15641
+ tone: feeNoticeTone,
15642
+ text: `Flat ${formatAmount(bridge.order.solverFee, token.decimals, token.symbol)} ${token.symbol} fee. Bridge more to pay a smaller share.`
15643
+ } : void 0;
15622
15644
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-4 flex-1", children: [
15623
15645
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
15624
15646
  /* @__PURE__ */ jsxs(AmountCard, { label: "Send", children: [
@@ -15726,7 +15748,7 @@ function BridgeForm({
15726
15748
  {
15727
15749
  label: "Solver fee",
15728
15750
  value: `${formatAmount(bridge.order.solverFee, token.decimals, token.symbol)} ` + token.symbol,
15729
- secondary: bridge.order.solverFeeShare !== void 0 ? `${formatFeeShare(bridge.order.solverFeeShare)} of the amount` : void 0,
15751
+ secondary: "flat fee",
15730
15752
  tooltip: "The solver that fills the order keeps this out of the amount you send. What you receive is already net of it. The fee is flat, so a larger deposit pays the same."
15731
15753
  }
15732
15754
  ) : null
@@ -15771,7 +15793,7 @@ function BridgeForm({
15771
15793
  ] }) : null,
15772
15794
  bridge.order ? /* @__PURE__ */ jsx("span", { className: "text-xs text-foreground/60", children: `${token.symbol} is sent as a limit order on ${route.source.name}: a solver pays ${deliveredToken.symbol} to your Fluent account, usually in ${fillTime}. Gas is paid in ${ethSymbol}.` }) : isSwap && !bridge.routeLoading ? /* @__PURE__ */ jsx("span", { className: "text-xs text-foreground/60", children: `${token.symbol} is swapped 1:1 to ${deliveredToken.symbol} on ${route.source.name}, then bridged to Fluent. Fees are paid in ${ethSymbol}. Expect up to 4 confirmations.` }) : null
15773
15795
  ] }) }),
15774
- bridge.order?.solverFeeShare !== void 0 && bridge.order.solverFeeShare > ORDER_DEPOSIT_FEE_SHARE_WARNING ? /* @__PURE__ */ jsx(Notice2, { children: `The solver fee takes ${formatFeeShare(bridge.order.solverFeeShare)} of this deposit. A larger deposit pays the same fee.` }) : null,
15796
+ feeNotice ? /* @__PURE__ */ jsx(Notice2, { tone: feeNotice.tone, children: feeNotice.text }) : null,
15775
15797
  bridge.gasFeeShort && bridge.ethBalance !== void 0 ? /* @__PURE__ */ jsx(Notice2, { children: `Your wallet holds ${formatAmount(bridge.ethBalance, 18)} ${ethSymbol} on ${route.source.name}, less than the network fee. Add ${ethSymbol}, or let your wallet pay gas with a token.` }) : null,
15776
15798
  state.phase === "error" ? /* @__PURE__ */ jsx("span", { className: "text-xs text-destructive", children: state.message }) : null,
15777
15799
  bridge.restoring ? /* @__PURE__ */ jsxs(Button, { className: "w-full", disabled: true, children: [