@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 80.2 kB
JavaScript
var Vn=Object.create;var Ne=Object.defineProperty,qn=Object.defineProperties,Wn=Object.getOwnPropertyDescriptor,Un=Object.getOwnPropertyDescriptors,Gn=Object.getOwnPropertyNames,Fe=Object.getOwnPropertySymbols,Hn=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var Ht=(t,e,n)=>e in t?Ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,G=(t,e)=>{for(var n in e||(e={}))dt.call(e,n)&&Ht(t,n,e[n]);if(Fe)for(var n of Fe(e))zt.call(e,n)&&Ht(t,n,e[n]);return t},ue=(t,e)=>qn(t,Un(e));var Ve=(t,e)=>{var n={};for(var r in t)dt.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Fe)for(var r of Fe(t))e.indexOf(r)<0&&zt.call(t,r)&&(n[r]=t[r]);return n};var zn=(t,e)=>{for(var n in e)Ne(t,n,{get:e[n],enumerable:!0})},jt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gn(e))!dt.call(t,i)&&i!==n&&Ne(t,i,{get:()=>e[i],enumerable:!(r=Wn(e,i))||r.enumerable});return t};var J=(t,e,n)=>(n=t!=null?Vn(Hn(t)):{},jt(e||!t||!t.__esModule?Ne(n,"default",{value:t,enumerable:!0}):n,t)),jn=t=>jt(Ne({},"__esModule",{value:!0}),t);var gi={};zn(gi,{default:()=>pt});module.exports=jn(gi);var ke=require("@solana/web3.js"),Gt=require("@solana/spl-token"),Ce=J(require("bn.js"));var Ee=require("lodash");var mt=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}},Qt={},Qn={};function z(t){let e=(0,Ee.get)(Qt,t);if(!e){let n=(0,Ee.get)(Qn,t);e=new mt({name:t,logLevel:n}),(0,Ee.set)(Qt,t,e)}return e}var R=require("@solana/web3.js"),Nn=J(require("axios"));var X={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",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut"};var Q=require("@solana/web3.js"),Zt=require("@solana/spl-token");var Yt=z("Raydium_txUtil"),Jt=1644;function qe(t){let e=[],n=[];return t.microLamports&&(e.push(Q.ComputeBudgetProgram.setComputeUnitPrice({microLamports:t.microLamports})),n.push(X.SetComputeUnitPrice)),t.units&&(e.push(Q.ComputeBudgetProgram.setComputeUnitLimit({units:t.units})),n.push(X.SetComputeUnitLimit)),{instructions:e,instructionTypes:n}}async function xe(t,e){var r,i;let n=e!=null?e:"confirmed";try{return((i=await((r=t.getLatestBlockhash)==null?void 0:r.call(t,{commitment:n})))==null?void 0:i.blockhash)||(await t.getRecentBlockhash(n)).blockhash}catch{return(await t.getRecentBlockhash(n)).blockhash}}function Yn(t,e){t.length<1&&Yt.logWithError(`no instructions provided: ${t.toString()}`),e.length<1&&Yt.logWithError(`no signers provided:, ${e.toString()}`);let n=new Q.Transaction;n.recentBlockhash="11111111111111111111111111111111",n.feePayer=e[0],n.add(...t);try{return Buffer.from(n.serialize({verifySignatures:!1})).toString("base64").length<Jt}catch{return!1}}function Me({instructions:t,payer:e,signers:n}){return Yn(t,[e,...n])}function Re({instructions:t,payer:e,lookupTableAddressAccount:n,recentBlockhash:r=Q.Keypair.generate().publicKey.toString()}){let o=new Q.TransactionMessage({payerKey:e,recentBlockhash:r,instructions:t}).compileToV0Message(Object.values(n!=null?n:{}));try{return Buffer.from(new Q.VersionedTransaction(o).serialize()).toString("base64").length<Jt}catch{return!1}}var Zn=t=>Buffer.isBuffer(t)?t:t instanceof Uint8Array?Buffer.from(t.buffer,t.byteOffset,t.byteLength):Buffer.from(t),Jn=t=>{let e=t.serialize({requireAllSignatures:!1,verifySignatures:!1});t instanceof Q.VersionedTransaction&&(e=Zn(e));try{return e instanceof Buffer?e.toString("base64"):Buffer.from(e).toString("base64")}catch{return e.toString("base64")}};function be(t){let e=[];return t.forEach(n=>{n instanceof Q.Transaction&&(n.recentBlockhash||(n.recentBlockhash=Zt.TOKEN_PROGRAM_ID.toBase58()),n.feePayer||(n.feePayer=Q.Keypair.generate().publicKey)),e.push(Jn(n))}),console.log("simulate tx string:",e),e}var de=require("@solana/web3.js");var kn=require("@solana/web3.js"),et=require("@solana/spl-token");var Jr=require("@solana/web3.js"),Xr=J(require("bn.js"));var Ln=J(require("big.js")),Zr=J(require("bn.js"));var Y=J(require("bn.js"));var Te=9e15,fe=1e9,gt="0123456789abcdef",Ue="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ge="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ht={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Te,maxE:Te,crypto:!1},tn,se,L=!0,ze="[DecimalError] ",le=ze+"Invalid argument: ",nn=ze+"Precision limit exceeded",rn=ze+"crypto unavailable",on="[object Decimal]",j=Math.floor,W=Math.pow,Xn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,$n=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,er=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,sn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,te=1e7,B=7,tr=9007199254740991,nr=Ue.length-1,bt=Ge.length-1,m={toStringTag:on};m.absoluteValue=m.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),P(t)};m.ceil=function(){return P(new this.constructor(this),this.e+1,2)};m.clampedTo=m.clamp=function(t,e){var n,r=this,i=r.constructor;if(t=new i(t),e=new i(e),!t.s||!e.s)return new i(NaN);if(t.gt(e))throw Error(le+e);return n=r.cmp(t),n<0?t:r.cmp(e)>0?e:new i(r)};m.comparedTo=m.cmp=function(t){var e,n,r,i,o=this,s=o.d,u=(t=new o.constructor(t)).d,a=o.s,c=t.s;if(!s||!u)return!a||!c?NaN:a!==c?a:s===u?0:!s^a<0?1:-1;if(!s[0]||!u[0])return s[0]?a:u[0]?-c:0;if(a!==c)return a;if(o.e!==t.e)return o.e>t.e^a<0?1:-1;for(r=s.length,i=u.length,e=0,n=r<i?r:i;e<n;++e)if(s[e]!==u[e])return s[e]>u[e]^a<0?1:-1;return r===i?0:r>i^a<0?1:-1};m.cosine=m.cos=function(){var t,e,n=this,r=n.constructor;return n.d?n.d[0]?(t=r.precision,e=r.rounding,r.precision=t+Math.max(n.e,n.sd())+B,r.rounding=1,n=rr(r,fn(r,n)),r.precision=t,r.rounding=e,P(se==2||se==3?n.neg():n,t,e,!0)):new r(1):new r(NaN)};m.cubeRoot=m.cbrt=function(){var t,e,n,r,i,o,s,u,a,c,f=this,l=f.constructor;if(!f.isFinite()||f.isZero())return new l(f);for(L=!1,o=f.s*W(f.s*f,1/3),!o||Math.abs(o)==1/0?(n=H(f.d),t=f.e,(o=(t-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=W(n,1/3),t=j((t+1)/3)-(t%3==(t<0?-1:2)),o==1/0?n="5e"+t:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),r=new l(n),r.s=f.s):r=new l(o.toString()),s=(t=l.precision)+3;;)if(u=r,a=u.times(u).times(u),c=a.plus(f),r=D(c.plus(f).times(u),c.plus(a),s+2,1),H(u.d).slice(0,s)===(n=H(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!i&&n=="4999"){if(!i&&(P(u,t+1,0),u.times(u).times(u).eq(f))){r=u;break}s+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(P(r,t+1,1),e=!r.times(r).times(r).eq(f));break}return L=!0,P(r,t,l.rounding,e)};m.decimalPlaces=m.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-j(this.e/B))*B,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};m.dividedBy=m.div=function(t){return D(this,new this.constructor(t))};m.dividedToIntegerBy=m.divToInt=function(t){var e=this,n=e.constructor;return P(D(e,new n(t),0,1,1),n.precision,n.rounding)};m.equals=m.eq=function(t){return this.cmp(t)===0};m.floor=function(){return P(new this.constructor(this),this.e+1,3)};m.greaterThan=m.gt=function(t){return this.cmp(t)>0};m.greaterThanOrEqualTo=m.gte=function(t){var e=this.cmp(t);return e==1||e===0};m.hyperbolicCosine=m.cosh=function(){var t,e,n,r,i,o=this,s=o.constructor,u=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return u;n=s.precision,r=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,i=o.d.length,i<32?(t=Math.ceil(i/3),e=(1/Qe(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=Pe(s,1,o.times(e),new s(1),!0);for(var a,c=t,f=new s(8);c--;)a=o.times(o),o=u.minus(a.times(f.minus(a.times(f))));return P(o,s.precision=n,s.rounding=r,!0)};m.hyperbolicSine=m.sinh=function(){var t,e,n,r,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(e=o.precision,n=o.rounding,o.precision=e+Math.max(i.e,i.sd())+4,o.rounding=1,r=i.d.length,r<3)i=Pe(o,2,i,i,!0);else{t=1.4*Math.sqrt(r),t=t>16?16:t|0,i=i.times(1/Qe(5,t)),i=Pe(o,2,i,i,!0);for(var s,u=new o(5),a=new o(16),c=new o(20);t--;)s=i.times(i),i=i.times(u.plus(s.times(a.times(s).plus(c))))}return o.precision=e,o.rounding=n,P(i,e,n,!0)};m.hyperbolicTangent=m.tanh=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+7,r.rounding=1,D(n.sinh(),n.cosh(),r.precision=t,r.rounding=e)):new r(n.s)};m.inverseCosine=m.acos=function(){var t,e=this,n=e.constructor,r=e.abs().cmp(1),i=n.precision,o=n.rounding;return r!==-1?r===0?e.isNeg()?ee(n,i,o):new n(0):new n(NaN):e.isZero()?ee(n,i+4,o).times(.5):(n.precision=i+6,n.rounding=1,e=e.asin(),t=ee(n,i+4,o).times(.5),n.precision=i,n.rounding=o,t.minus(e))};m.inverseHyperbolicCosine=m.acosh=function(){var t,e,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(t=r.precision,e=r.rounding,r.precision=t+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,L=!1,n=n.times(n).minus(1).sqrt().plus(n),L=!0,r.precision=t,r.rounding=e,n.ln()):new r(n)};m.inverseHyperbolicSine=m.asinh=function(){var t,e,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,L=!1,n=n.times(n).plus(1).sqrt().plus(n),L=!0,r.precision=t,r.rounding=e,n.ln())};m.inverseHyperbolicTangent=m.atanh=function(){var t,e,n,r,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=o.precision,e=o.rounding,r=i.sd(),Math.max(r,t)<2*-i.e-1?P(new o(i),t,e,!0):(o.precision=n=r-i.e,i=D(i.plus(1),new o(1).minus(i),n+t,1),o.precision=t+4,o.rounding=1,i=i.ln(),o.precision=t,o.rounding=e,i.times(.5))):new o(NaN)};m.inverseSine=m.asin=function(){var t,e,n,r,i=this,o=i.constructor;return i.isZero()?new o(i):(e=i.abs().cmp(1),n=o.precision,r=o.rounding,e!==-1?e===0?(t=ee(o,n+4,r).times(.5),t.s=i.s,t):new o(NaN):(o.precision=n+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=r,i.times(2)))};m.inverseTangent=m.atan=function(){var t,e,n,r,i,o,s,u,a,c=this,f=c.constructor,l=f.precision,p=f.rounding;if(c.isFinite()){if(c.isZero())return new f(c);if(c.abs().eq(1)&&l+4<=bt)return s=ee(f,l+4,p).times(.25),s.s=c.s,s}else{if(!c.s)return new f(NaN);if(l+4<=bt)return s=ee(f,l+4,p).times(.5),s.s=c.s,s}for(f.precision=u=l+10,f.rounding=1,n=Math.min(28,u/B+2|0),t=n;t;--t)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(L=!1,e=Math.ceil(u/B),r=1,a=c.times(c),s=new f(c),i=c;t!==-1;)if(i=i.times(a),o=s.minus(i.div(r+=2)),i=i.times(a),s=o.plus(i.div(r+=2)),s.d[e]!==void 0)for(t=e;s.d[t]===o.d[t]&&t--;);return n&&(s=s.times(2<<n-1)),L=!0,P(s,f.precision=l,f.rounding=p,!0)};m.isFinite=function(){return!!this.d};m.isInteger=m.isInt=function(){return!!this.d&&j(this.e/B)>this.d.length-2};m.isNaN=function(){return!this.s};m.isNegative=m.isNeg=function(){return this.s<0};m.isPositive=m.isPos=function(){return this.s>0};m.isZero=function(){return!!this.d&&this.d[0]===0};m.lessThan=m.lt=function(t){return this.cmp(t)<0};m.lessThanOrEqualTo=m.lte=function(t){return this.cmp(t)<1};m.logarithm=m.log=function(t){var e,n,r,i,o,s,u,a,c=this,f=c.constructor,l=f.precision,p=f.rounding,d=5;if(t==null)t=new f(10),e=!0;else{if(t=new f(t),n=t.d,t.s<0||!n||!n[0]||t.eq(1))return new f(NaN);e=t.eq(10)}if(n=c.d,c.s<0||!n||!n[0]||c.eq(1))return new f(n&&!n[0]?-1/0:c.s!=1?NaN:n?0:1/0);if(e)if(n.length>1)o=!0;else{for(i=n[0];i%10===0;)i/=10;o=i!==1}if(L=!1,u=l+d,s=ce(c,u),r=e?He(f,u+10):ce(t,u),a=D(s,r,u,1),De(a.d,i=l,p))do if(u+=10,s=ce(c,u),r=e?He(f,u+10):ce(t,u),a=D(s,r,u,1),!o){+H(a.d).slice(i+1,i+15)+1==1e14&&(a=P(a,l+1,0));break}while(De(a.d,i+=10,p));return L=!0,P(a,l,p)};m.minus=m.sub=function(t){var e,n,r,i,o,s,u,a,c,f,l,p,d=this,w=d.constructor;if(t=new w(t),!d.d||!t.d)return!d.s||!t.s?t=new w(NaN):d.d?t.s=-t.s:t=new w(t.d||d.s!==t.s?d:NaN),t;if(d.s!=t.s)return t.s=-t.s,d.plus(t);if(c=d.d,p=t.d,u=w.precision,a=w.rounding,!c[0]||!p[0]){if(p[0])t.s=-t.s;else if(c[0])t=new w(d);else return new w(a===3?-0:0);return L?P(t,u,a):t}if(n=j(t.e/B),f=j(d.e/B),c=c.slice(),o=f-n,o){for(l=o<0,l?(e=c,o=-o,s=p.length):(e=p,n=f,s=c.length),r=Math.max(Math.ceil(u/B),s)+2,o>r&&(o=r,e.length=1),e.reverse(),r=o;r--;)e.push(0);e.reverse()}else{for(r=c.length,s=p.length,l=r<s,l&&(s=r),r=0;r<s;r++)if(c[r]!=p[r]){l=c[r]<p[r];break}o=0}for(l&&(e=c,c=p,p=e,t.s=-t.s),s=c.length,r=p.length-s;r>0;--r)c[s++]=0;for(r=p.length;r>o;){if(c[--r]<p[r]){for(i=r;i&&c[--i]===0;)c[i]=te-1;--c[i],c[r]+=te}c[r]-=p[r]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--n;return c[0]?(t.d=c,t.e=je(c,n),L?P(t,u,a):t):new w(a===3?-0:0)};m.modulo=m.mod=function(t){var e,n=this,r=n.constructor;return t=new r(t),!n.d||!t.s||t.d&&!t.d[0]?new r(NaN):!t.d||n.d&&!n.d[0]?P(new r(n),r.precision,r.rounding):(L=!1,r.modulo==9?(e=D(n,t.abs(),0,3,1),e.s*=t.s):e=D(n,t,0,r.modulo,1),e=e.times(t),L=!0,n.minus(e))};m.naturalExponential=m.exp=function(){return yt(this)};m.naturalLogarithm=m.ln=function(){return ce(this)};m.negated=m.neg=function(){var t=new this.constructor(this);return t.s=-t.s,P(t)};m.plus=m.add=function(t){var e,n,r,i,o,s,u,a,c,f,l=this,p=l.constructor;if(t=new p(t),!l.d||!t.d)return!l.s||!t.s?t=new p(NaN):l.d||(t=new p(t.d||l.s===t.s?l:NaN)),t;if(l.s!=t.s)return t.s=-t.s,l.minus(t);if(c=l.d,f=t.d,u=p.precision,a=p.rounding,!c[0]||!f[0])return f[0]||(t=new p(l)),L?P(t,u,a):t;if(o=j(l.e/B),r=j(t.e/B),c=c.slice(),i=o-r,i){for(i<0?(n=c,i=-i,s=f.length):(n=f,r=o,s=c.length),o=Math.ceil(u/B),s=o>s?o+1:s+1,i>s&&(i=s,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(s=c.length,i=f.length,s-i<0&&(i=s,n=f,f=c,c=n),e=0;i;)e=(c[--i]=c[i]+f[i]+e)/te|0,c[i]%=te;for(e&&(c.unshift(e),++r),s=c.length;c[--s]==0;)c.pop();return t.d=c,t.e=je(c,r),L?P(t,u,a):t};m.precision=m.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(le+t);return n.d?(e=un(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};m.round=function(){var t=this,e=t.constructor;return P(new e(t),t.e+1,e.rounding)};m.sine=m.sin=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+Math.max(n.e,n.sd())+B,r.rounding=1,n=or(r,fn(r,n)),r.precision=t,r.rounding=e,P(se>2?n.neg():n,t,e,!0)):new r(NaN)};m.squareRoot=m.sqrt=function(){var t,e,n,r,i,o,s=this,u=s.d,a=s.e,c=s.s,f=s.constructor;if(c!==1||!u||!u[0])return new f(!c||c<0&&(!u||u[0])?NaN:u?s:1/0);for(L=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=H(u),(e.length+a)%2==0&&(e+="0"),c=Math.sqrt(e),a=j((a+1)/2)-(a<0||a%2),c==1/0?e="5e"+a:(e=c.toExponential(),e=e.slice(0,e.indexOf("e")+1)+a),r=new f(e)):r=new f(c.toString()),n=(a=f.precision)+3;;)if(o=r,r=o.plus(D(s,o,n+2,1)).times(.5),H(o.d).slice(0,n)===(e=H(r.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!i&&e=="4999"){if(!i&&(P(o,a+1,0),o.times(o).eq(s))){r=o;break}n+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(P(r,a+1,1),t=!r.times(r).eq(s));break}return L=!0,P(r,a,f.rounding,t)};m.tangent=m.tan=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+10,r.rounding=1,n=n.sin(),n.s=1,n=D(n,new r(1).minus(n.times(n)).sqrt(),t+10,0),r.precision=t,r.rounding=e,P(se==2||se==4?n.neg():n,t,e,!0)):new r(NaN)};m.times=m.mul=function(t){var e,n,r,i,o,s,u,a,c,f=this,l=f.constructor,p=f.d,d=(t=new l(t)).d;if(t.s*=f.s,!p||!p[0]||!d||!d[0])return new l(!t.s||p&&!p[0]&&!d||d&&!d[0]&&!p?NaN:!p||!d?t.s/0:t.s*0);for(n=j(f.e/B)+j(t.e/B),a=p.length,c=d.length,a<c&&(o=p,p=d,d=o,s=a,a=c,c=s),o=[],s=a+c,r=s;r--;)o.push(0);for(r=c;--r>=0;){for(e=0,i=a+r;i>r;)u=o[i]+d[r]*p[i-r-1]+e,o[i--]=u%te|0,e=u/te|0;o[i]=(o[i]+e)%te|0}for(;!o[--s];)o.pop();return e?++n:o.shift(),t.d=o,t.e=je(o,n),L?P(t,l.precision,l.rounding):t};m.toBinary=function(t,e){return xt(this,2,t,e)};m.toDecimalPlaces=m.toDP=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:($(t,0,fe),e===void 0?e=r.rounding:$(e,0,8),P(n,t+n.e+1,e))};m.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=ie(r,!0):($(t,0,fe),e===void 0?e=i.rounding:$(e,0,8),r=P(new i(r),t+1,e),n=ie(r,!0,t+1)),r.isNeg()&&!r.isZero()?"-"+n:n};m.toFixed=function(t,e){var n,r,i=this,o=i.constructor;return t===void 0?n=ie(i):($(t,0,fe),e===void 0?e=o.rounding:$(e,0,8),r=P(new o(i),t+i.e+1,e),n=ie(r,!1,t+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n};m.toFraction=function(t){var e,n,r,i,o,s,u,a,c,f,l,p,d=this,w=d.d,g=d.constructor;if(!w)return new g(d);if(c=n=new g(1),r=a=new g(0),e=new g(r),o=e.e=un(w)-d.e-1,s=o%B,e.d[0]=W(10,s<0?B+s:s),t==null)t=o>0?e:c;else{if(u=new g(t),!u.isInt()||u.lt(c))throw Error(le+u);t=u.gt(e)?o>0?e:c:u}for(L=!1,u=new g(H(w)),f=g.precision,g.precision=o=w.length*B*2;l=D(u,e,0,1,1),i=n.plus(l.times(r)),i.cmp(t)!=1;)n=r,r=i,i=c,c=a.plus(l.times(i)),a=i,i=e,e=u.minus(l.times(i)),u=i;return i=D(t.minus(n),r,0,1,1),a=a.plus(i.times(c)),n=n.plus(i.times(r)),a.s=c.s=d.s,p=D(c,r,o,1).minus(d).abs().cmp(D(a,n,o,1).minus(d).abs())<1?[c,r]:[a,n],g.precision=f,L=!0,p};m.toHexadecimal=m.toHex=function(t,e){return xt(this,16,t,e)};m.toNearest=function(t,e){var n=this,r=n.constructor;if(n=new r(n),t==null){if(!n.d)return n;t=new r(1),e=r.rounding}else{if(t=new r(t),e===void 0?e=r.rounding:$(e,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(L=!1,n=D(n,t,0,e,1).times(t),L=!0,P(n)):(t.s=n.s,n=t),n};m.toNumber=function(){return+this};m.toOctal=function(t,e){return xt(this,8,t,e)};m.toPower=m.pow=function(t){var e,n,r,i,o,s,u=this,a=u.constructor,c=+(t=new a(t));if(!u.d||!t.d||!u.d[0]||!t.d[0])return new a(W(+u,c));if(u=new a(u),u.eq(1))return u;if(r=a.precision,o=a.rounding,t.eq(1))return P(u,r,o);if(e=j(t.e/B),e>=t.d.length-1&&(n=c<0?-c:c)<=tr)return i=an(a,u,n,r),t.s<0?new a(1).div(i):P(i,r,o);if(s=u.s,s<0){if(e<t.d.length-1)return new a(NaN);if((t.d[e]&1)==0&&(s=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=s,u}return n=W(+u,c),e=n==0||!isFinite(n)?j(c*(Math.log("0."+H(u.d))/Math.LN10+u.e+1)):new a(n+"").e,e>a.maxE+1||e<a.minE-1?new a(e>0?s/0:0):(L=!1,a.rounding=u.s=1,n=Math.min(12,(e+"").length),i=yt(t.times(ce(u,r+n)),r),i.d&&(i=P(i,r+5,1),De(i.d,r,o)&&(e=r+10,i=P(yt(t.times(ce(u,e+n)),e),e+5,1),+H(i.d).slice(r+1,r+15)+1==1e14&&(i=P(i,r+1,0)))),i.s=s,L=!0,a.rounding=o,P(i,r,o))};m.toPrecision=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=ie(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):($(t,1,fe),e===void 0?e=i.rounding:$(e,0,8),r=P(new i(r),t,e),n=ie(r,t<=r.e||r.e<=i.toExpNeg,t)),r.isNeg()&&!r.isZero()?"-"+n:n};m.toSignificantDigits=m.toSD=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):($(t,1,fe),e===void 0?e=r.rounding:$(e,0,8)),P(new r(n),t,e)};m.toString=function(){var t=this,e=t.constructor,n=ie(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};m.truncated=m.trunc=function(){return P(new this.constructor(this),this.e+1,1)};m.valueOf=m.toJSON=function(){var t=this,e=t.constructor,n=ie(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function H(t){var e,n,r,i=t.length-1,o="",s=t[0];if(i>0){for(o+=s,e=1;e<i;e++)r=t[e]+"",n=B-r.length,n&&(o+=ae(n)),o+=r;s=t[e],r=s+"",n=B-r.length,n&&(o+=ae(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function $(t,e,n){if(t!==~~t||t<e||t>n)throw Error(le+t)}function De(t,e,n,r){var i,o,s,u;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=B,i=0):(i=Math.ceil((e+1)/B),e%=B),o=W(10,B-e),u=t[i]%o|0,r==null?e<3?(e==0?u=u/100|0:e==1&&(u=u/10|0),s=n<4&&u==99999||n>3&&u==49999||u==5e4||u==0):s=(n<4&&u+1==o||n>3&&u+1==o/2)&&(t[i+1]/o/100|0)==W(10,e-2)-1||(u==o/2||u==0)&&(t[i+1]/o/100|0)==0:e<4?(e==0?u=u/1e3|0:e==1?u=u/100|0:e==2&&(u=u/10|0),s=(r||n<4)&&u==9999||!r&&n>3&&u==4999):s=((r||n<4)&&u+1==o||!r&&n>3&&u+1==o/2)&&(t[i+1]/o/1e3|0)==W(10,e-3)-1,s}function We(t,e,n){for(var r,i=[0],o,s=0,u=t.length;s<u;){for(o=i.length;o--;)i[o]*=e;for(i[0]+=gt.indexOf(t.charAt(s++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function rr(t,e){var n,r,i;if(e.isZero())return e;r=e.d.length,r<32?(n=Math.ceil(r/3),i=(1/Qe(4,n)).toString()):(n=16,i="2.3283064365386962890625e-10"),t.precision+=n,e=Pe(t,1,e.times(i),new t(1));for(var o=n;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return t.precision-=n,e}var D=function(){function t(r,i,o){var s,u=0,a=r.length;for(r=r.slice();a--;)s=r[a]*i+u,r[a]=s%o|0,u=s/o|0;return u&&r.unshift(u),r}function e(r,i,o,s){var u,a;if(o!=s)a=o>s?1:-1;else for(u=a=0;u<o;u++)if(r[u]!=i[u]){a=r[u]>i[u]?1:-1;break}return a}function n(r,i,o,s){for(var u=0;o--;)r[o]-=u,u=r[o]<i[o]?1:0,r[o]=u*s+r[o]-i[o];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,o,s,u,a){var c,f,l,p,d,w,g,T,x,y,h,b,N,S,F,M,_,O,v,V,oe=r.constructor,we=r.s==i.s?1:-1,U=r.d,K=i.d;if(!U||!U[0]||!K||!K[0])return new oe(!r.s||!i.s||(U?K&&U[0]==K[0]:!K)?NaN:U&&U[0]==0||!K?we*0:we/0);for(a?(d=1,f=r.e-i.e):(a=te,d=B,f=j(r.e/d)-j(i.e/d)),v=K.length,_=U.length,x=new oe(we),y=x.d=[],l=0;K[l]==(U[l]||0);l++);if(K[l]>(U[l]||0)&&f--,o==null?(S=o=oe.precision,s=oe.rounding):u?S=o+(r.e-i.e)+1:S=o,S<0)y.push(1),w=!0;else{if(S=S/d+2|0,l=0,v==1){for(p=0,K=K[0],S++;(l<_||p)&&S--;l++)F=p*a+(U[l]||0),y[l]=F/K|0,p=F%K|0;w=p||l<_}else{for(p=a/(K[0]+1)|0,p>1&&(K=t(K,p,a),U=t(U,p,a),v=K.length,_=U.length),M=v,h=U.slice(0,v),b=h.length;b<v;)h[b++]=0;V=K.slice(),V.unshift(0),O=K[0],K[1]>=a/2&&++O;do p=0,c=e(K,h,v,b),c<0?(N=h[0],v!=b&&(N=N*a+(h[1]||0)),p=N/O|0,p>1?(p>=a&&(p=a-1),g=t(K,p,a),T=g.length,b=h.length,c=e(g,h,T,b),c==1&&(p--,n(g,v<T?V:K,T,a))):(p==0&&(c=p=1),g=K.slice()),T=g.length,T<b&&g.unshift(0),n(h,g,b,a),c==-1&&(b=h.length,c=e(K,h,v,b),c<1&&(p++,n(h,v<b?V:K,b,a))),b=h.length):c===0&&(p++,h=[0]),y[l++]=p,c&&h[0]?h[b++]=U[M]||0:(h=[U[M]],b=1);while((M++<_||h[0]!==void 0)&&S--);w=h[0]!==void 0}y[0]||y.shift()}if(d==1)x.e=f,tn=w;else{for(l=1,p=y[0];p>=10;p/=10)l++;x.e=l+f*d-1,P(x,u?o+x.e+1:o,s,w)}return x}}();function P(t,e,n,r){var i,o,s,u,a,c,f,l,p,d=t.constructor;e:if(e!=null){if(l=t.d,!l)return t;for(i=1,u=l[0];u>=10;u/=10)i++;if(o=e-i,o<0)o+=B,s=e,f=l[p=0],a=f/W(10,i-s-1)%10|0;else if(p=Math.ceil((o+1)/B),u=l.length,p>=u)if(r){for(;u++<=p;)l.push(0);f=a=0,i=1,o%=B,s=o-B+1}else break e;else{for(f=u=l[p],i=1;u>=10;u/=10)i++;o%=B,s=o-B+i,a=s<0?0:f/W(10,i-s-1)%10|0}if(r=r||e<0||l[p+1]!==void 0||(s<0?f:f%W(10,i-s-1)),c=n<4?(a||r)&&(n==0||n==(t.s<0?3:2)):a>5||a==5&&(n==4||r||n==6&&(o>0?s>0?f/W(10,i-s):0:l[p-1])%10&1||n==(t.s<0?8:7)),e<1||!l[0])return l.length=0,c?(e-=t.e+1,l[0]=W(10,(B-e%B)%B),t.e=-e||0):l[0]=t.e=0,t;if(o==0?(l.length=p,u=1,p--):(l.length=p+1,u=W(10,B-o),l[p]=s>0?(f/W(10,i-s)%W(10,s)|0)*u:0),c)for(;;)if(p==0){for(o=1,s=l[0];s>=10;s/=10)o++;for(s=l[0]+=u,u=1;s>=10;s/=10)u++;o!=u&&(t.e++,l[0]==te&&(l[0]=1));break}else{if(l[p]+=u,l[p]!=te)break;l[p--]=0,u=1}for(o=l.length;l[--o]===0;)l.pop()}return L&&(t.e>d.maxE?(t.d=null,t.e=NaN):t.e<d.minE&&(t.e=0,t.d=[0])),t}function ie(t,e,n){if(!t.isFinite())return ln(t);var r,i=t.e,o=H(t.d),s=o.length;return e?(n&&(r=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+ae(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):i<0?(o="0."+ae(-i-1)+o,n&&(r=n-s)>0&&(o+=ae(r))):i>=s?(o+=ae(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+ae(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(o+="."),o+=ae(r))),o}function je(t,e){var n=t[0];for(e*=B;n>=10;n/=10)e++;return e}function He(t,e,n){if(e>nr)throw L=!0,n&&(t.precision=n),Error(nn);return P(new t(Ue),e,1,!0)}function ee(t,e,n){if(e>bt)throw Error(nn);return P(new t(Ge),e,n,!0)}function un(t){var e=t.length-1,n=e*B+1;if(e=t[e],e){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function ae(t){for(var e="";t--;)e+="0";return e}function an(t,e,n,r){var i,o=new t(1),s=Math.ceil(r/B+4);for(L=!1;;){if(n%2&&(o=o.times(e),$t(o.d,s)&&(i=!0)),n=j(n/2),n===0){n=o.d.length-1,i&&o.d[n]===0&&++o.d[n];break}e=e.times(e),$t(e.d,s)}return L=!0,o}function Xt(t){return t.d[t.d.length-1]&1}function cn(t,e,n){for(var r,i=new t(e[0]),o=0;++o<e.length;)if(r=new t(e[o]),r.s)i[n](r)&&(i=r);else{i=r;break}return i}function yt(t,e){var n,r,i,o,s,u,a,c=0,f=0,l=0,p=t.constructor,d=p.rounding,w=p.precision;if(!t.d||!t.d[0]||t.e>17)return new p(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:0/0);for(e==null?(L=!1,a=w):a=e,u=new p(.03125);t.e>-2;)t=t.times(u),l+=5;for(r=Math.log(W(2,l))/Math.LN10*2+5|0,a+=r,n=o=s=new p(1),p.precision=a;;){if(o=P(o.times(t),a,1),n=n.times(++f),u=s.plus(D(o,n,a,1)),H(u.d).slice(0,a)===H(s.d).slice(0,a)){for(i=l;i--;)s=P(s.times(s),a,1);if(e==null)if(c<3&&De(s.d,a-r,d,c))p.precision=a+=10,n=o=u=new p(1),f=0,c++;else return P(s,p.precision=w,d,L=!0);else return p.precision=w,s}s=u}}function ce(t,e){var n,r,i,o,s,u,a,c,f,l,p,d=1,w=10,g=t,T=g.d,x=g.constructor,y=x.rounding,h=x.precision;if(g.s<0||!T||!T[0]||!g.e&&T[0]==1&&T.length==1)return new x(T&&!T[0]?-1/0:g.s!=1?NaN:T?0:g);if(e==null?(L=!1,f=h):f=e,x.precision=f+=w,n=H(T),r=n.charAt(0),Math.abs(o=g.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(t),n=H(g.d),r=n.charAt(0),d++;o=g.e,r>1?(g=new x("0."+n),o++):g=new x(r+"."+n.slice(1))}else return c=He(x,f+2,h).times(o+""),g=ce(new x(r+"."+n.slice(1)),f-w).plus(c),x.precision=h,e==null?P(g,h,y,L=!0):g;for(l=g,a=s=g=D(g.minus(1),g.plus(1),f,1),p=P(g.times(g),f,1),i=3;;){if(s=P(s.times(p),f,1),c=a.plus(D(s,new x(i),f,1)),H(c.d).slice(0,f)===H(a.d).slice(0,f))if(a=a.times(2),o!==0&&(a=a.plus(He(x,f+2,h).times(o+""))),a=D(a,new x(d),f,1),e==null)if(De(a.d,f-w,y,u))x.precision=f+=w,c=s=g=D(l.minus(1),l.plus(1),f,1),p=P(g.times(g),f,1),i=u=1;else return P(a,x.precision=h,y,L=!0);else return x.precision=h,a;a=c,i+=2}}function ln(t){return String(t.s*t.s/0)}function wt(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;r++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(r,i),e){if(i-=r,t.e=n=n-r-1,t.d=[],r=(n+1)%B,n<0&&(r+=B),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=B;r<i;)t.d.push(+e.slice(r,r+=B));e=e.slice(r),r=B-e.length}else r-=i;for(;r--;)e+="0";t.d.push(+e),L&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function ir(t,e){var n,r,i,o,s,u,a,c,f;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),sn.test(e))return wt(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if($n.test(e))n=16,e=e.toLowerCase();else if(Xn.test(e))n=2;else if(er.test(e))n=8;else throw Error(le+e);for(o=e.search(/p/i),o>0?(a=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,r=t.constructor,s&&(e=e.replace(".",""),u=e.length,o=u-o,i=an(r,new r(n),o,o*2)),c=We(e,n,te),f=c.length-1,o=f;c[o]===0;--o)c.pop();return o<0?new r(t.s*0):(t.e=je(c,f),t.d=c,L=!1,s&&(t=D(t,i,u*4)),a&&(t=t.times(Math.abs(a)<54?W(2,a):Ye.pow(2,a))),L=!0,t)}function or(t,e){var n,r=e.d.length;if(r<3)return e.isZero()?e:Pe(t,2,e,e);n=1.4*Math.sqrt(r),n=n>16?16:n|0,e=e.times(1/Qe(5,n)),e=Pe(t,2,e,e);for(var i,o=new t(5),s=new t(16),u=new t(20);n--;)i=e.times(e),e=e.times(o.plus(i.times(s.times(i).minus(u))));return e}function Pe(t,e,n,r,i){var o,s,u,a,c=1,f=t.precision,l=Math.ceil(f/B);for(L=!1,a=n.times(n),u=new t(r);;){if(s=D(u.times(a),new t(e++*e++),f,1),u=i?r.plus(s):r.minus(s),r=D(s.times(a),new t(e++*e++),f,1),s=u.plus(r),s.d[l]!==void 0){for(o=l;s.d[o]===u.d[o]&&o--;);if(o==-1)break}o=u,u=r,r=s,s=o,c++}return L=!0,s.d.length=l+1,s}function Qe(t,e){for(var n=t;--e;)n*=t;return n}function fn(t,e){var n,r=e.s<0,i=ee(t,t.precision,1),o=i.times(.5);if(e=e.abs(),e.lte(o))return se=r?4:1,e;if(n=e.divToInt(i),n.isZero())se=r?3:2;else{if(e=e.minus(n.times(i)),e.lte(o))return se=Xt(n)?r?2:3:r?4:1,e;se=Xt(n)?r?1:4:r?3:2}return e.minus(i).abs()}function xt(t,e,n,r){var i,o,s,u,a,c,f,l,p,d=t.constructor,w=n!==void 0;if(w?($(n,1,fe),r===void 0?r=d.rounding:$(r,0,8)):(n=d.precision,r=d.rounding),!t.isFinite())f=ln(t);else{for(f=ie(t),s=f.indexOf("."),w?(i=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):i=e,s>=0&&(f=f.replace(".",""),p=new d(1),p.e=f.length-s,p.d=We(ie(p),10,i),p.e=p.d.length),l=We(f,10,i),o=a=l.length;l[--a]==0;)l.pop();if(!l[0])f=w?"0p+0":"0";else{if(s<0?o--:(t=new d(t),t.d=l,t.e=o,t=D(t,p,n,r,0,i),l=t.d,o=t.e,c=tn),s=l[n],u=i/2,c=c||l[n+1]!==void 0,c=r<4?(s!==void 0||c)&&(r===0||r===(t.s<0?3:2)):s>u||s===u&&(r===4||c||r===6&&l[n-1]&1||r===(t.s<0?8:7)),l.length=n,c)for(;++l[--n]>i-1;)l[n]=0,n||(++o,l.unshift(1));for(a=l.length;!l[a-1];--a);for(s=0,f="";s<a;s++)f+=gt.charAt(l[s]);if(w){if(a>1)if(e==16||e==8){for(s=e==16?4:3,--a;a%s;a++)f+="0";for(l=We(f,i,e),a=l.length;!l[a-1];--a);for(s=1,f="1.";s<a;s++)f+=gt.charAt(l[s])}else f=f.charAt(0)+"."+f.slice(1);f=f+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)f="0"+f;f="0."+f}else if(++o>a)for(o-=a;o--;)f+="0";else o<a&&(f=f.slice(0,o)+"."+f.slice(o))}f=(e==16?"0x":e==2?"0b":e==8?"0o":"")+f}return t.s<0?"-"+f:f}function $t(t,e){if(t.length>e)return t.length=e,!0}function sr(t){return new this(t).abs()}function ur(t){return new this(t).acos()}function ar(t){return new this(t).acosh()}function cr(t,e){return new this(t).plus(e)}function lr(t){return new this(t).asin()}function fr(t){return new this(t).asinh()}function pr(t){return new this(t).atan()}function dr(t){return new this(t).atanh()}function mr(t,e){t=new this(t),e=new this(e);var n,r=this.precision,i=this.rounding,o=r+4;return!t.s||!e.s?n=new this(NaN):!t.d&&!e.d?(n=ee(this,o,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?ee(this,r,i):new this(0),n.s=t.s):!t.d||e.isZero()?(n=ee(this,o,1).times(.5),n.s=t.s):e.s<0?(this.precision=o,this.rounding=1,n=this.atan(D(t,e,o,1)),e=ee(this,o,1),this.precision=r,this.rounding=i,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(D(t,e,o,1)),n}function gr(t){return new this(t).cbrt()}function hr(t){return P(t=new this(t),t.e+1,2)}function br(t,e,n){return new this(t).clamp(e,n)}function yr(t){if(!t||typeof t!="object")throw Error(ze+"Object expected");var e,n,r,i=t.defaults===!0,o=["precision",1,fe,"rounding",0,8,"toExpNeg",-Te,0,"toExpPos",0,Te,"maxE",0,Te,"minE",-Te,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(n=o[e],i&&(this[n]=ht[n]),(r=t[n])!==void 0)if(j(r)===r&&r>=o[e+1]&&r<=o[e+2])this[n]=r;else throw Error(le+n+": "+r);if(n="crypto",i&&(this[n]=ht[n]),(r=t[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(rn);else this[n]=!1;else throw Error(le+n+": "+r);return this}function wr(t){return new this(t).cos()}function xr(t){return new this(t).cosh()}function pn(t){var e,n,r;function i(o){var s,u,a,c=this;if(!(c instanceof i))return new i(o);if(c.constructor=i,en(o)){c.s=o.s,L?!o.d||o.e>i.maxE?(c.e=NaN,c.d=null):o.e<i.minE?(c.e=0,c.d=[0]):(c.e=o.e,c.d=o.d.slice()):(c.e=o.e,c.d=o.d?o.d.slice():o.d);return}if(a=typeof o,a==="number"){if(o===0){c.s=1/o<0?-1:1,c.e=0,c.d=[0];return}if(o<0?(o=-o,c.s=-1):c.s=1,o===~~o&&o<1e7){for(s=0,u=o;u>=10;u/=10)s++;L?s>i.maxE?(c.e=NaN,c.d=null):s<i.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[o]):(c.e=s,c.d=[o]);return}else if(o*0!==0){o||(c.s=NaN),c.e=NaN,c.d=null;return}return wt(c,o.toString())}else if(a!=="string")throw Error(le+o);return(u=o.charCodeAt(0))===45?(o=o.slice(1),c.s=-1):(u===43&&(o=o.slice(1)),c.s=1),sn.test(o)?wt(c,o):ir(c,o)}if(i.prototype=m,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=yr,i.clone=pn,i.isDecimal=en,i.abs=sr,i.acos=ur,i.acosh=ar,i.add=cr,i.asin=lr,i.asinh=fr,i.atan=pr,i.atanh=dr,i.atan2=mr,i.cbrt=gr,i.ceil=hr,i.clamp=br,i.cos=wr,i.cosh=xr,i.div=Tr,i.exp=Pr,i.floor=Ar,i.hypot=Br,i.ln=Sr,i.log=Lr,i.log10=Cr,i.log2=kr,i.max=Nr,i.min=Er,i.mod=Mr,i.mul=Rr,i.pow=Dr,i.random=Kr,i.round=_r,i.sign=Ir,i.sin=vr,i.sinh=Or,i.sqrt=Fr,i.sub=Vr,i.sum=qr,i.tan=Wr,i.tanh=Ur,i.trunc=Gr,t===void 0&&(t={}),t&&t.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)t.hasOwnProperty(n=r[e++])||(t[n]=this[n]);return i.config(t),i}function Tr(t,e){return new this(t).div(e)}function Pr(t){return new this(t).exp()}function Ar(t){return P(t=new this(t),t.e+1,3)}function Br(){var t,e,n=new this(0);for(L=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)n.d&&(n=n.plus(e.times(e)));else{if(e.s)return L=!0,new this(1/0);n=e}return L=!0,n.sqrt()}function en(t){return t instanceof Ye||t&&t.toStringTag===on||!1}function Sr(t){return new this(t).ln()}function Lr(t,e){return new this(t).log(e)}function kr(t){return new this(t).log(2)}function Cr(t){return new this(t).log(10)}function Nr(){return cn(this,arguments,"lt")}function Er(){return cn(this,arguments,"gt")}function Mr(t,e){return new this(t).mod(e)}function Rr(t,e){return new this(t).mul(e)}function Dr(t,e){return new this(t).pow(e)}function Kr(t){var e,n,r,i,o=0,s=new this(1),u=[];if(t===void 0?t=this.precision:$(t,1,fe),r=Math.ceil(t/B),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));o<r;)i=e[o],i>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:u[o++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);o<r;)i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,o):(u.push(i%1e7),o+=4);o=r/4}else throw Error(rn);else for(;o<r;)u[o++]=Math.random()*1e7|0;for(r=u[--o],t%=B,r&&t&&(i=W(10,B-t),u[o]=(r/i|0)*i);u[o]===0;o--)u.pop();if(o<0)n=0,u=[0];else{for(n=-1;u[0]===0;n-=B)u.shift();for(r=1,i=u[0];i>=10;i/=10)r++;r<B&&(n-=B-r)}return s.e=n,s.d=u,s}function _r(t){return P(t=new this(t),t.e+1,this.rounding)}function Ir(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function vr(t){return new this(t).sin()}function Or(t){return new this(t).sinh()}function Fr(t){return new this(t).sqrt()}function Vr(t,e){return new this(t).sub(e)}function qr(){var t=0,e=arguments,n=new this(e[t]);for(L=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return L=!0,P(n,this.precision,this.rounding)}function Wr(t){return new this(t).tan()}function Ur(t){return new this(t).tanh()}function Gr(t){return P(t=new this(t),t.e+1,1)}m[Symbol.for("nodejs.util.inspect.custom")]=m.toString;m[Symbol.toStringTag]="Decimal";var Ye=m.constructor=pn(ht);Ue=new Ye(Ue);Ge=new Ye(Ge);var Ze=require("@solana/web3.js");var dn=require("@solana/spl-token"),E=require("@solana/web3.js");function Tt({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var Ni=[Tt({pubkey:dn.TOKEN_PROGRAM_ID,isWritable:!1}),Tt({pubkey:E.SystemProgram.programId,isWritable:!1}),Tt({pubkey:E.SYSVAR_RENT_PUBKEY,isWritable:!1})];function mn({publicKey:t,transformSol:e}){let n=gn(t.toString());if(n instanceof E.PublicKey)return e&&n.equals(Ke)?Pt:n;if(e&&n.toString()===Ke.toBase58())return Pt;if(typeof n=="string"){if(n===E.PublicKey.default.toBase58())return E.PublicKey.default;try{return new E.PublicKey(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function gn(t){try{return new E.PublicKey(t)}catch{return t}}var Ei=new E.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Mi=new E.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Ri=new E.PublicKey("SysvarRent111111111111111111111111111111111"),Di=new E.PublicKey("SysvarC1ock11111111111111111111111111111111"),Ki=new E.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),_i=new E.PublicKey("Sysvar1nstructions1111111111111111111111111"),Ii=E.SystemProgram.programId,vi=new E.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Oi=new E.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Fi=new E.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Vi=new E.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),qi=new E.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Wi=new E.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Ui=new E.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Gi=new E.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Hi=new E.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),zi=new E.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),ji=new E.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),Pt=new E.PublicKey("So11111111111111111111111111111111111111112"),Ke=E.PublicKey.default;var hn=require("@solana/web3.js"),At=require("@solana/spl-token"),bn={chainId:101,address:hn.PublicKey.default.toBase58(),programId:At.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},ye={chainId:101,address:"So11111111111111111111111111111111111111112",programId:At.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var Bt=class{constructor({mint:e,decimals:n,symbol:r,name:i,skipMint:o=!1,isToken2022:s=!1}){if(e===Ke.toBase58()||e instanceof Ze.PublicKey&&Ke.equals(e)){this.decimals=ye.decimals,this.symbol=ye.symbol,this.name=ye.name,this.mint=new Ze.PublicKey(ye.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=o?Ze.PublicKey.default:mn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Ae=Bt;Ae.WSOL=new Bt(ue(G({},ye),{mint:ye.address}));var Ie=J(require("big.js")),wn=J(require("bn.js")),xn=J(require("decimal.js-light"));var yn=J(require("toformat")),Hr=yn.default,_e=Hr;var Je=z("module/fraction"),St=_e(Ie.default),ve=_e(xn.default),zr={[0]:ve.ROUND_DOWN,[1]:ve.ROUND_HALF_UP,[2]:ve.ROUND_UP},jr={[0]:Ie.default.roundDown,[1]:Ie.default.roundHalfUp,[2]:Ie.default.roundUp},I=class{constructor(e,n=new wn.default(1)){this.numerator=pe(e),this.denominator=pe(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new I(this.denominator,this.numerator)}add(e){let n=e instanceof I?e:new I(pe(e));return this.denominator.eq(n.denominator)?new I(this.numerator.add(n.numerator),this.denominator):new I(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof I?e:new I(pe(e));return this.denominator.eq(n.denominator)?new I(this.numerator.sub(n.numerator),this.denominator):new I(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof I?e:new I(pe(e));return new I(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof I?e:new I(pe(e));return new I(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},r=1){Number.isInteger(e)||Je.logWithError(`${e} is not an integer.`),e<=0&&Je.logWithError(`${e} is not positive.`),ve.set({precision:e+1,rounding:zr[r]});let i=new ve(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)||Je.logWithError(`${e} is not an integer.`),e<0&&Je.logWithError(`${e} is negative.`),St.DP=e,St.RM=jr[r]||1,new St(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var po=z("Raydium_price");var Lt=class{constructor({decimals:e,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=r}equals(e){return this===e}},Xe=Lt;Xe.SOL=new Lt(bn);var Tn=J(require("bn.js"));var xo=new I(new Tn.default(100));var $e=new Y.default(0),Fo=new Y.default(1),Vo=new Y.default(2),qo=new Y.default(3),Wo=new Y.default(5),Yr=new Y.default(10),Uo=new Y.default(100),Go=new Y.default(1e3),Ho=new Y.default(1e4),Sn=9007199254740991;function pe(t){let e=z("Raydium_parseBigNumberish");if(t instanceof Y.default)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new Y.default(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=Sn||t<=-Sn)&&e.logWithError(`BigNumberish number overflow: ${t}`),new Y.default(String(t))):typeof t=="bigint"?new Y.default(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new Y.default(0))}var ns=z("Raydium_amount"),rs=_e(Ln.default);function kt(t,e=1,n=[]){let r=[...t];if(e<=0)return n;for(;r.length;)n.push(r.splice(0,e));return n}var C=require("@solana/web3.js"),ws=new C.PublicKey("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),xs=new C.PublicKey("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Ts=new C.PublicKey("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Ps=new C.PublicKey("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),As=new C.PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Bs=new C.PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Ss=new C.PublicKey("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Ls=new C.PublicKey("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),ks=new C.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Cs=new C.PublicKey("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),Ns=new C.PublicKey("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),Es=new C.PublicKey("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),Ms=new C.PublicKey("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Rs=new C.PublicKey("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Ds=new C.PublicKey("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Ks=new C.PublicKey("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),_s=new C.PublicKey("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Is=new C.PublicKey("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),vs=new C.PublicKey("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),$r=new C.PublicKey("CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"),ei=new C.PublicKey("7rQ1QFNosMkUCuh7Z7fPbTHvh73b68sQYdirycEzJVuw"),ti=new C.PublicKey("G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2");var Os={SERUM_MARKET:C.PublicKey.default,OPENBOOK_MARKET:new C.PublicKey("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),UTIL1216:C.PublicKey.default,FarmV3:new C.PublicKey("85BFyr98MbCUU9MVTEgzx1nbhWACbJqLzho6zd6DZcWL"),FarmV5:new C.PublicKey("EcLzTrNg9V7qhcdyXDe2qjtPkiGzDM2UbdRaeaadU5r2"),FarmV6:new C.PublicKey("Farm2hJLcqPtPg8M4rR6DMrsRNc5TPm5Cs4bVQrMe2T7"),AmmV4:new C.PublicKey("HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8"),AmmStable:new C.PublicKey("DDg4VmQaJV9ogWce7LpcjBA9bv22wRp5uaTPa5pGjijF"),CLMM:new C.PublicKey("devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH"),Router:new C.PublicKey("BVChZ3XFEwTMUk1o9i3HAf91H6mFxSwa5X2wFAWhYPhU"),CREATE_CPMM_POOL_PROGRAM:$r,CREATE_CPMM_POOL_AUTH:ei,CREATE_CPMM_POOL_FEE_ACC:ti,FEE_DESTINATION_ID:new C.PublicKey("3XMrhbv989VxAMi3DErLV9eJht1pHppW5LbKxe9fkEFR")};var ni=require("@solana/web3.js");var ri=require("@solana/spl-token");var ii=J(require("bn.js"));var Ct=z("Raydium_accountInfo_util");async function Cn(t,e,n){let{batchRequest:r,commitment:i="confirmed",chunkCount:o=100}=G({batchRequest:!1},n),s=kt(e,o),u=new Array(s.length).fill([]);if(r){let a=s.map(l=>{let p=t._buildArgs([l.map(d=>d.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:p}}),c=kt(a,10);u=(await(await Promise.all(c.map(async l=>await t._rpcBatchRequest(l)))).flat()).map(l=>(l.error&&Ct.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${l.error.message}`),l.result.value.map(p=>{if(p){let{data:d,executable:w,lamports:g,owner:T,rentEpoch:x}=p;return d.length!==2&&d[1]!=="base64"&&Ct.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(d[0],"base64"),executable:w,lamports:g,owner:new kn.PublicKey(T),rentEpoch:x}}return null})))}else try{u=await Promise.all(s.map(a=>t.getMultipleAccountsInfo(a,i)))}catch(a){a instanceof Error&&Ct.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${a.message}`)}return u.flat()}async function Nt({connection:t,address:e}){let n=await Cn(t,[...new Set(e.map(i=>i.toString()))].map(i=>new de.PublicKey(i))),r={};for(let i=0;i<e.length;i++){let o=n[i],s=e[i];if(!o)continue;let u=new de.AddressLookupTableAccount({key:s,state:de.AddressLookupTableAccount.deserialize(o.data)});r[s.toString()]=u,tt[s.toString()]=u}return r}var tt={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new de.AddressLookupTableAccount({key:new de.PublicKey("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:de.AddressLookupTableAccount.deserialize(Buffer.from("AQAAAP//////////d49+DAAAAAAAAQZMWvw7GUNJdaccNBVnb57OKakxL2BHLYvhRwVILRsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkG3fbh7nWP3hhCXbzkbM3athr8TYO5DSf+vfko2KGL/AVKU1D4XciC1hSlVnJ4iilt3x6rq9CmBniISTL07vagBqfVFxksXFEhjMlMPUrxf1ja7gibof1E49vZigAAAAAGp9UXGMd0yShWY5hpHV62i164o5tLbVxzVVshAAAAAIyXJY9OJInxuz0QKRSODYMLWhOZ2v8QhASOe9jb6fhZC3BlsePRfEU4nVJ/awTDzVi4bHMaoP21SbbRvAP4KUbIScv+6Yw2LHF/6K0ZjUPibbSWXCirYPGuuVl7zT789IUPLW4CpHr4JNCatp3ELXDLKMv6JJ+37le50lbBJ2LvDQdRqCgtphMF/imcN7mY5YRx2xE1A3MQ+L4QRaYK9u4GRfZP3LsAd00a+IkCpA22UNQMKdq5BFbJuwuOLqc8zxCTDlqxBG8J0HcxtfogQHDK06ukzfaXiNDKAob1MqBHS9lJxDYCwz8gd5DtFqNSTKG5l1zxIaKpDP/sffi2is1H9aKveyXSu5StXElYRl9SD5As0DHE4N0GLnf84/siiKXVyp4Ez121kLcUui/jLLFZEz/BwZK3Ilf9B9OcsEAeDMKAy2vjGSxQODgBz0QwGA+eP4ZjIjrIAQaXENv31QfLlOdXSRCkaybRniDHF4C8YcwhcvsqrOVuTP4B2Na+9wLdtrB31uz2rtlFI5kahdsnp/d1SrASDInYCtTYtdoke4kX+hoKWcEWM4Tle8pTUkUVv4BxS6fje/EzKBE4Qu9N9LMnrw/JNO0hqMVB4rk/2ou4AB1loQ7FZoPwut2o4KZB+0p9xnbrQKw038qjpHar+PyDwvxBRcu5hpHw3dguezeWv+IwvgW5icu8EGkhGa9AkFPPJT7VMSFb8xowveU=","base64"))})};var nt=class{constructor(e){this.instructions=[];this.endInstructions=[];this.lookupTableAddress=[];this.signers=[];this.instructionTypes=[];this.endInstru