UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 53.9 kB
var Vn=Object.create;var ke=Object.defineProperty,Wn=Object.defineProperties,qn=Object.getOwnPropertyDescriptor,Gn=Object.getOwnPropertyDescriptors,Un=Object.getOwnPropertyNames,_t=Object.getOwnPropertySymbols,Xn=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable;var Vt=(e,t,n)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t)=>{for(var n in t||(t={}))Wt.call(t,n)&&Vt(e,n,t[n]);if(_t)for(var n of _t(t))Hn.call(t,n)&&Vt(e,n,t[n]);return e},J=(e,t)=>Wn(e,Gn(t));var zn=(e,t)=>{for(var n in t)ke(e,n,{get:t[n],enumerable:!0})},qt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Un(t))!Wt.call(e,r)&&r!==n&&ke(e,r,{get:()=>t[r],enumerable:!(i=qn(t,r))||i.enumerable});return e};var M=(e,t,n)=>(n=e!=null?Vn(Xn(e)):{},qt(t||!e||!e.__esModule?ke(n,"default",{value:e,enumerable:!0}):n,e)),Zn=e=>qt(ke({},"__esModule",{value:!0}),e);var Wr={};zn(Wr,{LinearPriceCurve:()=>Dt});module.exports=Zn(Wr);var U=M(require("bn.js"));var pe=9e15,le=1e9,ct="0123456789abcdef",Ge="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ue="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",lt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-pe,maxE:pe,crypto:!1},Ht,oe,A=!0,He="[DecimalError] ",ce=He+"Invalid argument: ",zt=He+"Precision limit exceeded",Zt=He+"crypto unavailable",Yt="[object Decimal]",_=Math.floor,F=Math.pow,Yn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,jn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Qn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,jt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Q=1e7,w=7,Jn=9007199254740991,$n=Ge.length-1,mt=Ue.length-1,p={toStringTag:Yt};p.absoluteValue=p.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),f(e)};p.ceil=function(){return f(new this.constructor(this),this.e+1,2)};p.clampedTo=p.clamp=function(e,t){var n,i=this,r=i.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(ce+t);return n=i.cmp(e),n<0?e:i.cmp(t)>0?t:new r(i)};p.comparedTo=p.cmp=function(e){var t,n,i,r,o=this,s=o.d,a=(e=new o.constructor(e)).d,c=o.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(o.e!==e.e)return o.e>e.e^c<0?1:-1;for(i=s.length,r=a.length,t=0,n=i<r?i:r;t<n;++t)if(s[t]!==a[t])return s[t]>a[t]^c<0?1:-1;return i===r?0:i>r^c<0?1:-1};p.cosine=p.cos=function(){var e,t,n=this,i=n.constructor;return n.d?n.d[0]?(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+w,i.rounding=1,n=ei(i,tn(i,n)),i.precision=e,i.rounding=t,f(oe==2||oe==3?n.neg():n,e,t,!0)):new i(1):new i(NaN)};p.cubeRoot=p.cbrt=function(){var e,t,n,i,r,o,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(A=!1,o=l.s*F(l.s*l,1/3),!o||Math.abs(o)==1/0?(n=E(l.d),e=l.e,(o=(e-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=F(n,1/3),e=_((e+1)/3)-(e%3==(e<0?-1:2)),o==1/0?n="5e"+e:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),i=new m(n),i.s=l.s):i=new m(o.toString()),s=(e=m.precision)+3;;)if(a=i,c=a.times(a).times(a),u=c.plus(l),i=S(u.plus(l).times(a),u.plus(c),s+2,1),E(a.d).slice(0,s)===(n=E(i.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!r&&n=="4999"){if(!r&&(f(a,e+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")&&(f(i,e+1,1),t=!i.times(i).times(i).eq(l));break}return A=!0,f(i,e,m.rounding,t)};p.decimalPlaces=p.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-_(this.e/w))*w,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};p.dividedBy=p.div=function(e){return S(this,new this.constructor(e))};p.dividedToIntegerBy=p.divToInt=function(e){var t=this,n=t.constructor;return f(S(t,new n(e),0,1,1),n.precision,n.rounding)};p.equals=p.eq=function(e){return this.cmp(e)===0};p.floor=function(){return f(new this.constructor(this),this.e+1,3)};p.greaterThan=p.gt=function(e){return this.cmp(e)>0};p.greaterThanOrEqualTo=p.gte=function(e){var t=this.cmp(e);return t==1||t===0};p.hyperbolicCosine=p.cosh=function(){var e,t,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?(e=Math.ceil(r/3),t=(1/Ze(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),o=fe(s,1,o.times(t),new s(1),!0);for(var c,u=e,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return f(o,s.precision=n,s.rounding=i,!0)};p.hyperbolicSine=p.sinh=function(){var e,t,n,i,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(t=o.precision,n=o.rounding,o.precision=t+Math.max(r.e,r.sd())+4,o.rounding=1,i=r.d.length,i<3)r=fe(o,2,r,r,!0);else{e=1.4*Math.sqrt(i),e=e>16?16:e|0,r=r.times(1/Ze(5,e)),r=fe(o,2,r,r,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);e--;)s=r.times(r),r=r.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=t,o.rounding=n,f(r,t,n,!0)};p.hyperbolicTangent=p.tanh=function(){var e,t,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+7,i.rounding=1,S(n.sinh(),n.cosh(),i.precision=e,i.rounding=t)):new i(n.s)};p.inverseCosine=p.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),i=t.precision,r=t.rounding;return n!==-1?n===0?e.isNeg()?$(t,i,r):new t(0):new t(NaN):e.isZero()?$(t,i+4,r).times(.5):(t.precision=i+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=i,t.rounding=r,e.times(2))};p.inverseHyperbolicCosine=p.acosh=function(){var e,t,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(e=i.precision,t=i.rounding,i.precision=e+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,A=!1,n=n.times(n).minus(1).sqrt().plus(n),A=!0,i.precision=e,i.rounding=t,n.ln()):new i(n)};p.inverseHyperbolicSine=p.asinh=function(){var e,t,n=this,i=n.constructor;return!n.isFinite()||n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,A=!1,n=n.times(n).plus(1).sqrt().plus(n),A=!0,i.precision=e,i.rounding=t,n.ln())};p.inverseHyperbolicTangent=p.atanh=function(){var e,t,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):(e=o.precision,t=o.rounding,i=r.sd(),Math.max(i,e)<2*-r.e-1?f(new o(r),e,t,!0):(o.precision=n=i-r.e,r=S(r.plus(1),new o(1).minus(r),n+e,1),o.precision=e+4,o.rounding=1,r=r.ln(),o.precision=e,o.rounding=t,r.times(.5))):new o(NaN)};p.inverseSine=p.asin=function(){var e,t,n,i,r=this,o=r.constructor;return r.isZero()?new o(r):(t=r.abs().cmp(1),n=o.precision,i=o.rounding,t!==-1?t===0?(e=$(o,n+4,i).times(.5),e.s=r.s,e):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 e,t,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<=mt)return s=$(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=mt)return s=$(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/w+2|0),e=n;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(A=!1,t=Math.ceil(a/w),i=1,c=u.times(u),s=new l(u),r=u;e!==-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[t]!==void 0)for(e=t;s.d[e]===o.d[e]&&e--;);return n&&(s=s.times(2<<n-1)),A=!0,f(s,l.precision=m,l.rounding=d,!0)};p.isFinite=function(){return!!this.d};p.isInteger=p.isInt=function(){return!!this.d&&_(this.e/w)>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(e){return this.cmp(e)<0};p.lessThanOrEqualTo=p.lte=function(e){return this.cmp(e)<1};p.logarithm=p.log=function(e){var t,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,g=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new l(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)o=!0;else{for(r=n[0];r%10===0;)r/=10;o=r!==1}if(A=!1,a=m+g,s=ue(u,a),i=t?Xe(l,a+10):ue(e,a),c=S(s,i,a,1),Be(c.d,r=m,d))do if(a+=10,s=ue(u,a),i=t?Xe(l,a+10):ue(e,a),c=S(s,i,a,1),!o){+E(c.d).slice(r+1,r+15)+1==1e14&&(c=f(c,m+1,0));break}while(Be(c.d,r+=10,d));return A=!0,f(c,m,d)};p.minus=p.sub=function(e){var t,n,i,r,o,s,a,c,u,l,m,d,g=this,k=g.constructor;if(e=new k(e),!g.d||!e.d)return!g.s||!e.s?e=new k(NaN):g.d?e.s=-e.s:e=new k(e.d||g.s!==e.s?g:NaN),e;if(g.s!=e.s)return e.s=-e.s,g.plus(e);if(u=g.d,d=e.d,a=k.precision,c=k.rounding,!u[0]||!d[0]){if(d[0])e.s=-e.s;else if(u[0])e=new k(g);else return new k(c===3?-0:0);return A?f(e,a,c):e}if(n=_(e.e/w),l=_(g.e/w),u=u.slice(),o=l-n,o){for(m=o<0,m?(t=u,o=-o,s=d.length):(t=d,n=l,s=u.length),i=Math.max(Math.ceil(a/w),s)+2,o>i&&(o=i,t.length=1),t.reverse(),i=o;i--;)t.push(0);t.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&&(t=u,u=d,d=t,e.s=-e.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]=Q-1;--u[r],u[i]+=Q}u[i]-=d[i]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(e.d=u,e.e=ze(u,n),A?f(e,a,c):e):new k(c===3?-0:0)};p.modulo=p.mod=function(e){var t,n=this,i=n.constructor;return e=new i(e),!n.d||!e.s||e.d&&!e.d[0]?new i(NaN):!e.d||n.d&&!n.d[0]?f(new i(n),i.precision,i.rounding):(A=!1,i.modulo==9?(t=S(n,e.abs(),0,3,1),t.s*=e.s):t=S(n,e,0,i.modulo,1),t=t.times(e),A=!0,n.minus(t))};p.naturalExponential=p.exp=function(){return dt(this)};p.naturalLogarithm=p.ln=function(){return ue(this)};p.negated=p.neg=function(){var e=new this.constructor(this);return e.s=-e.s,f(e)};p.plus=p.add=function(e){var t,n,i,r,o,s,a,c,u,l,m=this,d=m.constructor;if(e=new d(e),!m.d||!e.d)return!m.s||!e.s?e=new d(NaN):m.d||(e=new d(e.d||m.s===e.s?m:NaN)),e;if(m.s!=e.s)return e.s=-e.s,m.minus(e);if(u=m.d,l=e.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(e=new d(m)),A?f(e,a,c):e;if(o=_(m.e/w),i=_(e.e/w),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/w),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),t=0;r;)t=(u[--r]=u[r]+l[r]+t)/Q|0,u[r]%=Q;for(t&&(u.unshift(t),++i),s=u.length;u[--s]==0;)u.pop();return e.d=u,e.e=ze(u,i),A?f(e,a,c):e};p.precision=p.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(ce+e);return n.d?(t=Qt(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};p.round=function(){var e=this,t=e.constructor;return f(new t(e),e.e+1,t.rounding)};p.sine=p.sin=function(){var e,t,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+w,i.rounding=1,n=ni(i,tn(i,n)),i.precision=e,i.rounding=t,f(oe>2?n.neg():n,e,t,!0)):new i(NaN)};p.squareRoot=p.sqrt=function(){var e,t,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(A=!1,u=Math.sqrt(+s),u==0||u==1/0?(t=E(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=_((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),i=new l(t)):i=new l(u.toString()),n=(c=l.precision)+3;;)if(o=i,i=o.plus(S(s,o,n+2,1)).times(.5),E(o.d).slice(0,n)===(t=E(i.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!r&&t=="4999"){if(!r&&(f(o,c+1,0),o.times(o).eq(s))){i=o;break}n+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(f(i,c+1,1),e=!i.times(i).eq(s));break}return A=!0,f(i,c,l.rounding,e)};p.tangent=p.tan=function(){var e,t,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+10,i.rounding=1,n=n.sin(),n.s=1,n=S(n,new i(1).minus(n.times(n)).sqrt(),e+10,0),i.precision=e,i.rounding=t,f(oe==2||oe==4?n.neg():n,e,t,!0)):new i(NaN)};p.times=p.mul=function(e){var t,n,i,r,o,s,a,c,u,l=this,m=l.constructor,d=l.d,g=(e=new m(e)).d;if(e.s*=l.s,!d||!d[0]||!g||!g[0])return new m(!e.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:!d||!g?e.s/0:e.s*0);for(n=_(l.e/w)+_(e.e/w),c=d.length,u=g.length,c<u&&(o=d,d=g,g=o,s=c,c=u,u=s),o=[],s=c+u,i=s;i--;)o.push(0);for(i=u;--i>=0;){for(t=0,r=c+i;r>i;)a=o[r]+g[i]*d[r-i-1]+t,o[r--]=a%Q|0,t=a/Q|0;o[r]=(o[r]+t)%Q|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=ze(o,n),A?f(e,m.precision,m.rounding):e};p.toBinary=function(e,t){return pt(this,2,e,t)};p.toDecimalPlaces=p.toDP=function(e,t){var n=this,i=n.constructor;return n=new i(n),e===void 0?n:(X(e,0,le),t===void 0?t=i.rounding:X(t,0,8),f(n,e+n.e+1,t))};p.toExponential=function(e,t){var n,i=this,r=i.constructor;return e===void 0?n=ee(i,!0):(X(e,0,le),t===void 0?t=r.rounding:X(t,0,8),i=f(new r(i),e+1,t),n=ee(i,!0,e+1)),i.isNeg()&&!i.isZero()?"-"+n:n};p.toFixed=function(e,t){var n,i,r=this,o=r.constructor;return e===void 0?n=ee(r):(X(e,0,le),t===void 0?t=o.rounding:X(t,0,8),i=f(new o(r),e+r.e+1,t),n=ee(i,!1,e+i.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};p.toFraction=function(e){var t,n,i,r,o,s,a,c,u,l,m,d,g=this,k=g.d,T=g.constructor;if(!k)return new T(g);if(u=n=new T(1),i=c=new T(0),t=new T(i),o=t.e=Qt(k)-g.e-1,s=o%w,t.d[0]=F(10,s<0?w+s:s),e==null)e=o>0?t:u;else{if(a=new T(e),!a.isInt()||a.lt(u))throw Error(ce+a);e=a.gt(t)?o>0?t:u:a}for(A=!1,a=new T(E(k)),l=T.precision,T.precision=o=k.length*w*2;m=S(a,t,0,1,1),r=n.plus(m.times(i)),r.cmp(e)!=1;)n=i,i=r,r=u,u=c.plus(m.times(r)),c=r,r=t,t=a.minus(m.times(r)),a=r;return r=S(e.minus(n),i,0,1,1),c=c.plus(r.times(u)),n=n.plus(r.times(i)),c.s=u.s=g.s,d=S(u,i,o,1).minus(g).abs().cmp(S(c,n,o,1).minus(g).abs())<1?[u,i]:[c,n],T.precision=l,A=!0,d};p.toHexadecimal=p.toHex=function(e,t){return pt(this,16,e,t)};p.toNearest=function(e,t){var n=this,i=n.constructor;if(n=new i(n),e==null){if(!n.d)return n;e=new i(1),t=i.rounding}else{if(e=new i(e),t===void 0?t=i.rounding:X(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(A=!1,n=S(n,e,0,t,1).times(e),A=!0,f(n)):(e.s=n.s,n=e),n};p.toNumber=function(){return+this};p.toOctal=function(e,t){return pt(this,8,e,t)};p.toPower=p.pow=function(e){var t,n,i,r,o,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(F(+a,u));if(a=new c(a),a.eq(1))return a;if(i=c.precision,o=c.rounding,e.eq(1))return f(a,i,o);if(t=_(e.e/w),t>=e.d.length-1&&(n=u<0?-u:u)<=Jn)return r=Jt(c,a,n,i),e.s<0?new c(1).div(r):f(r,i,o);if(s=a.s,s<0){if(t<e.d.length-1)return new c(NaN);if((e.d[t]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=F(+a,u),t=n==0||!isFinite(n)?_(u*(Math.log("0."+E(a.d))/Math.LN10+a.e+1)):new c(n+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(A=!1,c.rounding=a.s=1,n=Math.min(12,(t+"").length),r=dt(e.times(ue(a,i+n)),i),r.d&&(r=f(r,i+5,1),Be(r.d,i,o)&&(t=i+10,r=f(dt(e.times(ue(a,t+n)),t),t+5,1),+E(r.d).slice(i+1,i+15)+1==1e14&&(r=f(r,i+1,0)))),r.s=s,A=!0,c.rounding=o,f(r,i,o))};p.toPrecision=function(e,t){var n,i=this,r=i.constructor;return e===void 0?n=ee(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(X(e,1,le),t===void 0?t=r.rounding:X(t,0,8),i=f(new r(i),e,t),n=ee(i,e<=i.e||i.e<=r.toExpNeg,e)),i.isNeg()&&!i.isZero()?"-"+n:n};p.toSignificantDigits=p.toSD=function(e,t){var n=this,i=n.constructor;return e===void 0?(e=i.precision,t=i.rounding):(X(e,1,le),t===void 0?t=i.rounding:X(t,0,8)),f(new i(n),e,t)};p.toString=function(){var e=this,t=e.constructor,n=ee(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n};p.truncated=p.trunc=function(){return f(new this.constructor(this),this.e+1,1)};p.valueOf=p.toJSON=function(){var e=this,t=e.constructor,n=ee(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function E(e){var t,n,i,r=e.length-1,o="",s=e[0];if(r>0){for(o+=s,t=1;t<r;t++)i=e[t]+"",n=w-i.length,n&&(o+=ae(n)),o+=i;s=e[t],i=s+"",n=w-i.length,n&&(o+=ae(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function X(e,t,n){if(e!==~~e||e<t||e>n)throw Error(ce+e)}function Be(e,t,n,i){var r,o,s,a;for(o=e[0];o>=10;o/=10)--t;return--t<0?(t+=w,r=0):(r=Math.ceil((t+1)/w),t%=w),o=F(10,w-t),a=e[r]%o|0,i==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==o||n>3&&a+1==o/2)&&(e[r+1]/o/100|0)==F(10,t-2)-1||(a==o/2||a==0)&&(e[r+1]/o/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==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)&&(e[r+1]/o/1e3|0)==F(10,t-3)-1,s}function We(e,t,n){for(var i,r=[0],o,s=0,a=e.length;s<a;){for(o=r.length;o--;)r[o]*=t;for(r[0]+=ct.indexOf(e.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 ei(e,t){var n,i,r;if(t.isZero())return t;i=t.d.length,i<32?(n=Math.ceil(i/3),r=(1/Ze(4,n)).toString()):(n=16,r="2.3283064365386962890625e-10"),e.precision+=n,t=fe(e,1,t.times(r),new e(1));for(var o=n;o--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}var S=function(){function e(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 t(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,g,k,T,W,L,Z,I,v,ve,re,st,De,he,at,Y,_e,Ve=i.constructor,ut=i.s==r.s?1:-1,D=i.d,C=r.d;if(!D||!D[0]||!C||!C[0])return new Ve(!i.s||!r.s||(D?C&&D[0]==C[0]:!C)?NaN:D&&D[0]==0||!C?ut*0:ut/0);for(c?(g=1,l=i.e-r.e):(c=Q,g=w,l=_(i.e/g)-_(r.e/g)),Y=C.length,he=D.length,L=new Ve(ut),Z=L.d=[],m=0;C[m]==(D[m]||0);m++);if(C[m]>(D[m]||0)&&l--,o==null?(re=o=Ve.precision,s=Ve.rounding):a?re=o+(i.e-r.e)+1:re=o,re<0)Z.push(1),k=!0;else{if(re=re/g+2|0,m=0,Y==1){for(d=0,C=C[0],re++;(m<he||d)&&re--;m++)st=d*c+(D[m]||0),Z[m]=st/C|0,d=st%C|0;k=d||m<he}else{for(d=c/(C[0]+1)|0,d>1&&(C=e(C,d,c),D=e(D,d,c),Y=C.length,he=D.length),De=Y,I=D.slice(0,Y),v=I.length;v<Y;)I[v++]=0;_e=C.slice(),_e.unshift(0),at=C[0],C[1]>=c/2&&++at;do d=0,u=t(C,I,Y,v),u<0?(ve=I[0],Y!=v&&(ve=ve*c+(I[1]||0)),d=ve/at|0,d>1?(d>=c&&(d=c-1),T=e(C,d,c),W=T.length,v=I.length,u=t(T,I,W,v),u==1&&(d--,n(T,Y<W?_e:C,W,c))):(d==0&&(u=d=1),T=C.slice()),W=T.length,W<v&&T.unshift(0),n(I,T,v,c),u==-1&&(v=I.length,u=t(C,I,Y,v),u<1&&(d++,n(I,Y<v?_e:C,v,c))),v=I.length):u===0&&(d++,I=[0]),Z[m++]=d,u&&I[0]?I[v++]=D[De]||0:(I=[D[De]],v=1);while((De++<he||I[0]!==void 0)&&re--);k=I[0]!==void 0}Z[0]||Z.shift()}if(g==1)L.e=l,Ht=k;else{for(m=1,d=Z[0];d>=10;d/=10)m++;L.e=m+l*g-1,f(L,a?o+L.e+1:o,s,k)}return L}}();function f(e,t,n,i){var r,o,s,a,c,u,l,m,d,g=e.constructor;e:if(t!=null){if(m=e.d,!m)return e;for(r=1,a=m[0];a>=10;a/=10)r++;if(o=t-r,o<0)o+=w,s=t,l=m[d=0],c=l/F(10,r-s-1)%10|0;else if(d=Math.ceil((o+1)/w),a=m.length,d>=a)if(i){for(;a++<=d;)m.push(0);l=c=0,r=1,o%=w,s=o-w+1}else break e;else{for(l=a=m[d],r=1;a>=10;a/=10)r++;o%=w,s=o-w+r,c=s<0?0:l/F(10,r-s-1)%10|0}if(i=i||t<0||m[d+1]!==void 0||(s<0?l:l%F(10,r-s-1)),u=n<4?(c||i)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||i||n==6&&(o>0?s>0?l/F(10,r-s):0:m[d-1])%10&1||n==(e.s<0?8:7)),t<1||!m[0])return m.length=0,u?(t-=e.e+1,m[0]=F(10,(w-t%w)%w),e.e=-t||0):m[0]=e.e=0,e;if(o==0?(m.length=d,a=1,d--):(m.length=d+1,a=F(10,w-o),m[d]=s>0?(l/F(10,r-s)%F(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&&(e.e++,m[0]==Q&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=Q)break;m[d--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return A&&(e.e>g.maxE?(e.d=null,e.e=NaN):e.e<g.minE&&(e.e=0,e.d=[0])),e}function ee(e,t,n){if(!e.isFinite())return en(e);var i,r=e.e,o=E(e.d),s=o.length;return t?(n&&(i=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+ae(i):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(e.e<0?"e":"e+")+e.e):r<0?(o="0."+ae(-r-1)+o,n&&(i=n-s)>0&&(o+=ae(i))):r>=s?(o+=ae(r+1-s),n&&(i=n-r-1)>0&&(o=o+"."+ae(i))):((i=r+1)<s&&(o=o.slice(0,i)+"."+o.slice(i)),n&&(i=n-s)>0&&(r+1===s&&(o+="."),o+=ae(i))),o}function ze(e,t){var n=e[0];for(t*=w;n>=10;n/=10)t++;return t}function Xe(e,t,n){if(t>$n)throw A=!0,n&&(e.precision=n),Error(zt);return f(new e(Ge),t,1,!0)}function $(e,t,n){if(t>mt)throw Error(zt);return f(new e(Ue),t,n,!0)}function Qt(e){var t=e.length-1,n=t*w+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ae(e){for(var t="";e--;)t+="0";return t}function Jt(e,t,n,i){var r,o=new e(1),s=Math.ceil(i/w+4);for(A=!1;;){if(n%2&&(o=o.times(t),Ut(o.d,s)&&(r=!0)),n=_(n/2),n===0){n=o.d.length-1,r&&o.d[n]===0&&++o.d[n];break}t=t.times(t),Ut(t.d,s)}return A=!0,o}function Gt(e){return e.d[e.d.length-1]&1}function $t(e,t,n){for(var i,r,o=new e(t[0]),s=0;++s<t.length;){if(r=new e(t[s]),!r.s){o=r;break}i=o.cmp(r),(i===n||i===0&&o.s===n)&&(o=r)}return o}function dt(e,t){var n,i,r,o,s,a,c,u=0,l=0,m=0,d=e.constructor,g=d.rounding,k=d.precision;if(!e.d||!e.d[0]||e.e>17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(A=!1,c=k):c=t,a=new d(.03125);e.e>-2;)e=e.times(a),m+=5;for(i=Math.log(F(2,m))/Math.LN10*2+5|0,c+=i,n=o=s=new d(1),d.precision=c;;){if(o=f(o.times(e),c,1),n=n.times(++l),a=s.plus(S(o,n,c,1)),E(a.d).slice(0,c)===E(s.d).slice(0,c)){for(r=m;r--;)s=f(s.times(s),c,1);if(t==null)if(u<3&&Be(s.d,c-i,g,u))d.precision=c+=10,n=o=a=new d(1),l=0,u++;else return f(s,d.precision=k,g,A=!0);else return d.precision=k,s}s=a}}function ue(e,t){var n,i,r,o,s,a,c,u,l,m,d,g=1,k=10,T=e,W=T.d,L=T.constructor,Z=L.rounding,I=L.precision;if(T.s<0||!W||!W[0]||!T.e&&W[0]==1&&W.length==1)return new L(W&&!W[0]?-1/0:T.s!=1?NaN:W?0:T);if(t==null?(A=!1,l=I):l=t,L.precision=l+=k,n=E(W),i=n.charAt(0),Math.abs(o=T.e)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)T=T.times(e),n=E(T.d),i=n.charAt(0),g++;o=T.e,i>1?(T=new L("0."+n),o++):T=new L(i+"."+n.slice(1))}else return u=Xe(L,l+2,I).times(o+""),T=ue(new L(i+"."+n.slice(1)),l-k).plus(u),L.precision=I,t==null?f(T,I,Z,A=!0):T;for(m=T,c=s=T=S(T.minus(1),T.plus(1),l,1),d=f(T.times(T),l,1),r=3;;){if(s=f(s.times(d),l,1),u=c.plus(S(s,new L(r),l,1)),E(u.d).slice(0,l)===E(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(Xe(L,l+2,I).times(o+""))),c=S(c,new L(g),l,1),t==null)if(Be(c.d,l-k,Z,a))L.precision=l+=k,u=s=T=S(m.minus(1),m.plus(1),l,1),d=f(T.times(T),l,1),r=a=1;else return f(c,L.precision=I,Z,A=!0);else return L.precision=I,c;c=u,r+=2}}function en(e){return String(e.s*e.s/0)}function qe(e,t){var n,i,r;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(i=t.search(/e/i))>0?(n<0&&(n=i),n+=+t.slice(i+1),t=t.substring(0,i)):n<0&&(n=t.length),i=0;t.charCodeAt(i)===48;i++);for(r=t.length;t.charCodeAt(r-1)===48;--r);if(t=t.slice(i,r),t){if(r-=i,e.e=n=n-i-1,e.d=[],i=(n+1)%w,n<0&&(i+=w),i<r){for(i&&e.d.push(+t.slice(0,i)),r-=w;i<r;)e.d.push(+t.slice(i,i+=w));t=t.slice(i),i=w-t.length}else i-=r;for(;i--;)t+="0";e.d.push(+t),A&&(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 ti(e,t){var n,i,r,o,s,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),jt.test(t))return qe(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(jn.test(t))n=16,t=t.toLowerCase();else if(Yn.test(t))n=2;else if(Qn.test(t))n=8;else throw Error(ce+t);for(o=t.search(/p/i),o>0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),o=t.indexOf("."),s=o>=0,i=e.constructor,s&&(t=t.replace(".",""),a=t.length,o=a-o,r=Jt(i,new i(n),o,o*2)),u=We(t,n,Q),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new i(e.s*0):(e.e=ze(u,l),e.d=u,A=!1,s&&(e=S(e,r,a*4)),c&&(e=e.times(Math.abs(c)<54?F(2,c):xe.pow(2,c))),A=!0,e)}function ni(e,t){var n,i=t.d.length;if(i<3)return t.isZero()?t:fe(e,2,t,t);n=1.4*Math.sqrt(i),n=n>16?16:n|0,t=t.times(1/Ze(5,n)),t=fe(e,2,t,t);for(var r,o=new e(5),s=new e(16),a=new e(20);n--;)r=t.times(t),t=t.times(o.plus(r.times(s.times(r).minus(a))));return t}function fe(e,t,n,i,r){var o,s,a,c,u=1,l=e.precision,m=Math.ceil(l/w);for(A=!1,c=n.times(n),a=new e(i);;){if(s=S(a.times(c),new e(t++*t++),l,1),a=r?i.plus(s):i.minus(s),i=S(s.times(c),new e(t++*t++),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 A=!0,s.d.length=m+1,s}function Ze(e,t){for(var n=e;--t;)n*=e;return n}function tn(e,t){var n,i=t.s<0,r=$(e,e.precision,1),o=r.times(.5);if(t=t.abs(),t.lte(o))return oe=i?4:1,t;if(n=t.divToInt(r),n.isZero())oe=i?3:2;else{if(t=t.minus(n.times(r)),t.lte(o))return oe=Gt(n)?i?2:3:i?4:1,t;oe=Gt(n)?i?1:4:i?3:2}return t.minus(r).abs()}function pt(e,t,n,i){var r,o,s,a,c,u,l,m,d,g=e.constructor,k=n!==void 0;if(k?(X(n,1,le),i===void 0?i=g.rounding:X(i,0,8)):(n=g.precision,i=g.rounding),!e.isFinite())l=en(e);else{for(l=ee(e),s=l.indexOf("."),k?(r=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):r=t,s>=0&&(l=l.replace(".",""),d=new g(1),d.e=l.length-s,d.d=We(ee(d),10,r),d.e=d.d.length),m=We(l,10,r),o=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=k?"0p+0":"0";else{if(s<0?o--:(e=new g(e),e.d=m,e.e=o,e=S(e,d,n,i,0,r),m=e.d,o=e.e,u=Ht),s=m[n],a=r/2,u=u||m[n+1]!==void 0,u=i<4?(s!==void 0||u)&&(i===0||i===(e.s<0?3:2)):s>a||s===a&&(i===4||u||i===6&&m[n-1]&1||i===(e.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+=ct.charAt(m[s]);if(k){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(m=We(l,r,t),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=ct.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=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function Ut(e,t){if(e.length>t)return e.length=t,!0}function ii(e){return new this(e).abs()}function ri(e){return new this(e).acos()}function oi(e){return new this(e).acosh()}function si(e,t){return new this(e).plus(t)}function ai(e){return new this(e).asin()}function ui(e){return new this(e).asinh()}function ci(e){return new this(e).atan()}function li(e){return new this(e).atanh()}function mi(e,t){e=new this(e),t=new this(t);var n,i=this.precision,r=this.rounding,o=i+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=$(this,o,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?$(this,i,r):new this(0),n.s=e.s):!e.d||t.isZero()?(n=$(this,o,1).times(.5),n.s=e.s):t.s<0?(this.precision=o,this.rounding=1,n=this.atan(S(e,t,o,1)),t=$(this,o,1),this.precision=i,this.rounding=r,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(S(e,t,o,1)),n}function di(e){return new this(e).cbrt()}function pi(e){return f(e=new this(e),e.e+1,2)}function fi(e,t,n){return new this(e).clamp(t,n)}function bi(e){if(!e||typeof e!="object")throw Error(He+"Object expected");var t,n,i,r=e.defaults===!0,o=["precision",1,le,"rounding",0,8,"toExpNeg",-pe,0,"toExpPos",0,pe,"maxE",0,pe,"minE",-pe,0,"modulo",0,9];for(t=0;t<o.length;t+=3)if(n=o[t],r&&(this[n]=lt[n]),(i=e[n])!==void 0)if(_(i)===i&&i>=o[t+1]&&i<=o[t+2])this[n]=i;else throw Error(ce+n+": "+i);if(n="crypto",r&&(this[n]=lt[n]),(i=e[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(Zt);else this[n]=!1;else throw Error(ce+n+": "+i);return this}function gi(e){return new this(e).cos()}function yi(e){return new this(e).cosh()}function nn(e){var t,n,i;function r(o){var s,a,c,u=this;if(!(u instanceof r))return new r(o);if(u.constructor=r,Xt(o)){u.s=o.s,A?!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++;A?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),jt.test(o)?qe(u,o):ti(u,o);if(c==="bigint")return o<0?(o=-o,u.s=-1):u.s=1,qe(u,o.toString());throw Error(ce+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=bi,r.clone=nn,r.isDecimal=Xt,r.abs=ii,r.acos=ri,r.acosh=oi,r.add=si,r.asin=ai,r.asinh=ui,r.atan=ci,r.atanh=li,r.atan2=mi,r.cbrt=di,r.ceil=pi,r.clamp=fi,r.cos=gi,r.cosh=yi,r.div=wi,r.exp=Pi,r.floor=Ai,r.hypot=Ti,r.ln=hi,r.log=ki,r.log10=xi,r.log2=Bi,r.max=Ii,r.min=Si,r.mod=Ci,r.mul=Ki,r.pow=Ni,r.random=Ri,r.round=Li,r.sign=Mi,r.sin=Fi,r.sinh=Oi,r.sqrt=Ei,r.sub=vi,r.sum=Di,r.tan=_i,r.tanh=Vi,r.trunc=Wi,e===void 0&&(e={}),e&&e.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<i.length;)e.hasOwnProperty(n=i[t++])||(e[n]=this[n]);return r.config(e),r}function wi(e,t){return new this(e).div(t)}function Pi(e){return new this(e).exp()}function Ai(e){return f(e=new this(e),e.e+1,3)}function Ti(){var e,t,n=new this(0);for(A=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return A=!0,new this(1/0);n=t}return A=!0,n.sqrt()}function Xt(e){return e instanceof xe||e&&e.toStringTag===Yt||!1}function hi(e){return new this(e).ln()}function ki(e,t){return new this(e).log(t)}function Bi(e){return new this(e).log(2)}function xi(e){return new this(e).log(10)}function Ii(){return $t(this,arguments,-1)}function Si(){return $t(this,arguments,1)}function Ci(e,t){return new this(e).mod(t)}function Ki(e,t){return new this(e).mul(t)}function Ni(e,t){return new this(e).pow(t)}function Ri(e){var t,n,i,r,o=0,s=new this(1),a=[];if(e===void 0?e=this.precision:X(e,1,le),i=Math.ceil(e/w),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(i));o<i;)r=t[o],r>=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(i*=4);o<i;)r=t[o]+(t[o+1]<<8)+(t[o+2]<<16)+((t[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(t,o):(a.push(r%1e7),o+=4);o=i/4}else throw Error(Zt);else for(;o<i;)a[o++]=Math.random()*1e7|0;for(i=a[--o],e%=w,i&&e&&(r=F(10,w-e),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-=w)a.shift();for(i=1,r=a[0];r>=10;r/=10)i++;i<w&&(n-=w-i)}return s.e=n,s.d=a,s}function Li(e){return f(e=new this(e),e.e+1,this.rounding)}function Mi(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Fi(e){return new this(e).sin()}function Oi(e){return new this(e).sinh()}function Ei(e){return new this(e).sqrt()}function vi(e,t){return new this(e).sub(t)}function Di(){var e=0,t=arguments,n=new this(t[e]);for(A=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return A=!0,f(n,this.precision,this.rounding)}function _i(e){return new this(e).tan()}function Vi(e){return new this(e).tanh()}function Wi(e){return f(e=new this(e),e.e+1,1)}p[Symbol.for("nodejs.util.inspect.custom")]=p.toString;p[Symbol.toStringTag]="Decimal";var xe=p.constructor=nn(lt);Ge=new xe(Ge);Ue=new xe(Ue);var O=xe;var _r=require("@solana/web3.js"),Vr=M(require("bn.js"));var Gi=require("@solana/web3.js");var Ie=require("lodash");var ft=class{constructor(t){this.logLevel=t.logLevel!==void 0?t.logLevel:0,this.name=t.name}set level(t){this.logLevel=t}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(t){return t<=this.logLevel}error(...t){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...t),this):this}logWithError(...t){let n=t.map(i=>typeof i=="object"?JSON.stringify(i):i).join(", ");throw new Error(n)}warning(...t){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...t),this):this}info(...t){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...t),this):this}debug(...t){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...t),this):this}},rn={},qi={};function q(e){let t=(0,Ie.get)(rn,e);if(!t){let n=(0,Ie.get)(qi,e);t=new ft({name:e,logLevel:n}),(0,Ie.set)(rn,e,t)}return t}var Ye=require("@solana/spl-token"),jr=q("Raydium_accountInfo_util");var ne=M(require("bn.js"));var ln=M(require("big.js")),Zi=M(require("bn.js"));var sn=M(require("toformat")),Ui=sn.default,Se=Ui;var Ce=M(require("big.js")),un=M(require("bn.js")),cn=M(require("decimal.js-light"));var be=M(require("bn.js"));var an=9007199254740991;function te(e){let t=q("Raydium_parseBigNumberish");if(e instanceof be.default)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new be.default(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=an||e<=-an)&&t.logWithError(`BigNumberish number overflow: ${e}`),new be.default(String(e))):typeof e=="bigint"?new be.default(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new be.default(0))}var Qe=q("module/fraction"),bt=Se(Ce.default),Ke=Se(cn.default),Hi={[0]:Ke.ROUND_DOWN,[1]:Ke.ROUND_HALF_UP,[2]:Ke.ROUND_UP},zi={[0]:Ce.default.roundDown,[1]:Ce.default.roundHalfUp,[2]:Ce.default.roundUp},K=class{constructor(t,n=new un.default(1)){this.numerator=te(t),this.denominator=te(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new K(this.denominator,this.numerator)}add(t){let n=t instanceof K?t:new K(te(t));return this.denominator.eq(n.denominator)?new K(this.numerator.add(n.numerator),this.denominator):new K(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(t){let n=t instanceof K?t:new K(te(t));return this.denominator.eq(n.denominator)?new K(this.numerator.sub(n.numerator),this.denominator):new K(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(t){let n=t instanceof K?t:new K(te(t));return new K(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(t){let n=t instanceof K?t:new K(te(t));return new K(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(t,n={groupSeparator:""},i=1){Number.isInteger(t)||Qe.logWithError(`${t} is not an integer.`),t<=0&&Qe.logWithError(`${t} is not positive.`),Ke.set({precision:t+1,rounding:Hi[i]});let r=new Ke(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return r.toFormat(r.decimalPlaces(),n)}toFixed(t,n={groupSeparator:""},i=1){return Number.isInteger(t)||Qe.logWithError(`${t} is not an integer.`),t<0&&Qe.logWithError(`${t} is negative.`),bt.DP=t,bt.RM=zi[i]||1,new bt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)}isZero(){return this.numerator.isZero()}};var go=q("Raydium_amount"),yo=Se(ln.default);var mn=require("@solana/web3.js"),gt=require("@solana/spl-token"),yt={chainId:101,address:mn.PublicKey.default.toBase58(),programId:gt.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"}},me={chainId:101,address:"So11111111111111111111111111111111111111112",programId:gt.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 Je=require("@solana/web3.js");var B=require("@solana/web3.js"),dn=require("@solana/spl-token");function wt({pubkey:e,isSigner:t=!1,isWritable:n=!0}){return{pubkey:e,isWritable:n,isSigner:t}}var To=[wt({pubkey:dn.TOKEN_PROGRAM_ID,isWritable:!1}),wt({pubkey:B.SystemProgram.programId,isWritable:!1}),wt({pubkey:B.SYSVAR_RENT_PUBKEY,isWritable:!1})];function pn({publicKey:e,transformSol:t}){let n=fn(e.toString());if(n instanceof B.PublicKey)return t&&n.equals(Ne)?je:n;if(t&&n.toString()===Ne.toBase58())return je;if(typeof n=="string"){if(n===B.PublicKey.default.toBase58())return B.PublicKey.default;try{return new B.PublicKey(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function fn(e){try{return new B.PublicKey(e)}catch{return e}}var ji=new B.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Qi=new B.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Ji=new B.PublicKey("SysvarRent111111111111111111111111111111111"),ho=new B.PublicKey("SysvarC1ock11111111111111111111111111111111"),bn=new B.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),ko=new B.PublicKey("Sysvar1nstructions1111111111111111111111111"),Bo=B.SystemProgram.programId,xo=new B.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Io=new B.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),So=new B.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Co=new B.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Ko=new B.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),No=new B.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Ro=new B.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Lo=new B.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Mo=new B.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Fo=new B.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Oo=new B.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),je=new B.PublicKey("So11111111111111111111111111111111111111112"),Ne=B.PublicKey.default;var Pt=class{constructor({mint:t,decimals:n,symbol:i,name:r,skipMint:o=!1,isToken2022:s=!1}){if(t===Ne.toBase58()||t instanceof Je.PublicKey&&Ne.equals(t)){this.decimals=me.decimals,this.symbol=me.symbol,this.name=me.name,this.mint=new Je.PublicKey(me.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=i||t.toString().substring(0,6),this.name=r||t.toString().substring(0,6),this.mint=o?Je.PublicKey.default:pn({publicKey:t}),this.isToken2022=s}equals(t){return this===t?!0:this.mint.equals(t.mint)}},de=Pt;de.WSOL=new Pt(J(j({},me),{mint:me.address}));var At=class{constructor({decimals:t,symbol:n="UNKNOWN",name:i="UNKNOWN"}){this.decimals=t,this.symbol=n,this.name=i}equals(t){return this===t}},$e=At;$e.SOL=new At(yt);var gn=M(require("bn.js"));var Xo=new K(new gn.default(100));var Qo=q("Raydium_price");var $i=new ne.default(0),Bs=new ne.default(1),xs=new ne.default(2),Is=new ne.default(3),Ss=new ne.default(5),Yi=new ne.default(10),Cs=new ne.default(100),Ks=new ne.default(1e3),Ns=new ne.default(1e4);var nr=require("@solana/web3.js"),ir=require("@solana/spl-token");var ge=require("@solana/web3.js");var er=require("@solana/spl-token"),Gs=q("Raydium_txUtil");var b=require("@solana/web3.js"),zs=new b.PublicKey("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),Zs=new b.PublicKey("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),Ys=new b.PublicKey("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),js=new b.PublicKey("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Qs=new b.PublicKey("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Js=new b.PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),$s=new b.PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),ea=new b.PublicKey("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),ta=new b.PublicKey("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),na=new b.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),rr=new b.PublicKey("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),or=new b.PublicKey("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),sr=new b.PublicKey("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),ia=new b.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),ra=new b.PublicKey("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),oa=new b.PublicKey("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),sa=new b.PublicKey("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),aa=new b.PublicKey("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),ua=new b.PublicKey("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),ca=new b.PublicKey("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),la=new b.PublicKey("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),ma=new b.PublicKey("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),da=new b.PublicKey("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),pa=new b.PublicKey("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),fa=new b.PublicKey("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),ba=new b.PublicKey("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),ga=new b.PublicKey("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),ya=new b.PublicKey("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),wa=new b.PublicKey("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),Pa=new b.PublicKey("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),Aa=new b.PublicKey("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var Ta={OPEN_BOOK_PROGRAM:new b.PublicKey("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new b.PublicKey("Ray1111111111111111111111111111111111111111"),AMM_V4:new b.PublicKey("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new b.PublicKey("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new b.PublicKey("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new b.PublicKey("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new b.PublicKey("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new b.PublicKey("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new b.PublicKey("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new b.PublicKey("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new b.PublicKey("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new b.PublicKey("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:b.PublicKey.default,Router:new b.PublicKey("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new b.PublicKey("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new b.PublicKey("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new b.PublicKey("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new b.PublicKey("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new b.PublicKey("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new b.PublicKey("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new b.PublicKey("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new b.PublicKey("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new b.PublicKey("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new b.PublicKey("Ray1111111111111111111111111111111111111111")};var Re=M(require("bn.js"));function Bt(e,t){if(e.isZero())return new Re.default(0);let n=e.div(t);return n.isZero()?new Re.default(1):e.mod(t).gt(new Re.default(0))?n.add(new Re.default(1)):n}var wn=require("@solana/web3.js");var ye=require("@solana/web3.js"),cr=M(require("axios"));var lr=require("@solana/web3.js"),mr=M(require("bn.js"));var Pn=M(require("bn.js")),Ya=new Pn.default(1e6);var rt=require("@solana/spl-token");var dr=require("@solana/web3.js"),An=require("@solana/spl-token");var it=require("@solana/web3.js"),Dr=M(require("bn.js"));var Et=require("@solana/spl-token");var Bn=require("@solana/web3.js"),we=M(require("bn.js"));var y=require("@solana/buffer-layout"),xt=y.Layout,Tn=y.Structure;var It=y.UInt;var hn=y.u8,Le=y.u16;var se=y.s32;var kn=y.seq;var H=y.blob;var Pe=class extends xt{constructor(n,i,r){super(n,r);this.blob=H(n),this.signed=i}decode(n,i=0){let r=new we.default(this.blob.decode(n,i),10,"le");return this.signed?r.fromTwos(this.span*8).clone():r}encode(n,i,r=0){return typeof n=="number"&&(n=new we.default(n)),this.signed&&(n=n.toTwos(this.span*8)),this.blob.encode(n.toArrayLike(Buffer,"le",this.span),i,r)}};function G(e){return new It(1,e)}function Ae(e){return new It(4,e)}function h(e){return new Pe(8,!1,e)}function N(e){return new Pe(16,!1,e)}function xn(e){return new Pe(8,!0,e)}function In(e){return new Pe(16,!0,e)}var tt=class extends xt{constructor(n,i,r,o){super(n.span,o);this.layout=n,this.decoder=i,this.encoder=r}decode(n,i){return this.decoder(this.layout.decode(n,i))}encode(n,i,r){return this.layout.encode(this.encoder(n),i,r)}getSpan(n,i){return this.layout.getSpan(n,i)}};function x(e){return new tt(H(32),t=>new Bn.PublicKey(t),t=>t.toBuffer(),e)}function Ct(e){return new tt(hn(),pr,fr,e)}function pr(e){if(e===0)return!1;if(e===1)return!0;throw new Error("Invalid bool: "+e)}function fr(e){return e?1:0}var St=class extends Tn{decode(t,n){return super.decode(t,n)}};function V(e,t,n){return new St(e,t,n)}function R(e,t,n){let i,r=typeof t=="number"?t:(0,we.isBN)(t)?t.toNumber():new Proxy(t,{get(o,s){if(!i){let a=Reflect.get(o,"count");i=(0,we.isBN)(a)?a.toNumber():a,Reflect.set(o,"count",i)}return Reflect.get(o,s)},set(o,s,a){return s==="count"&&(i=a),Reflect.set(o,s,a)}});return kn(e,r,n)}var Ir=M(require("bn.js"));var z=M(require("bn.js")),Kt=new z.default(0),Sn=new z.default(1),Cn=new z.default(-1),ie=new z.default(1).shln(64),Kn=new z.default(1).shln(128),Nt=ie.sub(Sn);var br=Kn.subn(1),Te=-443636,Me=-Te,Rt=new z.default("4295048016"),Lt=new z.default("79226673521066979257578248091"),Du=new z.default("4295048017"),_u=new z.default("79226673521066979257578248090");var gr=new z.default(10).pow(new z.default(6));var Vu=new z.default("18446744073700000000");var xr=M(require("bn.js"));var zu=Buffer.from("amm_config","utf8"),Zu=Buffer.from("pool","utf8"),Yu=Buffer.from("pool_vault","utf8"),ju=Buffer.from("pool_reward_vault","utf8"),Qu=Buffer.from("position","utf8"),Ju=Buffer.from("tick_array","utf8"),$u=Buffer.from("operation","utf8"),ec=Buffer.from("pool_tick_array_bitmap_extension","utf8"),tc=Buffer.from("observation","utf8");var nc=Buffer.from("locked_position","utf8");var ic=Buffer.from("support_mint","utf8");var Tr=require("@solana/web3.js"),hr=require("@solana/spl-token"),kr=M(require("bn.js"));var yr=M(require("bn.js"));var Ot=14;var nt=60;var Sr=V([H(8),G("bump"),Le("index"),x(""),Ae("protocolFeeRate"),Ae("tradeFeeRate"),Le("tickSpacing"),R(h(),8,"")]),Cr=V([Ae("blockTimestamp"),xn("tickCumulative"),R(h(),4)]),_n=V([H(8),Ct("initialized"),h("recentEpoch"),Le("observationIndex"),x("poolId"),R(Cr,100,"observations"),R(h(),4)]),Kr=V([G("rewardState"),h("openTime"),h("endTime"),h("lastUpdateTime"),N("emissionsPerSecondX64"),h("rewardTotalEmissioned"),h("rewardClaimed"),x("tokenMint"),x("tokenVault"),x("creator"),N("rewardGrowthGlobalX64")]),En=V([H(8),G("bump"),x("ammConfig"),x("creator"),x("mintA"),x("mintB"),x("vaultA"),x("vaultB"),x("observationId"),G("mintDecimalsA"),G("mintDecimalsB"),Le("tickSpacing"),N("liquidity"),N("sqrtPriceX64"),se("tickCurrent"),Ae(),N("feeGrowthGlobalX64A"),N("feeGrowthGlobalX64B"),h("protocolFeesTokenA"),h("protocolFeesTokenB"),N("swapInAmountTokenA"),N("swapOutAmountTokenB"),N("swapInAmountTokenB"),N("swapOutAmountTokenA"),G("status"),R(G(),7,""),R(Kr,3,"rewardInfos"),R(h(),16,"tickArrayBitmap"),h("totalFeesTokenA"),h("totalFeesClaimedTokenA"),h("totalFeesTokenB"),h("totalFeesClaimedTokenB"),h("fundFeesTokenA"),h("fundFeesTokenB"),h("startTime"),R(h(),15*4-3,"padding")]),Nr=V([N("growthInsideLastX64"),h("rewardAmountOwed")]),vn=V([H(8),G("bump"),x("nftMint"),x("poolId"),se("tickLower"),se("tickUpper"),N("liquidity"),N("feeGrowthInsideLastX64A"),N("feeGrowthInsideLastX64B"),h("tokenFeesOwedA"),h("tokenFeesOwedB"),R(Nr,3,"rewardInfos"),R(h(),8,"")]),Tl=V([H(8),G("bump"),x("poolId"),se("tickLowerIndex"),se("tickUpperIndex"),N("liquidity"),N("feeGrowthInsideLastX64A"),N("feeGrowthInsideLastX64B"),h("tokenFeesOwedA"),h("tokenFeesOwedB"),R(N(),3,"rewardGrowthInside"),R(h(),8,"")]),Rr=V([se("tick"),In("liquidityNet"),N("liquidityGross"),N("feeGrowthOutsideX64A"),N("feeGrowthOutsideX64B"),R(N(),3,"rewardGrowthsOutsideX64"),R(Ae(),13,"")]),Mn=V([H(8),x("poolId"),se("startTickIn