@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
2 lines • 2.33 kB
JavaScript
var v=Object.create;var g=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var y=(r,e)=>{for(var o in e)g(r,o,{get:e[o],enumerable:!0})},c=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of d(e))!S.call(r,i)&&i!==o&&g(r,i,{get:()=>e[i],enumerable:!(t=b(e,i))||t.enumerable});return r};var I=(r,e,o)=>(o=r!=null?v(E(r)):{},c(e||!r||!r.__esModule?g(o,"default",{value:r,enumerable:!0}):o,r)),w=r=>c(g({},"__esModule",{value:!0}),r);var T={};y(T,{getSerumAssociatedAuthority:()=>R,getSerumVersion:()=>_});module.exports=w(T);var p=require("@solana/web3.js");var n=require("lodash");var l=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 o=e.map(t=>typeof t=="object"?JSON.stringify(t):t).join(", ");throw new Error(o)}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}},m={},x={};function a(r){let e=(0,n.get)(m,r);if(!e){let o=(0,n.get)(x,r);e=new l({name:r,logLevel:o}),(0,n.set)(m,r,e)}return e}var u=I(require("bn.js")),A=new u.default(25),M=new u.default(1e4),f={4:3,5:3};var h=a("Raydium_liquidity_serum");function _(r){let e=f[r];return e||h.logWithError("invalid version","version",r),e}function R({programId:r,marketId:e}){let o=[e.toBuffer()],t=0,i;for(;t<100;){try{let s=o.concat(Buffer.from([t]),Buffer.alloc(7));i=p.PublicKey.createProgramAddressSync(s,r)}catch(s){if(s instanceof TypeError)throw s;t++;continue}return{publicKey:i,nonce:t}}throw h.logWithError("unable to find a viable program address nonce","params",{programId:r,marketId:e}),new Error("unable to find a viable program address nonce")}0&&(module.exports={getSerumAssociatedAuthority,getSerumVersion});
//# sourceMappingURL=serum.js.map