UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

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