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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dexlab-project/mome-sdk

v0.2.1

Published

Mome SDK is designed for developers who want to automate Mome token transactions. With this SDK, you can easily write transaction programs to view and trade tokens generated by Mome.

Downloads

125

Readme

Mome SDK

Mome SDK is designed for developers who want to automate Mome token transactions. With this SDK, you can easily write transaction programs to view and trade tokens generated by Mome.

Installation

yarn add @dexlab-project/mome-sdk
# or
npm install @dexlab-project/mome-sdk

Usage

Initialization

  • If you want to automatically generate an anchor-provider:
    • WALLET_PATH is the path to your Solana CLI wallet (e.g., ~/.config/solana/id.json).
const sdk = MomeSDK.init(YOUR_RPC_URL, WALLET_PATH)
  • If you want to manually set an anchor-provider:
const connection = new Connection(YOUR_RPC_URL)
const wallet = NodeWallet.local()

const provider = new AnchorProvider(connection, wallet, {
  commitment: 'confirmed',
})

const sdk = new MomeSDK(provider)

Buy Transaction

const token = sdk.getToken('your-token-address')
const result = await token.beginTrade(wallet)
        .buy({
          amount: 1_000_000n, // may be 0.001 SOL
          slippageBps: 1_500,
        })
        .setComputeUnit({
          computeUnitLimit: 200_000,
          computeUnitPrice: 1_000,
        })
        .transaction({
          blockhashCommitment: 'confirmed',
        })
        .send( // you can use `sendAndConfirm` and `simulate`
                {
                  skipPreflight: false,
                  preflightCommitment: 'confirmed',
                  commitment: 'confirmed',
                })

Sell Transaction

const token = sdk.getToken('your-token-address')
const result = await token.beginTrade(wallet)
        .sell({
          amount: 10000000000n,
          slippageBps: 1_500,
        })
        .setComputeUnitPrice(200_000n)
        .transaction({
          blockhashCommitment: 'confirmed',
        })
        .send( // you can use `sendAndConfirm` and `simulate`
                {
                  skipPreflight: false,
                  preflightCommitment: 'confirmed',
                  commitment: 'confirmed',
                })

Parameter Descriptions

| Step | Parameter | Type | Description | |----------------------|------------------------|----------|-----------------------------------------------------------------------------------------------------------| | buy/sell | amount | bigint | Transaction amount | | buy/sell | slippage | number | Tolerance | | setBundle | lamports | number | Optional. Amount to use for Jitto bundling. If setBundle is declared without specifying lamports, it defaults to 1,000,000. | | setComputeUnit | computeUnitLimit | number | Optional. Directly sets the Compute Unit. | | setComputeUnit | computeUnitPrice | number | Optional. Directly sets the Compute Unit price. | | transaction | blockhashCommitment | string | Optional. Directly sets the blockhashCommitment. (default: 'confirmed') | | send/SendAndConfirm | ConfirmOption | string | See the Solana Web3.js documentation for more information. | | simulate | commitment | string | Optional. Directly sets the commitment. (default: 'confirmed') |

Using Transaction and Instruction Objects

If you want to create Instruction and Transaction objects and send them separately, you can do so as follows:

const buyTrade = token
        .beginTrade()
        .buy({
          amount: 100_100_100_000_000n,
          slippageBps: 1_500,
        })

const ix = await buyTrade.getTradeInstruction()
const tx = await buyTrade.getTransaction({ blockhashCommitment: 'confirmed' })

Event Handling

The Mome SDK provides functionality for handling events.

const sdk = MomeSDK.init(RPC_URL, defaultConfigPath)
const option = {
  commitment: 'confirmed',
}
const listener = sdk.createNewListener(option) // option is optional. Default is { commitment: 'confirmed' }
listener.onEvent('CurveTradeEvent', (event) => {
  console.log('event received')
})

process.on('SIGINT', () => {
  listener.close()
})
  • The first argument of listener.onEvent() is the name of the event to subscribe to.
  • The second argument is the callback function to execute when the event occurs.
  • Event names:
    • CurveCreateEvent: A token is created.
    • MigrateInitializeEvent: Token migration is initialized.
    • MigrateCreateEvent: A migration pool is created.
    • CurveTradeEvent: A buy or sell transaction occurs.
    • CurveStatusEvent: The status of a token is changed.

Using the Mome API

You can use the MOME API to view token information.

Usage

const momeApi = new MomeApi()
const list = await momeApi.listToken(1, 10, 'createdAt', 'desc')
const token = await momeApi.getToken('your-token-address')
  • listToken
    • parameters
      • page: Page number (starting from 1)
      • size: Page size (1 to 100)
      • sort: Sorting criteria createdAt | lastCommentedAt | marketCap
      • order: Sorting direction asc | desc
    • response
      • TokenResponse
  • getToken
    • parameters
      • address: Token address
    • response
      • TokenResponse