UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 353 kB
var mc=Object.defineProperty,dc=Object.defineProperties;var pc=Object.getOwnPropertyDescriptors;var Eo=Object.getOwnPropertySymbols;var Cs=Object.prototype.hasOwnProperty,Rs=Object.prototype.propertyIsEnumerable;var Ks=(r,e,t)=>e in r?mc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e)=>{for(var t in e||(e={}))Cs.call(e,t)&&Ks(r,t,e[t]);if(Eo)for(var t of Eo(e))Rs.call(e,t)&&Ks(r,t,e[t]);return r},E=(r,e)=>dc(r,pc(e));var Re=(r,e)=>{var t={};for(var n in r)Cs.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Eo)for(var n of Eo(r))e.indexOf(n)<0&&Rs.call(r,n)&&(t[n]=r[n]);return t};import{merge as up}from"lodash";import wa from"axios";import{get as Os,set as fc}from"lodash";var Yr=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(t)}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}},Ls={},yc={};function ue(r){let e=Os(Ls,r);if(!e){let t=Os(yc,r);e=new Yr({name:r,logLevel:t}),fc(Ls,r,e)}return e}import{PublicKey as Il}from"@solana/web3.js";import Bl from"bn.js";import hl from"big.js";import tr from"bn.js";import it from"bn.js";var Bn=9e15,Zt=1e9,jr="0123456789abcdef",Wo="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",qo="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Hr={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Bn,maxE:Bn,crypto:!1},vs,vt,oe=!0,Go="[DecimalError] ",Ht=Go+"Invalid argument: ",Vs=Go+"Precision limit exceeded",Fs=Go+"crypto unavailable",Es="[object Decimal]",ze=Math.floor,Ne=Math.pow,bc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,gc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ac=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ds=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,kt=1e7,te=7,wc=9007199254740991,Pc=Wo.length-1,Zr=qo.length-1,_={toStringTag:Es};_.absoluteValue=_.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Z(r)};_.ceil=function(){return Z(new this.constructor(this),this.e+1,2)};_.clampedTo=_.clamp=function(r,e){var t,n=this,o=n.constructor;if(r=new o(r),e=new o(e),!r.s||!e.s)return new o(NaN);if(r.gt(e))throw Error(Ht+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new o(n)};_.comparedTo=_.cmp=function(r){var e,t,n,o,i=this,s=i.d,a=(r=new i.constructor(r)).d,c=i.s,u=r.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(i.e!==r.e)return i.e>r.e^c<0?1:-1;for(n=s.length,o=a.length,e=0,t=n<o?n:o;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return n===o?0:n>o^c<0?1:-1};_.cosine=_.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+te,n.rounding=1,t=hc(n,Xs(n,t)),n.precision=r,n.rounding=e,Z(vt==2||vt==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};_.cubeRoot=_.cbrt=function(){var r,e,t,n,o,i,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(oe=!1,i=l.s*Ne(l.s*l,1/3),!i||Math.abs(i)==1/0?(t=De(l.d),r=l.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Ne(t,1/3),r=ze((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new m(t),n.s=l.s):n=new m(i.toString()),s=(r=m.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=he(u.plus(l).times(a),u.plus(c),s+2,1),De(a.d).slice(0,s)===(t=De(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!o&&t=="4999"){if(!o&&(Z(a,r+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Z(n,r+1,1),e=!n.times(n).times(n).eq(l));break}return oe=!0,Z(n,r,m.rounding,e)};_.decimalPlaces=_.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-ze(this.e/te))*te,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};_.dividedBy=_.div=function(r){return he(this,new this.constructor(r))};_.dividedToIntegerBy=_.divToInt=function(r){var e=this,t=e.constructor;return Z(he(e,new t(r),0,1,1),t.precision,t.rounding)};_.equals=_.eq=function(r){return this.cmp(r)===0};_.floor=function(){return Z(new this.constructor(this),this.e+1,3)};_.greaterThan=_.gt=function(r){return this.cmp(r)>0};_.greaterThanOrEqualTo=_.gte=function(r){var e=this.cmp(r);return e==1||e===0};_.hyperbolicCosine=_.cosh=function(){var r,e,t,n,o,i=this,s=i.constructor,a=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return a;t=s.precision,n=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,o=i.d.length,o<32?(r=Math.ceil(o/3),e=(1/zo(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=xn(s,1,i.times(e),new s(1),!0);for(var c,u=r,l=new s(8);u--;)c=i.times(i),i=a.minus(c.times(l.minus(c.times(l))));return Z(i,s.precision=t,s.rounding=n,!0)};_.hyperbolicSine=_.sinh=function(){var r,e,t,n,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(o.e,o.sd())+4,i.rounding=1,n=o.d.length,n<3)o=xn(i,2,o,o,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,o=o.times(1/zo(5,r)),o=xn(i,2,o,o,!0);for(var s,a=new i(5),c=new i(16),u=new i(20);r--;)s=o.times(o),o=o.times(a.plus(s.times(c.times(s).plus(u))))}return i.precision=e,i.rounding=t,Z(o,e,t,!0)};_.hyperbolicTangent=_.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,he(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};_.inverseCosine=_.acos=function(){var r,e=this,t=e.constructor,n=e.abs().cmp(1),o=t.precision,i=t.rounding;return n!==-1?n===0?e.isNeg()?ht(t,o,i):new t(0):new t(NaN):e.isZero()?ht(t,o+4,i).times(.5):(t.precision=o+6,t.rounding=1,e=e.asin(),r=ht(t,o+4,i).times(.5),t.precision=o,t.rounding=i,r.minus(e))};_.inverseHyperbolicCosine=_.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,oe=!1,t=t.times(t).minus(1).sqrt().plus(t),oe=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};_.inverseHyperbolicSine=_.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,oe=!1,t=t.times(t).plus(1).sqrt().plus(t),oe=!0,n.precision=r,n.rounding=e,t.ln())};_.inverseHyperbolicTangent=_.atanh=function(){var r,e,t,n,o=this,i=o.constructor;return o.isFinite()?o.e>=0?new i(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(r=i.precision,e=i.rounding,n=o.sd(),Math.max(n,r)<2*-o.e-1?Z(new i(o),r,e,!0):(i.precision=t=n-o.e,o=he(o.plus(1),new i(1).minus(o),t+r,1),i.precision=r+4,i.rounding=1,o=o.ln(),i.precision=r,i.rounding=e,o.times(.5))):new i(NaN)};_.inverseSine=_.asin=function(){var r,e,t,n,o=this,i=o.constructor;return o.isZero()?new i(o):(e=o.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=ht(i,t+4,n).times(.5),r.s=o.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,o.times(2)))};_.inverseTangent=_.atan=function(){var r,e,t,n,o,i,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<=Zr)return s=ht(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=Zr)return s=ht(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/te+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(oe=!1,e=Math.ceil(a/te),n=1,c=u.times(u),s=new l(u),o=u;r!==-1;)if(o=o.times(c),i=s.minus(o.div(n+=2)),o=o.times(c),s=i.plus(o.div(n+=2)),s.d[e]!==void 0)for(r=e;s.d[r]===i.d[r]&&r--;);return t&&(s=s.times(2<<t-1)),oe=!0,Z(s,l.precision=m,l.rounding=d,!0)};_.isFinite=function(){return!!this.d};_.isInteger=_.isInt=function(){return!!this.d&&ze(this.e/te)>this.d.length-2};_.isNaN=function(){return!this.s};_.isNegative=_.isNeg=function(){return this.s<0};_.isPositive=_.isPos=function(){return this.s>0};_.isZero=function(){return!!this.d&&this.d[0]===0};_.lessThan=_.lt=function(r){return this.cmp(r)<0};_.lessThanOrEqualTo=_.lte=function(r){return this.cmp(r)<1};_.logarithm=_.log=function(r){var e,t,n,o,i,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,p=5;if(r==null)r=new l(10),e=!0;else{if(r=new l(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new l(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new l(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(o=t[0];o%10===0;)o/=10;i=o!==1}if(oe=!1,a=m+p,s=jt(u,a),n=e?Uo(l,a+10):jt(r,a),c=he(s,n,a,1),qn(c.d,o=m,d))do if(a+=10,s=jt(u,a),n=e?Uo(l,a+10):jt(r,a),c=he(s,n,a,1),!i){+De(c.d).slice(o+1,o+15)+1==1e14&&(c=Z(c,m+1,0));break}while(qn(c.d,o+=10,d));return oe=!0,Z(c,m,d)};_.minus=_.sub=function(r){var e,t,n,o,i,s,a,c,u,l,m,d,p=this,y=p.constructor;if(r=new y(r),!p.d||!r.d)return!p.s||!r.s?r=new y(NaN):p.d?r.s=-r.s:r=new y(r.d||p.s!==r.s?p:NaN),r;if(p.s!=r.s)return r.s=-r.s,p.plus(r);if(u=p.d,d=r.d,a=y.precision,c=y.rounding,!u[0]||!d[0]){if(d[0])r.s=-r.s;else if(u[0])r=new y(p);else return new y(c===3?-0:0);return oe?Z(r,a,c):r}if(t=ze(r.e/te),l=ze(p.e/te),u=u.slice(),i=l-t,i){for(m=i<0,m?(e=u,i=-i,s=d.length):(e=d,t=l,s=u.length),n=Math.max(Math.ceil(a/te),s)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=u.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(u[n]!=d[n]){m=u[n]<d[n];break}i=0}for(m&&(e=u,u=d,d=e,r.s=-r.s),s=u.length,n=d.length-s;n>0;--n)u[s++]=0;for(n=d.length;n>i;){if(u[--n]<d[n]){for(o=n;o&&u[--o]===0;)u[o]=kt-1;--u[o],u[n]+=kt}u[n]-=d[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=Xo(u,t),oe?Z(r,a,c):r):new y(c===3?-0:0)};_.modulo=_.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?Z(new n(t),n.precision,n.rounding):(oe=!1,n.modulo==9?(e=he(t,r.abs(),0,3,1),e.s*=r.s):e=he(t,r,0,n.modulo,1),e=e.times(r),oe=!0,t.minus(e))};_.naturalExponential=_.exp=function(){return $r(this)};_.naturalLogarithm=_.ln=function(){return jt(this)};_.negated=_.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Z(r)};_.plus=_.add=function(r){var e,t,n,o,i,s,a,c,u,l,m=this,d=m.constructor;if(r=new d(r),!m.d||!r.d)return!m.s||!r.s?r=new d(NaN):m.d||(r=new d(r.d||m.s===r.s?m:NaN)),r;if(m.s!=r.s)return r.s=-r.s,m.minus(r);if(u=m.d,l=r.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(r=new d(m)),oe?Z(r,a,c):r;if(i=ze(m.e/te),n=ze(r.e/te),u=u.slice(),o=i-n,o){for(o<0?(t=u,o=-o,s=l.length):(t=l,n=i,s=u.length),i=Math.ceil(a/te),s=i>s?i+1:s+1,o>s&&(o=s,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,t=l,l=u,u=t),e=0;o;)e=(u[--o]=u[o]+l[o]+e)/kt|0,u[o]%=kt;for(e&&(u.unshift(e),++n),s=u.length;u[--s]==0;)u.pop();return r.d=u,r.e=Xo(u,n),oe?Z(r,a,c):r};_.precision=_.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(Ht+r);return t.d?(e=Ws(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};_.round=function(){var r=this,e=r.constructor;return Z(new e(r),r.e+1,e.rounding)};_.sine=_.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+te,n.rounding=1,t=Tc(n,Xs(n,t)),n.precision=r,n.rounding=e,Z(vt>2?t.neg():t,r,e,!0)):new n(NaN)};_.squareRoot=_.sqrt=function(){var r,e,t,n,o,i,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(oe=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=De(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=ze((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),n=new l(e)):n=new l(u.toString()),t=(c=l.precision)+3;;)if(i=n,n=i.plus(he(s,i,t+2,1)).times(.5),De(i.d).slice(0,t)===(e=De(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!o&&e=="4999"){if(!o&&(Z(i,c+1,0),i.times(i).eq(s))){n=i;break}t+=4,o=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Z(n,c+1,1),r=!n.times(n).eq(s));break}return oe=!0,Z(n,c,l.rounding,r)};_.tangent=_.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=he(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,Z(vt==2||vt==4?t.neg():t,r,e,!0)):new n(NaN)};_.times=_.mul=function(r){var e,t,n,o,i,s,a,c,u,l=this,m=l.constructor,d=l.d,p=(r=new m(r)).d;if(r.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!r.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?r.s/0:r.s*0);for(t=ze(l.e/te)+ze(r.e/te),c=d.length,u=p.length,c<u&&(i=d,d=p,p=i,s=c,c=u,u=s),i=[],s=c+u,n=s;n--;)i.push(0);for(n=u;--n>=0;){for(e=0,o=c+n;o>n;)a=i[o]+p[n]*d[o-n-1]+e,i[o--]=a%kt|0,e=a/kt|0;i[o]=(i[o]+e)%kt|0}for(;!i[--s];)i.pop();return e?++t:i.shift(),r.d=i,r.e=Xo(i,t),oe?Z(r,m.precision,m.rounding):r};_.toBinary=function(r,e){return ei(this,2,r,e)};_.toDecimalPlaces=_.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(nt(r,0,Zt),e===void 0?e=n.rounding:nt(e,0,8),Z(t,r+t.e+1,e))};_.toExponential=function(r,e){var t,n=this,o=n.constructor;return r===void 0?t=Ot(n,!0):(nt(r,0,Zt),e===void 0?e=o.rounding:nt(e,0,8),n=Z(new o(n),r+1,e),t=Ot(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};_.toFixed=function(r,e){var t,n,o=this,i=o.constructor;return r===void 0?t=Ot(o):(nt(r,0,Zt),e===void 0?e=i.rounding:nt(e,0,8),n=Z(new i(o),r+o.e+1,e),t=Ot(n,!1,r+n.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};_.toFraction=function(r){var e,t,n,o,i,s,a,c,u,l,m,d,p=this,y=p.d,f=p.constructor;if(!y)return new f(p);if(u=t=new f(1),n=c=new f(0),e=new f(n),i=e.e=Ws(y)-p.e-1,s=i%te,e.d[0]=Ne(10,s<0?te+s:s),r==null)r=i>0?e:u;else{if(a=new f(r),!a.isInt()||a.lt(u))throw Error(Ht+a);r=a.gt(e)?i>0?e:u:a}for(oe=!1,a=new f(De(y)),l=f.precision,f.precision=i=y.length*te*2;m=he(a,e,0,1,1),o=t.plus(m.times(n)),o.cmp(r)!=1;)t=n,n=o,o=u,u=c.plus(m.times(o)),c=o,o=e,e=a.minus(m.times(o)),a=o;return o=he(r.minus(t),n,0,1,1),c=c.plus(o.times(u)),t=t.plus(o.times(n)),c.s=u.s=p.s,d=he(u,n,i,1).minus(p).abs().cmp(he(c,t,i,1).minus(p).abs())<1?[u,n]:[c,t],f.precision=l,oe=!0,d};_.toHexadecimal=_.toHex=function(r,e){return ei(this,16,r,e)};_.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:nt(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(oe=!1,t=he(t,r,0,e,1).times(r),oe=!0,Z(t)):(r.s=t.s,t=r),t};_.toNumber=function(){return+this};_.toOctal=function(r,e){return ei(this,8,r,e)};_.toPower=_.pow=function(r){var e,t,n,o,i,s,a=this,c=a.constructor,u=+(r=new c(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new c(Ne(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,i=c.rounding,r.eq(1))return Z(a,n,i);if(e=ze(r.e/te),e>=r.d.length-1&&(t=u<0?-u:u)<=wc)return o=qs(c,a,t,n),r.s<0?new c(1).div(o):Z(o,n,i);if(s=a.s,s<0){if(e<r.d.length-1)return new c(NaN);if((r.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=Ne(+a,u),e=t==0||!isFinite(t)?ze(u*(Math.log("0."+De(a.d))/Math.LN10+a.e+1)):new c(t+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(oe=!1,c.rounding=a.s=1,t=Math.min(12,(e+"").length),o=$r(r.times(jt(a,n+t)),n),o.d&&(o=Z(o,n+5,1),qn(o.d,n,i)&&(e=n+10,o=Z($r(r.times(jt(a,e+t)),e),e+5,1),+De(o.d).slice(n+1,n+15)+1==1e14&&(o=Z(o,n+1,0)))),o.s=s,oe=!0,c.rounding=i,Z(o,n,i))};_.toPrecision=function(r,e){var t,n=this,o=n.constructor;return r===void 0?t=Ot(n,n.e<=o.toExpNeg||n.e>=o.toExpPos):(nt(r,1,Zt),e===void 0?e=o.rounding:nt(e,0,8),n=Z(new o(n),r,e),t=Ot(n,r<=n.e||n.e<=o.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};_.toSignificantDigits=_.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(nt(r,1,Zt),e===void 0?e=n.rounding:nt(e,0,8)),Z(new n(t),r,e)};_.toString=function(){var r=this,e=r.constructor,t=Ot(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};_.truncated=_.trunc=function(){return Z(new this.constructor(this),this.e+1,1)};_.valueOf=_.toJSON=function(){var r=this,e=r.constructor,t=Ot(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function De(r){var e,t,n,o=r.length-1,i="",s=r[0];if(o>0){for(i+=s,e=1;e<o;e++)n=r[e]+"",t=te-n.length,t&&(i+=Yt(t)),i+=n;s=r[e],n=s+"",t=te-n.length,t&&(i+=Yt(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function nt(r,e,t){if(r!==~~r||r<e||r>t)throw Error(Ht+r)}function qn(r,e,t,n){var o,i,s,a;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=te,o=0):(o=Math.ceil((e+1)/te),e%=te),i=Ne(10,te-e),a=r[o]%i|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==i||t>3&&a+1==i/2)&&(r[o+1]/i/100|0)==Ne(10,e-2)-1||(a==i/2||a==0)&&(r[o+1]/i/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(n||t<4)&&a==9999||!n&&t>3&&a==4999):s=((n||t<4)&&a+1==i||!n&&t>3&&a+1==i/2)&&(r[o+1]/i/1e3|0)==Ne(10,e-3)-1,s}function Do(r,e,t){for(var n,o=[0],i,s=0,a=r.length;s<a;){for(i=o.length;i--;)o[i]*=e;for(o[0]+=jr.indexOf(r.charAt(s++)),n=0;n<o.length;n++)o[n]>t-1&&(o[n+1]===void 0&&(o[n+1]=0),o[n+1]+=o[n]/t|0,o[n]%=t)}return o.reverse()}function hc(r,e){var t,n,o;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),o=(1/zo(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),r.precision+=t,e=xn(r,1,e.times(o),new r(1));for(var i=t;i--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return r.precision-=t,e}var he=function(){function r(n,o,i){var s,a=0,c=n.length;for(n=n.slice();c--;)s=n[c]*o+a,n[c]=s%i|0,a=s/i|0;return a&&n.unshift(a),n}function e(n,o,i,s){var a,c;if(i!=s)c=i>s?1:-1;else for(a=c=0;a<i;a++)if(n[a]!=o[a]){c=n[a]>o[a]?1:-1;break}return c}function t(n,o,i,s){for(var a=0;i--;)n[i]-=a,a=n[i]<o[i]?1:0,n[i]=a*s+n[i]-o[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,o,i,s,a,c){var u,l,m,d,p,y,f,b,g,w,A,k,I,T,S,x,R,B,L,D,V=n.constructor,H=n.s==o.s?1:-1,G=n.d,q=o.d;if(!G||!G[0]||!q||!q[0])return new V(!n.s||!o.s||(G?q&&G[0]==q[0]:!q)?NaN:G&&G[0]==0||!q?H*0:H/0);for(c?(p=1,l=n.e-o.e):(c=kt,p=te,l=ze(n.e/p)-ze(o.e/p)),L=q.length,R=G.length,g=new V(H),w=g.d=[],m=0;q[m]==(G[m]||0);m++);if(q[m]>(G[m]||0)&&l--,i==null?(T=i=V.precision,s=V.rounding):a?T=i+(n.e-o.e)+1:T=i,T<0)w.push(1),y=!0;else{if(T=T/p+2|0,m=0,L==1){for(d=0,q=q[0],T++;(m<R||d)&&T--;m++)S=d*c+(G[m]||0),w[m]=S/q|0,d=S%q|0;y=d||m<R}else{for(d=c/(q[0]+1)|0,d>1&&(q=r(q,d,c),G=r(G,d,c),L=q.length,R=G.length),x=L,A=G.slice(0,L),k=A.length;k<L;)A[k++]=0;D=q.slice(),D.unshift(0),B=q[0],q[1]>=c/2&&++B;do d=0,u=e(q,A,L,k),u<0?(I=A[0],L!=k&&(I=I*c+(A[1]||0)),d=I/B|0,d>1?(d>=c&&(d=c-1),f=r(q,d,c),b=f.length,k=A.length,u=e(f,A,b,k),u==1&&(d--,t(f,L<b?D:q,b,c))):(d==0&&(u=d=1),f=q.slice()),b=f.length,b<k&&f.unshift(0),t(A,f,k,c),u==-1&&(k=A.length,u=e(q,A,L,k),u<1&&(d++,t(A,L<k?D:q,k,c))),k=A.length):u===0&&(d++,A=[0]),w[m++]=d,u&&A[0]?A[k++]=G[x]||0:(A=[G[x]],k=1);while((x++<R||A[0]!==void 0)&&T--);y=A[0]!==void 0}w[0]||w.shift()}if(p==1)g.e=l,vs=y;else{for(m=1,d=w[0];d>=10;d/=10)m++;g.e=m+l*p-1,Z(g,a?i+g.e+1:i,s,y)}return g}}();function Z(r,e,t,n){var o,i,s,a,c,u,l,m,d,p=r.constructor;e:if(e!=null){if(m=r.d,!m)return r;for(o=1,a=m[0];a>=10;a/=10)o++;if(i=e-o,i<0)i+=te,s=e,l=m[d=0],c=l/Ne(10,o-s-1)%10|0;else if(d=Math.ceil((i+1)/te),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=c=0,o=1,i%=te,s=i-te+1}else break e;else{for(l=a=m[d],o=1;a>=10;a/=10)o++;i%=te,s=i-te+o,c=s<0?0:l/Ne(10,o-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%Ne(10,o-s-1)),u=t<4?(c||n)&&(t==0||t==(r.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(i>0?s>0?l/Ne(10,o-s):0:m[d-1])%10&1||t==(r.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=r.e+1,m[0]=Ne(10,(te-e%te)%te),r.e=-e||0):m[0]=r.e=0,r;if(i==0?(m.length=d,a=1,d--):(m.length=d+1,a=Ne(10,te-i),m[d]=s>0?(l/Ne(10,o-s)%Ne(10,s)|0)*a:0),u)for(;;)if(d==0){for(i=1,s=m[0];s>=10;s/=10)i++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;i!=a&&(r.e++,m[0]==kt&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=kt)break;m[d--]=0,a=1}for(i=m.length;m[--i]===0;)m.pop()}return oe&&(r.e>p.maxE?(r.d=null,r.e=NaN):r.e<p.minE&&(r.e=0,r.d=[0])),r}function Ot(r,e,t){if(!r.isFinite())return Gs(r);var n,o=r.e,i=De(r.d),s=i.length;return e?(t&&(n=t-s)>0?i=i.charAt(0)+"."+i.slice(1)+Yt(n):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):o<0?(i="0."+Yt(-o-1)+i,t&&(n=t-s)>0&&(i+=Yt(n))):o>=s?(i+=Yt(o+1-s),t&&(n=t-o-1)>0&&(i=i+"."+Yt(n))):((n=o+1)<s&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-s)>0&&(o+1===s&&(i+="."),i+=Yt(n))),i}function Xo(r,e){var t=r[0];for(e*=te;t>=10;t/=10)e++;return e}function Uo(r,e,t){if(e>Pc)throw oe=!0,t&&(r.precision=t),Error(Vs);return Z(new r(Wo),e,1,!0)}function ht(r,e,t){if(e>Zr)throw Error(Vs);return Z(new r(qo),e,t,!0)}function Ws(r){var e=r.length-1,t=e*te+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function Yt(r){for(var e="";r--;)e+="0";return e}function qs(r,e,t,n){var o,i=new r(1),s=Math.ceil(n/te+4);for(oe=!1;;){if(t%2&&(i=i.times(e),Ms(i.d,s)&&(o=!0)),t=ze(t/2),t===0){t=i.d.length-1,o&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Ms(e.d,s)}return oe=!0,i}function Ns(r){return r.d[r.d.length-1]&1}function Us(r,e,t){for(var n,o=new r(e[0]),i=0;++i<e.length;)if(n=new r(e[i]),n.s)o[t](n)&&(o=n);else{o=n;break}return o}function $r(r,e){var t,n,o,i,s,a,c,u=0,l=0,m=0,d=r.constructor,p=d.rounding,y=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(e==null?(oe=!1,c=y):c=e,a=new d(.03125);r.e>-2;)r=r.times(a),m+=5;for(n=Math.log(Ne(2,m))/Math.LN10*2+5|0,c+=n,t=i=s=new d(1),d.precision=c;;){if(i=Z(i.times(r),c,1),t=t.times(++l),a=s.plus(he(i,t,c,1)),De(a.d).slice(0,c)===De(s.d).slice(0,c)){for(o=m;o--;)s=Z(s.times(s),c,1);if(e==null)if(u<3&&qn(s.d,c-n,p,u))d.precision=c+=10,t=i=a=new d(1),l=0,u++;else return Z(s,d.precision=y,p,oe=!0);else return d.precision=y,s}s=a}}function jt(r,e){var t,n,o,i,s,a,c,u,l,m,d,p=1,y=10,f=r,b=f.d,g=f.constructor,w=g.rounding,A=g.precision;if(f.s<0||!b||!b[0]||!f.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:f.s!=1?NaN:b?0:f);if(e==null?(oe=!1,l=A):l=e,g.precision=l+=y,t=De(b),n=t.charAt(0),Math.abs(i=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(r),t=De(f.d),n=t.charAt(0),p++;i=f.e,n>1?(f=new g("0."+t),i++):f=new g(n+"."+t.slice(1))}else return u=Uo(g,l+2,A).times(i+""),f=jt(new g(n+"."+t.slice(1)),l-y).plus(u),g.precision=A,e==null?Z(f,A,w,oe=!0):f;for(m=f,c=s=f=he(f.minus(1),f.plus(1),l,1),d=Z(f.times(f),l,1),o=3;;){if(s=Z(s.times(d),l,1),u=c.plus(he(s,new g(o),l,1)),De(u.d).slice(0,l)===De(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(Uo(g,l+2,A).times(i+""))),c=he(c,new g(p),l,1),e==null)if(qn(c.d,l-y,w,a))g.precision=l+=y,u=s=f=he(m.minus(1),m.plus(1),l,1),d=Z(f.times(f),l,1),o=a=1;else return Z(c,g.precision=A,w,oe=!0);else return g.precision=A,c;c=u,o+=2}}function Gs(r){return String(r.s*r.s/0)}function Jr(r,e){var t,n,o;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(o=e.length;e.charCodeAt(o-1)===48;--o);if(e=e.slice(n,o),e){if(o-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%te,t<0&&(n+=te),n<o){for(n&&r.d.push(+e.slice(0,n)),o-=te;n<o;)r.d.push(+e.slice(n,n+=te));e=e.slice(n),n=te-e.length}else n-=o;for(;n--;)e+="0";r.d.push(+e),oe&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function kc(r,e){var t,n,o,i,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Ds.test(e))return Jr(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(gc.test(e))t=16,e=e.toLowerCase();else if(bc.test(e))t=2;else if(Ac.test(e))t=8;else throw Error(Ht+e);for(i=e.search(/p/i),i>0?(c=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),s=i>=0,n=r.constructor,s&&(e=e.replace(".",""),a=e.length,i=a-i,o=qs(n,new n(t),i,i*2)),u=Do(e,t,kt),l=u.length-1,i=l;u[i]===0;--i)u.pop();return i<0?new n(r.s*0):(r.e=Xo(u,l),r.d=u,oe=!1,s&&(r=he(r,o,a*4)),c&&(r=r.times(Math.abs(c)<54?Ne(2,c):Un.pow(2,c))),oe=!0,r)}function Tc(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:xn(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/zo(5,t)),e=xn(r,2,e,e);for(var o,i=new r(5),s=new r(16),a=new r(20);t--;)o=e.times(e),e=e.times(i.plus(o.times(s.times(o).minus(a))));return e}function xn(r,e,t,n,o){var i,s,a,c,u=1,l=r.precision,m=Math.ceil(l/te);for(oe=!1,c=t.times(t),a=new r(n);;){if(s=he(a.times(c),new r(e++*e++),l,1),a=o?n.plus(s):n.minus(s),n=he(s.times(c),new r(e++*e++),l,1),s=a.plus(n),s.d[m]!==void 0){for(i=m;s.d[i]===a.d[i]&&i--;);if(i==-1)break}i=a,a=n,n=s,s=i,u++}return oe=!0,s.d.length=m+1,s}function zo(r,e){for(var t=r;--e;)t*=r;return t}function Xs(r,e){var t,n=e.s<0,o=ht(r,r.precision,1),i=o.times(.5);if(e=e.abs(),e.lte(i))return vt=n?4:1,e;if(t=e.divToInt(o),t.isZero())vt=n?3:2;else{if(e=e.minus(t.times(o)),e.lte(i))return vt=Ns(t)?n?2:3:n?4:1,e;vt=Ns(t)?n?1:4:n?3:2}return e.minus(o).abs()}function ei(r,e,t,n){var o,i,s,a,c,u,l,m,d,p=r.constructor,y=t!==void 0;if(y?(nt(t,1,Zt),n===void 0?n=p.rounding:nt(n,0,8)):(t=p.precision,n=p.rounding),!r.isFinite())l=Gs(r);else{for(l=Ot(r),s=l.indexOf("."),y?(o=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):o=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Do(Ot(d),10,o),d.e=d.d.length),m=Do(l,10,o),i=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=y?"0p+0":"0";else{if(s<0?i--:(r=new p(r),r.d=m,r.e=i,r=he(r,d,t,n,0,o),m=r.d,i=r.e,u=vs),s=m[t],a=o/2,u=u||m[t+1]!==void 0,u=n<4?(s!==void 0||u)&&(n===0||n===(r.s<0?3:2)):s>a||s===a&&(n===4||u||n===6&&m[t-1]&1||n===(r.s<0?8:7)),m.length=t,u)for(;++m[--t]>o-1;)m[t]=0,t||(++i,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=jr.charAt(m[s]);if(y){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=Do(l,o,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=jr.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)l="0"+l;l="0."+l}else if(++i>c)for(i-=c;i--;)l+="0";else i<c&&(l=l.slice(0,i)+"."+l.slice(i))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return r.s<0?"-"+l:l}function Ms(r,e){if(r.length>e)return r.length=e,!0}function Ic(r){return new this(r).abs()}function Bc(r){return new this(r).acos()}function xc(r){return new this(r).acosh()}function Sc(r,e){return new this(r).plus(e)}function Kc(r){return new this(r).asin()}function Cc(r){return new this(r).asinh()}function Rc(r){return new this(r).atan()}function Oc(r){return new this(r).atanh()}function Lc(r,e){r=new this(r),e=new this(e);var t,n=this.precision,o=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=ht(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?ht(this,n,o):new this(0),t.s=r.s):!r.d||e.isZero()?(t=ht(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(he(r,e,i,1)),e=ht(this,i,1),this.precision=n,this.rounding=o,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(he(r,e,i,1)),t}function Nc(r){return new this(r).cbrt()}function Mc(r){return Z(r=new this(r),r.e+1,2)}function _c(r,e,t){return new this(r).clamp(e,t)}function vc(r){if(!r||typeof r!="object")throw Error(Go+"Object expected");var e,t,n,o=r.defaults===!0,i=["precision",1,Zt,"rounding",0,8,"toExpNeg",-Bn,0,"toExpPos",0,Bn,"maxE",0,Bn,"minE",-Bn,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],o&&(this[t]=Hr[t]),(n=r[t])!==void 0)if(ze(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(Ht+t+": "+n);if(t="crypto",o&&(this[t]=Hr[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Fs);else this[t]=!1;else throw Error(Ht+t+": "+n);return this}function Vc(r){return new this(r).cos()}function Fc(r){return new this(r).cosh()}function zs(r){var e,t,n;function o(i){var s,a,c,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,_s(i)){u.s=i.s,oe?!i.d||i.e>o.maxE?(u.e=NaN,u.d=null):i.e<o.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(s=0,a=i;a>=10;a/=10)s++;oe?s>o.maxE?(u.e=NaN,u.d=null):s<o.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[i]):(u.e=s,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return Jr(u,i.toString())}else if(c!=="string")throw Error(Ht+i);return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),Ds.test(i)?Jr(u,i):kc(u,i)}if(o.prototype=_,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=vc,o.clone=zs,o.isDecimal=_s,o.abs=Ic,o.acos=Bc,o.acosh=xc,o.add=Sc,o.asin=Kc,o.asinh=Cc,o.atan=Rc,o.atanh=Oc,o.atan2=Lc,o.cbrt=Nc,o.ceil=Mc,o.clamp=_c,o.cos=Vc,o.cosh=Fc,o.div=Ec,o.exp=Dc,o.floor=Wc,o.hypot=qc,o.ln=Uc,o.log=Gc,o.log10=zc,o.log2=Xc,o.max=Qc,o.min=Yc,o.mod=jc,o.mul=Hc,o.pow=Zc,o.random=$c,o.round=Jc,o.sign=el,o.sin=tl,o.sinh=nl,o.sqrt=ol,o.sub=rl,o.sum=il,o.tan=sl,o.tanh=al,o.trunc=ul,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return o.config(r),o}function Ec(r,e){return new this(r).div(e)}function Dc(r){return new this(r).exp()}function Wc(r){return Z(r=new this(r),r.e+1,3)}function qc(){var r,e,t=new this(0);for(oe=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return oe=!0,new this(1/0);t=e}return oe=!0,t.sqrt()}function _s(r){return r instanceof Un||r&&r.toStringTag===Es||!1}function Uc(r){return new this(r).ln()}function Gc(r,e){return new this(r).log(e)}function Xc(r){return new this(r).log(2)}function zc(r){return new this(r).log(10)}function Qc(){return Us(this,arguments,"lt")}function Yc(){return Us(this,arguments,"gt")}function jc(r,e){return new this(r).mod(e)}function Hc(r,e){return new this(r).mul(e)}function Zc(r,e){return new this(r).pow(e)}function $c(r){var e,t,n,o,i=0,s=new this(1),a=[];if(r===void 0?r=this.precision:nt(r,1,Zt),n=Math.ceil(r/te),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)o=e[i],o>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=o%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)o=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(e,i):(a.push(o%1e7),i+=4);i=n/4}else throw Error(Fs);else for(;i<n;)a[i++]=Math.random()*1e7|0;for(n=a[--i],r%=te,n&&r&&(o=Ne(10,te-r),a[i]=(n/o|0)*o);a[i]===0;i--)a.pop();if(i<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=te)a.shift();for(n=1,o=a[0];o>=10;o/=10)n++;n<te&&(t-=te-n)}return s.e=t,s.d=a,s}function Jc(r){return Z(r=new this(r),r.e+1,this.rounding)}function el(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function tl(r){return new this(r).sin()}function nl(r){return new this(r).sinh()}function ol(r){return new this(r).sqrt()}function rl(r,e){return new this(r).sub(e)}function il(){var r=0,e=arguments,t=new this(e[r]);for(oe=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return oe=!0,Z(t,this.precision,this.rounding)}function sl(r){return new this(r).tan()}function al(r){return new this(r).tanh()}function ul(r){return Z(r=new this(r),r.e+1,1)}_[Symbol.for("nodejs.util.inspect.custom")]=_.toString;_[Symbol.toStringTag]="Decimal";var Un=_.constructor=zs(Hr);Wo=new Un(Wo);qo=new Un(qo);var O=Un;import{PublicKey as ii}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as cl}from"@solana/spl-token";import{PublicKey as Ie,SystemProgram as Qs,SYSVAR_RENT_PUBKEY as ll}from"@solana/web3.js";function P({pubkey:r,isSigner:e=!1,isWritable:t=!0}){return{pubkey:r,isWritable:t,isSigner:e}}var ti=[P({pubkey:cl,isWritable:!1}),P({pubkey:Qs.programId,isWritable:!1}),P({pubkey:ll,isWritable:!1})];function ni({publicKey:r,transformSol:e}){let t=oi(r.toString());if(t instanceof Ie)return e&&t.equals(Me)?Y:t;if(e&&t.toString()===Me.toBase58())return Y;if(typeof t=="string"){if(t===Ie.default.toBase58())return Ie.default;try{return new Ie(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function oi(r){try{return new Ie(r)}catch{return r}}var Qo=new Ie("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Yo=new Ie("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),ot=new Ie("SysvarRent111111111111111111111111111111111"),ri=new Ie("SysvarC1ock11111111111111111111111111111111"),Sn=new Ie("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),jo=new Ie("Sysvar1nstructions1111111111111111111111111"),Ho=Qs.programId,bp=new Ie("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),gp=new Ie("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Ap=new Ie("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),wp=new Ie("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Pp=new Ie("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),hp=new Ie("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),kp=new Ie("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Tp=new Ie("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Ip=new Ie("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Bp=new Ie("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),xp=new Ie("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),Y=new Ie("So11111111111111111111111111111111111111112"),Me=Ie.default;function lt(r){return ni({publicKey:r,transformSol:!0})}import{PublicKey as ml}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Ys}from"@solana/spl-token";var Lt={chainId:101,address:ml.default.toBase58(),programId:Ys.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},_e={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Ys.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 si=class{constructor({mint:e,decimals:t,symbol:n,name:o,skipMint:i=!1,isToken2022:s=!1}){if(e===Me.toBase58()||e instanceof ii&&Me.equals(e)){this.decimals=_e.decimals,this.symbol=_e.symbol,this.name=_e.name,this.mint=new ii(_e.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=n||e.toString().substring(0,6),this.name=o||e.toString().substring(0,6),this.mint=i?ii.default:ni({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Be=si;Be.WSOL=new si(E(C({},_e),{mint:_e.address}));import $o from"big.js";import fl from"bn.js";import yl from"decimal.js-light";import dl from"toformat";var pl=dl,Gn=pl;var Zo=ue("module/fraction"),ai=Gn($o),Xn=Gn(yl),bl={[0]:Xn.ROUND_DOWN,[1]:Xn.ROUND_HALF_UP,[2]:Xn.ROUND_UP},gl={[0]:$o.roundDown,[1]:$o.roundHalfUp,[2]:$o.roundUp},pe=class{constructor(e,t=new fl(1)){this.numerator=$(e),this.denominator=$(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new pe(this.denominator,this.numerator)}add(e){let t=e instanceof pe?e:new pe($(e));return this.denominator.eq(t.denominator)?new pe(this.numerator.add(t.numerator),this.denominator):new pe(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof pe?e:new pe($(e));return this.denominator.eq(t.denominator)?new pe(this.numerator.sub(t.numerator),this.denominator):new pe(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof pe?e:new pe($(e));return new pe(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof pe?e:new pe($(e));return new pe(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||Zo.logWithError(`${e} is not an integer.`),e<=0&&Zo.logWithError(`${e} is not positive.`),Xn.set({precision:e+1,rounding:bl[n]});let o=new Xn(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return o.toFormat(o.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||Zo.logWithError(`${e} is not an integer.`),e<0&&Zo.logWithError(`${e} is negative.`),ai.DP=e,ai.RM=gl[n]||1,new ai(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var wl=ue("Raydium_price"),rt=class extends pe{constructor(t){let{baseToken:n,quoteToken:o,numerator:i,denominator:s}=t;super(i,s);this.baseToken=n,this.quoteToken=o,this.scalar=new pe(ui(n.decimals),ui(o.decimals))}get raw(){return new pe(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new rt({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&wl.logWithError("mul token not equals");let n=super.mul(t);return new rt({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(t=this.quoteToken.decimals,n,o){return this.adjusted.toSignificant(t,n,o)}toFixed(t=this.quoteToken.decimals,n,o){return this.adjusted.toFixed(t,n,o)}};var ci=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},Jo=ci;Jo.SOL=new ci(Lt);import Pl from"bn.js";var js=new pe(new Pl(100)),Qe=class extends pe{toSignificant(e=5,t,n){return this.mul(js).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(js).toFixed(e,t,n)}};var ft=new it(0),Zs=new it(1),Tf=new it(2),If=new it(3),Bf=new it(5),li=new it(10),xf=new it(100),Sf=new it(1e3),Kf=new it(1e4),Hs=9007199254740991;function $(r){let e=ue("Raydium_parseBigNumberish");if(r instanceof it)return r;if(typeof r=="string"){if(r.match(/^-?[0-9]+$/))return new it(r);e.logWithError(`invalid BigNumberish string: ${r}`)}return typeof r=="number"?(r%1&&e.logWithError(`BigNumberish number underflow: ${r}`),(r>=Hs||r<=-Hs)&&e.logWithError(`BigNumberish number overflow: ${r}`),new it(String(r))):typeof r=="bigint"?new it(r.toString()):(e.error(`invalid BigNumberish value: ${r}`),new it(0))}function ui(r){return li.pow($(r))}function er(r,e){let t=r.divmod(e);return t.mod.isZero()?t.div:t.div.isNeg()?t.div.isubn(1):t.div.iaddn(1)}var kl=ue("Raydium_amount"),Js=Gn(hl);function Tl(r,e){let t="0",n="0";if(r.includes(".")){let o=r.split(".");o.length===2?([t,n]=o,n=n.padEnd(e,"0")):kl.logWithError(`invalid number string, num: ${r}`)}else t=r;return[t,n.slice(0,e)||n]}var ge=class extends pe{constructor(t,n,o=!0,i){let s=new tr(0),a=li.pow(new tr(t.decimals));if(o)s=$(n);else{let c=new tr(0),u=new tr(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=Tl(n.toString(),t.decimals);c=$(l),u=$(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=ue(i||"TokenAmount"),this.token=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.token.equals(t.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(t.raw)}lt(t){return this.token.equals(t.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(t.raw)}add(t){return this.token.equals(t.token)||this.logger.logWithError("add token not equals"),new ge(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new ge(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,n,o=0){return super.toSignificant(t,n,o)}toFixed(t=this.token.decimals,n,o=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,o)}toExact(t={groupSeparator:""}){return Js.DP=this.token.decimals,new Js(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};function $s(r){return typeof r=="object"&&r!==null&&![Be,ge,Il,pe,Bl,rt,Qe].some(e=>typeof e=="object"&&r instanceof e)}function ke(r){return typeof r=="string"?oi(r):Array.isArray(r)?r.map(e=>ke(e)):$s(r)?Object.fromEntries(Object.entries(r).map(([e,t])=>[e,ke(t)])):r}import{PublicKey as Yn,sendAndConfirmTransaction as fi,Transaction as jn,TransactionMessage as Hn,VersionedTransaction as Zn}from"@solana/web3.js";import _l from"axios";var F={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut"};import{PublicKey as ta,ComputeBudgetProgram as ea,Transaction as nr,TransactionMessage as xl,Keypair as na,VersionedTransaction as oa}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Sl}from"@solana/spl-token";var Vt=ue("Raydium_txUtil"),ra=1644;function or(r){let e=[],t=[];return r.microLamports&&(e.push(ea.setComputeUnitPrice({microLamports:r.microLamports})),t.push(F.SetComputeUnitPrice)),r.units&&(e.push(ea.setComputeUnitLimit({units:r.units})),t.push(F.SetComputeUnitLimit)),{instructions:e,instructionTypes:t}}async function Kn(r,e){var n,o;let t=e!=null?e:"confirmed";try{return((o=await((n=r.getLatestBlockhash)==null?void 0:n.call(r,{commitment:t})))==null?void 0:o.blockhash)||(await r.getRecentBlockhash(t)).blockhash}catch{return(await r.getRecentBlockhash(t)).blockhash}}function rr(r,e){r.length<1&&Vt.logWithError(`no instructions provided: ${r.toString()}`),e.length<1&&Vt.logWithError(`no signers provided:, ${e.toString()}`);let t=new nr;t.recentBlockhash="11111111111111111111111111111111",t.feePayer=e[0],t.add(...r);try{return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64").length<ra}catch{return!1}}async function ia(r,e,t,n=!0){let o=new ta("RaydiumSimuLateTransaction11111111111111111"),i=[],s=new nr;s.feePayer=o;for(let u of e)rr([...s.instructions,u],[o])||(i.push(s),s=new nr,s.feePayer=o),s.add(u);s.instructions.length>0&&i.push(s);let a=[];try{if(a=await Kl(r,i,n),a.find(u=>u.err!==null))throw Error("rpc simulateTransaction error")}catch(u){u instanceof Error&&Vt.logWithError("failed to simulate for instructions","RPC_ERROR",{message:u.message})}let c=[];for(let u of a)if(Vt.debug("simulate result:",u),u.logs){let l=u.logs.filter(m=>m&&m.includes(t));Vt.debug("filteredLog:",c),l.length||Vt.logWithError("simulate log not match keyword","keyword",t),c.push(...l)}return c}function sa(r,e){let t=r.match(/{["\w:,]+}/g);return!t||t.length!==1?Vt.logWithError(`simulate log fail to match json, keyword: ${e}`):t[0]}function Ft(r,e){let n=new RegExp(`"${e}":(\\d+)`,"g").exec(r);return!n||n.length!==2?Vt.logWithError(`simulate log fail to match key", key: ${e}`):n[1]}function ae(r,e){let[t,n]=ta.findProgramAddressSync(r,e);return{publicKey:t,nonce:n}}async function Kl(r,e,t){let n=[];if(t){let o=await r.getLatestBlockhash(),i=[];for(let u of e){u.recentBlockhash=o.blockhash,u.lastValidBlockHeight=o.lastValidBlockHeight;let m=u._compile().serialize(),p=u._serialize(m).toString("base64");i.push(p)}let s=i.map(u=>{let l=r._buildArgs([u],void 0,"base64");return{methodName:"simulateTransaction",args:l}}),a=[],c=20;for(let u=0;u<Math.ceil(s.length/c);u++)a.push(s.slice(u*c,(u+1)*c));n=await(await Promise.all(a.map(async u=>(await r._rpcBatchRequest(u)).map(l=>l.result.value)))).flat()}else try{n=await Promise.all(e.map(async o=>await(await r.simulateTransaction(o)).value))}catch(o){o instanceof Error&&Vt.logWithError("failed to get info for multiple accounts","RPC_ERROR",{message:o.message})}return n}function zn({instructions:r,payer:e,signers:t}){return rr(r,[e,...t])}function Qn({instructions:r,payer:e,lookupTableAddressAccount:t,recentBlockhash:n=na.generate().publicKey.toString()}){let i=new xl({payerKey:e,recentBlockhash:n,instructions:r}).compileToV0Message(Object.values(t!=null?t:{}));try{return Buffer.from(new oa(i).serialize()).toString("base64").length<ra}catch{return!1}}var Cl=r=>Buffer.isBuffer(r)?r:r instanceof Uint8Array?Buffer.from(r.buffer,r.byteOffset,r.byteLength):Buffer.from(r),Rl=r=>{let e=r.serialize({requireAllSignatures:!1,verifySignatures:!1});r instanceof oa&&(e=Cl(e));try{return e instanceof Buffer?e.toString("base64"):Buffer.from(e).toString("base64")}catch{return e.toString("base64")}};function un(r){let e=[];return r.forEach(t=>{t instanceof nr&&(t.recentBlockhash||(t.recentBlockhash=Sl.toBase58()),t.feePayer||(t.feePayer=na.generate().publicKey)),e.push(Rl(t))}),console.log("simulate tx string:",e),e}import{PublicKey as ua,AddressLookupTableAccount as ir}from"@solana/web3.js";import{PublicKey as aa}from"@solana/web3.js";import{MINT_SIZE as Ol,TOKEN_PROGRAM_ID as Ll,getTransferFeeConfig as Nl,unpackMint as Ml}from"@solana/spl-token";var mi=ue("Raydium_accountInfo_util");async function Tt(r,e,t){let{batchRequest:n,commitment:o="confirmed",chunkCount:i=100}=C({batchRequest:!1},t),s=di(e,i),a=new Array(s.length).fill([]);if(n){let c=s.map(m=>{let d=r._buildArgs([m.map(p=>p.toBase58())],o,"base64");return{methodName:"getMultipleAccounts",args:d}}),u=di(c,10);a=(await(await Promise.all(u.map(async m=>await r._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&mi.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:y,lamports:f,owner:b,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&mi.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:y,lamports:f,owner:new aa(b),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(c=>r.getMultipleAccountsInfo(c,o)))}catch(c){c instanceof Error&&mi.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function ve(r,e,t){let n=await Tt(r,e.map(o=>o.pubkey),t);return e.map((o,i)=>E(C({},o),{accountInfo:n[i]}))}async function Cn({connection:r,mints:e,config:t}){var i,s,a;if(e.length===0)return{};let n=await ve(r,e.map(c=>({pubkey:l