@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 d=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var I=(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 b(e))!y.call(r,i)&&i!==o&&g(r,i,{get:()=>e[i],enumerable:!(t=d(e,i))||t.enumerable});return r};var S=(r,e,o)=>(o=r!=null?v(E(r)):{},c(e||!r||!r.__esModule?g(o,"default",{value:r,enumerable:!0}):o,r)),_=r=>c(g({},"__esModule",{value:!0}),r);var O={};I(O,{getSerumAssociatedAuthority:()=>N,getSerumVersion:()=>x});module.exports=_(O);var h=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={},w={};function a(r){let e=(0,n.get)(m,r);if(!e){let o=(0,n.get)(w,r);e=new l({name:r,logLevel:o}),(0,n.set)(m,r,e)}return e}var u=S(require("bn.js")),T=new u.default(25),D=new u.default(1e4),f={4:3,5:3};var p=a("Raydium_liquidity_serum");function x(r){let e=f[r];return e||p.logWithError("invalid version","version",r),e}function N({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=h.PublicKey.createProgramAddressSync(s,r)}catch(s){if(s instanceof TypeError)throw s;t++;continue}return{publicKey:i,nonce:t}}throw p.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