test-raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
2 lines • 4.75 kB
JavaScript
import{PublicKey as s}from"@solana/web3.js";var q=new s("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),W=new s("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),F=new s("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),z=new s("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),j=new s("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),x=new s("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),H=new s("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Q=new s("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Y=new s("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),J=new s("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),X=new s("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Z=new s("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),$=new s("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),ee=new s("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi");var L={[x.toBase58()]:3},h={3:x};import{PublicKey as V}from"@solana/web3.js";import S,{isBN as at}from"bn.js";import{bits as se,BitStructure as ue,blob as E,Blob as ae,cstr as ie,f32 as ce,f32be as pe,f64 as ye,f64be as Pe,greedy as de,Layout as I,ns64 as xe,ns64be as fe,nu64 as le,nu64be as ge,offset as me,s16 as be,s16be as Le,s24 as he,s24be as _e,s32 as Se,s32be as Te,s40 as we,s40be as Be,s48 as Me,s48be as Re,s8 as Ae,seq as Ue,struct as ve,Structure as k,u16 as Ee,u16be as Ie,u24 as ke,u24be as Ve,u32 as De,u32be as Oe,u40 as Ke,u40be as Ge,u48 as Ce,u48be as Ne,u8 as qe,UInt as We,union as Fe,Union as ze,unionLayoutDiscriminator as je,utf8 as He}from"@solana/buffer-layout";var f=I,_=k;var p=E;var l=class extends f{constructor(t,r,n){super(t,n);this.blob=p(t),this.signed=r}decode(t,r=0){let n=new S(this.blob.decode(t,r),10,"le");return this.signed?n.fromTwos(this.span*8).clone():n}encode(t,r,n=0){return typeof t=="number"&&(t=new S(t)),this.signed&&(t=t.toTwos(this.span*8)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),r,n)}};function u(o){return new l(8,!1,o)}var g=class extends f{constructor(t,r,n,y){super(t.span,y);this.layout=t,this.decoder=r,this.encoder=n}decode(t,r){return this.decoder(this.layout.decode(t,r))}encode(t,r,n){return this.layout.encode(this.encoder(t),r,n)}getSpan(t,r){return this.layout.getSpan(t,r)}};function a(o){return new g(p(32),e=>new V(e),e=>e.toBuffer(),o)}var m=class extends _{decode(e,t){return super.decode(e,t)}};function T(o,e,t){return new m(o,e,t)}var D=T([p(5),p(8),a("ownAddress"),u("vaultSignerNonce"),a("baseMint"),a("quoteMint"),a("baseVault"),u("baseDepositsTotal"),u("baseFeesAccrued"),a("quoteVault"),u("quoteDepositsTotal"),u("quoteFeesAccrued"),u("quoteDustThreshold"),a("requestQueue"),a("eventQueue"),a("bids"),a("asks"),u("baseLotSize"),u("quoteLotSize"),u("feeRateBps"),u("referrerRebatesAccrued"),p(7)]),w={3:D};import{PublicKey as U}from"@solana/web3.js";import{get as B,set as O}from"lodash";import R from"dayjs";import K from"dayjs/plugin/utc";R.extend(K);var b=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 R().utc().format("YYYY/MM/DD HH:mm:ss UTC")}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(r=>typeof r=="object"?JSON.stringify(r):r).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}},M={},G={};function A(o){let e=B(M,o);if(!e){let t=B(G,o);e=new b({name:o,logLevel:t}),O(M,o,e)}return e}var d=A("Serum"),v=class{static getProgramId(e){let t=h[e];return t||d.logWithError("invalid version","version",e),t}static getVersion(e){let t=e.toBase58(),r=L[t];return r||d.logWithError("invalid program id","programId",t),r}static getStateLayout(e){let t=w[e];return t||d.logWithError(!!t,"invalid version","version",e),t}static getLayouts(e){return{state:this.getStateLayout(e)}}static getAssociatedAuthority({programId:e,marketId:t}){let r=[t.toBuffer()],n=0,y;for(;n<100;){try{let P=r.concat(Buffer.from([n]),Buffer.alloc(7));y=U.createProgramAddressSync(P,e)}catch(P){if(P instanceof TypeError)throw P;n++;continue}return{publicKey:y,nonce:n}}return d.logWithError("unable to find a viable program address nonce","params",{programId:e,marketId:t}),{publicKey:U.default,nonce:n}}};export{D as MARKET_STATE_LAYOUT_V3,w as MARKET_VERSION_TO_STATE_LAYOUT,v as Market,L as SERUM_PROGRAMID_TO_VERSION,h as SERUM_VERSION_TO_PROGRAMID};
//# sourceMappingURL=index.mjs.map