UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

2 lines 1.65 kB
import{PublicKey as v}from"@solana/web3.js";import{get as g,set as h}from"lodash";var n=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(o=>typeof o=="object"?JSON.stringify(o):o).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},l={},p={};function m(r){let e=g(l,r);if(!e){let t=g(p,r);e=new n({name:r,logLevel:t}),h(l,r,e)}return e}import L from"bn.js";var y=new L(25),I=new L(1e4),a={4:3,5:3};var f=m("Raydium_liquidity_serum");function N(r){let e=a[r];return e||f.logWithError("invalid version","version",r),e}function O({programId:r,marketId:e}){let t=[e.toBuffer()],o=0,s;for(;o<100;){try{let i=t.concat(Buffer.from([o]),Buffer.alloc(7));s=v.createProgramAddressSync(i,r)}catch(i){if(i instanceof TypeError)throw i;o++;continue}return{publicKey:s,nonce:o}}throw f.logWithError("unable to find a viable program address nonce","params",{programId:r,marketId:e}),new Error("unable to find a viable program address nonce")}export{O as getSerumAssociatedAuthority,N as getSerumVersion}; //# sourceMappingURL=serum.mjs.map