Numbers Produce Meaning

    @mayanfinance/swap-sdk
    TypeScript icon, indicating that this package has built-in type declarations

    2.8.0 • Public • Published

    Mayan Swap SDK

    A minimal package for sending cross-chain swap transactions

    Installation:

    npm install --save @mayanfinance/swap-sdk

    Usage:

    Import the necessary functions and models:

    import { fetchQuote, swapFromEvm, swapFromSolana, Quote } from '@mayanfinance/swap-sdk'

    Then we will need to get a quote:

    Getting Quote:

    const quote = await fetchQuote({
      amountIn: 250,
      fromToken: fromToken.contract,
      toToken: toToken.contract,
      fromChain: "bsc",
      toChain: "solana",
      slippage: 3,
    });

    You can get the list of available tokens using Tokens API

    Slippage is in percentage, so 3 means "up to three percent slippage".

    After we get the quote we can send the swap transaction:

    Swap from Solana:

    swapTrx = await swapFromSolana(quote, originWalletAddress, destinationWalletAddress, deadlineInSeconds, signSolanaTransaction)

    Swap from EVM:

    swapTrx = await swapFromEvm(quote, destinationWalletAddress, deadlineInSeconds, provider, signer)

    Tracking:

    To track the progress of a swap, we can use Mayan Explorer API

    Install

    npm i @mayanfinance/swap-sdk

    DownloadsWeekly Downloads

    137

    Version

    2.8.0

    License

    MIT

    Unpacked Size

    205 kB

    Total Files

    23

    Last publish

    Collaborators

    • mohandes