UNPKG

test-raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 72.8 kB
var kn=Object.defineProperty,Cn=Object.defineProperties;var En=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable;var Kt=(t,e,n)=>e in t?kn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,O=(t,e)=>{for(var n in e||(e={}))vt.call(e,n)&&Kt(t,n,e[n]);if(Me)for(var n of Me(e))It.call(e,n)&&Kt(t,n,e[n]);return t},te=(t,e)=>Cn(t,En(e));var Ke=(t,e)=>{var n={};for(var r in t)vt.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Me)for(var r of Me(t))e.indexOf(r)<0&&It.call(t,r)&&(n[r]=t[r]);return n};import{PublicKey as Rt}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Nn}from"@solana/spl-token";import De from"bn.js";import{get as Ft,set as Dn}from"lodash";import Ot from"dayjs";import Rn from"dayjs/plugin/utc";Ot.extend(Rn);var ot=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 Ot().utc().format("YYYY/MM/DD HH:mm:ss UTC")}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}},_t={},Mn={};function V(t){let e=Ft(_t,t);if(!e){let n=Ft(Mn,t);e=new ot({name:t,logLevel:n}),Dn(_t,t,e)}return e}import{PublicKey as Ze,sendAndConfirmTransaction as xt,Transaction as Ne,TransactionMessage as ke,VersionedTransaction as Ce}from"@solana/web3.js";import jr from"axios";var G={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"};import{PublicKey as Ni,ComputeBudgetProgram as Vt,Transaction as Wt,TransactionMessage as Kn,Keypair as Ut,VersionedTransaction as vn}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as In}from"@solana/spl-token";var qt=V("Raydium_txUtil"),Gt=1644;function ve(t){let e=[],n=[];return t.microLamports&&(e.push(Vt.setComputeUnitPrice({microLamports:t.microLamports})),n.push(G.SetComputeUnitPrice)),t.units&&(e.push(Vt.setComputeUnitLimit({units:t.units})),n.push(G.SetComputeUnitLimit)),{instructions:e,instructionTypes:n}}async function me(t){var e,n;try{return((n=await((e=t.getLatestBlockhash)==null?void 0:e.call(t)))==null?void 0:n.blockhash)||(await t.getRecentBlockhash()).blockhash}catch{return(await t.getRecentBlockhash()).blockhash}}function Fn(t,e){t.length<1&&qt.logWithError(`no instructions provided: ${t.toString()}`),e.length<1&&qt.logWithError(`no signers provided:, ${e.toString()}`);let n=new Wt;n.recentBlockhash="11111111111111111111111111111111",n.feePayer=e[0],n.add(...t);try{return Buffer.from(n.serialize({verifySignatures:!1})).toString("base64").length<Gt}catch{return!1}}function Pe({instructions:t,payer:e,signers:n}){return Fn(t,[e,...n])}function Te({instructions:t,payer:e,lookupTableAddressAccount:n}){let i=new Kn({payerKey:e,recentBlockhash:Ut.generate().publicKey.toString(),instructions:t}).compileToV0Message(Object.values(n!=null?n:{}));try{return Buffer.from(i.serialize()).toString("base64").length<Gt}catch{return!1}}var _n=t=>Buffer.isBuffer(t)?t:t instanceof Uint8Array?Buffer.from(t.buffer,t.byteOffset,t.byteLength):Buffer.from(t);function le(t){let e=[];return t.forEach(n=>{n instanceof Wt&&(n.recentBlockhash||(n.recentBlockhash=In.toBase58()),n.feePayer||(n.feePayer=Ut.generate().publicKey));let r=n.serialize({requireAllSignatures:!1,verifySignatures:!1});n instanceof vn&&(r=_n(r));let i=r.toString("base64");e.push(i)}),console.log("simulate tx string:",e),e}import{PublicKey as hn,AddressLookupTableAccount as Ye}from"@solana/web3.js";import{PublicKey as Hr}from"@solana/web3.js";import{getTransferFeeConfig as Fu,unpackMint as _u}from"@solana/spl-token";import{PublicKey as Ks}from"@solana/web3.js";import Is from"bn.js";import zr from"big.js";import ms from"bn.js";import H from"bn.js";var ge=9e15,oe=1e9,st="0123456789abcdef",Fe="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",_e="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ut={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ge,maxE:ge,crypto:!1},Yt,ee,T=!0,Ve="[DecimalError] ",ie=Ve+"Invalid argument: ",Qt=Ve+"Precision limit exceeded",Zt=Ve+"crypto unavailable",Jt="[object Decimal]",q=Math.floor,v=Math.pow,On=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Vn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,qn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Xt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Z=1e7,P=7,Wn=9007199254740991,Un=Fe.length-1,at=_e.length-1,d={toStringTag:Jt};d.absoluteValue=d.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),x(t)};d.ceil=function(){return x(new this.constructor(this),this.e+1,2)};d.clampedTo=d.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(ie+e);return n=r.cmp(t),n<0?t:r.cmp(e)>0?e:new i(r)};d.comparedTo=d.cmp=function(t){var e,n,r,i,o=this,s=o.d,u=(t=new o.constructor(t)).d,c=o.s,a=t.s;if(!s||!u)return!c||!a?NaN:c!==a?c:s===u?0:!s^c<0?1:-1;if(!s[0]||!u[0])return s[0]?c:u[0]?-a:0;if(c!==a)return c;if(o.e!==t.e)return o.e>t.e^c<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]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1};d.cosine=d.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())+P,r.rounding=1,n=Gn(r,rn(r,n)),r.precision=t,r.rounding=e,x(ee==2||ee==3?n.neg():n,t,e,!0)):new r(1):new r(NaN)};d.cubeRoot=d.cbrt=function(){var t,e,n,r,i,o,s,u,c,a,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(T=!1,o=l.s*v(l.s*l,1/3),!o||Math.abs(o)==1/0?(n=I(l.d),t=l.e,(o=(t-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=v(n,1/3),t=q((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 f(n),r.s=l.s):r=new f(o.toString()),s=(t=f.precision)+3;;)if(u=r,c=u.times(u).times(u),a=c.plus(l),r=C(a.plus(l).times(u),a.plus(c),s+2,1),I(u.d).slice(0,s)===(n=I(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!i&&n=="4999"){if(!i&&(x(u,t+1,0),u.times(u).times(u).eq(l))){r=u;break}s+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(x(r,t+1,1),e=!r.times(r).times(r).eq(l));break}return T=!0,x(r,t,f.rounding,e)};d.decimalPlaces=d.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-q(this.e/P))*P,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};d.dividedBy=d.div=function(t){return C(this,new this.constructor(t))};d.dividedToIntegerBy=d.divToInt=function(t){var e=this,n=e.constructor;return x(C(e,new n(t),0,1,1),n.precision,n.rounding)};d.equals=d.eq=function(t){return this.cmp(t)===0};d.floor=function(){return x(new this.constructor(this),this.e+1,3)};d.greaterThan=d.gt=function(t){return this.cmp(t)>0};d.greaterThanOrEqualTo=d.gte=function(t){var e=this.cmp(t);return e==1||e===0};d.hyperbolicCosine=d.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/We(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=he(s,1,o.times(e),new s(1),!0);for(var c,a=t,l=new s(8);a--;)c=o.times(o),o=u.minus(c.times(l.minus(c.times(l))));return x(o,s.precision=n,s.rounding=r,!0)};d.hyperbolicSine=d.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=he(o,2,i,i,!0);else{t=1.4*Math.sqrt(r),t=t>16?16:t|0,i=i.times(1/We(5,t)),i=he(o,2,i,i,!0);for(var s,u=new o(5),c=new o(16),a=new o(20);t--;)s=i.times(i),i=i.times(u.plus(s.times(c.times(s).plus(a))))}return o.precision=e,o.rounding=n,x(i,e,n,!0)};d.hyperbolicTangent=d.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,C(n.sinh(),n.cosh(),r.precision=t,r.rounding=e)):new r(n.s)};d.inverseCosine=d.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()?Q(n,i,o):new n(0):new n(NaN):e.isZero()?Q(n,i+4,o).times(.5):(n.precision=i+6,n.rounding=1,e=e.asin(),t=Q(n,i+4,o).times(.5),n.precision=i,n.rounding=o,t.minus(e))};d.inverseHyperbolicCosine=d.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,T=!1,n=n.times(n).minus(1).sqrt().plus(n),T=!0,r.precision=t,r.rounding=e,n.ln()):new r(n)};d.inverseHyperbolicSine=d.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,T=!1,n=n.times(n).plus(1).sqrt().plus(n),T=!0,r.precision=t,r.rounding=e,n.ln())};d.inverseHyperbolicTangent=d.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?x(new o(i),t,e,!0):(o.precision=n=r-i.e,i=C(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)};d.inverseSine=d.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=Q(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)))};d.inverseTangent=d.atan=function(){var t,e,n,r,i,o,s,u,c,a=this,l=a.constructor,f=l.precision,p=l.rounding;if(a.isFinite()){if(a.isZero())return new l(a);if(a.abs().eq(1)&&f+4<=at)return s=Q(l,f+4,p).times(.25),s.s=a.s,s}else{if(!a.s)return new l(NaN);if(f+4<=at)return s=Q(l,f+4,p).times(.5),s.s=a.s,s}for(l.precision=u=f+10,l.rounding=1,n=Math.min(28,u/P+2|0),t=n;t;--t)a=a.div(a.times(a).plus(1).sqrt().plus(1));for(T=!1,e=Math.ceil(u/P),r=1,c=a.times(a),s=new l(a),i=a;t!==-1;)if(i=i.times(c),o=s.minus(i.div(r+=2)),i=i.times(c),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)),T=!0,x(s,l.precision=f,l.rounding=p,!0)};d.isFinite=function(){return!!this.d};d.isInteger=d.isInt=function(){return!!this.d&&q(this.e/P)>this.d.length-2};d.isNaN=function(){return!this.s};d.isNegative=d.isNeg=function(){return this.s<0};d.isPositive=d.isPos=function(){return this.s>0};d.isZero=function(){return!!this.d&&this.d[0]===0};d.lessThan=d.lt=function(t){return this.cmp(t)<0};d.lessThanOrEqualTo=d.lte=function(t){return this.cmp(t)<1};d.logarithm=d.log=function(t){var e,n,r,i,o,s,u,c,a=this,l=a.constructor,f=l.precision,p=l.rounding,g=5;if(t==null)t=new l(10),e=!0;else{if(t=new l(t),n=t.d,t.s<0||!n||!n[0]||t.eq(1))return new l(NaN);e=t.eq(10)}if(n=a.d,a.s<0||!n||!n[0]||a.eq(1))return new l(n&&!n[0]?-1/0:a.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(T=!1,u=f+g,s=re(a,u),r=e?Oe(l,u+10):re(t,u),c=C(s,r,u,1),Ae(c.d,i=f,p))do if(u+=10,s=re(a,u),r=e?Oe(l,u+10):re(t,u),c=C(s,r,u,1),!o){+I(c.d).slice(i+1,i+15)+1==1e14&&(c=x(c,f+1,0));break}while(Ae(c.d,i+=10,p));return T=!0,x(c,f,p)};d.minus=d.sub=function(t){var e,n,r,i,o,s,u,c,a,l,f,p,g=this,b=g.constructor;if(t=new b(t),!g.d||!t.d)return!g.s||!t.s?t=new b(NaN):g.d?t.s=-t.s:t=new b(t.d||g.s!==t.s?g:NaN),t;if(g.s!=t.s)return t.s=-t.s,g.plus(t);if(a=g.d,p=t.d,u=b.precision,c=b.rounding,!a[0]||!p[0]){if(p[0])t.s=-t.s;else if(a[0])t=new b(g);else return new b(c===3?-0:0);return T?x(t,u,c):t}if(n=q(t.e/P),l=q(g.e/P),a=a.slice(),o=l-n,o){for(f=o<0,f?(e=a,o=-o,s=p.length):(e=p,n=l,s=a.length),r=Math.max(Math.ceil(u/P),s)+2,o>r&&(o=r,e.length=1),e.reverse(),r=o;r--;)e.push(0);e.reverse()}else{for(r=a.length,s=p.length,f=r<s,f&&(s=r),r=0;r<s;r++)if(a[r]!=p[r]){f=a[r]<p[r];break}o=0}for(f&&(e=a,a=p,p=e,t.s=-t.s),s=a.length,r=p.length-s;r>0;--r)a[s++]=0;for(r=p.length;r>o;){if(a[--r]<p[r]){for(i=r;i&&a[--i]===0;)a[i]=Z-1;--a[i],a[r]+=Z}a[r]-=p[r]}for(;a[--s]===0;)a.pop();for(;a[0]===0;a.shift())--n;return a[0]?(t.d=a,t.e=qe(a,n),T?x(t,u,c):t):new b(c===3?-0:0)};d.modulo=d.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]?x(new r(n),r.precision,r.rounding):(T=!1,r.modulo==9?(e=C(n,t.abs(),0,3,1),e.s*=t.s):e=C(n,t,0,r.modulo,1),e=e.times(t),T=!0,n.minus(e))};d.naturalExponential=d.exp=function(){return ct(this)};d.naturalLogarithm=d.ln=function(){return re(this)};d.negated=d.neg=function(){var t=new this.constructor(this);return t.s=-t.s,x(t)};d.plus=d.add=function(t){var e,n,r,i,o,s,u,c,a,l,f=this,p=f.constructor;if(t=new p(t),!f.d||!t.d)return!f.s||!t.s?t=new p(NaN):f.d||(t=new p(t.d||f.s===t.s?f:NaN)),t;if(f.s!=t.s)return t.s=-t.s,f.minus(t);if(a=f.d,l=t.d,u=p.precision,c=p.rounding,!a[0]||!l[0])return l[0]||(t=new p(f)),T?x(t,u,c):t;if(o=q(f.e/P),r=q(t.e/P),a=a.slice(),i=o-r,i){for(i<0?(n=a,i=-i,s=l.length):(n=l,r=o,s=a.length),o=Math.ceil(u/P),s=o>s?o+1:s+1,i>s&&(i=s,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(s=a.length,i=l.length,s-i<0&&(i=s,n=l,l=a,a=n),e=0;i;)e=(a[--i]=a[i]+l[i]+e)/Z|0,a[i]%=Z;for(e&&(a.unshift(e),++r),s=a.length;a[--s]==0;)a.pop();return t.d=a,t.e=qe(a,r),T?x(t,u,c):t};d.precision=d.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(ie+t);return n.d?(e=$t(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};d.round=function(){var t=this,e=t.constructor;return x(new e(t),t.e+1,e.rounding)};d.sine=d.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())+P,r.rounding=1,n=Hn(r,rn(r,n)),r.precision=t,r.rounding=e,x(ee>2?n.neg():n,t,e,!0)):new r(NaN)};d.squareRoot=d.sqrt=function(){var t,e,n,r,i,o,s=this,u=s.d,c=s.e,a=s.s,l=s.constructor;if(a!==1||!u||!u[0])return new l(!a||a<0&&(!u||u[0])?NaN:u?s:1/0);for(T=!1,a=Math.sqrt(+s),a==0||a==1/0?(e=I(u),(e.length+c)%2==0&&(e+="0"),a=Math.sqrt(e),c=q((c+1)/2)-(c<0||c%2),a==1/0?e="5e"+c:(e=a.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),r=new l(e)):r=new l(a.toString()),n=(c=l.precision)+3;;)if(o=r,r=o.plus(C(s,o,n+2,1)).times(.5),I(o.d).slice(0,n)===(e=I(r.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!i&&e=="4999"){if(!i&&(x(o,c+1,0),o.times(o).eq(s))){r=o;break}n+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(x(r,c+1,1),t=!r.times(r).eq(s));break}return T=!0,x(r,c,l.rounding,t)};d.tangent=d.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=C(n,new r(1).minus(n.times(n)).sqrt(),t+10,0),r.precision=t,r.rounding=e,x(ee==2||ee==4?n.neg():n,t,e,!0)):new r(NaN)};d.times=d.mul=function(t){var e,n,r,i,o,s,u,c,a,l=this,f=l.constructor,p=l.d,g=(t=new f(t)).d;if(t.s*=l.s,!p||!p[0]||!g||!g[0])return new f(!t.s||p&&!p[0]&&!g||g&&!g[0]&&!p?NaN:!p||!g?t.s/0:t.s*0);for(n=q(l.e/P)+q(t.e/P),c=p.length,a=g.length,c<a&&(o=p,p=g,g=o,s=c,c=a,a=s),o=[],s=c+a,r=s;r--;)o.push(0);for(r=a;--r>=0;){for(e=0,i=c+r;i>r;)u=o[i]+g[r]*p[i-r-1]+e,o[i--]=u%Z|0,e=u/Z|0;o[i]=(o[i]+e)%Z|0}for(;!o[--s];)o.pop();return e?++n:o.shift(),t.d=o,t.e=qe(o,n),T?x(t,f.precision,f.rounding):t};d.toBinary=function(t,e){return ft(this,2,t,e)};d.toDecimalPlaces=d.toDP=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(z(t,0,oe),e===void 0?e=r.rounding:z(e,0,8),x(n,t+n.e+1,e))};d.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=$(r,!0):(z(t,0,oe),e===void 0?e=i.rounding:z(e,0,8),r=x(new i(r),t+1,e),n=$(r,!0,t+1)),r.isNeg()&&!r.isZero()?"-"+n:n};d.toFixed=function(t,e){var n,r,i=this,o=i.constructor;return t===void 0?n=$(i):(z(t,0,oe),e===void 0?e=o.rounding:z(e,0,8),r=x(new o(i),t+i.e+1,e),n=$(r,!1,t+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n};d.toFraction=function(t){var e,n,r,i,o,s,u,c,a,l,f,p,g=this,b=g.d,m=g.constructor;if(!b)return new m(g);if(a=n=new m(1),r=c=new m(0),e=new m(r),o=e.e=$t(b)-g.e-1,s=o%P,e.d[0]=v(10,s<0?P+s:s),t==null)t=o>0?e:a;else{if(u=new m(t),!u.isInt()||u.lt(a))throw Error(ie+u);t=u.gt(e)?o>0?e:a:u}for(T=!1,u=new m(I(b)),l=m.precision,m.precision=o=b.length*P*2;f=C(u,e,0,1,1),i=n.plus(f.times(r)),i.cmp(t)!=1;)n=r,r=i,i=a,a=c.plus(f.times(i)),c=i,i=e,e=u.minus(f.times(i)),u=i;return i=C(t.minus(n),r,0,1,1),c=c.plus(i.times(a)),n=n.plus(i.times(r)),c.s=a.s=g.s,p=C(a,r,o,1).minus(g).abs().cmp(C(c,n,o,1).minus(g).abs())<1?[a,r]:[c,n],m.precision=l,T=!0,p};d.toHexadecimal=d.toHex=function(t,e){return ft(this,16,t,e)};d.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:z(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]?(T=!1,n=C(n,t,0,e,1).times(t),T=!0,x(n)):(t.s=n.s,n=t),n};d.toNumber=function(){return+this};d.toOctal=function(t,e){return ft(this,8,t,e)};d.toPower=d.pow=function(t){var e,n,r,i,o,s,u=this,c=u.constructor,a=+(t=new c(t));if(!u.d||!t.d||!u.d[0]||!t.d[0])return new c(v(+u,a));if(u=new c(u),u.eq(1))return u;if(r=c.precision,o=c.rounding,t.eq(1))return x(u,r,o);if(e=q(t.e/P),e>=t.d.length-1&&(n=a<0?-a:a)<=Wn)return i=en(c,u,n,r),t.s<0?new c(1).div(i):x(i,r,o);if(s=u.s,s<0){if(e<t.d.length-1)return new c(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=v(+u,a),e=n==0||!isFinite(n)?q(a*(Math.log("0."+I(u.d))/Math.LN10+u.e+1)):new c(n+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(T=!1,c.rounding=u.s=1,n=Math.min(12,(e+"").length),i=ct(t.times(re(u,r+n)),r),i.d&&(i=x(i,r+5,1),Ae(i.d,r,o)&&(e=r+10,i=x(ct(t.times(re(u,e+n)),e),e+5,1),+I(i.d).slice(r+1,r+15)+1==1e14&&(i=x(i,r+1,0)))),i.s=s,T=!0,c.rounding=o,x(i,r,o))};d.toPrecision=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=$(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(z(t,1,oe),e===void 0?e=i.rounding:z(e,0,8),r=x(new i(r),t,e),n=$(r,t<=r.e||r.e<=i.toExpNeg,t)),r.isNeg()&&!r.isZero()?"-"+n:n};d.toSignificantDigits=d.toSD=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(z(t,1,oe),e===void 0?e=r.rounding:z(e,0,8)),x(new r(n),t,e)};d.toString=function(){var t=this,e=t.constructor,n=$(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};d.truncated=d.trunc=function(){return x(new this.constructor(this),this.e+1,1)};d.valueOf=d.toJSON=function(){var t=this,e=t.constructor,n=$(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function I(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=P-r.length,n&&(o+=ne(n)),o+=r;s=t[e],r=s+"",n=P-r.length,n&&(o+=ne(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function z(t,e,n){if(t!==~~t||t<e||t>n)throw Error(ie+t)}function Ae(t,e,n,r){var i,o,s,u;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=P,i=0):(i=Math.ceil((e+1)/P),e%=P),o=v(10,P-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)==v(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)==v(10,e-3)-1,s}function Ie(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]+=st.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 Gn(t,e){var n,r,i;if(e.isZero())return e;r=e.d.length,r<32?(n=Math.ceil(r/3),i=(1/We(4,n)).toString()):(n=16,i="2.3283064365386962890625e-10"),t.precision+=n,e=he(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 C=function(){function t(r,i,o){var s,u=0,c=r.length;for(r=r.slice();c--;)s=r[c]*i+u,r[c]=s%o|0,u=s/o|0;return u&&r.unshift(u),r}function e(r,i,o,s){var u,c;if(o!=s)c=o>s?1:-1;else for(u=c=0;u<o;u++)if(r[u]!=i[u]){c=r[u]>i[u]?1:-1;break}return c}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,c){var a,l,f,p,g,b,m,w,h,A,y,N,L,k,F,Y,M,X,U,de,Re=r.constructor,it=r.s==i.s?1:-1,_=r.d,E=i.d;if(!_||!_[0]||!E||!E[0])return new Re(!r.s||!i.s||(_?E&&_[0]==E[0]:!E)?NaN:_&&_[0]==0||!E?it*0:it/0);for(c?(g=1,l=r.e-i.e):(c=Z,g=P,l=q(r.e/g)-q(i.e/g)),U=E.length,M=_.length,h=new Re(it),A=h.d=[],f=0;E[f]==(_[f]||0);f++);if(E[f]>(_[f]||0)&&l--,o==null?(k=o=Re.precision,s=Re.rounding):u?k=o+(r.e-i.e)+1:k=o,k<0)A.push(1),b=!0;else{if(k=k/g+2|0,f=0,U==1){for(p=0,E=E[0],k++;(f<M||p)&&k--;f++)F=p*c+(_[f]||0),A[f]=F/E|0,p=F%E|0;b=p||f<M}else{for(p=c/(E[0]+1)|0,p>1&&(E=t(E,p,c),_=t(_,p,c),U=E.length,M=_.length),Y=U,y=_.slice(0,U),N=y.length;N<U;)y[N++]=0;de=E.slice(),de.unshift(0),X=E[0],E[1]>=c/2&&++X;do p=0,a=e(E,y,U,N),a<0?(L=y[0],U!=N&&(L=L*c+(y[1]||0)),p=L/X|0,p>1?(p>=c&&(p=c-1),m=t(E,p,c),w=m.length,N=y.length,a=e(m,y,w,N),a==1&&(p--,n(m,U<w?de:E,w,c))):(p==0&&(a=p=1),m=E.slice()),w=m.length,w<N&&m.unshift(0),n(y,m,N,c),a==-1&&(N=y.length,a=e(E,y,U,N),a<1&&(p++,n(y,U<N?de:E,N,c))),N=y.length):a===0&&(p++,y=[0]),A[f++]=p,a&&y[0]?y[N++]=_[Y]||0:(y=[_[Y]],N=1);while((Y++<M||y[0]!==void 0)&&k--);b=y[0]!==void 0}A[0]||A.shift()}if(g==1)h.e=l,Yt=b;else{for(f=1,p=A[0];p>=10;p/=10)f++;h.e=f+l*g-1,x(h,u?o+h.e+1:o,s,b)}return h}}();function x(t,e,n,r){var i,o,s,u,c,a,l,f,p,g=t.constructor;e:if(e!=null){if(f=t.d,!f)return t;for(i=1,u=f[0];u>=10;u/=10)i++;if(o=e-i,o<0)o+=P,s=e,l=f[p=0],c=l/v(10,i-s-1)%10|0;else if(p=Math.ceil((o+1)/P),u=f.length,p>=u)if(r){for(;u++<=p;)f.push(0);l=c=0,i=1,o%=P,s=o-P+1}else break e;else{for(l=u=f[p],i=1;u>=10;u/=10)i++;o%=P,s=o-P+i,c=s<0?0:l/v(10,i-s-1)%10|0}if(r=r||e<0||f[p+1]!==void 0||(s<0?l:l%v(10,i-s-1)),a=n<4?(c||r)&&(n==0||n==(t.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(o>0?s>0?l/v(10,i-s):0:f[p-1])%10&1||n==(t.s<0?8:7)),e<1||!f[0])return f.length=0,a?(e-=t.e+1,f[0]=v(10,(P-e%P)%P),t.e=-e||0):f[0]=t.e=0,t;if(o==0?(f.length=p,u=1,p--):(f.length=p+1,u=v(10,P-o),f[p]=s>0?(l/v(10,i-s)%v(10,s)|0)*u:0),a)for(;;)if(p==0){for(o=1,s=f[0];s>=10;s/=10)o++;for(s=f[0]+=u,u=1;s>=10;s/=10)u++;o!=u&&(t.e++,f[0]==Z&&(f[0]=1));break}else{if(f[p]+=u,f[p]!=Z)break;f[p--]=0,u=1}for(o=f.length;f[--o]===0;)f.pop()}return T&&(t.e>g.maxE?(t.d=null,t.e=NaN):t.e<g.minE&&(t.e=0,t.d=[0])),t}function $(t,e,n){if(!t.isFinite())return nn(t);var r,i=t.e,o=I(t.d),s=o.length;return e?(n&&(r=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+ne(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):i<0?(o="0."+ne(-i-1)+o,n&&(r=n-s)>0&&(o+=ne(r))):i>=s?(o+=ne(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+ne(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(o+="."),o+=ne(r))),o}function qe(t,e){var n=t[0];for(e*=P;n>=10;n/=10)e++;return e}function Oe(t,e,n){if(e>Un)throw T=!0,n&&(t.precision=n),Error(Qt);return x(new t(Fe),e,1,!0)}function Q(t,e,n){if(e>at)throw Error(Qt);return x(new t(_e),e,n,!0)}function $t(t){var e=t.length-1,n=e*P+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 ne(t){for(var e="";t--;)e+="0";return e}function en(t,e,n,r){var i,o=new t(1),s=Math.ceil(r/P+4);for(T=!1;;){if(n%2&&(o=o.times(e),Ht(o.d,s)&&(i=!0)),n=q(n/2),n===0){n=o.d.length-1,i&&o.d[n]===0&&++o.d[n];break}e=e.times(e),Ht(e.d,s)}return T=!0,o}function zt(t){return t.d[t.d.length-1]&1}function tn(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 ct(t,e){var n,r,i,o,s,u,c,a=0,l=0,f=0,p=t.constructor,g=p.rounding,b=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?(T=!1,c=b):c=e,u=new p(.03125);t.e>-2;)t=t.times(u),f+=5;for(r=Math.log(v(2,f))/Math.LN10*2+5|0,c+=r,n=o=s=new p(1),p.precision=c;;){if(o=x(o.times(t),c,1),n=n.times(++l),u=s.plus(C(o,n,c,1)),I(u.d).slice(0,c)===I(s.d).slice(0,c)){for(i=f;i--;)s=x(s.times(s),c,1);if(e==null)if(a<3&&Ae(s.d,c-r,g,a))p.precision=c+=10,n=o=u=new p(1),l=0,a++;else return x(s,p.precision=b,g,T=!0);else return p.precision=b,s}s=u}}function re(t,e){var n,r,i,o,s,u,c,a,l,f,p,g=1,b=10,m=t,w=m.d,h=m.constructor,A=h.rounding,y=h.precision;if(m.s<0||!w||!w[0]||!m.e&&w[0]==1&&w.length==1)return new h(w&&!w[0]?-1/0:m.s!=1?NaN:w?0:m);if(e==null?(T=!1,l=y):l=e,h.precision=l+=b,n=I(w),r=n.charAt(0),Math.abs(o=m.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=I(m.d),r=n.charAt(0),g++;o=m.e,r>1?(m=new h("0."+n),o++):m=new h(r+"."+n.slice(1))}else return a=Oe(h,l+2,y).times(o+""),m=re(new h(r+"."+n.slice(1)),l-b).plus(a),h.precision=y,e==null?x(m,y,A,T=!0):m;for(f=m,c=s=m=C(m.minus(1),m.plus(1),l,1),p=x(m.times(m),l,1),i=3;;){if(s=x(s.times(p),l,1),a=c.plus(C(s,new h(i),l,1)),I(a.d).slice(0,l)===I(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(Oe(h,l+2,y).times(o+""))),c=C(c,new h(g),l,1),e==null)if(Ae(c.d,l-b,A,u))h.precision=l+=b,a=s=m=C(f.minus(1),f.plus(1),l,1),p=x(m.times(m),l,1),i=u=1;else return x(c,h.precision=y,A,T=!0);else return h.precision=y,c;c=a,i+=2}}function nn(t){return String(t.s*t.s/0)}function lt(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)%P,n<0&&(r+=P),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=P;r<i;)t.d.push(+e.slice(r,r+=P));e=e.slice(r),r=P-e.length}else r-=i;for(;r--;)e+="0";t.d.push(+e),T&&(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 zn(t,e){var n,r,i,o,s,u,c,a,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Xt.test(e))return lt(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(Vn.test(e))n=16,e=e.toLowerCase();else if(On.test(e))n=2;else if(qn.test(e))n=8;else throw Error(ie+e);for(o=e.search(/p/i),o>0?(c=+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=en(r,new r(n),o,o*2)),a=Ie(e,n,Z),l=a.length-1,o=l;a[o]===0;--o)a.pop();return o<0?new r(t.s*0):(t.e=qe(a,l),t.d=a,T=!1,s&&(t=C(t,i,u*4)),c&&(t=t.times(Math.abs(c)<54?v(2,c):Ue.pow(2,c))),T=!0,t)}function Hn(t,e){var n,r=e.d.length;if(r<3)return e.isZero()?e:he(t,2,e,e);n=1.4*Math.sqrt(r),n=n>16?16:n|0,e=e.times(1/We(5,n)),e=he(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 he(t,e,n,r,i){var o,s,u,c,a=1,l=t.precision,f=Math.ceil(l/P);for(T=!1,c=n.times(n),u=new t(r);;){if(s=C(u.times(c),new t(e++*e++),l,1),u=i?r.plus(s):r.minus(s),r=C(s.times(c),new t(e++*e++),l,1),s=u.plus(r),s.d[f]!==void 0){for(o=f;s.d[o]===u.d[o]&&o--;);if(o==-1)break}o=u,u=r,r=s,s=o,a++}return T=!0,s.d.length=f+1,s}function We(t,e){for(var n=t;--e;)n*=t;return n}function rn(t,e){var n,r=e.s<0,i=Q(t,t.precision,1),o=i.times(.5);if(e=e.abs(),e.lte(o))return ee=r?4:1,e;if(n=e.divToInt(i),n.isZero())ee=r?3:2;else{if(e=e.minus(n.times(i)),e.lte(o))return ee=zt(n)?r?2:3:r?4:1,e;ee=zt(n)?r?1:4:r?3:2}return e.minus(i).abs()}function ft(t,e,n,r){var i,o,s,u,c,a,l,f,p,g=t.constructor,b=n!==void 0;if(b?(z(n,1,oe),r===void 0?r=g.rounding:z(r,0,8)):(n=g.precision,r=g.rounding),!t.isFinite())l=nn(t);else{for(l=$(t),s=l.indexOf("."),b?(i=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):i=e,s>=0&&(l=l.replace(".",""),p=new g(1),p.e=l.length-s,p.d=Ie($(p),10,i),p.e=p.d.length),f=Ie(l,10,i),o=c=f.length;f[--c]==0;)f.pop();if(!f[0])l=b?"0p+0":"0";else{if(s<0?o--:(t=new g(t),t.d=f,t.e=o,t=C(t,p,n,r,0,i),f=t.d,o=t.e,a=Yt),s=f[n],u=i/2,a=a||f[n+1]!==void 0,a=r<4?(s!==void 0||a)&&(r===0||r===(t.s<0?3:2)):s>u||s===u&&(r===4||a||r===6&&f[n-1]&1||r===(t.s<0?8:7)),f.length=n,a)for(;++f[--n]>i-1;)f[n]=0,n||(++o,f.unshift(1));for(c=f.length;!f[c-1];--c);for(s=0,l="";s<c;s++)l+=st.charAt(f[s]);if(b){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(f=Ie(l,i,e),c=f.length;!f[c-1];--c);for(s=1,l="1.";s<c;s++)l+=st.charAt(f[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>c)for(o-=c;o--;)l+="0";else o<c&&(l=l.slice(0,o)+"."+l.slice(o))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return t.s<0?"-"+l:l}function Ht(t,e){if(t.length>e)return t.length=e,!0}function jn(t){return new this(t).abs()}function Yn(t){return new this(t).acos()}function Qn(t){return new this(t).acosh()}function Zn(t,e){return new this(t).plus(e)}function Jn(t){return new this(t).asin()}function Xn(t){return new this(t).asinh()}function $n(t){return new this(t).atan()}function er(t){return new this(t).atanh()}function tr(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=Q(this,o,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?Q(this,r,i):new this(0),n.s=t.s):!t.d||e.isZero()?(n=Q(this,o,1).times(.5),n.s=t.s):e.s<0?(this.precision=o,this.rounding=1,n=this.atan(C(t,e,o,1)),e=Q(this,o,1),this.precision=r,this.rounding=i,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(C(t,e,o,1)),n}function nr(t){return new this(t).cbrt()}function rr(t){return x(t=new this(t),t.e+1,2)}function ir(t,e,n){return new this(t).clamp(e,n)}function or(t){if(!t||typeof t!="object")throw Error(Ve+"Object expected");var e,n,r,i=t.defaults===!0,o=["precision",1,oe,"rounding",0,8,"toExpNeg",-ge,0,"toExpPos",0,ge,"maxE",0,ge,"minE",-ge,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(n=o[e],i&&(this[n]=ut[n]),(r=t[n])!==void 0)if(q(r)===r&&r>=o[e+1]&&r<=o[e+2])this[n]=r;else throw Error(ie+n+": "+r);if(n="crypto",i&&(this[n]=ut[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(Zt);else this[n]=!1;else throw Error(ie+n+": "+r);return this}function sr(t){return new this(t).cos()}function ur(t){return new this(t).cosh()}function on(t){var e,n,r;function i(o){var s,u,c,a=this;if(!(a instanceof i))return new i(o);if(a.constructor=i,jt(o)){a.s=o.s,T?!o.d||o.e>i.maxE?(a.e=NaN,a.d=null):o.e<i.minE?(a.e=0,a.d=[0]):(a.e=o.e,a.d=o.d.slice()):(a.e=o.e,a.d=o.d?o.d.slice():o.d);return}if(c=typeof o,c==="number"){if(o===0){a.s=1/o<0?-1:1,a.e=0,a.d=[0];return}if(o<0?(o=-o,a.s=-1):a.s=1,o===~~o&&o<1e7){for(s=0,u=o;u>=10;u/=10)s++;T?s>i.maxE?(a.e=NaN,a.d=null):s<i.minE?(a.e=0,a.d=[0]):(a.e=s,a.d=[o]):(a.e=s,a.d=[o]);return}else if(o*0!==0){o||(a.s=NaN),a.e=NaN,a.d=null;return}return lt(a,o.toString())}else if(c!=="string")throw Error(ie+o);return(u=o.charCodeAt(0))===45?(o=o.slice(1),a.s=-1):(u===43&&(o=o.slice(1)),a.s=1),Xt.test(o)?lt(a,o):zn(a,o)}if(i.prototype=d,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=or,i.clone=on,i.isDecimal=jt,i.abs=jn,i.acos=Yn,i.acosh=Qn,i.add=Zn,i.asin=Jn,i.asinh=Xn,i.atan=$n,i.atanh=er,i.atan2=tr,i.cbrt=nr,i.ceil=rr,i.clamp=ir,i.cos=sr,i.cosh=ur,i.div=ar,i.exp=cr,i.floor=lr,i.hypot=fr,i.ln=pr,i.log=dr,i.log10=gr,i.log2=mr,i.max=hr,i.min=br,i.mod=yr,i.mul=wr,i.pow=xr,i.random=Pr,i.round=Tr,i.sign=Ar,i.sin=Sr,i.sinh=Br,i.sqrt=Lr,i.sub=Nr,i.sum=kr,i.tan=Cr,i.tanh=Er,i.trunc=Dr,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 ar(t,e){return new this(t).div(e)}function cr(t){return new this(t).exp()}function lr(t){return x(t=new this(t),t.e+1,3)}function fr(){var t,e,n=new this(0);for(T=!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 T=!0,new this(1/0);n=e}return T=!0,n.sqrt()}function jt(t){return t instanceof Ue||t&&t.toStringTag===Jt||!1}function pr(t){return new this(t).ln()}function dr(t,e){return new this(t).log(e)}function mr(t){return new this(t).log(2)}function gr(t){return new this(t).log(10)}function hr(){return tn(this,arguments,"lt")}function br(){return tn(this,arguments,"gt")}function yr(t,e){return new this(t).mod(e)}function wr(t,e){return new this(t).mul(e)}function xr(t,e){return new this(t).pow(e)}function Pr(t){var e,n,r,i,o=0,s=new this(1),u=[];if(t===void 0?t=this.precision:z(t,1,oe),r=Math.ceil(t/P),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(Zt);else for(;o<r;)u[o++]=Math.random()*1e7|0;for(r=u[--o],t%=P,r&&t&&(i=v(10,P-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-=P)u.shift();for(r=1,i=u[0];i>=10;i/=10)r++;r<P&&(n-=P-r)}return s.e=n,s.d=u,s}function Tr(t){return x(t=new this(t),t.e+1,this.rounding)}function Ar(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function Sr(t){return new this(t).sin()}function Br(t){return new this(t).sinh()}function Lr(t){return new this(t).sqrt()}function Nr(t,e){return new this(t).sub(e)}function kr(){var t=0,e=arguments,n=new this(e[t]);for(T=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return T=!0,x(n,this.precision,this.rounding)}function Cr(t){return new this(t).tan()}function Er(t){return new this(t).tanh()}function Dr(t){return x(t=new this(t),t.e+1,1)}d[Symbol.for("nodejs.util.inspect.custom")]=d.toString;d[Symbol.toStringTag]="Decimal";var Ue=d.constructor=on(ut);Fe=new Ue(Fe);_e=new Ue(_e);import{PublicKey as dt}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Rr}from"@solana/spl-token";import{PublicKey as R,SystemProgram as Mr,SYSVAR_RENT_PUBKEY as Kr}from"@solana/web3.js";function pt({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var Oi=[pt({pubkey:Rr,isWritable:!1}),pt({pubkey:Mr.programId,isWritable:!1}),pt({pubkey:Kr,isWritable:!1})];function un({publicKey:t,transformSol:e}){let n=an(t.toString());if(n instanceof R)return e&&n.equals(Se)?sn:n;if(e&&n.toString()===Se.toBase58())return sn;if(typeof n=="string"){if(n===R.default.toBase58())return R.default;try{return new R(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function an(t){try{return new R(t)}catch{return t}}var Vi=new R("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),qi=new R("SysvarRent111111111111111111111111111111111"),Wi=new R("SysvarC1ock11111111111111111111111111111111"),Ui=new R("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Gi=new R("Sysvar1nstructions1111111111111111111111111"),zi=new R("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Hi=new R("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),ji=new R("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Yi=new R("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Qi=new R("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Zi=new R("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Ji=new R("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Xi=new R("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),$i=new R("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),eo=new R("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),to=new R("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),sn=new R("So11111111111111111111111111111111111111112"),Se=R.default;import{PublicKey as vr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as cn}from"@solana/spl-token";var ln={chainId:101,address:vr.default.toBase58(),programId:cn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},fe={chainId:101,address:"So11111111111111111111111111111111111111112",programId:cn.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 mt=class{constructor({mint:e,decimals:n,symbol:r,name:i,skipMint:o=!1,isToken2022:s=!1}){if(e===Se.toBase58()||e instanceof dt&&Se.equals(e)){this.decimals=fe.decimals,this.symbol=fe.symbol,this.name=fe.name,this.mint=new dt(fe.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?dt.default:un({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},be=mt;be.WSOL=new mt(te(O({},fe),{mint:fe.address}));import ze from"big.js";import _r from"bn.js";import Or from"decimal.js-light";import Ir from"toformat";var Fr=Ir,Be=Fr;var Ge=V("module/fraction"),gt=Be(ze),Le=Be(Or),Vr={[0]:Le.ROUND_DOWN,[1]:Le.ROUND_HALF_UP,[2]:Le.ROUND_UP},qr={[0]:ze.roundDown,[1]:ze.roundHalfUp,[2]:ze.roundUp},D=class{constructor(e,n=new _r(1)){this.numerator=se(e),this.denominator=se(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new D(this.denominator,this.numerator)}add(e){let n=e instanceof D?e:new D(se(e));return this.denominator.eq(n.denominator)?new D(this.numerator.add(n.numerator),this.denominator):new D(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof D?e:new D(se(e));return this.denominator.eq(n.denominator)?new D(this.numerator.sub(n.numerator),this.denominator):new D(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof D?e:new D(se(e));return new D(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof D?e:new D(se(e));return new D(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},r=1){Number.isInteger(e)||Ge.logWithError(`${e} is not an integer.`),e<=0&&Ge.logWithError(`${e} is not positive.`),Le.set({precision:e+1,rounding:Vr[r]});let i=new Le(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)||Ge.logWithError(`${e} is not an integer.`),e<0&&Ge.logWithError(`${e} is negative.`),gt.DP=e,gt.RM=qr[r]||1,new gt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var ko=V("Raydium_price");var ht=class{constructor({decimals:e,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=r}equals(e){return this===e}},He=ht;He.SOL=new ht(ln);import Ur from"bn.js";var Io=new D(new Ur(100));var je=new H(0),ns=new H(1),rs=new H(2),is=new H(3),os=new H(5),Gr=new H(10),ss=new H(100),us=new H(1e3),as=new H(1e4),mn=9007199254740991;function se(t){let e=V("Raydium_parseBigNumberish");if(t instanceof H)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new H(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=mn||t<=-mn)&&e.logWithError(`BigNumberish number overflow: ${t}`),new H(String(t))):typeof t=="bigint"?new H(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new H(0))}var Ts=V("Raydium_amount"),As=Be(zr);function bt(t,e=1,n=[]){let r=[...t];if(e<=0)return n;for(;r.length;)n.push(r.splice(0,e));return n}import{PublicKey as j}from"@solana/web3.js";var Gs=new j("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),zs=new j("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Hs=new j("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),js=new j("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Ys=new j("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Qs=new j("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Zs=new j("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Js=new j("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Xs=new j("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),$s=new j("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),eu=new j("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),tu=new j("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),nu=new j("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),ru=new j("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi");import{PublicKey as uu}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as lu}from"@solana/spl-token";import du from"bn.js";var yt=V("Raydium_accountInfo_util");async function gn(t,e,n){let{batchRequest:r,commitment:i="confirmed"}=O({batchRequest:!1},n),o=bt(e,100),s=new Array(o.length).fill([]);if(r){let u=o.map(l=>{let f=t._buildArgs([l.map(p=>p.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:f}}),c=bt(u,10);s=(await(await Promise.all(c.map(async l=>await t._rpcBatchRequest(l)))).flat()).map(l=>(l.error&&yt.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${l.error.message}`),l.result.value.map(f=>{if(f){let{data:p,executable:g,lamports:b,owner:m,rentEpoch:w}=f;return p.length!==2&&p[1]!=="base64"&&yt.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:g,lamports:b,owner:new Hr(m),rentEpoch:w}}return null})))}else try{s=await Promise.all(o.map(u=>t.getMultipleAccountsInfo(u,i)))}catch(u){u instanceof Error&&yt.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return s.flat()}async function wt({connection:t,address:e}){let n=await gn(t,[...new Set(e.map(i=>i.toString()))].map(i=>new hn(i))),r={};for(let i=0;i<e.length;i++){let o=n[i],s=e[i];if(!o)continue;let u=new Ye({key:s,state:Ye.deserialize(o.data)});r[s.toString()]=u,Qe[s.toString()]=u}return r}var Qe={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new Ye({key:new hn("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:Ye.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 Je=class{constructor(e){this.instructions=[];this.endInstructions=[];this.lookupTableAddress=[];this.signers=[];this.instructionTypes=[];this.endInstructionTypes=[];this.connection=e.connection,this.feePayer=e.feePayer,this.signAllTransactions=e.signAllTransactions,this.owner=e.owner}get AllTxData(){return{instructions:this.instructions,endInstructions:this.endInstructions,signers:this.signers,instructionTypes:this.instructionTypes,endInstructionTypes:this.endInstructionTypes,lookupTableAddress:this.lookupTableAddress}}get allInstructions(){return[...this.instructions,...this.endInstructions]}async getComputeBudgetConfig(){var r;let e=(await jr.get(`https://solanacompass.com/api/fees?cacheFreshTime=${3e5}`)).data,{avg:n}=(r=e==null?void 0:e[15])!=null?r:{};if(!!n)return{units:6e5,microLamports:Math.min(Math.ceil(n*1e6/6e5),25e3)}}async calComputeBudget(e){try{let n=await this.getComputeBudgetConfig();if(n){let{instructions:r,instructionTypes:i}=ve(n);this.instructions.unshift(...r),this.instructionTypes.unshift(...i);return}e&&this.instructions.unshift(...e)}catch{e&&this.instructions.unshift(...e)}}addInstruction({instructions:e=[],endInstructions:n=[],signers:r=[],instructionTypes:i=[],endInstructionTypes:o=[],lookupTableAddress:s=[]}){return this.instructions.push(...e),this.endInstructions.push(...n),this.signers.push(...r),this.instructionTypes.push(...i),this.endInstructionTypes.push(...o),this.lookupTableAddress.push(...s.filter(u=>u!==Ze.default.toString())),this}async versionBuild({txVersion:e,extInfo:n}){return e===0?await this.buildV0(n||{}):this.build(n)}build(e){let n=new Ne;return this.allInstructions.length&&n.add(...this.allInstructions),n.feePayer=this.feePayer,{builder:this,transaction:n,signers:this.signers,instructionTypes:[...this.instructionTypes,...this.endInstructionTypes],execute:async()=>{var i;let r=await me(this.connection);if(n.recentBlockhash=r,this.signers.length&&n.sign(...this.signers),le([n]),(i=this.owner)!=null&&i.isKeyPair)return xt(this.connection,n,this.signers);if(this.signAllTransactions){let o=await this.signAllTransactions([n]);return await this.connection.sendRawTransaction(o[0].serialize(),{skipPreflight:!0})}throw new Error("please connect wallet first")},extInfo:e||{}}}buildMultiTx(e){let{extraPreBuildData:n=[],extInfo:r}=e,{transaction:i}=this.build(r),o=n.filter(a=>a.transaction.instructions.length>0),s=[i,...o.map(a=>a.transaction)],u=[this.signers,...o.map(a=>a.signers)],c=[...this.instructionTypes,...o.map(a=>a.instructionTypes).flat()];return{builder:this,transactions:s,signers:u,instructionTypes:c,execute:async a=>{var g;let{sequentially:l,onTxUpdate:f}=a||{},p=await me(this.connection);if((g=this.owner)!=null&&g.isKeyPair)return await Promise.all(s.map(async(b,m)=>(b.recentBlockhash=p,await xt(this.connection,b,u[m]))));if(this.signAllTransactions){let b=s.map((w,h)=>(w.recentBl