Giter Site home page Giter Site logo

raydium-sdk-v2-demo's Introduction

RAYDIUM SDK V2 demo

About the project

This project is for RAYDIUM SDK V2 demonstration

Getting Started

Installation

yarn install

this will install the dependencies for running the demo script

Prerequisites

Modify config.ts.template to fit your configuration, and rename it to config.ts

  • <YOUR_WALLET_SECRET_KEY>: replace to your own one
  • <YOUR_RPC_URL>: replace to your prefer one
  • <API_HOST>: by default it's no needed to provide raydium api host, only provide it when test on devent.

Usage

  • yarn dev src/<FOLDER>/<SCRIPT_NAME> run the specific demo script, e.g. yarn dev src/cpmm/deposit.ts. Note: if you want to execute tx, remember to uncomment code in last line

Sdk Methods

Transaction methods return data

all transaction related build function (e.g. await raydium.clmm.openPositionFromBase/ await raydium.cpmm.createPool ..etc) will return all transactions and instructions

const { execute, transaction, builder, extInfo } = await raydium.clmm.openPositionFromBase({ xxx })

  • transaction or transactions: all built transactions
  • builder: all instructions in transaction. e.g. builder.allInstructions, builder.AllTxData
  • extInfo: transaction related publicKeys. (e.g: extInfo from raydium.cpmm.createPool includes poolId, programId...etc)

Fetch pool list by mints

import { PoolFetchType } from '@raydium-io/raydium-sdk-v2'

const list = await raydium.api.fetchPoolByMints({
  mint1: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R', // required
  mint2: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // optional
  type: PoolFetchType.All, // optional
  sort: 'liquidity', // optional
  order: 'desc', // optional
  page: 1, // optional
})

Fetch Mint info from Api or Rpc

await raydium.token.getTokenInfo('<Mint address>')

Fetch token account

await raydium.account.fetchWalletTokenAccounts() // if need to force fetching token account, pass param { forceUpdate: true }

FAQ

Error: block height exceeded

  • transactions were expired, set higher priority fees (computeBudgetConfig) to make it go through smoothly
  • if you are testing in devnet, remember to replace programId to devnet one.

raydium.api.fetchPoolById/raydium.api.fetchFarmInfoById return null

  • currently api doesn't support devnet pool/farm data, please test on mainnet.
  • only raydium.xxxx.getRpcPoolInfos support get devnet rpc pool info.

create amm pool error

  • 0x10001a9: you might use https://openbook-tools.dexlab.space/market/create?network=devnet to create devnet market, and they used wrong devent program id, so please use createMarket.ts in demo to create market
  • lp amount is too less: please provide more base/quote amount when create pool, if there's SOL/WSOL in your market, it's better provide more than 4 sol(4*10**9) in initial amount.

raydium-sdk-v2-demo's People

Contributors

cruzshia avatar rudy5348 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.