UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 81 kB
var Rn=Object.defineProperty,_n=Object.defineProperties;var Dn=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var Kt=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var Ot=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Kt.call(t,n)&&Ot(e,n,t[n]);if(Me)for(var n of Me(t))vt.call(t,n)&&Ot(e,n,t[n]);return e},ne=(e,t)=>_n(e,Dn(t));var pe=(e,t)=>{var n={};for(var r in e)Kt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Me)for(var r of Me(e))t.indexOf(r)<0&&vt.call(e,r)&&(n[r]=e[r]);return n};import{createAssociatedTokenAccountInstruction as Dt,TOKEN_PROGRAM_ID as le,AccountLayout as xe,TOKEN_2022_PROGRAM_ID as Ao}from"@solana/spl-token";import{PublicKey as ot,SystemProgram as ko}from"@solana/web3.js";import{get as Ft,set as Mn}from"lodash";var it=class{constructor(t){this.logLevel=t.logLevel!==void 0?t.logLevel:0,this.name=t.name}set level(t){this.logLevel=t}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(t){return t<=this.logLevel}error(...t){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...t),this):this}logWithError(...t){let n=t.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(n)}warning(...t){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...t),this):this}info(...t){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...t),this):this}debug(...t){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...t),this):this}},Vt={},On={};function G(e){let t=Ft(Vt,e);if(!t){let n=Ft(On,e);t=new it({name:e,logLevel:n}),Mn(Vt,e,t)}return t}import{PublicKey as Is}from"@solana/web3.js";import Ns from"bn.js";import qr from"big.js";import cs from"bn.js";import z from"bn.js";var he=9e15,se=1e9,st="0123456789abcdef",Ke="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ve="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",at={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-he,maxE:he,crypto:!1},Gt,ee,B=!0,Ve="[DecimalError] ",ie=Ve+"Invalid argument: ",Ht=Ve+"Precision limit exceeded",jt=Ve+"crypto unavailable",zt="[object Decimal]",H=Math.floor,K=Math.pow,Kn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,vn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Fn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Zt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,J=1e7,A=7,Vn=9007199254740991,Un=Ke.length-1,ct=ve.length-1,d={toStringTag:zt};d.absoluteValue=d.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),P(e)};d.ceil=function(){return P(new this.constructor(this),this.e+1,2)};d.clampedTo=d.clamp=function(e,t){var n,r=this,o=r.constructor;if(e=new o(e),t=new o(t),!e.s||!t.s)return new o(NaN);if(e.gt(t))throw Error(ie+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new o(r)};d.comparedTo=d.cmp=function(e){var t,n,r,o,i=this,s=i.d,a=(e=new i.constructor(e)).d,c=i.s,u=e.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(i.e!==e.e)return i.e>e.e^c<0?1:-1;for(r=s.length,o=a.length,t=0,n=r<o?r:o;t<n;++t)if(s[t]!==a[t])return s[t]>a[t]^c<0?1:-1;return r===o?0:r>o^c<0?1:-1};d.cosine=d.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+A,r.rounding=1,n=Wn(r,$t(r,n)),r.precision=e,r.rounding=t,P(ee==2||ee==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)};d.cubeRoot=d.cbrt=function(){var e,t,n,r,o,i,s,a,c,u,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(B=!1,i=l.s*K(l.s*l,1/3),!i||Math.abs(i)==1/0?(n=W(l.d),e=l.e,(i=(e-n.length+1)%3)&&(n+=i==1||i==-2?"0":"00"),i=K(n,1/3),e=H((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?n="5e"+e:(n=i.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),r=new f(n),r.s=l.s):r=new f(i.toString()),s=(e=f.precision)+3;;)if(a=r,c=a.times(a).times(a),u=c.plus(l),r=N(u.plus(l).times(a),u.plus(c),s+2,1),W(a.d).slice(0,s)===(n=W(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!o&&n=="4999"){if(!o&&(P(a,e+1,0),a.times(a).times(a).eq(l))){r=a;break}s+=4,o=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(P(r,e+1,1),t=!r.times(r).times(r).eq(l));break}return B=!0,P(r,e,f.rounding,t)};d.decimalPlaces=d.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-H(this.e/A))*A,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};d.dividedBy=d.div=function(e){return N(this,new this.constructor(e))};d.dividedToIntegerBy=d.divToInt=function(e){var t=this,n=t.constructor;return P(N(t,new n(e),0,1,1),n.precision,n.rounding)};d.equals=d.eq=function(e){return this.cmp(e)===0};d.floor=function(){return P(new this.constructor(this),this.e+1,3)};d.greaterThan=d.gt=function(e){return this.cmp(e)>0};d.greaterThanOrEqualTo=d.gte=function(e){var t=this.cmp(e);return t==1||t===0};d.hyperbolicCosine=d.cosh=function(){var e,t,n,r,o,i=this,s=i.constructor,a=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return a;n=s.precision,r=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,o=i.d.length,o<32?(e=Math.ceil(o/3),t=(1/We(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),i=ge(s,1,i.times(t),new s(1),!0);for(var c,u=e,l=new s(8);u--;)c=i.times(i),i=a.minus(c.times(l.minus(c.times(l))));return P(i,s.precision=n,s.rounding=r,!0)};d.hyperbolicSine=d.sinh=function(){var e,t,n,r,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(t=i.precision,n=i.rounding,i.precision=t+Math.max(o.e,o.sd())+4,i.rounding=1,r=o.d.length,r<3)o=ge(i,2,o,o,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,o=o.times(1/We(5,e)),o=ge(i,2,o,o,!0);for(var s,a=new i(5),c=new i(16),u=new i(20);e--;)s=o.times(o),o=o.times(a.plus(s.times(c.times(s).plus(u))))}return i.precision=t,i.rounding=n,P(o,t,n,!0)};d.hyperbolicTangent=d.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,N(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)};d.inverseCosine=d.acos=function(){var e,t=this,n=t.constructor,r=t.abs().cmp(1),o=n.precision,i=n.rounding;return r!==-1?r===0?t.isNeg()?Y(n,o,i):new n(0):new n(NaN):t.isZero()?Y(n,o+4,i).times(.5):(n.precision=o+6,n.rounding=1,t=t.asin(),e=Y(n,o+4,i).times(.5),n.precision=o,n.rounding=i,e.minus(t))};d.inverseHyperbolicCosine=d.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,B=!1,n=n.times(n).minus(1).sqrt().plus(n),B=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)};d.inverseHyperbolicSine=d.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,B=!1,n=n.times(n).plus(1).sqrt().plus(n),B=!0,r.precision=e,r.rounding=t,n.ln())};d.inverseHyperbolicTangent=d.atanh=function(){var e,t,n,r,o=this,i=o.constructor;return o.isFinite()?o.e>=0?new i(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(e=i.precision,t=i.rounding,r=o.sd(),Math.max(r,e)<2*-o.e-1?P(new i(o),e,t,!0):(i.precision=n=r-o.e,o=N(o.plus(1),new i(1).minus(o),n+e,1),i.precision=e+4,i.rounding=1,o=o.ln(),i.precision=e,i.rounding=t,o.times(.5))):new i(NaN)};d.inverseSine=d.asin=function(){var e,t,n,r,o=this,i=o.constructor;return o.isZero()?new i(o):(t=o.abs().cmp(1),n=i.precision,r=i.rounding,t!==-1?t===0?(e=Y(i,n+4,r).times(.5),e.s=o.s,e):new i(NaN):(i.precision=n+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=n,i.rounding=r,o.times(2)))};d.inverseTangent=d.atan=function(){var e,t,n,r,o,i,s,a,c,u=this,l=u.constructor,f=l.precision,p=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&f+4<=ct)return s=Y(l,f+4,p).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(f+4<=ct)return s=Y(l,f+4,p).times(.5),s.s=u.s,s}for(l.precision=a=f+10,l.rounding=1,n=Math.min(28,a/A+2|0),e=n;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(B=!1,t=Math.ceil(a/A),r=1,c=u.times(u),s=new l(u),o=u;e!==-1;)if(o=o.times(c),i=s.minus(o.div(r+=2)),o=o.times(c),s=i.plus(o.div(r+=2)),s.d[t]!==void 0)for(e=t;s.d[e]===i.d[e]&&e--;);return n&&(s=s.times(2<<n-1)),B=!0,P(s,l.precision=f,l.rounding=p,!0)};d.isFinite=function(){return!!this.d};d.isInteger=d.isInt=function(){return!!this.d&&H(this.e/A)>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(e){return this.cmp(e)<0};d.lessThanOrEqualTo=d.lte=function(e){return this.cmp(e)<1};d.logarithm=d.log=function(e){var t,n,r,o,i,s,a,c,u=this,l=u.constructor,f=l.precision,p=l.rounding,m=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new l(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(o=n[0];o%10===0;)o/=10;i=o!==1}if(B=!1,a=f+m,s=oe(u,a),r=t?Fe(l,a+10):oe(e,a),c=N(s,r,a,1),Te(c.d,o=f,p))do if(a+=10,s=oe(u,a),r=t?Fe(l,a+10):oe(e,a),c=N(s,r,a,1),!i){+W(c.d).slice(o+1,o+15)+1==1e14&&(c=P(c,f+1,0));break}while(Te(c.d,o+=10,p));return B=!0,P(c,f,p)};d.minus=d.sub=function(e){var t,n,r,o,i,s,a,c,u,l,f,p,m=this,w=m.constructor;if(e=new w(e),!m.d||!e.d)return!m.s||!e.s?e=new w(NaN):m.d?e.s=-e.s:e=new w(e.d||m.s!==e.s?m:NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(u=m.d,p=e.d,a=w.precision,c=w.rounding,!u[0]||!p[0]){if(p[0])e.s=-e.s;else if(u[0])e=new w(m);else return new w(c===3?-0:0);return B?P(e,a,c):e}if(n=H(e.e/A),l=H(m.e/A),u=u.slice(),i=l-n,i){for(f=i<0,f?(t=u,i=-i,s=p.length):(t=p,n=l,s=u.length),r=Math.max(Math.ceil(a/A),s)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=u.length,s=p.length,f=r<s,f&&(s=r),r=0;r<s;r++)if(u[r]!=p[r]){f=u[r]<p[r];break}i=0}for(f&&(t=u,u=p,p=t,e.s=-e.s),s=u.length,r=p.length-s;r>0;--r)u[s++]=0;for(r=p.length;r>i;){if(u[--r]<p[r]){for(o=r;o&&u[--o]===0;)u[o]=J-1;--u[o],u[r]+=J}u[r]-=p[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(e.d=u,e.e=Ue(u,n),B?P(e,a,c):e):new w(c===3?-0:0)};d.modulo=d.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?P(new r(n),r.precision,r.rounding):(B=!1,r.modulo==9?(t=N(n,e.abs(),0,3,1),t.s*=e.s):t=N(n,e,0,r.modulo,1),t=t.times(e),B=!0,n.minus(t))};d.naturalExponential=d.exp=function(){return ut(this)};d.naturalLogarithm=d.ln=function(){return oe(this)};d.negated=d.neg=function(){var e=new this.constructor(this);return e.s=-e.s,P(e)};d.plus=d.add=function(e){var t,n,r,o,i,s,a,c,u,l,f=this,p=f.constructor;if(e=new p(e),!f.d||!e.d)return!f.s||!e.s?e=new p(NaN):f.d||(e=new p(e.d||f.s===e.s?f:NaN)),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(u=f.d,l=e.d,a=p.precision,c=p.rounding,!u[0]||!l[0])return l[0]||(e=new p(f)),B?P(e,a,c):e;if(i=H(f.e/A),r=H(e.e/A),u=u.slice(),o=i-r,o){for(o<0?(n=u,o=-o,s=l.length):(n=l,r=i,s=u.length),i=Math.ceil(a/A),s=i>s?i+1:s+1,o>s&&(o=s,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,n=l,l=u,u=n),t=0;o;)t=(u[--o]=u[o]+l[o]+t)/J|0,u[o]%=J;for(t&&(u.unshift(t),++r),s=u.length;u[--s]==0;)u.pop();return e.d=u,e.e=Ue(u,r),B?P(e,a,c):e};d.precision=d.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(ie+e);return n.d?(t=Yt(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};d.round=function(){var e=this,t=e.constructor;return P(new t(e),e.e+1,t.rounding)};d.sine=d.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+A,r.rounding=1,n=Gn(r,$t(r,n)),r.precision=e,r.rounding=t,P(ee>2?n.neg():n,e,t,!0)):new r(NaN)};d.squareRoot=d.sqrt=function(){var e,t,n,r,o,i,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(B=!1,u=Math.sqrt(+s),u==0||u==1/0?(t=W(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=H((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new l(t)):r=new l(u.toString()),n=(c=l.precision)+3;;)if(i=r,r=i.plus(N(s,i,n+2,1)).times(.5),W(i.d).slice(0,n)===(t=W(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!o&&t=="4999"){if(!o&&(P(i,c+1,0),i.times(i).eq(s))){r=i;break}n+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(P(r,c+1,1),e=!r.times(r).eq(s));break}return B=!0,P(r,c,l.rounding,e)};d.tangent=d.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=N(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,P(ee==2||ee==4?n.neg():n,e,t,!0)):new r(NaN)};d.times=d.mul=function(e){var t,n,r,o,i,s,a,c,u,l=this,f=l.constructor,p=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!p||!p[0]||!m||!m[0])return new f(!e.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:!p||!m?e.s/0:e.s*0);for(n=H(l.e/A)+H(e.e/A),c=p.length,u=m.length,c<u&&(i=p,p=m,m=i,s=c,c=u,u=s),i=[],s=c+u,r=s;r--;)i.push(0);for(r=u;--r>=0;){for(t=0,o=c+r;o>r;)a=i[o]+m[r]*p[o-r-1]+t,i[o--]=a%J|0,t=a/J|0;i[o]=(i[o]+t)%J|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=Ue(i,n),B?P(e,f.precision,f.rounding):e};d.toBinary=function(e,t){return ft(this,2,e,t)};d.toDecimalPlaces=d.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(j(e,0,se),t===void 0?t=r.rounding:j(t,0,8),P(n,e+n.e+1,t))};d.toExponential=function(e,t){var n,r=this,o=r.constructor;return e===void 0?n=Q(r,!0):(j(e,0,se),t===void 0?t=o.rounding:j(t,0,8),r=P(new o(r),e+1,t),n=Q(r,!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};d.toFixed=function(e,t){var n,r,o=this,i=o.constructor;return e===void 0?n=Q(o):(j(e,0,se),t===void 0?t=i.rounding:j(t,0,8),r=P(new i(o),e+o.e+1,t),n=Q(r,!1,e+r.e+1)),o.isNeg()&&!o.isZero()?"-"+n:n};d.toFraction=function(e){var t,n,r,o,i,s,a,c,u,l,f,p,m=this,w=m.d,g=m.constructor;if(!w)return new g(m);if(u=n=new g(1),r=c=new g(0),t=new g(r),i=t.e=Yt(w)-m.e-1,s=i%A,t.d[0]=K(10,s<0?A+s:s),e==null)e=i>0?t:u;else{if(a=new g(e),!a.isInt()||a.lt(u))throw Error(ie+a);e=a.gt(t)?i>0?t:u:a}for(B=!1,a=new g(W(w)),l=g.precision,g.precision=i=w.length*A*2;f=N(a,t,0,1,1),o=n.plus(f.times(r)),o.cmp(e)!=1;)n=r,r=o,o=u,u=c.plus(f.times(o)),c=o,o=t,t=a.minus(f.times(o)),a=o;return o=N(e.minus(n),r,0,1,1),c=c.plus(o.times(u)),n=n.plus(o.times(r)),c.s=u.s=m.s,p=N(u,r,i,1).minus(m).abs().cmp(N(c,n,i,1).minus(m).abs())<1?[u,r]:[c,n],g.precision=l,B=!0,p};d.toHexadecimal=d.toHex=function(e,t){return ft(this,16,e,t)};d.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:j(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(B=!1,n=N(n,e,0,t,1).times(e),B=!0,P(n)):(e.s=n.s,n=e),n};d.toNumber=function(){return+this};d.toOctal=function(e,t){return ft(this,8,e,t)};d.toPower=d.pow=function(e){var t,n,r,o,i,s,a=this,c=a.constructor,u=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c(K(+a,u));if(a=new c(a),a.eq(1))return a;if(r=c.precision,i=c.rounding,e.eq(1))return P(a,r,i);if(t=H(e.e/A),t>=e.d.length-1&&(n=u<0?-u:u)<=Vn)return o=Jt(c,a,n,r),e.s<0?new c(1).div(o):P(o,r,i);if(s=a.s,s<0){if(t<e.d.length-1)return new c(NaN);if((e.d[t]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=K(+a,u),t=n==0||!isFinite(n)?H(u*(Math.log("0."+W(a.d))/Math.LN10+a.e+1)):new c(n+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(B=!1,c.rounding=a.s=1,n=Math.min(12,(t+"").length),o=ut(e.times(oe(a,r+n)),r),o.d&&(o=P(o,r+5,1),Te(o.d,r,i)&&(t=r+10,o=P(ut(e.times(oe(a,t+n)),t),t+5,1),+W(o.d).slice(r+1,r+15)+1==1e14&&(o=P(o,r+1,0)))),o.s=s,B=!0,c.rounding=i,P(o,r,i))};d.toPrecision=function(e,t){var n,r=this,o=r.constructor;return e===void 0?n=Q(r,r.e<=o.toExpNeg||r.e>=o.toExpPos):(j(e,1,se),t===void 0?t=o.rounding:j(t,0,8),r=P(new o(r),e,t),n=Q(r,e<=r.e||r.e<=o.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n};d.toSignificantDigits=d.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(j(e,1,se),t===void 0?t=r.rounding:j(t,0,8)),P(new r(n),e,t)};d.toString=function(){var e=this,t=e.constructor,n=Q(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n};d.truncated=d.trunc=function(){return P(new this.constructor(this),this.e+1,1)};d.valueOf=d.toJSON=function(){var e=this,t=e.constructor,n=Q(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function W(e){var t,n,r,o=e.length-1,i="",s=e[0];if(o>0){for(i+=s,t=1;t<o;t++)r=e[t]+"",n=A-r.length,n&&(i+=re(n)),i+=r;s=e[t],r=s+"",n=A-r.length,n&&(i+=re(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function j(e,t,n){if(e!==~~e||e<t||e>n)throw Error(ie+e)}function Te(e,t,n,r){var o,i,s,a;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=A,o=0):(o=Math.ceil((t+1)/A),t%=A),i=K(10,A-t),a=e[o]%i|0,r==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==i||n>3&&a+1==i/2)&&(e[o+1]/i/100|0)==K(10,t-2)-1||(a==i/2||a==0)&&(e[o+1]/i/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==2&&(a=a/10|0),s=(r||n<4)&&a==9999||!r&&n>3&&a==4999):s=((r||n<4)&&a+1==i||!r&&n>3&&a+1==i/2)&&(e[o+1]/i/1e3|0)==K(10,t-3)-1,s}function Oe(e,t,n){for(var r,o=[0],i,s=0,a=e.length;s<a;){for(i=o.length;i--;)o[i]*=t;for(o[0]+=st.indexOf(e.charAt(s++)),r=0;r<o.length;r++)o[r]>n-1&&(o[r+1]===void 0&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function Wn(e,t){var n,r,o;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),o=(1/We(4,n)).toString()):(n=16,o="2.3283064365386962890625e-10"),e.precision+=n,t=ge(e,1,t.times(o),new e(1));for(var i=n;i--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}var N=function(){function e(r,o,i){var s,a=0,c=r.length;for(r=r.slice();c--;)s=r[c]*o+a,r[c]=s%i|0,a=s/i|0;return a&&r.unshift(a),r}function t(r,o,i,s){var a,c;if(i!=s)c=i>s?1:-1;else for(a=c=0;a<i;a++)if(r[a]!=o[a]){c=r[a]>o[a]?1:-1;break}return c}function n(r,o,i,s){for(var a=0;i--;)r[i]-=a,a=r[i]<o[i]?1:0,r[i]=a*s+r[i]-o[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,o,i,s,a,c){var u,l,f,p,m,w,g,T,x,b,h,y,L,k,v,E,M,q,F,Z,fe=r.constructor,de=r.s==o.s?1:-1,V=r.d,R=o.d;if(!V||!V[0]||!R||!R[0])return new fe(!r.s||!o.s||(V?R&&V[0]==R[0]:!R)?NaN:V&&V[0]==0||!R?de*0:de/0);for(c?(m=1,l=r.e-o.e):(c=J,m=A,l=H(r.e/m)-H(o.e/m)),F=R.length,M=V.length,x=new fe(de),b=x.d=[],f=0;R[f]==(V[f]||0);f++);if(R[f]>(V[f]||0)&&l--,i==null?(k=i=fe.precision,s=fe.rounding):a?k=i+(r.e-o.e)+1:k=i,k<0)b.push(1),w=!0;else{if(k=k/m+2|0,f=0,F==1){for(p=0,R=R[0],k++;(f<M||p)&&k--;f++)v=p*c+(V[f]||0),b[f]=v/R|0,p=v%R|0;w=p||f<M}else{for(p=c/(R[0]+1)|0,p>1&&(R=e(R,p,c),V=e(V,p,c),F=R.length,M=V.length),E=F,h=V.slice(0,F),y=h.length;y<F;)h[y++]=0;Z=R.slice(),Z.unshift(0),q=R[0],R[1]>=c/2&&++q;do p=0,u=t(R,h,F,y),u<0?(L=h[0],F!=y&&(L=L*c+(h[1]||0)),p=L/q|0,p>1?(p>=c&&(p=c-1),g=e(R,p,c),T=g.length,y=h.length,u=t(g,h,T,y),u==1&&(p--,n(g,F<T?Z:R,T,c))):(p==0&&(u=p=1),g=R.slice()),T=g.length,T<y&&g.unshift(0),n(h,g,y,c),u==-1&&(y=h.length,u=t(R,h,F,y),u<1&&(p++,n(h,F<y?Z:R,y,c))),y=h.length):u===0&&(p++,h=[0]),b[f++]=p,u&&h[0]?h[y++]=V[E]||0:(h=[V[E]],y=1);while((E++<M||h[0]!==void 0)&&k--);w=h[0]!==void 0}b[0]||b.shift()}if(m==1)x.e=l,Gt=w;else{for(f=1,p=b[0];p>=10;p/=10)f++;x.e=f+l*m-1,P(x,a?i+x.e+1:i,s,w)}return x}}();function P(e,t,n,r){var o,i,s,a,c,u,l,f,p,m=e.constructor;e:if(t!=null){if(f=e.d,!f)return e;for(o=1,a=f[0];a>=10;a/=10)o++;if(i=t-o,i<0)i+=A,s=t,l=f[p=0],c=l/K(10,o-s-1)%10|0;else if(p=Math.ceil((i+1)/A),a=f.length,p>=a)if(r){for(;a++<=p;)f.push(0);l=c=0,o=1,i%=A,s=i-A+1}else break e;else{for(l=a=f[p],o=1;a>=10;a/=10)o++;i%=A,s=i-A+o,c=s<0?0:l/K(10,o-s-1)%10|0}if(r=r||t<0||f[p+1]!==void 0||(s<0?l:l%K(10,o-s-1)),u=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(i>0?s>0?l/K(10,o-s):0:f[p-1])%10&1||n==(e.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=e.e+1,f[0]=K(10,(A-t%A)%A),e.e=-t||0):f[0]=e.e=0,e;if(i==0?(f.length=p,a=1,p--):(f.length=p+1,a=K(10,A-i),f[p]=s>0?(l/K(10,o-s)%K(10,s)|0)*a:0),u)for(;;)if(p==0){for(i=1,s=f[0];s>=10;s/=10)i++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;i!=a&&(e.e++,f[0]==J&&(f[0]=1));break}else{if(f[p]+=a,f[p]!=J)break;f[p--]=0,a=1}for(i=f.length;f[--i]===0;)f.pop()}return B&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e<m.minE&&(e.e=0,e.d=[0])),e}function Q(e,t,n){if(!e.isFinite())return Qt(e);var r,o=e.e,i=W(e.d),s=i.length;return t?(n&&(r=n-s)>0?i=i.charAt(0)+"."+i.slice(1)+re(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):o<0?(i="0."+re(-o-1)+i,n&&(r=n-s)>0&&(i+=re(r))):o>=s?(i+=re(o+1-s),n&&(r=n-o-1)>0&&(i=i+"."+re(r))):((r=o+1)<s&&(i=i.slice(0,r)+"."+i.slice(r)),n&&(r=n-s)>0&&(o+1===s&&(i+="."),i+=re(r))),i}function Ue(e,t){var n=e[0];for(t*=A;n>=10;n/=10)t++;return t}function Fe(e,t,n){if(t>Un)throw B=!0,n&&(e.precision=n),Error(Ht);return P(new e(Ke),t,1,!0)}function Y(e,t,n){if(t>ct)throw Error(Ht);return P(new e(ve),t,n,!0)}function Yt(e){var t=e.length-1,n=t*A+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function re(e){for(var t="";e--;)t+="0";return t}function Jt(e,t,n,r){var o,i=new e(1),s=Math.ceil(r/A+4);for(B=!1;;){if(n%2&&(i=i.times(t),Wt(i.d,s)&&(o=!0)),n=H(n/2),n===0){n=i.d.length-1,o&&i.d[n]===0&&++i.d[n];break}t=t.times(t),Wt(t.d,s)}return B=!0,i}function Ut(e){return e.d[e.d.length-1]&1}function Xt(e,t,n){for(var r,o=new e(t[0]),i=0;++i<t.length;)if(r=new e(t[i]),r.s)o[n](r)&&(o=r);else{o=r;break}return o}function ut(e,t){var n,r,o,i,s,a,c,u=0,l=0,f=0,p=e.constructor,m=p.rounding,w=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(B=!1,c=w):c=t,a=new p(.03125);e.e>-2;)e=e.times(a),f+=5;for(r=Math.log(K(2,f))/Math.LN10*2+5|0,c+=r,n=i=s=new p(1),p.precision=c;;){if(i=P(i.times(e),c,1),n=n.times(++l),a=s.plus(N(i,n,c,1)),W(a.d).slice(0,c)===W(s.d).slice(0,c)){for(o=f;o--;)s=P(s.times(s),c,1);if(t==null)if(u<3&&Te(s.d,c-r,m,u))p.precision=c+=10,n=i=a=new p(1),l=0,u++;else return P(s,p.precision=w,m,B=!0);else return p.precision=w,s}s=a}}function oe(e,t){var n,r,o,i,s,a,c,u,l,f,p,m=1,w=10,g=e,T=g.d,x=g.constructor,b=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(t==null?(B=!1,l=h):l=t,x.precision=l+=w,n=W(T),r=n.charAt(0),Math.abs(i=g.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=W(g.d),r=n.charAt(0),m++;i=g.e,r>1?(g=new x("0."+n),i++):g=new x(r+"."+n.slice(1))}else return u=Fe(x,l+2,h).times(i+""),g=oe(new x(r+"."+n.slice(1)),l-w).plus(u),x.precision=h,t==null?P(g,h,b,B=!0):g;for(f=g,c=s=g=N(g.minus(1),g.plus(1),l,1),p=P(g.times(g),l,1),o=3;;){if(s=P(s.times(p),l,1),u=c.plus(N(s,new x(o),l,1)),W(u.d).slice(0,l)===W(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(Fe(x,l+2,h).times(i+""))),c=N(c,new x(m),l,1),t==null)if(Te(c.d,l-w,b,a))x.precision=l+=w,u=s=g=N(f.minus(1),f.plus(1),l,1),p=P(g.times(g),l,1),o=a=1;else return P(c,x.precision=h,b,B=!0);else return x.precision=h,c;c=u,o+=2}}function Qt(e){return String(e.s*e.s/0)}function lt(e,t){var n,r,o;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(o=t.length;t.charCodeAt(o-1)===48;--o);if(t=t.slice(r,o),t){if(o-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%A,n<0&&(r+=A),r<o){for(r&&e.d.push(+t.slice(0,r)),o-=A;r<o;)e.d.push(+t.slice(r,r+=A));t=t.slice(r),r=A-t.length}else r-=o;for(;r--;)t+="0";e.d.push(+t),B&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function qn(e,t){var n,r,o,i,s,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Zt.test(t))return lt(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(vn.test(t))n=16,t=t.toLowerCase();else if(Kn.test(t))n=2;else if(Fn.test(t))n=8;else throw Error(ie+t);for(i=t.search(/p/i),i>0?(c=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),s=i>=0,r=e.constructor,s&&(t=t.replace(".",""),a=t.length,i=a-i,o=Jt(r,new r(n),i,i*2)),u=Oe(t,n,J),l=u.length-1,i=l;u[i]===0;--i)u.pop();return i<0?new r(e.s*0):(e.e=Ue(u,l),e.d=u,B=!1,s&&(e=N(e,o,a*4)),c&&(e=e.times(Math.abs(c)<54?K(2,c):qe.pow(2,c))),B=!0,e)}function Gn(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:ge(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/We(5,n)),t=ge(e,2,t,t);for(var o,i=new e(5),s=new e(16),a=new e(20);n--;)o=t.times(t),t=t.times(i.plus(o.times(s.times(o).minus(a))));return t}function ge(e,t,n,r,o){var i,s,a,c,u=1,l=e.precision,f=Math.ceil(l/A);for(B=!1,c=n.times(n),a=new e(r);;){if(s=N(a.times(c),new e(t++*t++),l,1),a=o?r.plus(s):r.minus(s),r=N(s.times(c),new e(t++*t++),l,1),s=a.plus(r),s.d[f]!==void 0){for(i=f;s.d[i]===a.d[i]&&i--;);if(i==-1)break}i=a,a=r,r=s,s=i,u++}return B=!0,s.d.length=f+1,s}function We(e,t){for(var n=e;--t;)n*=e;return n}function $t(e,t){var n,r=t.s<0,o=Y(e,e.precision,1),i=o.times(.5);if(t=t.abs(),t.lte(i))return ee=r?4:1,t;if(n=t.divToInt(o),n.isZero())ee=r?3:2;else{if(t=t.minus(n.times(o)),t.lte(i))return ee=Ut(n)?r?2:3:r?4:1,t;ee=Ut(n)?r?1:4:r?3:2}return t.minus(o).abs()}function ft(e,t,n,r){var o,i,s,a,c,u,l,f,p,m=e.constructor,w=n!==void 0;if(w?(j(n,1,se),r===void 0?r=m.rounding:j(r,0,8)):(n=m.precision,r=m.rounding),!e.isFinite())l=Qt(e);else{for(l=Q(e),s=l.indexOf("."),w?(o=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):o=t,s>=0&&(l=l.replace(".",""),p=new m(1),p.e=l.length-s,p.d=Oe(Q(p),10,o),p.e=p.d.length),f=Oe(l,10,o),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])l=w?"0p+0":"0";else{if(s<0?i--:(e=new m(e),e.d=f,e.e=i,e=N(e,p,n,r,0,o),f=e.d,i=e.e,u=Gt),s=f[n],a=o/2,u=u||f[n+1]!==void 0,u=r<4?(s!==void 0||u)&&(r===0||r===(e.s<0?3:2)):s>a||s===a&&(r===4||u||r===6&&f[n-1]&1||r===(e.s<0?8:7)),f.length=n,u)for(;++f[--n]>o-1;)f[n]=0,n||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(s=0,l="";s<c;s++)l+=st.charAt(f[s]);if(w){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(f=Oe(l,o,t),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+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)l="0"+l;l="0."+l}else if(++i>c)for(i-=c;i--;)l+="0";else i<c&&(l=l.slice(0,i)+"."+l.slice(i))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function Wt(e,t){if(e.length>t)return e.length=t,!0}function Hn(e){return new this(e).abs()}function jn(e){return new this(e).acos()}function zn(e){return new this(e).acosh()}function Zn(e,t){return new this(e).plus(t)}function Yn(e){return new this(e).asin()}function Jn(e){return new this(e).asinh()}function Xn(e){return new this(e).atan()}function Qn(e){return new this(e).atanh()}function $n(e,t){e=new this(e),t=new this(t);var n,r=this.precision,o=this.rounding,i=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=Y(this,i,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Y(this,r,o):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Y(this,i,1).times(.5),n.s=e.s):t.s<0?(this.precision=i,this.rounding=1,n=this.atan(N(e,t,i,1)),t=Y(this,i,1),this.precision=r,this.rounding=o,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(N(e,t,i,1)),n}function er(e){return new this(e).cbrt()}function tr(e){return P(e=new this(e),e.e+1,2)}function nr(e,t,n){return new this(e).clamp(t,n)}function rr(e){if(!e||typeof e!="object")throw Error(Ve+"Object expected");var t,n,r,o=e.defaults===!0,i=["precision",1,se,"rounding",0,8,"toExpNeg",-he,0,"toExpPos",0,he,"maxE",0,he,"minE",-he,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(n=i[t],o&&(this[n]=at[n]),(r=e[n])!==void 0)if(H(r)===r&&r>=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(ie+n+": "+r);if(n="crypto",o&&(this[n]=at[n]),(r=e[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(jt);else this[n]=!1;else throw Error(ie+n+": "+r);return this}function or(e){return new this(e).cos()}function ir(e){return new this(e).cosh()}function en(e){var t,n,r;function o(i){var s,a,c,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,qt(i)){u.s=i.s,B?!i.d||i.e>o.maxE?(u.e=NaN,u.d=null):i.e<o.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(s=0,a=i;a>=10;a/=10)s++;B?s>o.maxE?(u.e=NaN,u.d=null):s<o.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[i]):(u.e=s,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return lt(u,i.toString())}else if(c!=="string")throw Error(ie+i);return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),Zt.test(i)?lt(u,i):qn(u,i)}if(o.prototype=d,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=rr,o.clone=en,o.isDecimal=qt,o.abs=Hn,o.acos=jn,o.acosh=zn,o.add=Zn,o.asin=Yn,o.asinh=Jn,o.atan=Xn,o.atanh=Qn,o.atan2=$n,o.cbrt=er,o.ceil=tr,o.clamp=nr,o.cos=or,o.cosh=ir,o.div=sr,o.exp=ar,o.floor=cr,o.hypot=ur,o.ln=lr,o.log=fr,o.log10=mr,o.log2=pr,o.max=dr,o.min=hr,o.mod=gr,o.mul=br,o.pow=yr,o.random=wr,o.round=xr,o.sign=Tr,o.sin=Pr,o.sinh=Ar,o.sqrt=kr,o.sub=Br,o.sum=Sr,o.tan=Cr,o.tanh=Ir,o.trunc=Lr,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return o.config(e),o}function sr(e,t){return new this(e).div(t)}function ar(e){return new this(e).exp()}function cr(e){return P(e=new this(e),e.e+1,3)}function ur(){var e,t,n=new this(0);for(B=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return B=!0,new this(1/0);n=t}return B=!0,n.sqrt()}function qt(e){return e instanceof qe||e&&e.toStringTag===zt||!1}function lr(e){return new this(e).ln()}function fr(e,t){return new this(e).log(t)}function pr(e){return new this(e).log(2)}function mr(e){return new this(e).log(10)}function dr(){return Xt(this,arguments,"lt")}function hr(){return Xt(this,arguments,"gt")}function gr(e,t){return new this(e).mod(t)}function br(e,t){return new this(e).mul(t)}function yr(e,t){return new this(e).pow(t)}function wr(e){var t,n,r,o,i=0,s=new this(1),a=[];if(e===void 0?e=this.precision:j(e,1,se),r=Math.ceil(e/A),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));i<r;)o=t[i],o>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=o%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);i<r;)o=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(t,i):(a.push(o%1e7),i+=4);i=r/4}else throw Error(jt);else for(;i<r;)a[i++]=Math.random()*1e7|0;for(r=a[--i],e%=A,r&&e&&(o=K(10,A-e),a[i]=(r/o|0)*o);a[i]===0;i--)a.pop();if(i<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=A)a.shift();for(r=1,o=a[0];o>=10;o/=10)r++;r<A&&(n-=A-r)}return s.e=n,s.d=a,s}function xr(e){return P(e=new this(e),e.e+1,this.rounding)}function Tr(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Pr(e){return new this(e).sin()}function Ar(e){return new this(e).sinh()}function kr(e){return new this(e).sqrt()}function Br(e,t){return new this(e).sub(t)}function Sr(){var e=0,t=arguments,n=new this(t[e]);for(B=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return B=!0,P(n,this.precision,this.rounding)}function Cr(e){return new this(e).tan()}function Ir(e){return new this(e).tanh()}function Lr(e){return P(e=new this(e),e.e+1,1)}d[Symbol.for("nodejs.util.inspect.custom")]=d.toString;d[Symbol.toStringTag]="Decimal";var qe=d.constructor=en(at);Ke=new qe(Ke);ve=new qe(ve);import{PublicKey as mt}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Nr}from"@solana/spl-token";import{PublicKey as D,SystemProgram as tn,SYSVAR_RENT_PUBKEY as Er}from"@solana/web3.js";function pt({pubkey:e,isSigner:t=!1,isWritable:n=!0}){return{pubkey:e,isWritable:n,isSigner:t}}var Ro=[pt({pubkey:Nr,isWritable:!1}),pt({pubkey:tn.programId,isWritable:!1}),pt({pubkey:Er,isWritable:!1})];function nn({publicKey:e,transformSol:t}){let n=rn(e.toString());if(n instanceof D)return t&&n.equals(Pe)?ae:n;if(t&&n.toString()===Pe.toBase58())return ae;if(typeof n=="string"){if(n===D.default.toBase58())return D.default;try{return new D(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function rn(e){try{return new D(e)}catch{return e}}var _o=new D("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Do=new D("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Mo=new D("SysvarRent111111111111111111111111111111111"),Oo=new D("SysvarC1ock11111111111111111111111111111111"),Ko=new D("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),vo=new D("Sysvar1nstructions1111111111111111111111111"),Fo=tn.programId,Vo=new D("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Uo=new D("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Wo=new D("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),qo=new D("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Go=new D("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ho=new D("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),jo=new D("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),zo=new D("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Zo=new D("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Yo=new D("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Jo=new D("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),ae=new D("So11111111111111111111111111111111111111112"),Pe=D.default;import{PublicKey as Rr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as on}from"@solana/spl-token";var sn={chainId:101,address:Rr.default.toBase58(),programId:on.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},te={chainId:101,address:"So11111111111111111111111111111111111111112",programId:on.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 dt=class{constructor({mint:t,decimals:n,symbol:r,name:o,skipMint:i=!1,isToken2022:s=!1}){if(t===Pe.toBase58()||t instanceof mt&&Pe.equals(t)){this.decimals=te.decimals,this.symbol=te.symbol,this.name=te.name,this.mint=new mt(te.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=r||t.toString().substring(0,6),this.name=o||t.toString().substring(0,6),this.mint=i?mt.default:nn({publicKey:t}),this.isToken2022=s}equals(t){return this===t?!0:this.mint.equals(t.mint)}},be=dt;be.WSOL=new dt(ne(O({},te),{mint:te.address}));import He from"big.js";import Mr from"bn.js";import Or from"decimal.js-light";import _r from"toformat";var Dr=_r,Ae=Dr;var Ge=G("module/fraction"),ht=Ae(He),ke=Ae(Or),Kr={[0]:ke.ROUND_DOWN,[1]:ke.ROUND_HALF_UP,[2]:ke.ROUND_UP},vr={[0]:He.roundDown,[1]:He.roundHalfUp,[2]:He.roundUp},_=class{constructor(t,n=new Mr(1)){this.numerator=$(t),this.denominator=$(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new _(this.denominator,this.numerator)}add(t){let n=t instanceof _?t:new _($(t));return this.denominator.eq(n.denominator)?new _(this.numerator.add(n.numerator),this.denominator):new _(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(t){let n=t instanceof _?t:new _($(t));return this.denominator.eq(n.denominator)?new _(this.numerator.sub(n.numerator),this.denominator):new _(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(t){let n=t instanceof _?t:new _($(t));return new _(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(t){let n=t instanceof _?t:new _($(t));return new _(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(t,n={groupSeparator:""},r=1){Number.isInteger(t)||Ge.logWithError(`${t} is not an integer.`),t<=0&&Ge.logWithError(`${t} is not positive.`),ke.set({precision:t+1,rounding:Kr[r]});let o=new ke(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return o.toFormat(o.decimalPlaces(),n)}toFixed(t,n={groupSeparator:""},r=1){return Number.isInteger(t)||Ge.logWithError(`${t} is not an integer.`),t<0&&Ge.logWithError(`${t} is negative.`),ht.DP=t,ht.RM=vr[r]||1,new ht(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)}isZero(){return this.numerator.isZero()}};var Pi=G("Raydium_price");var gt=class{constructor({decimals:t,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=t,this.symbol=n,this.name=r}equals(t){return this===t}},je=gt;je.SOL=new gt(sn);import Vr from"bn.js";var Ni=new _(new Vr(100));var Ur=new z(0),Ji=new z(1),Xi=new z(2),Qi=new z(3),$i=new z(5),Wr=new z(10),es=new z(100),ts=new z(1e3),ns=new z(1e4),ln=9007199254740991;function $(e){let t=G("Raydium_parseBigNumberish");if(e instanceof z)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new z(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=ln||e<=-ln)&&t.logWithError(`BigNumberish number overflow: ${e}`),new z(String(e))):typeof e=="bigint"?new z(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new z(0))}var gs=G("Raydium_amount"),bs=Ae(qr);import{PublicKey as Ce,sendAndConfirmTransaction as xt,Transaction as Ie,TransactionMessage as Le,VersionedTransaction as Ne}from"@solana/web3.js";import Xr from"axios";var U={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut"};import{PublicKey as Gr,ComputeBudgetProgram as fn,Transaction as mn,TransactionMessage as Hr,Keypair as dn,VersionedTransaction as hn}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as jr}from"@solana/spl-token";var pn=G("Raydium_txUtil"),gn=1644;function ze(e){let t=[],n=[];return e.microLamports&&(t.push(fn.setComputeUnitPrice({microLamports:e.microLamports})),n.push(U.SetComputeUnitPrice)),e.units&&(t.push(fn.setComputeUnitLimit({units:e.units})),n.push(U.SetComputeUnitLimit)),{instructions:t,instructionTypes:n}}async function ye(e,t){var r,o;let n=t!=null?t:"confirmed";try{return((o=await((r=e.getLatestBlockhash)==null?void 0:r.call(e,{commitment:n})))==null?void 0:o.blockhash)||(await e.getRecentBlockhash(n)).blockhash}catch{return(await e.getRecentBlockhash(n)).blockhash}}function zr(e,t){e.length<1&&pn.logWithError(`no instructions provided: ${e.toString()}`),t.length<1&&pn.logWithError(`no signers provided:, ${t.toString()}`);let n=new mn;n.recentBlockhash="11111111111111111111111111111111",n.feePayer=t[0],n.add(...e);try{return Buffer.from(n.serialize({verifySignatures:!1})).toString("base64").length<gn}catch{return!1}}function bn(e,t){let[n,r]=Gr.findProgramAddressSync(e,t);return{publicKey:n,nonce:r}}function Be({instructions:e,payer:t,signers:n}){return zr(e,[t,...n])}function Se({instructions:e,payer:t,lookupTableAddressAccount:n,recentBlockhash:r=dn.generate().publicKey.toString()}){let i=new Hr({payerKey:t,recentBlockhash:r,instructions:e}).compileToV0Message(Object.values(n!=null?n:{}));try{return Buffer.from(new hn(i).serialize()).toString("base64").length<gn}catch{return!1}}var Zr=e=>Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e),Yr=e=>{let t=e.serialize({requireAllSignatures:!1,verifySignatures:!1});e instanceof hn&&(t=Zr(t));try{return t instanceof Buffer?t.toString("base64"):Buffer.from(t).toString("base64")}catch{return t.toString("base64")}};function me(e){let t=[];return e.forEach(n=>{n instanceof mn&&(n.recentBlockhash||(n.recentBlockhash=jr.toBase58()),n.feePayer||(n.feePayer=dn.generate().publicKey)),t.push(Yr(n))}),console.log("simulate tx string:",t),t}import{PublicKey as wn,AddressLookupTableAccount as Ze}from"@solana/web3.js";import{PublicKey as Jr}from"@solana/web3.js";import{MINT_SIZE as Xs,TOKEN_PROGRAM_ID as Qs,getTransferFeeConfig as $s,unpackMint as ea}from"@solana/spl-token";var bt=G("Raydium_accountInfo_util");async function yn(e,t,n){let{batchRequest:r,commitment:o="confirmed",chunkCount:i=100}=O({batchRequest:!1},n),s=yt(t,i),a=new Array(s.length).fill([]);if(r){let c=s.map(f=>{let p=e._buildArgs([f.map(m=>m.toBase58())],o,"base64");return{methodName:"getMultipleAccounts",args:p}}),u=yt(c,10);a=(await(await Promise.all(u.map(async f=>await e._rpcBatchRequest(f)))).flat()).map(f=>(f.error&&bt.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${f.error.message}`),f.result.value.map(p=>{if(p){let{data:m,executable:w,lamports:g,owner:T,rentEpoch:x}=p;return m.length!==2&&m[1]!=="base64"&&bt.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(m[0],"base64"),executable:w,lamports:g,owner:new Jr(T),rentEpoch:x}}return null})))}else try{a=await Promise.all(s.map(c=>e.getMultipleAccountsInfo(c,o)))}catch(c){c instanceof Error&&bt.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function wt({connection:e,address:t}){let n=await yn(e,[...new Set(t.map(o=>o.toString()))].map(o=>new wn(o))),r={};for(let o=0;o<t.length;o++){let i=n[o],s=t[o];if(!i)continue;let a=new Ze({key:s,state:Ze.deserialize(i.data)});r[s.toString()]=a,Ye[s.toString()]=a}return r}var Ye={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new Ze({key:new wn("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:Ze.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(t){this.instructions=[];this.endInstructions=[];this.lookupTableAddress=[];this.signers=[];this.instructionTypes=[];this.endInstructionTypes=[];this.connection=t.connection,this.feePayer=t.feePayer,this.signAllTransactions=t.signAllTransactions,this.owner=t.owner,this.cluster=t.cluster,this.blockhashCommitment=t.blockhashCommitment,this.api=t.api}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 t=(await Xr.get(`https://solanacompass.com/api/fees?cacheFreshTime=${3e5}`)).data,{avg:n}=(r=t==null?void 0:t[15])!=null?r:{};if(!!n)return{units:6e5,microLamports:Math.min(Math.ceil(n*1e6/6e5),25e3)}}addCustomComputeBudget(t){if(t){let{instructions:n,instructionTypes:r}=ze(t);return this.instructions.unshift(...n),this.instructionTypes.unshift(...r),!0}return!1}async calComputeBudget({config:t,defaultIns:n}){try{let r=t||await this.getComputeBudgetConfig();if(this.addCustomComputeBudget(r))return;n&&this.instructions.unshift(...n)}catch{n&&this.instructions.unshift(...n)}}addInstruction({instructions:t=[],endInstructions:n=[],signers:r=[],instructionTypes:o=[],endInstructionTypes:i=[],lookupTableAddress:s=[]}){return this.instructions.push(...t),this.endInstructions.push(...n),this.signers.push(...r),this.instructionTypes.push(...o),this.endInstructionTypes.push(...i),this.lookupTableAddress.push(...s.filter(a=>a!==Ce.default.toString())),this}async versionBuild({txVersion:t,extInfo:n}){return t===0?await this.buildV0(O({},n||{})):this.build(n)}build(t){var r;let n=new Ie;return this.allInstructions.length&&n.add(...this.allInstructions),n.feePayer=this.feePayer,((r=this.owner)==null?void 0:r.signer)&&!this.signers.some(o=>o.publicKey.equals(this.owner.publicKey))&&this.signers.push(this.owner.signer),{builder:this,transaction:n,signers:this.signers,instructionTypes:[...this.instructionTypes,...this.endInstructionTypes],execute:async o=>{var u;let{recentBlockHash:i,skipPreflight:s=!0,sendAndConfirm:a}=o||{},c=i!=null?i:await ye(this.connection,this.blockhashCommitment);if(n.recentBlockhash=c,this.signers.length&&n.sign(...this.signers),me([n]),(u=this.owner)!=null&&u.isKeyPair)return{txId:a?await xt(this.connection,n,this.signers.find(f=>f.publicKey.equals(this.owner.publicKey))?this.signers:[...this.signers,this.owner.signer],{skipPreflight:s}):await this.connection.sendRawTransaction(n.serialize(),{skipPreflight:s}),signedTx:n};if(this.signAllTransactions){let l=await this.signAllTransactions([n]);return{txId:await this.connection.sendRawTransaction(l[0].serialize(),{skipPreflight:s}),signedTx:l[0]}}throw new Error("please provide owner in keypair format or signAllTransactions function")},extInfo:t||{}}}buildMultiTx(t){var u;let{extraPreBuildData:n=[],extInfo:r}=t,{transaction:o}=this.build(r),i=n.filter(l=>l.transaction.instructions.length>0),s=[o,...i.map(l=>l.transaction)],a=[this.signers,...i.map(l=>l.signers)],c=[...this.instructionTypes,...i.map(l=>l.instructionTypes).flat()];return(u=this.owner)!=null&&u.signer&&a.forEach(l=>{l.some(f=>f.publicKey.equals(this.owner.publicKey))||this.signers.push(this.owner