UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 68.3 kB
var $n=Object.defineProperty,et=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var De=Object.getOwnPropertySymbols;var wn=Object.prototype.hasOwnProperty,Tn=Object.prototype.propertyIsEnumerable;var hn=(e,n,t)=>n in e?$n(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Z=(e,n)=>{for(var t in n||(n={}))wn.call(n,t)&&hn(e,t,n[t]);if(De)for(var t of De(n))Tn.call(n,t)&&hn(e,t,n[t]);return e},te=(e,n)=>et(e,nt(n));var Ee=(e,n)=>{var t={};for(var r in e)wn.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&De)for(var r of De(e))n.indexOf(r)<0&&Tn.call(e,r)&&(t[r]=e[r]);return t};import{PublicKey as be,sendAndConfirmTransaction as pn,SystemProgram as Tr,Transaction as Be,TransactionMessage as Re,VersionedTransaction as Ie}from"@solana/web3.js";import br from"axios";import{PublicKey as ln,AddressLookupTableAccount as Te}from"@solana/web3.js";import{PublicKey as wr}from"@solana/web3.js";import ne from"bn.js";var me=9e15,se=1e9,ze="0123456789abcdef",ve="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Fe="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ye={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-me,maxE:me,crypto:!1},Pn,$,B=!0,Oe="[DecimalError] ",oe=Oe+"Invalid argument: ",An=Oe+"Precision limit exceeded",Nn=Oe+"crypto unavailable",Sn="[object Decimal]",H=Math.floor,U=Math.pow,tt=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,rt=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,it=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,kn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,J=1e7,k=7,ot=9007199254740991,st=ve.length-1,Je=Fe.length-1,d={toStringTag:Sn};d.absoluteValue=d.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),P(e)};d.ceil=function(){return P(new this.constructor(this),this.e+1,2)};d.clampedTo=d.clamp=function(e,n){var t,r=this,o=r.constructor;if(e=new o(e),n=new o(n),!e.s||!n.s)return new o(NaN);if(e.gt(n))throw Error(oe+n);return t=r.cmp(e),t<0?e:r.cmp(n)>0?n:new o(r)};d.comparedTo=d.cmp=function(e){var n,t,r,o,i=this,s=i.d,a=(e=new i.constructor(e)).d,c=i.s,u=e.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(i.e!==e.e)return i.e>e.e^c<0?1:-1;for(r=s.length,o=a.length,n=0,t=r<o?r:o;n<t;++n)if(s[n]!==a[n])return s[n]>a[n]^c<0?1:-1;return r===o?0:r>o^c<0?1:-1};d.cosine=d.cos=function(){var e,n,t=this,r=t.constructor;return t.d?t.d[0]?(e=r.precision,n=r.rounding,r.precision=e+Math.max(t.e,t.sd())+k,r.rounding=1,t=at(r,Mn(r,t)),r.precision=e,r.rounding=n,P($==2||$==3?t.neg():t,e,n,!0)):new r(1):new r(NaN)};d.cubeRoot=d.cbrt=function(){var e,n,t,r,o,i,s,a,c,u,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(B=!1,i=l.s*U(l.s*l,1/3),!i||Math.abs(i)==1/0?(t=G(l.d),e=l.e,(i=(e-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=U(t,1/3),e=H((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new f(t),r.s=l.s):r=new f(i.toString()),s=(e=f.precision)+3;;)if(a=r,c=a.times(a).times(a),u=c.plus(l),r=V(u.plus(l).times(a),u.plus(c),s+2,1),G(a.d).slice(0,s)===(t=G(r.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!o&&t=="4999"){if(!o&&(P(a,e+1,0),a.times(a).times(a).eq(l))){r=a;break}s+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(P(r,e+1,1),n=!r.times(r).times(r).eq(l));break}return B=!0,P(r,e,f.rounding,n)};d.decimalPlaces=d.dp=function(){var e,n=this.d,t=NaN;if(n){if(e=n.length-1,t=(e-H(this.e/k))*k,e=n[e],e)for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t};d.dividedBy=d.div=function(e){return V(this,new this.constructor(e))};d.dividedToIntegerBy=d.divToInt=function(e){var n=this,t=n.constructor;return P(V(n,new t(e),0,1,1),t.precision,t.rounding)};d.equals=d.eq=function(e){return this.cmp(e)===0};d.floor=function(){return P(new this.constructor(this),this.e+1,3)};d.greaterThan=d.gt=function(e){return this.cmp(e)>0};d.greaterThanOrEqualTo=d.gte=function(e){var n=this.cmp(e);return n==1||n===0};d.hyperbolicCosine=d.cosh=function(){var e,n,t,r,o,i=this,s=i.constructor,a=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return a;t=s.precision,r=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,o=i.d.length,o<32?(e=Math.ceil(o/3),n=(1/We(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),i=de(s,1,i.times(n),new s(1),!0);for(var c,u=e,l=new s(8);u--;)c=i.times(i),i=a.minus(c.times(l.minus(c.times(l))));return P(i,s.precision=t,s.rounding=r,!0)};d.hyperbolicSine=d.sinh=function(){var e,n,t,r,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(n=i.precision,t=i.rounding,i.precision=n+Math.max(o.e,o.sd())+4,i.rounding=1,r=o.d.length,r<3)o=de(i,2,o,o,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,o=o.times(1/We(5,e)),o=de(i,2,o,o,!0);for(var s,a=new i(5),c=new i(16),u=new i(20);e--;)s=o.times(o),o=o.times(a.plus(s.times(c.times(s).plus(u))))}return i.precision=n,i.rounding=t,P(o,n,t,!0)};d.hyperbolicTangent=d.tanh=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,n=r.rounding,r.precision=e+7,r.rounding=1,V(t.sinh(),t.cosh(),r.precision=e,r.rounding=n)):new r(t.s)};d.inverseCosine=d.acos=function(){var e,n=this,t=n.constructor,r=n.abs().cmp(1),o=t.precision,i=t.rounding;return r!==-1?r===0?n.isNeg()?Y(t,o,i):new t(0):new t(NaN):n.isZero()?Y(t,o+4,i).times(.5):(t.precision=o+6,t.rounding=1,n=n.asin(),e=Y(t,o+4,i).times(.5),t.precision=o,t.rounding=i,e.minus(n))};d.inverseHyperbolicCosine=d.acosh=function(){var e,n,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(e=r.precision,n=r.rounding,r.precision=e+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,B=!1,t=t.times(t).minus(1).sqrt().plus(t),B=!0,r.precision=e,r.rounding=n,t.ln()):new r(t)};d.inverseHyperbolicSine=d.asinh=function(){var e,n,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(e=r.precision,n=r.rounding,r.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,B=!1,t=t.times(t).plus(1).sqrt().plus(t),B=!0,r.precision=e,r.rounding=n,t.ln())};d.inverseHyperbolicTangent=d.atanh=function(){var e,n,t,r,o=this,i=o.constructor;return o.isFinite()?o.e>=0?new i(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(e=i.precision,n=i.rounding,r=o.sd(),Math.max(r,e)<2*-o.e-1?P(new i(o),e,n,!0):(i.precision=t=r-o.e,o=V(o.plus(1),new i(1).minus(o),t+e,1),i.precision=e+4,i.rounding=1,o=o.ln(),i.precision=e,i.rounding=n,o.times(.5))):new i(NaN)};d.inverseSine=d.asin=function(){var e,n,t,r,o=this,i=o.constructor;return o.isZero()?new i(o):(n=o.abs().cmp(1),t=i.precision,r=i.rounding,n!==-1?n===0?(e=Y(i,t+4,r).times(.5),e.s=o.s,e):new i(NaN):(i.precision=t+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=r,o.times(2)))};d.inverseTangent=d.atan=function(){var e,n,t,r,o,i,s,a,c,u=this,l=u.constructor,f=l.precision,m=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&f+4<=Je)return s=Y(l,f+4,m).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(f+4<=Je)return s=Y(l,f+4,m).times(.5),s.s=u.s,s}for(l.precision=a=f+10,l.rounding=1,t=Math.min(28,a/k+2|0),e=t;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(B=!1,n=Math.ceil(a/k),r=1,c=u.times(u),s=new l(u),o=u;e!==-1;)if(o=o.times(c),i=s.minus(o.div(r+=2)),o=o.times(c),s=i.plus(o.div(r+=2)),s.d[n]!==void 0)for(e=n;s.d[e]===i.d[e]&&e--;);return t&&(s=s.times(2<<t-1)),B=!0,P(s,l.precision=f,l.rounding=m,!0)};d.isFinite=function(){return!!this.d};d.isInteger=d.isInt=function(){return!!this.d&&H(this.e/k)>this.d.length-2};d.isNaN=function(){return!this.s};d.isNegative=d.isNeg=function(){return this.s<0};d.isPositive=d.isPos=function(){return this.s>0};d.isZero=function(){return!!this.d&&this.d[0]===0};d.lessThan=d.lt=function(e){return this.cmp(e)<0};d.lessThanOrEqualTo=d.lte=function(e){return this.cmp(e)<1};d.logarithm=d.log=function(e){var n,t,r,o,i,s,a,c,u=this,l=u.constructor,f=l.precision,m=l.rounding,p=5;if(e==null)e=new l(10),n=!0;else{if(e=new l(e),t=e.d,e.s<0||!t||!t[0]||e.eq(1))return new l(NaN);n=e.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new l(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(n)if(t.length>1)i=!0;else{for(o=t[0];o%10===0;)o/=10;i=o!==1}if(B=!1,a=f+p,s=ie(u,a),r=n?_e(l,a+10):ie(e,a),c=V(s,r,a,1),ye(c.d,o=f,m))do if(a+=10,s=ie(u,a),r=n?_e(l,a+10):ie(e,a),c=V(s,r,a,1),!i){+G(c.d).slice(o+1,o+15)+1==1e14&&(c=P(c,f+1,0));break}while(ye(c.d,o+=10,m));return B=!0,P(c,f,m)};d.minus=d.sub=function(e){var n,t,r,o,i,s,a,c,u,l,f,m,p=this,h=p.constructor;if(e=new h(e),!p.d||!e.d)return!p.s||!e.s?e=new h(NaN):p.d?e.s=-e.s:e=new h(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(u=p.d,m=e.d,a=h.precision,c=h.rounding,!u[0]||!m[0]){if(m[0])e.s=-e.s;else if(u[0])e=new h(p);else return new h(c===3?-0:0);return B?P(e,a,c):e}if(t=H(e.e/k),l=H(p.e/k),u=u.slice(),i=l-t,i){for(f=i<0,f?(n=u,i=-i,s=m.length):(n=m,t=l,s=u.length),r=Math.max(Math.ceil(a/k),s)+2,i>r&&(i=r,n.length=1),n.reverse(),r=i;r--;)n.push(0);n.reverse()}else{for(r=u.length,s=m.length,f=r<s,f&&(s=r),r=0;r<s;r++)if(u[r]!=m[r]){f=u[r]<m[r];break}i=0}for(f&&(n=u,u=m,m=n,e.s=-e.s),s=u.length,r=m.length-s;r>0;--r)u[s++]=0;for(r=m.length;r>i;){if(u[--r]<m[r]){for(o=r;o&&u[--o]===0;)u[o]=J-1;--u[o],u[r]+=J}u[r]-=m[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(e.d=u,e.e=Ve(u,t),B?P(e,a,c):e):new h(c===3?-0:0)};d.modulo=d.mod=function(e){var n,t=this,r=t.constructor;return e=new r(e),!t.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||t.d&&!t.d[0]?P(new r(t),r.precision,r.rounding):(B=!1,r.modulo==9?(n=V(t,e.abs(),0,3,1),n.s*=e.s):n=V(t,e,0,r.modulo,1),n=n.times(e),B=!0,t.minus(n))};d.naturalExponential=d.exp=function(){return Xe(this)};d.naturalLogarithm=d.ln=function(){return ie(this)};d.negated=d.neg=function(){var e=new this.constructor(this);return e.s=-e.s,P(e)};d.plus=d.add=function(e){var n,t,r,o,i,s,a,c,u,l,f=this,m=f.constructor;if(e=new m(e),!f.d||!e.d)return!f.s||!e.s?e=new m(NaN):f.d||(e=new m(e.d||f.s===e.s?f:NaN)),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(u=f.d,l=e.d,a=m.precision,c=m.rounding,!u[0]||!l[0])return l[0]||(e=new m(f)),B?P(e,a,c):e;if(i=H(f.e/k),r=H(e.e/k),u=u.slice(),o=i-r,o){for(o<0?(t=u,o=-o,s=l.length):(t=l,r=i,s=u.length),i=Math.ceil(a/k),s=i>s?i+1:s+1,o>s&&(o=s,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,t=l,l=u,u=t),n=0;o;)n=(u[--o]=u[o]+l[o]+n)/J|0,u[o]%=J;for(n&&(u.unshift(n),++r),s=u.length;u[--s]==0;)u.pop();return e.d=u,e.e=Ve(u,r),B?P(e,a,c):e};d.precision=d.sd=function(e){var n,t=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(oe+e);return t.d?(n=Cn(t.d),e&&t.e+1>n&&(n=t.e+1)):n=NaN,n};d.round=function(){var e=this,n=e.constructor;return P(new n(e),e.e+1,n.rounding)};d.sine=d.sin=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,n=r.rounding,r.precision=e+Math.max(t.e,t.sd())+k,r.rounding=1,t=ct(r,Mn(r,t)),r.precision=e,r.rounding=n,P($>2?t.neg():t,e,n,!0)):new r(NaN)};d.squareRoot=d.sqrt=function(){var e,n,t,r,o,i,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(B=!1,u=Math.sqrt(+s),u==0||u==1/0?(n=G(a),(n.length+c)%2==0&&(n+="0"),u=Math.sqrt(n),c=H((c+1)/2)-(c<0||c%2),u==1/0?n="5e"+c:(n=u.toExponential(),n=n.slice(0,n.indexOf("e")+1)+c),r=new l(n)):r=new l(u.toString()),t=(c=l.precision)+3;;)if(i=r,r=i.plus(V(s,i,t+2,1)).times(.5),G(i.d).slice(0,t)===(n=G(r.d)).slice(0,t))if(n=n.slice(t-3,t+1),n=="9999"||!o&&n=="4999"){if(!o&&(P(i,c+1,0),i.times(i).eq(s))){r=i;break}t+=4,o=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(P(r,c+1,1),e=!r.times(r).eq(s));break}return B=!0,P(r,c,l.rounding,e)};d.tangent=d.tan=function(){var e,n,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,n=r.rounding,r.precision=e+10,r.rounding=1,t=t.sin(),t.s=1,t=V(t,new r(1).minus(t.times(t)).sqrt(),e+10,0),r.precision=e,r.rounding=n,P($==2||$==4?t.neg():t,e,n,!0)):new r(NaN)};d.times=d.mul=function(e){var n,t,r,o,i,s,a,c,u,l=this,f=l.constructor,m=l.d,p=(e=new f(e)).d;if(e.s*=l.s,!m||!m[0]||!p||!p[0])return new f(!e.s||m&&!m[0]&&!p||p&&!p[0]&&!m?NaN:!m||!p?e.s/0:e.s*0);for(t=H(l.e/k)+H(e.e/k),c=m.length,u=p.length,c<u&&(i=m,m=p,p=i,s=c,c=u,u=s),i=[],s=c+u,r=s;r--;)i.push(0);for(r=u;--r>=0;){for(n=0,o=c+r;o>r;)a=i[o]+p[r]*m[o-r-1]+n,i[o--]=a%J|0,n=a/J|0;i[o]=(i[o]+n)%J|0}for(;!i[--s];)i.pop();return n?++t:i.shift(),e.d=i,e.e=Ve(i,t),B?P(e,f.precision,f.rounding):e};d.toBinary=function(e,n){return $e(this,2,e,n)};d.toDecimalPlaces=d.toDP=function(e,n){var t=this,r=t.constructor;return t=new r(t),e===void 0?t:(j(e,0,se),n===void 0?n=r.rounding:j(n,0,8),P(t,e+t.e+1,n))};d.toExponential=function(e,n){var t,r=this,o=r.constructor;return e===void 0?t=X(r,!0):(j(e,0,se),n===void 0?n=o.rounding:j(n,0,8),r=P(new o(r),e+1,n),t=X(r,!0,e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};d.toFixed=function(e,n){var t,r,o=this,i=o.constructor;return e===void 0?t=X(o):(j(e,0,se),n===void 0?n=i.rounding:j(n,0,8),r=P(new i(o),e+o.e+1,n),t=X(r,!1,e+r.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};d.toFraction=function(e){var n,t,r,o,i,s,a,c,u,l,f,m,p=this,h=p.d,g=p.constructor;if(!h)return new g(p);if(u=t=new g(1),r=c=new g(0),n=new g(r),i=n.e=Cn(h)-p.e-1,s=i%k,n.d[0]=U(10,s<0?k+s:s),e==null)e=i>0?n:u;else{if(a=new g(e),!a.isInt()||a.lt(u))throw Error(oe+a);e=a.gt(n)?i>0?n:u:a}for(B=!1,a=new g(G(h)),l=g.precision,g.precision=i=h.length*k*2;f=V(a,n,0,1,1),o=t.plus(f.times(r)),o.cmp(e)!=1;)t=r,r=o,o=u,u=c.plus(f.times(o)),c=o,o=n,n=a.minus(f.times(o)),a=o;return o=V(e.minus(t),r,0,1,1),c=c.plus(o.times(u)),t=t.plus(o.times(r)),c.s=u.s=p.s,m=V(u,r,i,1).minus(p).abs().cmp(V(c,t,i,1).minus(p).abs())<1?[u,r]:[c,t],g.precision=l,B=!0,m};d.toHexadecimal=d.toHex=function(e,n){return $e(this,16,e,n)};d.toNearest=function(e,n){var t=this,r=t.constructor;if(t=new r(t),e==null){if(!t.d)return t;e=new r(1),n=r.rounding}else{if(e=new r(e),n===void 0?n=r.rounding:j(n,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(B=!1,t=V(t,e,0,n,1).times(e),B=!0,P(t)):(e.s=t.s,t=e),t};d.toNumber=function(){return+this};d.toOctal=function(e,n){return $e(this,8,e,n)};d.toPower=d.pow=function(e){var n,t,r,o,i,s,a=this,c=a.constructor,u=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c(U(+a,u));if(a=new c(a),a.eq(1))return a;if(r=c.precision,i=c.rounding,e.eq(1))return P(a,r,i);if(n=H(e.e/k),n>=e.d.length-1&&(t=u<0?-u:u)<=ot)return o=Bn(c,a,t,r),e.s<0?new c(1).div(o):P(o,r,i);if(s=a.s,s<0){if(n<e.d.length-1)return new c(NaN);if((e.d[n]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=U(+a,u),n=t==0||!isFinite(t)?H(u*(Math.log("0."+G(a.d))/Math.LN10+a.e+1)):new c(t+"").e,n>c.maxE+1||n<c.minE-1?new c(n>0?s/0:0):(B=!1,c.rounding=a.s=1,t=Math.min(12,(n+"").length),o=Xe(e.times(ie(a,r+t)),r),o.d&&(o=P(o,r+5,1),ye(o.d,r,i)&&(n=r+10,o=P(Xe(e.times(ie(a,n+t)),n),n+5,1),+G(o.d).slice(r+1,r+15)+1==1e14&&(o=P(o,r+1,0)))),o.s=s,B=!0,c.rounding=i,P(o,r,i))};d.toPrecision=function(e,n){var t,r=this,o=r.constructor;return e===void 0?t=X(r,r.e<=o.toExpNeg||r.e>=o.toExpPos):(j(e,1,se),n===void 0?n=o.rounding:j(n,0,8),r=P(new o(r),e,n),t=X(r,e<=r.e||r.e<=o.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+t:t};d.toSignificantDigits=d.toSD=function(e,n){var t=this,r=t.constructor;return e===void 0?(e=r.precision,n=r.rounding):(j(e,1,se),n===void 0?n=r.rounding:j(n,0,8)),P(new r(t),e,n)};d.toString=function(){var e=this,n=e.constructor,t=X(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t};d.truncated=d.trunc=function(){return P(new this.constructor(this),this.e+1,1)};d.valueOf=d.toJSON=function(){var e=this,n=e.constructor,t=X(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+t:t};function G(e){var n,t,r,o=e.length-1,i="",s=e[0];if(o>0){for(i+=s,n=1;n<o;n++)r=e[n]+"",t=k-r.length,t&&(i+=re(t)),i+=r;s=e[n],r=s+"",t=k-r.length,t&&(i+=re(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function j(e,n,t){if(e!==~~e||e<n||e>t)throw Error(oe+e)}function ye(e,n,t,r){var o,i,s,a;for(i=e[0];i>=10;i/=10)--n;return--n<0?(n+=k,o=0):(o=Math.ceil((n+1)/k),n%=k),i=U(10,k-n),a=e[o]%i|0,r==null?n<3?(n==0?a=a/100|0:n==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==i||t>3&&a+1==i/2)&&(e[o+1]/i/100|0)==U(10,n-2)-1||(a==i/2||a==0)&&(e[o+1]/i/100|0)==0:n<4?(n==0?a=a/1e3|0:n==1?a=a/100|0:n==2&&(a=a/10|0),s=(r||t<4)&&a==9999||!r&&t>3&&a==4999):s=((r||t<4)&&a+1==i||!r&&t>3&&a+1==i/2)&&(e[o+1]/i/1e3|0)==U(10,n-3)-1,s}function Le(e,n,t){for(var r,o=[0],i,s=0,a=e.length;s<a;){for(i=o.length;i--;)o[i]*=n;for(o[0]+=ze.indexOf(e.charAt(s++)),r=0;r<o.length;r++)o[r]>t-1&&(o[r+1]===void 0&&(o[r+1]=0),o[r+1]+=o[r]/t|0,o[r]%=t)}return o.reverse()}function at(e,n){var t,r,o;if(n.isZero())return n;r=n.d.length,r<32?(t=Math.ceil(r/3),o=(1/We(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),e.precision+=t,n=de(e,1,n.times(o),new e(1));for(var i=t;i--;){var s=n.times(n);n=s.times(s).minus(s).times(8).plus(1)}return e.precision-=t,n}var V=function(){function e(r,o,i){var s,a=0,c=r.length;for(r=r.slice();c--;)s=r[c]*o+a,r[c]=s%i|0,a=s/i|0;return a&&r.unshift(a),r}function n(r,o,i,s){var a,c;if(i!=s)c=i>s?1:-1;else for(a=c=0;a<i;a++)if(r[a]!=o[a]){c=r[a]>o[a]?1:-1;break}return c}function t(r,o,i,s){for(var a=0;i--;)r[i]-=a,a=r[i]<o[i]?1:0,r[i]=a*s+r[i]-o[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,o,i,s,a,c){var u,l,f,m,p,h,g,w,A,N,x,T,b,y,I,C,M,v,E,D,L=r.constructor,W=r.s==o.s?1:-1,F=r.d,R=o.d;if(!F||!F[0]||!R||!R[0])return new L(!r.s||!o.s||(F?R&&F[0]==R[0]:!R)?NaN:F&&F[0]==0||!R?W*0:W/0);for(c?(p=1,l=r.e-o.e):(c=J,p=k,l=H(r.e/p)-H(o.e/p)),E=R.length,M=F.length,A=new L(W),N=A.d=[],f=0;R[f]==(F[f]||0);f++);if(R[f]>(F[f]||0)&&l--,i==null?(y=i=L.precision,s=L.rounding):a?y=i+(r.e-o.e)+1:y=i,y<0)N.push(1),h=!0;else{if(y=y/p+2|0,f=0,E==1){for(m=0,R=R[0],y++;(f<M||m)&&y--;f++)I=m*c+(F[f]||0),N[f]=I/R|0,m=I%R|0;h=m||f<M}else{for(m=c/(R[0]+1)|0,m>1&&(R=e(R,m,c),F=e(F,m,c),E=R.length,M=F.length),C=E,x=F.slice(0,E),T=x.length;T<E;)x[T++]=0;D=R.slice(),D.unshift(0),v=R[0],R[1]>=c/2&&++v;do m=0,u=n(R,x,E,T),u<0?(b=x[0],E!=T&&(b=b*c+(x[1]||0)),m=b/v|0,m>1?(m>=c&&(m=c-1),g=e(R,m,c),w=g.length,T=x.length,u=n(g,x,w,T),u==1&&(m--,t(g,E<w?D:R,w,c))):(m==0&&(u=m=1),g=R.slice()),w=g.length,w<T&&g.unshift(0),t(x,g,T,c),u==-1&&(T=x.length,u=n(R,x,E,T),u<1&&(m++,t(x,E<T?D:R,T,c))),T=x.length):u===0&&(m++,x=[0]),N[f++]=m,u&&x[0]?x[T++]=F[C]||0:(x=[F[C]],T=1);while((C++<M||x[0]!==void 0)&&y--);h=x[0]!==void 0}N[0]||N.shift()}if(p==1)A.e=l,Pn=h;else{for(f=1,m=N[0];m>=10;m/=10)f++;A.e=f+l*p-1,P(A,a?i+A.e+1:i,s,h)}return A}}();function P(e,n,t,r){var o,i,s,a,c,u,l,f,m,p=e.constructor;e:if(n!=null){if(f=e.d,!f)return e;for(o=1,a=f[0];a>=10;a/=10)o++;if(i=n-o,i<0)i+=k,s=n,l=f[m=0],c=l/U(10,o-s-1)%10|0;else if(m=Math.ceil((i+1)/k),a=f.length,m>=a)if(r){for(;a++<=m;)f.push(0);l=c=0,o=1,i%=k,s=i-k+1}else break e;else{for(l=a=f[m],o=1;a>=10;a/=10)o++;i%=k,s=i-k+o,c=s<0?0:l/U(10,o-s-1)%10|0}if(r=r||n<0||f[m+1]!==void 0||(s<0?l:l%U(10,o-s-1)),u=t<4?(c||r)&&(t==0||t==(e.s<0?3:2)):c>5||c==5&&(t==4||r||t==6&&(i>0?s>0?l/U(10,o-s):0:f[m-1])%10&1||t==(e.s<0?8:7)),n<1||!f[0])return f.length=0,u?(n-=e.e+1,f[0]=U(10,(k-n%k)%k),e.e=-n||0):f[0]=e.e=0,e;if(i==0?(f.length=m,a=1,m--):(f.length=m+1,a=U(10,k-i),f[m]=s>0?(l/U(10,o-s)%U(10,s)|0)*a:0),u)for(;;)if(m==0){for(i=1,s=f[0];s>=10;s/=10)i++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;i!=a&&(e.e++,f[0]==J&&(f[0]=1));break}else{if(f[m]+=a,f[m]!=J)break;f[m--]=0,a=1}for(i=f.length;f[--i]===0;)f.pop()}return B&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function X(e,n,t){if(!e.isFinite())return In(e);var r,o=e.e,i=G(e.d),s=i.length;return n?(t&&(r=t-s)>0?i=i.charAt(0)+"."+i.slice(1)+re(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):o<0?(i="0."+re(-o-1)+i,t&&(r=t-s)>0&&(i+=re(r))):o>=s?(i+=re(o+1-s),t&&(r=t-o-1)>0&&(i=i+"."+re(r))):((r=o+1)<s&&(i=i.slice(0,r)+"."+i.slice(r)),t&&(r=t-s)>0&&(o+1===s&&(i+="."),i+=re(r))),i}function Ve(e,n){var t=e[0];for(n*=k;t>=10;t/=10)n++;return n}function _e(e,n,t){if(n>st)throw B=!0,t&&(e.precision=t),Error(An);return P(new e(ve),n,1,!0)}function Y(e,n,t){if(n>Je)throw Error(An);return P(new e(Fe),n,t,!0)}function Cn(e){var n=e.length-1,t=n*k+1;if(n=e[n],n){for(;n%10==0;n/=10)t--;for(n=e[0];n>=10;n/=10)t++}return t}function re(e){for(var n="";e--;)n+="0";return n}function Bn(e,n,t,r){var o,i=new e(1),s=Math.ceil(r/k+4);for(B=!1;;){if(t%2&&(i=i.times(n),yn(i.d,s)&&(o=!0)),t=H(t/2),t===0){t=i.d.length-1,o&&i.d[t]===0&&++i.d[t];break}n=n.times(n),yn(n.d,s)}return B=!0,i}function bn(e){return e.d[e.d.length-1]&1}function Rn(e,n,t){for(var r,o=new e(n[0]),i=0;++i<n.length;)if(r=new e(n[i]),r.s)o[t](r)&&(o=r);else{o=r;break}return o}function Xe(e,n){var t,r,o,i,s,a,c,u=0,l=0,f=0,m=e.constructor,p=m.rounding,h=m.precision;if(!e.d||!e.d[0]||e.e>17)return new m(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(n==null?(B=!1,c=h):c=n,a=new m(.03125);e.e>-2;)e=e.times(a),f+=5;for(r=Math.log(U(2,f))/Math.LN10*2+5|0,c+=r,t=i=s=new m(1),m.precision=c;;){if(i=P(i.times(e),c,1),t=t.times(++l),a=s.plus(V(i,t,c,1)),G(a.d).slice(0,c)===G(s.d).slice(0,c)){for(o=f;o--;)s=P(s.times(s),c,1);if(n==null)if(u<3&&ye(s.d,c-r,p,u))m.precision=c+=10,t=i=a=new m(1),l=0,u++;else return P(s,m.precision=h,p,B=!0);else return m.precision=h,s}s=a}}function ie(e,n){var t,r,o,i,s,a,c,u,l,f,m,p=1,h=10,g=e,w=g.d,A=g.constructor,N=A.rounding,x=A.precision;if(g.s<0||!w||!w[0]||!g.e&&w[0]==1&&w.length==1)return new A(w&&!w[0]?-1/0:g.s!=1?NaN:w?0:g);if(n==null?(B=!1,l=x):l=n,A.precision=l+=h,t=G(w),r=t.charAt(0),Math.abs(i=g.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)g=g.times(e),t=G(g.d),r=t.charAt(0),p++;i=g.e,r>1?(g=new A("0."+t),i++):g=new A(r+"."+t.slice(1))}else return u=_e(A,l+2,x).times(i+""),g=ie(new A(r+"."+t.slice(1)),l-h).plus(u),A.precision=x,n==null?P(g,x,N,B=!0):g;for(f=g,c=s=g=V(g.minus(1),g.plus(1),l,1),m=P(g.times(g),l,1),o=3;;){if(s=P(s.times(m),l,1),u=c.plus(V(s,new A(o),l,1)),G(u.d).slice(0,l)===G(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(_e(A,l+2,x).times(i+""))),c=V(c,new A(p),l,1),n==null)if(ye(c.d,l-h,N,a))A.precision=l+=h,u=s=g=V(f.minus(1),f.plus(1),l,1),m=P(g.times(g),l,1),o=a=1;else return P(c,A.precision=x,N,B=!0);else return A.precision=x,c;c=u,o+=2}}function In(e){return String(e.s*e.s/0)}function Qe(e,n){var t,r,o;for((t=n.indexOf("."))>-1&&(n=n.replace(".","")),(r=n.search(/e/i))>0?(t<0&&(t=r),t+=+n.slice(r+1),n=n.substring(0,r)):t<0&&(t=n.length),r=0;n.charCodeAt(r)===48;r++);for(o=n.length;n.charCodeAt(o-1)===48;--o);if(n=n.slice(r,o),n){if(o-=r,e.e=t=t-r-1,e.d=[],r=(t+1)%k,t<0&&(r+=k),r<o){for(r&&e.d.push(+n.slice(0,r)),o-=k;r<o;)e.d.push(+n.slice(r,r+=k));n=n.slice(r),r=k-n.length}else r-=o;for(;r--;)n+="0";e.d.push(+n),B&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function ut(e,n){var t,r,o,i,s,a,c,u,l;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),kn.test(n))return Qe(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(rt.test(n))t=16,n=n.toLowerCase();else if(tt.test(n))t=2;else if(it.test(n))t=8;else throw Error(oe+n);for(i=n.search(/p/i),i>0?(c=+n.slice(i+1),n=n.substring(2,i)):n=n.slice(2),i=n.indexOf("."),s=i>=0,r=e.constructor,s&&(n=n.replace(".",""),a=n.length,i=a-i,o=Bn(r,new r(t),i,i*2)),u=Le(n,t,J),l=u.length-1,i=l;u[i]===0;--i)u.pop();return i<0?new r(e.s*0):(e.e=Ve(u,l),e.d=u,B=!1,s&&(e=V(e,o,a*4)),c&&(e=e.times(Math.abs(c)<54?U(2,c):Ke.pow(2,c))),B=!0,e)}function ct(e,n){var t,r=n.d.length;if(r<3)return n.isZero()?n:de(e,2,n,n);t=1.4*Math.sqrt(r),t=t>16?16:t|0,n=n.times(1/We(5,t)),n=de(e,2,n,n);for(var o,i=new e(5),s=new e(16),a=new e(20);t--;)o=n.times(n),n=n.times(i.plus(o.times(s.times(o).minus(a))));return n}function de(e,n,t,r,o){var i,s,a,c,u=1,l=e.precision,f=Math.ceil(l/k);for(B=!1,c=t.times(t),a=new e(r);;){if(s=V(a.times(c),new e(n++*n++),l,1),a=o?r.plus(s):r.minus(s),r=V(s.times(c),new e(n++*n++),l,1),s=a.plus(r),s.d[f]!==void 0){for(i=f;s.d[i]===a.d[i]&&i--;);if(i==-1)break}i=a,a=r,r=s,s=i,u++}return B=!0,s.d.length=f+1,s}function We(e,n){for(var t=e;--n;)t*=e;return t}function Mn(e,n){var t,r=n.s<0,o=Y(e,e.precision,1),i=o.times(.5);if(n=n.abs(),n.lte(i))return $=r?4:1,n;if(t=n.divToInt(o),t.isZero())$=r?3:2;else{if(n=n.minus(t.times(o)),n.lte(i))return $=bn(t)?r?2:3:r?4:1,n;$=bn(t)?r?1:4:r?3:2}return n.minus(o).abs()}function $e(e,n,t,r){var o,i,s,a,c,u,l,f,m,p=e.constructor,h=t!==void 0;if(h?(j(t,1,se),r===void 0?r=p.rounding:j(r,0,8)):(t=p.precision,r=p.rounding),!e.isFinite())l=In(e);else{for(l=X(e),s=l.indexOf("."),h?(o=2,n==16?t=t*4-3:n==8&&(t=t*3-2)):o=n,s>=0&&(l=l.replace(".",""),m=new p(1),m.e=l.length-s,m.d=Le(X(m),10,o),m.e=m.d.length),f=Le(l,10,o),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])l=h?"0p+0":"0";else{if(s<0?i--:(e=new p(e),e.d=f,e.e=i,e=V(e,m,t,r,0,o),f=e.d,i=e.e,u=Pn),s=f[t],a=o/2,u=u||f[t+1]!==void 0,u=r<4?(s!==void 0||u)&&(r===0||r===(e.s<0?3:2)):s>a||s===a&&(r===4||u||r===6&&f[t-1]&1||r===(e.s<0?8:7)),f.length=t,u)for(;++f[--t]>o-1;)f[t]=0,t||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(s=0,l="";s<c;s++)l+=ze.charAt(f[s]);if(h){if(c>1)if(n==16||n==8){for(s=n==16?4:3,--c;c%s;c++)l+="0";for(f=Le(l,o,n),c=f.length;!f[c-1];--c);for(s=1,l="1.";s<c;s++)l+=ze.charAt(f[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)l="0"+l;l="0."+l}else if(++i>c)for(i-=c;i--;)l+="0";else i<c&&(l=l.slice(0,i)+"."+l.slice(i))}l=(n==16?"0x":n==2?"0b":n==8?"0o":"")+l}return e.s<0?"-"+l:l}function yn(e,n){if(e.length>n)return e.length=n,!0}function lt(e){return new this(e).abs()}function ft(e){return new this(e).acos()}function mt(e){return new this(e).acosh()}function dt(e,n){return new this(e).plus(n)}function pt(e){return new this(e).asin()}function gt(e){return new this(e).asinh()}function ht(e){return new this(e).atan()}function wt(e){return new this(e).atanh()}function Tt(e,n){e=new this(e),n=new this(n);var t,r=this.precision,o=this.rounding,i=r+4;return!e.s||!n.s?t=new this(NaN):!e.d&&!n.d?(t=Y(this,i,1).times(n.s>0?.25:.75),t.s=e.s):!n.d||e.isZero()?(t=n.s<0?Y(this,r,o):new this(0),t.s=e.s):!e.d||n.isZero()?(t=Y(this,i,1).times(.5),t.s=e.s):n.s<0?(this.precision=i,this.rounding=1,t=this.atan(V(e,n,i,1)),n=Y(this,i,1),this.precision=r,this.rounding=o,t=e.s<0?t.minus(n):t.plus(n)):t=this.atan(V(e,n,i,1)),t}function bt(e){return new this(e).cbrt()}function yt(e){return P(e=new this(e),e.e+1,2)}function xt(e,n,t){return new this(e).clamp(n,t)}function Pt(e){if(!e||typeof e!="object")throw Error(Oe+"Object expected");var n,t,r,o=e.defaults===!0,i=["precision",1,se,"rounding",0,8,"toExpNeg",-me,0,"toExpPos",0,me,"maxE",0,me,"minE",-me,0,"modulo",0,9];for(n=0;n<i.length;n+=3)if(t=i[n],o&&(this[t]=Ye[t]),(r=e[t])!==void 0)if(H(r)===r&&r>=i[n+1]&&r<=i[n+2])this[t]=r;else throw Error(oe+t+": "+r);if(t="crypto",o&&(this[t]=Ye[t]),(r=e[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Nn);else this[t]=!1;else throw Error(oe+t+": "+r);return this}function At(e){return new this(e).cos()}function Nt(e){return new this(e).cosh()}function Dn(e){var n,t,r;function o(i){var s,a,c,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,xn(i)){u.s=i.s,B?!i.d||i.e>o.maxE?(u.e=NaN,u.d=null):i.e<o.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(s=0,a=i;a>=10;a/=10)s++;B?s>o.maxE?(u.e=NaN,u.d=null):s<o.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[i]):(u.e=s,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return Qe(u,i.toString())}else if(c!=="string")throw Error(oe+i);return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),kn.test(i)?Qe(u,i):ut(u,i)}if(o.prototype=d,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Pt,o.clone=Dn,o.isDecimal=xn,o.abs=lt,o.acos=ft,o.acosh=mt,o.add=dt,o.asin=pt,o.asinh=gt,o.atan=ht,o.atanh=wt,o.atan2=Tt,o.cbrt=bt,o.ceil=yt,o.clamp=xt,o.cos=At,o.cosh=Nt,o.div=St,o.exp=kt,o.floor=Ct,o.hypot=Bt,o.ln=Rt,o.log=It,o.log10=Dt,o.log2=Mt,o.max=Et,o.min=Lt,o.mod=vt,o.mul=Ft,o.pow=_t,o.random=Ot,o.round=Vt,o.sign=Wt,o.sin=Kt,o.sinh=qt,o.sqrt=Ut,o.sub=Gt,o.sum=Ht,o.tan=Zt,o.tanh=jt,o.trunc=zt,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<r.length;)e.hasOwnProperty(t=r[n++])||(e[t]=this[t]);return o.config(e),o}function St(e,n){return new this(e).div(n)}function kt(e){return new this(e).exp()}function Ct(e){return P(e=new this(e),e.e+1,3)}function Bt(){var e,n,t=new this(0);for(B=!1,e=0;e<arguments.length;)if(n=new this(arguments[e++]),n.d)t.d&&(t=t.plus(n.times(n)));else{if(n.s)return B=!0,new this(1/0);t=n}return B=!0,t.sqrt()}function xn(e){return e instanceof Ke||e&&e.toStringTag===Sn||!1}function Rt(e){return new this(e).ln()}function It(e,n){return new this(e).log(n)}function Mt(e){return new this(e).log(2)}function Dt(e){return new this(e).log(10)}function Et(){return Rn(this,arguments,"lt")}function Lt(){return Rn(this,arguments,"gt")}function vt(e,n){return new this(e).mod(n)}function Ft(e,n){return new this(e).mul(n)}function _t(e,n){return new this(e).pow(n)}function Ot(e){var n,t,r,o,i=0,s=new this(1),a=[];if(e===void 0?e=this.precision:j(e,1,se),r=Math.ceil(e/k),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(r));i<r;)o=n[i],o>=429e7?n[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=o%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(r*=4);i<r;)o=n[i]+(n[i+1]<<8)+(n[i+2]<<16)+((n[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(n,i):(a.push(o%1e7),i+=4);i=r/4}else throw Error(Nn);else for(;i<r;)a[i++]=Math.random()*1e7|0;for(r=a[--i],e%=k,r&&e&&(o=U(10,k-e),a[i]=(r/o|0)*o);a[i]===0;i--)a.pop();if(i<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=k)a.shift();for(r=1,o=a[0];o>=10;o/=10)r++;r<k&&(t-=k-r)}return s.e=t,s.d=a,s}function Vt(e){return P(e=new this(e),e.e+1,this.rounding)}function Wt(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Kt(e){return new this(e).sin()}function qt(e){return new this(e).sinh()}function Ut(e){return new this(e).sqrt()}function Gt(e,n){return new this(e).sub(n)}function Ht(){var e=0,n=arguments,t=new this(n[e]);for(B=!1;t.s&&++e<n.length;)t=t.plus(n[e]);return B=!0,P(t,this.precision,this.rounding)}function Zt(e){return new this(e).tan()}function jt(e){return new this(e).tanh()}function zt(e){return P(e=new this(e),e.e+1,1)}d[Symbol.for("nodejs.util.inspect.custom")]=d.toString;d[Symbol.toStringTag]="Decimal";var Ke=d.constructor=Dn(Ye);ve=new Ke(ve);Fe=new Ke(Fe);import ir from"big.js";import Vr from"bn.js";import{get as En,set as Yt}from"lodash";var en=class{constructor(n){this.logLevel=n.logLevel!==void 0?n.logLevel:0,this.name=n.name}set level(n){this.logLevel=n}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(n){return n<=this.logLevel}error(...n){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...n),this):this}logWithError(...n){let t=n.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(t)}warning(...n){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...n),this):this}info(...n){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...n),this):this}debug(...n){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...n),this):this}},Ln={},Jt={};function z(e){let n=En(Ln,e);if(!n){let t=En(Jt,e);n=new en({name:e,logLevel:t}),Yt(Ln,e,n)}return n}import Xt from"toformat";var Qt=Xt,xe=Qt;import Ue from"big.js";import er from"bn.js";import nr from"decimal.js-light";import Pe from"bn.js";var vn=9007199254740991;function ee(e){let n=z("Raydium_parseBigNumberish");if(e instanceof Pe)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new Pe(e);n.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&n.logWithError(`BigNumberish number underflow: ${e}`),(e>=vn||e<=-vn)&&n.logWithError(`BigNumberish number overflow: ${e}`),new Pe(String(e))):typeof e=="bigint"?new Pe(e.toString()):(n.error(`invalid BigNumberish value: ${e}`),new Pe(0))}var qe=z("module/fraction"),nn=xe(Ue),Ae=xe(nr),tr={[0]:Ae.ROUND_DOWN,[1]:Ae.ROUND_HALF_UP,[2]:Ae.ROUND_UP},rr={[0]:Ue.roundDown,[1]:Ue.roundHalfUp,[2]:Ue.roundUp},K=class{constructor(n,t=new er(1)){this.numerator=ee(n),this.denominator=ee(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new K(this.denominator,this.numerator)}add(n){let t=n instanceof K?n:new K(ee(n));return this.denominator.eq(t.denominator)?new K(this.numerator.add(t.numerator),this.denominator):new K(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(n){let t=n instanceof K?n:new K(ee(n));return this.denominator.eq(t.denominator)?new K(this.numerator.sub(t.numerator),this.denominator):new K(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(n){let t=n instanceof K?n:new K(ee(n));return new K(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(n){let t=n instanceof K?n:new K(ee(n));return new K(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(n,t={groupSeparator:""},r=1){Number.isInteger(n)||qe.logWithError(`${n} is not an integer.`),n<=0&&qe.logWithError(`${n} is not positive.`),Ae.set({precision:n+1,rounding:tr[r]});let o=new Ae(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(n);return o.toFormat(o.decimalPlaces(),t)}toFixed(n,t={groupSeparator:""},r=1){return Number.isInteger(n)||qe.logWithError(`${n} is not an integer.`),n<0&&qe.logWithError(`${n} is negative.`),nn.DP=n,nn.RM=rr[r]||1,new nn(this.numerator.toString()).div(this.denominator.toString()).toFormat(n,t)}isZero(){return this.numerator.isZero()}};var zr=z("Raydium_amount"),Yr=xe(ir);import{PublicKey as sr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Fn}from"@solana/spl-token";var _n={chainId:101,address:sr.default.toBase58(),programId:Fn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},ce={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Fn.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};import{PublicKey as on}from"@solana/web3.js";import{PublicKey as q,SystemProgram as On,SYSVAR_RENT_PUBKEY as ar}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as ur}from"@solana/spl-token";function tn({pubkey:e,isSigner:n=!1,isWritable:t=!0}){return{pubkey:e,isWritable:t,isSigner:n}}var ri=[tn({pubkey:ur,isWritable:!1}),tn({pubkey:On.programId,isWritable:!1}),tn({pubkey:ar,isWritable:!1})];function Vn({publicKey:e,transformSol:n}){let t=Wn(e.toString());if(t instanceof q)return n&&t.equals(Ne)?rn:t;if(n&&t.toString()===Ne.toBase58())return rn;if(typeof t=="string"){if(t===q.default.toBase58())return q.default;try{return new q(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Wn(e){try{return new q(e)}catch{return e}}var ii=new q("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),oi=new q("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),si=new q("SysvarRent111111111111111111111111111111111"),ai=new q("SysvarC1ock11111111111111111111111111111111"),ui=new q("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),ci=new q("Sysvar1nstructions1111111111111111111111111"),li=On.programId,fi=new q("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),mi=new q("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),di=new q("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),pi=new q("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),gi=new q("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),hi=new q("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),wi=new q("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ti=new q("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),bi=new q("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),yi=new q("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),xi=new q("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),rn=new q("So11111111111111111111111111111111111111112"),Ne=q.default;var sn=class{constructor({mint:n,decimals:t,symbol:r,name:o,skipMint:i=!1,isToken2022:s=!1}){if(n===Ne.toBase58()||n instanceof on&&Ne.equals(n)){this.decimals=ce.decimals,this.symbol=ce.symbol,this.name=ce.name,this.mint=new on(ce.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=r||n.toString().substring(0,6),this.name=o||n.toString().substring(0,6),this.mint=i?on.default:Vn({publicKey:n}),this.isToken2022=s}equals(n){return this===n?!0:this.mint.equals(n.mint)}},pe=sn;pe.WSOL=new sn(te(Z({},ce),{mint:ce.address}));var an=class{constructor({decimals:n,symbol:t="UNKNOWN",name:r="UNKNOWN"}){this.decimals=n,this.symbol=t,this.name=r}equals(n){return this===n}},Ge=an;Ge.SOL=new an(_n);import cr from"bn.js";var Ei=new K(new cr(100));var Vi=z("Raydium_price");var lr=new ne(0),go=new ne(1),ho=new ne(2),wo=new ne(3),To=new ne(5),or=new ne(10),bo=new ne(100),yo=new ne(1e3),xo=new ne(1e4);function un(e,n=1,t=[]){let r=[...e];if(n<=0)return t;for(;r.length;)t.push(r.splice(0,n));return t}import{PublicKey as Wo}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as qo}from"@solana/spl-token";import{ComputeBudgetProgram as Gn,Keypair as Zn,PublicKey as Mo,Transaction as jn,TransactionMessage as fr,VersionedTransaction as zn}from"@solana/web3.js";var Se={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",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",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",FarmV4Withdraw:"FarmV4Withdraw",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",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee",TransferTip:"TransferTip"};import{TOKEN_PROGRAM_ID as mr}from"@solana/spl-token";var Hn=z("Raydium_txUtil"),Yn=1644;function He(e){let n=[],t=[];return e.microLamports&&(n.push(Gn.setComputeUnitPrice({microLamports:e.microLamports})),t.push(Se.SetComputeUnitPrice)),e.units&&(n.push(Gn.setComputeUnitLimit({units:e.units})),t.push(Se.SetComputeUnitLimit)),{instructions:n,instructionTypes:t}}async function ge(e,n){var r,o;let t=n!=null?n:"confirmed";return(o=await((r=e.getLatestBlockhash)==null?void 0:r.call(e,{commitment:t})))==null?void 0:o.blockhash}async function Ze(e,n){return e.getSignatureStatuses([n]),new Promise((t,r)=>{let o=setTimeout(r,6e4);e.onSignature(n,i=>{if(clearTimeout(o),!i.err){t("");return}r(Object.assign(i.err,{txId:n}))},"confirmed")})}function dr(e,n){e.length<1&&Hn.logWithError(`no instructions provided: ${e.toString()}`),n.length<1&&Hn.logWithError(`no signers provided:, ${n.toString()}`);let t=new jn;t.recentBlockhash="11111111111111111111111111111111",t.feePayer=n[0],t.add(...e);try{return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64").length<Yn}catch{return!1}}function ke({instructions:e,payer:n,signers:t}){return dr(e,[n,...t])}function Ce({instructions:e,payer:n,lookupTableAddressAccount:t,recentBlockhash:r=Zn.generate().publicKey.toString()}){let i=new fr({payerKey:n,recentBlockhash:r,instructions:e}).compileToV0Message(Object.values(t!=null?t:{}));try{return Buffer.from(new zn(i).serialize()).toString("base64").length<Yn}catch{return!1}}var pr=e=>Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e),gr=e=>{let n=e.serialize({requireAllSignatures:!1,verifySignatures:!1});e instanceof zn&&(n=pr(n));try{return n instanceof Buffer?n.toString("base64"):Buffer.from(n).toString("base64")}catch{return n.toString("base64")}};function le(e){let n=[];return e.forEach(t=>{t instanceof jn&&(t.recentBlockhash||(t.recentBlockhash=mr.toBase58()),t.feePayer||(t.feePayer=Zn.generate().publicKey)),n.push(gr(t))}),console.log("simulate tx string:",n),n}import{PublicKey as S}from"@solana/web3.js";var Zo=new S("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),jo=new S("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),zo=new S("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Yo=new S("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Jo=new S("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Xo=new S("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Qo=new S("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),$o=new S("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),es=new S("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),ns=new S("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),ts=new S("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),rs=new S("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),is=new S("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),os=new S("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),ss=new S("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),as=new S("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),us=new S("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),cs=new S("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),ls=new S("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),fs=new S("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),ms=new S("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),ds=new S("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),ps=new S("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),gs=new S("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),hs=new S("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),ws=new S("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),Ts=new S("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),bs=new S("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),ys=new S("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),xs=new S("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),Ps=new S("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var As={OPEN_BOOK_PROGRAM:new S("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new S("Ray1111111111111111111111111111111111111111"),AMM_V4:new S("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new S("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new S("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new S("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new S("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new S("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new S("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new S("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new S("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new S("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:S.default,Router:new S("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new S("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new S("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new S("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new S("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new S("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new S("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new S("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new S("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new S("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new S("Ray1111111111111111111111111111111111111111")};import ks from"bn.js";import{PublicKey as Rs}from"@solana/web3.js";import Ms from"bn.js";import hr from"bn.js";var Fs=new hr(1e6);import{MINT_SIZE as fa,TOKEN_PROGRAM_ID as ma,getTransferFeeConfig as da,unpackMint as pa}from"@solana/spl-token";var cn=z("Raydium_accountInfo_util");async function Jn(e,n,t){let{batchRequest:r,commitment:o="confirmed",chunkCount:i=100}=Z({batchRequest:!1},t),s=un(n,i),a=new Array(s.length).fill([]);if(r){let c=s.map(f=>{let m=e._buildArgs([f.map(p=>p.toBase58())],o,"base64");return{methodName:"getMultipleAccounts",args:m}}),u=un(c,10);a=(await(await Promise.all(u.map(async f=>await e._rpcBatchRequest(f)))).flat()).map(f=>(f.error&&cn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${f.error.message}`),f.result.value.map(m=>{if(m){let{data:p,executable:h,lamports:g,owner:w,rentEpoch:A}=m;return p.length!==2&&p[1]!=="base64"&&cn.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:h,lamports:g,owner:new wr(w),rentEpoch:A}}return null})))}else try{a=await Promise.all(s.map(c=>e.getMultipleAccountsInfo(c,o)))}catch(c){c instanceof Error&&cn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function fn({connection:e,address:n,cluster:t="mainnet"}){let r=await Jn(e,[...new Set(n.map(i=>i.toString()))].map(i=>new ln(i))),o={};for(let i=0;i<n.length;i++){let s=r[i],a=n[i];if(!s)continue;let c=new Te({key:a,state:Te.deserialize(s.data)});o[a.toString()]=c,t==="devnet"?we[a.toString()]=c:he[a.toString()]=c}return o}var he={},mn=async e=>{let n="AcL1Vo8oy1ULiavEcjSUcwfBSForXMudcZvDZy5nzJkU";if(he[n])return he;let t=new ln(n),r=await e.getAccountInfo(t);return r&&(he[n]=new Te({key:t,state:Te.deserialize(r.data)})),he},we={},dn=async e=>{let n="EFhMuDw1PKEuckuFRW9PavNfTH4LKP5uKHgyXDmWpFCq";if(we[n])return we;let t=new ln(n),r=await e.getAccountInfo(t);return r&&(we[n]=new Te({key:t,state:Te.deserialize(r.data)})),we};var je=2e3,Xn=class{constructor(n){this.instructions=[];this.endInstructions=[];this.lookupTableAddress=[];this.signers=[];this.instructionTypes=[];this.endInstructionTypes=[];this.connection=n.connection,this.feePayer=n.feePayer,this.signAllTransactions=n.signAllTransactions,this.owner=n.owner,this.cluster=n.cluster,this.blockhashCommitment=n.blockhashCommitment,this.loopMultiTxStatus=!