UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 78.4 kB
var zn=Object.defineProperty,Zn=Object.defineProperties;var jn=Object.getOwnPropertyDescriptors;var Xt=Object.getOwnPropertySymbols;var Qn=Object.prototype.hasOwnProperty,Yn=Object.prototype.propertyIsEnumerable;var Ht=(t,e,n)=>e in t?zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,W=(t,e)=>{for(var n in e||(e={}))Qn.call(e,n)&&Ht(t,n,e[n]);if(Xt)for(var n of Xt(e))Yn.call(e,n)&&Ht(t,n,e[n]);return t},q=(t,e)=>Zn(t,jn(e));import{SystemProgram as Xe,TransactionInstruction as oe}from"@solana/web3.js";import{ASSOCIATED_TOKEN_PROGRAM_ID as Xn}from"@solana/spl-token";import mt from"bn.js";import{PublicKey as ui}from"@solana/web3.js";import Jt,{isBN as $t}from"bn.js";import{bits as Bo,BitStructure as xo,blob as Jn,Blob as Io,cstr as So,f32 as Co,f32be as Ko,f64 as No,f64be as Lo,greedy as Ro,Layout as $n,ns64 as Fo,ns64be as Mo,nu64 as vo,nu64be as Eo,offset as ei,s16 as Oo,s16be as Do,s24 as Wo,s24be as Vo,s32 as ti,s32be as _o,s40 as qo,s40be as Uo,s48 as Go,s48be as Xo,s8 as Ho,seq as ni,struct as zo,Structure as ii,u16 as ri,u16be as Zo,u24 as jo,u24be as Qo,u32 as oi,u32be as Yo,u40 as Jo,u40be as $o,u48 as es,u48be as ts,u8 as si,UInt as ai,union as ns,Union as is,unionLayoutDiscriminator as rs,utf8 as os}from"@solana/buffer-layout";var gt=$n,zt=ii;var yt=ai;var Zt=si,xe=ri;var jt=oi;var ce=ti;var Qt=ni;var j=Jn;var Yt=ei;var Se=class extends gt{constructor(n,i,r){super(n,r);this.blob=j(n),this.signed=i}decode(n,i=0){let r=new Jt(this.blob.decode(n,i),10,"le");return this.signed?r.fromTwos(this.span*8).clone():r}encode(n,i,r=0){return typeof n=="number"&&(n=new Jt(n)),this.signed&&(n=n.toTwos(this.span*8)),this.blob.encode(n.toArrayLike(Buffer,"le",this.span),i,r)}};function N(t){return new yt(1,t)}function Ke(t){return new yt(4,t)}function p(t){return new Se(8,!1,t)}function O(t){return new Se(16,!1,t)}function en(t){return new Se(8,!0,t)}function tn(t){return new Se(16,!0,t)}var Ce=class extends gt{constructor(n,i,r,o){super(n.span,o);this.layout=n,this.decoder=i,this.encoder=r}decode(n,i){return this.decoder(this.layout.decode(n,i))}encode(n,i,r){return this.layout.encode(this.encoder(n),i,r)}getSpan(n,i){return this.layout.getSpan(n,i)}};function h(t){return new Ce(j(32),e=>new ui(e),e=>e.toBuffer(),t)}function At(t){return new Ce(Zt(),ci,li,t)}function ci(t){if(t===0)return!1;if(t===1)return!0;throw new Error("Invalid bool: "+t)}function li(t){return t?1:0}function mi(t){let e=jt("length"),n=C([e,j(Yt(e,-e.span),"data")]);return new Ce(n,({data:i})=>i,i=>({data:i}),t)}function ge(t){return new Ce(mi(),e=>e.toString("utf-8"),e=>Buffer.from(e,"utf-8"),t)}var Pt=class extends zt{decode(e,n){return super.decode(e,n)}};function C(t,e,n){return new Pt(t,e,n)}function F(t,e,n){let i,r=typeof e=="number"?e:$t(e)?e.toNumber():new Proxy(e,{get(o,s){if(!i){let a=Reflect.get(o,"count");i=$t(a)?a.toNumber():a,Reflect.set(o,"count",i)}return Reflect.get(o,s)},set(o,s,a){return s==="count"&&(i=a),Reflect.set(o,s,a)}});return Qt(t,r,n)}import{PublicKey as hs}from"@solana/web3.js";import{get as nn,set as di}from"lodash";var wt=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 n=e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(", ");throw new Error(n)}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}},rn={},pi={};function H(t){let e=nn(rn,t);if(!e){let n=nn(pi,t);e=new wt({name:t,logLevel:n}),di(rn,t,e)}return e}import{MINT_SIZE as Is,TOKEN_PROGRAM_ID as Ss,getTransferFeeConfig as Cs,unpackMint as Ks}from"@solana/spl-token";var Ns=H("Raydium_accountInfo_util");import re from"bn.js";var Ne=9e15,we=1e9,kt="0123456789abcdef",Ye="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Je="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ht={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Ne,maxE:Ne,crypto:!1},cn,le,B=!0,et="[DecimalError] ",Ae=et+"Invalid argument: ",ln=et+"Precision limit exceeded",mn=et+"crypto unavailable",dn="[object Decimal]",X=Math.floor,V=Math.pow,fi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,bi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,gi=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,pn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,te=1e7,k=7,yi=9007199254740991,Pi=Ye.length-1,Tt=Je.length-1,f={toStringTag:dn};f.absoluteValue=f.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),w(t)};f.ceil=function(){return w(new this.constructor(this),this.e+1,2)};f.clampedTo=f.clamp=function(t,e){var n,i=this,r=i.constructor;if(t=new r(t),e=new r(e),!t.s||!e.s)return new r(NaN);if(t.gt(e))throw Error(Ae+e);return n=i.cmp(t),n<0?t:i.cmp(e)>0?e:new r(i)};f.comparedTo=f.cmp=function(t){var e,n,i,r,o=this,s=o.d,a=(t=new o.constructor(t)).d,c=o.s,u=t.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(o.e!==t.e)return o.e>t.e^c<0?1:-1;for(i=s.length,r=a.length,e=0,n=i<r?i:r;e<n;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return i===r?0:i>r^c<0?1:-1};f.cosine=f.cos=function(){var t,e,n=this,i=n.constructor;return n.d?n.d[0]?(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+k,i.rounding=1,n=Ai(i,Pn(i,n)),i.precision=t,i.rounding=e,w(le==2||le==3?n.neg():n,t,e,!0)):new i(1):new i(NaN)};f.cubeRoot=f.cbrt=function(){var t,e,n,i,r,o,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(B=!1,o=l.s*V(l.s*l,1/3),!o||Math.abs(o)==1/0?(n=U(l.d),t=l.e,(o=(t-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=V(n,1/3),t=X((t+1)/3)-(t%3==(t<0?-1:2)),o==1/0?n="5e"+t:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),i=new m(n),i.s=l.s):i=new m(o.toString()),s=(t=m.precision)+3;;)if(a=i,c=a.times(a).times(a),u=c.plus(l),i=M(u.plus(l).times(a),u.plus(c),s+2,1),U(a.d).slice(0,s)===(n=U(i.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!r&&n=="4999"){if(!r&&(w(a,t+1,0),a.times(a).times(a).eq(l))){i=a;break}s+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(w(i,t+1,1),e=!i.times(i).times(i).eq(l));break}return B=!0,w(i,t,m.rounding,e)};f.decimalPlaces=f.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-X(this.e/k))*k,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};f.dividedBy=f.div=function(t){return M(this,new this.constructor(t))};f.dividedToIntegerBy=f.divToInt=function(t){var e=this,n=e.constructor;return w(M(e,new n(t),0,1,1),n.precision,n.rounding)};f.equals=f.eq=function(t){return this.cmp(t)===0};f.floor=function(){return w(new this.constructor(this),this.e+1,3)};f.greaterThan=f.gt=function(t){return this.cmp(t)>0};f.greaterThanOrEqualTo=f.gte=function(t){var e=this.cmp(t);return e==1||e===0};f.hyperbolicCosine=f.cosh=function(){var t,e,n,i,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;n=s.precision,i=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(t=Math.ceil(r/3),e=(1/nt(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=Le(s,1,o.times(e),new s(1),!0);for(var c,u=t,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return w(o,s.precision=n,s.rounding=i,!0)};f.hyperbolicSine=f.sinh=function(){var t,e,n,i,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,n=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,i=r.d.length,i<3)r=Le(o,2,r,r,!0);else{t=1.4*Math.sqrt(i),t=t>16?16:t|0,r=r.times(1/nt(5,t)),r=Le(o,2,r,r,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);t--;)s=r.times(r),r=r.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=e,o.rounding=n,w(r,e,n,!0)};f.hyperbolicTangent=f.tanh=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+7,i.rounding=1,M(n.sinh(),n.cosh(),i.precision=t,i.rounding=e)):new i(n.s)};f.inverseCosine=f.acos=function(){var t,e=this,n=e.constructor,i=e.abs().cmp(1),r=n.precision,o=n.rounding;return i!==-1?i===0?e.isNeg()?ee(n,r,o):new n(0):new n(NaN):e.isZero()?ee(n,r+4,o).times(.5):(n.precision=r+6,n.rounding=1,e=e.asin(),t=ee(n,r+4,o).times(.5),n.precision=r,n.rounding=o,t.minus(e))};f.inverseHyperbolicCosine=f.acosh=function(){var t,e,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(t=i.precision,e=i.rounding,i.precision=t+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,B=!1,n=n.times(n).minus(1).sqrt().plus(n),B=!0,i.precision=t,i.rounding=e,n.ln()):new i(n)};f.inverseHyperbolicSine=f.asinh=function(){var t,e,n=this,i=n.constructor;return!n.isFinite()||n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,B=!1,n=n.times(n).plus(1).sqrt().plus(n),B=!0,i.precision=t,i.rounding=e,n.ln())};f.inverseHyperbolicTangent=f.atanh=function(){var t,e,n,i,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(t=o.precision,e=o.rounding,i=r.sd(),Math.max(i,t)<2*-r.e-1?w(new o(r),t,e,!0):(o.precision=n=i-r.e,r=M(r.plus(1),new o(1).minus(r),n+t,1),o.precision=t+4,o.rounding=1,r=r.ln(),o.precision=t,o.rounding=e,r.times(.5))):new o(NaN)};f.inverseSine=f.asin=function(){var t,e,n,i,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),n=o.precision,i=o.rounding,e!==-1?e===0?(t=ee(o,n+4,i).times(.5),t.s=r.s,t):new o(NaN):(o.precision=n+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=i,r.times(2)))};f.inverseTangent=f.atan=function(){var t,e,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=Tt)return s=ee(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=Tt)return s=ee(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,n=Math.min(28,a/k+2|0),t=n;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(B=!1,e=Math.ceil(a/k),i=1,c=u.times(u),s=new l(u),r=u;t!==-1;)if(r=r.times(c),o=s.minus(r.div(i+=2)),r=r.times(c),s=o.plus(r.div(i+=2)),s.d[e]!==void 0)for(t=e;s.d[t]===o.d[t]&&t--;);return n&&(s=s.times(2<<n-1)),B=!0,w(s,l.precision=m,l.rounding=d,!0)};f.isFinite=function(){return!!this.d};f.isInteger=f.isInt=function(){return!!this.d&&X(this.e/k)>this.d.length-2};f.isNaN=function(){return!this.s};f.isNegative=f.isNeg=function(){return this.s<0};f.isPositive=f.isPos=function(){return this.s>0};f.isZero=function(){return!!this.d&&this.d[0]===0};f.lessThan=f.lt=function(t){return this.cmp(t)<0};f.lessThanOrEqualTo=f.lte=function(t){return this.cmp(t)<1};f.logarithm=f.log=function(t){var e,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,b=5;if(t==null)t=new l(10),e=!0;else{if(t=new l(t),n=t.d,t.s<0||!n||!n[0]||t.eq(1))return new l(NaN);e=t.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new l(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(e)if(n.length>1)o=!0;else{for(r=n[0];r%10===0;)r/=10;o=r!==1}if(B=!1,a=m+b,s=Pe(u,a),i=e?$e(l,a+10):Pe(t,a),c=M(s,i,a,1),Ee(c.d,r=m,d))do if(a+=10,s=Pe(u,a),i=e?$e(l,a+10):Pe(t,a),c=M(s,i,a,1),!o){+U(c.d).slice(r+1,r+15)+1==1e14&&(c=w(c,m+1,0));break}while(Ee(c.d,r+=10,d));return B=!0,w(c,m,d)};f.minus=f.sub=function(t){var e,n,i,r,o,s,a,c,u,l,m,d,b=this,y=b.constructor;if(t=new y(t),!b.d||!t.d)return!b.s||!t.s?t=new y(NaN):b.d?t.s=-t.s:t=new y(t.d||b.s!==t.s?b:NaN),t;if(b.s!=t.s)return t.s=-t.s,b.plus(t);if(u=b.d,d=t.d,a=y.precision,c=y.rounding,!u[0]||!d[0]){if(d[0])t.s=-t.s;else if(u[0])t=new y(b);else return new y(c===3?-0:0);return B?w(t,a,c):t}if(n=X(t.e/k),l=X(b.e/k),u=u.slice(),o=l-n,o){for(m=o<0,m?(e=u,o=-o,s=d.length):(e=d,n=l,s=u.length),i=Math.max(Math.ceil(a/k),s)+2,o>i&&(o=i,e.length=1),e.reverse(),i=o;i--;)e.push(0);e.reverse()}else{for(i=u.length,s=d.length,m=i<s,m&&(s=i),i=0;i<s;i++)if(u[i]!=d[i]){m=u[i]<d[i];break}o=0}for(m&&(e=u,u=d,d=e,t.s=-t.s),s=u.length,i=d.length-s;i>0;--i)u[s++]=0;for(i=d.length;i>o;){if(u[--i]<d[i]){for(r=i;r&&u[--r]===0;)u[r]=te-1;--u[r],u[i]+=te}u[i]-=d[i]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(t.d=u,t.e=tt(u,n),B?w(t,a,c):t):new y(c===3?-0:0)};f.modulo=f.mod=function(t){var e,n=this,i=n.constructor;return t=new i(t),!n.d||!t.s||t.d&&!t.d[0]?new i(NaN):!t.d||n.d&&!n.d[0]?w(new i(n),i.precision,i.rounding):(B=!1,i.modulo==9?(e=M(n,t.abs(),0,3,1),e.s*=t.s):e=M(n,t,0,i.modulo,1),e=e.times(t),B=!0,n.minus(e))};f.naturalExponential=f.exp=function(){return Bt(this)};f.naturalLogarithm=f.ln=function(){return Pe(this)};f.negated=f.neg=function(){var t=new this.constructor(this);return t.s=-t.s,w(t)};f.plus=f.add=function(t){var e,n,i,r,o,s,a,c,u,l,m=this,d=m.constructor;if(t=new d(t),!m.d||!t.d)return!m.s||!t.s?t=new d(NaN):m.d||(t=new d(t.d||m.s===t.s?m:NaN)),t;if(m.s!=t.s)return t.s=-t.s,m.minus(t);if(u=m.d,l=t.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(t=new d(m)),B?w(t,a,c):t;if(o=X(m.e/k),i=X(t.e/k),u=u.slice(),r=o-i,r){for(r<0?(n=u,r=-r,s=l.length):(n=l,i=o,s=u.length),o=Math.ceil(a/k),s=o>s?o+1:s+1,r>s&&(r=s,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for(s=u.length,r=l.length,s-r<0&&(r=s,n=l,l=u,u=n),e=0;r;)e=(u[--r]=u[r]+l[r]+e)/te|0,u[r]%=te;for(e&&(u.unshift(e),++i),s=u.length;u[--s]==0;)u.pop();return t.d=u,t.e=tt(u,i),B?w(t,a,c):t};f.precision=f.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Ae+t);return n.d?(e=fn(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};f.round=function(){var t=this,e=t.constructor;return w(new e(t),t.e+1,e.rounding)};f.sine=f.sin=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+k,i.rounding=1,n=ki(i,Pn(i,n)),i.precision=t,i.rounding=e,w(le>2?n.neg():n,t,e,!0)):new i(NaN)};f.squareRoot=f.sqrt=function(){var t,e,n,i,r,o,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(B=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=U(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=X((c+1)/2)-(c<0||c%2),u==1/0?e="5e"+c:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),i=new l(e)):i=new l(u.toString()),n=(c=l.precision)+3;;)if(o=i,i=o.plus(M(s,o,n+2,1)).times(.5),U(o.d).slice(0,n)===(e=U(i.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!r&&e=="4999"){if(!r&&(w(o,c+1,0),o.times(o).eq(s))){i=o;break}n+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(w(i,c+1,1),t=!i.times(i).eq(s));break}return B=!0,w(i,c,l.rounding,t)};f.tangent=f.tan=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+10,i.rounding=1,n=n.sin(),n.s=1,n=M(n,new i(1).minus(n.times(n)).sqrt(),t+10,0),i.precision=t,i.rounding=e,w(le==2||le==4?n.neg():n,t,e,!0)):new i(NaN)};f.times=f.mul=function(t){var e,n,i,r,o,s,a,c,u,l=this,m=l.constructor,d=l.d,b=(t=new m(t)).d;if(t.s*=l.s,!d||!d[0]||!b||!b[0])return new m(!t.s||d&&!d[0]&&!b||b&&!b[0]&&!d?NaN:!d||!b?t.s/0:t.s*0);for(n=X(l.e/k)+X(t.e/k),c=d.length,u=b.length,c<u&&(o=d,d=b,b=o,s=c,c=u,u=s),o=[],s=c+u,i=s;i--;)o.push(0);for(i=u;--i>=0;){for(e=0,r=c+i;r>i;)a=o[r]+b[i]*d[r-i-1]+e,o[r--]=a%te|0,e=a/te|0;o[r]=(o[r]+e)%te|0}for(;!o[--s];)o.pop();return e?++n:o.shift(),t.d=o,t.e=tt(o,n),B?w(t,m.precision,m.rounding):t};f.toBinary=function(t,e){return It(this,2,t,e)};f.toDecimalPlaces=f.toDP=function(t,e){var n=this,i=n.constructor;return n=new i(n),t===void 0?n:(Q(t,0,we),e===void 0?e=i.rounding:Q(e,0,8),w(n,t+n.e+1,e))};f.toExponential=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=ne(i,!0):(Q(t,0,we),e===void 0?e=r.rounding:Q(e,0,8),i=w(new r(i),t+1,e),n=ne(i,!0,t+1)),i.isNeg()&&!i.isZero()?"-"+n:n};f.toFixed=function(t,e){var n,i,r=this,o=r.constructor;return t===void 0?n=ne(r):(Q(t,0,we),e===void 0?e=o.rounding:Q(e,0,8),i=w(new o(r),t+r.e+1,e),n=ne(i,!1,t+i.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toFraction=function(t){var e,n,i,r,o,s,a,c,u,l,m,d,b=this,y=b.d,g=b.constructor;if(!y)return new g(b);if(u=n=new g(1),i=c=new g(0),e=new g(i),o=e.e=fn(y)-b.e-1,s=o%k,e.d[0]=V(10,s<0?k+s:s),t==null)t=o>0?e:u;else{if(a=new g(t),!a.isInt()||a.lt(u))throw Error(Ae+a);t=a.gt(e)?o>0?e:u:a}for(B=!1,a=new g(U(y)),l=g.precision,g.precision=o=y.length*k*2;m=M(a,e,0,1,1),r=n.plus(m.times(i)),r.cmp(t)!=1;)n=i,i=r,r=u,u=c.plus(m.times(r)),c=r,r=e,e=a.minus(m.times(r)),a=r;return r=M(t.minus(n),i,0,1,1),c=c.plus(r.times(u)),n=n.plus(r.times(i)),c.s=u.s=b.s,d=M(u,i,o,1).minus(b).abs().cmp(M(c,n,o,1).minus(b).abs())<1?[u,i]:[c,n],g.precision=l,B=!0,d};f.toHexadecimal=f.toHex=function(t,e){return It(this,16,t,e)};f.toNearest=function(t,e){var n=this,i=n.constructor;if(n=new i(n),t==null){if(!n.d)return n;t=new i(1),e=i.rounding}else{if(t=new i(t),e===void 0?e=i.rounding:Q(e,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(B=!1,n=M(n,t,0,e,1).times(t),B=!0,w(n)):(t.s=n.s,n=t),n};f.toNumber=function(){return+this};f.toOctal=function(t,e){return It(this,8,t,e)};f.toPower=f.pow=function(t){var e,n,i,r,o,s,a=this,c=a.constructor,u=+(t=new c(t));if(!a.d||!t.d||!a.d[0]||!t.d[0])return new c(V(+a,u));if(a=new c(a),a.eq(1))return a;if(i=c.precision,o=c.rounding,t.eq(1))return w(a,i,o);if(e=X(t.e/k),e>=t.d.length-1&&(n=u<0?-u:u)<=yi)return r=bn(c,a,n,i),t.s<0?new c(1).div(r):w(r,i,o);if(s=a.s,s<0){if(e<t.d.length-1)return new c(NaN);if((t.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=V(+a,u),e=n==0||!isFinite(n)?X(u*(Math.log("0."+U(a.d))/Math.LN10+a.e+1)):new c(n+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(B=!1,c.rounding=a.s=1,n=Math.min(12,(e+"").length),r=Bt(t.times(Pe(a,i+n)),i),r.d&&(r=w(r,i+5,1),Ee(r.d,i,o)&&(e=i+10,r=w(Bt(t.times(Pe(a,e+n)),e),e+5,1),+U(r.d).slice(i+1,i+15)+1==1e14&&(r=w(r,i+1,0)))),r.s=s,B=!0,c.rounding=o,w(r,i,o))};f.toPrecision=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=ne(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(Q(t,1,we),e===void 0?e=r.rounding:Q(e,0,8),i=w(new r(i),t,e),n=ne(i,t<=i.e||i.e<=r.toExpNeg,t)),i.isNeg()&&!i.isZero()?"-"+n:n};f.toSignificantDigits=f.toSD=function(t,e){var n=this,i=n.constructor;return t===void 0?(t=i.precision,e=i.rounding):(Q(t,1,we),e===void 0?e=i.rounding:Q(e,0,8)),w(new i(n),t,e)};f.toString=function(){var t=this,e=t.constructor,n=ne(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};f.truncated=f.trunc=function(){return w(new this.constructor(this),this.e+1,1)};f.valueOf=f.toJSON=function(){var t=this,e=t.constructor,n=ne(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function U(t){var e,n,i,r=t.length-1,o="",s=t[0];if(r>0){for(o+=s,e=1;e<r;e++)i=t[e]+"",n=k-i.length,n&&(o+=ye(n)),o+=i;s=t[e],i=s+"",n=k-i.length,n&&(o+=ye(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Q(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Ae+t)}function Ee(t,e,n,i){var r,o,s,a;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=k,r=0):(r=Math.ceil((e+1)/k),e%=k),o=V(10,k-e),a=t[r]%o|0,i==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==o||n>3&&a+1==o/2)&&(t[r+1]/o/100|0)==V(10,e-2)-1||(a==o/2||a==0)&&(t[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=(i||n<4)&&a==9999||!i&&n>3&&a==4999):s=((i||n<4)&&a+1==o||!i&&n>3&&a+1==o/2)&&(t[r+1]/o/1e3|0)==V(10,e-3)-1,s}function Qe(t,e,n){for(var i,r=[0],o,s=0,a=t.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=kt.indexOf(t.charAt(s++)),i=0;i<r.length;i++)r[i]>n-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/n|0,r[i]%=n)}return r.reverse()}function Ai(t,e){var n,i,r;if(e.isZero())return e;i=e.d.length,i<32?(n=Math.ceil(i/3),r=(1/nt(4,n)).toString()):(n=16,r="2.3283064365386962890625e-10"),t.precision+=n,e=Le(t,1,e.times(r),new t(1));for(var o=n;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return t.precision-=n,e}var M=function(){function t(i,r,o){var s,a=0,c=i.length;for(i=i.slice();c--;)s=i[c]*r+a,i[c]=s%o|0,a=s/o|0;return a&&i.unshift(a),i}function e(i,r,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(i[a]!=r[a]){c=i[a]>r[a]?1:-1;break}return c}function n(i,r,o,s){for(var a=0;o--;)i[o]-=a,a=i[o]<r[o]?1:0,i[o]=a*s+i[o]-r[o];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,o,s,a,c){var u,l,m,d,b,y,g,K,I,S,T,R,de,z,pe,fe,be,ve,Z,Be,ue=i.constructor,bt=i.s==r.s?1:-1,G=i.d,v=r.d;if(!G||!G[0]||!v||!v[0])return new ue(!i.s||!r.s||(G?v&&G[0]==v[0]:!v)?NaN:G&&G[0]==0||!v?bt*0:bt/0);for(c?(b=1,l=i.e-r.e):(c=te,b=k,l=X(i.e/b)-X(r.e/b)),Z=v.length,be=G.length,I=new ue(bt),S=I.d=[],m=0;v[m]==(G[m]||0);m++);if(v[m]>(G[m]||0)&&l--,o==null?(z=o=ue.precision,s=ue.rounding):a?z=o+(i.e-r.e)+1:z=o,z<0)S.push(1),y=!0;else{if(z=z/b+2|0,m=0,Z==1){for(d=0,v=v[0],z++;(m<be||d)&&z--;m++)pe=d*c+(G[m]||0),S[m]=pe/v|0,d=pe%v|0;y=d||m<be}else{for(d=c/(v[0]+1)|0,d>1&&(v=t(v,d,c),G=t(G,d,c),Z=v.length,be=G.length),fe=Z,T=G.slice(0,Z),R=T.length;R<Z;)T[R++]=0;Be=v.slice(),Be.unshift(0),ve=v[0],v[1]>=c/2&&++ve;do d=0,u=e(v,T,Z,R),u<0?(de=T[0],Z!=R&&(de=de*c+(T[1]||0)),d=de/ve|0,d>1?(d>=c&&(d=c-1),g=t(v,d,c),K=g.length,R=T.length,u=e(g,T,K,R),u==1&&(d--,n(g,Z<K?Be:v,K,c))):(d==0&&(u=d=1),g=v.slice()),K=g.length,K<R&&g.unshift(0),n(T,g,R,c),u==-1&&(R=T.length,u=e(v,T,Z,R),u<1&&(d++,n(T,Z<R?Be:v,R,c))),R=T.length):u===0&&(d++,T=[0]),S[m++]=d,u&&T[0]?T[R++]=G[fe]||0:(T=[G[fe]],R=1);while((fe++<be||T[0]!==void 0)&&z--);y=T[0]!==void 0}S[0]||S.shift()}if(b==1)I.e=l,cn=y;else{for(m=1,d=S[0];d>=10;d/=10)m++;I.e=m+l*b-1,w(I,a?o+I.e+1:o,s,y)}return I}}();function w(t,e,n,i){var r,o,s,a,c,u,l,m,d,b=t.constructor;e:if(e!=null){if(m=t.d,!m)return t;for(r=1,a=m[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=k,s=e,l=m[d=0],c=l/V(10,r-s-1)%10|0;else if(d=Math.ceil((o+1)/k),a=m.length,d>=a)if(i){for(;a++<=d;)m.push(0);l=c=0,r=1,o%=k,s=o-k+1}else break e;else{for(l=a=m[d],r=1;a>=10;a/=10)r++;o%=k,s=o-k+r,c=s<0?0:l/V(10,r-s-1)%10|0}if(i=i||e<0||m[d+1]!==void 0||(s<0?l:l%V(10,r-s-1)),u=n<4?(c||i)&&(n==0||n==(t.s<0?3:2)):c>5||c==5&&(n==4||i||n==6&&(o>0?s>0?l/V(10,r-s):0:m[d-1])%10&1||n==(t.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=t.e+1,m[0]=V(10,(k-e%k)%k),t.e=-e||0):m[0]=t.e=0,t;if(o==0?(m.length=d,a=1,d--):(m.length=d+1,a=V(10,k-o),m[d]=s>0?(l/V(10,r-s)%V(10,s)|0)*a:0),u)for(;;)if(d==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&&(t.e++,m[0]==te&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=te)break;m[d--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return B&&(t.e>b.maxE?(t.d=null,t.e=NaN):t.e<b.minE&&(t.e=0,t.d=[0])),t}function ne(t,e,n){if(!t.isFinite())return yn(t);var i,r=t.e,o=U(t.d),s=o.length;return e?(n&&(i=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+ye(i):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):r<0?(o="0."+ye(-r-1)+o,n&&(i=n-s)>0&&(o+=ye(i))):r>=s?(o+=ye(r+1-s),n&&(i=n-r-1)>0&&(o=o+"."+ye(i))):((i=r+1)<s&&(o=o.slice(0,i)+"."+o.slice(i)),n&&(i=n-s)>0&&(r+1===s&&(o+="."),o+=ye(i))),o}function tt(t,e){var n=t[0];for(e*=k;n>=10;n/=10)e++;return e}function $e(t,e,n){if(e>Pi)throw B=!0,n&&(t.precision=n),Error(ln);return w(new t(Ye),e,1,!0)}function ee(t,e,n){if(e>Tt)throw Error(ln);return w(new t(Je),e,n,!0)}function fn(t){var e=t.length-1,n=e*k+1;if(e=t[e],e){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function ye(t){for(var e="";t--;)e+="0";return e}function bn(t,e,n,i){var r,o=new t(1),s=Math.ceil(i/k+4);for(B=!1;;){if(n%2&&(o=o.times(e),an(o.d,s)&&(r=!0)),n=X(n/2),n===0){n=o.d.length-1,r&&o.d[n]===0&&++o.d[n];break}e=e.times(e),an(e.d,s)}return B=!0,o}function sn(t){return t.d[t.d.length-1]&1}function gn(t,e,n){for(var i,r=new t(e[0]),o=0;++o<e.length;)if(i=new t(e[o]),i.s)r[n](i)&&(r=i);else{r=i;break}return r}function Bt(t,e){var n,i,r,o,s,a,c,u=0,l=0,m=0,d=t.constructor,b=d.rounding,y=d.precision;if(!t.d||!t.d[0]||t.e>17)return new d(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:0/0);for(e==null?(B=!1,c=y):c=e,a=new d(.03125);t.e>-2;)t=t.times(a),m+=5;for(i=Math.log(V(2,m))/Math.LN10*2+5|0,c+=i,n=o=s=new d(1),d.precision=c;;){if(o=w(o.times(t),c,1),n=n.times(++l),a=s.plus(M(o,n,c,1)),U(a.d).slice(0,c)===U(s.d).slice(0,c)){for(r=m;r--;)s=w(s.times(s),c,1);if(e==null)if(u<3&&Ee(s.d,c-i,b,u))d.precision=c+=10,n=o=a=new d(1),l=0,u++;else return w(s,d.precision=y,b,B=!0);else return d.precision=y,s}s=a}}function Pe(t,e){var n,i,r,o,s,a,c,u,l,m,d,b=1,y=10,g=t,K=g.d,I=g.constructor,S=I.rounding,T=I.precision;if(g.s<0||!K||!K[0]||!g.e&&K[0]==1&&K.length==1)return new I(K&&!K[0]?-1/0:g.s!=1?NaN:K?0:g);if(e==null?(B=!1,l=T):l=e,I.precision=l+=y,n=U(K),i=n.charAt(0),Math.abs(o=g.e)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)g=g.times(t),n=U(g.d),i=n.charAt(0),b++;o=g.e,i>1?(g=new I("0."+n),o++):g=new I(i+"."+n.slice(1))}else return u=$e(I,l+2,T).times(o+""),g=Pe(new I(i+"."+n.slice(1)),l-y).plus(u),I.precision=T,e==null?w(g,T,S,B=!0):g;for(m=g,c=s=g=M(g.minus(1),g.plus(1),l,1),d=w(g.times(g),l,1),r=3;;){if(s=w(s.times(d),l,1),u=c.plus(M(s,new I(r),l,1)),U(u.d).slice(0,l)===U(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus($e(I,l+2,T).times(o+""))),c=M(c,new I(b),l,1),e==null)if(Ee(c.d,l-y,S,a))I.precision=l+=y,u=s=g=M(m.minus(1),m.plus(1),l,1),d=w(g.times(g),l,1),r=a=1;else return w(c,I.precision=T,S,B=!0);else return I.precision=T,c;c=u,r+=2}}function yn(t){return String(t.s*t.s/0)}function xt(t,e){var n,i,r;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(n<0&&(n=i),n+=+e.slice(i+1),e=e.substring(0,i)):n<0&&(n=e.length),i=0;e.charCodeAt(i)===48;i++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(i,r),e){if(r-=i,t.e=n=n-i-1,t.d=[],i=(n+1)%k,n<0&&(i+=k),i<r){for(i&&t.d.push(+e.slice(0,i)),r-=k;i<r;)t.d.push(+e.slice(i,i+=k));e=e.slice(i),i=k-e.length}else i-=r;for(;i--;)e+="0";t.d.push(+e),B&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function wi(t,e){var n,i,r,o,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),pn.test(e))return xt(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(bi.test(e))n=16,e=e.toLowerCase();else if(fi.test(e))n=2;else if(gi.test(e))n=8;else throw Error(Ae+e);for(o=e.search(/p/i),o>0?(c=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,i=t.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=bn(i,new i(n),o,o*2)),u=Qe(e,n,te),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new i(t.s*0):(t.e=tt(u,l),t.d=u,B=!1,s&&(t=M(t,r,a*4)),c&&(t=t.times(Math.abs(c)<54?V(2,c):Oe.pow(2,c))),B=!0,t)}function ki(t,e){var n,i=e.d.length;if(i<3)return e.isZero()?e:Le(t,2,e,e);n=1.4*Math.sqrt(i),n=n>16?16:n|0,e=e.times(1/nt(5,n)),e=Le(t,2,e,e);for(var r,o=new t(5),s=new t(16),a=new t(20);n--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function Le(t,e,n,i,r){var o,s,a,c,u=1,l=t.precision,m=Math.ceil(l/k);for(B=!1,c=n.times(n),a=new t(i);;){if(s=M(a.times(c),new t(e++*e++),l,1),a=r?i.plus(s):i.minus(s),i=M(s.times(c),new t(e++*e++),l,1),s=a.plus(i),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=i,i=s,s=o,u++}return B=!0,s.d.length=m+1,s}function nt(t,e){for(var n=t;--e;)n*=t;return n}function Pn(t,e){var n,i=e.s<0,r=ee(t,t.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return le=i?4:1,e;if(n=e.divToInt(r),n.isZero())le=i?3:2;else{if(e=e.minus(n.times(r)),e.lte(o))return le=sn(n)?i?2:3:i?4:1,e;le=sn(n)?i?1:4:i?3:2}return e.minus(r).abs()}function It(t,e,n,i){var r,o,s,a,c,u,l,m,d,b=t.constructor,y=n!==void 0;if(y?(Q(n,1,we),i===void 0?i=b.rounding:Q(i,0,8)):(n=b.precision,i=b.rounding),!t.isFinite())l=yn(t);else{for(l=ne(t),s=l.indexOf("."),y?(r=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):r=e,s>=0&&(l=l.replace(".",""),d=new b(1),d.e=l.length-s,d.d=Qe(ne(d),10,r),d.e=d.d.length),m=Qe(l,10,r),o=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=y?"0p+0":"0";else{if(s<0?o--:(t=new b(t),t.d=m,t.e=o,t=M(t,d,n,i,0,r),m=t.d,o=t.e,u=cn),s=m[n],a=r/2,u=u||m[n+1]!==void 0,u=i<4?(s!==void 0||u)&&(i===0||i===(t.s<0?3:2)):s>a||s===a&&(i===4||u||i===6&&m[n-1]&1||i===(t.s<0?8:7)),m.length=n,u)for(;++m[--n]>r-1;)m[n]=0,n||(++o,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=kt.charAt(m[s]);if(y){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=Qe(l,r,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=kt.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>c)for(o-=c;o--;)l+="0";else o<c&&(l=l.slice(0,o)+"."+l.slice(o))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return t.s<0?"-"+l:l}function an(t,e){if(t.length>e)return t.length=e,!0}function hi(t){return new this(t).abs()}function Ti(t){return new this(t).acos()}function Bi(t){return new this(t).acosh()}function xi(t,e){return new this(t).plus(e)}function Ii(t){return new this(t).asin()}function Si(t){return new this(t).asinh()}function Ci(t){return new this(t).atan()}function Ki(t){return new this(t).atanh()}function Ni(t,e){t=new this(t),e=new this(e);var n,i=this.precision,r=this.rounding,o=i+4;return!t.s||!e.s?n=new this(NaN):!t.d&&!e.d?(n=ee(this,o,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?ee(this,i,r):new this(0),n.s=t.s):!t.d||e.isZero()?(n=ee(this,o,1).times(.5),n.s=t.s):e.s<0?(this.precision=o,this.rounding=1,n=this.atan(M(t,e,o,1)),e=ee(this,o,1),this.precision=i,this.rounding=r,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(M(t,e,o,1)),n}function Li(t){return new this(t).cbrt()}function Ri(t){return w(t=new this(t),t.e+1,2)}function Fi(t,e,n){return new this(t).clamp(e,n)}function Mi(t){if(!t||typeof t!="object")throw Error(et+"Object expected");var e,n,i,r=t.defaults===!0,o=["precision",1,we,"rounding",0,8,"toExpNeg",-Ne,0,"toExpPos",0,Ne,"maxE",0,Ne,"minE",-Ne,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(n=o[e],r&&(this[n]=ht[n]),(i=t[n])!==void 0)if(X(i)===i&&i>=o[e+1]&&i<=o[e+2])this[n]=i;else throw Error(Ae+n+": "+i);if(n="crypto",r&&(this[n]=ht[n]),(i=t[n])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(mn);else this[n]=!1;else throw Error(Ae+n+": "+i);return this}function vi(t){return new this(t).cos()}function Ei(t){return new this(t).cosh()}function An(t){var e,n,i;function r(o){var s,a,c,u=this;if(!(u instanceof r))return new r(o);if(u.constructor=r,un(o)){u.s=o.s,B?!o.d||o.e>r.maxE?(u.e=NaN,u.d=null):o.e<r.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(c=typeof o,c==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;B?s>r.maxE?(u.e=NaN,u.d=null):s<r.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}else if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return xt(u,o.toString())}else if(c!=="string")throw Error(Ae+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),pn.test(o)?xt(u,o):wi(u,o)}if(r.prototype=f,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=Mi,r.clone=An,r.isDecimal=un,r.abs=hi,r.acos=Ti,r.acosh=Bi,r.add=xi,r.asin=Ii,r.asinh=Si,r.atan=Ci,r.atanh=Ki,r.atan2=Ni,r.cbrt=Li,r.ceil=Ri,r.clamp=Fi,r.cos=vi,r.cosh=Ei,r.div=Oi,r.exp=Di,r.floor=Wi,r.hypot=Vi,r.ln=_i,r.log=qi,r.log10=Gi,r.log2=Ui,r.max=Xi,r.min=Hi,r.mod=zi,r.mul=Zi,r.pow=ji,r.random=Qi,r.round=Yi,r.sign=Ji,r.sin=$i,r.sinh=er,r.sqrt=tr,r.sub=nr,r.sum=ir,r.tan=rr,r.tanh=or,r.trunc=sr,t===void 0&&(t={}),t&&t.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)t.hasOwnProperty(n=i[e++])||(t[n]=this[n]);return r.config(t),r}function Oi(t,e){return new this(t).div(e)}function Di(t){return new this(t).exp()}function Wi(t){return w(t=new this(t),t.e+1,3)}function Vi(){var t,e,n=new this(0);for(B=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)n.d&&(n=n.plus(e.times(e)));else{if(e.s)return B=!0,new this(1/0);n=e}return B=!0,n.sqrt()}function un(t){return t instanceof Oe||t&&t.toStringTag===dn||!1}function _i(t){return new this(t).ln()}function qi(t,e){return new this(t).log(e)}function Ui(t){return new this(t).log(2)}function Gi(t){return new this(t).log(10)}function Xi(){return gn(this,arguments,"lt")}function Hi(){return gn(this,arguments,"gt")}function zi(t,e){return new this(t).mod(e)}function Zi(t,e){return new this(t).mul(e)}function ji(t,e){return new this(t).pow(e)}function Qi(t){var e,n,i,r,o=0,s=new this(1),a=[];if(t===void 0?t=this.precision:Q(t,1,we),i=Math.ceil(t/k),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));o<i;)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(i*=4);o<i;)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=i/4}else throw Error(mn);else for(;o<i;)a[o++]=Math.random()*1e7|0;for(i=a[--o],t%=k,i&&t&&(r=V(10,k-t),a[o]=(i/r|0)*r);a[o]===0;o--)a.pop();if(o<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=k)a.shift();for(i=1,r=a[0];r>=10;r/=10)i++;i<k&&(n-=k-i)}return s.e=n,s.d=a,s}function Yi(t){return w(t=new this(t),t.e+1,this.rounding)}function Ji(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function $i(t){return new this(t).sin()}function er(t){return new this(t).sinh()}function tr(t){return new this(t).sqrt()}function nr(t,e){return new this(t).sub(e)}function ir(){var t=0,e=arguments,n=new this(e[t]);for(B=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return B=!0,w(n,this.precision,this.rounding)}function rr(t){return new this(t).tan()}function or(t){return new this(t).tanh()}function sr(t){return w(t=new this(t),t.e+1,1)}f[Symbol.for("nodejs.util.inspect.custom")]=f.toString;f[Symbol.toStringTag]="Decimal";var Oe=f.constructor=An(ht);Ye=new Oe(Ye);Je=new Oe(Je);var L=Oe;import fr from"big.js";import js from"bn.js";import ar from"toformat";var ur=ar,De=ur;import rt from"big.js";import lr from"bn.js";import mr from"decimal.js-light";import We from"bn.js";var wn=9007199254740991;function ie(t){let e=H("Raydium_parseBigNumberish");if(t instanceof We)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new We(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=wn||t<=-wn)&&e.logWithError(`BigNumberish number overflow: ${t}`),new We(String(t))):typeof t=="bigint"?new We(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new We(0))}var it=H("module/fraction"),St=De(rt),Ve=De(mr),dr={[0]:Ve.ROUND_DOWN,[1]:Ve.ROUND_HALF_UP,[2]:Ve.ROUND_UP},pr={[0]:rt.roundDown,[1]:rt.roundHalfUp,[2]:rt.roundUp},E=class{constructor(e,n=new lr(1)){this.numerator=ie(e),this.denominator=ie(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new E(this.denominator,this.numerator)}add(e){let n=e instanceof E?e:new E(ie(e));return this.denominator.eq(n.denominator)?new E(this.numerator.add(n.numerator),this.denominator):new E(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof E?e:new E(ie(e));return this.denominator.eq(n.denominator)?new E(this.numerator.sub(n.numerator),this.denominator):new E(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof E?e:new E(ie(e));return new E(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof E?e:new E(ie(e));return new E(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},i=1){Number.isInteger(e)||it.logWithError(`${e} is not an integer.`),e<=0&&it.logWithError(`${e} is not positive.`),Ve.set({precision:e+1,rounding:dr[i]});let r=new Ve(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),n)}toFixed(e,n={groupSeparator:""},i=1){return Number.isInteger(e)||it.logWithError(`${e} is not an integer.`),e<0&&it.logWithError(`${e} is negative.`),St.DP=e,St.RM=pr[i]||1,new St(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var ra=H("Raydium_amount"),oa=De(fr);import{PublicKey as gr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as kn}from"@solana/spl-token";var Ct={chainId:101,address:gr.default.toBase58(),programId:kn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},ke={chainId:101,address:"So11111111111111111111111111111111111111112",programId:kn.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};import{PublicKey as Lt}from"@solana/web3.js";import{PublicKey as D,SystemProgram as hn,SYSVAR_RENT_PUBKEY as yr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Pr}from"@solana/spl-token";function Kt({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var pa=[Kt({pubkey:Pr,isWritable:!1}),Kt({pubkey:hn.programId,isWritable:!1}),Kt({pubkey:yr,isWritable:!1})];function Tn({publicKey:t,transformSol:e}){let n=Bn(t.toString());if(n instanceof D)return e&&n.equals(_e)?je:n;if(e&&n.toString()===_e.toBase58())return je;if(typeof n=="string"){if(n===D.default.toBase58())return D.default;try{return new D(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Bn(t){try{return new D(t)}catch{return t}}var Ar=new D("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),wr=new D("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Nt=new D("SysvarRent111111111111111111111111111111111"),fa=new D("SysvarC1ock11111111111111111111111111111111"),ot=new D("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),ba=new D("Sysvar1nstructions1111111111111111111111111"),ga=hn.programId,ya=new D("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Pa=new D("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Aa=new D("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),wa=new D("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),ka=new D("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),ha=new D("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Ta=new D("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ba=new D("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),xa=new D("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Ia=new D("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Sa=new D("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),je=new D("So11111111111111111111111111111111111111112"),_e=D.default;var Rt=class{constructor({mint:e,decimals:n,symbol:i,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===_e.toBase58()||e instanceof Lt&&_e.equals(e)){this.decimals=ke.decimals,this.symbol=ke.symbol,this.name=ke.name,this.mint=new Lt(ke.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=i||e.toString().substring(0,6),this.name=r||e.toString().substring(0,6),this.mint=o?Lt.default:Tn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},he=Rt;he.WSOL=new Rt(q(W({},ke),{mint:ke.address}));var Ft=class{constructor({decimals:e,symbol:n="UNKNOWN",name:i="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=i}equals(e){return this===e}},st=Ft;st.SOL=new Ft(Ct);import kr from"bn.js";var Wa=new E(new kr(100));var Xa=H("Raydium_price");import{PublicKey as uu}from"@solana/web3.js";import lu from"bn.js";var hr=new re(0),Cu=new re(1),Ku=new re(2),Nu=new re(3),Lu=new re(5),br=new re(10),Ru=new re(100),Fu=new re(1e3),Mu=new re(1e4);function xn(t,e,n){return t.mul(e).add(n).sub(new re(1)).div(n)}import{PublicKey as rc}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as sc}from"@solana/spl-token";import{ComputeBudgetProgram as qu,Keypair as Xu,PublicKey as Tr,Transaction as zu,TransactionMessage as ju,VersionedTransaction as Qu}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as ec}from"@solana/spl-token";var tc=H("Raydium_txUtil");function me(t,e){let[n,i]=Tr.findProgramAddressSync(t,e);return{publicKey:n,nonce:i}}import{PublicKey as x}from"@solana/web3.js";var lc=new x("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),mc=new x("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),dc=new x("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),pc=new x("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),fc=new x("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),bc=new x("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),gc=new x("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),yc=new x("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Pc=new x("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Ac=new x("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Br=new x("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),xr=new x("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Ir=new x("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),wc=new x("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),kc=new x("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),hc=new x("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Tc=new x("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Bc=new x("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),xc=new x("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),Ic=new x("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Sc=new x("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),Cc=new x("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),Sr=new x("CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"),Cr=new x("7rQ1QFNosMkUCuh7Z7fPbTHvh73b68sQYdirycEzJVuw"),Kr=new x("G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2"),Kc=new x("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Nr=new x("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),Nc=new x("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),Lr=new x("7AFUeLVRjBfzqK3tTGw8hN48KLQWSk6DTE8xprWdPqix"),Rr=new x("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),Lc=new x("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),Fr=new x("7soRSLviCKHCKzCbRuVpZDif76NWLVqFtbjt8LpyxWSq"),Mr=new x("DG6kZFFCqxdtWXw53Zc28hLs3MTr28Efkm2FrsNERNSQ");var Rc={SERUM_MARKET:x.default,OPENBOOK_MARKET:new x("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),UTIL1216:x.default,FarmV3:new x("85BFyr98MbCUU9MVTEgzx1nbhWACbJqLzho6zd6DZcWL"),FarmV5:new x("EcLzTrNg9V7qhcdyXDe2qjtPkiGzDM2UbdRaeaadU5r2"),FarmV6:new x("Farm2hJLcqPtPg8M4rR6DMrsRNc5TPm5Cs4bVQrMe2T7"),AmmV4:new x("HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8"),AmmStable:new x("DDg4VmQaJV9ogWce7LpcjBA9bv22wRp5uaTPa5pGjijF"),CLMM:new x("devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH"),CLMM_LOCK_PROGRAM_ID:new x("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),CLMM_LOCK_AUTH_ID:new x("8qmHNvu2Kr2C7U8mJL4Vz1vTDxMhVuXKREwU7TNoaVEo"),Router:new x("BVChZ3XFEwTMUk1o9i3HAf91H6mFxSwa5X2wFAWhYPhU"),CREATE_CPMM_POOL_PROGRAM:Sr,CREATE_CPMM_POOL_AUTH:Cr,CREATE_CPMM_POOL_FEE_ACC:Kr,FEE_DESTINATION_ID:new x("3XMrhbv989VxAMi3DErLV9eJht1pHppW5LbKxe9fkEFR"),LOCK_CPMM_PROGRAM:Nr,LCOK_CPMM_AUTH:Lr,LAUNCHPAD_PROGRAM:Fr,LAUNCHPAD_AUTH:Mr};import ut from"bn.js";function ct(t,e){if(t.isZero())return new ut(0);let n=t.div(e);return n.isZero()?new ut(1):t.mod(e).gt(new ut(0))?n.add(new ut(1)):n}import{PublicKey as vr,AddressLookupTableAccount as In}from"@solana/web3.js";var Er={AcL1Vo8oy1ULiavEcjSUcwfBSForXMudcZvDZy5nzJkU:new In({key:new vr("AcL1Vo8oy1ULiavEcjSUcwfBSForXMudcZvDZy5nzJkU"),state:In.deserialize(Buffer.from("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","base64"))})};import{PublicKey as Qc,sendAndConfirmTransaction as Yc,SystemProgram as el,Transaction as tl,TransactionMessage as il,VersionedTransaction as rl}from"@solana/web3.js";import sl from"axios";import Or from"bn.js";var Ie=new Or(1e6);import{PublicKey as Lp}from"@solana/web3.js";import Fp from"bn.js";import{AccountLayout as Op,TOKEN_2022_PROGRAM_ID as Dp,TOKEN_PROGRAM_ID as Wp}from"@solana/spl-token";import{PublicKey as vl}from"@solana/web3.js";import{MintLayout as Ol,TOKEN_PROGRAM_ID as Wl}from"@solana/spl-token";import{Keypair as tp,PublicKey as np,SystemProgram as rp,TransactionInstruction as op}from"@solana/web3.js";import ap from"bn.js";import{ASSOCIATED_TOKEN_PROGRAM_ID as lp,TOKEN_2022_PROGRAM_ID as mp,TOKEN_PROGRAM_ID as dp}from"@solana/spl-token";import Md from"bn.js";import $ from"bn.js";var Ot=new $(0),Nn=new $(1),Ln=new $(-1),Y=new $(1).shln(64),Rn=new $(1).shln(128),Dt=Y.sub(Nn);var Dr=Rn.subn(1),Re=-443636,qe=-Re,Wt=new $("4295048016"),Vt=new $("79226673521066979257578248091"),Yl=new $("4295048017"),Jl=new $("79226673521066979257578248090");var Wr=new $(10).pow(new $(6));var $l=new $("18446744073700000000");import wd from"bn.js";function _t(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t,!1),new Uint8Array(e)}var om=Buffer.from("amm_config","utf8"),sm=Buffer.from("pool","utf8"),am=Buffe