UNPKG

test-raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

2 lines 8.28 kB
var F=Object.defineProperty;var w=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var B=(n,t,e)=>t in n?F(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,m=(n,t)=>{for(var e in t||(t={}))N.call(t,e)&&B(n,e,t[e]);if(w)for(var e of w(t))v.call(t,e)&&B(n,e,t[e]);return n};import{TransactionInstruction as G,SYSVAR_RENT_PUBKEY as Y}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as q}from"@solana/spl-token";import{createInitializeAccountInstruction as U}from"@solana/spl-token";import{SystemProgram as i,Transaction as R}from"@solana/web3.js";import{PublicKey as k}from"@solana/web3.js";import V,{isBN as Ie}from"bn.js";import{bits as D,BitStructure as X,blob as M,Blob as Z,cstr as $,f32 as ee,f32be as te,f64 as ne,f64be as re,greedy as oe,Layout as E,ns64 as se,ns64be as ue,nu64 as ae,nu64be as ie,offset as ce,s16 as pe,s16be as ye,s24 as de,s24be as be,s32 as Pe,s32be as le,s40 as me,s40be as xe,s48 as ge,s48be as fe,s8 as Le,seq as Se,struct as he,Structure as W,u16 as z,u16be as Te,u24 as we,u24be as Be,u32 as O,u32be as Ae,u40 as Ce,u40be as Ve,u48 as _e,u48be as Ke,u8 as qe,UInt as Q,union as Ue,Union as Re,unionLayoutDiscriminator as Fe,utf8 as Ne}from"@solana/buffer-layout";var b=E,A=W;var x=Q;var C=z;var g=O;var p=M;var f=D;var L=class extends b{constructor(e,r,o){super(e,o);this.blob=p(e),this.signed=r}decode(e,r=0){let o=new V(this.blob.decode(e,r),10,"le");return this.signed?o.fromTwos(this.span*8).clone():o}encode(e,r,o=0){return typeof e=="number"&&(e=new V(e)),this.signed&&(e=e.toTwos(this.span*8)),this.blob.encode(e.toArrayLike(Buffer,"le",this.span),r,o)}},P=class extends b{constructor(e){super(8,e);this._lower=f(g(),!1),this._upper=f(g(),!1)}addBoolean(e){this._lower.fields.length<32?this._lower.addBoolean(e):this._upper.addBoolean(e)}decode(e,r=0){let o=this._lower.decode(e,r),c=this._upper.decode(e,r+this._lower.span);return m(m({},o),c)}encode(e,r,o=0){return this._lower.encode(e,r,o)+this._upper.encode(e,r,o+this._lower.span)}};function _(n){return new x(1,n)}function K(n){return new x(4,n)}function s(n){return new L(8,!1,n)}var S=class extends b{constructor(e,r,o,c){super(e.span,c);this.layout=e,this.decoder=r,this.encoder=o}decode(e,r){return this.decoder(this.layout.decode(e,r))}encode(e,r,o){return this.layout.encode(this.encoder(e),r,o)}getSpan(e,r){return this.layout.getSpan(e,r)}};function a(n){return new S(p(32),t=>new k(t),t=>t.toBuffer(),n)}var h=class extends A{decode(t,e){return super.decode(t,e)}};function l(n,t,e){return new h(n,t,e)}function I(n="accountFlags"){let t=new P(n);return t.addBoolean("initialized"),t.addBoolean("market"),t.addBoolean("openOrders"),t.addBoolean("requestQueue"),t.addBoolean("eventQueue"),t.addBoolean("bids"),t.addBoolean("asks"),t}var T=l([p(5),I("accountFlags"),a("ownAddress"),s("vaultSignerNonce"),a("baseMint"),a("quoteMint"),a("baseVault"),s("baseDepositsTotal"),s("baseFeesAccrued"),a("quoteVault"),s("quoteDepositsTotal"),s("quoteFeesAccrued"),s("quoteDustThreshold"),a("requestQueue"),a("eventQueue"),a("bids"),a("asks"),s("baseLotSize"),s("quoteLotSize"),s("feeRateBps"),s("referrerRebatesAccrued"),p(7)]);var u={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw"};function j({programId:n,marketInfo:t}){let e=l([_("version"),K("instruction"),s("baseLotSize"),s("quoteLotSize"),C("feeRateBps"),s("vaultSignerNonce"),s("quoteDustThreshold")]),r=[{pubkey:t.id,isSigner:!1,isWritable:!0},{pubkey:t.requestQueue,isSigner:!1,isWritable:!0},{pubkey:t.eventQueue,isSigner:!1,isWritable:!0},{pubkey:t.bids,isSigner:!1,isWritable:!0},{pubkey:t.asks,isSigner:!1,isWritable:!0},{pubkey:t.baseVault,isSigner:!1,isWritable:!0},{pubkey:t.quoteVault,isSigner:!1,isWritable:!0},{pubkey:t.baseMint,isSigner:!1,isWritable:!1},{pubkey:t.quoteMint,isSigner:!1,isWritable:!1},{pubkey:t.authority?t.quoteMint:Y,isSigner:!1,isWritable:!1}].concat(t.authority?{pubkey:t.authority,isSigner:!1,isWritable:!1}:[]).concat(t.authority&&t.pruneAuthority?{pubkey:t.pruneAuthority,isSigner:!1,isWritable:!1}:[]),o=Buffer.alloc(e.span);return e.encode({version:0,instruction:0,baseLotSize:t.baseLotSize,quoteLotSize:t.quoteLotSize,feeRateBps:t.feeRateBps,vaultSignerNonce:t.vaultSignerNonce,quoteDustThreshold:t.quoteDustThreshold},o),new G({keys:r,programId:n,data:o})}async function it({connection:n,wallet:t,marketInfo:e}){let r=new R,o=await n.getMinimumBalanceForRentExemption(165);r.add(i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.baseVault.seed,newAccountPubkey:e.baseVault.publicKey,lamports:o,space:165,programId:q}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.quoteVault.seed,newAccountPubkey:e.quoteVault.publicKey,lamports:o,space:165,programId:q}),U(e.baseVault.publicKey,e.baseMint,e.vaultOwner),U(e.quoteVault.publicKey,e.quoteMint,e.vaultOwner));let c=new R;return c.add(i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.id.seed,newAccountPubkey:e.id.publicKey,lamports:await n.getMinimumBalanceForRentExemption(T.span),space:T.span,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.requestQueue.seed,newAccountPubkey:e.requestQueue.publicKey,lamports:await n.getMinimumBalanceForRentExemption(5120+12),space:5120+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.eventQueue.seed,newAccountPubkey:e.eventQueue.publicKey,lamports:await n.getMinimumBalanceForRentExemption(262144+12),space:262144+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.bids.seed,newAccountPubkey:e.bids.publicKey,lamports:await n.getMinimumBalanceForRentExemption(65536+12),space:65536+12,programId:e.programId}),i.createAccountWithSeed({fromPubkey:t,basePubkey:t,seed:e.asks.seed,newAccountPubkey:e.asks.publicKey,lamports:await n.getMinimumBalanceForRentExemption(65536+12),space:65536+12,programId:e.programId}),j({programId:e.programId,marketInfo:{id:e.id.publicKey,requestQueue:e.requestQueue.publicKey,eventQueue:e.eventQueue.publicKey,bids:e.bids.publicKey,asks:e.asks.publicKey,baseVault:e.baseVault.publicKey,quoteVault:e.quoteVault.publicKey,baseMint:e.baseMint,quoteMint:e.quoteMint,baseLotSize:e.baseLotSize,quoteLotSize:e.quoteLotSize,feeRateBps:e.feeRateBps,vaultSignerNonce:e.vaultSignerNonce,quoteDustThreshold:e.quoteDustThreshold}})),[{transaction:r,signer:[],instructionTypes:[u.CreateAccount,u.CreateAccount,u.InitAccount,u.InitAccount]},{transaction:c,signer:[],instructionTypes:[u.CreateAccount,u.CreateAccount,u.CreateAccount,u.CreateAccount,u.CreateAccount,u.InitMarket]}]}export{j as initializeMarket,it as makeCreateMarketInstruction}; //# sourceMappingURL=instrument.mjs.map