@cobaltx/sdk-v2
Version:
An SDK for building applications on top of CobaltX.
2 lines • 3.5 kB
JavaScript
import{SYSVAR_CLOCK_PUBKEY as K,TransactionInstruction as x}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as m}from"@solana/spl-token";import{PublicKey as r,SystemProgram as g,SYSVAR_RENT_PUBKEY as B}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as k}from"@solana/spl-token";function p({pubkey:n,isSigner:e=!1,isWritable:t=!0}){return{pubkey:n,isWritable:t,isSigner:e}}var D=[p({pubkey:k,isWritable:!1}),p({pubkey:g.programId,isWritable:!1}),p({pubkey:B,isWritable:!1})];var E=new r("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),N=new r("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),L=new r("SysvarRent111111111111111111111111111111111"),P=new r("SysvarC1ock11111111111111111111111111111111"),O=new r("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),W=new r("Sysvar1nstructions1111111111111111111111111"),S=g.programId,q=new r("a2Gt18uJC8puJT9JRYQLU6rPi6okxQb4WqCjwtYshZB"),G=new r("bXSKiFqYrALF9gJy1KqHm8tv4QXk8nCgbLN8WRsGEbh"),V=new r("So11111111111111111111111111111111111111112"),v=r.default,Y=new r("71kRXzJMvSeArtXYNEWa8KAjpRJosdMQ7Dpgy5Jt5zfd"),X=new r("ERFzpDteGNo8LTDKW1WwVGrkRMmA2y9WZHXNHxMA6BSV");import{PublicKey as ze}from"@solana/web3.js";import Qe,{isBN as Ze}from"bn.js";import{bits as J,BitStructure as z,blob as F,Blob as Q,cstr as Z,f32 as $,f32be as ee,f64 as te,f64be as ne,greedy as re,Layout as oe,ns64 as se,ns64be as ue,nu64 as I,nu64be as ae,offset as ie,s16 as ce,s16be as ye,s24 as pe,s24be as Pe,s32 as de,s32be as be,s40 as le,s40be as fe,s48 as xe,s48be as me,s8 as ge,seq as Le,struct as Se,Structure as A,u16 as Te,u16be as he,u24 as _e,u24be as we,u32 as Be,u32be as ke,u40 as Ie,u40be as Ae,u48 as Ue,u48be as Ke,u8 as Re,UInt as U,union as Me,Union as Ce,unionLayoutDiscriminator as De,utf8 as Ee}from"@solana/buffer-layout";var T=A;var h=U;var _=I;function b(n){return new h(1,n)}var d=class extends T{decode(e,t){return super.decode(e,t)}};function l(n,e,t){return new d(n,e,t)}var f=l([b("instruction"),_("amount")]),a=l([b("instruction")]);function ct({programId:n,amount:e,instructionKeys:t}){let o=[{pubkey:S,isSigner:!1,isWritable:!1},{pubkey:m,isSigner:!1,isWritable:!1},{pubkey:L,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!1,isWritable:!1},...Object.entries(t).map(([u,i])=>({pubkey:i,isSigner:u==="userOwner",isWritable:!["authority","userOwner","userIdoCheck","userStakeInfo"].includes(u)}))],s=Buffer.alloc(f.span);return f.encode({instruction:1,amount:Number(e)},s),new x({keys:o,programId:n,data:s})}function yt({programId:n},e){let t=[{pubkey:m,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!1,isWritable:!1},...Object.entries(e).map(([s,u])=>({pubkey:u,isSigner:s==="userOwner",isWritable:!["authority","userOwner"].includes(s)}))],o=Buffer.alloc(a.span);return a.encode({instruction:2},o),new x({keys:t,programId:n,data:o})}function pt(n){let{poolConfig:e,userKeys:t,side:o}=n,s=o==="base"?t.baseTokenAccount:t.quoteTokenAccount,u=o==="base"?e.baseVault:e.quoteVault,i=Buffer.alloc(a.span);a.encode({instruction:2},i);let w=[{pubkey:m,isWritable:!1,isSigner:!1},{pubkey:K,isWritable:!1,isSigner:!1},{pubkey:e.id,isWritable:!0,isSigner:!1},{pubkey:e.authority,isWritable:!1,isSigner:!1},{pubkey:u,isWritable:!0,isSigner:!1},{pubkey:s,isWritable:!0,isSigner:!1},{pubkey:t.ledgerAccount,isWritable:!0,isSigner:!1},{pubkey:t.owner,isWritable:!1,isSigner:!0}];return new x({programId:e.programId,keys:w,data:i})}export{yt as makeClaimInstruction,pt as makeClaimInstructionV4,ct as makePurchaseInstruction};
//# sourceMappingURL=instruction.mjs.map