@sega-so/sega-sdk
Version:
An SDK for building applications on top of SEGA.
2 lines • 21.5 kB
JavaScript
var Ee=Object.defineProperty,Oe=Object.defineProperties;var Fe=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var me=(t,e,n)=>e in t?Ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,C=(t,e)=>{for(var n in e||(e={}))Ve.call(e,n)&&me(t,n,e[n]);if(le)for(var n of le(e))ve.call(e,n)&&me(t,n,e[n]);return t},R=(t,e)=>Oe(t,Fe(e));var K=(t,e,n)=>new Promise((r,i)=>{var u=o=>{try{m(n.next(o))}catch(s){i(s)}},c=o=>{try{m(n.throw(o))}catch(s){i(s)}},m=o=>o.done?r(o.value):Promise.resolve(o.value).then(u,c);m((n=n.apply(t,e)).next())});import{PublicKey as q,TransactionInstruction as _,Keypair as Pt,SystemProgram as Tt}from"@solana/web3.js";import{ASSOCIATED_TOKEN_PROGRAM_ID as We,TOKEN_2022_PROGRAM_ID as ue,TOKEN_PROGRAM_ID as L}from"@solana/spl-token";import{PublicKey as Kt}from"@solana/web3.js";import{get as pe,set as Ue}from"lodash";var Z=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 Date.now().toString()}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 n=e.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(n)}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}},fe={},qe={};function T(t){let e=pe(fe,t);if(!e){let n=pe(qe,t);e=new Z({name:t,logLevel:n}),Ue(fe,t,e)}return e}import{MINT_SIZE as Wt,TOKEN_PROGRAM_ID as Rt,getTransferFeeConfig as Dt,unpackMint as Et}from"@solana/spl-token";var Ot=T("Sega_accountInfo_util");import B from"bn.js";import _r from"decimal.js";import Xe from"big.js";import on from"bn.js";import Ge from"toformat";var je=Ge,E=je;import j from"big.js";import ze from"bn.js";import Ye from"decimal.js-light";import O from"bn.js";var de=9007199254740991;function S(t){let e=T("Sega_parseBigNumberish");if(t instanceof O)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new O(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=de||t<=-de)&&e.logWithError(`BigNumberish number overflow: ${t}`),new O(String(t))):typeof t=="bigint"?new O(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new O(0))}var G=T("module/fraction"),$=E(j),F=E(Ye),Je={0:F.ROUND_DOWN,1:F.ROUND_HALF_UP,2:F.ROUND_UP},Ze={0:j.roundDown,1:j.roundHalfUp,2:j.roundUp},k=class t{constructor(e,n=new ze(1)){this.numerator=S(e),this.denominator=S(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new t(this.denominator,this.numerator)}add(e){let n=e instanceof t?e:new t(S(e));return this.denominator.eq(n.denominator)?new t(this.numerator.add(n.numerator),this.denominator):new t(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof t?e:new t(S(e));return this.denominator.eq(n.denominator)?new t(this.numerator.sub(n.numerator),this.denominator):new t(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof t?e:new t(S(e));return new t(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof t?e:new t(S(e));return new t(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},r=1){Number.isInteger(e)||G.logWithError(`${e} is not an integer.`),e<=0&&G.logWithError(`${e} is not positive.`),F.set({precision:e+1,rounding:Je[r]});let i=new F(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return i.toFormat(i.decimalPlaces(),n)}toFixed(e,n={groupSeparator:""},r=1){return Number.isInteger(e)||G.logWithError(`${e} is not an integer.`),e<0&&G.logWithError(`${e} is negative.`),$.DP=e,$.RM=Ze[r]||1,new $(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var dn=T("Sega_amount"),gn=E(Xe);import{PublicKey as Qe}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as ge}from"@solana/spl-token";var be={chainId:101,address:Qe.default.toBase58(),programId:ge.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"sega",extensions:{coingeckoId:"solana"}},M={chainId:101,address:"So11111111111111111111111111111111111111112",programId:ge.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"sega",extensions:{coingeckoId:"solana"}};import{PublicKey as ne}from"@solana/web3.js";import{PublicKey as a,SystemProgram as ye,SYSVAR_RENT_PUBKEY as et}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as tt}from"@solana/spl-token";function Q({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var Sn=[Q({pubkey:tt,isWritable:!1}),Q({pubkey:ye.programId,isWritable:!1}),Q({pubkey:et,isWritable:!1})];function he({publicKey:t,transformSol:e}){let n=Pe(t.toString());if(n instanceof a)return e&&n.equals(V)?X:n;if(e&&n.toString()===V.toBase58())return X;if(typeof n=="string"){if(n===a.default.toBase58())return a.default;try{return new a(n)}catch(r){throw new Error("invalid public key")}}throw new Error("invalid public key")}function Pe(t){try{return new a(t)}catch(e){return t}}var kn=new a("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),ee=new a("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),te=new a("SysvarRent111111111111111111111111111111111"),Bn=new a("SysvarC1ock11111111111111111111111111111111"),v=new a("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),An=new a("Sysvar1nstructions1111111111111111111111111"),Te=ye.programId,Ln=new a("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),In=new a("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Cn=new a("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Kn=new a("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Mn=new a("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),_n=new a("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Nn=new a("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Wn=new a("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Rn=new a("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Dn=new a("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),En=new a("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),X=new a("So11111111111111111111111111111111111111112"),V=a.default;var H=class H{constructor({mint:e,decimals:n,symbol:r,name:i,skipMint:u=!1,isToken2022:c=!1}){if(e===V.toBase58()||e instanceof ne&&V.equals(e)){this.decimals=M.decimals,this.symbol=M.symbol,this.name=M.name,this.mint=new ne(M.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=r||e.toString().substring(0,6),this.name=i||e.toString().substring(0,6),this.mint=u?ne.default:he({publicKey:e}),this.isToken2022=c}equals(e){return this===e?!0:this.mint.equals(e.mint)}};H.WSOL=new H(R(C({},M),{mint:M.address}));var U=H;var z=class z{constructor({decimals:e,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=r}equals(e){return this===e}};z.SOL=new z(be);var re=z;import nt from"bn.js";var Zn=new k(new nt(100));var nr=T("Sega_price");import{PublicKey as Pr}from"@solana/web3.js";import xr from"bn.js";var rt=new B(0),Ur=new B(1),qr=new B(2),Gr=new B(3),jr=new B(5),$e=new B(10),Hr=new B(100),zr=new B(1e3),Yr=new B(1e4);import{PublicKey as ot}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as st}from"@solana/spl-token";import{ComputeBudgetProgram as ri,Keypair as si,PublicKey as it,Transaction as ui,TransactionMessage as li,VersionedTransaction as mi}from"@solana/web3.js";var Y={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",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",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",FarmV4Withdraw:"FarmV4Withdraw",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee",TransferTip:"TransferTip"};import{TOKEN_PROGRAM_ID as gi}from"@solana/spl-token";var bi=T("Sega_txUtil");function D(t,e){let[n,r]=it.findProgramAddressSync(t,e);return{publicKey:n,nonce:r}}function J(t,e,n){return D([t.toBuffer(),(n!=null?n:st).toBuffer(),e.toBuffer()],new ot("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))}function ke(t){return D([Buffer.from("metadata","utf8"),v.toBuffer(),t.toBuffer()],v)}import{PublicKey as w}from"@solana/web3.js";var Be=new w("SegazTQwbYWknDZkJ6j2Kgvm5gw3MrHGKtWstZdoNKZ"),Ae=new w("Ajk8d9bERSaFdeoT1d8JUVfaDayrYLnAdgeB47TFMUaG"),Bi=new w("2HbjxVVKJ7Ct72Rcd8WK4VTqmwTXL5aAggkH1CHGFGmh"),at=new w("auetiVUVJkRxvNPLYEvVnz8UJSqQ1VgoA83PcicHVD1"),ut=new w("GzqQwxPSmUZnTyCfX9YWqi32MJg43ujP786ZoacL559Y"),ct=new w("GzqQwxPSmUZnTyCfX9YWqi32MJg43ujP786ZoacL559Y"),Ai=new w("SegaXNnoXYTZiqUt9Xn2XqGcL56b25yzXLuJSpadcMu"),Li=new w("2t1hV2YqnDCPuJZqr7Fy8oAygGwZE5Q9uaQzpLC1QryJ"),Ii=new w("BLxynZeHE123MmQgNJZiV1pwW4VYh46oZYyC66xwmtTY");var lt={SERUM_MARKET:w.default,UTIL1216:w.default,CREATE_CPMM_POOL_PROGRAM:at,CREATE_CPMM_POOL_AUTH:ut,CREATE_CPMM_POOL_FEE_ACC:ct};import Mi from"bn.js";import{PublicKey as Ei,AddressLookupTableAccount as Oi}from"@solana/web3.js";import{PublicKey as to,sendAndConfirmTransaction as no,SystemProgram as oo,Transaction as so,TransactionMessage as uo,VersionedTransaction as co}from"@solana/web3.js";import mo from"axios";import{Connection as wo}from"@solana/web3.js";var Ho=Buffer.from("vault_and_lp_mint_auth_seed","utf8"),zo=Buffer.from("amm_config","utf8"),mt=Buffer.from("pool","utf8"),Yo=Buffer.from("pool_lp_mint","utf8"),Jo=Buffer.from("pool_vault","utf8"),Zo=Buffer.from("observation","utf8");function Le(t,e,n,r){return D([mt,e.toBuffer(),n.toBuffer(),r.toBuffer()],t)}var pt=Buffer.from("locked_liquidity","utf8");function Ie(t,e){return D([pt,e.toBuffer()],t)}import{PublicKey as Xs}from"@solana/web3.js";import _e,{isBN as Qs}from"bn.js";import{bits as Qo,BitStructure as es,blob as ft,Blob as ts,cstr as ns,f32 as rs,f32be as is,f64 as os,f64be as ss,greedy as as,Layout as dt,ns64 as us,ns64be as cs,nu64 as ls,nu64be as ms,offset as ps,s16 as fs,s16be as ds,s24 as gs,s24be as bs,s32 as ys,s32be as hs,s40 as Ps,s40be as Ts,s48 as xs,s48be as ws,s8 as Ss,seq as ks,struct as Bs,Structure as gt,u16 as As,u16be as Ls,u24 as Is,u24be as Cs,u32 as Ks,u32be as Ms,u40 as _s,u40be as Ns,u48 as Ws,u48be as Rs,u8 as bt,UInt as Ds,union as Es,Union as Os,unionLayoutDiscriminator as Fs,utf8 as Vs}from"@solana/buffer-layout";var ie=dt,Ce=gt;var Ke=bt;var Me=ft;var oe=class extends ie{constructor(e,n,r){super(e,r),this.blob=Me(e),this.signed=n}decode(e,n=0){let r=new _e(this.blob.decode(e,n),10,"le");return this.signed?r.fromTwos(this.span*8).clone():r}encode(e,n,r=0){return typeof e=="number"&&(e=new _e(e)),this.signed&&(e=e.toTwos(this.span*8)),this.blob.encode(e.toArrayLike(Buffer,"le",this.span),n,r)}};function P(t){return new oe(8,!1,t)}var se=class extends ie{constructor(e,n,r,i){super(e.span,i),this.layout=e,this.decoder=n,this.encoder=r}decode(e,n){return this.decoder(this.layout.decode(e,n))}encode(e,n,r){return this.layout.encode(this.encoder(e),n,r)}getSpan(e,n){return this.layout.getSpan(e,n)}};function Ne(t){return new se(Ke(),yt,ht,t)}function yt(t){if(t===0)return!1;if(t===1)return!0;throw new Error("Invalid bool: "+t)}function ht(t){return t?1:0}var ae=class extends Ce{decode(e,n){return super.decode(e,n)}};function A(t,e,n){return new ae(t,e,n)}var xt=T("Sega_cpmm"),N={initialize:[175,175,109,31,13,152,155,237],deposit:[242,35,198,137,82,225,242,182],withdraw:[183,18,70,156,148,109,161,34],swapBaseInput:[143,190,90,218,196,30,51,222],swapBaseOutput:[55,217,98,86,163,74,180,173],lockCpLiquidity:[216,157,29,78,38,51,31,26],collectCpFee:[8,30,51,199,209,184,247,133]};function pa(t,e,n,r,i,u,c,m,o,s,y,h,d,g,b,p,l,f,x,I){let W=A([P("amountMaxA"),P("amountMaxB"),P("openTime")]),Re=Le(t,n,u,c).publicKey,De=[{pubkey:e,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!i.equals(Re),isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!1},{pubkey:c,isSigner:!1,isWritable:!1},{pubkey:m,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:y,isSigner:!1,isWritable:!0},{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:d,isSigner:!1,isWritable:!0},{pubkey:g,isSigner:!1,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!0},{pubkey:L,isSigner:!1,isWritable:!1},{pubkey:b,isSigner:!1,isWritable:!1},{pubkey:p,isSigner:!1,isWritable:!1},{pubkey:We,isSigner:!1,isWritable:!1},{pubkey:Te,isSigner:!1,isWritable:!1},{pubkey:te,isSigner:!1,isWritable:!1}],ce=Buffer.alloc(W.span);return W.encode({amountMaxA:f,amountMaxB:x,openTime:I},ce),new _({keys:De,programId:t,data:Buffer.from([...N.initialize,...ce])})}function fa(t,e,n,r,i,u,c,m,o,s,y,h,d,g,b){let p=A([P("lpAmount"),P("amountMaxA"),P("amountMaxB")]),l=[{pubkey:e,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:m,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:L,isSigner:!1,isWritable:!1},{pubkey:ue,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:y,isSigner:!1,isWritable:!1},{pubkey:h,isSigner:!1,isWritable:!0}],f=Buffer.alloc(p.span);return xt.debug("cpmm deposit data",{lpAmount:d.toString(),amountMaxA:g.toString(),amountMaxB:b.toString()}),p.encode({lpAmount:d,amountMaxA:g,amountMaxB:b},f),new _({keys:l,programId:t,data:Buffer.from([...N.deposit,...f])})}function da(t,e,n,r,i,u,c,m,o,s,y,h,d,g,b){let p=A([P("lpAmount"),P("amountMinA"),P("amountMinB")]),l=[{pubkey:e,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:m,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:L,isSigner:!1,isWritable:!1},{pubkey:ue,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:y,isSigner:!1,isWritable:!1},{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:ee,isSigner:!1,isWritable:!1}],f=Buffer.alloc(p.span);return p.encode({lpAmount:d,amountMinA:g,amountMinB:b},f),new _({keys:l,programId:t,data:Buffer.from([...N.withdraw,...f])})}function ga(t,e,n,r,i,u,c,m,o,s,y,h,d,g,b,p){let l=A([P("amountIn"),P("amounOutMin")]),f=[{pubkey:e,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:m,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:y,isSigner:!1,isWritable:!1},{pubkey:h,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!1,isWritable:!1},{pubkey:g,isSigner:!1,isWritable:!0}],x=Buffer.alloc(l.span);return l.encode({amountIn:b,amounOutMin:p},x),new _({keys:f,programId:t,data:Buffer.from([...N.swapBaseInput,...x])})}function ba(t,e,n,r,i,u,c,m,o,s,y,h,d,g,b,p){let l=A([P("amountInMax"),P("amountOut")]),f=[{pubkey:e,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:m,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:y,isSigner:!1,isWritable:!1},{pubkey:h,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!1,isWritable:!1},{pubkey:g,isSigner:!1,isWritable:!0}],x=Buffer.alloc(l.span);return l.encode({amountInMax:b,amountOut:p},x),new _({keys:f,programId:t,data:Buffer.from([...N.swapBaseOutput,...x])})}function ya(t){return K(this,null,function*(){var l;let{ownerInfo:e,poolInfo:n,poolKeys:r,feeNftOwner:i,getEphemeralSigners:u}=t,c=[],[m,o]=[new q(n.id),new q(n.lpMint.address)],s;if(u)s=new q((yield u(1))[0]);else{let f=Pt.generate();c.push(f),s=f.publicKey}let{publicKey:y}=J(i,s,L),{publicKey:h}=ke(s),{publicKey:d}=Ie(t.lockProgram,s),{publicKey:g}=J(e.wallet,o,L),{publicKey:b}=J(t.lockAuthProgram,o,L),p=wt({programId:t.lockProgram,auth:t.lockAuthProgram,payer:e.feePayer,liquidityOwner:e.wallet,nftOwner:i,nftMint:s,nftAccount:y,poolId:m,lockPda:d,mintLp:o,userLpVault:g,lockLpVault:b,poolVaultA:new q(r.vault.A),poolVaultB:new q(r.vault.B),metadataAccount:h,lpAmount:t.lpAmount,withMetadata:(l=t.withMetadata)!=null?l:!0});return{address:{nftMint:s,nftAccount:y,metadataAccount:h,lockPda:d,userLpVault:g,lockLpVault:b},instructions:[p],signers:c,instructionTypes:[Y.CpmmLockLp],lookupTableAddress:[]}})}function wt({programId:t,auth:e,payer:n,liquidityOwner:r,nftOwner:i,nftMint:u,nftAccount:c,poolId:m,lockPda:o,mintLp:s,userLpVault:y,lockLpVault:h,poolVaultA:d,poolVaultB:g,metadataAccount:b,lpAmount:p,withMetadata:l}){let f=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!0,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:m,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:y,isSigner:!1,isWritable:!0},{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:d,isSigner:!1,isWritable:!0},{pubkey:g,isSigner:!1,isWritable:!0},{pubkey:b,isSigner:!1,isWritable:!0},{pubkey:te,isSigner:!1,isWritable:!1},{pubkey:Tt.programId,isSigner:!1,isWritable:!1},{pubkey:L,isSigner:!1,isWritable:!1},{pubkey:We,isSigner:!1,isWritable:!1},{pubkey:v,isSigner:!1,isWritable:!1}],x=A([P("lpAmount"),Ne("withMetadata")]),I=Buffer.alloc(x.span);x.encode({lpAmount:p,withMetadata:l},I);let W=Buffer.from([...N.lockCpLiquidity,...I]);return new _({keys:f,programId:t,data:W})}function ha({programId:t,nftOwner:e,auth:n,nftAccount:r,lockPda:i,poolId:u,mintLp:c,userVaultA:m,userVaultB:o,poolVaultA:s,poolVaultB:y,mintA:h,mintB:d,lockLpVault:g,lpFeeAmount:b,cpmmProgram:p,cpmmAuthProgram:l}){let f=[{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:p!=null?p:Be,isSigner:!1,isWritable:!1},{pubkey:l!=null?l:Ae,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:m,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:y,isSigner:!1,isWritable:!0},{pubkey:h,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!1,isWritable:!1},{pubkey:g,isSigner:!1,isWritable:!0},{pubkey:L,isSigner:!1,isWritable:!1},{pubkey:ue,isSigner:!1,isWritable:!1},{pubkey:ee,isSigner:!1,isWritable:!1}],x=A([P("lpFeeAmount")]),I=Buffer.alloc(x.span);x.encode({lpFeeAmount:b},I);let W=Buffer.from([...N.collectCpFee,...I]);return new _({keys:f,programId:t,data:W})}export{ha as collectCpFeeInstruction,wt as cpmmLockPositionInstruction,ya as makeCpmmLockInstruction,pa as makeCreateCpmmPoolInInstruction,fa as makeDepositCpmmInInstruction,ga as makeSwapCpmmBaseInInstruction,ba as makeSwapCpmmBaseOutInstruction,da as makeWithdrawCpmmInInstruction};
//# sourceMappingURL=instruction.mjs.map