npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mosaicag/swap-widget

v1.1.11

Published

The Swap Widget bundles the whole swapping experience into a single React component that developers can easily embed in their app with a few lines of code.

Downloads

131

Readme

Mosaic Swap Widget

The Swap Widget bundles the whole swapping experience into a single React component that developers can easily embed in their app with a few lines of code.

Documentation:

See https://docs.mosaic.ag/swap-integration/swap-widget

Installation

Install the widgets library via npm ,pnpm or yarn.

yarn add @mosaicag/swap-widget
npm i --save @mosaicag/swap-widget

Usage

// import it in the root component in react, (ex: main.tsx/App.tsx)
import '@mosaicag/swap-widget/style.css' 

import SwapWidget from '@mosaicag/swap-widget'
<SwapWidget wallet={wallet} />

💡 Demo & Example code

Widget configs

import { Asset } from '@/constants/asset'
import { AnyRawTransaction, UserTransactionResponse } from '@aptos-labs/ts-sdk'
import {
  AptosSignAndSubmitTransactionInput,
  AptosSignAndSubmitTransactionOutput,
  AptosSignTransactionOutput,
  UserResponse,
} from '@aptos-labs/wallet-standard'
import { CSSProperties, ReactNode } from 'react'

export type WidgetProps = {
  /**
   * which chain to use, default mainnet 126
   */
  chainId: ChainId
  /**
   * wallet provider object, should have some mandatory field
   */
  wallet: WalletStandard
  /**
   * contact us to get a new one, https://docs.mosaic.ag/swap-integration/integration-partners#note-api-key-requirement
   */
  apiKey: string
  title?: {
    /**
     * default: Swap
     */
    title?: ReactNode
    /**
     * default: You are paying
     */
    input?: ReactNode
    /**
     * default: To Receive
     */
    output?: ReactNode
  }

  /**
   * use our default toast notification or not, set it to false if you want to use your own toast
   * default: true
   */
  notification?: boolean
  /**
   * default: 1
   */
  defaultInputAmount?: string
  /**
   * default slippage in bips, ex: if set to 50, it will be 0.5%
   */
  defaultSlippage?: number
  /**
   * list slippage options in settings UI, value should be in bips, default: [5, 10, 50, 100]
   */
  slippageOptions?: [number, number, number, number]
  /**
   * custom style
   */
  style?: WidgetStyle
  /**
   * custom theme colors
   */
  theme?: Theme
  /**
   * fa address (recommended) or coinType, ex: `0xe161897670a0ee5a0e3c79c3b894a0c46e4ba54c6d2ca32e285ab4b01eb74b66` or `0x275f508689de8756169d1ee02d889c777de1cebda3a7bbcce63ba8a27c563c6f::tokens::USDT`
   */
  defaultTokenInAddress?: string
  /**
   * same as defaultTokenInAddress
   */
  defaultTokenOutAddress?: string
  /**
   * custom threshold to show high or very high price impact, default: { high: 5, veryHigh: 10 }
   */
  priceImpactWarnings?: PriceImpactWarnings
  /**
   * show price impact warnings or not, default: true
   */
  showPriceImpactWarningsMsg?: boolean
  fee?: {
    /**
     * charge fee by src coin or not, default false
     */
    isFeeIn?: boolean
    /**
     * Fee in basis points
     */
    feeInBps: number
    /**
     * Fee receiver address
     */
    feeReceiver: string
  }
  /**
   * show powered by mosaic or not, default: true
   */
  poweredBy?: boolean
  /**
   *
   * callback when tx is submitted successfully
   */
  onTxSubmit?: (data: { hash: string; metadata: SwapMetadata }) => void
  /**
   *
   * callback when tx is submitted failed
   */
  onTxFail?: (data: { error: MosaicException; metadata: SwapMetadata }) => void
  /**
   *
   * callback when tx is confirmed successfully
   */
  onTxSuccess?: (data: { hash: string; receipt: UserTransactionResponse; metadata: SwapMetadata }) => void
  /**
   *
   * callback when click button connect wallet, show connect wallet modal in this function
   */
  onConnectButtonClick?: () => void
} & (LocalStateProps | GlobalStateProps)

export interface WalletStandard {
  account:
    | {
        address: string
        publicKey: Uint8Array
      }
    | undefined
  signAndSubmitTransaction(
    input: AptosSignAndSubmitTransactionInput,
  ): Promise<UserResponse<AptosSignAndSubmitTransactionOutput>>
  signTransaction(
    transaction: AnyRawTransaction,
    asFeePayer?: boolean,
  ): Promise<UserResponse<AptosSignTransactionOutput>>
}

export type Theme = {
  background?: string
  primary?: string
  secondary?: string
  error?: string
  secondaryBackground?: string
  baseContent?: string
  neutralContent?: string
  border?: string
}

type SelectFunc = (token: Asset) => void

type SelectState = {
  tokenIn: Asset | undefined
  tokenOut: Asset | undefined
  onChangeTokenIn: SelectFunc
  onChangeTokenOut: SelectFunc
  /**
   *
   * event when click switch token / arrow icon
   */
  onSwitchToken: (newTokenIn: Asset, newTokenOut: Asset) => void
}

type LocalStateProps = {
  /**
   *  use our local state or use your state
   *  if you set to false, you need to specify all: tokenIn, tokenOut, onChangeTokenIn, onChangeTokenOut, onSwitchToken
   *  if you set to true, sdk will use our local widget state
   *  default true
   */
  useLocalState?: true
} & Partial<SelectState>

type GlobalStateProps = {
  useLocalState: false
} & SelectState

export type WidgetStyle = {
  /**
   * outer div
   */
  wrapper?: CSSProperties
  /**
   * inner div
   */
  container?: CSSProperties
  inputGroup?: CSSProperties
  outputGroup?: CSSProperties
  /**
   * panel in the bottom
   */
  swapDetail?: CSSProperties
  settings?: CSSProperties
  arrowIcon?: CSSProperties
  selectTokenModal?: CSSProperties
  /**
   * swap button
   */
  ctaButton?: CSSProperties
}

export type PriceImpactWarnings = {
  high: number
  veryHigh: number
}

export type SwapMetadata = { amountIn: string; amountOut: string; tokenIn: Asset; tokenOut: Asset }