UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

2 lines 45.6 kB
var yn=Object.defineProperty,xn=Object.defineProperties;var Pn=Object.getOwnPropertyDescriptors;var He=Object.getOwnPropertySymbols;var An=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable;var Ze=(e,n,t)=>n in e?yn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,J=(e,n)=>{for(var t in n||(n={}))An.call(n,t)&&Ze(e,t,n[t]);if(He)for(var t of He(n))Nn.call(n,t)&&Ze(e,t,n[t]);return e},Q=(e,n)=>xn(e,Pn(n));import{PublicKey as Ge,AddressLookupTableAccount as ie}from"@solana/web3.js";import{PublicKey as Vt}from"@solana/web3.js";import H from"bn.js";var $=9e15,Y=1e9,Re="0123456789abcdef",he="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",we="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ie={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-$,maxE:$,crypto:!1},Je,U,b=!0,be="[DecimalError] ",z=be+"Invalid argument: ",Xe=be+"Precision limit exceeded",Qe=be+"crypto unavailable",$e="[object Decimal]",L=Math.floor,R=Math.pow,Sn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,kn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Cn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,en=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,W=1e7,w=7,Bn=9007199254740991,Rn=he.length-1,Me=we.length-1,d={toStringTag:$e};d.absoluteValue=d.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),g(e)};d.ceil=function(){return g(new this.constructor(this),this.e+1,2)};d.clampedTo=d.clamp=function(e,n){var t,r=this,o=r.constructor;if(e=new o(e),n=new o(n),!e.s||!n.s)return new o(NaN);if(e.gt(n))throw Error(z+n);return t=r.cmp(e),t<0?e:r.cmp(n)>0?n:new o(r)};d.comparedTo=d.cmp=function(e){var n,t,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,n=0,t=r<o?r:o;n<t;++n)if(s[n]!==a[n])return s[n]>a[n]^c<0?1:-1;return r===o?0:r>o^c<0?1:-1};d.cosine=d.cos=function(){var e,n,t=this,r=t.constructor;return t.d?t.d[0]?(e=r.precision,n=r.rounding,r.precision=e+Math.max(t.e,t.sd())+w,r.rounding=1,t=In(r,sn(r,t)),r.precision=e,r.rounding=n,g(U==2||U==3?t.neg():t,e,n,!0)):new r(1):new r(NaN)};d.cubeRoot=d.cbrt=function(){var e,n,t,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*R(l.s*l,1/3),!i||Math.abs(i)==1/0?(t=M(l.d),e=l.e,(i=(e-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=R(t,1/3),e=L((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new f(t),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),M(a.d).slice(0,s)===(t=M(r.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!o&&t=="4999"){if(!o&&(g(a,e+1,0),a.times(a).times(a).eq(l))){r=a;break}s+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(g(r,e+1,1),n=!r.times(r).times(r).eq(l));break}return b=!0,g(r,e,f.rounding,n)};d.decimalPlaces=d.dp=function(){var e,n=this.d,t=NaN;if(n){if(e=n.length-1,t=(e-L(this.e/w))*w,e=n[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t};d.dividedBy=d.div=function(e){return N(this,new this.constructor(e))};d.dividedToIntegerBy=d.divToInt=function(e){var n=this,t=n.constructor;return g(N(n,new t(e),0,1,1),t.precision,t.rounding)};d.equals=d.eq=function(e){return this.cmp(e)===0};d.floor=function(){return g(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 n=this.cmp(e);return n==1||n===0};d.hyperbolicCosine=d.cosh=function(){var e,n,t,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;t=s.precision,r=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,o=i.d.length,o<32?(e=Math.ceil(o/3),n=(1/xe(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i=ee(s,1,i.times(n),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 g(i,s.precision=t,s.rounding=r,!0)};d.hyperbolicSine=d.sinh=function(){var e,n,t,r,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(n=i.precision,t=i.rounding,i.precision=n+Math.max(o.e,o.sd())+4,i.rounding=1,r=o.d.length,r<3)o=ee(i,2,o,o,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,o=o.times(1/xe(5,e)),o=ee(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=n,i.rounding=t,g(o,n,t,!0)};d.hyperbolicTangent=d.tanh=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,n=r.rounding,r.precision=e+7,r.rounding=1,N(t.sinh(),t.cosh(),r.precision=e,r.rounding=n)):new r(t.s)};d.inverseCosine=d.acos=function(){var e,n=this,t=n.constructor,r=n.abs().cmp(1),o=t.precision,i=t.rounding;return r!==-1?r===0?n.isNeg()?V(t,o,i):new t(0):new t(NaN):n.isZero()?V(t,o+4,i).times(.5):(t.precision=o+6,t.rounding=1,n=n.asin(),e=V(t,o+4,i).times(.5),t.precision=o,t.rounding=i,e.minus(n))};d.inverseHyperbolicCosine=d.acosh=function(){var e,n,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(e=r.precision,n=r.rounding,r.precision=e+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,b=!1,t=t.times(t).minus(1).sqrt().plus(t),b=!0,r.precision=e,r.rounding=n,t.ln()):new r(t)};d.inverseHyperbolicSine=d.asinh=function(){var e,n,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(e=r.precision,n=r.rounding,r.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,b=!1,t=t.times(t).plus(1).sqrt().plus(t),b=!0,r.precision=e,r.rounding=n,t.ln())};d.inverseHyperbolicTangent=d.atanh=function(){var e,n,t,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,n=i.rounding,r=o.sd(),Math.max(r,e)<2*-o.e-1?g(new i(o),e,n,!0):(i.precision=t=r-o.e,o=N(o.plus(1),new i(1).minus(o),t+e,1),i.precision=e+4,i.rounding=1,o=o.ln(),i.precision=e,i.rounding=n,o.times(.5))):new i(NaN)};d.inverseSine=d.asin=function(){var e,n,t,r,o=this,i=o.constructor;return o.isZero()?new i(o):(n=o.abs().cmp(1),t=i.precision,r=i.rounding,n!==-1?n===0?(e=V(i,t+4,r).times(.5),e.s=o.s,e):new i(NaN):(i.precision=t+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=r,o.times(2)))};d.inverseTangent=d.atan=function(){var e,n,t,r,o,i,s,a,c,u=this,l=u.constructor,f=l.precision,m=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&f+4<=Me)return s=V(l,f+4,m).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(f+4<=Me)return s=V(l,f+4,m).times(.5),s.s=u.s,s}for(l.precision=a=f+10,l.rounding=1,t=Math.min(28,a/w+2|0),e=t;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(b=!1,n=Math.ceil(a/w),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[n]!==void 0)for(e=n;s.d[e]===i.d[e]&&e--;);return t&&(s=s.times(2<<t-1)),b=!0,g(s,l.precision=f,l.rounding=m,!0)};d.isFinite=function(){return!!this.d};d.isInteger=d.isInt=function(){return!!this.d&&L(this.e/w)>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 n,t,r,o,i,s,a,c,u=this,l=u.constructor,f=l.precision,m=l.rounding,p=5;if(e==null)e=new l(10),n=!0;else{if(e=new l(e),t=e.d,e.s<0||!t||!t[0]||e.eq(1))return new l(NaN);n=e.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new l(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(n)if(t.length>1)i=!0;else{for(o=t[0];o%10===0;)o/=10;i=o!==1}if(b=!1,a=f+p,s=j(u,a),r=n?Te(l,a+10):j(e,a),c=N(s,r,a,1),se(c.d,o=f,m))do if(a+=10,s=j(u,a),r=n?Te(l,a+10):j(e,a),c=N(s,r,a,1),!i){+M(c.d).slice(o+1,o+15)+1==1e14&&(c=g(c,f+1,0));break}while(se(c.d,o+=10,m));return b=!0,g(c,f,m)};d.minus=d.sub=function(e){var n,t,r,o,i,s,a,c,u,l,f,m,p=this,y=p.constructor;if(e=new y(e),!p.d||!e.d)return!p.s||!e.s?e=new y(NaN):p.d?e.s=-e.s:e=new y(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(u=p.d,m=e.d,a=y.precision,c=y.rounding,!u[0]||!m[0]){if(m[0])e.s=-e.s;else if(u[0])e=new y(p);else return new y(c===3?-0:0);return b?g(e,a,c):e}if(t=L(e.e/w),l=L(p.e/w),u=u.slice(),i=l-t,i){for(f=i<0,f?(n=u,i=-i,s=m.length):(n=m,t=l,s=u.length),r=Math.max(Math.ceil(a/w),s)+2,i>r&&(i=r,n.length=1),n.reverse(),r=i;r--;)n.push(0);n.reverse()}else{for(r=u.length,s=m.length,f=r<s,f&&(s=r),r=0;r<s;r++)if(u[r]!=m[r]){f=u[r]<m[r];break}i=0}for(f&&(n=u,u=m,m=n,e.s=-e.s),s=u.length,r=m.length-s;r>0;--r)u[s++]=0;for(r=m.length;r>i;){if(u[--r]<m[r]){for(o=r;o&&u[--o]===0;)u[o]=W-1;--u[o],u[r]+=W}u[r]-=m[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(e.d=u,e.e=ye(u,t),b?g(e,a,c):e):new y(c===3?-0:0)};d.modulo=d.mod=function(e){var n,t=this,r=t.constructor;return e=new r(e),!t.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||t.d&&!t.d[0]?g(new r(t),r.precision,r.rounding):(b=!1,r.modulo==9?(n=N(t,e.abs(),0,3,1),n.s*=e.s):n=N(t,e,0,r.modulo,1),n=n.times(e),b=!0,t.minus(n))};d.naturalExponential=d.exp=function(){return De(this)};d.naturalLogarithm=d.ln=function(){return j(this)};d.negated=d.neg=function(){var e=new this.constructor(this);return e.s=-e.s,g(e)};d.plus=d.add=function(e){var n,t,r,o,i,s,a,c,u,l,f=this,m=f.constructor;if(e=new m(e),!f.d||!e.d)return!f.s||!e.s?e=new m(NaN):f.d||(e=new m(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=m.precision,c=m.rounding,!u[0]||!l[0])return l[0]||(e=new m(f)),b?g(e,a,c):e;if(i=L(f.e/w),r=L(e.e/w),u=u.slice(),o=i-r,o){for(o<0?(t=u,o=-o,s=l.length):(t=l,r=i,s=u.length),i=Math.ceil(a/w),s=i>s?i+1:s+1,o>s&&(o=s,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,t=l,l=u,u=t),n=0;o;)n=(u[--o]=u[o]+l[o]+n)/W|0,u[o]%=W;for(n&&(u.unshift(n),++r),s=u.length;u[--s]==0;)u.pop();return e.d=u,e.e=ye(u,r),b?g(e,a,c):e};d.precision=d.sd=function(e){var n,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(z+e);return t.d?(n=nn(t.d),e&&t.e+1>n&&(n=t.e+1)):n=NaN,n};d.round=function(){var e=this,n=e.constructor;return g(new n(e),e.e+1,n.rounding)};d.sine=d.sin=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,n=r.rounding,r.precision=e+Math.max(t.e,t.sd())+w,r.rounding=1,t=Dn(r,sn(r,t)),r.precision=e,r.rounding=n,g(U>2?t.neg():t,e,n,!0)):new r(NaN)};d.squareRoot=d.sqrt=function(){var e,n,t,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?(n=M(a),(n.length+c)%2==0&&(n+="0"),u=Math.sqrt(n),c=L((c+1)/2)-(c<0||c%2),u==1/0?n="5e"+c:(n=u.toExponential(),n=n.slice(0,n.indexOf("e")+1)+c),r=new l(n)):r=new l(u.toString()),t=(c=l.precision)+3;;)if(i=r,r=i.plus(N(s,i,t+2,1)).times(.5),M(i.d).slice(0,t)===(n=M(r.d)).slice(0,t))if(n=n.slice(t-3,t+1),n=="9999"||!o&&n=="4999"){if(!o&&(g(i,c+1,0),i.times(i).eq(s))){r=i;break}t+=4,o=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(g(r,c+1,1),e=!r.times(r).eq(s));break}return b=!0,g(r,c,l.rounding,e)};d.tangent=d.tan=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,n=r.rounding,r.precision=e+10,r.rounding=1,t=t.sin(),t.s=1,t=N(t,new r(1).minus(t.times(t)).sqrt(),e+10,0),r.precision=e,r.rounding=n,g(U==2||U==4?t.neg():t,e,n,!0)):new r(NaN)};d.times=d.mul=function(e){var n,t,r,o,i,s,a,c,u,l=this,f=l.constructor,m=l.d,p=(e=new f(e)).d;if(e.s*=l.s,!m||!m[0]||!p||!p[0])return new f(!e.s||m&&!m[0]&&!p||p&&!p[0]&&!m?NaN:!m||!p?e.s/0:e.s*0);for(t=L(l.e/w)+L(e.e/w),c=m.length,u=p.length,c<u&&(i=m,m=p,p=i,s=c,c=u,u=s),i=[],s=c+u,r=s;r--;)i.push(0);for(r=u;--r>=0;){for(n=0,o=c+r;o>r;)a=i[o]+p[r]*m[o-r-1]+n,i[o--]=a%W|0,n=a/W|0;i[o]=(i[o]+n)%W|0}for(;!i[--s];)i.pop();return n?++t:i.shift(),e.d=i,e.e=ye(i,t),b?g(e,f.precision,f.rounding):e};d.toBinary=function(e,n){return Le(this,2,e,n)};d.toDecimalPlaces=d.toDP=function(e,n){var t=this,r=t.constructor;return t=new r(t),e===void 0?t:(v(e,0,Y),n===void 0?n=r.rounding:v(n,0,8),g(t,e+t.e+1,n))};d.toExponential=function(e,n){var t,r=this,o=r.constructor;return e===void 0?t=K(r,!0):(v(e,0,Y),n===void 0?n=o.rounding:v(n,0,8),r=g(new o(r),e+1,n),t=K(r,!0,e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};d.toFixed=function(e,n){var t,r,o=this,i=o.constructor;return e===void 0?t=K(o):(v(e,0,Y),n===void 0?n=i.rounding:v(n,0,8),r=g(new i(o),e+o.e+1,n),t=K(r,!1,e+r.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};d.toFraction=function(e){var n,t,r,o,i,s,a,c,u,l,f,m,p=this,y=p.d,T=p.constructor;if(!y)return new T(p);if(u=t=new T(1),r=c=new T(0),n=new T(r),i=n.e=nn(y)-p.e-1,s=i%w,n.d[0]=R(10,s<0?w+s:s),e==null)e=i>0?n:u;else{if(a=new T(e),!a.isInt()||a.lt(u))throw Error(z+a);e=a.gt(n)?i>0?n:u:a}for(b=!1,a=new T(M(y)),l=T.precision,T.precision=i=y.length*w*2;f=N(a,n,0,1,1),o=t.plus(f.times(r)),o.cmp(e)!=1;)t=r,r=o,o=u,u=c.plus(f.times(o)),c=o,o=n,n=a.minus(f.times(o)),a=o;return o=N(e.minus(t),r,0,1,1),c=c.plus(o.times(u)),t=t.plus(o.times(r)),c.s=u.s=p.s,m=N(u,r,i,1).minus(p).abs().cmp(N(c,t,i,1).minus(p).abs())<1?[u,r]:[c,t],T.precision=l,b=!0,m};d.toHexadecimal=d.toHex=function(e,n){return Le(this,16,e,n)};d.toNearest=function(e,n){var t=this,r=t.constructor;if(t=new r(t),e==null){if(!t.d)return t;e=new r(1),n=r.rounding}else{if(e=new r(e),n===void 0?n=r.rounding:v(n,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(b=!1,t=N(t,e,0,n,1).times(e),b=!0,g(t)):(e.s=t.s,t=e),t};d.toNumber=function(){return+this};d.toOctal=function(e,n){return Le(this,8,e,n)};d.toPower=d.pow=function(e){var n,t,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(R(+a,u));if(a=new c(a),a.eq(1))return a;if(r=c.precision,i=c.rounding,e.eq(1))return g(a,r,i);if(n=L(e.e/w),n>=e.d.length-1&&(t=u<0?-u:u)<=Bn)return o=tn(c,a,t,r),e.s<0?new c(1).div(o):g(o,r,i);if(s=a.s,s<0){if(n<e.d.length-1)return new c(NaN);if((e.d[n]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=R(+a,u),n=t==0||!isFinite(t)?L(u*(Math.log("0."+M(a.d))/Math.LN10+a.e+1)):new c(t+"").e,n>c.maxE+1||n<c.minE-1?new c(n>0?s/0:0):(b=!1,c.rounding=a.s=1,t=Math.min(12,(n+"").length),o=De(e.times(j(a,r+t)),r),o.d&&(o=g(o,r+5,1),se(o.d,r,i)&&(n=r+10,o=g(De(e.times(j(a,n+t)),n),n+5,1),+M(o.d).slice(r+1,r+15)+1==1e14&&(o=g(o,r+1,0)))),o.s=s,b=!0,c.rounding=i,g(o,r,i))};d.toPrecision=function(e,n){var t,r=this,o=r.constructor;return e===void 0?t=K(r,r.e<=o.toExpNeg||r.e>=o.toExpPos):(v(e,1,Y),n===void 0?n=o.rounding:v(n,0,8),r=g(new o(r),e,n),t=K(r,e<=r.e||r.e<=o.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+t:t};d.toSignificantDigits=d.toSD=function(e,n){var t=this,r=t.constructor;return e===void 0?(e=r.precision,n=r.rounding):(v(e,1,Y),n===void 0?n=r.rounding:v(n,0,8)),g(new r(t),e,n)};d.toString=function(){var e=this,n=e.constructor,t=K(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t};d.truncated=d.trunc=function(){return g(new this.constructor(this),this.e+1,1)};d.valueOf=d.toJSON=function(){var e=this,n=e.constructor,t=K(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+t:t};function M(e){var n,t,r,o=e.length-1,i="",s=e[0];if(o>0){for(i+=s,n=1;n<o;n++)r=e[n]+"",t=w-r.length,t&&(i+=Z(t)),i+=r;s=e[n],r=s+"",t=w-r.length,t&&(i+=Z(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function v(e,n,t){if(e!==~~e||e<n||e>t)throw Error(z+e)}function se(e,n,t,r){var o,i,s,a;for(i=e[0];i>=10;i/=10)--n;return--n<0?(n+=w,o=0):(o=Math.ceil((n+1)/w),n%=w),i=R(10,w-n),a=e[o]%i|0,r==null?n<3?(n==0?a=a/100|0:n==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==i||t>3&&a+1==i/2)&&(e[o+1]/i/100|0)==R(10,n-2)-1||(a==i/2||a==0)&&(e[o+1]/i/100|0)==0:n<4?(n==0?a=a/1e3|0:n==1?a=a/100|0:n==2&&(a=a/10|0),s=(r||t<4)&&a==9999||!r&&t>3&&a==4999):s=((r||t<4)&&a+1==i||!r&&t>3&&a+1==i/2)&&(e[o+1]/i/1e3|0)==R(10,n-3)-1,s}function ge(e,n,t){for(var r,o=[0],i,s=0,a=e.length;s<a;){for(i=o.length;i--;)o[i]*=n;for(o[0]+=Re.indexOf(e.charAt(s++)),r=0;r<o.length;r++)o[r]>t-1&&(o[r+1]===void 0&&(o[r+1]=0),o[r+1]+=o[r]/t|0,o[r]%=t)}return o.reverse()}function In(e,n){var t,r,o;if(n.isZero())return n;r=n.d.length,r<32?(t=Math.ceil(r/3),o=(1/xe(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),e.precision+=t,n=ee(e,1,n.times(o),new e(1));for(var i=t;i--;){var s=n.times(n);n=s.times(s).minus(s).times(8).plus(1)}return e.precision-=t,n}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 n(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 t(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,m,p,y,T,I,k,_,A,D,fe,q,ke,me,oe,Ce,O,de,pe=r.constructor,Be=r.s==o.s?1:-1,E=r.d,S=o.d;if(!E||!E[0]||!S||!S[0])return new pe(!r.s||!o.s||(E?S&&E[0]==S[0]:!S)?NaN:E&&E[0]==0||!S?Be*0:Be/0);for(c?(p=1,l=r.e-o.e):(c=W,p=w,l=L(r.e/p)-L(o.e/p)),O=S.length,oe=E.length,k=new pe(Be),_=k.d=[],f=0;S[f]==(E[f]||0);f++);if(S[f]>(E[f]||0)&&l--,i==null?(q=i=pe.precision,s=pe.rounding):a?q=i+(r.e-o.e)+1:q=i,q<0)_.push(1),y=!0;else{if(q=q/p+2|0,f=0,O==1){for(m=0,S=S[0],q++;(f<oe||m)&&q--;f++)ke=m*c+(E[f]||0),_[f]=ke/S|0,m=ke%S|0;y=m||f<oe}else{for(m=c/(S[0]+1)|0,m>1&&(S=e(S,m,c),E=e(E,m,c),O=S.length,oe=E.length),me=O,A=E.slice(0,O),D=A.length;D<O;)A[D++]=0;de=S.slice(),de.unshift(0),Ce=S[0],S[1]>=c/2&&++Ce;do m=0,u=n(S,A,O,D),u<0?(fe=A[0],O!=D&&(fe=fe*c+(A[1]||0)),m=fe/Ce|0,m>1?(m>=c&&(m=c-1),T=e(S,m,c),I=T.length,D=A.length,u=n(T,A,I,D),u==1&&(m--,t(T,O<I?de:S,I,c))):(m==0&&(u=m=1),T=S.slice()),I=T.length,I<D&&T.unshift(0),t(A,T,D,c),u==-1&&(D=A.length,u=n(S,A,O,D),u<1&&(m++,t(A,O<D?de:S,D,c))),D=A.length):u===0&&(m++,A=[0]),_[f++]=m,u&&A[0]?A[D++]=E[me]||0:(A=[E[me]],D=1);while((me++<oe||A[0]!==void 0)&&q--);y=A[0]!==void 0}_[0]||_.shift()}if(p==1)k.e=l,Je=y;else{for(f=1,m=_[0];m>=10;m/=10)f++;k.e=f+l*p-1,g(k,a?i+k.e+1:i,s,y)}return k}}();function g(e,n,t,r){var o,i,s,a,c,u,l,f,m,p=e.constructor;e:if(n!=null){if(f=e.d,!f)return e;for(o=1,a=f[0];a>=10;a/=10)o++;if(i=n-o,i<0)i+=w,s=n,l=f[m=0],c=l/R(10,o-s-1)%10|0;else if(m=Math.ceil((i+1)/w),a=f.length,m>=a)if(r){for(;a++<=m;)f.push(0);l=c=0,o=1,i%=w,s=i-w+1}else break e;else{for(l=a=f[m],o=1;a>=10;a/=10)o++;i%=w,s=i-w+o,c=s<0?0:l/R(10,o-s-1)%10|0}if(r=r||n<0||f[m+1]!==void 0||(s<0?l:l%R(10,o-s-1)),u=t<4?(c||r)&&(t==0||t==(e.s<0?3:2)):c>5||c==5&&(t==4||r||t==6&&(i>0?s>0?l/R(10,o-s):0:f[m-1])%10&1||t==(e.s<0?8:7)),n<1||!f[0])return f.length=0,u?(n-=e.e+1,f[0]=R(10,(w-n%w)%w),e.e=-n||0):f[0]=e.e=0,e;if(i==0?(f.length=m,a=1,m--):(f.length=m+1,a=R(10,w-i),f[m]=s>0?(l/R(10,o-s)%R(10,s)|0)*a:0),u)for(;;)if(m==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]==W&&(f[0]=1));break}else{if(f[m]+=a,f[m]!=W)break;f[m--]=0,a=1}for(i=f.length;f[--i]===0;)f.pop()}return b&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function K(e,n,t){if(!e.isFinite())return on(e);var r,o=e.e,i=M(e.d),s=i.length;return n?(t&&(r=t-s)>0?i=i.charAt(0)+"."+i.slice(1)+Z(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):o<0?(i="0."+Z(-o-1)+i,t&&(r=t-s)>0&&(i+=Z(r))):o>=s?(i+=Z(o+1-s),t&&(r=t-o-1)>0&&(i=i+"."+Z(r))):((r=o+1)<s&&(i=i.slice(0,r)+"."+i.slice(r)),t&&(r=t-s)>0&&(o+1===s&&(i+="."),i+=Z(r))),i}function ye(e,n){var t=e[0];for(n*=w;t>=10;t/=10)n++;return n}function Te(e,n,t){if(n>Rn)throw b=!0,t&&(e.precision=t),Error(Xe);return g(new e(he),n,1,!0)}function V(e,n,t){if(n>Me)throw Error(Xe);return g(new e(we),n,t,!0)}function nn(e){var n=e.length-1,t=n*w+1;if(n=e[n],n){for(;n%10==0;n/=10)t--;for(n=e[0];n>=10;n/=10)t++}return t}function Z(e){for(var n="";e--;)n+="0";return n}function tn(e,n,t,r){var o,i=new e(1),s=Math.ceil(r/w+4);for(b=!1;;){if(t%2&&(i=i.times(n),ze(i.d,s)&&(o=!0)),t=L(t/2),t===0){t=i.d.length-1,o&&i.d[t]===0&&++i.d[t];break}n=n.times(n),ze(n.d,s)}return b=!0,i}function je(e){return e.d[e.d.length-1]&1}function rn(e,n,t){for(var r,o=new e(n[0]),i=0;++i<n.length;)if(r=new e(n[i]),r.s)o[t](r)&&(o=r);else{o=r;break}return o}function De(e,n){var t,r,o,i,s,a,c,u=0,l=0,f=0,m=e.constructor,p=m.rounding,y=m.precision;if(!e.d||!e.d[0]||e.e>17)return new m(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(n==null?(b=!1,c=y):c=n,a=new m(.03125);e.e>-2;)e=e.times(a),f+=5;for(r=Math.log(R(2,f))/Math.LN10*2+5|0,c+=r,t=i=s=new m(1),m.precision=c;;){if(i=g(i.times(e),c,1),t=t.times(++l),a=s.plus(N(i,t,c,1)),M(a.d).slice(0,c)===M(s.d).slice(0,c)){for(o=f;o--;)s=g(s.times(s),c,1);if(n==null)if(u<3&&se(s.d,c-r,p,u))m.precision=c+=10,t=i=a=new m(1),l=0,u++;else return g(s,m.precision=y,p,b=!0);else return m.precision=y,s}s=a}}function j(e,n){var t,r,o,i,s,a,c,u,l,f,m,p=1,y=10,T=e,I=T.d,k=T.constructor,_=k.rounding,A=k.precision;if(T.s<0||!I||!I[0]||!T.e&&I[0]==1&&I.length==1)return new k(I&&!I[0]?-1/0:T.s!=1?NaN:I?0:T);if(n==null?(b=!1,l=A):l=n,k.precision=l+=y,t=M(I),r=t.charAt(0),Math.abs(i=T.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)T=T.times(e),t=M(T.d),r=t.charAt(0),p++;i=T.e,r>1?(T=new k("0."+t),i++):T=new k(r+"."+t.slice(1))}else return u=Te(k,l+2,A).times(i+""),T=j(new k(r+"."+t.slice(1)),l-y).plus(u),k.precision=A,n==null?g(T,A,_,b=!0):T;for(f=T,c=s=T=N(T.minus(1),T.plus(1),l,1),m=g(T.times(T),l,1),o=3;;){if(s=g(s.times(m),l,1),u=c.plus(N(s,new k(o),l,1)),M(u.d).slice(0,l)===M(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(Te(k,l+2,A).times(i+""))),c=N(c,new k(p),l,1),n==null)if(se(c.d,l-y,_,a))k.precision=l+=y,u=s=T=N(f.minus(1),f.plus(1),l,1),m=g(T.times(T),l,1),o=a=1;else return g(c,k.precision=A,_,b=!0);else return k.precision=A,c;c=u,o+=2}}function on(e){return String(e.s*e.s/0)}function Ee(e,n){var t,r,o;for((t=n.indexOf("."))>-1&&(n=n.replace(".","")),(r=n.search(/e/i))>0?(t<0&&(t=r),t+=+n.slice(r+1),n=n.substring(0,r)):t<0&&(t=n.length),r=0;n.charCodeAt(r)===48;r++);for(o=n.length;n.charCodeAt(o-1)===48;--o);if(n=n.slice(r,o),n){if(o-=r,e.e=t=t-r-1,e.d=[],r=(t+1)%w,t<0&&(r+=w),r<o){for(r&&e.d.push(+n.slice(0,r)),o-=w;r<o;)e.d.push(+n.slice(r,r+=w));n=n.slice(r),r=w-n.length}else r-=o;for(;r--;)n+="0";e.d.push(+n),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 Mn(e,n){var t,r,o,i,s,a,c,u,l;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),en.test(n))return Ee(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(kn.test(n))t=16,n=n.toLowerCase();else if(Sn.test(n))t=2;else if(Cn.test(n))t=8;else throw Error(z+n);for(i=n.search(/p/i),i>0?(c=+n.slice(i+1),n=n.substring(2,i)):n=n.slice(2),i=n.indexOf("."),s=i>=0,r=e.constructor,s&&(n=n.replace(".",""),a=n.length,i=a-i,o=tn(r,new r(t),i,i*2)),u=ge(n,t,W),l=u.length-1,i=l;u[i]===0;--i)u.pop();return i<0?new r(e.s*0):(e.e=ye(u,l),e.d=u,b=!1,s&&(e=N(e,o,a*4)),c&&(e=e.times(Math.abs(c)<54?R(2,c):Pe.pow(2,c))),b=!0,e)}function Dn(e,n){var t,r=n.d.length;if(r<3)return n.isZero()?n:ee(e,2,n,n);t=1.4*Math.sqrt(r),t=t>16?16:t|0,n=n.times(1/xe(5,t)),n=ee(e,2,n,n);for(var o,i=new e(5),s=new e(16),a=new e(20);t--;)o=n.times(n),n=n.times(i.plus(o.times(s.times(o).minus(a))));return n}function ee(e,n,t,r,o){var i,s,a,c,u=1,l=e.precision,f=Math.ceil(l/w);for(b=!1,c=t.times(t),a=new e(r);;){if(s=N(a.times(c),new e(n++*n++),l,1),a=o?r.plus(s):r.minus(s),r=N(s.times(c),new e(n++*n++),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 xe(e,n){for(var t=e;--n;)t*=e;return t}function sn(e,n){var t,r=n.s<0,o=V(e,e.precision,1),i=o.times(.5);if(n=n.abs(),n.lte(i))return U=r?4:1,n;if(t=n.divToInt(o),t.isZero())U=r?3:2;else{if(n=n.minus(t.times(o)),n.lte(i))return U=je(t)?r?2:3:r?4:1,n;U=je(t)?r?1:4:r?3:2}return n.minus(o).abs()}function Le(e,n,t,r){var o,i,s,a,c,u,l,f,m,p=e.constructor,y=t!==void 0;if(y?(v(t,1,Y),r===void 0?r=p.rounding:v(r,0,8)):(t=p.precision,r=p.rounding),!e.isFinite())l=on(e);else{for(l=K(e),s=l.indexOf("."),y?(o=2,n==16?t=t*4-3:n==8&&(t=t*3-2)):o=n,s>=0&&(l=l.replace(".",""),m=new p(1),m.e=l.length-s,m.d=ge(K(m),10,o),m.e=m.d.length),f=ge(l,10,o),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])l=y?"0p+0":"0";else{if(s<0?i--:(e=new p(e),e.d=f,e.e=i,e=N(e,m,t,r,0,o),f=e.d,i=e.e,u=Je),s=f[t],a=o/2,u=u||f[t+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[t-1]&1||r===(e.s<0?8:7)),f.length=t,u)for(;++f[--t]>o-1;)f[t]=0,t||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(s=0,l="";s<c;s++)l+=Re.charAt(f[s]);if(y){if(c>1)if(n==16||n==8){for(s=n==16?4:3,--c;c%s;c++)l+="0";for(f=ge(l,o,n),c=f.length;!f[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Re.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=(n==16?"0x":n==2?"0b":n==8?"0o":"")+l}return e.s<0?"-"+l:l}function ze(e,n){if(e.length>n)return e.length=n,!0}function En(e){return new this(e).abs()}function Ln(e){return new this(e).acos()}function vn(e){return new this(e).acosh()}function Fn(e,n){return new this(e).plus(n)}function _n(e){return new this(e).asin()}function On(e){return new this(e).asinh()}function Vn(e){return new this(e).atan()}function Wn(e){return new this(e).atanh()}function Kn(e,n){e=new this(e),n=new this(n);var t,r=this.precision,o=this.rounding,i=r+4;return!e.s||!n.s?t=new this(NaN):!e.d&&!n.d?(t=V(this,i,1).times(n.s>0?.25:.75),t.s=e.s):!n.d||e.isZero()?(t=n.s<0?V(this,r,o):new this(0),t.s=e.s):!e.d||n.isZero()?(t=V(this,i,1).times(.5),t.s=e.s):n.s<0?(this.precision=i,this.rounding=1,t=this.atan(N(e,n,i,1)),n=V(this,i,1),this.precision=r,this.rounding=o,t=e.s<0?t.minus(n):t.plus(n)):t=this.atan(N(e,n,i,1)),t}function qn(e){return new this(e).cbrt()}function Un(e){return g(e=new this(e),e.e+1,2)}function Gn(e,n,t){return new this(e).clamp(n,t)}function Hn(e){if(!e||typeof e!="object")throw Error(be+"Object expected");var n,t,r,o=e.defaults===!0,i=["precision",1,Y,"rounding",0,8,"toExpNeg",-$,0,"toExpPos",0,$,"maxE",0,$,"minE",-$,0,"modulo",0,9];for(n=0;n<i.length;n+=3)if(t=i[n],o&&(this[t]=Ie[t]),(r=e[t])!==void 0)if(L(r)===r&&r>=i[n+1]&&r<=i[n+2])this[t]=r;else throw Error(z+t+": "+r);if(t="crypto",o&&(this[t]=Ie[t]),(r=e[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Qe);else this[t]=!1;else throw Error(z+t+": "+r);return this}function Zn(e){return new this(e).cos()}function jn(e){return new this(e).cosh()}function an(e){var n,t,r;function o(i){var s,a,c,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,Ye(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 Ee(u,i.toString())}else if(c!=="string")throw Error(z+i);return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),en.test(i)?Ee(u,i):Mn(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=Hn,o.clone=an,o.isDecimal=Ye,o.abs=En,o.acos=Ln,o.acosh=vn,o.add=Fn,o.asin=_n,o.asinh=On,o.atan=Vn,o.atanh=Wn,o.atan2=Kn,o.cbrt=qn,o.ceil=Un,o.clamp=Gn,o.cos=Zn,o.cosh=jn,o.div=zn,o.exp=Yn,o.floor=Jn,o.hypot=Xn,o.ln=Qn,o.log=$n,o.log10=nt,o.log2=et,o.max=tt,o.min=rt,o.mod=it,o.mul=ot,o.pow=st,o.random=at,o.round=ut,o.sign=ct,o.sin=lt,o.sinh=ft,o.sqrt=mt,o.sub=dt,o.sum=pt,o.tan=gt,o.tanh=ht,o.trunc=wt,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<r.length;)e.hasOwnProperty(t=r[n++])||(e[t]=this[t]);return o.config(e),o}function zn(e,n){return new this(e).div(n)}function Yn(e){return new this(e).exp()}function Jn(e){return g(e=new this(e),e.e+1,3)}function Xn(){var e,n,t=new this(0);for(b=!1,e=0;e<arguments.length;)if(n=new this(arguments[e++]),n.d)t.d&&(t=t.plus(n.times(n)));else{if(n.s)return b=!0,new this(1/0);t=n}return b=!0,t.sqrt()}function Ye(e){return e instanceof Pe||e&&e.toStringTag===$e||!1}function Qn(e){return new this(e).ln()}function $n(e,n){return new this(e).log(n)}function et(e){return new this(e).log(2)}function nt(e){return new this(e).log(10)}function tt(){return rn(this,arguments,"lt")}function rt(){return rn(this,arguments,"gt")}function it(e,n){return new this(e).mod(n)}function ot(e,n){return new this(e).mul(n)}function st(e,n){return new this(e).pow(n)}function at(e){var n,t,r,o,i=0,s=new this(1),a=[];if(e===void 0?e=this.precision:v(e,1,Y),r=Math.ceil(e/w),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(r));i<r;)o=n[i],o>=429e7?n[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=o%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(r*=4);i<r;)o=n[i]+(n[i+1]<<8)+(n[i+2]<<16)+((n[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(n,i):(a.push(o%1e7),i+=4);i=r/4}else throw Error(Qe);else for(;i<r;)a[i++]=Math.random()*1e7|0;for(r=a[--i],e%=w,r&&e&&(o=R(10,w-e),a[i]=(r/o|0)*o);a[i]===0;i--)a.pop();if(i<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=w)a.shift();for(r=1,o=a[0];o>=10;o/=10)r++;r<w&&(t-=w-r)}return s.e=t,s.d=a,s}function ut(e){return g(e=new this(e),e.e+1,this.rounding)}function ct(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function lt(e){return new this(e).sin()}function ft(e){return new this(e).sinh()}function mt(e){return new this(e).sqrt()}function dt(e,n){return new this(e).sub(n)}function pt(){var e=0,n=arguments,t=new this(n[e]);for(b=!1;t.s&&++e<n.length;)t=t.plus(n[e]);return b=!0,g(t,this.precision,this.rounding)}function gt(e){return new this(e).tan()}function ht(e){return new this(e).tanh()}function wt(e){return g(e=new this(e),e.e+1,1)}d[Symbol.for("nodejs.util.inspect.custom")]=d.toString;d[Symbol.toStringTag]="Decimal";var Pe=d.constructor=an(Ie);he=new Pe(he);we=new Pe(we);import Ct from"big.js";import or from"bn.js";import{get as un,set as Tt}from"lodash";var ve=class{constructor(n){this.logLevel=n.logLevel!==void 0?n.logLevel:0,this.name=n.name}set level(n){this.logLevel=n}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(n){return n<=this.logLevel}error(...n){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...n),this):this}logWithError(...n){let t=n.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(t)}warning(...n){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...n),this):this}info(...n){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...n),this):this}debug(...n){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...n),this):this}},cn={},bt={};function F(e){let n=un(cn,e);if(!n){let t=un(bt,e);n=new ve({name:e,logLevel:t}),Tt(cn,e,n)}return n}import yt from"toformat";var xt=yt,ae=xt;import Ne from"big.js";import At from"bn.js";import Nt from"decimal.js-light";import ue from"bn.js";var ln=9007199254740991;function G(e){let n=F("Raydium_parseBigNumberish");if(e instanceof ue)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new ue(e);n.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&n.logWithError(`BigNumberish number underflow: ${e}`),(e>=ln||e<=-ln)&&n.logWithError(`BigNumberish number overflow: ${e}`),new ue(String(e))):typeof e=="bigint"?new ue(e.toString()):(n.error(`invalid BigNumberish value: ${e}`),new ue(0))}var Ae=F("module/fraction"),Fe=ae(Ne),ce=ae(Nt),St={[0]:ce.ROUND_DOWN,[1]:ce.ROUND_HALF_UP,[2]:ce.ROUND_UP},kt={[0]:Ne.roundDown,[1]:Ne.roundHalfUp,[2]:Ne.roundUp},C=class{constructor(n,t=new At(1)){this.numerator=G(n),this.denominator=G(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new C(this.denominator,this.numerator)}add(n){let t=n instanceof C?n:new C(G(n));return this.denominator.eq(t.denominator)?new C(this.numerator.add(t.numerator),this.denominator):new C(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(n){let t=n instanceof C?n:new C(G(n));return this.denominator.eq(t.denominator)?new C(this.numerator.sub(t.numerator),this.denominator):new C(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(n){let t=n instanceof C?n:new C(G(n));return new C(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(n){let t=n instanceof C?n:new C(G(n));return new C(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(n,t={groupSeparator:""},r=1){Number.isInteger(n)||Ae.logWithError(`${n} is not an integer.`),n<=0&&Ae.logWithError(`${n} is not positive.`),ce.set({precision:n+1,rounding:St[r]});let o=new ce(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(n);return o.toFormat(o.decimalPlaces(),t)}toFixed(n,t={groupSeparator:""},r=1){return Number.isInteger(n)||Ae.logWithError(`${n} is not an integer.`),n<0&&Ae.logWithError(`${n} is negative.`),Fe.DP=n,Fe.RM=kt[r]||1,new Fe(this.numerator.toString()).div(this.denominator.toString()).toFormat(n,t)}isZero(){return this.numerator.isZero()}};var pr=F("Raydium_amount"),gr=ae(Ct);import{PublicKey as Rt}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as fn}from"@solana/spl-token";var mn={chainId:101,address:Rt.default.toBase58(),programId:fn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},X={chainId:101,address:"So11111111111111111111111111111111111111112",programId:fn.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};import{PublicKey as Ve}from"@solana/web3.js";import{PublicKey as B,SystemProgram as dn,SYSVAR_RENT_PUBKEY as It}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Mt}from"@solana/spl-token";function _e({pubkey:e,isSigner:n=!1,isWritable:t=!0}){return{pubkey:e,isWritable:t,isSigner:n}}var Ar=[_e({pubkey:Mt,isWritable:!1}),_e({pubkey:dn.programId,isWritable:!1}),_e({pubkey:It,isWritable:!1})];function pn({publicKey:e,transformSol:n}){let t=gn(e.toString());if(t instanceof B)return n&&t.equals(le)?Oe:t;if(n&&t.toString()===le.toBase58())return Oe;if(typeof t=="string"){if(t===B.default.toBase58())return B.default;try{return new B(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function gn(e){try{return new B(e)}catch{return e}}var Nr=new B("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Sr=new B("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),kr=new B("SysvarRent111111111111111111111111111111111"),Cr=new B("SysvarC1ock11111111111111111111111111111111"),Br=new B("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Rr=new B("Sysvar1nstructions1111111111111111111111111"),Ir=dn.programId,Mr=new B("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Dr=new B("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Er=new B("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Lr=new B("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),vr=new B("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Fr=new B("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),_r=new B("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Or=new B("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Vr=new B("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Wr=new B("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Kr=new B("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),Oe=new B("So11111111111111111111111111111111111111112"),le=B.default;var We=class{constructor({mint:n,decimals:t,symbol:r,name:o,skipMint:i=!1,isToken2022:s=!1}){if(n===le.toBase58()||n instanceof Ve&&le.equals(n)){this.decimals=X.decimals,this.symbol=X.symbol,this.name=X.name,this.mint=new Ve(X.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=r||n.toString().substring(0,6),this.name=o||n.toString().substring(0,6),this.mint=i?Ve.default:pn({publicKey:n}),this.isToken2022=s}equals(n){return this===n?!0:this.mint.equals(n.mint)}},ne=We;ne.WSOL=new We(Q(J({},X),{mint:X.address}));var Ke=class{constructor({decimals:n,symbol:t="UNKNOWN",name:r="UNKNOWN"}){this.decimals=n,this.symbol=t,this.name=r}equals(n){return this===n}},Se=Ke;Se.SOL=new Ke(mn);import Dt from"bn.js";var $r=new C(new Dt(100));var oi=F("Raydium_price");var Et=new H(0),Li=new H(1),vi=new H(2),Fi=new H(3),_i=new H(5),Bt=new H(10),Oi=new H(100),Vi=new H(1e3),Wi=new H(1e4);function qe(e,n=1,t=[]){let r=[...e];if(n<=0)return t;for(;r.length;)t.push(r.splice(0,n));return t}import{PublicKey as mo}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as go}from"@solana/spl-token";import{ComputeBudgetProgram as zi,Keypair as Xi,PublicKey as Qi,Transaction as eo,TransactionMessage as to,VersionedTransaction as ro}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as ao}from"@solana/spl-token";var uo=F("Raydium_txUtil");import{PublicKey as h}from"@solana/web3.js";var bo=new h("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),yo=new h("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),xo=new h("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Po=new h("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Ao=new h("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),No=new h("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),So=new h("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),ko=new h("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Co=new h("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Bo=new h("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Ro=new h("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),Io=new h("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Mo=new h("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),Do=new h("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Eo=new h("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),Lo=new h("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),vo=new h("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Fo=new h("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),_o=new h("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Oo=new h("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),Vo=new h("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Wo=new h("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),Ko=new h("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),qo=new h("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Uo=new h("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),Go=new h("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),Ho=new h("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),Zo=new h("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),jo=new h("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),zo=new h("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),Yo=new h("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var Jo={OPEN_BOOK_PROGRAM:new h("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new h("Ray1111111111111111111111111111111111111111"),AMM_V4:new h("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new h("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new h("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new h("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new h("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new h("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new h("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new h("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new h("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new h("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:h.default,Router:new h("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new h("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new h("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new h("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new h("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new h("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new h("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new h("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new h("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new h("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new h("Ray1111111111111111111111111111111111111111")};import $o from"bn.js";import{PublicKey as ms,sendAndConfirmTransaction as ds,SystemProgram as hs,Transaction as ws,TransactionMessage as bs,VersionedTransaction as ys}from"@solana/web3.js";import Ps from"axios";import{PublicKey as Rs}from"@solana/web3.js";import Ms from"bn.js";import Ot from"bn.js";var Fs=new Ot(1e6);import{MINT_SIZE as fa,TOKEN_PROGRAM_ID as ma,getTransferFeeConfig as da,unpackMint as pa}from"@solana/spl-token";var Ue=F("Raydium_accountInfo_util");async function bn(e,n,t){let{batchRequest:r,commitment:o="confirmed",chunkCount:i=100}=J({batchRequest:!1},t),s=qe(n,i),a=new Array(s.length).fill([]);if(r){let c=s.map(f=>{let m=e._buildArgs([f.map(p=>p.toBase58())],o,"base64");return{methodName:"getMultipleAccounts",args:m}}),u=qe(c,10);a=(await(await Promise.all(u.map(async f=>await e._rpcBatchRequest(f)))).flat()).map(f=>(f.error&&Ue.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${f.error.message}`),f.result.value.map(m=>{if(m){let{data:p,executable:y,lamports:T,owner:I,rentEpoch:k}=m;return p.length!==2&&p[1]!=="base64"&&Ue.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:y,lamports:T,owner:new Vt(I),rentEpoch:k}}return null})))}else try{a=await Promise.all(s.map(c=>e.getMultipleAccountsInfo(c,o)))}catch(c){c instanceof Error&&Ue.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function vt({connection:e,address:n,cluster:t="mainnet"}){let r=await bn(e,[...new Set(n.map(i=>i.toString()))].map(i=>new Ge(i))),o={};for(let i=0;i<n.length;i++){let s=r[i],a=n[i];if(!s)continue;let c=new ie({key:a,state:ie.deserialize(s.data)});o[a.toString()]=c,t==="devnet"?re[a.toString()]=c:te[a.toString()]=c}return o}var te={},Ft=async e=>{let n="AcL1Vo8oy1ULiavEcjSUcwfBSForXMudcZvDZy5nzJkU";if(te[n])return te;let t=new Ge(n),r=await e.getAccountInfo(t);return r&&(te[n]=new ie({key:t,state:ie.deserialize(r.data)})),te},re={},_t=async e=>{let n="EFhMuDw1PKEuckuFRW9PavNfTH4LKP5uKHgyXDmWpFCq";if(re[n])return re;let t=new Ge(n),r=await e.getAccountInfo(t);return r&&(re[n]=new ie({key:t,state:ie.deserialize(r.data)})),re};export{re as DEV_LOOKUP_TABLE_CACHE,te as LOOKUP_TABLE_CACHE,_t as getDevLookupTableCache,Ft as getMainLookupTableCache,vt as getMultipleLookupTableInfo}; //# sourceMappingURL=lookupTable.mjs.map