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

@memeroyale/memeroyale-sdk

v0.1.2

Published

SDK to interact with Meme Royale

Downloads

5

Readme

MemeRoyale SDK

Program

| Environment | Program ID | | ----------- | -------------------------------------------- | | Devnet | 2FbQu6gQ8DyATLzT3WrX2dbrXpzi6gFMMeXgCcwH7o17 | | Mainnet | mrxyzcbo1w1azx3MjKxNkEQEnzZyUvWHHTWaS2j882A |

Integrating Meme Royale

All keys are derived by the token's mint.

Account Seeds

Global

  • Description: Global config account
  • Seeds: ["global"]

Pool

  • Description: The bonding curve
  • Seeds: ["pool", token_mint]

Conversion

  • Description: Conversion between rekt tokens to winning tokens.
  • Seeds: ["conversion", old_token_mint]

Token Accounts

Pool

  • Mint: token_mint
  • Authority: pool

Vault

  • Mint: token_mint
  • Authority: global

Usage

import { Connection, PublicKey } from "@solana/web3.js";
import * as anchor from "@coral-xyz/anchor";
import { MemeRoyale } from "meme-royale-sdk";

// Initialize the SDK
const connection = new Connection("https://api.mainnet-beta.solana.com");
const programId = new PublicKey(MEMEROYALE_PROGRAM_ID);
const wallet = new anchor.Wallet(YOUR_KEYPAIR);

const memeRoyale = new MemeRoyale(connection, programId, wallet);

// Initialize the SDK (required before using other methods)
await memeRoyale.init();

// Initialize the user account for your payer's pubkey
await memeroyale.initUser(wallet.publicKey);

// Now you can use the SDK methods

Key Features

  • Bonding curve calculations
  • Fee calculations
  • Supply and price estimations

Public Methods

init(): Initializes the SDK by fetching the global state. Must be called before using other methods.

initUser(payer: PublicKey): Initializes a user account for the given payer public key.

getUser(payer: PublicKey): Fetches the user account data for the given payer public key.

getPool(tokenMintPubkey: PublicKey): Fetches the pool data for a given token mint public key.

getMarketCap(tokenMintPubkey: PublicKey): Calculates the market cap for a given token mint public key.

getTokenPrice(tokenMintPubkey: PublicKey): Calculates the current token price for a given token mint public key.

derivePoolPubkey(tokenMintPubkey: PublicKey): Derives the public key for a pool given a token mint public key.

deriveConversionAccountPubkey(tokenMintPubkey: PublicKey): Derives the public key for a conversion account given a token mint public key.

priceInLamportsGivenSupplyInTokens(supplyInTokens: Decimal): Calculates the price in lamports given the current circulating supply.

marketCapInLamportsGivenSupplyInTokens(supplyInTokens: Decimal): Calculates the market capitalization in lamports given the current circulating supply.

currentProportionOfGraduatingSupplyDecimal(pool: Pool): Calculates the current proportion of the graduating supply for a given pool.

getFeeAndTaxRateBps(inRaid: boolean, side: TradeType, pool: Pool): Calculates the fee and tax rates in basis points for a trade based on current conditions.

estimateLamportsOutForTokensIn(tokensIn: Decimal, pool: Pool): Estimates the amount of lamports received for selling a given amount of tokens.

estimateTokensOutForLamportsIn(_lamportGrossInflow: Decimal, pool: Pool): Estimates the amount of tokens received for a given amount of lamports.

calculateFeesAndTaxes(isGrossInflow: boolean, lamportAmount: Decimal, feeAndTaxRates: FeesAndTaxRates): Calculates fees and taxes for a given lamport amount.

grossInflowFromNet(feeAndTaxRates: FeesAndTaxRates, netInflow: Decimal, precision: Decimal): Calculates gross inflow from net inflow.

tokensOutForLamportsIn(lamportsIn: Decimal, circulatingSupply: Decimal, isGrossInflow: boolean): Calculates tokens out for a given lamports in amount.

Static methods:

MemeRoyale.deriveUserPubkey(ownerPubkey: PublicKey, programId: PublicKey): Derives the public key for a user account.

MemeRoyale.initializeUser(ownerPubkey: PublicKey, program: anchor.Program<Hungermemes>, referral?: PublicKey): Initializes a user account for the given owner public key.

MemeRoyale.deriveMetadataPubkey(tokenMintPubkey: PublicKey): Derives the public key for token metadata.

MemeRoyale.getTokenMetadata(connection: Connection, tokenMintPubkey: PublicKey): Fetches the token metadata for a given token mint public key.

MemeRoyale.getInitUserIx(program: Program<Hungermemes>, payer: PublicKey, referral?: PublicKey): Gets the instruction to initialize a user account.

MemeRoyale.deriveTokenAccountPubkey(userPubkey: PublicKey, tokenMintPubkey: PublicKey): Derives the public key for a token account.

MemeRoyale.deriveGlobalStatePubkey(programId: PublicKey): Derives the public key for the global state account.

MemeRoyale.derivePoolPubkey(tokenMintPubkey: PublicKey, programId: PublicKey): Derives the public key for a pool.

MemeRoyale.deriveTokenMintPubkey(symbol: string, creatorPubkey: PublicKey, programId: PublicKey): Derives the public key for a token mint.

MemeRoyale.deriveVaultPubkey(poolPubkey: PublicKey, tokenMintPubkey: PublicKey): Derives the public key for a vault.

MemeRoyale.createToken(program: anchor.Program<Hungermemes>, userPubkey: PublicKey, name: string, symbol: string, uri: string): Creates a new token.

Note

Methods prefixed with an underscore (e.g., _deriveGlobalStatePubkey) are considered private and should not be used directly in your application code.