@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 138 kB
JavaScript
var Yi=Object.defineProperty,Hi=Object.defineProperties;var Zi=Object.getOwnPropertyDescriptors;var Wn=Object.getOwnPropertySymbols;var ji=Object.prototype.hasOwnProperty,Ji=Object.prototype.propertyIsEnumerable;var qn=(i,e,t)=>e in i?Yi(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,j=(i,e)=>{for(var t in e||(e={}))ji.call(e,t)&&qn(i,t,e[t]);if(Wn)for(var t of Wn(e))Ji.call(e,t)&&qn(i,t,e[t]);return i},ee=(i,e)=>Hi(i,Zi(e));import{PublicKey as _g}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Wg,TOKEN_2022_PROGRAM_ID as qg,createTransferInstruction as Gg}from"@solana/spl-token";import{get as Gn,set as $i}from"lodash";var rn=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},Un={},er={};function ie(i){let e=Gn(Un,i);if(!e){let t=Gn(er,i);e=new rn({name:i,logLevel:t}),$i(Un,i,e)}return e}import{PublicKey as lo}from"@solana/web3.js";import po from"bn.js";import uo from"big.js";import zt from"bn.js";import Ke from"bn.js";var bt=9e15,ot=1e9,on="0123456789abcdef",Ft="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",vt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",sn={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-bt,maxE:bt,crypto:!1},Yn,Ze,V=!0,Dt="[DecimalError] ",rt=Dt+"Invalid argument: ",Hn=Dt+"Precision limit exceeded",Zn=Dt+"crypto unavailable",jn="[object Decimal]",he=Math.floor,de=Math.pow,tr=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,nr=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,ir=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Jn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,_e=1e7,_=7,rr=9007199254740991,or=Ft.length-1,an=vt.length-1,P={toStringTag:jn};P.absoluteValue=P.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),M(i)};P.ceil=function(){return M(new this.constructor(this),this.e+1,2)};P.clampedTo=P.clamp=function(i,e){var t,n=this,r=n.constructor;if(i=new r(i),e=new r(e),!i.s||!e.s)return new r(NaN);if(i.gt(e))throw Error(rt+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new r(n)};P.comparedTo=P.cmp=function(i){var e,t,n,r,o=this,s=o.d,a=(i=new o.constructor(i)).d,u=o.s,c=i.s;if(!s||!a)return!u||!c?NaN:u!==c?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-c:0;if(u!==c)return u;if(o.e!==i.e)return o.e>i.e^u<0?1:-1;for(n=s.length,r=a.length,e=0,t=n<r?n:r;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^u<0?1:-1;return n===r?0:n>r^u<0?1:-1};P.cosine=P.cos=function(){var i,e,t=this,n=t.constructor;return t.d?t.d[0]?(i=n.precision,e=n.rounding,n.precision=i+Math.max(t.e,t.sd())+_,n.rounding=1,t=sr(n,ii(n,t)),n.precision=i,n.rounding=e,M(Ze==2||Ze==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};P.cubeRoot=P.cbrt=function(){var i,e,t,n,r,o,s,a,u,c,m=this,l=m.constructor;if(!m.isFinite()||m.isZero())return new l(m);for(V=!1,o=m.s*de(m.s*m,1/3),!o||Math.abs(o)==1/0?(t=Pe(m.d),i=m.e,(o=(i-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=de(t,1/3),i=he((i+1)/3)-(i%3==(i<0?-1:2)),o==1/0?t="5e"+i:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+i),n=new l(t),n.s=m.s):n=new l(o.toString()),s=(i=l.precision)+3;;)if(a=n,u=a.times(a).times(a),c=u.plus(m),n=ne(c.plus(m).times(a),c.plus(u),s+2,1),Pe(a.d).slice(0,s)===(t=Pe(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(M(a,i+1,0),a.times(a).times(a).eq(m))){n=a;break}s+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(M(n,i+1,1),e=!n.times(n).times(n).eq(m));break}return V=!0,M(n,i,l.rounding,e)};P.decimalPlaces=P.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-he(this.e/_))*_,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};P.dividedBy=P.div=function(i){return ne(this,new this.constructor(i))};P.dividedToIntegerBy=P.divToInt=function(i){var e=this,t=e.constructor;return M(ne(e,new t(i),0,1,1),t.precision,t.rounding)};P.equals=P.eq=function(i){return this.cmp(i)===0};P.floor=function(){return M(new this.constructor(this),this.e+1,3)};P.greaterThan=P.gt=function(i){return this.cmp(i)>0};P.greaterThanOrEqualTo=P.gte=function(i){var e=this.cmp(i);return e==1||e===0};P.hyperbolicCosine=P.cosh=function(){var i,e,t,n,r,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;t=s.precision,n=s.rounding,s.precision=t+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(i=Math.ceil(r/3),e=(1/Wt(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),o=yt(s,1,o.times(e),new s(1),!0);for(var u,c=i,m=new s(8);c--;)u=o.times(o),o=a.minus(u.times(m.minus(u.times(m))));return M(o,s.precision=t,s.rounding=n,!0)};P.hyperbolicSine=P.sinh=function(){var i,e,t,n,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,t=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,n=r.d.length,n<3)r=yt(o,2,r,r,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,r=r.times(1/Wt(5,i)),r=yt(o,2,r,r,!0);for(var s,a=new o(5),u=new o(16),c=new o(20);i--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(c))))}return o.precision=e,o.rounding=t,M(r,e,t,!0)};P.hyperbolicTangent=P.tanh=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+7,n.rounding=1,ne(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};P.inverseCosine=P.acos=function(){var i,e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,o=t.rounding;return n!==-1?n===0?e.isNeg()?ve(t,r,o):new t(0):new t(NaN):e.isZero()?ve(t,r+4,o).times(.5):(t.precision=r+6,t.rounding=1,e=e.asin(),i=ve(t,r+4,o).times(.5),t.precision=r,t.rounding=o,i.minus(e))};P.inverseHyperbolicCosine=P.acosh=function(){var i,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(i=n.precision,e=n.rounding,n.precision=i+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,V=!1,t=t.times(t).minus(1).sqrt().plus(t),V=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};P.inverseHyperbolicSine=P.asinh=function(){var i,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,V=!1,t=t.times(t).plus(1).sqrt().plus(t),V=!0,n.precision=i,n.rounding=e,t.ln())};P.inverseHyperbolicTangent=P.atanh=function(){var i,e,t,n,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(i=o.precision,e=o.rounding,n=r.sd(),Math.max(n,i)<2*-r.e-1?M(new o(r),i,e,!0):(o.precision=t=n-r.e,r=ne(r.plus(1),new o(1).minus(r),t+i,1),o.precision=i+4,o.rounding=1,r=r.ln(),o.precision=i,o.rounding=e,r.times(.5))):new o(NaN)};P.inverseSine=P.asin=function(){var i,e,t,n,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),t=o.precision,n=o.rounding,e!==-1?e===0?(i=ve(o,t+4,n).times(.5),i.s=r.s,i):new o(NaN):(o.precision=t+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=t,o.rounding=n,r.times(2)))};P.inverseTangent=P.atan=function(){var i,e,t,n,r,o,s,a,u,c=this,m=c.constructor,l=m.precision,d=m.rounding;if(c.isFinite()){if(c.isZero())return new m(c);if(c.abs().eq(1)&&l+4<=an)return s=ve(m,l+4,d).times(.25),s.s=c.s,s}else{if(!c.s)return new m(NaN);if(l+4<=an)return s=ve(m,l+4,d).times(.5),s.s=c.s,s}for(m.precision=a=l+10,m.rounding=1,t=Math.min(28,a/_+2|0),i=t;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(V=!1,e=Math.ceil(a/_),n=1,u=c.times(c),s=new m(c),r=c;i!==-1;)if(r=r.times(u),o=s.minus(r.div(n+=2)),r=r.times(u),s=o.plus(r.div(n+=2)),s.d[e]!==void 0)for(i=e;s.d[i]===o.d[i]&&i--;);return t&&(s=s.times(2<<t-1)),V=!0,M(s,m.precision=l,m.rounding=d,!0)};P.isFinite=function(){return!!this.d};P.isInteger=P.isInt=function(){return!!this.d&&he(this.e/_)>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(i){return this.cmp(i)<0};P.lessThanOrEqualTo=P.lte=function(i){return this.cmp(i)<1};P.logarithm=P.log=function(i){var e,t,n,r,o,s,a,u,c=this,m=c.constructor,l=m.precision,d=m.rounding,p=5;if(i==null)i=new m(10),e=!0;else{if(i=new m(i),t=i.d,i.s<0||!t||!t[0]||i.eq(1))return new m(NaN);e=i.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new m(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)o=!0;else{for(r=t[0];r%10===0;)r/=10;o=r!==1}if(V=!1,a=l+p,s=it(c,a),n=e?_t(m,a+10):it(i,a),u=ne(s,n,a,1),kt(u.d,r=l,d))do if(a+=10,s=it(c,a),n=e?_t(m,a+10):it(i,a),u=ne(s,n,a,1),!o){+Pe(u.d).slice(r+1,r+15)+1==1e14&&(u=M(u,l+1,0));break}while(kt(u.d,r+=10,d));return V=!0,M(u,l,d)};P.minus=P.sub=function(i){var e,t,n,r,o,s,a,u,c,m,l,d,p=this,g=p.constructor;if(i=new g(i),!p.d||!i.d)return!p.s||!i.s?i=new g(NaN):p.d?i.s=-i.s:i=new g(i.d||p.s!==i.s?p:NaN),i;if(p.s!=i.s)return i.s=-i.s,p.plus(i);if(c=p.d,d=i.d,a=g.precision,u=g.rounding,!c[0]||!d[0]){if(d[0])i.s=-i.s;else if(c[0])i=new g(p);else return new g(u===3?-0:0);return V?M(i,a,u):i}if(t=he(i.e/_),m=he(p.e/_),c=c.slice(),o=m-t,o){for(l=o<0,l?(e=c,o=-o,s=d.length):(e=d,t=m,s=c.length),n=Math.max(Math.ceil(a/_),s)+2,o>n&&(o=n,e.length=1),e.reverse(),n=o;n--;)e.push(0);e.reverse()}else{for(n=c.length,s=d.length,l=n<s,l&&(s=n),n=0;n<s;n++)if(c[n]!=d[n]){l=c[n]<d[n];break}o=0}for(l&&(e=c,c=d,d=e,i.s=-i.s),s=c.length,n=d.length-s;n>0;--n)c[s++]=0;for(n=d.length;n>o;){if(c[--n]<d[n]){for(r=n;r&&c[--r]===0;)c[r]=_e-1;--c[r],c[n]+=_e}c[n]-=d[n]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(i.d=c,i.e=Vt(c,t),V?M(i,a,u):i):new g(u===3?-0:0)};P.modulo=P.mod=function(i){var e,t=this,n=t.constructor;return i=new n(i),!t.d||!i.s||i.d&&!i.d[0]?new n(NaN):!i.d||t.d&&!t.d[0]?M(new n(t),n.precision,n.rounding):(V=!1,n.modulo==9?(e=ne(t,i.abs(),0,3,1),e.s*=i.s):e=ne(t,i,0,n.modulo,1),e=e.times(i),V=!0,t.minus(e))};P.naturalExponential=P.exp=function(){return un(this)};P.naturalLogarithm=P.ln=function(){return it(this)};P.negated=P.neg=function(){var i=new this.constructor(this);return i.s=-i.s,M(i)};P.plus=P.add=function(i){var e,t,n,r,o,s,a,u,c,m,l=this,d=l.constructor;if(i=new d(i),!l.d||!i.d)return!l.s||!i.s?i=new d(NaN):l.d||(i=new d(i.d||l.s===i.s?l:NaN)),i;if(l.s!=i.s)return i.s=-i.s,l.minus(i);if(c=l.d,m=i.d,a=d.precision,u=d.rounding,!c[0]||!m[0])return m[0]||(i=new d(l)),V?M(i,a,u):i;if(o=he(l.e/_),n=he(i.e/_),c=c.slice(),r=o-n,r){for(r<0?(t=c,r=-r,s=m.length):(t=m,n=o,s=c.length),o=Math.ceil(a/_),s=o>s?o+1:s+1,r>s&&(r=s,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for(s=c.length,r=m.length,s-r<0&&(r=s,t=m,m=c,c=t),e=0;r;)e=(c[--r]=c[r]+m[r]+e)/_e|0,c[r]%=_e;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=Vt(c,n),V?M(i,a,u):i};P.precision=P.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(rt+i);return t.d?(e=$n(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};P.round=function(){var i=this,e=i.constructor;return M(new e(i),i.e+1,e.rounding)};P.sine=P.sin=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+Math.max(t.e,t.sd())+_,n.rounding=1,t=ur(n,ii(n,t)),n.precision=i,n.rounding=e,M(Ze>2?t.neg():t,i,e,!0)):new n(NaN)};P.squareRoot=P.sqrt=function(){var i,e,t,n,r,o,s=this,a=s.d,u=s.e,c=s.s,m=s.constructor;if(c!==1||!a||!a[0])return new m(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(V=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=Pe(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=he((u+1)/2)-(u<0||u%2),c==1/0?e="5e"+u:(e=c.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),n=new m(e)):n=new m(c.toString()),t=(u=m.precision)+3;;)if(o=n,n=o.plus(ne(s,o,t+2,1)).times(.5),Pe(o.d).slice(0,t)===(e=Pe(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(M(o,u+1,0),o.times(o).eq(s))){n=o;break}t+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(M(n,u+1,1),i=!n.times(n).eq(s));break}return V=!0,M(n,u,m.rounding,i)};P.tangent=P.tan=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+10,n.rounding=1,t=t.sin(),t.s=1,t=ne(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,M(Ze==2||Ze==4?t.neg():t,i,e,!0)):new n(NaN)};P.times=P.mul=function(i){var e,t,n,r,o,s,a,u,c,m=this,l=m.constructor,d=m.d,p=(i=new l(i)).d;if(i.s*=m.s,!d||!d[0]||!p||!p[0])return new l(!i.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?i.s/0:i.s*0);for(t=he(m.e/_)+he(i.e/_),u=d.length,c=p.length,u<c&&(o=d,d=p,p=o,s=u,u=c,c=s),o=[],s=u+c,n=s;n--;)o.push(0);for(n=c;--n>=0;){for(e=0,r=u+n;r>n;)a=o[r]+p[n]*d[r-n-1]+e,o[r--]=a%_e|0,e=a/_e|0;o[r]=(o[r]+e)%_e|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),i.d=o,i.e=Vt(o,t),V?M(i,l.precision,l.rounding):i};P.toBinary=function(i,e){return mn(this,2,i,e)};P.toDecimalPlaces=P.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(Se(i,0,ot),e===void 0?e=n.rounding:Se(e,0,8),M(t,i+t.e+1,e))};P.toExponential=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=Xe(n,!0):(Se(i,0,ot),e===void 0?e=r.rounding:Se(e,0,8),n=M(new r(n),i+1,e),t=Xe(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};P.toFixed=function(i,e){var t,n,r=this,o=r.constructor;return i===void 0?t=Xe(r):(Se(i,0,ot),e===void 0?e=o.rounding:Se(e,0,8),n=M(new o(r),i+r.e+1,e),t=Xe(n,!1,i+n.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};P.toFraction=function(i){var e,t,n,r,o,s,a,u,c,m,l,d,p=this,g=p.d,f=p.constructor;if(!g)return new f(p);if(c=t=new f(1),n=u=new f(0),e=new f(n),o=e.e=$n(g)-p.e-1,s=o%_,e.d[0]=de(10,s<0?_+s:s),i==null)i=o>0?e:c;else{if(a=new f(i),!a.isInt()||a.lt(c))throw Error(rt+a);i=a.gt(e)?o>0?e:c:a}for(V=!1,a=new f(Pe(g)),m=f.precision,f.precision=o=g.length*_*2;l=ne(a,e,0,1,1),r=t.plus(l.times(n)),r.cmp(i)!=1;)t=n,n=r,r=c,c=u.plus(l.times(r)),u=r,r=e,e=a.minus(l.times(r)),a=r;return r=ne(i.minus(t),n,0,1,1),u=u.plus(r.times(c)),t=t.plus(r.times(n)),u.s=c.s=p.s,d=ne(c,n,o,1).minus(p).abs().cmp(ne(u,t,o,1).minus(p).abs())<1?[c,n]:[u,t],f.precision=m,V=!0,d};P.toHexadecimal=P.toHex=function(i,e){return mn(this,16,i,e)};P.toNearest=function(i,e){var t=this,n=t.constructor;if(t=new n(t),i==null){if(!t.d)return t;i=new n(1),e=n.rounding}else{if(i=new n(i),e===void 0?e=n.rounding:Se(e,0,8),!t.d)return i.s?t:i;if(!i.d)return i.s&&(i.s=t.s),i}return i.d[0]?(V=!1,t=ne(t,i,0,e,1).times(i),V=!0,M(t)):(i.s=t.s,t=i),t};P.toNumber=function(){return+this};P.toOctal=function(i,e){return mn(this,8,i,e)};P.toPower=P.pow=function(i){var e,t,n,r,o,s,a=this,u=a.constructor,c=+(i=new u(i));if(!a.d||!i.d||!a.d[0]||!i.d[0])return new u(de(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,o=u.rounding,i.eq(1))return M(a,n,o);if(e=he(i.e/_),e>=i.d.length-1&&(t=c<0?-c:c)<=rr)return r=ei(u,a,t,n),i.s<0?new u(1).div(r):M(r,n,o);if(s=a.s,s<0){if(e<i.d.length-1)return new u(NaN);if((i.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=de(+a,c),e=t==0||!isFinite(t)?he(c*(Math.log("0."+Pe(a.d))/Math.LN10+a.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?s/0:0):(V=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),r=un(i.times(it(a,n+t)),n),r.d&&(r=M(r,n+5,1),kt(r.d,n,o)&&(e=n+10,r=M(un(i.times(it(a,e+t)),e),e+5,1),+Pe(r.d).slice(n+1,n+15)+1==1e14&&(r=M(r,n+1,0)))),r.s=s,V=!0,u.rounding=o,M(r,n,o))};P.toPrecision=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=Xe(n,n.e<=r.toExpNeg||n.e>=r.toExpPos):(Se(i,1,ot),e===void 0?e=r.rounding:Se(e,0,8),n=M(new r(n),i,e),t=Xe(n,i<=n.e||n.e<=r.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};P.toSignificantDigits=P.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(Se(i,1,ot),e===void 0?e=n.rounding:Se(e,0,8)),M(new n(t),i,e)};P.toString=function(){var i=this,e=i.constructor,t=Xe(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};P.truncated=P.trunc=function(){return M(new this.constructor(this),this.e+1,1)};P.valueOf=P.toJSON=function(){var i=this,e=i.constructor,t=Xe(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function Pe(i){var e,t,n,r=i.length-1,o="",s=i[0];if(r>0){for(o+=s,e=1;e<r;e++)n=i[e]+"",t=_-n.length,t&&(o+=nt(t)),o+=n;s=i[e],n=s+"",t=_-n.length,t&&(o+=nt(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Se(i,e,t){if(i!==~~i||i<e||i>t)throw Error(rt+i)}function kt(i,e,t,n){var r,o,s,a;for(o=i[0];o>=10;o/=10)--e;return--e<0?(e+=_,r=0):(r=Math.ceil((e+1)/_),e%=_),o=de(10,_-e),a=i[r]%o|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==o||t>3&&a+1==o/2)&&(i[r+1]/o/100|0)==de(10,e-2)-1||(a==o/2||a==0)&&(i[r+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(n||t<4)&&a==9999||!n&&t>3&&a==4999):s=((n||t<4)&&a+1==o||!n&&t>3&&a+1==o/2)&&(i[r+1]/o/1e3|0)==de(10,e-3)-1,s}function Et(i,e,t){for(var n,r=[0],o,s=0,a=i.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=on.indexOf(i.charAt(s++)),n=0;n<r.length;n++)r[n]>t-1&&(r[n+1]===void 0&&(r[n+1]=0),r[n+1]+=r[n]/t|0,r[n]%=t)}return r.reverse()}function sr(i,e){var t,n,r;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),r=(1/Wt(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),i.precision+=t,e=yt(i,1,e.times(r),new i(1));for(var o=t;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return i.precision-=t,e}var ne=function(){function i(n,r,o){var s,a=0,u=n.length;for(n=n.slice();u--;)s=n[u]*r+a,n[u]=s%o|0,a=s/o|0;return a&&n.unshift(a),n}function e(n,r,o,s){var a,u;if(o!=s)u=o>s?1:-1;else for(a=u=0;a<o;a++)if(n[a]!=r[a]){u=n[a]>r[a]?1:-1;break}return u}function t(n,r,o,s){for(var a=0;o--;)n[o]-=a,a=n[o]<r[o]?1:0,n[o]=a*s+n[o]-r[o];for(;!n[0]&&n.length>1;)n.shift()}return function(n,r,o,s,a,u){var c,m,l,d,p,g,f,y,A,T,w,C,D,B,E,O,z,h,v,ge,le=n.constructor,xe=n.s==r.s?1:-1,ue=n.d,$=r.d;if(!ue||!ue[0]||!$||!$[0])return new le(!n.s||!r.s||(ue?$&&ue[0]==$[0]:!$)?NaN:ue&&ue[0]==0||!$?xe*0:xe/0);for(u?(p=1,m=n.e-r.e):(u=_e,p=_,m=he(n.e/p)-he(r.e/p)),v=$.length,z=ue.length,A=new le(xe),T=A.d=[],l=0;$[l]==(ue[l]||0);l++);if($[l]>(ue[l]||0)&&m--,o==null?(B=o=le.precision,s=le.rounding):a?B=o+(n.e-r.e)+1:B=o,B<0)T.push(1),g=!0;else{if(B=B/p+2|0,l=0,v==1){for(d=0,$=$[0],B++;(l<z||d)&&B--;l++)E=d*u+(ue[l]||0),T[l]=E/$|0,d=E%$|0;g=d||l<z}else{for(d=u/($[0]+1)|0,d>1&&($=i($,d,u),ue=i(ue,d,u),v=$.length,z=ue.length),O=v,w=ue.slice(0,v),C=w.length;C<v;)w[C++]=0;ge=$.slice(),ge.unshift(0),h=$[0],$[1]>=u/2&&++h;do d=0,c=e($,w,v,C),c<0?(D=w[0],v!=C&&(D=D*u+(w[1]||0)),d=D/h|0,d>1?(d>=u&&(d=u-1),f=i($,d,u),y=f.length,C=w.length,c=e(f,w,y,C),c==1&&(d--,t(f,v<y?ge:$,y,u))):(d==0&&(c=d=1),f=$.slice()),y=f.length,y<C&&f.unshift(0),t(w,f,C,u),c==-1&&(C=w.length,c=e($,w,v,C),c<1&&(d++,t(w,v<C?ge:$,C,u))),C=w.length):c===0&&(d++,w=[0]),T[l++]=d,c&&w[0]?w[C++]=ue[O]||0:(w=[ue[O]],C=1);while((O++<z||w[0]!==void 0)&&B--);g=w[0]!==void 0}T[0]||T.shift()}if(p==1)A.e=m,Yn=g;else{for(l=1,d=T[0];d>=10;d/=10)l++;A.e=l+m*p-1,M(A,a?o+A.e+1:o,s,g)}return A}}();function M(i,e,t,n){var r,o,s,a,u,c,m,l,d,p=i.constructor;e:if(e!=null){if(l=i.d,!l)return i;for(r=1,a=l[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=_,s=e,m=l[d=0],u=m/de(10,r-s-1)%10|0;else if(d=Math.ceil((o+1)/_),a=l.length,d>=a)if(n){for(;a++<=d;)l.push(0);m=u=0,r=1,o%=_,s=o-_+1}else break e;else{for(m=a=l[d],r=1;a>=10;a/=10)r++;o%=_,s=o-_+r,u=s<0?0:m/de(10,r-s-1)%10|0}if(n=n||e<0||l[d+1]!==void 0||(s<0?m:m%de(10,r-s-1)),c=t<4?(u||n)&&(t==0||t==(i.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(o>0?s>0?m/de(10,r-s):0:l[d-1])%10&1||t==(i.s<0?8:7)),e<1||!l[0])return l.length=0,c?(e-=i.e+1,l[0]=de(10,(_-e%_)%_),i.e=-e||0):l[0]=i.e=0,i;if(o==0?(l.length=d,a=1,d--):(l.length=d+1,a=de(10,_-o),l[d]=s>0?(m/de(10,r-s)%de(10,s)|0)*a:0),c)for(;;)if(d==0){for(o=1,s=l[0];s>=10;s/=10)o++;for(s=l[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(i.e++,l[0]==_e&&(l[0]=1));break}else{if(l[d]+=a,l[d]!=_e)break;l[d--]=0,a=1}for(o=l.length;l[--o]===0;)l.pop()}return V&&(i.e>p.maxE?(i.d=null,i.e=NaN):i.e<p.minE&&(i.e=0,i.d=[0])),i}function Xe(i,e,t){if(!i.isFinite())return ni(i);var n,r=i.e,o=Pe(i.d),s=o.length;return e?(t&&(n=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+nt(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i.e<0?"e":"e+")+i.e):r<0?(o="0."+nt(-r-1)+o,t&&(n=t-s)>0&&(o+=nt(n))):r>=s?(o+=nt(r+1-s),t&&(n=t-r-1)>0&&(o=o+"."+nt(n))):((n=r+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),t&&(n=t-s)>0&&(r+1===s&&(o+="."),o+=nt(n))),o}function Vt(i,e){var t=i[0];for(e*=_;t>=10;t/=10)e++;return e}function _t(i,e,t){if(e>or)throw V=!0,t&&(i.precision=t),Error(Hn);return M(new i(Ft),e,1,!0)}function ve(i,e,t){if(e>an)throw Error(Hn);return M(new i(vt),e,t,!0)}function $n(i){var e=i.length-1,t=e*_+1;if(e=i[e],e){for(;e%10==0;e/=10)t--;for(e=i[0];e>=10;e/=10)t++}return t}function nt(i){for(var e="";i--;)e+="0";return e}function ei(i,e,t,n){var r,o=new i(1),s=Math.ceil(n/_+4);for(V=!1;;){if(t%2&&(o=o.times(e),zn(o.d,s)&&(r=!0)),t=he(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),zn(e.d,s)}return V=!0,o}function Xn(i){return i.d[i.d.length-1]&1}function ti(i,e,t){for(var n,r=new i(e[0]),o=0;++o<e.length;)if(n=new i(e[o]),n.s)r[t](n)&&(r=n);else{r=n;break}return r}function un(i,e){var t,n,r,o,s,a,u,c=0,m=0,l=0,d=i.constructor,p=d.rounding,g=d.precision;if(!i.d||!i.d[0]||i.e>17)return new d(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:0/0);for(e==null?(V=!1,u=g):u=e,a=new d(.03125);i.e>-2;)i=i.times(a),l+=5;for(n=Math.log(de(2,l))/Math.LN10*2+5|0,u+=n,t=o=s=new d(1),d.precision=u;;){if(o=M(o.times(i),u,1),t=t.times(++m),a=s.plus(ne(o,t,u,1)),Pe(a.d).slice(0,u)===Pe(s.d).slice(0,u)){for(r=l;r--;)s=M(s.times(s),u,1);if(e==null)if(c<3&&kt(s.d,u-n,p,c))d.precision=u+=10,t=o=a=new d(1),m=0,c++;else return M(s,d.precision=g,p,V=!0);else return d.precision=g,s}s=a}}function it(i,e){var t,n,r,o,s,a,u,c,m,l,d,p=1,g=10,f=i,y=f.d,A=f.constructor,T=A.rounding,w=A.precision;if(f.s<0||!y||!y[0]||!f.e&&y[0]==1&&y.length==1)return new A(y&&!y[0]?-1/0:f.s!=1?NaN:y?0:f);if(e==null?(V=!1,m=w):m=e,A.precision=m+=g,t=Pe(y),n=t.charAt(0),Math.abs(o=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(i),t=Pe(f.d),n=t.charAt(0),p++;o=f.e,n>1?(f=new A("0."+t),o++):f=new A(n+"."+t.slice(1))}else return c=_t(A,m+2,w).times(o+""),f=it(new A(n+"."+t.slice(1)),m-g).plus(c),A.precision=w,e==null?M(f,w,T,V=!0):f;for(l=f,u=s=f=ne(f.minus(1),f.plus(1),m,1),d=M(f.times(f),m,1),r=3;;){if(s=M(s.times(d),m,1),c=u.plus(ne(s,new A(r),m,1)),Pe(c.d).slice(0,m)===Pe(u.d).slice(0,m))if(u=u.times(2),o!==0&&(u=u.plus(_t(A,m+2,w).times(o+""))),u=ne(u,new A(p),m,1),e==null)if(kt(u.d,m-g,T,a))A.precision=m+=g,c=s=f=ne(l.minus(1),l.plus(1),m,1),d=M(f.times(f),m,1),r=a=1;else return M(u,A.precision=w,T,V=!0);else return A.precision=w,u;u=c,r+=2}}function ni(i){return String(i.s*i.s/0)}function cn(i,e){var t,n,r;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(n,r),e){if(r-=n,i.e=t=t-n-1,i.d=[],n=(t+1)%_,t<0&&(n+=_),n<r){for(n&&i.d.push(+e.slice(0,n)),r-=_;n<r;)i.d.push(+e.slice(n,n+=_));e=e.slice(n),n=_-e.length}else n-=r;for(;n--;)e+="0";i.d.push(+e),V&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function ar(i,e){var t,n,r,o,s,a,u,c,m;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Jn.test(e))return cn(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(nr.test(e))t=16,e=e.toLowerCase();else if(tr.test(e))t=2;else if(ir.test(e))t=8;else throw Error(rt+e);for(o=e.search(/p/i),o>0?(u=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,n=i.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=ei(n,new n(t),o,o*2)),c=Et(e,t,_e),m=c.length-1,o=m;c[o]===0;--o)c.pop();return o<0?new n(i.s*0):(i.e=Vt(c,m),i.d=c,V=!1,s&&(i=ne(i,r,a*4)),u&&(i=i.times(Math.abs(u)<54?de(2,u):wt.pow(2,u))),V=!0,i)}function ur(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:yt(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Wt(5,t)),e=yt(i,2,e,e);for(var r,o=new i(5),s=new i(16),a=new i(20);t--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function yt(i,e,t,n,r){var o,s,a,u,c=1,m=i.precision,l=Math.ceil(m/_);for(V=!1,u=t.times(t),a=new i(n);;){if(s=ne(a.times(u),new i(e++*e++),m,1),a=r?n.plus(s):n.minus(s),n=ne(s.times(u),new i(e++*e++),m,1),s=a.plus(n),s.d[l]!==void 0){for(o=l;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=n,n=s,s=o,c++}return V=!0,s.d.length=l+1,s}function Wt(i,e){for(var t=i;--e;)t*=i;return t}function ii(i,e){var t,n=e.s<0,r=ve(i,i.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return Ze=n?4:1,e;if(t=e.divToInt(r),t.isZero())Ze=n?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return Ze=Xn(t)?n?2:3:n?4:1,e;Ze=Xn(t)?n?1:4:n?3:2}return e.minus(r).abs()}function mn(i,e,t,n){var r,o,s,a,u,c,m,l,d,p=i.constructor,g=t!==void 0;if(g?(Se(t,1,ot),n===void 0?n=p.rounding:Se(n,0,8)):(t=p.precision,n=p.rounding),!i.isFinite())m=ni(i);else{for(m=Xe(i),s=m.indexOf("."),g?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(m=m.replace(".",""),d=new p(1),d.e=m.length-s,d.d=Et(Xe(d),10,r),d.e=d.d.length),l=Et(m,10,r),o=u=l.length;l[--u]==0;)l.pop();if(!l[0])m=g?"0p+0":"0";else{if(s<0?o--:(i=new p(i),i.d=l,i.e=o,i=ne(i,d,t,n,0,r),l=i.d,o=i.e,c=Yn),s=l[t],a=r/2,c=c||l[t+1]!==void 0,c=n<4?(s!==void 0||c)&&(n===0||n===(i.s<0?3:2)):s>a||s===a&&(n===4||c||n===6&&l[t-1]&1||n===(i.s<0?8:7)),l.length=t,c)for(;++l[--t]>r-1;)l[t]=0,t||(++o,l.unshift(1));for(u=l.length;!l[u-1];--u);for(s=0,m="";s<u;s++)m+=on.charAt(l[s]);if(g){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)m+="0";for(l=Et(m,r,e),u=l.length;!l[u-1];--u);for(s=1,m="1.";s<u;s++)m+=on.charAt(l[s])}else m=m.charAt(0)+"."+m.slice(1);m=m+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)m="0"+m;m="0."+m}else if(++o>u)for(o-=u;o--;)m+="0";else o<u&&(m=m.slice(0,o)+"."+m.slice(o))}m=(e==16?"0x":e==2?"0b":e==8?"0o":"")+m}return i.s<0?"-"+m:m}function zn(i,e){if(i.length>e)return i.length=e,!0}function cr(i){return new this(i).abs()}function mr(i){return new this(i).acos()}function lr(i){return new this(i).acosh()}function dr(i,e){return new this(i).plus(e)}function pr(i){return new this(i).asin()}function fr(i){return new this(i).asinh()}function br(i){return new this(i).atan()}function yr(i){return new this(i).atanh()}function gr(i,e){i=new this(i),e=new this(e);var t,n=this.precision,r=this.rounding,o=n+4;return!i.s||!e.s?t=new this(NaN):!i.d&&!e.d?(t=ve(this,o,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?ve(this,n,r):new this(0),t.s=i.s):!i.d||e.isZero()?(t=ve(this,o,1).times(.5),t.s=i.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(ne(i,e,o,1)),e=ve(this,o,1),this.precision=n,this.rounding=r,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(ne(i,e,o,1)),t}function Ar(i){return new this(i).cbrt()}function Pr(i){return M(i=new this(i),i.e+1,2)}function kr(i,e,t){return new this(i).clamp(e,t)}function wr(i){if(!i||typeof i!="object")throw Error(Dt+"Object expected");var e,t,n,r=i.defaults===!0,o=["precision",1,ot,"rounding",0,8,"toExpNeg",-bt,0,"toExpPos",0,bt,"maxE",0,bt,"minE",-bt,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],r&&(this[t]=sn[t]),(n=i[t])!==void 0)if(he(n)===n&&n>=o[e+1]&&n<=o[e+2])this[t]=n;else throw Error(rt+t+": "+n);if(t="crypto",r&&(this[t]=sn[t]),(n=i[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Zn);else this[t]=!1;else throw Error(rt+t+": "+n);return this}function hr(i){return new this(i).cos()}function Tr(i){return new this(i).cosh()}function ri(i){var e,t,n;function r(o){var s,a,u,c=this;if(!(c instanceof r))return new r(o);if(c.constructor=r,Qn(o)){c.s=o.s,V?!o.d||o.e>r.maxE?(c.e=NaN,c.d=null):o.e<r.minE?(c.e=0,c.d=[0]):(c.e=o.e,c.d=o.d.slice()):(c.e=o.e,c.d=o.d?o.d.slice():o.d);return}if(u=typeof o,u==="number"){if(o===0){c.s=1/o<0?-1:1,c.e=0,c.d=[0];return}if(o<0?(o=-o,c.s=-1):c.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;V?s>r.maxE?(c.e=NaN,c.d=null):s<r.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[o]):(c.e=s,c.d=[o]);return}else if(o*0!==0){o||(c.s=NaN),c.e=NaN,c.d=null;return}return cn(c,o.toString())}else if(u!=="string")throw Error(rt+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),c.s=-1):(a===43&&(o=o.slice(1)),c.s=1),Jn.test(o)?cn(c,o):ar(c,o)}if(r.prototype=P,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=wr,r.clone=ri,r.isDecimal=Qn,r.abs=cr,r.acos=mr,r.acosh=lr,r.add=dr,r.asin=pr,r.asinh=fr,r.atan=br,r.atanh=yr,r.atan2=gr,r.cbrt=Ar,r.ceil=Pr,r.clamp=kr,r.cos=hr,r.cosh=Tr,r.div=Br,r.exp=Ir,r.floor=xr,r.hypot=Sr,r.ln=Kr,r.log=Cr,r.log10=Rr,r.log2=Nr,r.max=Or,r.min=Lr,r.mod=Mr,r.mul=Er,r.pow=Fr,r.random=vr,r.round=_r,r.sign=Dr,r.sin=Vr,r.sinh=Wr,r.sqrt=qr,r.sub=Gr,r.sum=Ur,r.tan=Xr,r.tanh=zr,r.trunc=Qr,i===void 0&&(i={}),i&&i.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)i.hasOwnProperty(t=n[e++])||(i[t]=this[t]);return r.config(i),r}function Br(i,e){return new this(i).div(e)}function Ir(i){return new this(i).exp()}function xr(i){return M(i=new this(i),i.e+1,3)}function Sr(){var i,e,t=new this(0);for(V=!1,i=0;i<arguments.length;)if(e=new this(arguments[i++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return V=!0,new this(1/0);t=e}return V=!0,t.sqrt()}function Qn(i){return i instanceof wt||i&&i.toStringTag===jn||!1}function Kr(i){return new this(i).ln()}function Cr(i,e){return new this(i).log(e)}function Nr(i){return new this(i).log(2)}function Rr(i){return new this(i).log(10)}function Or(){return ti(this,arguments,"lt")}function Lr(){return ti(this,arguments,"gt")}function Mr(i,e){return new this(i).mod(e)}function Er(i,e){return new this(i).mul(e)}function Fr(i,e){return new this(i).pow(e)}function vr(i){var e,t,n,r,o=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Se(i,1,ot),n=Math.ceil(i/_),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));o<n;)r=e[o],r>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);o<n;)r=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(r%1e7),o+=4);o=n/4}else throw Error(Zn);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],i%=_,n&&i&&(r=de(10,_-i),a[o]=(n/r|0)*r);a[o]===0;o--)a.pop();if(o<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=_)a.shift();for(n=1,r=a[0];r>=10;r/=10)n++;n<_&&(t-=_-n)}return s.e=t,s.d=a,s}function _r(i){return M(i=new this(i),i.e+1,this.rounding)}function Dr(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Vr(i){return new this(i).sin()}function Wr(i){return new this(i).sinh()}function qr(i){return new this(i).sqrt()}function Gr(i,e){return new this(i).sub(e)}function Ur(){var i=0,e=arguments,t=new this(e[i]);for(V=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return V=!0,M(t,this.precision,this.rounding)}function Xr(i){return new this(i).tan()}function zr(i){return new this(i).tanh()}function Qr(i){return M(i=new this(i),i.e+1,1)}P[Symbol.for("nodejs.util.inspect.custom")]=P.toString;P[Symbol.toStringTag]="Decimal";var wt=P.constructor=ri(sn);Ft=new wt(Ft);vt=new wt(vt);var N=wt;import{PublicKey as bn}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Yr}from"@solana/spl-token";import{PublicKey as se,SystemProgram as oi,SYSVAR_RENT_PUBKEY as Hr}from"@solana/web3.js";function k({pubkey:i,isSigner:e=!1,isWritable:t=!0}){return{pubkey:i,isWritable:t,isSigner:e}}var Rs=[k({pubkey:Yr,isWritable:!1}),k({pubkey:oi.programId,isWritable:!1}),k({pubkey:Hr,isWritable:!1})];function ln({publicKey:i,transformSol:e}){let t=dn(i.toString());if(t instanceof se)return e&&t.equals(Tt)?ht:t;if(e&&t.toString()===Tt.toBase58())return ht;if(typeof t=="string"){if(t===se.default.toBase58())return se.default;try{return new se(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function dn(i){try{return new se(i)}catch{return i}}var qt=new se("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),pn=new se("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),ut=new se("SysvarRent111111111111111111111111111111111"),Os=new se("SysvarC1ock11111111111111111111111111111111"),gt=new se("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Ls=new se("Sysvar1nstructions1111111111111111111111111"),Zr=oi.programId,Ms=new se("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Es=new se("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Fs=new se("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),vs=new se("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),_s=new se("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ds=new se("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Vs=new se("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ws=new se("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),qs=new se("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Gs=new se("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Us=new se("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),ht=new se("So11111111111111111111111111111111111111112"),Tt=se.default;function At(i){return ln({publicKey:i,transformSol:!0})}import{PublicKey as jr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as si}from"@solana/spl-token";var fn={chainId:101,address:jr.default.toBase58(),programId:si.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},je={chainId:101,address:"So11111111111111111111111111111111111111112",programId:si.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var yn=class{constructor({mint:e,decimals:t,symbol:n,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===Tt.toBase58()||e instanceof bn&&Tt.equals(e)){this.decimals=je.decimals,this.symbol=je.symbol,this.name=je.name,this.mint=new bn(je.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=n||e.toString().substring(0,6),this.name=r||e.toString().substring(0,6),this.mint=o?bn.default:ln({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},De=yn;De.WSOL=new yn(ee(j({},je),{mint:je.address}));import Ut from"big.js";import eo from"bn.js";import to from"decimal.js-light";import Jr from"toformat";var $r=Jr,Bt=$r;var Gt=ie("module/fraction"),gn=Bt(Ut),It=Bt(to),no={[0]:It.ROUND_DOWN,[1]:It.ROUND_HALF_UP,[2]:It.ROUND_UP},io={[0]:Ut.roundDown,[1]:Ut.roundHalfUp,[2]:Ut.roundUp},J=class{constructor(e,t=new eo(1)){this.numerator=ae(e),this.denominator=ae(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new J(this.denominator,this.numerator)}add(e){let t=e instanceof J?e:new J(ae(e));return this.denominator.eq(t.denominator)?new J(this.numerator.add(t.numerator),this.denominator):new J(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof J?e:new J(ae(e));return this.denominator.eq(t.denominator)?new J(this.numerator.sub(t.numerator),this.denominator):new J(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof J?e:new J(ae(e));return new J(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof J?e:new J(ae(e));return new J(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||Gt.logWithError(`${e} is not an integer.`),e<=0&&Gt.logWithError(`${e} is not positive.`),It.set({precision:e+1,rounding:no[n]});let r=new It(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||Gt.logWithError(`${e} is not an integer.`),e<0&&Gt.logWithError(`${e} is negative.`),gn.DP=e,gn.RM=io[n]||1,new gn(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var oo=ie("Raydium_price"),Ne=class extends J{constructor(t){let{baseToken:n,quoteToken:r,numerator:o,denominator:s}=t;super(o,s);this.baseToken=n,this.quoteToken=r,this.scalar=new J(An(n.decimals),An(r.decimals))}get raw(){return new J(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new Ne({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&oo.logWithError("mul token not equals");let n=super.mul(t);return new Ne({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(t=this.quoteToken.decimals,n,r){return this.adjusted.toSignificant(t,n,r)}toFixed(t=this.quoteToken.decimals,n,r){return this.adjusted.toFixed(t,n,r)}};var Pn=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},Xt=Pn;Xt.SOL=new Pn(fn);import so from"bn.js";var ai=new J(new so(100)),Je=class extends J{toSignificant(e=5,t,n){return this.mul(ai).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(ai).toFixed(e,t,n)}};var ui=new Ke(0),ao=new Ke(1),Va=new Ke(2),Wa=new Ke(3),qa=new Ke(5),kn=new Ke(10),Ga=new Ke(100),Ua=new Ke(1e3),Xa=new Ke(1e4),ci=9007199254740991;function ae(i){let e=ie("Raydium_parseBigNumberish");if(i instanceof Ke)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new Ke(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=ci||i<=-ci)&&e.logWithError(`BigNumberish number overflow: ${i}`),new Ke(String(i))):typeof i=="bigint"?new Ke(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new Ke(0))}function An(i){return kn.pow(ae(i))}var co=ie("Raydium_amount"),li=Bt(uo);function mo(i,e){let t="0",n="0";if(i.includes(".")){let r=i.split(".");r.length===2?([t,n]=r,n=n.padEnd(e,"0")):co.logWithError(`invalid number string, num: ${i}`)}else t=i;return[t,n.slice(0,e)||n]}var pe=class extends J{constructor(t,n,r=!0,o){let s=new zt(0),a=kn.pow(new zt(t.decimals));if(r)s=ae(n);else{let u=new zt(0),c=new zt(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[m,l]=mo(n.toString(),t.decimals);u=ae(m),c=ae(l)}u=u.mul(a),s=u.add(c)}super(s,a);this.logger=ie(o||"TokenAmount"),this.token=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.token.equals(t.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(t.raw)}lt(t){return this.token.equals(t.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(t.raw)}add(t){return this.token.equals(t.token)||this.logger.logWithError("add token not equals"),new pe(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new pe(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,n,r=0){return super.toSignificant(t,n,r)}toFixed(t=this.token.decimals,n,r=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,r)}toExact(t={groupSeparator:""}){return li.DP=this.token.decimals,new li(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};function mi(i){return typeof i=="object"&&i!==null&&![De,pe,lo,J,po,Ne,Je].some(e=>typeof e=="object"&&i instanceof e)}function Re(i){return typeof i=="string"?dn(i):Array.isArray(i)?i.map(e=>Re(e)):mi(i)?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,Re(t)])):i}import{PublicKey as oc,sendAndConfirmTransaction as sc,Transaction as uc,TransactionMessage as mc,VersionedTransaction as lc}from"@solana/web3.js";import fc from"axios";var re={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut"};import{PublicKey as fo,ComputeBudgetProgram as ku,Transaction as hu,TransactionMessage as Bu,Keypair as Iu,VersionedTransaction as Su}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Nu}from"@solana/spl-token";var Lu=ie("Raydium_txUtil");function Be(i,e){let[t,n]=fo.findProgramAddressSync(i,e);return{publicKey:t,nonce:n}}import{PublicKey as yo,AddressLookupTableAccount as di}from"@solana/web3.js";import{PublicKey as bo}from"@solana/web3.js";import{MINT_SIZE as Vu,TOKEN_PROGRAM_ID as Wu,getTransferFeeConfig as qu,unpackMint as Gu}from"@solana/spl-token";var wn=ie("Raydium_accountInfo_util");async function st(i,e,t){let{batchRequest:n,commitment:r="confirmed",chunkCount:o=100}=j({batchRequest:!1},t),s=hn(e,o),a=new Array(s.length).fill([]);if(n){let u=s.map(l=>{let d=i._buildArgs([l.map(p=>p.toBase58())],r,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=hn(u,10);a=(await(await Promise.all(c.map(async l=>await i._rpcBatchRequest(l)))).flat()).map(l=>(l.error&&wn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${l.error.message}`),l.result.value.map(d=>{if(d){let{data:p,executable:g,lamports:f,owner:y,rentEpoch:A}=d;return p.length!==2&&p[1]!=="base64"&&wn.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:g,lamports:f,owner:new bo(y),rentEpoch:A}}return null})))}else try{a=await Promise.all(s.map(u=>i.getMultipleAccountsInfo(u,r)))}catch(u){u instanceof Error&&wn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return a.flat()}async function xt(i,e,t){let n=await st(i,e.map(r=>r.pubkey),t);return e.map((r,o)=>ee(j({},r),{accountInfo:n[o]}))}var go={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new di({key:new yo("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:di.deserialize(Buffer.from("AQAAAP//////////d49+DAAAAAAAAQZMWvw7GUNJdaccNBVnb57OKakxL2BHLYvhRwVILRsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkG3fbh7nWP3hhCXbzkbM3athr8TYO5DSf+vfko2KGL/AVKU1D4XciC1hSlVnJ4iilt3x6rq9CmBniISTL07vagBqfVFxksXFEhjMlMPUrxf1ja7gibof1E49vZigAAAAAGp9UXGMd0yShWY5hpHV62i164o5tLbVxzVVshAAAAAIyXJY9OJInxuz0QKRSODYMLWhOZ2v8QhASOe9jb6fhZC3BlsePRfEU4nVJ/awTDzVi4bHMaoP21SbbRvAP4KUbIScv+6Yw2LHF/6K0ZjUPibbSWXCirYPGuuVl7zT789IUPLW4CpHr4JNCatp3ELXDLKMv6JJ+37le50lbBJ2LvDQdRqCgtphMF/imcN7mY5YRx2xE1A3MQ+L4QRaYK9u4GRfZP3LsAd00a+IkCpA22UNQMKdq5BFbJuwuOLqc8zxCTDlqxBG8J0HcxtfogQHDK06ukzfaXiNDKAob1MqBHS9lJxDYCwz8gd5DtFqNSTKG5l1zxIaKpDP/sffi2is1H9aKveyXSu5StXElYRl9SD5As0DHE4N0GLnf84/siiKXVyp4Ez121kLcUui/jLLFZEz/BwZK3Ilf9B9OcsEAeDMKAy2vjGSxQODgBz0QwGA+eP4ZjIjrIAQaXENv31QfLlOdXSRCkaybRniDHF4C8YcwhcvsqrOVuTP4B2Na+9wLdtrB31uz2rtlFI5kahdsnp/d1SrASDInYCtTYtdoke4kX+hoKWcEWM4Tle8pTUkUVv4BxS6fje/EzKBE4Qu9N9LMnrw/JNO0hqMVB4rk/2ou4AB1loQ7FZoPwut2o4KZB+0p9xnbrQKw038qjpHar+PyDwvxBRcu5hpHw3dguezeWv+IwvgW5icu8EGkhGa9AkFPPJT7VMSFb8xowveU=","base64"))})};function hn(i,e=1,t=[]){let n=[...i];if(e<=0)return t;for(;n.length;)t.push(n.splice(0,e));return t}import{PublicKey as Y}from"@solana/web3.js";var Bc=new Y("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),Ic=new Y("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),xc=new Y("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Sc=new Y("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Kc=new Y("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),fi=new Y("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Po=new Y("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Cc=new Y("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),bi=new Y("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),ko=new Y("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),Nc=new Y("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),Rc=new Y("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),Oc=new Y("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Lc=new Y("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Mc=new Y("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Ec=new Y("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),wo=new Y("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Fc=new Y("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),vc=new Y("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),ho=new Y("CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"),To=new Y("7rQ1QFNosMkUCuh7Z7fPbTHvh73b68sQYdirycEzJVuw"),Bo=new Y("G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2");var _c={SERUM_MARKET:Y.default,OPENBOOK_MARKET:new Y("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),UTIL1216:Y.default,FarmV3:new Y("85BFyr98MbCUU9MVTEgzx1nbhWACbJqLzho6zd6DZcWL"),FarmV5:new Y("EcLzTrNg9V7qhcdyXDe2qjtPkiGzDM2UbdRaeaadU5r2"),FarmV6:new Y("Farm2hJLcqPtPg8M4rR6DMrsRNc5TPm5Cs4bVQrMe2T7"),AmmV4:new Y("HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8"),AmmStable:new Y("DDg4VmQaJV9ogWce7LpcjBA9bv22wRp5uaTPa5pGjijF"),CLMM:new Y("devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH"),Router:new Y("BVChZ3XFEwTMUk1o9i3HAf91H6mFxSwa5X2wFAWhYPhU"),CREATE_CPMM_POOL_PROGRAM:ho,CREATE_CPMM_POOL_AUTH:To,CREATE_CPMM_POOL_FEE_ACC:Bo,FEE_DESTINATION_ID:new Y("3XMrhbv989VxAMi3DErLV9eJht1pHppW5LbKxe9fkEFR")};import{PublicKey as Io}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as xo}from"@solana/spl-token";function ze(i,e,t){return Be([i.toBuffer(),(t!=null?t:xo).toBuffer(),e.toBuffer()],new Io("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))}import Ve from"bn.js";var St=1e4;function ce(i,e,t,n){if(e===void 0)return{amount:i,fee:void 0,expirationTime:void 0};let r=ee(j({},e),{olderTransferFee:{epoch:BigInt(e.olderTransferFee.epoch),maximumFee:BigInt(e.olderTransferFee.maximumFee),transferFeeBasisPoints:e.olderTransferFee.transferFeeBasisPoints},newerTransferFee:{epoch:BigInt(e.newerTr