UNPKG

test-raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 59.9 kB
var On=Object.create;var Re=Object.defineProperty,Dn=Object.defineProperties,Mn=Object.getOwnPropertyDescriptor,_n=Object.getOwnPropertyDescriptors,vn=Object.getOwnPropertyNames,Vt=Object.getOwnPropertySymbols,Kn=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty,qn=Object.prototype.propertyIsEnumerable;var Ut=(t,e,n)=>e in t?Re(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ue=(t,e)=>{for(var n in e||(e={}))Wt.call(e,n)&&Ut(t,n,e[n]);if(Vt)for(var n of Vt(e))qn.call(e,n)&&Ut(t,n,e[n]);return t},me=(t,e)=>Dn(t,_n(e));var Gn=(t,e)=>{for(var n in e)Re(t,n,{get:e[n],enumerable:!0})},Xt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of vn(e))!Wt.call(t,i)&&i!==n&&Re(t,i,{get:()=>e[i],enumerable:!(r=Mn(e,i))||r.enumerable});return t};var D=(t,e,n)=>(n=t!=null?On(Kn(t)):{},Xt(e||!t||!t.__esModule?Re(n,"default",{value:t,enumerable:!0}):n,t)),Vn=t=>Xt(Re({},"__esModule",{value:!0}),t);var pi={};Gn(pi,{PositionUtils:()=>ut});module.exports=Vn(pi);var ae=D(require("bn.js"));var Fe=require("lodash"),ft=D(require("dayjs")),Ht=D(require("dayjs/plugin/utc"));ft.default.extend(Ht.default);var dt=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(0,ft.default)().utc().format("YYYY/MM/DD HH:mm:ss UTC")}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let n=e.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(n)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},zt={},Un={};function j(t){let e=(0,Fe.get)(zt,t);if(!e){let n=(0,Fe.get)(Un,t);e=new dt({name:t,logLevel:n}),(0,Fe.set)(zt,t,e)}return e}var Xr=require("@solana/web3.js"),zr=D(require("bn.js"));var yn=D(require("big.js")),Wr=D(require("bn.js"));var X=D(require("bn.js"));var Pe=9e15,he=1e9,pt="0123456789abcdef",je="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qe="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",gt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Pe,maxE:Pe,crypto:!1},Qt,de,w=!0,$e="[DecimalError] ",ge=$e+"Invalid argument: ",Jt=$e+"Precision limit exceeded",$t=$e+"crypto unavailable",en="[object Decimal]",U=Math.floor,M=Math.pow,Wn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Xn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,zn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,tn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ie=1e7,b=7,Hn=9007199254740991,Yn=je.length-1,ht=Qe.length-1,f={toStringTag:en};f.absoluteValue=f.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),g(t)};f.ceil=function(){return g(new this.constructor(this),this.e+1,2)};f.clampedTo=f.clamp=function(t,e){var n,r=this,i=r.constructor;if(t=new i(t),e=new i(e),!t.s||!e.s)return new i(NaN);if(t.gt(e))throw Error(ge+e);return n=r.cmp(t),n<0?t:r.cmp(e)>0?e:new i(r)};f.comparedTo=f.cmp=function(t){var e,n,r,i,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(r=s.length,i=a.length,e=0,n=r<i?r:i;e<n;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1};f.cosine=f.cos=function(){var t,e,n=this,r=n.constructor;return n.d?n.d[0]?(t=r.precision,e=r.rounding,r.precision=t+Math.max(n.e,n.sd())+b,r.rounding=1,n=Zn(r,an(r,n)),r.precision=t,r.rounding=e,g(de==2||de==3?n.neg():n,t,e,!0)):new r(1):new r(NaN)};f.cubeRoot=f.cbrt=function(){var t,e,n,r,i,o,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(w=!1,o=l.s*M(l.s*l,1/3),!o||Math.abs(o)==1/0?(n=G(l.d),t=l.e,(o=(t-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=M(n,1/3),t=U((t+1)/3)-(t%3==(t<0?-1:2)),o==1/0?n="5e"+t:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),r=new m(n),r.s=l.s):r=new m(o.toString()),s=(t=m.precision)+3;;)if(a=r,c=a.times(a).times(a),u=c.plus(l),r=N(u.plus(l).times(a),u.plus(c),s+2,1),G(a.d).slice(0,s)===(n=G(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!i&&n=="4999"){if(!i&&(g(a,t+1,0),a.times(a).times(a).eq(l))){r=a;break}s+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(g(r,t+1,1),e=!r.times(r).times(r).eq(l));break}return w=!0,g(r,t,m.rounding,e)};f.decimalPlaces=f.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-U(this.e/b))*b,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};f.dividedBy=f.div=function(t){return N(this,new this.constructor(t))};f.dividedToIntegerBy=f.divToInt=function(t){var e=this,n=e.constructor;return g(N(e,new n(t),0,1,1),n.precision,n.rounding)};f.equals=f.eq=function(t){return this.cmp(t)===0};f.floor=function(){return g(new this.constructor(this),this.e+1,3)};f.greaterThan=f.gt=function(t){return this.cmp(t)>0};f.greaterThanOrEqualTo=f.gte=function(t){var e=this.cmp(t);return e==1||e===0};f.hyperbolicCosine=f.cosh=function(){var t,e,n,r,i,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,r=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,i=o.d.length,i<32?(t=Math.ceil(i/3),e=(1/tt(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=Be(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 g(o,s.precision=n,s.rounding=r,!0)};f.hyperbolicSine=f.sinh=function(){var t,e,n,r,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(e=o.precision,n=o.rounding,o.precision=e+Math.max(i.e,i.sd())+4,o.rounding=1,r=i.d.length,r<3)i=Be(o,2,i,i,!0);else{t=1.4*Math.sqrt(r),t=t>16?16:t|0,i=i.times(1/tt(5,t)),i=Be(o,2,i,i,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);t--;)s=i.times(i),i=i.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=e,o.rounding=n,g(i,e,n,!0)};f.hyperbolicTangent=f.tanh=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+7,r.rounding=1,N(n.sinh(),n.cosh(),r.precision=t,r.rounding=e)):new r(n.s)};f.inverseCosine=f.acos=function(){var t,e=this,n=e.constructor,r=e.abs().cmp(1),i=n.precision,o=n.rounding;return r!==-1?r===0?e.isNeg()?re(n,i,o):new n(0):new n(NaN):e.isZero()?re(n,i+4,o).times(.5):(n.precision=i+6,n.rounding=1,e=e.asin(),t=re(n,i+4,o).times(.5),n.precision=i,n.rounding=o,t.minus(e))};f.inverseHyperbolicCosine=f.acosh=function(){var t,e,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(t=r.precision,e=r.rounding,r.precision=t+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,w=!1,n=n.times(n).minus(1).sqrt().plus(n),w=!0,r.precision=t,r.rounding=e,n.ln()):new r(n)};f.inverseHyperbolicSine=f.asinh=function(){var t,e,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,w=!1,n=n.times(n).plus(1).sqrt().plus(n),w=!0,r.precision=t,r.rounding=e,n.ln())};f.inverseHyperbolicTangent=f.atanh=function(){var t,e,n,r,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=o.precision,e=o.rounding,r=i.sd(),Math.max(r,t)<2*-i.e-1?g(new o(i),t,e,!0):(o.precision=n=r-i.e,i=N(i.plus(1),new o(1).minus(i),n+t,1),o.precision=t+4,o.rounding=1,i=i.ln(),o.precision=t,o.rounding=e,i.times(.5))):new o(NaN)};f.inverseSine=f.asin=function(){var t,e,n,r,i=this,o=i.constructor;return i.isZero()?new o(i):(e=i.abs().cmp(1),n=o.precision,r=o.rounding,e!==-1?e===0?(t=re(o,n+4,r).times(.5),t.s=i.s,t):new o(NaN):(o.precision=n+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=r,i.times(2)))};f.inverseTangent=f.atan=function(){var t,e,n,r,i,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=re(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=re(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/b+2|0),t=n;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(w=!1,e=Math.ceil(a/b),r=1,c=u.times(u),s=new l(u),i=u;t!==-1;)if(i=i.times(c),o=s.minus(i.div(r+=2)),i=i.times(c),s=o.plus(i.div(r+=2)),s.d[e]!==void 0)for(t=e;s.d[t]===o.d[t]&&t--;);return n&&(s=s.times(2<<n-1)),w=!0,g(s,l.precision=m,l.rounding=d,!0)};f.isFinite=function(){return!!this.d};f.isInteger=f.isInt=function(){return!!this.d&&U(this.e/b)>this.d.length-2};f.isNaN=function(){return!this.s};f.isNegative=f.isNeg=function(){return this.s<0};f.isPositive=f.isPos=function(){return this.s>0};f.isZero=function(){return!!this.d&&this.d[0]===0};f.lessThan=f.lt=function(t){return this.cmp(t)<0};f.lessThanOrEqualTo=f.lte=function(t){return this.cmp(t)<1};f.logarithm=f.log=function(t){var e,n,r,i,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,p=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(i=n[0];i%10===0;)i/=10;o=i!==1}if(w=!1,a=m+p,s=pe(u,a),r=e?Je(l,a+10):pe(t,a),c=N(s,r,a,1),Oe(c.d,i=m,d))do if(a+=10,s=pe(u,a),r=e?Je(l,a+10):pe(t,a),c=N(s,r,a,1),!o){+G(c.d).slice(i+1,i+15)+1==1e14&&(c=g(c,m+1,0));break}while(Oe(c.d,i+=10,d));return w=!0,g(c,m,d)};f.minus=f.sub=function(t){var e,n,r,i,o,s,a,c,u,l,m,d,p=this,T=p.constructor;if(t=new T(t),!p.d||!t.d)return!p.s||!t.s?t=new T(NaN):p.d?t.s=-t.s:t=new T(t.d||p.s!==t.s?p:NaN),t;if(p.s!=t.s)return t.s=-t.s,p.plus(t);if(u=p.d,d=t.d,a=T.precision,c=T.rounding,!u[0]||!d[0]){if(d[0])t.s=-t.s;else if(u[0])t=new T(p);else return new T(c===3?-0:0);return w?g(t,a,c):t}if(n=U(t.e/b),l=U(p.e/b),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),r=Math.max(Math.ceil(a/b),s)+2,o>r&&(o=r,e.length=1),e.reverse(),r=o;r--;)e.push(0);e.reverse()}else{for(r=u.length,s=d.length,m=r<s,m&&(s=r),r=0;r<s;r++)if(u[r]!=d[r]){m=u[r]<d[r];break}o=0}for(m&&(e=u,u=d,d=e,t.s=-t.s),s=u.length,r=d.length-s;r>0;--r)u[s++]=0;for(r=d.length;r>o;){if(u[--r]<d[r]){for(i=r;i&&u[--i]===0;)u[i]=ie-1;--u[i],u[r]+=ie}u[r]-=d[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(t.d=u,t.e=et(u,n),w?g(t,a,c):t):new T(c===3?-0:0)};f.modulo=f.mod=function(t){var e,n=this,r=n.constructor;return t=new r(t),!n.d||!t.s||t.d&&!t.d[0]?new r(NaN):!t.d||n.d&&!n.d[0]?g(new r(n),r.precision,r.rounding):(w=!1,r.modulo==9?(e=N(n,t.abs(),0,3,1),e.s*=t.s):e=N(n,t,0,r.modulo,1),e=e.times(t),w=!0,n.minus(e))};f.naturalExponential=f.exp=function(){return bt(this)};f.naturalLogarithm=f.ln=function(){return pe(this)};f.negated=f.neg=function(){var t=new this.constructor(this);return t.s=-t.s,g(t)};f.plus=f.add=function(t){var e,n,r,i,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)),w?g(t,a,c):t;if(o=U(m.e/b),r=U(t.e/b),u=u.slice(),i=o-r,i){for(i<0?(n=u,i=-i,s=l.length):(n=l,r=o,s=u.length),o=Math.ceil(a/b),s=o>s?o+1:s+1,i>s&&(i=s,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(s=u.length,i=l.length,s-i<0&&(i=s,n=l,l=u,u=n),e=0;i;)e=(u[--i]=u[i]+l[i]+e)/ie|0,u[i]%=ie;for(e&&(u.unshift(e),++r),s=u.length;u[--s]==0;)u.pop();return t.d=u,t.e=et(u,r),w?g(t,a,c):t};f.precision=f.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(ge+t);return n.d?(e=nn(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};f.round=function(){var t=this,e=t.constructor;return g(new e(t),t.e+1,e.rounding)};f.sine=f.sin=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+Math.max(n.e,n.sd())+b,r.rounding=1,n=Qn(r,an(r,n)),r.precision=t,r.rounding=e,g(de>2?n.neg():n,t,e,!0)):new r(NaN)};f.squareRoot=f.sqrt=function(){var t,e,n,r,i,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(w=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=G(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=U((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),r=new l(e)):r=new l(u.toString()),n=(c=l.precision)+3;;)if(o=r,r=o.plus(N(s,o,n+2,1)).times(.5),G(o.d).slice(0,n)===(e=G(r.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!i&&e=="4999"){if(!i&&(g(o,c+1,0),o.times(o).eq(s))){r=o;break}n+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(g(r,c+1,1),t=!r.times(r).eq(s));break}return w=!0,g(r,c,l.rounding,t)};f.tangent=f.tan=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+10,r.rounding=1,n=n.sin(),n.s=1,n=N(n,new r(1).minus(n.times(n)).sqrt(),t+10,0),r.precision=t,r.rounding=e,g(de==2||de==4?n.neg():n,t,e,!0)):new r(NaN)};f.times=f.mul=function(t){var e,n,r,i,o,s,a,c,u,l=this,m=l.constructor,d=l.d,p=(t=new m(t)).d;if(t.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!t.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?t.s/0:t.s*0);for(n=U(l.e/b)+U(t.e/b),c=d.length,u=p.length,c<u&&(o=d,d=p,p=o,s=c,c=u,u=s),o=[],s=c+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)a=o[i]+p[r]*d[i-r-1]+e,o[i--]=a%ie|0,e=a/ie|0;o[i]=(o[i]+e)%ie|0}for(;!o[--s];)o.pop();return e?++n:o.shift(),t.d=o,t.e=et(o,n),w?g(t,m.precision,m.rounding):t};f.toBinary=function(t,e){return wt(this,2,t,e)};f.toDecimalPlaces=f.toDP=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Y(t,0,he),e===void 0?e=r.rounding:Y(e,0,8),g(n,t+n.e+1,e))};f.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=ce(r,!0):(Y(t,0,he),e===void 0?e=i.rounding:Y(e,0,8),r=g(new i(r),t+1,e),n=ce(r,!0,t+1)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toFixed=function(t,e){var n,r,i=this,o=i.constructor;return t===void 0?n=ce(i):(Y(t,0,he),e===void 0?e=o.rounding:Y(e,0,8),r=g(new o(i),t+i.e+1,e),n=ce(r,!1,t+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n};f.toFraction=function(t){var e,n,r,i,o,s,a,c,u,l,m,d,p=this,T=p.d,y=p.constructor;if(!T)return new y(p);if(u=n=new y(1),r=c=new y(0),e=new y(r),o=e.e=nn(T)-p.e-1,s=o%b,e.d[0]=M(10,s<0?b+s:s),t==null)t=o>0?e:u;else{if(a=new y(t),!a.isInt()||a.lt(u))throw Error(ge+a);t=a.gt(e)?o>0?e:u:a}for(w=!1,a=new y(G(T)),l=y.precision,y.precision=o=T.length*b*2;m=N(a,e,0,1,1),i=n.plus(m.times(r)),i.cmp(t)!=1;)n=r,r=i,i=u,u=c.plus(m.times(i)),c=i,i=e,e=a.minus(m.times(i)),a=i;return i=N(t.minus(n),r,0,1,1),c=c.plus(i.times(u)),n=n.plus(i.times(r)),c.s=u.s=p.s,d=N(u,r,o,1).minus(p).abs().cmp(N(c,n,o,1).minus(p).abs())<1?[u,r]:[c,n],y.precision=l,w=!0,d};f.toHexadecimal=f.toHex=function(t,e){return wt(this,16,t,e)};f.toNearest=function(t,e){var n=this,r=n.constructor;if(n=new r(n),t==null){if(!n.d)return n;t=new r(1),e=r.rounding}else{if(t=new r(t),e===void 0?e=r.rounding:Y(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]?(w=!1,n=N(n,t,0,e,1).times(t),w=!0,g(n)):(t.s=n.s,n=t),n};f.toNumber=function(){return+this};f.toOctal=function(t,e){return wt(this,8,t,e)};f.toPower=f.pow=function(t){var e,n,r,i,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(M(+a,u));if(a=new c(a),a.eq(1))return a;if(r=c.precision,o=c.rounding,t.eq(1))return g(a,r,o);if(e=U(t.e/b),e>=t.d.length-1&&(n=u<0?-u:u)<=Hn)return i=rn(c,a,n,r),t.s<0?new c(1).div(i):g(i,r,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=M(+a,u),e=n==0||!isFinite(n)?U(u*(Math.log("0."+G(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):(w=!1,c.rounding=a.s=1,n=Math.min(12,(e+"").length),i=bt(t.times(pe(a,r+n)),r),i.d&&(i=g(i,r+5,1),Oe(i.d,r,o)&&(e=r+10,i=g(bt(t.times(pe(a,e+n)),e),e+5,1),+G(i.d).slice(r+1,r+15)+1==1e14&&(i=g(i,r+1,0)))),i.s=s,w=!0,c.rounding=o,g(i,r,o))};f.toPrecision=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=ce(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Y(t,1,he),e===void 0?e=i.rounding:Y(e,0,8),r=g(new i(r),t,e),n=ce(r,t<=r.e||r.e<=i.toExpNeg,t)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toSignificantDigits=f.toSD=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Y(t,1,he),e===void 0?e=r.rounding:Y(e,0,8)),g(new r(n),t,e)};f.toString=function(){var t=this,e=t.constructor,n=ce(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};f.truncated=f.trunc=function(){return g(new this.constructor(this),this.e+1,1)};f.valueOf=f.toJSON=function(){var t=this,e=t.constructor,n=ce(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function G(t){var e,n,r,i=t.length-1,o="",s=t[0];if(i>0){for(o+=s,e=1;e<i;e++)r=t[e]+"",n=b-r.length,n&&(o+=fe(n)),o+=r;s=t[e],r=s+"",n=b-r.length,n&&(o+=fe(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Y(t,e,n){if(t!==~~t||t<e||t>n)throw Error(ge+t)}function Oe(t,e,n,r){var i,o,s,a;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=b,i=0):(i=Math.ceil((e+1)/b),e%=b),o=M(10,b-e),a=t[i]%o|0,r==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[i+1]/o/100|0)==M(10,e-2)-1||(a==o/2||a==0)&&(t[i+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=(r||n<4)&&a==9999||!r&&n>3&&a==4999):s=((r||n<4)&&a+1==o||!r&&n>3&&a+1==o/2)&&(t[i+1]/o/1e3|0)==M(10,e-3)-1,s}function Ze(t,e,n){for(var r,i=[0],o,s=0,a=t.length;s<a;){for(o=i.length;o--;)i[o]*=e;for(i[0]+=pt.indexOf(t.charAt(s++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function Zn(t,e){var n,r,i;if(e.isZero())return e;r=e.d.length,r<32?(n=Math.ceil(r/3),i=(1/tt(4,n)).toString()):(n=16,i="2.3283064365386962890625e-10"),t.precision+=n,e=Be(t,1,e.times(i),new t(1));for(var o=n;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return t.precision-=n,e}var N=function(){function t(r,i,o){var s,a=0,c=r.length;for(r=r.slice();c--;)s=r[c]*i+a,r[c]=s%o|0,a=s/o|0;return a&&r.unshift(a),r}function e(r,i,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(r[a]!=i[a]){c=r[a]>i[a]?1:-1;break}return c}function n(r,i,o,s){for(var a=0;o--;)r[o]-=a,a=r[o]<i[o]?1:0,r[o]=a*s+r[o]-i[o];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,o,s,a,c){var u,l,m,d,p,T,y,F,B,q,P,O,Te,le,ct,ze,Ee,lt,ne,He,Ye=r.constructor,mt=r.s==i.s?1:-1,V=r.d,L=i.d;if(!V||!V[0]||!L||!L[0])return new Ye(!r.s||!i.s||(V?L&&V[0]==L[0]:!L)?NaN:V&&V[0]==0||!L?mt*0:mt/0);for(c?(p=1,l=r.e-i.e):(c=ie,p=b,l=U(r.e/p)-U(i.e/p)),ne=L.length,Ee=V.length,B=new Ye(mt),q=B.d=[],m=0;L[m]==(V[m]||0);m++);if(L[m]>(V[m]||0)&&l--,o==null?(le=o=Ye.precision,s=Ye.rounding):a?le=o+(r.e-i.e)+1:le=o,le<0)q.push(1),T=!0;else{if(le=le/p+2|0,m=0,ne==1){for(d=0,L=L[0],le++;(m<Ee||d)&&le--;m++)ct=d*c+(V[m]||0),q[m]=ct/L|0,d=ct%L|0;T=d||m<Ee}else{for(d=c/(L[0]+1)|0,d>1&&(L=t(L,d,c),V=t(V,d,c),ne=L.length,Ee=V.length),ze=ne,P=V.slice(0,ne),O=P.length;O<ne;)P[O++]=0;He=L.slice(),He.unshift(0),lt=L[0],L[1]>=c/2&&++lt;do d=0,u=e(L,P,ne,O),u<0?(Te=P[0],ne!=O&&(Te=Te*c+(P[1]||0)),d=Te/lt|0,d>1?(d>=c&&(d=c-1),y=t(L,d,c),F=y.length,O=P.length,u=e(y,P,F,O),u==1&&(d--,n(y,ne<F?He:L,F,c))):(d==0&&(u=d=1),y=L.slice()),F=y.length,F<O&&y.unshift(0),n(P,y,O,c),u==-1&&(O=P.length,u=e(L,P,ne,O),u<1&&(d++,n(P,ne<O?He:L,O,c))),O=P.length):u===0&&(d++,P=[0]),q[m++]=d,u&&P[0]?P[O++]=V[ze]||0:(P=[V[ze]],O=1);while((ze++<Ee||P[0]!==void 0)&&le--);T=P[0]!==void 0}q[0]||q.shift()}if(p==1)B.e=l,Qt=T;else{for(m=1,d=q[0];d>=10;d/=10)m++;B.e=m+l*p-1,g(B,a?o+B.e+1:o,s,T)}return B}}();function g(t,e,n,r){var i,o,s,a,c,u,l,m,d,p=t.constructor;e:if(e!=null){if(m=t.d,!m)return t;for(i=1,a=m[0];a>=10;a/=10)i++;if(o=e-i,o<0)o+=b,s=e,l=m[d=0],c=l/M(10,i-s-1)%10|0;else if(d=Math.ceil((o+1)/b),a=m.length,d>=a)if(r){for(;a++<=d;)m.push(0);l=c=0,i=1,o%=b,s=o-b+1}else break e;else{for(l=a=m[d],i=1;a>=10;a/=10)i++;o%=b,s=o-b+i,c=s<0?0:l/M(10,i-s-1)%10|0}if(r=r||e<0||m[d+1]!==void 0||(s<0?l:l%M(10,i-s-1)),u=n<4?(c||r)&&(n==0||n==(t.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(o>0?s>0?l/M(10,i-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]=M(10,(b-e%b)%b),t.e=-e||0):m[0]=t.e=0,t;if(o==0?(m.length=d,a=1,d--):(m.length=d+1,a=M(10,b-o),m[d]=s>0?(l/M(10,i-s)%M(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]==ie&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=ie)break;m[d--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return w&&(t.e>p.maxE?(t.d=null,t.e=NaN):t.e<p.minE&&(t.e=0,t.d=[0])),t}function ce(t,e,n){if(!t.isFinite())return sn(t);var r,i=t.e,o=G(t.d),s=o.length;return e?(n&&(r=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+fe(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):i<0?(o="0."+fe(-i-1)+o,n&&(r=n-s)>0&&(o+=fe(r))):i>=s?(o+=fe(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+fe(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(o+="."),o+=fe(r))),o}function et(t,e){var n=t[0];for(e*=b;n>=10;n/=10)e++;return e}function Je(t,e,n){if(e>Yn)throw w=!0,n&&(t.precision=n),Error(Jt);return g(new t(je),e,1,!0)}function re(t,e,n){if(e>ht)throw Error(Jt);return g(new t(Qe),e,n,!0)}function nn(t){var e=t.length-1,n=e*b+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 fe(t){for(var e="";t--;)e+="0";return e}function rn(t,e,n,r){var i,o=new t(1),s=Math.ceil(r/b+4);for(w=!1;;){if(n%2&&(o=o.times(e),Zt(o.d,s)&&(i=!0)),n=U(n/2),n===0){n=o.d.length-1,i&&o.d[n]===0&&++o.d[n];break}e=e.times(e),Zt(e.d,s)}return w=!0,o}function Yt(t){return t.d[t.d.length-1]&1}function on(t,e,n){for(var r,i=new t(e[0]),o=0;++o<e.length;)if(r=new t(e[o]),r.s)i[n](r)&&(i=r);else{i=r;break}return i}function bt(t,e){var n,r,i,o,s,a,c,u=0,l=0,m=0,d=t.constructor,p=d.rounding,T=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?(w=!1,c=T):c=e,a=new d(.03125);t.e>-2;)t=t.times(a),m+=5;for(r=Math.log(M(2,m))/Math.LN10*2+5|0,c+=r,n=o=s=new d(1),d.precision=c;;){if(o=g(o.times(t),c,1),n=n.times(++l),a=s.plus(N(o,n,c,1)),G(a.d).slice(0,c)===G(s.d).slice(0,c)){for(i=m;i--;)s=g(s.times(s),c,1);if(e==null)if(u<3&&Oe(s.d,c-r,p,u))d.precision=c+=10,n=o=a=new d(1),l=0,u++;else return g(s,d.precision=T,p,w=!0);else return d.precision=T,s}s=a}}function pe(t,e){var n,r,i,o,s,a,c,u,l,m,d,p=1,T=10,y=t,F=y.d,B=y.constructor,q=B.rounding,P=B.precision;if(y.s<0||!F||!F[0]||!y.e&&F[0]==1&&F.length==1)return new B(F&&!F[0]?-1/0:y.s!=1?NaN:F?0:y);if(e==null?(w=!1,l=P):l=e,B.precision=l+=T,n=G(F),r=n.charAt(0),Math.abs(o=y.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)y=y.times(t),n=G(y.d),r=n.charAt(0),p++;o=y.e,r>1?(y=new B("0."+n),o++):y=new B(r+"."+n.slice(1))}else return u=Je(B,l+2,P).times(o+""),y=pe(new B(r+"."+n.slice(1)),l-T).plus(u),B.precision=P,e==null?g(y,P,q,w=!0):y;for(m=y,c=s=y=N(y.minus(1),y.plus(1),l,1),d=g(y.times(y),l,1),i=3;;){if(s=g(s.times(d),l,1),u=c.plus(N(s,new B(i),l,1)),G(u.d).slice(0,l)===G(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(Je(B,l+2,P).times(o+""))),c=N(c,new B(p),l,1),e==null)if(Oe(c.d,l-T,q,a))B.precision=l+=T,u=s=y=N(m.minus(1),m.plus(1),l,1),d=g(y.times(y),l,1),i=a=1;else return g(c,B.precision=P,q,w=!0);else return B.precision=P,c;c=u,i+=2}}function sn(t){return String(t.s*t.s/0)}function yt(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;r++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(r,i),e){if(i-=r,t.e=n=n-r-1,t.d=[],r=(n+1)%b,n<0&&(r+=b),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=b;r<i;)t.d.push(+e.slice(r,r+=b));e=e.slice(r),r=b-e.length}else r-=i;for(;r--;)e+="0";t.d.push(+e),w&&(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 jn(t,e){var n,r,i,o,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),tn.test(e))return yt(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(Xn.test(e))n=16,e=e.toLowerCase();else if(Wn.test(e))n=2;else if(zn.test(e))n=8;else throw Error(ge+e);for(o=e.search(/p/i),o>0?(c=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,r=t.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,i=rn(r,new r(n),o,o*2)),u=Ze(e,n,ie),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new r(t.s*0):(t.e=et(u,l),t.d=u,w=!1,s&&(t=N(t,i,a*4)),c&&(t=t.times(Math.abs(c)<54?M(2,c):De.pow(2,c))),w=!0,t)}function Qn(t,e){var n,r=e.d.length;if(r<3)return e.isZero()?e:Be(t,2,e,e);n=1.4*Math.sqrt(r),n=n>16?16:n|0,e=e.times(1/tt(5,n)),e=Be(t,2,e,e);for(var i,o=new t(5),s=new t(16),a=new t(20);n--;)i=e.times(e),e=e.times(o.plus(i.times(s.times(i).minus(a))));return e}function Be(t,e,n,r,i){var o,s,a,c,u=1,l=t.precision,m=Math.ceil(l/b);for(w=!1,c=n.times(n),a=new t(r);;){if(s=N(a.times(c),new t(e++*e++),l,1),a=i?r.plus(s):r.minus(s),r=N(s.times(c),new t(e++*e++),l,1),s=a.plus(r),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=r,r=s,s=o,u++}return w=!0,s.d.length=m+1,s}function tt(t,e){for(var n=t;--e;)n*=t;return n}function an(t,e){var n,r=e.s<0,i=re(t,t.precision,1),o=i.times(.5);if(e=e.abs(),e.lte(o))return de=r?4:1,e;if(n=e.divToInt(i),n.isZero())de=r?3:2;else{if(e=e.minus(n.times(i)),e.lte(o))return de=Yt(n)?r?2:3:r?4:1,e;de=Yt(n)?r?1:4:r?3:2}return e.minus(i).abs()}function wt(t,e,n,r){var i,o,s,a,c,u,l,m,d,p=t.constructor,T=n!==void 0;if(T?(Y(n,1,he),r===void 0?r=p.rounding:Y(r,0,8)):(n=p.precision,r=p.rounding),!t.isFinite())l=sn(t);else{for(l=ce(t),s=l.indexOf("."),T?(i=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):i=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Ze(ce(d),10,i),d.e=d.d.length),m=Ze(l,10,i),o=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=T?"0p+0":"0";else{if(s<0?o--:(t=new p(t),t.d=m,t.e=o,t=N(t,d,n,r,0,i),m=t.d,o=t.e,u=Qt),s=m[n],a=i/2,u=u||m[n+1]!==void 0,u=r<4?(s!==void 0||u)&&(r===0||r===(t.s<0?3:2)):s>a||s===a&&(r===4||u||r===6&&m[n-1]&1||r===(t.s<0?8:7)),m.length=n,u)for(;++m[--n]>i-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(T){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=Ze(l,i,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 Zt(t,e){if(t.length>e)return t.length=e,!0}function Jn(t){return new this(t).abs()}function $n(t){return new this(t).acos()}function er(t){return new this(t).acosh()}function tr(t,e){return new this(t).plus(e)}function nr(t){return new this(t).asin()}function rr(t){return new this(t).asinh()}function ir(t){return new this(t).atan()}function or(t){return new this(t).atanh()}function sr(t,e){t=new this(t),e=new this(e);var n,r=this.precision,i=this.rounding,o=r+4;return!t.s||!e.s?n=new this(NaN):!t.d&&!e.d?(n=re(this,o,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?re(this,r,i):new this(0),n.s=t.s):!t.d||e.isZero()?(n=re(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=re(this,o,1),this.precision=r,this.rounding=i,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(N(t,e,o,1)),n}function ar(t){return new this(t).cbrt()}function ur(t){return g(t=new this(t),t.e+1,2)}function cr(t,e,n){return new this(t).clamp(e,n)}function lr(t){if(!t||typeof t!="object")throw Error($e+"Object expected");var e,n,r,i=t.defaults===!0,o=["precision",1,he,"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],i&&(this[n]=gt[n]),(r=t[n])!==void 0)if(U(r)===r&&r>=o[e+1]&&r<=o[e+2])this[n]=r;else throw Error(ge+n+": "+r);if(n="crypto",i&&(this[n]=gt[n]),(r=t[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error($t);else this[n]=!1;else throw Error(ge+n+": "+r);return this}function mr(t){return new this(t).cos()}function dr(t){return new this(t).cosh()}function un(t){var e,n,r;function i(o){var s,a,c,u=this;if(!(u instanceof i))return new i(o);if(u.constructor=i,jt(o)){u.s=o.s,w?!o.d||o.e>i.maxE?(u.e=NaN,u.d=null):o.e<i.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++;w?s>i.maxE?(u.e=NaN,u.d=null):s<i.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}else if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return yt(u,o.toString())}else if(c!=="string")throw Error(ge+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),tn.test(o)?yt(u,o):jn(u,o)}if(i.prototype=f,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=lr,i.clone=un,i.isDecimal=jt,i.abs=Jn,i.acos=$n,i.acosh=er,i.add=tr,i.asin=nr,i.asinh=rr,i.atan=ir,i.atanh=or,i.atan2=sr,i.cbrt=ar,i.ceil=ur,i.clamp=cr,i.cos=mr,i.cosh=dr,i.div=fr,i.exp=pr,i.floor=gr,i.hypot=hr,i.ln=br,i.log=yr,i.log10=Tr,i.log2=wr,i.max=xr,i.min=Ar,i.mod=kr,i.mul=Pr,i.pow=Br,i.random=Ir,i.round=Nr,i.sign=Sr,i.sin=Cr,i.sinh=Lr,i.sqrt=Er,i.sub=Rr,i.sum=Fr,i.tan=Or,i.tanh=Dr,i.trunc=Mr,t===void 0&&(t={}),t&&t.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)t.hasOwnProperty(n=r[e++])||(t[n]=this[n]);return i.config(t),i}function fr(t,e){return new this(t).div(e)}function pr(t){return new this(t).exp()}function gr(t){return g(t=new this(t),t.e+1,3)}function hr(){var t,e,n=new this(0);for(w=!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 w=!0,new this(1/0);n=e}return w=!0,n.sqrt()}function jt(t){return t instanceof De||t&&t.toStringTag===en||!1}function br(t){return new this(t).ln()}function yr(t,e){return new this(t).log(e)}function wr(t){return new this(t).log(2)}function Tr(t){return new this(t).log(10)}function xr(){return on(this,arguments,"lt")}function Ar(){return on(this,arguments,"gt")}function kr(t,e){return new this(t).mod(e)}function Pr(t,e){return new this(t).mul(e)}function Br(t,e){return new this(t).pow(e)}function Ir(t){var e,n,r,i,o=0,s=new this(1),a=[];if(t===void 0?t=this.precision:Y(t,1,he),r=Math.ceil(t/b),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));o<r;)i=e[o],i>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);o<r;)i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(i%1e7),o+=4);o=r/4}else throw Error($t);else for(;o<r;)a[o++]=Math.random()*1e7|0;for(r=a[--o],t%=b,r&&t&&(i=M(10,b-t),a[o]=(r/i|0)*i);a[o]===0;o--)a.pop();if(o<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=b)a.shift();for(r=1,i=a[0];i>=10;i/=10)r++;r<b&&(n-=b-r)}return s.e=n,s.d=a,s}function Nr(t){return g(t=new this(t),t.e+1,this.rounding)}function Sr(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function Cr(t){return new this(t).sin()}function Lr(t){return new this(t).sinh()}function Er(t){return new this(t).sqrt()}function Rr(t,e){return new this(t).sub(e)}function Fr(){var t=0,e=arguments,n=new this(e[t]);for(w=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return w=!0,g(n,this.precision,this.rounding)}function Or(t){return new this(t).tan()}function Dr(t){return new this(t).tanh()}function Mr(t){return g(t=new this(t),t.e+1,1)}f[Symbol.for("nodejs.util.inspect.custom")]=f.toString;f[Symbol.toStringTag]="Decimal";var De=f.constructor=un(gt);je=new De(je);Qe=new De(Qe);var v=De;var nt=require("@solana/web3.js");var cn=require("@solana/spl-token"),I=require("@solana/web3.js");function Tt({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var wi=[Tt({pubkey:cn.TOKEN_PROGRAM_ID,isWritable:!1}),Tt({pubkey:I.SystemProgram.programId,isWritable:!1}),Tt({pubkey:I.SYSVAR_RENT_PUBKEY,isWritable:!1})];function ln({publicKey:t,transformSol:e}){let n=mn(t.toString());if(n instanceof I.PublicKey)return e&&n.equals(Ie)?xt:n;if(e&&n.toString()===Ie.toBase58())return xt;if(typeof n=="string"){if(n===I.PublicKey.default.toBase58())return I.PublicKey.default;try{return new I.PublicKey(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function mn(t){try{return new I.PublicKey(t)}catch{return t}}var Ti=new I.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),xi=new I.PublicKey("SysvarRent111111111111111111111111111111111"),Ai=new I.PublicKey("SysvarC1ock11111111111111111111111111111111"),_r=new I.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),ki=new I.PublicKey("Sysvar1nstructions1111111111111111111111111"),Pi=new I.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Bi=new I.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Ii=new I.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Ni=new I.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Si=new I.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ci=new I.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Li=new I.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ei=new I.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Ri=new I.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Fi=new I.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Oi=new I.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),xt=new I.PublicKey("So11111111111111111111111111111111111111112"),Ie=I.PublicKey.default;var dn=require("@solana/web3.js"),At=require("@solana/spl-token"),kt={chainId:101,address:dn.PublicKey.default.toBase58(),programId:At.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},xe={chainId:101,address:"So11111111111111111111111111111111111111112",programId:At.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var Pt=class{constructor({mint:e,decimals:n,symbol:r,name:i,skipMint:o=!1,isToken2022:s=!1}){if(e===Ie.toBase58()||e instanceof nt.PublicKey&&Ie.equals(e)){this.decimals=xe.decimals,this.symbol=xe.symbol,this.name=xe.name,this.mint=new nt.PublicKey(xe.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=r||e.toString().substring(0,6),this.name=i||e.toString().substring(0,6),this.mint=o?nt.PublicKey.default:ln({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Ae=Pt;Ae.WSOL=new Pt(me(ue({},xe),{mint:xe.address}));var _e=D(require("big.js")),pn=D(require("bn.js")),gn=D(require("decimal.js-light"));var fn=D(require("toformat")),vr=fn.default,Me=vr;var rt=j("module/fraction"),Bt=Me(_e.default),ve=Me(gn.default),Kr={[0]:ve.ROUND_DOWN,[1]:ve.ROUND_HALF_UP,[2]:ve.ROUND_UP},qr={[0]:_e.default.roundDown,[1]:_e.default.roundHalfUp,[2]:_e.default.roundUp},E=class{constructor(e,n=new pn.default(1)){this.numerator=be(e),this.denominator=be(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new E(this.denominator,this.numerator)}add(e){let n=e instanceof E?e:new E(be(e));return this.denominator.eq(n.denominator)?new E(this.numerator.add(n.numerator),this.denominator):new E(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof E?e:new E(be(e));return this.denominator.eq(n.denominator)?new E(this.numerator.sub(n.numerator),this.denominator):new E(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof E?e:new E(be(e));return new E(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof E?e:new E(be(e));return new E(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},r=1){Number.isInteger(e)||rt.logWithError(`${e} is not an integer.`),e<=0&&rt.logWithError(`${e} is not positive.`),ve.set({precision:e+1,rounding:Kr[r]});let i=new ve(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return i.toFormat(i.decimalPlaces(),n)}toFixed(e,n={groupSeparator:""},r=1){return Number.isInteger(e)||rt.logWithError(`${e} is not an integer.`),e<0&&rt.logWithError(`${e} is negative.`),Bt.DP=e,Bt.RM=qr[r]||1,new Bt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var $i=j("Raydium_price");var It=class{constructor({decimals:e,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=r}equals(e){return this===e}},it=It;it.SOL=new It(kt);var hn=D(require("bn.js"));var so=new E(new hn.default(100));var Vr=new X.default(0),Bo=new X.default(1),Io=new X.default(2),No=new X.default(3),So=new X.default(5),Ur=new X.default(10),Co=new X.default(100),Lo=new X.default(1e3),Eo=new X.default(1e4),bn=9007199254740991;function be(t){let e=j("Raydium_parseBigNumberish");if(t instanceof X.default)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new X.default(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=bn||t<=-bn)&&e.logWithError(`BigNumberish number overflow: ${t}`),new X.default(String(t))):typeof t=="bigint"?new X.default(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new X.default(0))}var Vo=j("Raydium_amount"),Uo=Me(yn.default);var qe=require("@solana/web3.js"),jr=D(require("axios"));var Ne=require("@solana/web3.js"),Hr=require("@solana/spl-token");var ls=j("Raydium_txUtil");var Ke=require("@solana/web3.js");var Yr=require("@solana/web3.js"),wn=require("@solana/spl-token");var bs=j("Raydium_accountInfo_util");var Zr={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new Ke.AddressLookupTableAccount({key:new Ke.PublicKey("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:Ke.AddressLookupTableAccount.deserialize(Buffer.from("AQAAAP//////////d49+DAAAAAAAAQZMWvw7GUNJdaccNBVnb57OKakxL2BHLYvhRwVILRsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkG3fbh7nWP3hhCXbzkbM3athr8TYO5DSf+vfko2KGL/AVKU1D4XciC1hSlVnJ4iilt3x6rq9CmBniISTL07vagBqfVFxksXFEhjMlMPUrxf1ja7gibof1E49vZigAAAAAGp9UXGMd0yShWY5hpHV62i164o5tLbVxzVVshAAAAAIyXJY9OJInxuz0QKRSODYMLWhOZ2v8QhASOe9jb6fhZC3BlsePRfEU4nVJ/awTDzVi4bHMaoP21SbbRvAP4KUbIScv+6Yw2LHF/6K0ZjUPibbSWXCirYPGuuVl7zT789IUPLW4CpHr4JNCatp3ELXDLKMv6JJ+37le50lbBJ2LvDQdRqCgtphMF/imcN7mY5YRx2xE1A3MQ+L4QRaYK9u4GRfZP3LsAd00a+IkCpA22UNQMKdq5BFbJuwuOLqc8zxCTDlqxBG8J0HcxtfogQHDK06ukzfaXiNDKAob1MqBHS9lJxDYCwz8gd5DtFqNSTKG5l1zxIaKpDP/sffi2is1H9aKveyXSu5StXElYRl9SD5As0DHE4N0GLnf84/siiKXVyp4Ez121kLcUui/jLLFZEz/BwZK3Ilf9B9OcsEAeDMKAy2vjGSxQODgBz0QwGA+eP4ZjIjrIAQaXENv31QfLlOdXSRCkaybRniDHF4C8YcwhcvsqrOVuTP4B2Na+9wLdtrB31uz2rtlFI5kahdsnp/d1SrASDInYCtTYtdoke4kX+hoKWcEWM4Tle8pTUkUVv4BxS6fje/EzKBE4Qu9N9LMnrw/JNO0hqMVB4rk/2ou4AB1loQ7FZoPwut2o4KZB+0p9xnbrQKw038qjpHar+PyDwvxBRcu5hpHw3dguezeWv+IwvgW5icu8EGkhGa9AkFPPJT7VMSFb8xowveU=","base64"))})};var z=require("@solana/web3.js"),Vs=new z.PublicKey("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),Us=new z.PublicKey("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Ws=new z.PublicKey("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Xs=new z.PublicKey("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),zs=new z.PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Hs=new z.PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Ys=new z.PublicKey("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Zs=new z.PublicKey("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),js=new z.PublicKey("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),Qs=new z.PublicKey("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),Js=new z.PublicKey("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),$s=new z.PublicKey("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),ea=new z.PublicKey("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),ta=new z.PublicKey("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi");var Jr=require("@solana/web3.js");var $r=require("@solana/spl-token");var Q=D(require("bn.js")),Ge=1e4;function oe(t,e,n,r){if(e===void 0)return{amount:t,fee:void 0,expirationTime:void 0};let i=me(ue({},e),{olderTransferFee:{epoch:BigInt(e.olderTransferFee.epoch),maximumFee:BigInt(e.olderTransferFee.maximumFee),transferFeeBasisPoints:e.olderTransferFee.transferFeeBasisPoints},newerTransferFee:{epoch:BigInt(e.newerTransferFee.epoch),maximumFee:BigInt(e.newerTransferFee.maximumFee),transferFeeBasisPoints:e.newerTransferFee.transferFeeBasisPoints}}),o=n.epoch<i.newerTransferFee.epoch?i.olderTransferFee:i.newerTransferFee,s=new Q.default(o.maximumFee.toString()),a=n.epoch<i.newerTransferFee.epoch?(Number(i.newerTransferFee.epoch)*n.slotsInEpoch-n.absoluteSlot)*400/1e3:void 0;if(r)if(o.transferFeeBasisPoints===Ge){let c=new Q.default(o.maximumFee.toString());return{amount:t.add(c),fee:c,expirationTime:a}}else{let c=Lt(t.mul(new Q.default(Ge)),new Q.default(Ge-o.transferFeeBasisPoints)),u=new Q.default(o.maximumFee.toString()),l=c.sub(t).gt(u)?t.add(u):c,m=Lt(l.mul(new Q.default(o.transferFeeBasisPoints)),new Q.default(Ge)),d=m.gt(s)?s:m;return{amount:l,fee:d,expirationTime:a}}else{let c=Lt(t.mul(new Q.default(o.transferFeeBasisPoints)),new Q.default(Ge)),u=c.gt(s)?s:c;return{amount:t,fee:u,expirationTime:a}}}function Ve(t,e){return t===void 0?e:e===void 0?t:Math.min(t,e)}function Lt(t,e){let{div:n,mod:r}=t.divmod(e);return r.gt(new Q.default(0))?n.add(new Q.default(1)):n}var se=D(require("bn.js")),J=new se.default(0),ye=new se.default(1),xn=new se.default(-1),$=new se.default(1).shln(64),ot=new se.default(1).shln(128),Et=$.sub(ye),Ue=64,An=ot.subn(1),ke=-443636,Se=-ke,Rt=new se.default("4295048016"),Ft=new se.default("79226673521066979257578248091"),kn=16,Pn="59543866431248",Bn="184467440737095516",In="15793534762490258745",ei=new se.default(10).pow(new se.default(6));var ka=new se.default("18446744073700000000");var k=D(require("bn.js"));var La=Buffer.from("amm_config","utf8"),Ea=Buffer.from("pool","utf8"),Ra=Buffer.from("pool_vault","utf8"),Fa=Buffer.from("pool_reward_vault","utf8"),Oa=Buffer.from("position","utf8"),Da=Buffer.from("tick_array","utf8"),Ma=Buffer.from("operation","utf8"),_a=Buffer.from("pool_tick_array_bitmap_extension","utf8");var mi=require("@solana/web3.js"),di=D(require("bn.js"));var li=D(require("bn.js"));var Ln=require("@solana/web3.js"),Le=D(require("bn.js"));var h=require("@solana/buffer-layout"),Ot=h.Layout,Nn=h.Structure;var Dt=h.UInt;var Sn=h.u8,Ce=h.u16;var we=h.s32;var Cn=h.seq;var ee=h.blob;var We=class extends Ot{constructor(n,r,i){super(n,i);this.blob=ee(n),this.signed=r}decode(n,r=0){let i=new Le.default(this.blob.decode(n,r),10,"le");return this.signed?i.fromTwos(this.span*8).clone():i}encode(n,r,i=0){return typeof n=="number"&&(n=new Le.default(n)),this.signed&&(n=n.toTwos(this.span*8)),this.blob.encode(n.toArrayLike(Buffer,"le",this.span),r,i)}};function te(t){return new Dt(1,t)}function Xe(t){return new Dt(4,t)}function S(t){return new We(8,!1,t)}function C(t){return new We(16,!1,t)}function En(t){return new We(16,!0,t)}var st=class extends Ot{constructor(n,r,i,o){super(n.span,o);this.layout=n,this.decoder=r,this.encoder=i}decode(n,r){return this.decoder(this.layout.decode(n,r))}encode(n,r,i){return this.layout.encode(this.encoder(n),r,i)}getSpan(n,r){return this.layout.getSpan(n,r)}};function _(t){return new st(ee(32),e=>new Ln.PublicKey(e),e=>e.toBuffer(),t)}function Rn(t){return new st(Sn(),ti,ni,t)}function ti(t){if(t===0)return!1;if(t===1)return!0;throw new Error("Invalid bool: "+t)}function ni(t){return t?1:0}var Mt=class extends Nn{decode(e,n){return super.decode(e,n)}};function Z(t,e,n){return new Mt(t,e,n)}function R(t,e,n){let r,i=typeof e=="number"?e:(0,Le.isBN)(e)?e.toNumber():new Proxy(e,{get(o,s){if(!r){let a=Reflect.get(o,"count");r=(0,Le.isBN)(a)?a.toNumber():a,Reflect.set(o,"count",r)}return Reflect.get(o,s)},set(o,s,a){return s==="count"&&(r=a),Reflect.set(o,s,a)}});return Cn(t,i,n)}var _t=14;var uu=Z([ee(8),te("bump"),Ce("index"),_(""),Xe("protocolFeeRate"),Xe("tradeFeeRate"),Ce("tickSpacing"),R(S(),8,"")]),ii=Z([Xe("blockTimestamp"),C("sqrtPriceX64"),C("cumulativeTimePriceX64"),R(C(),1,"")]),cu=Z([ee(8),Rn("initialized"),_("poolId"),R(ii,1e3,"observations"),R(C(),5,"")]),oi=Z([te("rewardState"),S("openTime"),S("endTime"),S("lastUpdateTime"),C("emissionsPerSecondX64"),S("rewardTotalEmissioned"),S("rewardClaimed"),_("tokenMint"),_("tokenVault"),_("creator"),C("rewardGrowthGlobalX64")]),lu=Z([ee(8),te("bump"),_("ammConfig"),_("creator"),_("mintA"),_("mintB"),_("vaultA"),_("vaultB"),_("observationId"),te("mintDecimalsA"),te("mintDecimalsB"),Ce("tickSpacing"),C("liquidity"),C("sqrtPriceX64"),we("tickCurrent"),Ce("observationIndex"),Ce("observationUpdateDuration"),C("feeGrowthGlobalX64A"),C("feeGrowthGlobalX64B"),S("protocolFeesTokenA"),S("protocolFeesTokenB"),C("swapInAmountTokenA"),C("swapOutAmountTokenB"),C("swapInAmountTokenB"),C("swapOutAmountTokenA"),te("status"),R(te(),7,""),R(oi,3,"rewardInfos"),R(S(),16,"tickArrayBitmap"),S("totalFeesTokenA"),S("totalFeesClaimedTokenA"),S("totalFeesTokenB"),S("totalFeesClaimedTokenB"),S("fundFeesTokenA"),S("fundFeesTokenB"),S("startTime"),R(S(),15*4-3,"padding")]),si=Z([C("growthInsideLastX64"),S("rewardAmountOwed")]),ai=Z([ee(8),te("bump"),_("nftMint"),_("poolId"),we("tickLower"),we("tickUpper"),C("liquidity"),C("feeGrowthInsideLastX64A"),C("feeGrowthInsideLastX64B"),S("tokenFeesOwedA"),S("tokenFeesOwedB"),R(si,3,"rewardInfos"),R(S(),8,"")]),mu=Z([ee(8),te("bump"),_("poolId"),we("tickLowerIndex"),we("tickUpperIndex"),C("liquidity"),C("feeGrowthInsideLastX64A"),C("feeGrowthInsideLastX64B"),S("tokenFeesOwedA"),S("tokenFeesOwedB"),R(C(),3,"rewardGrowthInside"),R(S(),8,"")]),ui=Z([we("tick"),En("liquidityNet"),C("liquidityGross"),C("feeGrowthOutsideX64A"),C("feeGrowthOutsideX64B"),R(C(),3,"rewardGrowthsOutsideX64"),R(Xe(),13,"")]),Fn=Z([ee(8),_("poolId"),we("startTickIndex"),R(ui,at,"ticks"),te("initializedTickCount"),R(te(),115,"")]),du=Z([ee(329),R(_(),100,"whitelistMints")]),ci=Z([ee(8),_("poolId"),R(R(S(),8),_t,"positiveTickArrayBitmap"),R(R(S(),8),_t,"negativeTickArrayBitmap")]);var at=60;var A=class{static mulDivRoundingUp(e,n,r){let i=e.mul(n),o=i.div(r);return i.mod(r).eq(J)||(o=o.add(ye)),o}static mulDivFloor(e,n,r){if(r.eq(J))throw new Error("division by 0");return e.mul(n).div(r)}static mulDivCeil(e,n,r){if(r.eq(J))throw new Error("division by 0");return e.mul(n).add(r.sub(ye)).div(r)}static x64ToDecimal(e,n){return new v(e.toString()).div(v.pow(2,64)).toDecimalPlaces(n)}static decimalToX64(e){return new k.default(e.mul(v.pow(2,64)).floor().toFixed())}static wrappingSubU128(e,n){return e.add(ot).sub(n).mod(ot)}};function K(t,e){return Gt(t.mul(e),64,256)}function fi(t,e,n){let r=t.toTwos(n).shln(e);return r.imaskn(n+1),r.fromTwos(n)}function Gt(t,e,n){let r=t.toTwos(n).shrn(e);return r.imaskn(n-e+1),r.fromTwos(n-e)}var H=class{static sqrtPriceX64ToPrice(e,n,r){return