UNPKG

test-raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

2 lines 4.63 kB
import{PublicKey as U}from"@solana/web3.js";import{get as L,set as E}from"lodash";import _ from"dayjs";import I from"dayjs/plugin/utc";_.extend(I);var x=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 _().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}},h={},k={};function S(o){let e=L(h,o);if(!e){let t=L(k,o);e=new x({name:o,logLevel:t}),E(h,o,e)}return e}import{PublicKey as s}from"@solana/web3.js";var j=new s("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),H=new s("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Q=new s("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Y=new s("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),J=new s("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),f=new s("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),X=new s("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Z=new s("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),$=new s("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),ee=new s("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),te=new s("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),re=new s("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),ne=new s("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),oe=new s("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi");var T={[f.toBase58()]:3},w={3:f};import{PublicKey as K}from"@solana/web3.js";import M,{isBN as pt}from"bn.js";import{bits as ce,BitStructure as ye,blob as D,Blob as pe,cstr as Pe,f32 as de,f32be as xe,f64 as fe,f64be as le,greedy as ge,Layout as V,ns64 as be,ns64be as me,nu64 as Le,nu64be as he,offset as _e,s16 as Se,s16be as Te,s24 as we,s24be as Be,s32 as Me,s32be as Re,s40 as Ae,s40be as Ue,s48 as ve,s48be as Ee,s8 as Ie,seq as ke,struct as De,Structure as O,u16 as Ve,u16be as Oe,u24 as Ke,u24be as Ge,u32 as Ce,u32be as Ne,u40 as qe,u40be as We,u48 as Fe,u48be as ze,u8 as je,UInt as He,union as Qe,Union as Ye,unionLayoutDiscriminator as Je,utf8 as Xe}from"@solana/buffer-layout";var l=V,B=O;var i=D;var g=class extends l{constructor(t,r,n){super(t,n);this.blob=i(t),this.signed=r}decode(t,r=0){let n=new M(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 M(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 g(8,!1,o)}var b=class extends l{constructor(t,r,n,p){super(t.span,p);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 b(i(32),e=>new K(e),e=>e.toBuffer(),o)}var m=class extends B{decode(e,t){return super.decode(e,t)}};function R(o,e,t){return new m(o,e,t)}var G=R([i(5),i(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"),i(7)]),A={3:G};var d=S("Serum"),v=class{static getProgramId(e){let t=w[e];return t||d.logWithError("invalid version","version",e),t}static getVersion(e){let t=e.toBase58(),r=T[t];return r||d.logWithError("invalid program id","programId",t),r}static getStateLayout(e){let t=A[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,p;for(;n<100;){try{let P=r.concat(Buffer.from([n]),Buffer.alloc(7));p=U.createProgramAddressSync(P,e)}catch(P){if(P instanceof TypeError)throw P;n++;continue}return{publicKey:p,nonce:n}}return d.logWithError("unable to find a viable program address nonce","params",{programId:e,marketId:t}),{publicKey:U.default,nonce:n}}};export{v as Market}; //# sourceMappingURL=serum.mjs.map