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

0.1.2 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @memeroyale/memeroyale-sdk

Weekly Downloads

4

Version

0.1.2

License

none

Unpacked Size

1.19 MB

Total Files

9

Last publish

Collaborators

  • 0xcen