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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mimboku-swap-sdk

v1.0.2

Published

Mimboku DEX Aggregator Swap SDK

Downloads

8

Readme

@mimboku/swap-sdk

A comprehensive React SDK for integrating Mimboku DEX Aggregator swap functionality into your DeFi applications.

Features

  • 🔄 Complete Swap Widget - Ready-to-use swap interface with full UI/UX
  • 🎯 Token Selection - Modal for browsing and selecting tokens
  • ⚙️ Advanced Settings - Slippage tolerance, time limits, and protocol selection
  • 📊 Route Display - Visual representation of swap routes and price impact
  • 📈 Transaction History - View past swap transactions
  • 🎨 Customizable Themes - Light and dark theme support
  • 📱 Responsive Design - Works on desktop and mobile
  • 🔗 Wallet Integration - Seamless connection with popular wallets
  • 🛡️ Type Safety - Full TypeScript support

Installation

npm install @mimboku/swap-sdk
# or
yarn add @mimboku/swap-sdk

Quick Start

1. Basic Setup

import React from 'react';
import { SwapProvider, SwapWidget } from '@mimboku/swap-sdk';
import { WagmiProvider } from 'wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { config as wagmiConfig } from './wagmi-config';

// Import CSS (required)
import '@mimboku/swap-sdk/dist/styles/index.css';

const queryClient = new QueryClient();

const swapConfig = {
  quoteApiUrl: 'https://api.mimboku.com/quote',
  contractAddresses: {
    router: '0x1234567890123456789012345678901234567890',
    permit2: '0x000000000022D473030F116dDEE9F6B43aC78BA3',
  },
  defaultChainId: 1514,
  supportedChains: [1514, 1, 56, 137],
};

function App() {
  return (
    <WagmiProvider config={wagmiConfig}>
      <QueryClientProvider client={queryClient}>
        <SwapProvider config={swapConfig}>
          <div className="max-w-md mx-auto p-4">
            <SwapWidget theme="dark" />
          </div>
        </SwapProvider>
      </QueryClientProvider>
    </WagmiProvider>
  );
}

export default App;

2. Custom Integration

You can also use individual components for a custom integration:

import React from 'react';
import {
  SwapProvider,
  SellingSection,
  BuyingSection,
  SwapButton,
  TokenSelectionModal,
  SlippageSettingsModal,
  useSwapState,
  useSwapSettings
} from '@mimboku/swap-sdk';

function CustomSwapInterface() {
  const {
    tokenIn,
    tokenOut,
    amountIn,
    amountOut,
    setTokenIn,
    setTokenOut,
    setAmountIn,
    swapTokens,
    balanceIn,
    isSwapEnabled,
    isFetchingQuote,
  } = useSwapState();

  const {
    slippage,
    timeLimit,
    protocols,
    setSlippage,
    setTimeLimit,
    setProtocols,
  } = useSwapSettings();

  return (
    <div className="swap-interface">
      <SellingSection
        tokenIn={tokenIn}
        amountIn={amountIn}
        setAmountIn={setAmountIn}
        balanceIn={balanceIn}
        openModal={() => {/* handle modal */}}
        isFetchingQuote={isFetchingQuote}
      />
      
      <button onClick={swapTokens}>
        Swap Tokens
      </button>
      
      <BuyingSection
        tokenOut={tokenOut}
        amountOut={amountOut}
        openModal={() => {/* handle modal */}}
        isFetchingQuote={isFetchingQuote}
      />
      
      <SwapButton
        tokenIn={tokenIn}
        tokenOut={tokenOut}
        amountIn={amountIn}
        isSwapEnabled={isSwapEnabled}
        isFetchingQuote={isFetchingQuote}
      />
    </div>
  );
}

Configuration

SwapConfig

interface SwapConfig {
  quoteApiUrl: string;           // API endpoint for fetching quotes
  contractAddresses: {
    router: string;              // DEX router contract address
    permit2?: string;            // Permit2 contract address (optional)
  };
  defaultChainId: number;        // Default blockchain network
  supportedChains: number[];     // List of supported chain IDs
}

SwapWidget Props

interface SwapWidgetProps {
  className?: string;            // Additional CSS classes
  theme?: 'light' | 'dark';     // Theme selection
  showHistory?: boolean;         // Show transaction history by default
  showChart?: boolean;           // Show chart by default
}

Components

Core Components

  • SwapWidget - Complete swap interface
  • SwapProvider - Context provider with configuration
  • SellingSection - Token input section
  • BuyingSection - Token output section
  • SwapButton - Swap execution button
  • TokenSelectionModal - Token selection interface
  • SlippageSettingsModal - Advanced settings modal
  • RouteDisplay - Route visualization
  • ViewHistory - Transaction history
  • LogoToken - Token logo component

Utility Hooks

  • useSwapState - Main swap state management
  • useSwapSettings - Settings state management
  • useFetchQuote - Quote fetching logic
  • useTokenApproval - Token approval handling
  • useSwap - Swap execution logic

Types

import { IToken, QuoteResponse, SwapConfig } from '@mimboku/swap-sdk';

// Token interface
interface IToken {
  id: string;
  address: string;
  name: string;
  symbol: string;
  decimals: number;
  logoURI: string;
  chainId?: number;
}

// Quote response
interface QuoteResponse {
  amount: string;
  quote: string;
  gasUseEstimate: string;
  gasUseEstimateUSD: string;
  route: Array<Array<RouteStep>>;
  priceImpact: string;
  // ... additional fields
}

Theming

The SDK supports both light and dark themes:

<SwapWidget theme="light" />   // Light theme
<SwapWidget theme="dark" />    // Dark theme (default)

You can also customize the theme by overriding CSS variables:

.mimboku-swap-widget.custom {
  --background: #1a1a1a;
  --foreground: #ffffff;
  --accent: #00ff88;
  --secondary: #2a2a2a;
  --muted: #888888;
}

Examples

Check out the /examples directory for complete implementation examples:

Requirements

  • React 16.8+
  • wagmi 2.0+
  • viem 2.0+
  • @tanstack/react-query 5.0+

Peer Dependencies

The following packages are required as peer dependencies:

{
  "react": ">=16.8.0",
  "react-dom": ">=16.8.0",
  "wagmi": "^2.0.0",
  "viem": "^2.0.0",
  "ethers": "^6.0.0",
  "@tanstack/react-query": "^5.0.0"
}

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please open an issue on GitHub or contact the Mimboku team.


Built with ❤️ by the Mimboku Team