@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 138 kB
JavaScript
var eo=Object.defineProperty,to=Object.defineProperties;var no=Object.getOwnPropertyDescriptors;var Ht=Object.getOwnPropertySymbols;var Oi=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable;var Ei=(n,e,t)=>e in n?eo(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,z=(n,e)=>{for(var t in e||(e={}))Oi.call(e,t)&&Ei(n,t,e[t]);if(Ht)for(var t of Ht(e))Vi.call(e,t)&&Ei(n,t,e[t]);return n},Q=(n,e)=>to(n,no(e));var nt=(n,e)=>{var t={};for(var i in n)Oi.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&Ht)for(var i of Ht(n))e.indexOf(i)<0&&Vi.call(n,i)&&(t[i]=n[i]);return t};import{get as Wi,set as io}from"lodash";var In=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},Di={},ro={};function de(n){let e=Wi(Di,n);if(!e){let t=Wi(ro,n);e=new In({name:n,logLevel:t}),io(Di,n,e)}return e}import{PublicKey as wt,sendAndConfirmTransaction as jn,SystemProgram as Cs,Transaction as Vt,TransactionMessage as Wt,VersionedTransaction as Dt}from"@solana/web3.js";import Ks from"axios";import{PublicKey as zn,AddressLookupTableAccount as Pt}from"@solana/web3.js";import{PublicKey as Ss}from"@solana/web3.js";import ve from"bn.js";var dt=9e15,je=1e9,Sn="0123456789abcdef",jt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Cn={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-dt,maxE:dt,crypto:!1},Ui,_e,U=!0,$t="[DecimalError] ",Ze=$t+"Invalid argument: ",Xi=$t+"Precision limit exceeded",zi=$t+"crypto unavailable",Hi="[object Decimal]",pe=Math.floor,ue=Math.pow,oo=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,so=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,ao=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Yi=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ke=1e7,_=7,uo=9007199254740991,co=jt.length-1,Kn=Qt.length-1,T={toStringTag:Hi};T.absoluteValue=T.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),E(n)};T.ceil=function(){return E(new this.constructor(this),this.e+1,2)};T.clampedTo=T.clamp=function(n,e){var t,i=this,o=i.constructor;if(n=new o(n),e=new o(e),!n.s||!e.s)return new o(NaN);if(n.gt(e))throw Error(Ze+e);return t=i.cmp(n),t<0?n:i.cmp(e)>0?e:new o(i)};T.comparedTo=T.cmp=function(n){var e,t,i,o,r=this,s=r.d,a=(n=new r.constructor(n)).d,c=r.s,u=n.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(r.e!==n.e)return r.e>n.e^c<0?1:-1;for(i=s.length,o=a.length,e=0,t=i<o?i:o;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return i===o?0:i>o^c<0?1:-1};T.cosine=T.cos=function(){var n,e,t=this,i=t.constructor;return t.d?t.d[0]?(n=i.precision,e=i.rounding,i.precision=n+Math.max(t.e,t.sd())+_,i.rounding=1,t=lo(i,$i(i,t)),i.precision=n,i.rounding=e,E(_e==2||_e==3?t.neg():t,n,e,!0)):new i(1):new i(NaN)};T.cubeRoot=T.cbrt=function(){var n,e,t,i,o,r,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(U=!1,r=l.s*ue(l.s*l,1/3),!r||Math.abs(r)==1/0?(t=le(l.d),n=l.e,(r=(n-t.length+1)%3)&&(t+=r==1||r==-2?"0":"00"),r=ue(t,1/3),n=pe((n+1)/3)-(n%3==(n<0?-1:2)),r==1/0?t="5e"+n:(t=r.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),i=new m(t),i.s=l.s):i=new m(r.toString()),s=(n=m.precision)+3;;)if(a=i,c=a.times(a).times(a),u=c.plus(l),i=te(u.plus(l).times(a),u.plus(c),s+2,1),le(a.d).slice(0,s)===(t=le(i.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!o&&t=="4999"){if(!o&&(E(a,n+1,0),a.times(a).times(a).eq(l))){i=a;break}s+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(E(i,n+1,1),e=!i.times(i).times(i).eq(l));break}return U=!0,E(i,n,m.rounding,e)};T.decimalPlaces=T.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-pe(this.e/_))*_,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};T.dividedBy=T.div=function(n){return te(this,new this.constructor(n))};T.dividedToIntegerBy=T.divToInt=function(n){var e=this,t=e.constructor;return E(te(e,new t(n),0,1,1),t.precision,t.rounding)};T.equals=T.eq=function(n){return this.cmp(n)===0};T.floor=function(){return E(new this.constructor(this),this.e+1,3)};T.greaterThan=T.gt=function(n){return this.cmp(n)>0};T.greaterThanOrEqualTo=T.gte=function(n){var e=this.cmp(n);return e==1||e===0};T.hyperbolicCosine=T.cosh=function(){var n,e,t,i,o,r=this,s=r.constructor,a=new s(1);if(!r.isFinite())return new s(r.s?1/0:NaN);if(r.isZero())return a;t=s.precision,i=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,o=r.d.length,o<32?(n=Math.ceil(o/3),e=(1/tn(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),r=pt(s,1,r.times(e),new s(1),!0);for(var c,u=n,l=new s(8);u--;)c=r.times(r),r=a.minus(c.times(l.minus(c.times(l))));return E(r,s.precision=t,s.rounding=i,!0)};T.hyperbolicSine=T.sinh=function(){var n,e,t,i,o=this,r=o.constructor;if(!o.isFinite()||o.isZero())return new r(o);if(e=r.precision,t=r.rounding,r.precision=e+Math.max(o.e,o.sd())+4,r.rounding=1,i=o.d.length,i<3)o=pt(r,2,o,o,!0);else{n=1.4*Math.sqrt(i),n=n>16?16:n|0,o=o.times(1/tn(5,n)),o=pt(r,2,o,o,!0);for(var s,a=new r(5),c=new r(16),u=new r(20);n--;)s=o.times(o),o=o.times(a.plus(s.times(c.times(s).plus(u))))}return r.precision=e,r.rounding=t,E(o,e,t,!0)};T.hyperbolicTangent=T.tanh=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+7,i.rounding=1,te(t.sinh(),t.cosh(),i.precision=n,i.rounding=e)):new i(t.s)};T.inverseCosine=T.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),i=e.precision,o=e.rounding;return t!==-1?t===0?n.isNeg()?Le(e,i,o):new e(0):new e(NaN):n.isZero()?Le(e,i+4,o).times(.5):(e.precision=i+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=i,e.rounding=o,n.times(2))};T.inverseHyperbolicCosine=T.acosh=function(){var n,e,t=this,i=t.constructor;return t.lte(1)?new i(t.eq(1)?0:NaN):t.isFinite()?(n=i.precision,e=i.rounding,i.precision=n+Math.max(Math.abs(t.e),t.sd())+4,i.rounding=1,U=!1,t=t.times(t).minus(1).sqrt().plus(t),U=!0,i.precision=n,i.rounding=e,t.ln()):new i(t)};T.inverseHyperbolicSine=T.asinh=function(){var n,e,t=this,i=t.constructor;return!t.isFinite()||t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,i.rounding=1,U=!1,t=t.times(t).plus(1).sqrt().plus(t),U=!0,i.precision=n,i.rounding=e,t.ln())};T.inverseHyperbolicTangent=T.atanh=function(){var n,e,t,i,o=this,r=o.constructor;return o.isFinite()?o.e>=0?new r(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(n=r.precision,e=r.rounding,i=o.sd(),Math.max(i,n)<2*-o.e-1?E(new r(o),n,e,!0):(r.precision=t=i-o.e,o=te(o.plus(1),new r(1).minus(o),t+n,1),r.precision=n+4,r.rounding=1,o=o.ln(),r.precision=n,r.rounding=e,o.times(.5))):new r(NaN)};T.inverseSine=T.asin=function(){var n,e,t,i,o=this,r=o.constructor;return o.isZero()?new r(o):(e=o.abs().cmp(1),t=r.precision,i=r.rounding,e!==-1?e===0?(n=Le(r,t+4,i).times(.5),n.s=o.s,n):new r(NaN):(r.precision=t+6,r.rounding=1,o=o.div(new r(1).minus(o.times(o)).sqrt().plus(1)).atan(),r.precision=t,r.rounding=i,o.times(2)))};T.inverseTangent=T.atan=function(){var n,e,t,i,o,r,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=Kn)return s=Le(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=Kn)return s=Le(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/_+2|0),n=t;n;--n)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(U=!1,e=Math.ceil(a/_),i=1,c=u.times(u),s=new l(u),o=u;n!==-1;)if(o=o.times(c),r=s.minus(o.div(i+=2)),o=o.times(c),s=r.plus(o.div(i+=2)),s.d[e]!==void 0)for(n=e;s.d[n]===r.d[n]&&n--;);return t&&(s=s.times(2<<t-1)),U=!0,E(s,l.precision=m,l.rounding=d,!0)};T.isFinite=function(){return!!this.d};T.isInteger=T.isInt=function(){return!!this.d&&pe(this.e/_)>this.d.length-2};T.isNaN=function(){return!this.s};T.isNegative=T.isNeg=function(){return this.s<0};T.isPositive=T.isPos=function(){return this.s>0};T.isZero=function(){return!!this.d&&this.d[0]===0};T.lessThan=T.lt=function(n){return this.cmp(n)<0};T.lessThanOrEqualTo=T.lte=function(n){return this.cmp(n)<1};T.logarithm=T.log=function(n){var e,t,i,o,r,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,p=5;if(n==null)n=new l(10),e=!0;else{if(n=new l(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new l(NaN);e=n.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new l(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)r=!0;else{for(o=t[0];o%10===0;)o/=10;r=o!==1}if(U=!1,a=m+p,s=Ye(u,a),i=e?Jt(l,a+10):Ye(n,a),c=te(s,i,a,1),Ct(c.d,o=m,d))do if(a+=10,s=Ye(u,a),i=e?Jt(l,a+10):Ye(n,a),c=te(s,i,a,1),!r){+le(c.d).slice(o+1,o+15)+1==1e14&&(c=E(c,m+1,0));break}while(Ct(c.d,o+=10,d));return U=!0,E(c,m,d)};T.minus=T.sub=function(n){var e,t,i,o,r,s,a,c,u,l,m,d,p=this,b=p.constructor;if(n=new b(n),!p.d||!n.d)return!p.s||!n.s?n=new b(NaN):p.d?n.s=-n.s:n=new b(n.d||p.s!==n.s?p:NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(u=p.d,d=n.d,a=b.precision,c=b.rounding,!u[0]||!d[0]){if(d[0])n.s=-n.s;else if(u[0])n=new b(p);else return new b(c===3?-0:0);return U?E(n,a,c):n}if(t=pe(n.e/_),l=pe(p.e/_),u=u.slice(),r=l-t,r){for(m=r<0,m?(e=u,r=-r,s=d.length):(e=d,t=l,s=u.length),i=Math.max(Math.ceil(a/_),s)+2,r>i&&(r=i,e.length=1),e.reverse(),i=r;i--;)e.push(0);e.reverse()}else{for(i=u.length,s=d.length,m=i<s,m&&(s=i),i=0;i<s;i++)if(u[i]!=d[i]){m=u[i]<d[i];break}r=0}for(m&&(e=u,u=d,d=e,n.s=-n.s),s=u.length,i=d.length-s;i>0;--i)u[s++]=0;for(i=d.length;i>r;){if(u[--i]<d[i]){for(o=i;o&&u[--o]===0;)u[o]=Ke-1;--u[o],u[i]+=Ke}u[i]-=d[i]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(n.d=u,n.e=en(u,t),U?E(n,a,c):n):new b(c===3?-0:0)};T.modulo=T.mod=function(n){var e,t=this,i=t.constructor;return n=new i(n),!t.d||!n.s||n.d&&!n.d[0]?new i(NaN):!n.d||t.d&&!t.d[0]?E(new i(t),i.precision,i.rounding):(U=!1,i.modulo==9?(e=te(t,n.abs(),0,3,1),e.s*=n.s):e=te(t,n,0,i.modulo,1),e=e.times(n),U=!0,t.minus(e))};T.naturalExponential=T.exp=function(){return Nn(this)};T.naturalLogarithm=T.ln=function(){return Ye(this)};T.negated=T.neg=function(){var n=new this.constructor(this);return n.s=-n.s,E(n)};T.plus=T.add=function(n){var e,t,i,o,r,s,a,c,u,l,m=this,d=m.constructor;if(n=new d(n),!m.d||!n.d)return!m.s||!n.s?n=new d(NaN):m.d||(n=new d(n.d||m.s===n.s?m:NaN)),n;if(m.s!=n.s)return n.s=-n.s,m.minus(n);if(u=m.d,l=n.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(n=new d(m)),U?E(n,a,c):n;if(r=pe(m.e/_),i=pe(n.e/_),u=u.slice(),o=r-i,o){for(o<0?(t=u,o=-o,s=l.length):(t=l,i=r,s=u.length),r=Math.ceil(a/_),s=r>s?r+1:s+1,o>s&&(o=s,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,t=l,l=u,u=t),e=0;o;)e=(u[--o]=u[o]+l[o]+e)/Ke|0,u[o]%=Ke;for(e&&(u.unshift(e),++i),s=u.length;u[--s]==0;)u.pop();return n.d=u,n.e=en(u,i),U?E(n,a,c):n};T.precision=T.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(Ze+n);return t.d?(e=Zi(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};T.round=function(){var n=this,e=n.constructor;return E(new e(n),n.e+1,e.rounding)};T.sine=T.sin=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+Math.max(t.e,t.sd())+_,i.rounding=1,t=po(i,$i(i,t)),i.precision=n,i.rounding=e,E(_e>2?t.neg():t,n,e,!0)):new i(NaN)};T.squareRoot=T.sqrt=function(){var n,e,t,i,o,r,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(U=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=le(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=pe((c+1)/2)-(c<0||c%2),u==1/0?e="5e"+c:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),i=new l(e)):i=new l(u.toString()),t=(c=l.precision)+3;;)if(r=i,i=r.plus(te(s,r,t+2,1)).times(.5),le(r.d).slice(0,t)===(e=le(i.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!o&&e=="4999"){if(!o&&(E(r,c+1,0),r.times(r).eq(s))){i=r;break}t+=4,o=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(E(i,c+1,1),n=!i.times(i).eq(s));break}return U=!0,E(i,c,l.rounding,n)};T.tangent=T.tan=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+10,i.rounding=1,t=t.sin(),t.s=1,t=te(t,new i(1).minus(t.times(t)).sqrt(),n+10,0),i.precision=n,i.rounding=e,E(_e==2||_e==4?t.neg():t,n,e,!0)):new i(NaN)};T.times=T.mul=function(n){var e,t,i,o,r,s,a,c,u,l=this,m=l.constructor,d=l.d,p=(n=new m(n)).d;if(n.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?n.s/0:n.s*0);for(t=pe(l.e/_)+pe(n.e/_),c=d.length,u=p.length,c<u&&(r=d,d=p,p=r,s=c,c=u,u=s),r=[],s=c+u,i=s;i--;)r.push(0);for(i=u;--i>=0;){for(e=0,o=c+i;o>i;)a=r[o]+p[i]*d[o-i-1]+e,r[o--]=a%Ke|0,e=a/Ke|0;r[o]=(r[o]+e)%Ke|0}for(;!r[--s];)r.pop();return e?++t:r.shift(),n.d=r,n.e=en(r,t),U?E(n,m.precision,m.rounding):n};T.toBinary=function(n,e){return Rn(this,2,n,e)};T.toDecimalPlaces=T.toDP=function(n,e){var t=this,i=t.constructor;return t=new i(t),n===void 0?t:(Pe(n,0,je),e===void 0?e=i.rounding:Pe(e,0,8),E(t,n+t.e+1,e))};T.toExponential=function(n,e){var t,i=this,o=i.constructor;return n===void 0?t=Fe(i,!0):(Pe(n,0,je),e===void 0?e=o.rounding:Pe(e,0,8),i=E(new o(i),n+1,e),t=Fe(i,!0,n+1)),i.isNeg()&&!i.isZero()?"-"+t:t};T.toFixed=function(n,e){var t,i,o=this,r=o.constructor;return n===void 0?t=Fe(o):(Pe(n,0,je),e===void 0?e=r.rounding:Pe(e,0,8),i=E(new r(o),n+o.e+1,e),t=Fe(i,!1,n+i.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};T.toFraction=function(n){var e,t,i,o,r,s,a,c,u,l,m,d,p=this,b=p.d,f=p.constructor;if(!b)return new f(p);if(u=t=new f(1),i=c=new f(0),e=new f(i),r=e.e=Zi(b)-p.e-1,s=r%_,e.d[0]=ue(10,s<0?_+s:s),n==null)n=r>0?e:u;else{if(a=new f(n),!a.isInt()||a.lt(u))throw Error(Ze+a);n=a.gt(e)?r>0?e:u:a}for(U=!1,a=new f(le(b)),l=f.precision,f.precision=r=b.length*_*2;m=te(a,e,0,1,1),o=t.plus(m.times(i)),o.cmp(n)!=1;)t=i,i=o,o=u,u=c.plus(m.times(o)),c=o,o=e,e=a.minus(m.times(o)),a=o;return o=te(n.minus(t),i,0,1,1),c=c.plus(o.times(u)),t=t.plus(o.times(i)),c.s=u.s=p.s,d=te(u,i,r,1).minus(p).abs().cmp(te(c,t,r,1).minus(p).abs())<1?[u,i]:[c,t],f.precision=l,U=!0,d};T.toHexadecimal=T.toHex=function(n,e){return Rn(this,16,n,e)};T.toNearest=function(n,e){var t=this,i=t.constructor;if(t=new i(t),n==null){if(!t.d)return t;n=new i(1),e=i.rounding}else{if(n=new i(n),e===void 0?e=i.rounding:Pe(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(U=!1,t=te(t,n,0,e,1).times(n),U=!0,E(t)):(n.s=t.s,t=n),t};T.toNumber=function(){return+this};T.toOctal=function(n,e){return Rn(this,8,n,e)};T.toPower=T.pow=function(n){var e,t,i,o,r,s,a=this,c=a.constructor,u=+(n=new c(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new c(ue(+a,u));if(a=new c(a),a.eq(1))return a;if(i=c.precision,r=c.rounding,n.eq(1))return E(a,i,r);if(e=pe(n.e/_),e>=n.d.length-1&&(t=u<0?-u:u)<=uo)return o=ji(c,a,t,i),n.s<0?new c(1).div(o):E(o,i,r);if(s=a.s,s<0){if(e<n.d.length-1)return new c(NaN);if((n.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=ue(+a,u),e=t==0||!isFinite(t)?pe(u*(Math.log("0."+le(a.d))/Math.LN10+a.e+1)):new c(t+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(U=!1,c.rounding=a.s=1,t=Math.min(12,(e+"").length),o=Nn(n.times(Ye(a,i+t)),i),o.d&&(o=E(o,i+5,1),Ct(o.d,i,r)&&(e=i+10,o=E(Nn(n.times(Ye(a,e+t)),e),e+5,1),+le(o.d).slice(i+1,i+15)+1==1e14&&(o=E(o,i+1,0)))),o.s=s,U=!0,c.rounding=r,E(o,i,r))};T.toPrecision=function(n,e){var t,i=this,o=i.constructor;return n===void 0?t=Fe(i,i.e<=o.toExpNeg||i.e>=o.toExpPos):(Pe(n,1,je),e===void 0?e=o.rounding:Pe(e,0,8),i=E(new o(i),n,e),t=Fe(i,n<=i.e||i.e<=o.toExpNeg,n)),i.isNeg()&&!i.isZero()?"-"+t:t};T.toSignificantDigits=T.toSD=function(n,e){var t=this,i=t.constructor;return n===void 0?(n=i.precision,e=i.rounding):(Pe(n,1,je),e===void 0?e=i.rounding:Pe(e,0,8)),E(new i(t),n,e)};T.toString=function(){var n=this,e=n.constructor,t=Fe(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};T.truncated=T.trunc=function(){return E(new this.constructor(this),this.e+1,1)};T.valueOf=T.toJSON=function(){var n=this,e=n.constructor,t=Fe(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function le(n){var e,t,i,o=n.length-1,r="",s=n[0];if(o>0){for(r+=s,e=1;e<o;e++)i=n[e]+"",t=_-i.length,t&&(r+=He(t)),r+=i;s=n[e],i=s+"",t=_-i.length,t&&(r+=He(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function Pe(n,e,t){if(n!==~~n||n<e||n>t)throw Error(Ze+n)}function Ct(n,e,t,i){var o,r,s,a;for(r=n[0];r>=10;r/=10)--e;return--e<0?(e+=_,o=0):(o=Math.ceil((e+1)/_),e%=_),r=ue(10,_-e),a=n[o]%r|0,i==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==r||t>3&&a+1==r/2)&&(n[o+1]/r/100|0)==ue(10,e-2)-1||(a==r/2||a==0)&&(n[o+1]/r/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(i||t<4)&&a==9999||!i&&t>3&&a==4999):s=((i||t<4)&&a+1==r||!i&&t>3&&a+1==r/2)&&(n[o+1]/r/1e3|0)==ue(10,e-3)-1,s}function Yt(n,e,t){for(var i,o=[0],r,s=0,a=n.length;s<a;){for(r=o.length;r--;)o[r]*=e;for(o[0]+=Sn.indexOf(n.charAt(s++)),i=0;i<o.length;i++)o[i]>t-1&&(o[i+1]===void 0&&(o[i+1]=0),o[i+1]+=o[i]/t|0,o[i]%=t)}return o.reverse()}function lo(n,e){var t,i,o;if(e.isZero())return e;i=e.d.length,i<32?(t=Math.ceil(i/3),o=(1/tn(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),n.precision+=t,e=pt(n,1,e.times(o),new n(1));for(var r=t;r--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return n.precision-=t,e}var te=function(){function n(i,o,r){var s,a=0,c=i.length;for(i=i.slice();c--;)s=i[c]*o+a,i[c]=s%r|0,a=s/r|0;return a&&i.unshift(a),i}function e(i,o,r,s){var a,c;if(r!=s)c=r>s?1:-1;else for(a=c=0;a<r;a++)if(i[a]!=o[a]){c=i[a]>o[a]?1:-1;break}return c}function t(i,o,r,s){for(var a=0;r--;)i[r]-=a,a=i[r]<o[r]?1:0,i[r]=a*s+i[r]-o[r];for(;!i[0]&&i.length>1;)i.shift()}return function(i,o,r,s,a,c){var u,l,m,d,p,b,f,g,w,A,k,x,P,B,I,S,C,L,K,q,R=i.constructor,H=i.s==o.s?1:-1,h=i.d,N=o.d;if(!h||!h[0]||!N||!N[0])return new R(!i.s||!o.s||(h?N&&h[0]==N[0]:!N)?NaN:h&&h[0]==0||!N?H*0:H/0);for(c?(p=1,l=i.e-o.e):(c=Ke,p=_,l=pe(i.e/p)-pe(o.e/p)),K=N.length,C=h.length,w=new R(H),A=w.d=[],m=0;N[m]==(h[m]||0);m++);if(N[m]>(h[m]||0)&&l--,r==null?(B=r=R.precision,s=R.rounding):a?B=r+(i.e-o.e)+1:B=r,B<0)A.push(1),b=!0;else{if(B=B/p+2|0,m=0,K==1){for(d=0,N=N[0],B++;(m<C||d)&&B--;m++)I=d*c+(h[m]||0),A[m]=I/N|0,d=I%N|0;b=d||m<C}else{for(d=c/(N[0]+1)|0,d>1&&(N=n(N,d,c),h=n(h,d,c),K=N.length,C=h.length),S=K,k=h.slice(0,K),x=k.length;x<K;)k[x++]=0;q=N.slice(),q.unshift(0),L=N[0],N[1]>=c/2&&++L;do d=0,u=e(N,k,K,x),u<0?(P=k[0],K!=x&&(P=P*c+(k[1]||0)),d=P/L|0,d>1?(d>=c&&(d=c-1),f=n(N,d,c),g=f.length,x=k.length,u=e(f,k,g,x),u==1&&(d--,t(f,K<g?q:N,g,c))):(d==0&&(u=d=1),f=N.slice()),g=f.length,g<x&&f.unshift(0),t(k,f,x,c),u==-1&&(x=k.length,u=e(N,k,K,x),u<1&&(d++,t(k,K<x?q:N,x,c))),x=k.length):u===0&&(d++,k=[0]),A[m++]=d,u&&k[0]?k[x++]=h[S]||0:(k=[h[S]],x=1);while((S++<C||k[0]!==void 0)&&B--);b=k[0]!==void 0}A[0]||A.shift()}if(p==1)w.e=l,Ui=b;else{for(m=1,d=A[0];d>=10;d/=10)m++;w.e=m+l*p-1,E(w,a?r+w.e+1:r,s,b)}return w}}();function E(n,e,t,i){var o,r,s,a,c,u,l,m,d,p=n.constructor;e:if(e!=null){if(m=n.d,!m)return n;for(o=1,a=m[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=_,s=e,l=m[d=0],c=l/ue(10,o-s-1)%10|0;else if(d=Math.ceil((r+1)/_),a=m.length,d>=a)if(i){for(;a++<=d;)m.push(0);l=c=0,o=1,r%=_,s=r-_+1}else break e;else{for(l=a=m[d],o=1;a>=10;a/=10)o++;r%=_,s=r-_+o,c=s<0?0:l/ue(10,o-s-1)%10|0}if(i=i||e<0||m[d+1]!==void 0||(s<0?l:l%ue(10,o-s-1)),u=t<4?(c||i)&&(t==0||t==(n.s<0?3:2)):c>5||c==5&&(t==4||i||t==6&&(r>0?s>0?l/ue(10,o-s):0:m[d-1])%10&1||t==(n.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=n.e+1,m[0]=ue(10,(_-e%_)%_),n.e=-e||0):m[0]=n.e=0,n;if(r==0?(m.length=d,a=1,d--):(m.length=d+1,a=ue(10,_-r),m[d]=s>0?(l/ue(10,o-s)%ue(10,s)|0)*a:0),u)for(;;)if(d==0){for(r=1,s=m[0];s>=10;s/=10)r++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;r!=a&&(n.e++,m[0]==Ke&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=Ke)break;m[d--]=0,a=1}for(r=m.length;m[--r]===0;)m.pop()}return U&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function Fe(n,e,t){if(!n.isFinite())return Ji(n);var i,o=n.e,r=le(n.d),s=r.length;return e?(t&&(i=t-s)>0?r=r.charAt(0)+"."+r.slice(1)+He(i):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(n.e<0?"e":"e+")+n.e):o<0?(r="0."+He(-o-1)+r,t&&(i=t-s)>0&&(r+=He(i))):o>=s?(r+=He(o+1-s),t&&(i=t-o-1)>0&&(r=r+"."+He(i))):((i=o+1)<s&&(r=r.slice(0,i)+"."+r.slice(i)),t&&(i=t-s)>0&&(o+1===s&&(r+="."),r+=He(i))),r}function en(n,e){var t=n[0];for(e*=_;t>=10;t/=10)e++;return e}function Jt(n,e,t){if(e>co)throw U=!0,t&&(n.precision=t),Error(Xi);return E(new n(jt),e,1,!0)}function Le(n,e,t){if(e>Kn)throw Error(Xi);return E(new n(Qt),e,t,!0)}function Zi(n){var e=n.length-1,t=e*_+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function He(n){for(var e="";n--;)e+="0";return e}function ji(n,e,t,i){var o,r=new n(1),s=Math.ceil(i/_+4);for(U=!1;;){if(t%2&&(r=r.times(e),qi(r.d,s)&&(o=!0)),t=pe(t/2),t===0){t=r.d.length-1,o&&r.d[t]===0&&++r.d[t];break}e=e.times(e),qi(e.d,s)}return U=!0,r}function _i(n){return n.d[n.d.length-1]&1}function Qi(n,e,t){for(var i,o,r=new n(e[0]),s=0;++s<e.length;){if(o=new n(e[s]),!o.s){r=o;break}i=r.cmp(o),(i===t||i===0&&r.s===t)&&(r=o)}return r}function Nn(n,e){var t,i,o,r,s,a,c,u=0,l=0,m=0,d=n.constructor,p=d.rounding,b=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:0/0);for(e==null?(U=!1,c=b):c=e,a=new d(.03125);n.e>-2;)n=n.times(a),m+=5;for(i=Math.log(ue(2,m))/Math.LN10*2+5|0,c+=i,t=r=s=new d(1),d.precision=c;;){if(r=E(r.times(n),c,1),t=t.times(++l),a=s.plus(te(r,t,c,1)),le(a.d).slice(0,c)===le(s.d).slice(0,c)){for(o=m;o--;)s=E(s.times(s),c,1);if(e==null)if(u<3&&Ct(s.d,c-i,p,u))d.precision=c+=10,t=r=a=new d(1),l=0,u++;else return E(s,d.precision=b,p,U=!0);else return d.precision=b,s}s=a}}function Ye(n,e){var t,i,o,r,s,a,c,u,l,m,d,p=1,b=10,f=n,g=f.d,w=f.constructor,A=w.rounding,k=w.precision;if(f.s<0||!g||!g[0]||!f.e&&g[0]==1&&g.length==1)return new w(g&&!g[0]?-1/0:f.s!=1?NaN:g?0:f);if(e==null?(U=!1,l=k):l=e,w.precision=l+=b,t=le(g),i=t.charAt(0),Math.abs(r=f.e)<15e14){for(;i<7&&i!=1||i==1&&t.charAt(1)>3;)f=f.times(n),t=le(f.d),i=t.charAt(0),p++;r=f.e,i>1?(f=new w("0."+t),r++):f=new w(i+"."+t.slice(1))}else return u=Jt(w,l+2,k).times(r+""),f=Ye(new w(i+"."+t.slice(1)),l-b).plus(u),w.precision=k,e==null?E(f,k,A,U=!0):f;for(m=f,c=s=f=te(f.minus(1),f.plus(1),l,1),d=E(f.times(f),l,1),o=3;;){if(s=E(s.times(d),l,1),u=c.plus(te(s,new w(o),l,1)),le(u.d).slice(0,l)===le(c.d).slice(0,l))if(c=c.times(2),r!==0&&(c=c.plus(Jt(w,l+2,k).times(r+""))),c=te(c,new w(p),l,1),e==null)if(Ct(c.d,l-b,A,a))w.precision=l+=b,u=s=f=te(m.minus(1),m.plus(1),l,1),d=E(f.times(f),l,1),o=a=1;else return E(c,w.precision=k,A,U=!0);else return w.precision=k,c;c=u,o+=2}}function Ji(n){return String(n.s*n.s/0)}function Zt(n,e){var t,i,o;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(t<0&&(t=i),t+=+e.slice(i+1),e=e.substring(0,i)):t<0&&(t=e.length),i=0;e.charCodeAt(i)===48;i++);for(o=e.length;e.charCodeAt(o-1)===48;--o);if(e=e.slice(i,o),e){if(o-=i,n.e=t=t-i-1,n.d=[],i=(t+1)%_,t<0&&(i+=_),i<o){for(i&&n.d.push(+e.slice(0,i)),o-=_;i<o;)n.d.push(+e.slice(i,i+=_));e=e.slice(i),i=_-e.length}else i-=o;for(;i--;)e+="0";n.d.push(+e),U&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function mo(n,e){var t,i,o,r,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Yi.test(e))return Zt(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(so.test(e))t=16,e=e.toLowerCase();else if(oo.test(e))t=2;else if(ao.test(e))t=8;else throw Error(Ze+e);for(r=e.search(/p/i),r>0?(c=+e.slice(r+1),e=e.substring(2,r)):e=e.slice(2),r=e.indexOf("."),s=r>=0,i=n.constructor,s&&(e=e.replace(".",""),a=e.length,r=a-r,o=ji(i,new i(t),r,r*2)),u=Yt(e,t,Ke),l=u.length-1,r=l;u[r]===0;--r)u.pop();return r<0?new i(n.s*0):(n.e=en(u,l),n.d=u,U=!1,s&&(n=te(n,o,a*4)),c&&(n=n.times(Math.abs(c)<54?ue(2,c):Kt.pow(2,c))),U=!0,n)}function po(n,e){var t,i=e.d.length;if(i<3)return e.isZero()?e:pt(n,2,e,e);t=1.4*Math.sqrt(i),t=t>16?16:t|0,e=e.times(1/tn(5,t)),e=pt(n,2,e,e);for(var o,r=new n(5),s=new n(16),a=new n(20);t--;)o=e.times(e),e=e.times(r.plus(o.times(s.times(o).minus(a))));return e}function pt(n,e,t,i,o){var r,s,a,c,u=1,l=n.precision,m=Math.ceil(l/_);for(U=!1,c=t.times(t),a=new n(i);;){if(s=te(a.times(c),new n(e++*e++),l,1),a=o?i.plus(s):i.minus(s),i=te(s.times(c),new n(e++*e++),l,1),s=a.plus(i),s.d[m]!==void 0){for(r=m;s.d[r]===a.d[r]&&r--;);if(r==-1)break}r=a,a=i,i=s,s=r,u++}return U=!0,s.d.length=m+1,s}function tn(n,e){for(var t=n;--e;)t*=n;return t}function $i(n,e){var t,i=e.s<0,o=Le(n,n.precision,1),r=o.times(.5);if(e=e.abs(),e.lte(r))return _e=i?4:1,e;if(t=e.divToInt(o),t.isZero())_e=i?3:2;else{if(e=e.minus(t.times(o)),e.lte(r))return _e=_i(t)?i?2:3:i?4:1,e;_e=_i(t)?i?1:4:i?3:2}return e.minus(o).abs()}function Rn(n,e,t,i){var o,r,s,a,c,u,l,m,d,p=n.constructor,b=t!==void 0;if(b?(Pe(t,1,je),i===void 0?i=p.rounding:Pe(i,0,8)):(t=p.precision,i=p.rounding),!n.isFinite())l=Ji(n);else{for(l=Fe(n),s=l.indexOf("."),b?(o=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):o=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Yt(Fe(d),10,o),d.e=d.d.length),m=Yt(l,10,o),r=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=b?"0p+0":"0";else{if(s<0?r--:(n=new p(n),n.d=m,n.e=r,n=te(n,d,t,i,0,o),m=n.d,r=n.e,u=Ui),s=m[t],a=o/2,u=u||m[t+1]!==void 0,u=i<4?(s!==void 0||u)&&(i===0||i===(n.s<0?3:2)):s>a||s===a&&(i===4||u||i===6&&m[t-1]&1||i===(n.s<0?8:7)),m.length=t,u)for(;++m[--t]>o-1;)m[t]=0,t||(++r,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=Sn.charAt(m[s]);if(b){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=Yt(l,o,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Sn.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(r<0?"p":"p+")+r}else if(r<0){for(;++r;)l="0"+l;l="0."+l}else if(++r>c)for(r-=c;r--;)l+="0";else r<c&&(l=l.slice(0,r)+"."+l.slice(r))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return n.s<0?"-"+l:l}function qi(n,e){if(n.length>e)return n.length=e,!0}function fo(n){return new this(n).abs()}function bo(n){return new this(n).acos()}function yo(n){return new this(n).acosh()}function go(n,e){return new this(n).plus(e)}function Po(n){return new this(n).asin()}function wo(n){return new this(n).asinh()}function Ao(n){return new this(n).atan()}function To(n){return new this(n).atanh()}function ko(n,e){n=new this(n),e=new this(e);var t,i=this.precision,o=this.rounding,r=i+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=Le(this,r,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?Le(this,i,o):new this(0),t.s=n.s):!n.d||e.isZero()?(t=Le(this,r,1).times(.5),t.s=n.s):e.s<0?(this.precision=r,this.rounding=1,t=this.atan(te(n,e,r,1)),e=Le(this,r,1),this.precision=i,this.rounding=o,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(te(n,e,r,1)),t}function ho(n){return new this(n).cbrt()}function Bo(n){return E(n=new this(n),n.e+1,2)}function xo(n,e,t){return new this(n).clamp(e,t)}function Io(n){if(!n||typeof n!="object")throw Error($t+"Object expected");var e,t,i,o=n.defaults===!0,r=["precision",1,je,"rounding",0,8,"toExpNeg",-dt,0,"toExpPos",0,dt,"maxE",0,dt,"minE",-dt,0,"modulo",0,9];for(e=0;e<r.length;e+=3)if(t=r[e],o&&(this[t]=Cn[t]),(i=n[t])!==void 0)if(pe(i)===i&&i>=r[e+1]&&i<=r[e+2])this[t]=i;else throw Error(Ze+t+": "+i);if(t="crypto",o&&(this[t]=Cn[t]),(i=n[t])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(zi);else this[t]=!1;else throw Error(Ze+t+": "+i);return this}function So(n){return new this(n).cos()}function Co(n){return new this(n).cosh()}function er(n){var e,t,i;function o(r){var s,a,c,u=this;if(!(u instanceof o))return new o(r);if(u.constructor=o,Gi(r)){u.s=r.s,U?!r.d||r.e>o.maxE?(u.e=NaN,u.d=null):r.e<o.minE?(u.e=0,u.d=[0]):(u.e=r.e,u.d=r.d.slice()):(u.e=r.e,u.d=r.d?r.d.slice():r.d);return}if(c=typeof r,c==="number"){if(r===0){u.s=1/r<0?-1:1,u.e=0,u.d=[0];return}if(r<0?(r=-r,u.s=-1):u.s=1,r===~~r&&r<1e7){for(s=0,a=r;a>=10;a/=10)s++;U?s>o.maxE?(u.e=NaN,u.d=null):s<o.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[r]):(u.e=s,u.d=[r]);return}if(r*0!==0){r||(u.s=NaN),u.e=NaN,u.d=null;return}return Zt(u,r.toString())}if(c==="string")return(a=r.charCodeAt(0))===45?(r=r.slice(1),u.s=-1):(a===43&&(r=r.slice(1)),u.s=1),Yi.test(r)?Zt(u,r):mo(u,r);if(c==="bigint")return r<0?(r=-r,u.s=-1):u.s=1,Zt(u,r.toString());throw Error(Ze+r)}if(o.prototype=T,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=Io,o.clone=er,o.isDecimal=Gi,o.abs=fo,o.acos=bo,o.acosh=yo,o.add=go,o.asin=Po,o.asinh=wo,o.atan=Ao,o.atanh=To,o.atan2=ko,o.cbrt=ho,o.ceil=Bo,o.clamp=xo,o.cos=So,o.cosh=Co,o.div=Ko,o.exp=No,o.floor=Ro,o.hypot=Lo,o.ln=Fo,o.log=Mo,o.log10=Eo,o.log2=vo,o.max=Oo,o.min=Vo,o.mod=Wo,o.mul=Do,o.pow=_o,o.random=qo,o.round=Go,o.sign=Uo,o.sin=Xo,o.sinh=zo,o.sqrt=Ho,o.sub=Yo,o.sum=Zo,o.tan=jo,o.tanh=Qo,o.trunc=Jo,n===void 0&&(n={}),n&&n.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)n.hasOwnProperty(t=i[e++])||(n[t]=this[t]);return o.config(n),o}function Ko(n,e){return new this(n).div(e)}function No(n){return new this(n).exp()}function Ro(n){return E(n=new this(n),n.e+1,3)}function Lo(){var n,e,t=new this(0);for(U=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return U=!0,new this(1/0);t=e}return U=!0,t.sqrt()}function Gi(n){return n instanceof Kt||n&&n.toStringTag===Hi||!1}function Fo(n){return new this(n).ln()}function Mo(n,e){return new this(n).log(e)}function vo(n){return new this(n).log(2)}function Eo(n){return new this(n).log(10)}function Oo(){return Qi(this,arguments,-1)}function Vo(){return Qi(this,arguments,1)}function Wo(n,e){return new this(n).mod(e)}function Do(n,e){return new this(n).mul(e)}function _o(n,e){return new this(n).pow(e)}function qo(n){var e,t,i,o,r=0,s=new this(1),a=[];if(n===void 0?n=this.precision:Pe(n,1,je),i=Math.ceil(n/_),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));r<i;)o=e[r],o>=429e7?e[r]=crypto.getRandomValues(new Uint32Array(1))[0]:a[r++]=o%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);r<i;)o=e[r]+(e[r+1]<<8)+(e[r+2]<<16)+((e[r+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(e,r):(a.push(o%1e7),r+=4);r=i/4}else throw Error(zi);else for(;r<i;)a[r++]=Math.random()*1e7|0;for(i=a[--r],n%=_,i&&n&&(o=ue(10,_-n),a[r]=(i/o|0)*o);a[r]===0;r--)a.pop();if(r<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=_)a.shift();for(i=1,o=a[0];o>=10;o/=10)i++;i<_&&(t-=_-i)}return s.e=t,s.d=a,s}function Go(n){return E(n=new this(n),n.e+1,this.rounding)}function Uo(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function Xo(n){return new this(n).sin()}function zo(n){return new this(n).sinh()}function Ho(n){return new this(n).sqrt()}function Yo(n,e){return new this(n).sub(e)}function Zo(){var n=0,e=arguments,t=new this(e[n]);for(U=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return U=!0,E(t,this.precision,this.rounding)}function jo(n){return new this(n).tan()}function Qo(n){return new this(n).tanh()}function Jo(n){return E(n=new this(n),n.e+1,1)}T[Symbol.for("nodejs.util.inspect.custom")]=T.toString;T[Symbol.toStringTag]="Decimal";var Kt=T.constructor=er(Cn);jt=new Kt(jt);Qt=new Kt(Qt);var G=Kt;import ss from"big.js";import Oa from"bn.js";import $o from"toformat";var es=$o,Nt=es;import rn from"big.js";import ns from"bn.js";import is from"decimal.js-light";import Rt from"bn.js";var tr=9007199254740991;function Me(n){let e=de("Raydium_parseBigNumberish");if(n instanceof Rt)return n;if(typeof n=="string"){if(n.match(/^-?[0-9]+$/))return new Rt(n);e.logWithError(`invalid BigNumberish string: ${n}`)}return typeof n=="number"?(n%1&&e.logWithError(`BigNumberish number underflow: ${n}`),(n>=tr||n<=-tr)&&e.logWithError(`BigNumberish number overflow: ${n}`),new Rt(String(n))):typeof n=="bigint"?new Rt(n.toString()):(e.error(`invalid BigNumberish value: ${n}`),new Rt(0))}var nn=de("module/fraction"),Ln=Nt(rn),Lt=Nt(is),rs={[0]:Lt.ROUND_DOWN,[1]:Lt.ROUND_HALF_UP,[2]:Lt.ROUND_UP},os={[0]:rn.roundDown,[1]:rn.roundHalfUp,[2]:rn.roundUp},ie=class{constructor(e,t=new ns(1)){this.numerator=Me(e),this.denominator=Me(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new ie(this.denominator,this.numerator)}add(e){let t=e instanceof ie?e:new ie(Me(e));return this.denominator.eq(t.denominator)?new ie(this.numerator.add(t.numerator),this.denominator):new ie(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof ie?e:new ie(Me(e));return this.denominator.eq(t.denominator)?new ie(this.numerator.sub(t.numerator),this.denominator):new ie(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof ie?e:new ie(Me(e));return new ie(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof ie?e:new ie(Me(e));return new ie(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},i=1){Number.isInteger(e)||nn.logWithError(`${e} is not an integer.`),e<=0&&nn.logWithError(`${e} is not positive.`),Lt.set({precision:e+1,rounding:rs[i]});let o=new Lt(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return o.toFormat(o.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},i=1){return Number.isInteger(e)||nn.logWithError(`${e} is not an integer.`),e<0&&nn.logWithError(`${e} is negative.`),Ln.DP=e,Ln.RM=os[i]||1,new Ln(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var za=de("Raydium_amount"),Ha=Nt(ss);import{PublicKey as us}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as nr}from"@solana/spl-token";var Fn={chainId:101,address:us.default.toBase58(),programId:nr.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},Qe={chainId:101,address:"So11111111111111111111111111111111111111112",programId:nr.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 En}from"@solana/web3.js";import{PublicKey as re,SystemProgram as ir,SYSVAR_RENT_PUBKEY as cs}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as ls}from"@solana/spl-token";function Mn({pubkey:n,isSigner:e=!1,isWritable:t=!0}){return{pubkey:n,isWritable:t,isSigner:e}}var tu=[Mn({pubkey:ls,isWritable:!1}),Mn({pubkey:ir.programId,isWritable:!1}),Mn({pubkey:cs,isWritable:!1})];function rr({publicKey:n,transformSol:e}){let t=or(n.toString());if(t instanceof re)return e&&t.equals(Ft)?on:t;if(e&&t.toString()===Ft.toBase58())return on;if(typeof t=="string"){if(t===re.default.toBase58())return re.default;try{return new re(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function or(n){try{return new re(n)}catch{return n}}var ms=new re("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),ds=new re("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),vn=new re("SysvarRent111111111111111111111111111111111"),nu=new re("SysvarC1ock11111111111111111111111111111111"),ft=new re("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),iu=new re("Sysvar1nstructions1111111111111111111111111"),ru=ir.programId,ou=new re("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),su=new re("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),au=new re("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),uu=new re("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),cu=new re("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),lu=new re("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),mu=new re("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),du=new re("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),pu=new re("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),fu=new re("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),bu=new re("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),on=new re("So11111111111111111111111111111111111111112"),Ft=re.default;var On=class{constructor({mint:e,decimals:t,symbol:i,name:o,skipMint:r=!1,isToken2022:s=!1}){if(e===Ft.toBase58()||e instanceof En&&Ft.equals(e)){this.decimals=Qe.decimals,this.symbol=Qe.symbol,this.name=Qe.name,this.mint=new En(Qe.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=i||e.toString().substring(0,6),this.name=o||e.toString().substring(0,6),this.mint=r?En.default:rr({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Je=On;Je.WSOL=new On(Q(z({},Qe),{mint:Qe.address}));var Vn=class{constructor({decimals:e,symbol:t="UNKNOWN",name:i="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=i}equals(e){return this===e}},sn=Vn;sn.SOL=new Vn(Fn);import ps from"bn.js";var Su=new ie(new ps(100));var Fu=de("Raydium_price");var fs=new ve(0),ac=new ve(1),uc=new ve(2),cc=new ve(3),lc=new ve(5),as=new ve(10),mc=new ve(100),dc=new ve(1e3),pc=new ve(1e4);function sr(n,e,t){return n.mul(e).add(t).sub(new ve(1)).div(t)}function _n(n,e=1,t=[]){let i=[...n];if(e<=0)return t;for(;i.length;)t.push(i.splice(0,e));return t}import{PublicKey as Ts}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as ks}from"@solana/spl-token";import{ComputeBudgetProgram as ar,Keypair as cr,PublicKey as bs,Transaction as lr,TransactionMessage as ys,VersionedTransaction as mr}from"@solana/web3.js";var it={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 gs}from"@solana/spl-token";var ur=de("Raydium_txUtil"),dr=1644;function un(n){let e=[],t=[];return n.microLamports&&(e.push(ar.setComputeUnitPrice({microLamports:n.microLamports})),t.push(it.SetComputeUnitPrice)),n.units&&(e.push(ar.setComputeUnitLimit({units:n.units})),t.push(it.SetComputeUnitLimit)),{instructions:e,instructionTypes:t}}async function bt(n,e){var i,o;let t=e!=null?e:"confirmed";return(o=await((i=n.getLatestBlockhash)==null?void 0:i.call(n,{commitment:t})))==null?void 0:o.blockhash}async function cn(n,e){return n.getSignatureStatuses([e]),new Promise((t,i)=>{let o=setTimeout(i,6e4);n.onSignature(e,r=>{if(clearTimeout(o),!r.err){t("");return}i(Object.assign(r.err,{txId:e}))},"confirmed")})}function Ps(n,e){n.length<1&&ur.logWithError(`no instructions provided: ${n.toString()}`),e.length<1&&ur.logWithError(`no signers provided:, ${e.toString()}`);let t=new lr;t.recentBlockhash="11111111111111111111111111111111",t.feePayer=e[0],t.add(...n);try{return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64").length<dr}catch{return!1}}function fe(n,e){let[t,i]=bs.findProgramAddressSync(n,e);return{publicKey:t,nonce:i}}function Mt({instructions:n,payer:e,signers:t}){return Ps(n,[e,...t])}function vt({instructions:n,payer:e,lookupTableAddressAccount:t,recentBlockhash:i=cr.generate().publicKey.toString()}){let r=new ys({payerKey:e,recentBlockhash:i,instructions:n}).compileToV0Message(Object.values(t!=null?t:{}));try{return Buffer.from(new mr(r).serialize()).toString("base64").length<dr}catch{return!1}}var ws=n=>Buffer.isBuffer(n)?n:n instanceof Uint8Array?Buffer.from(n.buffer,n.byteOffset,n.byteLength):Buffer.from(n),As=n=>{let e=n.serialize({requireAllSignatures:!1,verifySignatures:!1});n instanceof mr&&(e=ws(e));try{return e instanceof Buffer?e.toString("base64"):Buffer.from(e).toString("base64")}catch{return e.toString("base64")}};function rt(n){let e=[];return n.forEach(t=>{t instanceof lr&&(t.recentBlockhash||(t.recentBlockhash=gs.toBase58()),t.feePayer||(t.feePayer=cr.generate().publicKey)),e.push(As(t))}),console.log("simulate tx string:",e),e}function Ne(n,e,t){return fe([n.toBuffer(),(t!=null?t:ks).toBuffer(),e.toBuffer()],new Ts("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))}import{PublicKey as W}from"@solana/web3.js";var Mc=new W("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),vc=new W("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),Ec=new W("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Oc=new W("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Vc=new W("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Wc=new W("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Dc=new W("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),_c=new W("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),qc=new W("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Gc=new W("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),hs=new W("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),Bs=new W("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),xs=new W("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),Uc=new W("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Xc=new W("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),zc=new W("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),Hc=new W("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Yc=new W("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Zc=new W("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),jc=new W("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),Qc=new W("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Jc=new W("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),$c=new W("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),el=new W("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),tl=new W("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),ce=new W("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),nl=new W("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),il=new W("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),rl=new W("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),ol=new W("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),sl=new W("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var al={OPEN_BOOK_PROGRAM:new W("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new W("Ray1111111111111111111111111111111111111111"),AMM_V4:new W("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new W("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new W("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new W("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new W("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new W("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new W("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new W("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new W("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new W("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:W.default,Router:new W("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new W("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new W("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new W("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new W("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new W("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new W("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new W("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new W("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new W("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new W("Ray1111111111111111111111111111111111111111")};import be from"bn.js";var Et=1e4;function qn(n,e){let{div:t,mod:i}=n.divmod(e);return i.gt(new be(0))?t.add(new be(1)):t}function ot(n,e){if(n.isZero())return new be(0);let t=n.div(e);return t.isZero()?new be(1):n.mod(e).gt(new be(0))?t.add(new be(1)):t}function Gn(n,e,t){if(e===void 0)return{amount:n,fee:void 0,expirationTime:void 0};let i=Math.floor(t/432e3),o=i<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,r=new be(o.maximumFee.toString()),s=i<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*432e3-t)*400/1e3:void 0,a=qn(n.mul(new be(o.transferFeeBasisPoints)),new be(Et)),c=a.gt(r)?r:a;return{amount:n,fee:c,expirationTime:s}}function Un(n,e,t){if(e===void 0)return{amount:n,fee:void 0,expirationTime:void 0};let i=Math.floor(t/432e3),o=i<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,r=new be(o.maximumFee.toString()),s=i<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*432e3-t)*400/1e3:void 0;if(o.transferFeeBasisPoints===Et){let a=new be(o.maximumFee.toString());return{amount:n.add(a),fee:a,expirationTime:s}}else{let a=qn(n.mul(new be(Et)),new be(Et-o.transferFeeBasisPoints)),c=new be(o.maximumFee.toString()),u=a.sub(n).gt(c)?n.add(c):a,l=qn(u.mul(new be(o.transferFeeBasisPoints)),new be(Et)),m=l.gt(r)?r:l;return{amount:u,fee:m,expirationTime:s}}}import{PublicKey as dl}from"@solana/web3.js";import fl from"bn.js";import Is from"bn.js";var st=new Is(1e6);import{MINT_SIZE as zl,TOKEN_PROGRAM_ID as Hl,getTransferFeeConfig as Yl,unpackMint as Zl}from"@solana/spl-token";var Xn=de("Raydium_accountInfo_util");async function Ot(n,e,t){let{batchRequest:i,commitment:o="confirmed",chunkCount:r=100}=z({batchRequest:!1},t),s=_n(e,r),a=new Array(s.length).fill([]);if(i){let c=s.map(m=>{let d=n._buildArgs([m.map(p=>p.toBase58())],o,