UNPKG

test-rrr-sdk

Version:

An SDK for building applications on top of Raydium.

2 lines 6.53 kB
import{PublicKey as E}from"@solana/web3.js";import{get as l,set as U}from"lodash";var x=class{constructor(t){this.logLevel=t.logLevel!==void 0?t.logLevel:0,this.name=t.name}set level(t){this.logLevel=t}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(t){return t<=this.logLevel}error(...t){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...t),this):this}logWithError(...t){let r=t.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(r)}warning(...t){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...t),this):this}info(...t){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...t),this):this}debug(...t){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...t),this):this}},_={},B={};function T(s){let t=l(_,s);if(!t){let r=l(B,s);t=new x({name:s,logLevel:r}),U(_,s,t)}return t}import{PublicKey as e}from"@solana/web3.js";var J=new e("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),X=new e("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),Z=new e("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Y=new e("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),$=new e("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),ee=new e("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),L=new e("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),te=new e("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),re=new e("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),ne=new e("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),oe=new e("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),se=new e("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),ue=new e("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),ae=new e("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),ie=new e("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),ce=new e("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),pe=new e("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),ye=new e("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Pe=new e("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),de=new e("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),xe=new e("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),Le=new e("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),D=new e("CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"),O=new e("7rQ1QFNosMkUCuh7Z7fPbTHvh73b68sQYdirycEzJVuw"),V=new e("G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2"),be=new e("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),v=new e("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),fe=new e("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),k=new e("7AFUeLVRjBfzqK3tTGw8hN48KLQWSk6DTE8xprWdPqix"),ge=new e("LanMkFSVSncjWqWAM8MUHenZzt9xTcT3DcAp949ZwbF"),me=new e("495mQpkX8mHAv18yGsfubCXbFQ9Jok1L1BvMrV9KvCHr"),K=new e("7soRSLviCKHCKzCbRuVpZDif76NWLVqFtbjt8LpyxWSq"),G=new e("DG6kZFFCqxdtWXw53Zc28hLs3MTr28Efkm2FrsNERNSQ");var le={SERUM_MARKET:e.default,OPENBOOK_MARKET:new e("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),UTIL1216:e.default,FarmV3:new e("85BFyr98MbCUU9MVTEgzx1nbhWACbJqLzho6zd6DZcWL"),FarmV5:new e("EcLzTrNg9V7qhcdyXDe2qjtPkiGzDM2UbdRaeaadU5r2"),FarmV6:new e("Farm2hJLcqPtPg8M4rR6DMrsRNc5TPm5Cs4bVQrMe2T7"),AmmV4:new e("HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8"),AmmStable:new e("DDg4VmQaJV9ogWce7LpcjBA9bv22wRp5uaTPa5pGjijF"),CLMM:new e("devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH"),CLMM_LOCK_PROGRAM_ID:new e("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),CLMM_LOCK_AUTH_ID:new e("8qmHNvu2Kr2C7U8mJL4Vz1vTDxMhVuXKREwU7TNoaVEo"),Router:new e("BVChZ3XFEwTMUk1o9i3HAf91H6mFxSwa5X2wFAWhYPhU"),CREATE_CPMM_POOL_PROGRAM:D,CREATE_CPMM_POOL_AUTH:O,CREATE_CPMM_POOL_FEE_ACC:V,FEE_DESTINATION_ID:new e("3XMrhbv989VxAMi3DErLV9eJht1pHppW5LbKxe9fkEFR"),LOCK_CPMM_PROGRAM:v,LCOK_CPMM_AUTH:k,LAUNCHPAD_PROGRAM:K,LAUNCHPAD_AUTH:G};var M={[L.toBase58()]:3},h={3:L};import{PublicKey as F}from"@solana/web3.js";import A,{isBN as St}from"bn.js";import{bits as we,BitStructure as Ae,blob as I,Blob as Se,cstr as Re,f32 as Ee,f32be as Ce,f64 as Ue,f64be as Be,greedy as De,Layout as N,ns64 as Oe,ns64be as Ve,nu64 as ve,nu64be as ke,offset as Ke,s16 as Ge,s16be as Ie,s24 as Ne,s24be as He,s32 as Fe,s32be as qe,s40 as We,s40be as Qe,s48 as je,s48be as ze,s8 as Je,seq as Xe,struct as Ze,Structure as H,u16 as Ye,u16be as $e,u24 as et,u24be as tt,u32 as rt,u32be as nt,u40 as ot,u40be as st,u48 as ut,u48be as at,u8 as it,UInt as ct,union as pt,Union as yt,unionLayoutDiscriminator as Pt,utf8 as dt}from"@solana/buffer-layout";var b=N,w=H;var i=I;var f=class extends b{constructor(r,n,o){super(r,o);this.blob=i(r),this.signed=n}decode(r,n=0){let o=new A(this.blob.decode(r,n),10,"le");return this.signed?o.fromTwos(this.span*8).clone():o}encode(r,n,o=0){return typeof r=="number"&&(r=new A(r)),this.signed&&(r=r.toTwos(this.span*8)),this.blob.encode(r.toArrayLike(Buffer,"le",this.span),n,o)}};function u(s){return new f(8,!1,s)}var g=class extends b{constructor(r,n,o,y){super(r.span,y);this.layout=r,this.decoder=n,this.encoder=o}decode(r,n){return this.decoder(this.layout.decode(r,n))}encode(r,n,o){return this.layout.encode(this.encoder(r),n,o)}getSpan(r,n){return this.layout.getSpan(r,n)}};function a(s){return new g(i(32),t=>new F(t),t=>t.toBuffer(),s)}var m=class extends w{decode(t,r){return super.decode(t,r)}};function S(s,t,r){return new m(s,t,r)}var q=S([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)]),R={3:q};var d=T("Serum"),C=class{static getProgramId(t){let r=h[t];return r||d.logWithError("invalid version","version",t),r}static getVersion(t){let r=t.toBase58(),n=M[r];return n||d.logWithError("invalid program id","programId",r),n}static getStateLayout(t){let r=R[t];return r||d.logWithError(!!r,"invalid version","version",t),r}static getLayouts(t){return{state:this.getStateLayout(t)}}static getAssociatedAuthority({programId:t,marketId:r}){let n=[r.toBuffer()],o=0,y;for(;o<100;){try{let P=n.concat(Buffer.from([o]),Buffer.alloc(7));y=E.createProgramAddressSync(P,t)}catch(P){if(P instanceof TypeError)throw P;o++;continue}return{publicKey:y,nonce:o}}return d.logWithError("unable to find a viable program address nonce","params",{programId:t,marketId:r}),{publicKey:E.default,nonce:o}}};export{C as Market}; //# sourceMappingURL=serum.mjs.map