UNPKG

test-raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 136 kB
var $i=Object.defineProperty,er=Object.defineProperties;var tr=Object.getOwnPropertyDescriptors;var Yn=Object.getOwnPropertySymbols;var nr=Object.prototype.hasOwnProperty,ir=Object.prototype.propertyIsEnumerable;var Zn=(i,e,t)=>e in i?$i(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,$=(i,e)=>{for(var t in e||(e={}))nr.call(e,t)&&Zn(i,t,e[t]);if(Yn)for(var t of Yn(e))ir.call(e,t)&&Zn(i,t,e[t]);return i},ie=(i,e)=>er(i,tr(e));import{PublicKey as ab}from"@solana/web3.js";import{createTransferInstruction as lb}from"@solana/spl-token";import{get as jn,set as rr}from"lodash";import $n from"dayjs";import or from"dayjs/plugin/utc";$n.extend(or);var sn=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 $n().utc().format("YYYY/MM/DD HH:mm:ss UTC")}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}},Jn={},sr={};function se(i){let e=jn(Jn,i);if(!e){let t=jn(sr,i);e=new sn({name:i,logLevel:t}),rr(Jn,i,e)}return e}import{PublicKey as ko}from"@solana/web3.js";import wo from"bn.js";import bo from"big.js";import Yt from"bn.js";import Be from"bn.js";var yt=9e15,rt=1e9,an="0123456789abcdef",vt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Dt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",un={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-yt,maxE:yt,crypto:!1},ii,He,O=!0,_t="[DecimalError] ",it=_t+"Invalid argument: ",ri=_t+"Precision limit exceeded",oi=_t+"crypto unavailable",si="[object Decimal]",ge=Math.floor,ce=Math.pow,ar=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ur=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,cr=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ai=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Fe=1e7,C=7,lr=9007199254740991,mr=vt.length-1,cn=Dt.length-1,k={toStringTag:si};k.absoluteValue=k.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),K(i)};k.ceil=function(){return K(new this.constructor(this),this.e+1,2)};k.clampedTo=k.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(it+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new r(n)};k.comparedTo=k.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};k.cosine=k.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())+C,n.rounding=1,t=dr(n,di(n,t)),n.precision=i,n.rounding=e,K(He==2||He==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};k.cubeRoot=k.cbrt=function(){var i,e,t,n,r,o,s,a,u,c,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(O=!1,o=l.s*ce(l.s*l,1/3),!o||Math.abs(o)==1/0?(t=pe(l.d),i=l.e,(o=(i-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=ce(t,1/3),i=ge((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 m(t),n.s=l.s):n=new m(o.toString()),s=(i=m.precision)+3;;)if(a=n,u=a.times(a).times(a),c=u.plus(l),n=j(c.plus(l).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&&(K(a,i+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(K(n,i+1,1),e=!n.times(n).times(n).eq(l));break}return O=!0,K(n,i,m.rounding,e)};k.decimalPlaces=k.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-ge(this.e/C))*C,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};k.dividedBy=k.div=function(i){return j(this,new this.constructor(i))};k.dividedToIntegerBy=k.divToInt=function(i){var e=this,t=e.constructor;return K(j(e,new t(i),0,1,1),t.precision,t.rounding)};k.equals=k.eq=function(i){return this.cmp(i)===0};k.floor=function(){return K(new this.constructor(this),this.e+1,3)};k.greaterThan=k.gt=function(i){return this.cmp(i)>0};k.greaterThanOrEqualTo=k.gte=function(i){var e=this.cmp(i);return e==1||e===0};k.hyperbolicCosine=k.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/Gt(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),o=gt(s,1,o.times(e),new s(1),!0);for(var u,c=i,l=new s(8);c--;)u=o.times(o),o=a.minus(u.times(l.minus(u.times(l))));return K(o,s.precision=t,s.rounding=n,!0)};k.hyperbolicSine=k.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=gt(o,2,r,r,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,r=r.times(1/Gt(5,i)),r=gt(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,K(r,e,t,!0)};k.hyperbolicTangent=k.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,j(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};k.inverseCosine=k.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()?Me(t,r,o):new t(0):new t(NaN):e.isZero()?Me(t,r+4,o).times(.5):(t.precision=r+6,t.rounding=1,e=e.asin(),i=Me(t,r+4,o).times(.5),t.precision=r,t.rounding=o,i.minus(e))};k.inverseHyperbolicCosine=k.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,O=!1,t=t.times(t).minus(1).sqrt().plus(t),O=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};k.inverseHyperbolicSine=k.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,O=!1,t=t.times(t).plus(1).sqrt().plus(t),O=!0,n.precision=i,n.rounding=e,t.ln())};k.inverseHyperbolicTangent=k.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?K(new o(r),i,e,!0):(o.precision=t=n-r.e,r=j(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)};k.inverseSine=k.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=Me(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)))};k.inverseTangent=k.atan=function(){var i,e,t,n,r,o,s,a,u,c=this,l=c.constructor,m=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&m+4<=cn)return s=Me(l,m+4,p).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(m+4<=cn)return s=Me(l,m+4,p).times(.5),s.s=c.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/C+2|0),i=t;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(O=!1,e=Math.ceil(a/C),n=1,u=c.times(c),s=new l(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)),O=!0,K(s,l.precision=m,l.rounding=p,!0)};k.isFinite=function(){return!!this.d};k.isInteger=k.isInt=function(){return!!this.d&&ge(this.e/C)>this.d.length-2};k.isNaN=function(){return!this.s};k.isNegative=k.isNeg=function(){return this.s<0};k.isPositive=k.isPos=function(){return this.s>0};k.isZero=function(){return!!this.d&&this.d[0]===0};k.lessThan=k.lt=function(i){return this.cmp(i)<0};k.lessThanOrEqualTo=k.lte=function(i){return this.cmp(i)<1};k.logarithm=k.log=function(i){var e,t,n,r,o,s,a,u,c=this,l=c.constructor,m=l.precision,p=l.rounding,d=5;if(i==null)i=new l(10),e=!0;else{if(i=new l(i),t=i.d,i.s<0||!t||!t[0]||i.eq(1))return new l(NaN);e=i.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new l(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(O=!1,a=m+d,s=nt(c,a),n=e?Vt(l,a+10):nt(i,a),u=j(s,n,a,1),It(u.d,r=m,p))do if(a+=10,s=nt(c,a),n=e?Vt(l,a+10):nt(i,a),u=j(s,n,a,1),!o){+pe(u.d).slice(r+1,r+15)+1==1e14&&(u=K(u,m+1,0));break}while(It(u.d,r+=10,p));return O=!0,K(u,m,p)};k.minus=k.sub=function(i){var e,t,n,r,o,s,a,u,c,l,m,p,d=this,b=d.constructor;if(i=new b(i),!d.d||!i.d)return!d.s||!i.s?i=new b(NaN):d.d?i.s=-i.s:i=new b(i.d||d.s!==i.s?d:NaN),i;if(d.s!=i.s)return i.s=-i.s,d.plus(i);if(c=d.d,p=i.d,a=b.precision,u=b.rounding,!c[0]||!p[0]){if(p[0])i.s=-i.s;else if(c[0])i=new b(d);else return new b(u===3?-0:0);return O?K(i,a,u):i}if(t=ge(i.e/C),l=ge(d.e/C),c=c.slice(),o=l-t,o){for(m=o<0,m?(e=c,o=-o,s=p.length):(e=p,t=l,s=c.length),n=Math.max(Math.ceil(a/C),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=p.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(c[n]!=p[n]){m=c[n]<p[n];break}o=0}for(m&&(e=c,c=p,p=e,i.s=-i.s),s=c.length,n=p.length-s;n>0;--n)c[s++]=0;for(n=p.length;n>o;){if(c[--n]<p[n]){for(r=n;r&&c[--r]===0;)c[r]=Fe-1;--c[r],c[n]+=Fe}c[n]-=p[n]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(i.d=c,i.e=qt(c,t),O?K(i,a,u):i):new b(u===3?-0:0)};k.modulo=k.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]?K(new n(t),n.precision,n.rounding):(O=!1,n.modulo==9?(e=j(t,i.abs(),0,3,1),e.s*=i.s):e=j(t,i,0,n.modulo,1),e=e.times(i),O=!0,t.minus(e))};k.naturalExponential=k.exp=function(){return ln(this)};k.naturalLogarithm=k.ln=function(){return nt(this)};k.negated=k.neg=function(){var i=new this.constructor(this);return i.s=-i.s,K(i)};k.plus=k.add=function(i){var e,t,n,r,o,s,a,u,c,l,m=this,p=m.constructor;if(i=new p(i),!m.d||!i.d)return!m.s||!i.s?i=new p(NaN):m.d||(i=new p(i.d||m.s===i.s?m:NaN)),i;if(m.s!=i.s)return i.s=-i.s,m.minus(i);if(c=m.d,l=i.d,a=p.precision,u=p.rounding,!c[0]||!l[0])return l[0]||(i=new p(m)),O?K(i,a,u):i;if(o=ge(m.e/C),n=ge(i.e/C),c=c.slice(),r=o-n,r){for(r<0?(t=c,r=-r,s=l.length):(t=l,n=o,s=c.length),o=Math.ceil(a/C),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=l.length,s-r<0&&(r=s,t=l,l=c,c=t),e=0;r;)e=(c[--r]=c[r]+l[r]+e)/Fe|0,c[r]%=Fe;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=qt(c,n),O?K(i,a,u):i};k.precision=k.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(it+i);return t.d?(e=ui(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};k.round=function(){var i=this,e=i.constructor;return K(new e(i),i.e+1,e.rounding)};k.sine=k.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())+C,n.rounding=1,t=fr(n,di(n,t)),n.precision=i,n.rounding=e,K(He>2?t.neg():t,i,e,!0)):new n(NaN)};k.squareRoot=k.sqrt=function(){var i,e,t,n,r,o,s=this,a=s.d,u=s.e,c=s.s,l=s.constructor;if(c!==1||!a||!a[0])return new l(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(O=!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=ge((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 l(e)):n=new l(c.toString()),t=(u=l.precision)+3;;)if(o=n,n=o.plus(j(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&&(K(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")&&(K(n,u+1,1),i=!n.times(n).eq(s));break}return O=!0,K(n,u,l.rounding,i)};k.tangent=k.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=j(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,K(He==2||He==4?t.neg():t,i,e,!0)):new n(NaN)};k.times=k.mul=function(i){var e,t,n,r,o,s,a,u,c,l=this,m=l.constructor,p=l.d,d=(i=new m(i)).d;if(i.s*=l.s,!p||!p[0]||!d||!d[0])return new m(!i.s||p&&!p[0]&&!d||d&&!d[0]&&!p?NaN:!p||!d?i.s/0:i.s*0);for(t=ge(l.e/C)+ge(i.e/C),u=p.length,c=d.length,u<c&&(o=p,p=d,d=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]+d[n]*p[r-n-1]+e,o[r--]=a%Fe|0,e=a/Fe|0;o[r]=(o[r]+e)%Fe|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),i.d=o,i.e=qt(o,t),O?K(i,m.precision,m.rounding):i};k.toBinary=function(i,e){return dn(this,2,i,e)};k.toDecimalPlaces=k.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(Ie(i,0,rt),e===void 0?e=n.rounding:Ie(e,0,8),K(t,i+t.e+1,e))};k.toExponential=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=Ve(n,!0):(Ie(i,0,rt),e===void 0?e=r.rounding:Ie(e,0,8),n=K(new r(n),i+1,e),t=Ve(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};k.toFixed=function(i,e){var t,n,r=this,o=r.constructor;return i===void 0?t=Ve(r):(Ie(i,0,rt),e===void 0?e=o.rounding:Ie(e,0,8),n=K(new o(r),i+r.e+1,e),t=Ve(n,!1,i+n.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};k.toFraction=function(i){var e,t,n,r,o,s,a,u,c,l,m,p,d=this,b=d.d,f=d.constructor;if(!b)return new f(d);if(c=t=new f(1),n=u=new f(0),e=new f(n),o=e.e=ui(b)-d.e-1,s=o%C,e.d[0]=ce(10,s<0?C+s:s),i==null)i=o>0?e:c;else{if(a=new f(i),!a.isInt()||a.lt(c))throw Error(it+a);i=a.gt(e)?o>0?e:c:a}for(O=!1,a=new f(pe(b)),l=f.precision,f.precision=o=b.length*C*2;m=j(a,e,0,1,1),r=t.plus(m.times(n)),r.cmp(i)!=1;)t=n,n=r,r=c,c=u.plus(m.times(r)),u=r,r=e,e=a.minus(m.times(r)),a=r;return r=j(i.minus(t),n,0,1,1),u=u.plus(r.times(c)),t=t.plus(r.times(n)),u.s=c.s=d.s,p=j(c,n,o,1).minus(d).abs().cmp(j(u,t,o,1).minus(d).abs())<1?[c,n]:[u,t],f.precision=l,O=!0,p};k.toHexadecimal=k.toHex=function(i,e){return dn(this,16,i,e)};k.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:Ie(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]?(O=!1,t=j(t,i,0,e,1).times(i),O=!0,K(t)):(i.s=t.s,t=i),t};k.toNumber=function(){return+this};k.toOctal=function(i,e){return dn(this,8,i,e)};k.toPower=k.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(ce(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,o=u.rounding,i.eq(1))return K(a,n,o);if(e=ge(i.e/C),e>=i.d.length-1&&(t=c<0?-c:c)<=lr)return r=ci(u,a,t,n),i.s<0?new u(1).div(r):K(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=ce(+a,c),e=t==0||!isFinite(t)?ge(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):(O=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),r=ln(i.times(nt(a,n+t)),n),r.d&&(r=K(r,n+5,1),It(r.d,n,o)&&(e=n+10,r=K(ln(i.times(nt(a,e+t)),e),e+5,1),+pe(r.d).slice(n+1,n+15)+1==1e14&&(r=K(r,n+1,0)))),r.s=s,O=!0,u.rounding=o,K(r,n,o))};k.toPrecision=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=Ve(n,n.e<=r.toExpNeg||n.e>=r.toExpPos):(Ie(i,1,rt),e===void 0?e=r.rounding:Ie(e,0,8),n=K(new r(n),i,e),t=Ve(n,i<=n.e||n.e<=r.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};k.toSignificantDigits=k.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(Ie(i,1,rt),e===void 0?e=n.rounding:Ie(e,0,8)),K(new n(t),i,e)};k.toString=function(){var i=this,e=i.constructor,t=Ve(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};k.truncated=k.trunc=function(){return K(new this.constructor(this),this.e+1,1)};k.valueOf=k.toJSON=function(){var i=this,e=i.constructor,t=Ve(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=C-n.length,t&&(o+=tt(t)),o+=n;s=i[e],n=s+"",t=C-n.length,t&&(o+=tt(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Ie(i,e,t){if(i!==~~i||i<e||i>t)throw Error(it+i)}function It(i,e,t,n){var r,o,s,a;for(o=i[0];o>=10;o/=10)--e;return--e<0?(e+=C,r=0):(r=Math.ceil((e+1)/C),e%=C),o=ce(10,C-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)==ce(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)==ce(10,e-3)-1,s}function Wt(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]+=an.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 dr(i,e){var t,n,r;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),r=(1/Gt(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),i.precision+=t,e=gt(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 j=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,l,m,p,d,b,f,g,w,P,A,x,h,L,F,_,Z,z,Q,Te,de=n.constructor,xe=n.s==r.s?1:-1,ne=n.d,H=r.d;if(!ne||!ne[0]||!H||!H[0])return new de(!n.s||!r.s||(ne?H&&ne[0]==H[0]:!H)?NaN:ne&&ne[0]==0||!H?xe*0:xe/0);for(u?(d=1,l=n.e-r.e):(u=Fe,d=C,l=ge(n.e/d)-ge(r.e/d)),Q=H.length,Z=ne.length,w=new de(xe),P=w.d=[],m=0;H[m]==(ne[m]||0);m++);if(H[m]>(ne[m]||0)&&l--,o==null?(L=o=de.precision,s=de.rounding):a?L=o+(n.e-r.e)+1:L=o,L<0)P.push(1),b=!0;else{if(L=L/d+2|0,m=0,Q==1){for(p=0,H=H[0],L++;(m<Z||p)&&L--;m++)F=p*u+(ne[m]||0),P[m]=F/H|0,p=F%H|0;b=p||m<Z}else{for(p=u/(H[0]+1)|0,p>1&&(H=i(H,p,u),ne=i(ne,p,u),Q=H.length,Z=ne.length),_=Q,A=ne.slice(0,Q),x=A.length;x<Q;)A[x++]=0;Te=H.slice(),Te.unshift(0),z=H[0],H[1]>=u/2&&++z;do p=0,c=e(H,A,Q,x),c<0?(h=A[0],Q!=x&&(h=h*u+(A[1]||0)),p=h/z|0,p>1?(p>=u&&(p=u-1),f=i(H,p,u),g=f.length,x=A.length,c=e(f,A,g,x),c==1&&(p--,t(f,Q<g?Te:H,g,u))):(p==0&&(c=p=1),f=H.slice()),g=f.length,g<x&&f.unshift(0),t(A,f,x,u),c==-1&&(x=A.length,c=e(H,A,Q,x),c<1&&(p++,t(A,Q<x?Te:H,x,u))),x=A.length):c===0&&(p++,A=[0]),P[m++]=p,c&&A[0]?A[x++]=ne[_]||0:(A=[ne[_]],x=1);while((_++<Z||A[0]!==void 0)&&L--);b=A[0]!==void 0}P[0]||P.shift()}if(d==1)w.e=l,ii=b;else{for(m=1,p=P[0];p>=10;p/=10)m++;w.e=m+l*d-1,K(w,a?o+w.e+1:o,s,b)}return w}}();function K(i,e,t,n){var r,o,s,a,u,c,l,m,p,d=i.constructor;e:if(e!=null){if(m=i.d,!m)return i;for(r=1,a=m[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=C,s=e,l=m[p=0],u=l/ce(10,r-s-1)%10|0;else if(p=Math.ceil((o+1)/C),a=m.length,p>=a)if(n){for(;a++<=p;)m.push(0);l=u=0,r=1,o%=C,s=o-C+1}else break e;else{for(l=a=m[p],r=1;a>=10;a/=10)r++;o%=C,s=o-C+r,u=s<0?0:l/ce(10,r-s-1)%10|0}if(n=n||e<0||m[p+1]!==void 0||(s<0?l:l%ce(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?l/ce(10,r-s):0:m[p-1])%10&1||t==(i.s<0?8:7)),e<1||!m[0])return m.length=0,c?(e-=i.e+1,m[0]=ce(10,(C-e%C)%C),i.e=-e||0):m[0]=i.e=0,i;if(o==0?(m.length=p,a=1,p--):(m.length=p+1,a=ce(10,C-o),m[p]=s>0?(l/ce(10,r-s)%ce(10,s)|0)*a:0),c)for(;;)if(p==0){for(o=1,s=m[0];s>=10;s/=10)o++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(i.e++,m[0]==Fe&&(m[0]=1));break}else{if(m[p]+=a,m[p]!=Fe)break;m[p--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return O&&(i.e>d.maxE?(i.d=null,i.e=NaN):i.e<d.minE&&(i.e=0,i.d=[0])),i}function Ve(i,e,t){if(!i.isFinite())return mi(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)+tt(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i.e<0?"e":"e+")+i.e):r<0?(o="0."+tt(-r-1)+o,t&&(n=t-s)>0&&(o+=tt(n))):r>=s?(o+=tt(r+1-s),t&&(n=t-r-1)>0&&(o=o+"."+tt(n))):((n=r+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),t&&(n=t-s)>0&&(r+1===s&&(o+="."),o+=tt(n))),o}function qt(i,e){var t=i[0];for(e*=C;t>=10;t/=10)e++;return e}function Vt(i,e,t){if(e>mr)throw O=!0,t&&(i.precision=t),Error(ri);return K(new i(vt),e,1,!0)}function Me(i,e,t){if(e>cn)throw Error(ri);return K(new i(Dt),e,t,!0)}function ui(i){var e=i.length-1,t=e*C+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 tt(i){for(var e="";i--;)e+="0";return e}function ci(i,e,t,n){var r,o=new i(1),s=Math.ceil(n/C+4);for(O=!1;;){if(t%2&&(o=o.times(e),ti(o.d,s)&&(r=!0)),t=ge(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),ti(e.d,s)}return O=!0,o}function ei(i){return i.d[i.d.length-1]&1}function li(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 ln(i,e){var t,n,r,o,s,a,u,c=0,l=0,m=0,p=i.constructor,d=p.rounding,b=p.precision;if(!i.d||!i.d[0]||i.e>17)return new p(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:0/0);for(e==null?(O=!1,u=b):u=e,a=new p(.03125);i.e>-2;)i=i.times(a),m+=5;for(n=Math.log(ce(2,m))/Math.LN10*2+5|0,u+=n,t=o=s=new p(1),p.precision=u;;){if(o=K(o.times(i),u,1),t=t.times(++l),a=s.plus(j(o,t,u,1)),pe(a.d).slice(0,u)===pe(s.d).slice(0,u)){for(r=m;r--;)s=K(s.times(s),u,1);if(e==null)if(c<3&&It(s.d,u-n,d,c))p.precision=u+=10,t=o=a=new p(1),l=0,c++;else return K(s,p.precision=b,d,O=!0);else return p.precision=b,s}s=a}}function nt(i,e){var t,n,r,o,s,a,u,c,l,m,p,d=1,b=10,f=i,g=f.d,w=f.constructor,P=w.rounding,A=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?(O=!1,l=A):l=e,w.precision=l+=b,t=pe(g),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),d++;o=f.e,n>1?(f=new w("0."+t),o++):f=new w(n+"."+t.slice(1))}else return c=Vt(w,l+2,A).times(o+""),f=nt(new w(n+"."+t.slice(1)),l-b).plus(c),w.precision=A,e==null?K(f,A,P,O=!0):f;for(m=f,u=s=f=j(f.minus(1),f.plus(1),l,1),p=K(f.times(f),l,1),r=3;;){if(s=K(s.times(p),l,1),c=u.plus(j(s,new w(r),l,1)),pe(c.d).slice(0,l)===pe(u.d).slice(0,l))if(u=u.times(2),o!==0&&(u=u.plus(Vt(w,l+2,A).times(o+""))),u=j(u,new w(d),l,1),e==null)if(It(u.d,l-b,P,a))w.precision=l+=b,c=s=f=j(m.minus(1),m.plus(1),l,1),p=K(f.times(f),l,1),r=a=1;else return K(u,w.precision=A,P,O=!0);else return w.precision=A,u;u=c,r+=2}}function mi(i){return String(i.s*i.s/0)}function mn(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)%C,t<0&&(n+=C),n<r){for(n&&i.d.push(+e.slice(0,n)),r-=C;n<r;)i.d.push(+e.slice(n,n+=C));e=e.slice(n),n=C-e.length}else n-=r;for(;n--;)e+="0";i.d.push(+e),O&&(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 pr(i,e){var t,n,r,o,s,a,u,c,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),ai.test(e))return mn(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(ur.test(e))t=16,e=e.toLowerCase();else if(ar.test(e))t=2;else if(cr.test(e))t=8;else throw Error(it+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=ci(n,new n(t),o,o*2)),c=Wt(e,t,Fe),l=c.length-1,o=l;c[o]===0;--o)c.pop();return o<0?new n(i.s*0):(i.e=qt(c,l),i.d=c,O=!1,s&&(i=j(i,r,a*4)),u&&(i=i.times(Math.abs(u)<54?ce(2,u):Bt.pow(2,u))),O=!0,i)}function fr(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:gt(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Gt(5,t)),e=gt(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 gt(i,e,t,n,r){var o,s,a,u,c=1,l=i.precision,m=Math.ceil(l/C);for(O=!1,u=t.times(t),a=new i(n);;){if(s=j(a.times(u),new i(e++*e++),l,1),a=r?n.plus(s):n.minus(s),n=j(s.times(u),new i(e++*e++),l,1),s=a.plus(n),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=n,n=s,s=o,c++}return O=!0,s.d.length=m+1,s}function Gt(i,e){for(var t=i;--e;)t*=i;return t}function di(i,e){var t,n=e.s<0,r=Me(i,i.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return He=n?4:1,e;if(t=e.divToInt(r),t.isZero())He=n?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return He=ei(t)?n?2:3:n?4:1,e;He=ei(t)?n?1:4:n?3:2}return e.minus(r).abs()}function dn(i,e,t,n){var r,o,s,a,u,c,l,m,p,d=i.constructor,b=t!==void 0;if(b?(Ie(t,1,rt),n===void 0?n=d.rounding:Ie(n,0,8)):(t=d.precision,n=d.rounding),!i.isFinite())l=mi(i);else{for(l=Ve(i),s=l.indexOf("."),b?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(l=l.replace(".",""),p=new d(1),p.e=l.length-s,p.d=Wt(Ve(p),10,r),p.e=p.d.length),m=Wt(l,10,r),o=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=b?"0p+0":"0";else{if(s<0?o--:(i=new d(i),i.d=m,i.e=o,i=j(i,p,t,n,0,r),m=i.d,o=i.e,c=ii),s=m[t],a=r/2,c=c||m[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&&m[t-1]&1||n===(i.s<0?8:7)),m.length=t,c)for(;++m[--t]>r-1;)m[t]=0,t||(++o,m.unshift(1));for(u=m.length;!m[u-1];--u);for(s=0,l="";s<u;s++)l+=an.charAt(m[s]);if(b){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)l+="0";for(m=Wt(l,r,e),u=m.length;!m[u-1];--u);for(s=1,l="1.";s<u;s++)l+=an.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>u)for(o-=u;o--;)l+="0";else o<u&&(l=l.slice(0,o)+"."+l.slice(o))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return i.s<0?"-"+l:l}function ti(i,e){if(i.length>e)return i.length=e,!0}function br(i){return new this(i).abs()}function yr(i){return new this(i).acos()}function gr(i){return new this(i).acosh()}function kr(i,e){return new this(i).plus(e)}function wr(i){return new this(i).asin()}function Ar(i){return new this(i).asinh()}function hr(i){return new this(i).atan()}function Pr(i){return new this(i).atanh()}function Tr(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=Me(this,o,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?Me(this,n,r):new this(0),t.s=i.s):!i.d||e.isZero()?(t=Me(this,o,1).times(.5),t.s=i.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(j(i,e,o,1)),e=Me(this,o,1),this.precision=n,this.rounding=r,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(j(i,e,o,1)),t}function xr(i){return new this(i).cbrt()}function Ir(i){return K(i=new this(i),i.e+1,2)}function Br(i,e,t){return new this(i).clamp(e,t)}function Sr(i){if(!i||typeof i!="object")throw Error(_t+"Object expected");var e,t,n,r=i.defaults===!0,o=["precision",1,rt,"rounding",0,8,"toExpNeg",-yt,0,"toExpPos",0,yt,"maxE",0,yt,"minE",-yt,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],r&&(this[t]=un[t]),(n=i[t])!==void 0)if(ge(n)===n&&n>=o[e+1]&&n<=o[e+2])this[t]=n;else throw Error(it+t+": "+n);if(t="crypto",r&&(this[t]=un[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(oi);else this[t]=!1;else throw Error(it+t+": "+n);return this}function Kr(i){return new this(i).cos()}function Cr(i){return new this(i).cosh()}function pi(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,ni(o)){c.s=o.s,O?!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++;O?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 mn(c,o.toString())}else if(u!=="string")throw Error(it+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),c.s=-1):(a===43&&(o=o.slice(1)),c.s=1),ai.test(o)?mn(c,o):pr(c,o)}if(r.prototype=k,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=Sr,r.clone=pi,r.isDecimal=ni,r.abs=br,r.acos=yr,r.acosh=gr,r.add=kr,r.asin=wr,r.asinh=Ar,r.atan=hr,r.atanh=Pr,r.atan2=Tr,r.cbrt=xr,r.ceil=Ir,r.clamp=Br,r.cos=Kr,r.cosh=Cr,r.div=Nr,r.exp=Lr,r.floor=Rr,r.hypot=Or,r.ln=Mr,r.log=Fr,r.log10=Wr,r.log2=Er,r.max=vr,r.min=Dr,r.mod=Vr,r.mul=_r,r.pow=qr,r.random=Gr,r.round=Ur,r.sign=Xr,r.sin=zr,r.sinh=Qr,r.sqrt=Hr,r.sub=Yr,r.sum=Zr,r.tan=jr,r.tanh=Jr,r.trunc=$r,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 Nr(i,e){return new this(i).div(e)}function Lr(i){return new this(i).exp()}function Rr(i){return K(i=new this(i),i.e+1,3)}function Or(){var i,e,t=new this(0);for(O=!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 O=!0,new this(1/0);t=e}return O=!0,t.sqrt()}function ni(i){return i instanceof Bt||i&&i.toStringTag===si||!1}function Mr(i){return new this(i).ln()}function Fr(i,e){return new this(i).log(e)}function Er(i){return new this(i).log(2)}function Wr(i){return new this(i).log(10)}function vr(){return li(this,arguments,"lt")}function Dr(){return li(this,arguments,"gt")}function Vr(i,e){return new this(i).mod(e)}function _r(i,e){return new this(i).mul(e)}function qr(i,e){return new this(i).pow(e)}function Gr(i){var e,t,n,r,o=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Ie(i,1,rt),n=Math.ceil(i/C),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(oi);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],i%=C,n&&i&&(r=ce(10,C-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-=C)a.shift();for(n=1,r=a[0];r>=10;r/=10)n++;n<C&&(t-=C-n)}return s.e=t,s.d=a,s}function Ur(i){return K(i=new this(i),i.e+1,this.rounding)}function Xr(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function zr(i){return new this(i).sin()}function Qr(i){return new this(i).sinh()}function Hr(i){return new this(i).sqrt()}function Yr(i,e){return new this(i).sub(e)}function Zr(){var i=0,e=arguments,t=new this(e[i]);for(O=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return O=!0,K(t,this.precision,this.rounding)}function jr(i){return new this(i).tan()}function Jr(i){return new this(i).tanh()}function $r(i){return K(i=new this(i),i.e+1,1)}k[Symbol.for("nodejs.util.inspect.custom")]=k.toString;k[Symbol.toStringTag]="Decimal";var Bt=k.constructor=pi(un);vt=new Bt(vt);Dt=new Bt(Dt);var N=Bt;import{PublicKey as bn}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as eo}from"@solana/spl-token";import{PublicKey as re,SystemProgram as to,SYSVAR_RENT_PUBKEY as no}from"@solana/web3.js";function D({pubkey:i,isSigner:e=!1,isWritable:t=!0}){return{pubkey:i,isWritable:t,isSigner:e}}var Cs=[D({pubkey:eo,isWritable:!1}),D({pubkey:to.programId,isWritable:!1}),D({pubkey:no,isWritable:!1})];function pn({publicKey:i,transformSol:e}){let t=fn(i.toString());if(t instanceof re)return e&&t.equals(ot)?kt:t;if(e&&t.toString()===ot.toBase58())return kt;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 fn(i){try{return new re(i)}catch{return i}}var wt=new re("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),At=new re("SysvarRent111111111111111111111111111111111"),Ns=new re("SysvarC1ock11111111111111111111111111111111"),ht=new re("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Ls=new re("Sysvar1nstructions1111111111111111111111111"),Rs=new re("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Os=new re("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Ms=new re("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Fs=new re("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Es=new re("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ws=new re("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),vs=new re("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ds=new re("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Vs=new re("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),_s=new re("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),qs=new re("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),kt=new re("So11111111111111111111111111111111111111112"),ot=re.default;function Ut(i){return pn({publicKey:i,transformSol:!0})}import{PublicKey as io}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as fi}from"@solana/spl-token";var Xt={chainId:101,address:io.default.toBase58(),programId:fi.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},st={chainId:101,address:"So11111111111111111111111111111111111111112",programId:fi.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===ot.toBase58()||e instanceof bn&&ot.equals(e)){this.decimals=st.decimals,this.symbol=st.symbol,this.name=st.name,this.mint=new bn(st.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:pn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Ee=yn;Ee.WSOL=new yn(ie($({},st),{mint:st.address}));import Qt from"big.js";import so from"bn.js";import ao from"decimal.js-light";import ro from"toformat";var oo=ro,St=oo;var zt=se("module/fraction"),gn=St(Qt),Kt=St(ao),uo={[0]:Kt.ROUND_DOWN,[1]:Kt.ROUND_HALF_UP,[2]:Kt.ROUND_UP},co={[0]:Qt.roundDown,[1]:Qt.roundHalfUp,[2]:Qt.roundUp},U=class{constructor(e,t=new so(1)){this.numerator=ee(e),this.denominator=ee(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new U(this.denominator,this.numerator)}add(e){let t=e instanceof U?e:new U(ee(e));return this.denominator.eq(t.denominator)?new U(this.numerator.add(t.numerator),this.denominator):new U(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof U?e:new U(ee(e));return this.denominator.eq(t.denominator)?new U(this.numerator.sub(t.numerator),this.denominator):new U(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof U?e:new U(ee(e));return new U(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof U?e:new U(ee(e));return new U(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||zt.logWithError(`${e} is not an integer.`),e<=0&&zt.logWithError(`${e} is not positive.`),Kt.set({precision:e+1,rounding:uo[n]});let r=new Kt(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)||zt.logWithError(`${e} is not an integer.`),e<0&&zt.logWithError(`${e} is negative.`),gn.DP=e,gn.RM=co[n]||1,new gn(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var mo=se("Raydium_price"),Ne=class extends U{constructor(t){let{baseToken:n,quoteToken:r,numerator:o,denominator:s}=t;super(o,s);this.baseToken=n,this.quoteToken=r,this.scalar=new U(kn(n.decimals),kn(r.decimals))}get raw(){return new U(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&&mo.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 wn=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},Ht=wn;Ht.SOL=new wn(Xt);import po from"bn.js";var bi=new U(new po(100)),Ye=class extends U{toSignificant(e=5,t,n){return this.mul(bi).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(bi).toFixed(e,t,n)}};var An=new Be(0),fo=new Be(1),va=new Be(2),Da=new Be(3),Va=new Be(5),hn=new Be(10),_a=new Be(100),qa=new Be(1e3),Ga=new Be(1e4),yi=9007199254740991;function ee(i){let e=se("Raydium_parseBigNumberish");if(i instanceof Be)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new Be(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=yi||i<=-yi)&&e.logWithError(`BigNumberish number overflow: ${i}`),new Be(String(i))):typeof i=="bigint"?new Be(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new Be(0))}function kn(i){return hn.pow(ee(i))}var yo=se("Raydium_amount"),ki=St(bo);function go(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")):yo.logWithError(`invalid number string, num: ${i}`)}else t=i;return[t,n.slice(0,e)||n]}var fe=class extends U{constructor(t,n,r=!0,o){let s=new Yt(0),a=hn.pow(new Yt(t.decimals));if(r)s=ee(n);else{let u=new Yt(0),c=new Yt(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=go(n.toString(),t.decimals);u=ee(l),c=ee(m)}u=u.mul(a),s=u.add(c)}super(s,a);this.logger=se(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 fe(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new fe(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 ki.DP=this.token.decimals,new ki(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};function gi(i){return typeof i=="object"&&i!==null&&![Ee,fe,ko,U,wo,Ne,Ye].some(e=>typeof e=="object"&&i instanceof e)}function ke(i){return typeof i=="string"?fn(i):Array.isArray(i)?i.map(e=>ke(e)):gi(i)?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,ke(t)])):i}import{PublicKey as ec,sendAndConfirmTransaction as tc,Transaction as ic,TransactionMessage as oc,VersionedTransaction as sc}from"@solana/web3.js";import uc from"axios";var te={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"};import{PublicKey as Ao,ComputeBudgetProgram as ku,Transaction as Au,TransactionMessage as Pu,Keypair as Tu,VersionedTransaction as Iu}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Su}from"@solana/spl-token";var Nu=se("Raydium_txUtil");function Le(i,e){let[t,n]=Ao.findProgramAddressSync(i,e);return{publicKey:t,nonce:n}}import{PublicKey as Po,AddressLookupTableAccount as wi}from"@solana/web3.js";import{PublicKey as ho}from"@solana/web3.js";import{getTransferFeeConfig as Wu,unpackMint as vu}from"@solana/spl-token";var Pn=se("Raydium_accountInfo_util");async function lt(i,e,t){let{batchRequest:n,commitment:r="confirmed"}=$({batchRequest:!1},t),o=Tn(e,100),s=new Array(o.length).fill([]);if(n){let a=o.map(l=>{let m=i._buildArgs([l.map(p=>p.toBase58())],r,"base64");return{methodName:"getMultipleAccounts",args:m}}),u=Tn(a,10);s=(await(await Promise.all(u.map(async l=>await i._rpcBatchRequest(l)))).flat()).map(l=>(l.error&&Pn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${l.error.message}`),l.result.value.map(m=>{if(m){let{data:p,executable:d,lamports:b,owner:f,rentEpoch:g}=m;return p.length!==2&&p[1]!=="base64"&&Pn.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:d,lamports:b,owner:new ho(f),rentEpoch:g}}return null})))}else try{s=await Promise.all(o.map(a=>i.getMultipleAccountsInfo(a,r)))}catch(a){a instanceof Error&&Pn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${a.message}`)}return s.flat()}async function xn(i,e,t){let n=await lt(i,e.map(r=>r.pubkey),t);return e.map((r,o)=>ie($({},r),{accountInfo:n[o]}))}var To={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new wi({key:new Po("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:wi.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 Tn(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 Se}from"@solana/web3.js";var kc=new Se("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),wc=new Se("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Ac=new Se("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),hc=new Se("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Pc=new Se("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Tc=new Se("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),xc=new Se("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Ic=new Se("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Bc=new Se("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),Sc=new Se("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),Kc=new Se("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Cc=new Se("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Nc=new Se("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Lc=new Se("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi");import{PublicKey as Bo}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as So}from"@solana/spl-token";function _e(i,e,t){return Le([i.toBuffer(),(t!=null?t:So).toBuffer(),e.toBuffer()],new Bo("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))}import ae from"bn.js";var qe=1e4;function Ct(i,e,t,n){if(e===void 0)return{amount:i,fee:void 0,expirationTime:void 0};let r=t.epoch<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,o=new ae(r.maximumFee.toString()),s=t.epoch<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*t.slotsInEpoch-t.absoluteSlot)*400/1e3:void 0;if(n)if(r.transferFeeBasisPoints===qe){let a=new ae(r.maximumFee.toString());return{amount:i.add(a),fee:a,expirationTime:s}}else{let a=Pt(i.mul(new ae(qe)),new ae(qe-r.transferFeeBasisPoints)),u=new ae(r.maximumFee.toString()),c=a.sub(i).gt(u)?i.add(u):a,l=Pt(c.mul(new ae(r.transferFeeBasisPoints)),new ae(qe)),m=l.gt(o)?o:l;return{amount:c,fee:m,expirationTime:s}}else{let a=Pt(i.mul(new ae(r.transferFeeBasisPoints)),new ae(qe)),u=a.gt(o)?o:a;return{amount:i,fee:u,expirationTime:s}}}function we(i,e,t,n){if(e===void 0)return{amount:i,fee:void 0,expirationTime:void 0};let r=ie($({},e),{olderTransferFee:{epoch:BigInt(e.olderTransferFee.epoch),maximumFee:BigInt(e.olderTransferFee.maximumFee),transferFeeBasisPoints:e.olderTransferFee.transferFeeBasisPoints},newerTransferFee:{epoch:BigInt(e.newerTransferFee.epoch),maximumFee:BigInt(e.newerTransferFee.maximumFee),transferFeeBasisPoints:e.newerTransferFee.transferFeeBasisPoints}}),o=t.epoch<r.newerTransferFee.epoch?r.olderTransferFee:r.newerTransferFee,s=new ae(o.maximumFee.toString()),a=t.epoch<r.newerTransferFee.epoch?(Number(r.newerTransferFee.epoch)*t.slotsInEpoch-t.absoluteSlot)*400/1e3:void 0;if(n)if(o.transferFeeBasisPoints===qe){let u=new ae(o.maximumFee.toString());return{amount:i.add(u),fee:u,expirationTime:a}}else{let u=Pt(i.mul(new ae(qe)),new ae(qe-o.transferFeeBasisPoints)),c=new ae(o.maximumFee.toString()),l=u.sub(i).gt(c)?i.add(c):u,m=Pt(l.mul(new ae(o.transfe