@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 65.8 kB
JavaScript
var Jn=Object.create;var Ke=Object.defineProperty,$n=Object.defineProperties,ei=Object.getOwnPropertyDescriptor,ti=Object.getOwnPropertyDescriptors,ni=Object.getOwnPropertyNames,jt=Object.getOwnPropertySymbols,ii=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty,ri=Object.prototype.propertyIsEnumerable;var Qt=(t,e,n)=>e in t?Ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Z=(t,e)=>{for(var n in e||(e={}))Jt.call(e,n)&&Qt(t,n,e[n]);if(jt)for(var n of jt(e))ri.call(e,n)&&Qt(t,n,e[n]);return t},$=(t,e)=>$n(t,ti(e));var oi=(t,e)=>{for(var n in e)Ke(t,n,{get:e[n],enumerable:!0})},$t=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ni(e))!Jt.call(t,r)&&r!==n&&Ke(t,r,{get:()=>e[r],enumerable:!(i=ei(e,r))||i.enumerable});return t};var L=(t,e,n)=>(n=t!=null?Jn(ii(t)):{},$t(e||!t||!t.__esModule?Ke(n,"default",{value:t,enumerable:!0}):n,t)),si=t=>$t(Ke({},"__esModule",{value:!0}),t);var $r={};oi($r,{Curve:()=>He});module.exports=si($r);var Q=L(require("bn.js"));var Pe=9e15,de=1e9,Pt="0123456789abcdef",Je="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",$e="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",At={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Pe,maxE:Pe,crypto:!1},rn,ae,T=!0,tt="[DecimalError] ",me=tt+"Invalid argument: ",on=tt+"Precision limit exceeded",sn=tt+"crypto unavailable",an="[object Decimal]",q=Math.floor,D=Math.pow,ai=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ui=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,ci=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,un=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,te=1e7,h=7,li=9007199254740991,mi=Je.length-1,ht=$e.length-1,p={toStringTag:an};p.absoluteValue=p.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),y(t)};p.ceil=function(){return y(new this.constructor(this),this.e+1,2)};p.clampedTo=p.clamp=function(t,e){var n,i=this,r=i.constructor;if(t=new r(t),e=new r(e),!t.s||!e.s)return new r(NaN);if(t.gt(e))throw Error(me+e);return n=i.cmp(t),n<0?t:i.cmp(e)>0?e:new r(i)};p.comparedTo=p.cmp=function(t){var e,n,i,r,o=this,s=o.d,a=(t=new o.constructor(t)).d,c=o.s,u=t.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(o.e!==t.e)return o.e>t.e^c<0?1:-1;for(i=s.length,r=a.length,e=0,n=i<r?i:r;e<n;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return i===r?0:i>r^c<0?1:-1};p.cosine=p.cos=function(){var t,e,n=this,i=n.constructor;return n.d?n.d[0]?(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+h,i.rounding=1,n=di(i,pn(i,n)),i.precision=t,i.rounding=e,y(ae==2||ae==3?n.neg():n,t,e,!0)):new i(1):new i(NaN)};p.cubeRoot=p.cbrt=function(){var t,e,n,i,r,o,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(T=!1,o=l.s*D(l.s*l,1/3),!o||Math.abs(o)==1/0?(n=_(l.d),t=l.e,(o=(t-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=D(n,1/3),t=q((t+1)/3)-(t%3==(t<0?-1:2)),o==1/0?n="5e"+t:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),i=new m(n),i.s=l.s):i=new m(o.toString()),s=(t=m.precision)+3;;)if(a=i,c=a.times(a).times(a),u=c.plus(l),i=N(u.plus(l).times(a),u.plus(c),s+2,1),_(a.d).slice(0,s)===(n=_(i.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!r&&n=="4999"){if(!r&&(y(a,t+1,0),a.times(a).times(a).eq(l))){i=a;break}s+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(y(i,t+1,1),e=!i.times(i).times(i).eq(l));break}return T=!0,y(i,t,m.rounding,e)};p.decimalPlaces=p.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-q(this.e/h))*h,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};p.dividedBy=p.div=function(t){return N(this,new this.constructor(t))};p.dividedToIntegerBy=p.divToInt=function(t){var e=this,n=e.constructor;return y(N(e,new n(t),0,1,1),n.precision,n.rounding)};p.equals=p.eq=function(t){return this.cmp(t)===0};p.floor=function(){return y(new this.constructor(this),this.e+1,3)};p.greaterThan=p.gt=function(t){return this.cmp(t)>0};p.greaterThanOrEqualTo=p.gte=function(t){var e=this.cmp(t);return e==1||e===0};p.hyperbolicCosine=p.cosh=function(){var t,e,n,i,r,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;n=s.precision,i=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(t=Math.ceil(r/3),e=(1/it(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=Ae(s,1,o.times(e),new s(1),!0);for(var c,u=t,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return y(o,s.precision=n,s.rounding=i,!0)};p.hyperbolicSine=p.sinh=function(){var t,e,n,i,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,n=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,i=r.d.length,i<3)r=Ae(o,2,r,r,!0);else{t=1.4*Math.sqrt(i),t=t>16?16:t|0,r=r.times(1/it(5,t)),r=Ae(o,2,r,r,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);t--;)s=r.times(r),r=r.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=e,o.rounding=n,y(r,e,n,!0)};p.hyperbolicTangent=p.tanh=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+7,i.rounding=1,N(n.sinh(),n.cosh(),i.precision=t,i.rounding=e)):new i(n.s)};p.inverseCosine=p.acos=function(){var t=this,e=t.constructor,n=t.abs().cmp(1),i=e.precision,r=e.rounding;return n!==-1?n===0?t.isNeg()?ie(e,i,r):new e(0):new e(NaN):t.isZero()?ie(e,i+4,r).times(.5):(e.precision=i+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=i,e.rounding=r,t.times(2))};p.inverseHyperbolicCosine=p.acosh=function(){var t,e,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(t=i.precision,e=i.rounding,i.precision=t+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,T=!1,n=n.times(n).minus(1).sqrt().plus(n),T=!0,i.precision=t,i.rounding=e,n.ln()):new i(n)};p.inverseHyperbolicSine=p.asinh=function(){var t,e,n=this,i=n.constructor;return!n.isFinite()||n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,T=!1,n=n.times(n).plus(1).sqrt().plus(n),T=!0,i.precision=t,i.rounding=e,n.ln())};p.inverseHyperbolicTangent=p.atanh=function(){var t,e,n,i,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(t=o.precision,e=o.rounding,i=r.sd(),Math.max(i,t)<2*-r.e-1?y(new o(r),t,e,!0):(o.precision=n=i-r.e,r=N(r.plus(1),new o(1).minus(r),n+t,1),o.precision=t+4,o.rounding=1,r=r.ln(),o.precision=t,o.rounding=e,r.times(.5))):new o(NaN)};p.inverseSine=p.asin=function(){var t,e,n,i,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),n=o.precision,i=o.rounding,e!==-1?e===0?(t=ie(o,n+4,i).times(.5),t.s=r.s,t):new o(NaN):(o.precision=n+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=i,r.times(2)))};p.inverseTangent=p.atan=function(){var t,e,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=ht)return s=ie(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=ht)return s=ie(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,n=Math.min(28,a/h+2|0),t=n;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(T=!1,e=Math.ceil(a/h),i=1,c=u.times(u),s=new l(u),r=u;t!==-1;)if(r=r.times(c),o=s.minus(r.div(i+=2)),r=r.times(c),s=o.plus(r.div(i+=2)),s.d[e]!==void 0)for(t=e;s.d[t]===o.d[t]&&t--;);return n&&(s=s.times(2<<n-1)),T=!0,y(s,l.precision=m,l.rounding=d,!0)};p.isFinite=function(){return!!this.d};p.isInteger=p.isInt=function(){return!!this.d&&q(this.e/h)>this.d.length-2};p.isNaN=function(){return!this.s};p.isNegative=p.isNeg=function(){return this.s<0};p.isPositive=p.isPos=function(){return this.s>0};p.isZero=function(){return!!this.d&&this.d[0]===0};p.lessThan=p.lt=function(t){return this.cmp(t)<0};p.lessThanOrEqualTo=p.lte=function(t){return this.cmp(t)<1};p.logarithm=p.log=function(t){var e,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,f=5;if(t==null)t=new l(10),e=!0;else{if(t=new l(t),n=t.d,t.s<0||!n||!n[0]||t.eq(1))return new l(NaN);e=t.eq(10)}if(n=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(e)if(n.length>1)o=!0;else{for(r=n[0];r%10===0;)r/=10;o=r!==1}if(T=!1,a=m+f,s=le(u,a),i=e?et(l,a+10):le(t,a),c=N(s,i,a,1),Re(c.d,r=m,d))do if(a+=10,s=le(u,a),i=e?et(l,a+10):le(t,a),c=N(s,i,a,1),!o){+_(c.d).slice(r+1,r+15)+1==1e14&&(c=y(c,m+1,0));break}while(Re(c.d,r+=10,d));return T=!0,y(c,m,d)};p.minus=p.sub=function(t){var e,n,i,r,o,s,a,c,u,l,m,d,f=this,b=f.constructor;if(t=new b(t),!f.d||!t.d)return!f.s||!t.s?t=new b(NaN):f.d?t.s=-t.s:t=new b(t.d||f.s!==t.s?f:NaN),t;if(f.s!=t.s)return t.s=-t.s,f.plus(t);if(u=f.d,d=t.d,a=b.precision,c=b.rounding,!u[0]||!d[0]){if(d[0])t.s=-t.s;else if(u[0])t=new b(f);else return new b(c===3?-0:0);return T?y(t,a,c):t}if(n=q(t.e/h),l=q(f.e/h),u=u.slice(),o=l-n,o){for(m=o<0,m?(e=u,o=-o,s=d.length):(e=d,n=l,s=u.length),i=Math.max(Math.ceil(a/h),s)+2,o>i&&(o=i,e.length=1),e.reverse(),i=o;i--;)e.push(0);e.reverse()}else{for(i=u.length,s=d.length,m=i<s,m&&(s=i),i=0;i<s;i++)if(u[i]!=d[i]){m=u[i]<d[i];break}o=0}for(m&&(e=u,u=d,d=e,t.s=-t.s),s=u.length,i=d.length-s;i>0;--i)u[s++]=0;for(i=d.length;i>o;){if(u[--i]<d[i]){for(r=i;r&&u[--r]===0;)u[r]=te-1;--u[r],u[i]+=te}u[i]-=d[i]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(t.d=u,t.e=nt(u,n),T?y(t,a,c):t):new b(c===3?-0:0)};p.modulo=p.mod=function(t){var e,n=this,i=n.constructor;return t=new i(t),!n.d||!t.s||t.d&&!t.d[0]?new i(NaN):!t.d||n.d&&!n.d[0]?y(new i(n),i.precision,i.rounding):(T=!1,i.modulo==9?(e=N(n,t.abs(),0,3,1),e.s*=t.s):e=N(n,t,0,i.modulo,1),e=e.times(t),T=!0,n.minus(e))};p.naturalExponential=p.exp=function(){return Tt(this)};p.naturalLogarithm=p.ln=function(){return le(this)};p.negated=p.neg=function(){var t=new this.constructor(this);return t.s=-t.s,y(t)};p.plus=p.add=function(t){var e,n,i,r,o,s,a,c,u,l,m=this,d=m.constructor;if(t=new d(t),!m.d||!t.d)return!m.s||!t.s?t=new d(NaN):m.d||(t=new d(t.d||m.s===t.s?m:NaN)),t;if(m.s!=t.s)return t.s=-t.s,m.minus(t);if(u=m.d,l=t.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(t=new d(m)),T?y(t,a,c):t;if(o=q(m.e/h),i=q(t.e/h),u=u.slice(),r=o-i,r){for(r<0?(n=u,r=-r,s=l.length):(n=l,i=o,s=u.length),o=Math.ceil(a/h),s=o>s?o+1:s+1,r>s&&(r=s,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for(s=u.length,r=l.length,s-r<0&&(r=s,n=l,l=u,u=n),e=0;r;)e=(u[--r]=u[r]+l[r]+e)/te|0,u[r]%=te;for(e&&(u.unshift(e),++i),s=u.length;u[--s]==0;)u.pop();return t.d=u,t.e=nt(u,i),T?y(t,a,c):t};p.precision=p.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(me+t);return n.d?(e=cn(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};p.round=function(){var t=this,e=t.constructor;return y(new e(t),t.e+1,e.rounding)};p.sine=p.sin=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+h,i.rounding=1,n=fi(i,pn(i,n)),i.precision=t,i.rounding=e,y(ae>2?n.neg():n,t,e,!0)):new i(NaN)};p.squareRoot=p.sqrt=function(){var t,e,n,i,r,o,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(T=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=_(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=q((c+1)/2)-(c<0||c%2),u==1/0?e="5e"+c:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),i=new l(e)):i=new l(u.toString()),n=(c=l.precision)+3;;)if(o=i,i=o.plus(N(s,o,n+2,1)).times(.5),_(o.d).slice(0,n)===(e=_(i.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!r&&e=="4999"){if(!r&&(y(o,c+1,0),o.times(o).eq(s))){i=o;break}n+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(y(i,c+1,1),t=!i.times(i).eq(s));break}return T=!0,y(i,c,l.rounding,t)};p.tangent=p.tan=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+10,i.rounding=1,n=n.sin(),n.s=1,n=N(n,new i(1).minus(n.times(n)).sqrt(),t+10,0),i.precision=t,i.rounding=e,y(ae==2||ae==4?n.neg():n,t,e,!0)):new i(NaN)};p.times=p.mul=function(t){var e,n,i,r,o,s,a,c,u,l=this,m=l.constructor,d=l.d,f=(t=new m(t)).d;if(t.s*=l.s,!d||!d[0]||!f||!f[0])return new m(!t.s||d&&!d[0]&&!f||f&&!f[0]&&!d?NaN:!d||!f?t.s/0:t.s*0);for(n=q(l.e/h)+q(t.e/h),c=d.length,u=f.length,c<u&&(o=d,d=f,f=o,s=c,c=u,u=s),o=[],s=c+u,i=s;i--;)o.push(0);for(i=u;--i>=0;){for(e=0,r=c+i;r>i;)a=o[r]+f[i]*d[r-i-1]+e,o[r--]=a%te|0,e=a/te|0;o[r]=(o[r]+e)%te|0}for(;!o[--s];)o.pop();return e?++n:o.shift(),t.d=o,t.e=nt(o,n),T?y(t,m.precision,m.rounding):t};p.toBinary=function(t,e){return kt(this,2,t,e)};p.toDecimalPlaces=p.toDP=function(t,e){var n=this,i=n.constructor;return n=new i(n),t===void 0?n:(z(t,0,de),e===void 0?e=i.rounding:z(e,0,8),y(n,t+n.e+1,e))};p.toExponential=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=re(i,!0):(z(t,0,de),e===void 0?e=r.rounding:z(e,0,8),i=y(new r(i),t+1,e),n=re(i,!0,t+1)),i.isNeg()&&!i.isZero()?"-"+n:n};p.toFixed=function(t,e){var n,i,r=this,o=r.constructor;return t===void 0?n=re(r):(z(t,0,de),e===void 0?e=o.rounding:z(e,0,8),i=y(new o(r),t+r.e+1,e),n=re(i,!1,t+i.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};p.toFraction=function(t){var e,n,i,r,o,s,a,c,u,l,m,d,f=this,b=f.d,g=f.constructor;if(!b)return new g(f);if(u=n=new g(1),i=c=new g(0),e=new g(i),o=e.e=cn(b)-f.e-1,s=o%h,e.d[0]=D(10,s<0?h+s:s),t==null)t=o>0?e:u;else{if(a=new g(t),!a.isInt()||a.lt(u))throw Error(me+a);t=a.gt(e)?o>0?e:u:a}for(T=!1,a=new g(_(b)),l=g.precision,g.precision=o=b.length*h*2;m=N(a,e,0,1,1),r=n.plus(m.times(i)),r.cmp(t)!=1;)n=i,i=r,r=u,u=c.plus(m.times(r)),c=r,r=e,e=a.minus(m.times(r)),a=r;return r=N(t.minus(n),i,0,1,1),c=c.plus(r.times(u)),n=n.plus(r.times(i)),c.s=u.s=f.s,d=N(u,i,o,1).minus(f).abs().cmp(N(c,n,o,1).minus(f).abs())<1?[u,i]:[c,n],g.precision=l,T=!0,d};p.toHexadecimal=p.toHex=function(t,e){return kt(this,16,t,e)};p.toNearest=function(t,e){var n=this,i=n.constructor;if(n=new i(n),t==null){if(!n.d)return n;t=new i(1),e=i.rounding}else{if(t=new i(t),e===void 0?e=i.rounding:z(e,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(T=!1,n=N(n,t,0,e,1).times(t),T=!0,y(n)):(t.s=n.s,n=t),n};p.toNumber=function(){return+this};p.toOctal=function(t,e){return kt(this,8,t,e)};p.toPower=p.pow=function(t){var e,n,i,r,o,s,a=this,c=a.constructor,u=+(t=new c(t));if(!a.d||!t.d||!a.d[0]||!t.d[0])return new c(D(+a,u));if(a=new c(a),a.eq(1))return a;if(i=c.precision,o=c.rounding,t.eq(1))return y(a,i,o);if(e=q(t.e/h),e>=t.d.length-1&&(n=u<0?-u:u)<=li)return r=ln(c,a,n,i),t.s<0?new c(1).div(r):y(r,i,o);if(s=a.s,s<0){if(e<t.d.length-1)return new c(NaN);if((t.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=D(+a,u),e=n==0||!isFinite(n)?q(u*(Math.log("0."+_(a.d))/Math.LN10+a.e+1)):new c(n+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(T=!1,c.rounding=a.s=1,n=Math.min(12,(e+"").length),r=Tt(t.times(le(a,i+n)),i),r.d&&(r=y(r,i+5,1),Re(r.d,i,o)&&(e=i+10,r=y(Tt(t.times(le(a,e+n)),e),e+5,1),+_(r.d).slice(i+1,i+15)+1==1e14&&(r=y(r,i+1,0)))),r.s=s,T=!0,c.rounding=o,y(r,i,o))};p.toPrecision=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=re(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(z(t,1,de),e===void 0?e=r.rounding:z(e,0,8),i=y(new r(i),t,e),n=re(i,t<=i.e||i.e<=r.toExpNeg,t)),i.isNeg()&&!i.isZero()?"-"+n:n};p.toSignificantDigits=p.toSD=function(t,e){var n=this,i=n.constructor;return t===void 0?(t=i.precision,e=i.rounding):(z(t,1,de),e===void 0?e=i.rounding:z(e,0,8)),y(new i(n),t,e)};p.toString=function(){var t=this,e=t.constructor,n=re(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};p.truncated=p.trunc=function(){return y(new this.constructor(this),this.e+1,1)};p.valueOf=p.toJSON=function(){var t=this,e=t.constructor,n=re(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function _(t){var e,n,i,r=t.length-1,o="",s=t[0];if(r>0){for(o+=s,e=1;e<r;e++)i=t[e]+"",n=h-i.length,n&&(o+=ce(n)),o+=i;s=t[e],i=s+"",n=h-i.length,n&&(o+=ce(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function z(t,e,n){if(t!==~~t||t<e||t>n)throw Error(me+t)}function Re(t,e,n,i){var r,o,s,a;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=h,r=0):(r=Math.ceil((e+1)/h),e%=h),o=D(10,h-e),a=t[r]%o|0,i==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==o||n>3&&a+1==o/2)&&(t[r+1]/o/100|0)==D(10,e-2)-1||(a==o/2||a==0)&&(t[r+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(i||n<4)&&a==9999||!i&&n>3&&a==4999):s=((i||n<4)&&a+1==o||!i&&n>3&&a+1==o/2)&&(t[r+1]/o/1e3|0)==D(10,e-3)-1,s}function je(t,e,n){for(var i,r=[0],o,s=0,a=t.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=Pt.indexOf(t.charAt(s++)),i=0;i<r.length;i++)r[i]>n-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/n|0,r[i]%=n)}return r.reverse()}function di(t,e){var n,i,r;if(e.isZero())return e;i=e.d.length,i<32?(n=Math.ceil(i/3),r=(1/it(4,n)).toString()):(n=16,r="2.3283064365386962890625e-10"),t.precision+=n,e=Ae(t,1,e.times(r),new t(1));for(var o=n;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return t.precision-=n,e}var N=function(){function t(i,r,o){var s,a=0,c=i.length;for(i=i.slice();c--;)s=i[c]*r+a,i[c]=s%o|0,a=s/o|0;return a&&i.unshift(a),i}function e(i,r,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(i[a]!=r[a]){c=i[a]>r[a]?1:-1;break}return c}function n(i,r,o,s){for(var a=0;o--;)i[o]-=a,a=i[o]<r[o]?1:0,i[o]=a*s+i[o]-r[o];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,o,s,a,c){var u,l,m,d,f,b,g,K,x,v,k,E,we,J,Ce,ze,Ne,yt,ee,Ze,Ye=i.constructor,wt=i.s==r.s?1:-1,W=i.d,R=r.d;if(!W||!W[0]||!R||!R[0])return new Ye(!i.s||!r.s||(W?R&&W[0]==R[0]:!R)?NaN:W&&W[0]==0||!R?wt*0:wt/0);for(c?(f=1,l=i.e-r.e):(c=te,f=h,l=q(i.e/f)-q(r.e/f)),ee=R.length,Ne=W.length,x=new Ye(wt),v=x.d=[],m=0;R[m]==(W[m]||0);m++);if(R[m]>(W[m]||0)&&l--,o==null?(J=o=Ye.precision,s=Ye.rounding):a?J=o+(i.e-r.e)+1:J=o,J<0)v.push(1),b=!0;else{if(J=J/f+2|0,m=0,ee==1){for(d=0,R=R[0],J++;(m<Ne||d)&&J--;m++)Ce=d*c+(W[m]||0),v[m]=Ce/R|0,d=Ce%R|0;b=d||m<Ne}else{for(d=c/(R[0]+1)|0,d>1&&(R=t(R,d,c),W=t(W,d,c),ee=R.length,Ne=W.length),ze=ee,k=W.slice(0,ee),E=k.length;E<ee;)k[E++]=0;Ze=R.slice(),Ze.unshift(0),yt=R[0],R[1]>=c/2&&++yt;do d=0,u=e(R,k,ee,E),u<0?(we=k[0],ee!=E&&(we=we*c+(k[1]||0)),d=we/yt|0,d>1?(d>=c&&(d=c-1),g=t(R,d,c),K=g.length,E=k.length,u=e(g,k,K,E),u==1&&(d--,n(g,ee<K?Ze:R,K,c))):(d==0&&(u=d=1),g=R.slice()),K=g.length,K<E&&g.unshift(0),n(k,g,E,c),u==-1&&(E=k.length,u=e(R,k,ee,E),u<1&&(d++,n(k,ee<E?Ze:R,E,c))),E=k.length):u===0&&(d++,k=[0]),v[m++]=d,u&&k[0]?k[E++]=W[ze]||0:(k=[W[ze]],E=1);while((ze++<Ne||k[0]!==void 0)&&J--);b=k[0]!==void 0}v[0]||v.shift()}if(f==1)x.e=l,rn=b;else{for(m=1,d=v[0];d>=10;d/=10)m++;x.e=m+l*f-1,y(x,a?o+x.e+1:o,s,b)}return x}}();function y(t,e,n,i){var r,o,s,a,c,u,l,m,d,f=t.constructor;e:if(e!=null){if(m=t.d,!m)return t;for(r=1,a=m[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=h,s=e,l=m[d=0],c=l/D(10,r-s-1)%10|0;else if(d=Math.ceil((o+1)/h),a=m.length,d>=a)if(i){for(;a++<=d;)m.push(0);l=c=0,r=1,o%=h,s=o-h+1}else break e;else{for(l=a=m[d],r=1;a>=10;a/=10)r++;o%=h,s=o-h+r,c=s<0?0:l/D(10,r-s-1)%10|0}if(i=i||e<0||m[d+1]!==void 0||(s<0?l:l%D(10,r-s-1)),u=n<4?(c||i)&&(n==0||n==(t.s<0?3:2)):c>5||c==5&&(n==4||i||n==6&&(o>0?s>0?l/D(10,r-s):0:m[d-1])%10&1||n==(t.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=t.e+1,m[0]=D(10,(h-e%h)%h),t.e=-e||0):m[0]=t.e=0,t;if(o==0?(m.length=d,a=1,d--):(m.length=d+1,a=D(10,h-o),m[d]=s>0?(l/D(10,r-s)%D(10,s)|0)*a:0),u)for(;;)if(d==0){for(o=1,s=m[0];s>=10;s/=10)o++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(t.e++,m[0]==te&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=te)break;m[d--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return T&&(t.e>f.maxE?(t.d=null,t.e=NaN):t.e<f.minE&&(t.e=0,t.d=[0])),t}function re(t,e,n){if(!t.isFinite())return dn(t);var i,r=t.e,o=_(t.d),s=o.length;return e?(n&&(i=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+ce(i):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):r<0?(o="0."+ce(-r-1)+o,n&&(i=n-s)>0&&(o+=ce(i))):r>=s?(o+=ce(r+1-s),n&&(i=n-r-1)>0&&(o=o+"."+ce(i))):((i=r+1)<s&&(o=o.slice(0,i)+"."+o.slice(i)),n&&(i=n-s)>0&&(r+1===s&&(o+="."),o+=ce(i))),o}function nt(t,e){var n=t[0];for(e*=h;n>=10;n/=10)e++;return e}function et(t,e,n){if(e>mi)throw T=!0,n&&(t.precision=n),Error(on);return y(new t(Je),e,1,!0)}function ie(t,e,n){if(e>ht)throw Error(on);return y(new t($e),e,n,!0)}function cn(t){var e=t.length-1,n=e*h+1;if(e=t[e],e){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function ce(t){for(var e="";t--;)e+="0";return e}function ln(t,e,n,i){var r,o=new t(1),s=Math.ceil(i/h+4);for(T=!1;;){if(n%2&&(o=o.times(e),tn(o.d,s)&&(r=!0)),n=q(n/2),n===0){n=o.d.length-1,r&&o.d[n]===0&&++o.d[n];break}e=e.times(e),tn(e.d,s)}return T=!0,o}function en(t){return t.d[t.d.length-1]&1}function mn(t,e,n){for(var i,r,o=new t(e[0]),s=0;++s<e.length;){if(r=new t(e[s]),!r.s){o=r;break}i=o.cmp(r),(i===n||i===0&&o.s===n)&&(o=r)}return o}function Tt(t,e){var n,i,r,o,s,a,c,u=0,l=0,m=0,d=t.constructor,f=d.rounding,b=d.precision;if(!t.d||!t.d[0]||t.e>17)return new d(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:0/0);for(e==null?(T=!1,c=b):c=e,a=new d(.03125);t.e>-2;)t=t.times(a),m+=5;for(i=Math.log(D(2,m))/Math.LN10*2+5|0,c+=i,n=o=s=new d(1),d.precision=c;;){if(o=y(o.times(t),c,1),n=n.times(++l),a=s.plus(N(o,n,c,1)),_(a.d).slice(0,c)===_(s.d).slice(0,c)){for(r=m;r--;)s=y(s.times(s),c,1);if(e==null)if(u<3&&Re(s.d,c-i,f,u))d.precision=c+=10,n=o=a=new d(1),l=0,u++;else return y(s,d.precision=b,f,T=!0);else return d.precision=b,s}s=a}}function le(t,e){var n,i,r,o,s,a,c,u,l,m,d,f=1,b=10,g=t,K=g.d,x=g.constructor,v=x.rounding,k=x.precision;if(g.s<0||!K||!K[0]||!g.e&&K[0]==1&&K.length==1)return new x(K&&!K[0]?-1/0:g.s!=1?NaN:K?0:g);if(e==null?(T=!1,l=k):l=e,x.precision=l+=b,n=_(K),i=n.charAt(0),Math.abs(o=g.e)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)g=g.times(t),n=_(g.d),i=n.charAt(0),f++;o=g.e,i>1?(g=new x("0."+n),o++):g=new x(i+"."+n.slice(1))}else return u=et(x,l+2,k).times(o+""),g=le(new x(i+"."+n.slice(1)),l-b).plus(u),x.precision=k,e==null?y(g,k,v,T=!0):g;for(m=g,c=s=g=N(g.minus(1),g.plus(1),l,1),d=y(g.times(g),l,1),r=3;;){if(s=y(s.times(d),l,1),u=c.plus(N(s,new x(r),l,1)),_(u.d).slice(0,l)===_(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(et(x,l+2,k).times(o+""))),c=N(c,new x(f),l,1),e==null)if(Re(c.d,l-b,v,a))x.precision=l+=b,u=s=g=N(m.minus(1),m.plus(1),l,1),d=y(g.times(g),l,1),r=a=1;else return y(c,x.precision=k,v,T=!0);else return x.precision=k,c;c=u,r+=2}}function dn(t){return String(t.s*t.s/0)}function Qe(t,e){var n,i,r;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(n<0&&(n=i),n+=+e.slice(i+1),e=e.substring(0,i)):n<0&&(n=e.length),i=0;e.charCodeAt(i)===48;i++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(i,r),e){if(r-=i,t.e=n=n-i-1,t.d=[],i=(n+1)%h,n<0&&(i+=h),i<r){for(i&&t.d.push(+e.slice(0,i)),r-=h;i<r;)t.d.push(+e.slice(i,i+=h));e=e.slice(i),i=h-e.length}else i-=r;for(;i--;)e+="0";t.d.push(+e),T&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function pi(t,e){var n,i,r,o,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),un.test(e))return Qe(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(ui.test(e))n=16,e=e.toLowerCase();else if(ai.test(e))n=2;else if(ci.test(e))n=8;else throw Error(me+e);for(o=e.search(/p/i),o>0?(c=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,i=t.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=ln(i,new i(n),o,o*2)),u=je(e,n,te),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new i(t.s*0):(t.e=nt(u,l),t.d=u,T=!1,s&&(t=N(t,r,a*4)),c&&(t=t.times(Math.abs(c)<54?D(2,c):Le.pow(2,c))),T=!0,t)}function fi(t,e){var n,i=e.d.length;if(i<3)return e.isZero()?e:Ae(t,2,e,e);n=1.4*Math.sqrt(i),n=n>16?16:n|0,e=e.times(1/it(5,n)),e=Ae(t,2,e,e);for(var r,o=new t(5),s=new t(16),a=new t(20);n--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function Ae(t,e,n,i,r){var o,s,a,c,u=1,l=t.precision,m=Math.ceil(l/h);for(T=!1,c=n.times(n),a=new t(i);;){if(s=N(a.times(c),new t(e++*e++),l,1),a=r?i.plus(s):i.minus(s),i=N(s.times(c),new t(e++*e++),l,1),s=a.plus(i),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=i,i=s,s=o,u++}return T=!0,s.d.length=m+1,s}function it(t,e){for(var n=t;--e;)n*=t;return n}function pn(t,e){var n,i=e.s<0,r=ie(t,t.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return ae=i?4:1,e;if(n=e.divToInt(r),n.isZero())ae=i?3:2;else{if(e=e.minus(n.times(r)),e.lte(o))return ae=en(n)?i?2:3:i?4:1,e;ae=en(n)?i?1:4:i?3:2}return e.minus(r).abs()}function kt(t,e,n,i){var r,o,s,a,c,u,l,m,d,f=t.constructor,b=n!==void 0;if(b?(z(n,1,de),i===void 0?i=f.rounding:z(i,0,8)):(n=f.precision,i=f.rounding),!t.isFinite())l=dn(t);else{for(l=re(t),s=l.indexOf("."),b?(r=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):r=e,s>=0&&(l=l.replace(".",""),d=new f(1),d.e=l.length-s,d.d=je(re(d),10,r),d.e=d.d.length),m=je(l,10,r),o=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=b?"0p+0":"0";else{if(s<0?o--:(t=new f(t),t.d=m,t.e=o,t=N(t,d,n,i,0,r),m=t.d,o=t.e,u=rn),s=m[n],a=r/2,u=u||m[n+1]!==void 0,u=i<4?(s!==void 0||u)&&(i===0||i===(t.s<0?3:2)):s>a||s===a&&(i===4||u||i===6&&m[n-1]&1||i===(t.s<0?8:7)),m.length=n,u)for(;++m[--n]>r-1;)m[n]=0,n||(++o,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=Pt.charAt(m[s]);if(b){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=je(l,r,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Pt.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>c)for(o-=c;o--;)l+="0";else o<c&&(l=l.slice(0,o)+"."+l.slice(o))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return t.s<0?"-"+l:l}function tn(t,e){if(t.length>e)return t.length=e,!0}function bi(t){return new this(t).abs()}function gi(t){return new this(t).acos()}function yi(t){return new this(t).acosh()}function wi(t,e){return new this(t).plus(e)}function Pi(t){return new this(t).asin()}function Ai(t){return new this(t).asinh()}function hi(t){return new this(t).atan()}function Ti(t){return new this(t).atanh()}function ki(t,e){t=new this(t),e=new this(e);var n,i=this.precision,r=this.rounding,o=i+4;return!t.s||!e.s?n=new this(NaN):!t.d&&!e.d?(n=ie(this,o,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?ie(this,i,r):new this(0),n.s=t.s):!t.d||e.isZero()?(n=ie(this,o,1).times(.5),n.s=t.s):e.s<0?(this.precision=o,this.rounding=1,n=this.atan(N(t,e,o,1)),e=ie(this,o,1),this.precision=i,this.rounding=r,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(N(t,e,o,1)),n}function Bi(t){return new this(t).cbrt()}function xi(t){return y(t=new this(t),t.e+1,2)}function Ii(t,e,n){return new this(t).clamp(e,n)}function Si(t){if(!t||typeof t!="object")throw Error(tt+"Object expected");var e,n,i,r=t.defaults===!0,o=["precision",1,de,"rounding",0,8,"toExpNeg",-Pe,0,"toExpPos",0,Pe,"maxE",0,Pe,"minE",-Pe,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(n=o[e],r&&(this[n]=At[n]),(i=t[n])!==void 0)if(q(i)===i&&i>=o[e+1]&&i<=o[e+2])this[n]=i;else throw Error(me+n+": "+i);if(n="crypto",r&&(this[n]=At[n]),(i=t[n])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(sn);else this[n]=!1;else throw Error(me+n+": "+i);return this}function Ci(t){return new this(t).cos()}function Ni(t){return new this(t).cosh()}function fn(t){var e,n,i;function r(o){var s,a,c,u=this;if(!(u instanceof r))return new r(o);if(u.constructor=r,nn(o)){u.s=o.s,T?!o.d||o.e>r.maxE?(u.e=NaN,u.d=null):o.e<r.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(c=typeof o,c==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;T?s>r.maxE?(u.e=NaN,u.d=null):s<r.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return Qe(u,o.toString())}if(c==="string")return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),un.test(o)?Qe(u,o):pi(u,o);if(c==="bigint")return o<0?(o=-o,u.s=-1):u.s=1,Qe(u,o.toString());throw Error(me+o)}if(r.prototype=p,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Si,r.clone=fn,r.isDecimal=nn,r.abs=bi,r.acos=gi,r.acosh=yi,r.add=wi,r.asin=Pi,r.asinh=Ai,r.atan=hi,r.atanh=Ti,r.atan2=ki,r.cbrt=Bi,r.ceil=xi,r.clamp=Ii,r.cos=Ci,r.cosh=Ni,r.div=Ki,r.exp=Ri,r.floor=Li,r.hypot=Fi,r.ln=Mi,r.log=Oi,r.log10=Ei,r.log2=vi,r.max=Di,r.min=_i,r.mod=Vi,r.mul=Wi,r.pow=qi,r.random=Gi,r.round=Ui,r.sign=Xi,r.sin=Hi,r.sinh=zi,r.sqrt=Zi,r.sub=Yi,r.sum=ji,r.tan=Qi,r.tanh=Ji,r.trunc=$i,t===void 0&&(t={}),t&&t.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)t.hasOwnProperty(n=i[e++])||(t[n]=this[n]);return r.config(t),r}function Ki(t,e){return new this(t).div(e)}function Ri(t){return new this(t).exp()}function Li(t){return y(t=new this(t),t.e+1,3)}function Fi(){var t,e,n=new this(0);for(T=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)n.d&&(n=n.plus(e.times(e)));else{if(e.s)return T=!0,new this(1/0);n=e}return T=!0,n.sqrt()}function nn(t){return t instanceof Le||t&&t.toStringTag===an||!1}function Mi(t){return new this(t).ln()}function Oi(t,e){return new this(t).log(e)}function vi(t){return new this(t).log(2)}function Ei(t){return new this(t).log(10)}function Di(){return mn(this,arguments,-1)}function _i(){return mn(this,arguments,1)}function Vi(t,e){return new this(t).mod(e)}function Wi(t,e){return new this(t).mul(e)}function qi(t,e){return new this(t).pow(e)}function Gi(t){var e,n,i,r,o=0,s=new this(1),a=[];if(t===void 0?t=this.precision:z(t,1,de),i=Math.ceil(t/h),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));o<i;)r=e[o],r>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);o<i;)r=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(r%1e7),o+=4);o=i/4}else throw Error(sn);else for(;o<i;)a[o++]=Math.random()*1e7|0;for(i=a[--o],t%=h,i&&t&&(r=D(10,h-t),a[o]=(i/r|0)*r);a[o]===0;o--)a.pop();if(o<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=h)a.shift();for(i=1,r=a[0];r>=10;r/=10)i++;i<h&&(n-=h-i)}return s.e=n,s.d=a,s}function Ui(t){return y(t=new this(t),t.e+1,this.rounding)}function Xi(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function Hi(t){return new this(t).sin()}function zi(t){return new this(t).sinh()}function Zi(t){return new this(t).sqrt()}function Yi(t,e){return new this(t).sub(e)}function ji(){var t=0,e=arguments,n=new this(e[t]);for(T=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return T=!0,y(n,this.precision,this.rounding)}function Qi(t){return new this(t).tan()}function Ji(t){return new this(t).tanh()}function $i(t){return y(t=new this(t),t.e+1,1)}p[Symbol.for("nodejs.util.inspect.custom")]=p.toString;p[Symbol.toStringTag]="Decimal";var Le=p.constructor=fn(At);Je=new Le(Je);$e=new Le($e);var I=Le;var tr=require("@solana/web3.js");var Fe=require("lodash");var Bt=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let n=e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(", ");throw new Error(n)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},bn={},er={};function U(t){let e=(0,Fe.get)(bn,t);if(!e){let n=(0,Fe.get)(er,t);e=new Bt({name:t,logLevel:n}),(0,Fe.set)(bn,t,e)}return e}var rt=require("@solana/spl-token"),uo=U("Raydium_accountInfo_util");var ne=L(require("bn.js"));var hn=L(require("big.js")),sr=L(require("bn.js"));var yn=L(require("toformat")),nr=yn.default,Me=nr;var Oe=L(require("big.js")),Pn=L(require("bn.js")),An=L(require("decimal.js-light"));var he=L(require("bn.js"));var wn=9007199254740991;function oe(t){let e=U("Raydium_parseBigNumberish");if(t instanceof he.default)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new he.default(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=wn||t<=-wn)&&e.logWithError(`BigNumberish number overflow: ${t}`),new he.default(String(t))):typeof t=="bigint"?new he.default(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new he.default(0))}var st=U("module/fraction"),xt=Me(Oe.default),ve=Me(An.default),rr={[0]:ve.ROUND_DOWN,[1]:ve.ROUND_HALF_UP,[2]:ve.ROUND_UP},or={[0]:Oe.default.roundDown,[1]:Oe.default.roundHalfUp,[2]:Oe.default.roundUp},F=class{constructor(e,n=new Pn.default(1)){this.numerator=oe(e),this.denominator=oe(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new F(this.denominator,this.numerator)}add(e){let n=e instanceof F?e:new F(oe(e));return this.denominator.eq(n.denominator)?new F(this.numerator.add(n.numerator),this.denominator):new F(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof F?e:new F(oe(e));return this.denominator.eq(n.denominator)?new F(this.numerator.sub(n.numerator),this.denominator):new F(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof F?e:new F(oe(e));return new F(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof F?e:new F(oe(e));return new F(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},i=1){Number.isInteger(e)||st.logWithError(`${e} is not an integer.`),e<=0&&st.logWithError(`${e} is not positive.`),ve.set({precision:e+1,rounding:rr[i]});let r=new ve(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),n)}toFixed(e,n={groupSeparator:""},i=1){return Number.isInteger(e)||st.logWithError(`${e} is not an integer.`),e<0&&st.logWithError(`${e} is negative.`),xt.DP=e,xt.RM=or[i]||1,new xt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var Co=U("Raydium_amount"),No=Me(hn.default);var Tn=require("@solana/web3.js"),It=require("@solana/spl-token"),St={chainId:101,address:Tn.PublicKey.default.toBase58(),programId:It.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},pe={chainId:101,address:"So11111111111111111111111111111111111111112",programId:It.TOKEN_PROGRAM_ID.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"}};var at=require("@solana/web3.js");var S=require("@solana/web3.js"),kn=require("@solana/spl-token");function Ct({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var Fo=[Ct({pubkey:kn.TOKEN_PROGRAM_ID,isWritable:!1}),Ct({pubkey:S.SystemProgram.programId,isWritable:!1}),Ct({pubkey:S.SYSVAR_RENT_PUBKEY,isWritable:!1})];function Bn({publicKey:t,transformSol:e}){let n=xn(t.toString());if(n instanceof S.PublicKey)return e&&n.equals(Ee)?ot:n;if(e&&n.toString()===Ee.toBase58())return ot;if(typeof n=="string"){if(n===S.PublicKey.default.toBase58())return S.PublicKey.default;try{return new S.PublicKey(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function xn(t){try{return new S.PublicKey(t)}catch{return t}}var ur=new S.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),cr=new S.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),lr=new S.PublicKey("SysvarRent111111111111111111111111111111111"),Mo=new S.PublicKey("SysvarC1ock11111111111111111111111111111111"),In=new S.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Oo=new S.PublicKey("Sysvar1nstructions1111111111111111111111111"),vo=S.SystemProgram.programId,Eo=new S.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Do=new S.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),_o=new S.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Vo=new S.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Wo=new S.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),qo=new S.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Go=new S.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Uo=new S.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Xo=new S.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Ho=new S.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),zo=new S.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),ot=new S.PublicKey("So11111111111111111111111111111111111111112"),Ee=S.PublicKey.default;var Nt=class{constructor({mint:e,decimals:n,symbol:i,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===Ee.toBase58()||e instanceof at.PublicKey&&Ee.equals(e)){this.decimals=pe.decimals,this.symbol=pe.symbol,this.name=pe.name,this.mint=new at.PublicKey(pe.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=i||e.toString().substring(0,6),this.name=r||e.toString().substring(0,6),this.mint=o?at.PublicKey.default:Bn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},fe=Nt;fe.WSOL=new Nt($(Z({},pe),{mint:pe.address}));var Kt=class{constructor({decimals:e,symbol:n="UNKNOWN",name:i="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=i}equals(e){return this===e}},ut=Kt;ut.SOL=new Kt(St);var Sn=L(require("bn.js"));var is=new F(new Sn.default(100));var cs=U("Raydium_price");var mr=new ne.default(0),vs=new ne.default(1),Es=new ne.default(2),Ds=new ne.default(3),_s=new ne.default(5),ar=new ne.default(10),Vs=new ne.default(100),Ws=new ne.default(1e3),qs=new ne.default(1e4);function Cn(t,e,n){return t.mul(e).add(n).sub(new ne.default(1)).div(n)}var fr=require("@solana/web3.js"),br=require("@solana/spl-token");var Te=require("@solana/web3.js");var dr=require("@solana/spl-token"),ta=U("Raydium_txUtil");var w=require("@solana/web3.js"),oa=new w.PublicKey("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),sa=new w.PublicKey("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),aa=new w.PublicKey("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),ua=new w.PublicKey("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),ca=new w.PublicKey("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),la=new w.PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),ma=new w.PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),da=new w.PublicKey("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),pa=new w.PublicKey("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),fa=new w.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),gr=new w.PublicKey("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),yr=new w.PublicKey("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),wr=new w.PublicKey("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),ba=new w.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),ga=new w.PublicKey("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),ya=new w.PublicKey("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),wa=new w.PublicKey("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Pa=new w.PublicKey("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Aa=new w.PublicKey("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),ha=new w.PublicKey("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),Ta=new w.PublicKey("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),ka=new w.PublicKey("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),Ba=new w.PublicKey("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),xa=new w.PublicKey("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Ia=new w.PublicKey("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),Sa=new w.PublicKey("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),Ca=new w.PublicKey("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),Na=new w.PublicKey("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),Ka=new w.PublicKey("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),Ra=new w.PublicKey("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),La=new w.PublicKey("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var Fa={OPEN_BOOK_PROGRAM:new w.PublicKey("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new w.PublicKey("Ray1111111111111111111111111111111111111111"),AMM_V4:new w.PublicKey("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new w.PublicKey("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new w.PublicKey("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new w.PublicKey("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new w.PublicKey("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new w.PublicKey("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new w.PublicKey("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new w.PublicKey("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new w.PublicKey("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new w.PublicKey("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:w.PublicKey.default,Router:new w.PublicKey("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new w.PublicKey("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new w.PublicKey("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new w.PublicKey("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new w.PublicKey("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new w.PublicKey("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new w.PublicKey("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new w.PublicKey("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new w.PublicKey("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new w.PublicKey("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new w.PublicKey("Ray1111111111111111111111111111111111111111")};var V=L(require("bn.js")),De=1e4;function Mt(t,e){let{div:n,mod:i}=t.divmod(e);return i.gt(new V.default(0))?n.add(new V.default(1)):n}function ge(t,e){if(t.isZero())return new V.default(0);let n=t.div(e);return n.isZero()?new V.default(1):t.mod(e).gt(new V.default(0))?n.add(new V.default(1)):n}function Ot(t,e,n){if(e===void 0)return{amount:t,fee:void 0,expirationTime:void 0};let i=Math.floor(n/432e3),r=i<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,o=new V.default(r.maximumFee.toString()),s=i<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*432e3-n)*400/1e3:void 0,a=Mt(t.mul(new V.default(r.transferFeeBasisPoints)),new V.default(De)),c=a.gt(o)?o:a;return{amount:t,fee:c,expirationTime:s}}function vt(t,e,n){if(e===void 0)return{amount:t,fee:void 0,expirationTime:void 0};let i=Math.floor(n/432e3),r=i<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,o=new V.default(r.maximumFee.toString()),s=i<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*432e3-n)*400/1e3:void 0;if(r.transferFeeBasisPoints===De){let a=new V.default(r.maximumFee.toString());return{amount:t.add(a),fee:a,expirationTime:s}}else{let a=Mt(t.mul(new V.default(De)),new V.default(De-r.transferFeeBasisPoints)),c=new V.default(r.maximumFee.toString()),u=a.sub(t).gt(c)?t.add(c):a,l=Mt(u.mul(new V.default(r.transferFeeBasisPoints)),new V.default(De)),m=l.gt(o)?o:l;return{amount:u,fee:m,expirationTime:s}}}var Kn=require("@solana/web3.js");var ke=require("@solana/web3.js"),hr=L(require("axios"));var Tr=require("@solana/web3.js"),kr=L(require("bn.js"));var Rn=L(require("bn.js")),ye=new Rn.default(1e6);var _e=L(require("bn.js"));var be=class{static getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i}){throw Error()}static getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r}){throw Error()}static getPoolPrice({poolInfo:e,decimalA:n,decimalB:i}){throw Error()}static getPoolEndPrice({supply:e,totalSell:n,totalLockedAmount:i,totalFundRaising:r,migrateFee:o,decimalA:s,decimalB:a}){throw Error()}static getPoolEndPriceReal({poolInfo:e,decimalA:n,decimalB:i}){throw Error()}static getInitParam({supply:e,totalFundRaising:n,totalSell:i,totalLockedAmount:r,migrateFee:o}){throw Error()}static buyExactIn({poolInfo:e,amount:n}){throw Error()}static buyExactOut({poolInfo:e,amount:n}){throw Error()}static sellExactIn({poolInfo:e,amount:n}){throw Error()}static sellExactOut({poolInfo:e,amount:n}){throw Error()}};var lt=class extends be{static getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i}){return new I(e.virtualB.toString()).div(e.virtualA.toString()).mul(10**(n-i))}static getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r}){return new I(n.toString()).div(e.toString()).mul(10**(i-r))}static getPoolPrice({poolInfo:e,decimalA:n,decimalB:i}){return new I(e.virtualB.add(e.realB).toString()).div(e.virtualA.sub(e.realA).toString()).mul(10**(n-i))}static getPoolEndPrice({supply:e,totalSell:n,totalLockedAmount:i,totalFundRaising:r,migrateFee:o,decimalA:s,decimalB:a}){return new I(r.sub(o).toString()).div(e.sub(n).sub(i).toString()).mul(10**(s-a))}static getPoolEndPriceReal({poolInfo:e,decimalA:n,decimalB:i}){let r=e.totalSellA.sub(e.realA),o=e.totalFundRaisingB.sub(e.realB);return new I(e.virtualB.add(e.realB.add(o)).toString()).div(e.virtualA.sub(e.realA.add(r)).toString()).mul(10**(n-i))}static getInitParam({supply:e,totalFundRaising:n,totalSell:i,totalLockedAmount:r,migrateFee:o}){if(e.lte(i))throw Error("supply need gt total sell");let s=e.sub(i).sub(r);if(s.lte(new _e.default(0)))throw Error("supplyMinusSellLocked <= 0");let a=n.sub(o);if(a.lte(new _e.default(0)))throw Error("tfMinusMf <= 0");let c=a.mul(i).mul(i).div(s),u=a.mul(i).div(s).sub(n),l=c.div(u),m=n.mul(n).div(u);if(l.lt(new _e.default(0))||m.lt(new _e.default(0)))throw Error("invalid input 0");return{a:l,b:m,c:i}}static buyExactIn({poolInfo:e,amount:n}){return this.getAmountOut({amountIn:n,inputReserve:e.virtualB.add(e.realB),outputReserve:e.virtualA.sub(e.realA)})}static buyExactOut({poolInfo:e,amount:n}){return this.getAmountIn({amountOut:n,inputReserve:e.virtualB.add(e.realB),outputReserve:e.virtualA.sub(e.realA)})}static sellExactIn({poolInfo:e,amount:n}){return this.getAmountOut({amountIn:n,inputReserve:e.virtualA.sub(e.realA),outputReserve:e.virtualB.add(e.realB)})}static sellExactOut({poolInfo:e,amount:n}){return this.getAmountIn({amountOut:n,inputReserve:e.virtualA.sub(e.realA),outputReserve:e.virtualB.add(e.realB)})}static getAmountOut({amountIn:e,inputReserve:n,outputReserve:i}){let r=e.mul(i),o=n.add(e);return r.div(o)}static getAmountIn({amountOut:e,inputReserve:n,outputReserve:i}){let r=n.mul(e),o=i.sub(e);return ge(r,o)}};var Ve=L(require("bn.js"));var mt=class extends be{static getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i}){return new I(e.virtualB.toString()).div(e.virtualA.toString()).mul(10**(n-i))}static getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r}){return new I(n.toString()).div(e.toString()).mul(10**(i-r))}static getPoolPrice({poolInfo:e,decimalA:n,decimalB:i}){return new I(e.virtualB.toString()).div(e.virtualA.toString()).mul(10**(n-i))}static getPoolEndPrice({supply:e,totalSell:n,totalLockedAmount:i