@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 203 kB
JavaScript
var Jr=Object.create;var zt=Object.defineProperty,$r=Object.defineProperties,eo=Object.getOwnPropertyDescriptor,to=Object.getOwnPropertyDescriptors,no=Object.getOwnPropertyNames,fn=Object.getOwnPropertySymbols,io=Object.getPrototypeOf,Un=Object.prototype.hasOwnProperty,Ui=Object.prototype.propertyIsEnumerable;var Gi=(i,e,t)=>e in i?zt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,V=(i,e)=>{for(var t in e||(e={}))Un.call(e,t)&&Gi(i,t,e[t]);if(fn)for(var t of fn(e))Ui.call(e,t)&&Gi(i,t,e[t]);return i},j=(i,e)=>$r(i,to(e));var Nt=(i,e)=>{var t={};for(var n in i)Un.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&fn)for(var n of fn(i))e.indexOf(n)<0&&Ui.call(i,n)&&(t[n]=i[n]);return t};var ro=(i,e)=>{for(var t in e)zt(i,t,{get:e[t],enumerable:!0})},Xi=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of no(e))!Un.call(i,r)&&r!==t&&zt(i,r,{get:()=>e[r],enumerable:!(n=eo(e,r))||n.enumerable});return i};var we=(i,e,t)=>(t=i!=null?Jr(io(i)):{},Xi(e||!i||!i.__esModule?zt(t,"default",{value:i,enumerable:!0}):t,i)),oo=i=>Xi(zt({},"__esModule",{value:!0}),i);var Ns={};ro(Ns,{AMM_CONFIG_SEED:()=>Or,BIT_PRECISION:()=>Ai,Clmm:()=>qn,ClmmConfigLayout:()=>Di,ClmmInstrument:()=>le,EXTENSION_TICKARRAY_BITMAP_SIZE:()=>_n,FEE_RATE_DENOMINATOR:()=>mn,FETCH_TICKARRAY_COUNT:()=>Gr,Fee:()=>Mr,LOG_B_2_X32:()=>Ti,LOG_B_P_ERR_MARGIN_LOWER_X64:()=>ki,LOG_B_P_ERR_MARGIN_UPPER_X64:()=>hi,LiquidityMath:()=>$,LockClPositionLayoutV2:()=>Wi,LockPositionLayout:()=>Ks,MAX_SQRT_PRICE_X64:()=>tt,MAX_SQRT_PRICE_X64_SUB_ONE:()=>Ps,MAX_TICK:()=>Fe,MIN_SQRT_PRICE_X64:()=>et,MIN_SQRT_PRICE_X64_ADD_ONE:()=>ws,MIN_TICK:()=>Ne,MathUtil:()=>H,MaxU64:()=>On,MaxUint128:()=>Pi,NEGATIVE_ONE:()=>at,OBSERVATION_SEED:()=>Wr,ONE:()=>$e,OPERATION_SEED:()=>Vr,ObservationInfoLayout:()=>Vi,ObservationLayout:()=>Xr,OperationLayout:()=>_i,POOL_LOCK_ID_SEED:()=>Li,POOL_REWARD_VAULT_SEED:()=>vr,POOL_SEED:()=>Fr,POOL_TICK_ARRAY_BITMAP_SEED:()=>_r,POOL_VAULT_SEED:()=>Er,POSITION_SEED:()=>Ci,PoolInfoLayout:()=>pn,PoolUtils:()=>fe,PositionInfoLayout:()=>Kt,PositionRewardInfoLayout:()=>zr,PositionUtils:()=>Ut,ProtocolPositionLayout:()=>Cs,Q128:()=>ln,Q64:()=>We,RewardInfo:()=>Hr,SUPPORT_MINT_SEED:()=>qr,SqrtPriceMath:()=>U,SwapMath:()=>ht,TICK_ARRAY_BITMAP_SIZE:()=>kt,TICK_ARRAY_SEED:()=>Dr,TICK_ARRAY_SIZE:()=>ke,TICK_SPACINGS:()=>As,TickArrayBitmap:()=>ut,TickArrayBitmapExtensionLayout:()=>Ei,TickArrayBitmapExtensionUtils:()=>Ht,TickArrayLayout:()=>Xt,TickLayout:()=>Zr,TickMath:()=>xt,TickQuery:()=>te,TickUtils:()=>E,U64Resolution:()=>_t,U64_IGNORE_RANGE:()=>ks,ZERO:()=>Q,clmmComputeInfoToApiInfo:()=>Fi,getLiquidityFromAmounts:()=>Is,getPdaAmmConfigId:()=>Bs,getPdaExBitmapAccount:()=>Pe,getPdaLockClPositionIdV2:()=>Ct,getPdaLockPositionId:()=>Dn,getPdaMetadataKey:()=>qt,getPdaMintExAccount:()=>Vn,getPdaObservationAccount:()=>Ri,getPdaOperationAccount:()=>Gt,getPdaPersonalPositionAddress:()=>Ee,getPdaPoolId:()=>Ki,getPdaPoolRewardVaulId:()=>Ni,getPdaPoolVaultId:()=>vn,getPdaProtocolPositionAddress:()=>Ze,getPdaTickArrayAddress:()=>J,i16ToBytes:()=>hs,i32ToBytes:()=>dn,isZero:()=>Wt,leadingZeros:()=>Fn,leastSignificantBit:()=>Si,mockCreatePoolInfo:()=>Ts,mockV3CreatePoolInfo:()=>xi,mostSignificantBit:()=>Ii,trailingZeros:()=>En,u16ToBytes:()=>Bi,u32ToBytes:()=>xs});module.exports=oo(Ns);var R=require("@solana/web3.js"),ve=we(require("bn.js"));var Rt=9e15,bt=1e9,Xn="0123456789abcdef",yn="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",wn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Hn={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Rt,maxE:Rt,crypto:!1},Yi,ct,Z=!0,An="[DecimalError] ",gt=An+"Invalid argument: ",ji=An+"Precision limit exceeded",Qi=An+"crypto unavailable",Ji="[object Decimal]",Me=Math.floor,he=Math.pow,so=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ao=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,uo=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,$i=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,je=1e7,X=7,co=9007199254740991,lo=yn.length-1,zn=wn.length-1,S={toStringTag:Ji};S.absoluteValue=S.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),_(i)};S.ceil=function(){return _(new this.constructor(this),this.e+1,2)};S.clampedTo=S.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(gt+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new r(n)};S.comparedTo=S.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};S.cosine=S.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())+X,n.rounding=1,t=mo(n,rr(n,t)),n.precision=i,n.rounding=e,_(ct==2||ct==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};S.cubeRoot=S.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(Z=!1,o=l.s*he(l.s*l,1/3),!o||Math.abs(o)==1/0?(t=Ie(l.d),i=l.e,(o=(i-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=he(t,1/3),i=Me((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=ue(c.plus(l).times(a),c.plus(u),s+2,1),Ie(a.d).slice(0,s)===(t=Ie(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(_(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")&&(_(n,i+1,1),e=!n.times(n).times(n).eq(l));break}return Z=!0,_(n,i,m.rounding,e)};S.decimalPlaces=S.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-Me(this.e/X))*X,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};S.dividedBy=S.div=function(i){return ue(this,new this.constructor(i))};S.dividedToIntegerBy=S.divToInt=function(i){var e=this,t=e.constructor;return _(ue(e,new t(i),0,1,1),t.precision,t.rounding)};S.equals=S.eq=function(i){return this.cmp(i)===0};S.floor=function(){return _(new this.constructor(this),this.e+1,3)};S.greaterThan=S.gt=function(i){return this.cmp(i)>0};S.greaterThanOrEqualTo=S.gte=function(i){var e=this.cmp(i);return e==1||e===0};S.hyperbolicCosine=S.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/kn(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),o=Lt(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 _(o,s.precision=t,s.rounding=n,!0)};S.hyperbolicSine=S.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=Lt(o,2,r,r,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,r=r.times(1/kn(5,i)),r=Lt(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,_(r,e,t,!0)};S.hyperbolicTangent=S.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,ue(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};S.inverseCosine=S.acos=function(){var i=this,e=i.constructor,t=i.abs().cmp(1),n=e.precision,r=e.rounding;return t!==-1?t===0?i.isNeg()?it(e,n,r):new e(0):new e(NaN):i.isZero()?it(e,n+4,r).times(.5):(e.precision=n+6,e.rounding=1,i=new e(1).minus(i).div(i.plus(1)).sqrt().atan(),e.precision=n,e.rounding=r,i.times(2))};S.inverseHyperbolicCosine=S.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,Z=!1,t=t.times(t).minus(1).sqrt().plus(t),Z=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};S.inverseHyperbolicSine=S.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,Z=!1,t=t.times(t).plus(1).sqrt().plus(t),Z=!0,n.precision=i,n.rounding=e,t.ln())};S.inverseHyperbolicTangent=S.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?_(new o(r),i,e,!0):(o.precision=t=n-r.e,r=ue(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)};S.inverseSine=S.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=it(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)))};S.inverseTangent=S.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<=zn)return s=it(l,m+4,p).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(m+4<=zn)return s=it(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/X+2|0),i=t;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(Z=!1,e=Math.ceil(a/X),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)),Z=!0,_(s,l.precision=m,l.rounding=p,!0)};S.isFinite=function(){return!!this.d};S.isInteger=S.isInt=function(){return!!this.d&&Me(this.e/X)>this.d.length-2};S.isNaN=function(){return!this.s};S.isNegative=S.isNeg=function(){return this.s<0};S.isPositive=S.isPos=function(){return this.s>0};S.isZero=function(){return!!this.d&&this.d[0]===0};S.lessThan=S.lt=function(i){return this.cmp(i)<0};S.lessThanOrEqualTo=S.lte=function(i){return this.cmp(i)<1};S.logarithm=S.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(Z=!1,a=m+d,s=ft(c,a),n=e?Pn(l,a+10):ft(i,a),u=ue(s,n,a,1),Zt(u.d,r=m,p))do if(a+=10,s=ft(c,a),n=e?Pn(l,a+10):ft(i,a),u=ue(s,n,a,1),!o){+Ie(u.d).slice(r+1,r+15)+1==1e14&&(u=_(u,m+1,0));break}while(Zt(u.d,r+=10,p));return Z=!0,_(u,m,p)};S.minus=S.sub=function(i){var e,t,n,r,o,s,a,u,c,l,m,p,d=this,g=d.constructor;if(i=new g(i),!d.d||!i.d)return!d.s||!i.s?i=new g(NaN):d.d?i.s=-i.s:i=new g(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=g.precision,u=g.rounding,!c[0]||!p[0]){if(p[0])i.s=-i.s;else if(c[0])i=new g(d);else return new g(u===3?-0:0);return Z?_(i,a,u):i}if(t=Me(i.e/X),l=Me(d.e/X),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/X),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]=je-1;--c[r],c[n]+=je}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=Tn(c,t),Z?_(i,a,u):i):new g(u===3?-0:0)};S.modulo=S.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]?_(new n(t),n.precision,n.rounding):(Z=!1,n.modulo==9?(e=ue(t,i.abs(),0,3,1),e.s*=i.s):e=ue(t,i,0,n.modulo,1),e=e.times(i),Z=!0,t.minus(e))};S.naturalExponential=S.exp=function(){return Zn(this)};S.naturalLogarithm=S.ln=function(){return ft(this)};S.negated=S.neg=function(){var i=new this.constructor(this);return i.s=-i.s,_(i)};S.plus=S.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)),Z?_(i,a,u):i;if(o=Me(m.e/X),n=Me(i.e/X),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/X),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)/je|0,c[r]%=je;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=Tn(c,n),Z?_(i,a,u):i};S.precision=S.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(gt+i);return t.d?(e=er(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};S.round=function(){var i=this,e=i.constructor;return _(new e(i),i.e+1,e.rounding)};S.sine=S.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())+X,n.rounding=1,t=fo(n,rr(n,t)),n.precision=i,n.rounding=e,_(ct>2?t.neg():t,i,e,!0)):new n(NaN)};S.squareRoot=S.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(Z=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=Ie(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=Me((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(ue(s,o,t+2,1)).times(.5),Ie(o.d).slice(0,t)===(e=Ie(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(_(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")&&(_(n,u+1,1),i=!n.times(n).eq(s));break}return Z=!0,_(n,u,l.rounding,i)};S.tangent=S.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=ue(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,_(ct==2||ct==4?t.neg():t,i,e,!0)):new n(NaN)};S.times=S.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=Me(l.e/X)+Me(i.e/X),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%je|0,e=a/je|0;o[r]=(o[r]+e)%je|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),i.d=o,i.e=Tn(o,t),Z?_(i,m.precision,m.rounding):i};S.toBinary=function(i,e){return Yn(this,2,i,e)};S.toDecimalPlaces=S.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(_e(i,0,bt),e===void 0?e=n.rounding:_e(e,0,8),_(t,i+t.e+1,e))};S.toExponential=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=rt(n,!0):(_e(i,0,bt),e===void 0?e=r.rounding:_e(e,0,8),n=_(new r(n),i+1,e),t=rt(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};S.toFixed=function(i,e){var t,n,r=this,o=r.constructor;return i===void 0?t=rt(r):(_e(i,0,bt),e===void 0?e=o.rounding:_e(e,0,8),n=_(new o(r),i+r.e+1,e),t=rt(n,!1,i+n.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};S.toFraction=function(i){var e,t,n,r,o,s,a,u,c,l,m,p,d=this,g=d.d,f=d.constructor;if(!g)return new f(d);if(c=t=new f(1),n=u=new f(0),e=new f(n),o=e.e=er(g)-d.e-1,s=o%X,e.d[0]=he(10,s<0?X+s:s),i==null)i=o>0?e:c;else{if(a=new f(i),!a.isInt()||a.lt(c))throw Error(gt+a);i=a.gt(e)?o>0?e:c:a}for(Z=!1,a=new f(Ie(g)),l=f.precision,f.precision=o=g.length*X*2;m=ue(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=ue(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=ue(c,n,o,1).minus(d).abs().cmp(ue(u,t,o,1).minus(d).abs())<1?[c,n]:[u,t],f.precision=l,Z=!0,p};S.toHexadecimal=S.toHex=function(i,e){return Yn(this,16,i,e)};S.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:_e(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]?(Z=!1,t=ue(t,i,0,e,1).times(i),Z=!0,_(t)):(i.s=t.s,t=i),t};S.toNumber=function(){return+this};S.toOctal=function(i,e){return Yn(this,8,i,e)};S.toPower=S.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(he(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,o=u.rounding,i.eq(1))return _(a,n,o);if(e=Me(i.e/X),e>=i.d.length-1&&(t=c<0?-c:c)<=co)return r=tr(u,a,t,n),i.s<0?new u(1).div(r):_(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=he(+a,c),e=t==0||!isFinite(t)?Me(c*(Math.log("0."+Ie(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):(Z=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),r=Zn(i.times(ft(a,n+t)),n),r.d&&(r=_(r,n+5,1),Zt(r.d,n,o)&&(e=n+10,r=_(Zn(i.times(ft(a,e+t)),e),e+5,1),+Ie(r.d).slice(n+1,n+15)+1==1e14&&(r=_(r,n+1,0)))),r.s=s,Z=!0,u.rounding=o,_(r,n,o))};S.toPrecision=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=rt(n,n.e<=r.toExpNeg||n.e>=r.toExpPos):(_e(i,1,bt),e===void 0?e=r.rounding:_e(e,0,8),n=_(new r(n),i,e),t=rt(n,i<=n.e||n.e<=r.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};S.toSignificantDigits=S.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(_e(i,1,bt),e===void 0?e=n.rounding:_e(e,0,8)),_(new n(t),i,e)};S.toString=function(){var i=this,e=i.constructor,t=rt(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};S.truncated=S.trunc=function(){return _(new this.constructor(this),this.e+1,1)};S.valueOf=S.toJSON=function(){var i=this,e=i.constructor,t=rt(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function Ie(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=X-n.length,t&&(o+=pt(t)),o+=n;s=i[e],n=s+"",t=X-n.length,t&&(o+=pt(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function _e(i,e,t){if(i!==~~i||i<e||i>t)throw Error(gt+i)}function Zt(i,e,t,n){var r,o,s,a;for(o=i[0];o>=10;o/=10)--e;return--e<0?(e+=X,r=0):(r=Math.ceil((e+1)/X),e%=X),o=he(10,X-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)==he(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)==he(10,e-3)-1,s}function gn(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]+=Xn.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 mo(i,e){var t,n,r;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),r=(1/kn(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),i.precision+=t,e=Lt(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 ue=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,g,f,y,b,P,A,k,T,w,h,I,B,C,M,L,O=n.constructor,K=n.s==r.s?1:-1,N=n.d,v=r.d;if(!N||!N[0]||!v||!v[0])return new O(!n.s||!r.s||(N?v&&N[0]==v[0]:!v)?NaN:N&&N[0]==0||!v?K*0:K/0);for(u?(d=1,l=n.e-r.e):(u=je,d=X,l=Me(n.e/d)-Me(r.e/d)),M=v.length,B=N.length,b=new O(K),P=b.d=[],m=0;v[m]==(N[m]||0);m++);if(v[m]>(N[m]||0)&&l--,o==null?(w=o=O.precision,s=O.rounding):a?w=o+(n.e-r.e)+1:w=o,w<0)P.push(1),g=!0;else{if(w=w/d+2|0,m=0,M==1){for(p=0,v=v[0],w++;(m<B||p)&&w--;m++)h=p*u+(N[m]||0),P[m]=h/v|0,p=h%v|0;g=p||m<B}else{for(p=u/(v[0]+1)|0,p>1&&(v=i(v,p,u),N=i(N,p,u),M=v.length,B=N.length),I=M,A=N.slice(0,M),k=A.length;k<M;)A[k++]=0;L=v.slice(),L.unshift(0),C=v[0],v[1]>=u/2&&++C;do p=0,c=e(v,A,M,k),c<0?(T=A[0],M!=k&&(T=T*u+(A[1]||0)),p=T/C|0,p>1?(p>=u&&(p=u-1),f=i(v,p,u),y=f.length,k=A.length,c=e(f,A,y,k),c==1&&(p--,t(f,M<y?L:v,y,u))):(p==0&&(c=p=1),f=v.slice()),y=f.length,y<k&&f.unshift(0),t(A,f,k,u),c==-1&&(k=A.length,c=e(v,A,M,k),c<1&&(p++,t(A,M<k?L:v,k,u))),k=A.length):c===0&&(p++,A=[0]),P[m++]=p,c&&A[0]?A[k++]=N[I]||0:(A=[N[I]],k=1);while((I++<B||A[0]!==void 0)&&w--);g=A[0]!==void 0}P[0]||P.shift()}if(d==1)b.e=l,Yi=g;else{for(m=1,p=P[0];p>=10;p/=10)m++;b.e=m+l*d-1,_(b,a?o+b.e+1:o,s,g)}return b}}();function _(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+=X,s=e,l=m[p=0],u=l/he(10,r-s-1)%10|0;else if(p=Math.ceil((o+1)/X),a=m.length,p>=a)if(n){for(;a++<=p;)m.push(0);l=u=0,r=1,o%=X,s=o-X+1}else break e;else{for(l=a=m[p],r=1;a>=10;a/=10)r++;o%=X,s=o-X+r,u=s<0?0:l/he(10,r-s-1)%10|0}if(n=n||e<0||m[p+1]!==void 0||(s<0?l:l%he(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/he(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]=he(10,(X-e%X)%X),i.e=-e||0):m[0]=i.e=0,i;if(o==0?(m.length=p,a=1,p--):(m.length=p+1,a=he(10,X-o),m[p]=s>0?(l/he(10,r-s)%he(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]==je&&(m[0]=1));break}else{if(m[p]+=a,m[p]!=je)break;m[p--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return Z&&(i.e>d.maxE?(i.d=null,i.e=NaN):i.e<d.minE&&(i.e=0,i.d=[0])),i}function rt(i,e,t){if(!i.isFinite())return ir(i);var n,r=i.e,o=Ie(i.d),s=o.length;return e?(t&&(n=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+pt(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i.e<0?"e":"e+")+i.e):r<0?(o="0."+pt(-r-1)+o,t&&(n=t-s)>0&&(o+=pt(n))):r>=s?(o+=pt(r+1-s),t&&(n=t-r-1)>0&&(o=o+"."+pt(n))):((n=r+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),t&&(n=t-s)>0&&(r+1===s&&(o+="."),o+=pt(n))),o}function Tn(i,e){var t=i[0];for(e*=X;t>=10;t/=10)e++;return e}function Pn(i,e,t){if(e>lo)throw Z=!0,t&&(i.precision=t),Error(ji);return _(new i(yn),e,1,!0)}function it(i,e,t){if(e>zn)throw Error(ji);return _(new i(wn),e,t,!0)}function er(i){var e=i.length-1,t=e*X+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 pt(i){for(var e="";i--;)e+="0";return e}function tr(i,e,t,n){var r,o=new i(1),s=Math.ceil(n/X+4);for(Z=!1;;){if(t%2&&(o=o.times(e),zi(o.d,s)&&(r=!0)),t=Me(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),zi(e.d,s)}return Z=!0,o}function Hi(i){return i.d[i.d.length-1]&1}function nr(i,e,t){for(var n,r,o=new i(e[0]),s=0;++s<e.length;){if(r=new i(e[s]),!r.s){o=r;break}n=o.cmp(r),(n===t||n===0&&o.s===t)&&(o=r)}return o}function Zn(i,e){var t,n,r,o,s,a,u,c=0,l=0,m=0,p=i.constructor,d=p.rounding,g=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?(Z=!1,u=g):u=e,a=new p(.03125);i.e>-2;)i=i.times(a),m+=5;for(n=Math.log(he(2,m))/Math.LN10*2+5|0,u+=n,t=o=s=new p(1),p.precision=u;;){if(o=_(o.times(i),u,1),t=t.times(++l),a=s.plus(ue(o,t,u,1)),Ie(a.d).slice(0,u)===Ie(s.d).slice(0,u)){for(r=m;r--;)s=_(s.times(s),u,1);if(e==null)if(c<3&&Zt(s.d,u-n,d,c))p.precision=u+=10,t=o=a=new p(1),l=0,c++;else return _(s,p.precision=g,d,Z=!0);else return p.precision=g,s}s=a}}function ft(i,e){var t,n,r,o,s,a,u,c,l,m,p,d=1,g=10,f=i,y=f.d,b=f.constructor,P=b.rounding,A=b.precision;if(f.s<0||!y||!y[0]||!f.e&&y[0]==1&&y.length==1)return new b(y&&!y[0]?-1/0:f.s!=1?NaN:y?0:f);if(e==null?(Z=!1,l=A):l=e,b.precision=l+=g,t=Ie(y),n=t.charAt(0),Math.abs(o=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(i),t=Ie(f.d),n=t.charAt(0),d++;o=f.e,n>1?(f=new b("0."+t),o++):f=new b(n+"."+t.slice(1))}else return c=Pn(b,l+2,A).times(o+""),f=ft(new b(n+"."+t.slice(1)),l-g).plus(c),b.precision=A,e==null?_(f,A,P,Z=!0):f;for(m=f,u=s=f=ue(f.minus(1),f.plus(1),l,1),p=_(f.times(f),l,1),r=3;;){if(s=_(s.times(p),l,1),c=u.plus(ue(s,new b(r),l,1)),Ie(c.d).slice(0,l)===Ie(u.d).slice(0,l))if(u=u.times(2),o!==0&&(u=u.plus(Pn(b,l+2,A).times(o+""))),u=ue(u,new b(d),l,1),e==null)if(Zt(u.d,l-g,P,a))b.precision=l+=g,c=s=f=ue(m.minus(1),m.plus(1),l,1),p=_(f.times(f),l,1),r=a=1;else return _(u,b.precision=A,P,Z=!0);else return b.precision=A,u;u=c,r+=2}}function ir(i){return String(i.s*i.s/0)}function bn(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)%X,t<0&&(n+=X),n<r){for(n&&i.d.push(+e.slice(0,n)),r-=X;n<r;)i.d.push(+e.slice(n,n+=X));e=e.slice(n),n=X-e.length}else n-=r;for(;n--;)e+="0";i.d.push(+e),Z&&(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 po(i,e){var t,n,r,o,s,a,u,c,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),$i.test(e))return bn(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(ao.test(e))t=16,e=e.toLowerCase();else if(so.test(e))t=2;else if(uo.test(e))t=8;else throw Error(gt+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=tr(n,new n(t),o,o*2)),c=gn(e,t,je),l=c.length-1,o=l;c[o]===0;--o)c.pop();return o<0?new n(i.s*0):(i.e=Tn(c,l),i.d=c,Z=!1,s&&(i=ue(i,r,a*4)),u&&(i=i.times(Math.abs(u)<54?he(2,u):Yt.pow(2,u))),Z=!0,i)}function fo(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:Lt(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/kn(5,t)),e=Lt(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 Lt(i,e,t,n,r){var o,s,a,u,c=1,l=i.precision,m=Math.ceil(l/X);for(Z=!1,u=t.times(t),a=new i(n);;){if(s=ue(a.times(u),new i(e++*e++),l,1),a=r?n.plus(s):n.minus(s),n=ue(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 Z=!0,s.d.length=m+1,s}function kn(i,e){for(var t=i;--e;)t*=i;return t}function rr(i,e){var t,n=e.s<0,r=it(i,i.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return ct=n?4:1,e;if(t=e.divToInt(r),t.isZero())ct=n?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return ct=Hi(t)?n?2:3:n?4:1,e;ct=Hi(t)?n?1:4:n?3:2}return e.minus(r).abs()}function Yn(i,e,t,n){var r,o,s,a,u,c,l,m,p,d=i.constructor,g=t!==void 0;if(g?(_e(t,1,bt),n===void 0?n=d.rounding:_e(n,0,8)):(t=d.precision,n=d.rounding),!i.isFinite())l=ir(i);else{for(l=rt(i),s=l.indexOf("."),g?(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=gn(rt(p),10,r),p.e=p.d.length),m=gn(l,10,r),o=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=g?"0p+0":"0";else{if(s<0?o--:(i=new d(i),i.d=m,i.e=o,i=ue(i,p,t,n,0,r),m=i.d,o=i.e,c=Yi),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+=Xn.charAt(m[s]);if(g){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)l+="0";for(m=gn(l,r,e),u=m.length;!m[u-1];--u);for(s=1,l="1.";s<u;s++)l+=Xn.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 zi(i,e){if(i.length>e)return i.length=e,!0}function go(i){return new this(i).abs()}function bo(i){return new this(i).acos()}function yo(i){return new this(i).acosh()}function wo(i,e){return new this(i).plus(e)}function Po(i){return new this(i).asin()}function Ao(i){return new this(i).asinh()}function To(i){return new this(i).atan()}function ko(i){return new this(i).atanh()}function ho(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=it(this,o,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?it(this,n,r):new this(0),t.s=i.s):!i.d||e.isZero()?(t=it(this,o,1).times(.5),t.s=i.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(ue(i,e,o,1)),e=it(this,o,1),this.precision=n,this.rounding=r,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(ue(i,e,o,1)),t}function xo(i){return new this(i).cbrt()}function Bo(i){return _(i=new this(i),i.e+1,2)}function Io(i,e,t){return new this(i).clamp(e,t)}function So(i){if(!i||typeof i!="object")throw Error(An+"Object expected");var e,t,n,r=i.defaults===!0,o=["precision",1,bt,"rounding",0,8,"toExpNeg",-Rt,0,"toExpPos",0,Rt,"maxE",0,Rt,"minE",-Rt,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],r&&(this[t]=Hn[t]),(n=i[t])!==void 0)if(Me(n)===n&&n>=o[e+1]&&n<=o[e+2])this[t]=n;else throw Error(gt+t+": "+n);if(t="crypto",r&&(this[t]=Hn[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(Qi);else this[t]=!1;else throw Error(gt+t+": "+n);return this}function Co(i){return new this(i).cos()}function Ko(i){return new this(i).cosh()}function or(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,Zi(o)){c.s=o.s,Z?!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++;Z?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}if(o*0!==0){o||(c.s=NaN),c.e=NaN,c.d=null;return}return bn(c,o.toString())}if(u==="string")return(a=o.charCodeAt(0))===45?(o=o.slice(1),c.s=-1):(a===43&&(o=o.slice(1)),c.s=1),$i.test(o)?bn(c,o):po(c,o);if(u==="bigint")return o<0?(o=-o,c.s=-1):c.s=1,bn(c,o.toString());throw Error(gt+o)}if(r.prototype=S,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=So,r.clone=or,r.isDecimal=Zi,r.abs=go,r.acos=bo,r.acosh=yo,r.add=wo,r.asin=Po,r.asinh=Ao,r.atan=To,r.atanh=ko,r.atan2=ho,r.cbrt=xo,r.ceil=Bo,r.clamp=Io,r.cos=Co,r.cosh=Ko,r.div=No,r.exp=Ro,r.floor=Lo,r.hypot=Mo,r.ln=Oo,r.log=Fo,r.log10=vo,r.log2=Eo,r.max=Do,r.min=Vo,r.mod=_o,r.mul=Wo,r.pow=qo,r.random=Go,r.round=Uo,r.sign=Xo,r.sin=Ho,r.sinh=zo,r.sqrt=Zo,r.sub=Yo,r.sum=jo,r.tan=Qo,r.tanh=Jo,r.trunc=$o,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 No(i,e){return new this(i).div(e)}function Ro(i){return new this(i).exp()}function Lo(i){return _(i=new this(i),i.e+1,3)}function Mo(){var i,e,t=new this(0);for(Z=!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 Z=!0,new this(1/0);t=e}return Z=!0,t.sqrt()}function Zi(i){return i instanceof Yt||i&&i.toStringTag===Ji||!1}function Oo(i){return new this(i).ln()}function Fo(i,e){return new this(i).log(e)}function Eo(i){return new this(i).log(2)}function vo(i){return new this(i).log(10)}function Do(){return nr(this,arguments,-1)}function Vo(){return nr(this,arguments,1)}function _o(i,e){return new this(i).mod(e)}function Wo(i,e){return new this(i).mul(e)}function qo(i,e){return new this(i).pow(e)}function Go(i){var e,t,n,r,o=0,s=new this(1),a=[];if(i===void 0?i=this.precision:_e(i,1,bt),n=Math.ceil(i/X),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(Qi);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],i%=X,n&&i&&(r=he(10,X-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-=X)a.shift();for(n=1,r=a[0];r>=10;r/=10)n++;n<X&&(t-=X-n)}return s.e=t,s.d=a,s}function Uo(i){return _(i=new this(i),i.e+1,this.rounding)}function Xo(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Ho(i){return new this(i).sin()}function zo(i){return new this(i).sinh()}function Zo(i){return new this(i).sqrt()}function Yo(i,e){return new this(i).sub(e)}function jo(){var i=0,e=arguments,t=new this(e[i]);for(Z=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return Z=!0,_(t,this.precision,this.rounding)}function Qo(i){return new this(i).tan()}function Jo(i){return new this(i).tanh()}function $o(i){return _(i=new this(i),i.e+1,1)}S[Symbol.for("nodejs.util.inspect.custom")]=S.toString;S[Symbol.toStringTag]="Decimal";var Yt=S.constructor=or(Hn);yn=new Yt(yn);wn=new Yt(wn);var F=Yt;var $n=require("@solana/web3.js");var jt=require("lodash");var jn=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},sr={},es={};function Se(i){let e=(0,jt.get)(sr,i);if(!e){let t=(0,jt.get)(es,i);e=new jn({name:i,logLevel:t}),(0,jt.set)(sr,i,e)}return e}var yt=require("@solana/spl-token"),Qn=Se("Raydium_accountInfo_util");async function lt(i,e,t){let{batchRequest:n,commitment:r="confirmed",chunkCount:o=100}=V({batchRequest:!1},t),s=Jn(e,o),a=new Array(s.length).fill([]);if(n){let u=s.map(m=>{let p=i._buildArgs([m.map(d=>d.toBase58())],r,"base64");return{methodName:"getMultipleAccounts",args:p}}),c=Jn(u,10);a=(await(await Promise.all(c.map(async m=>await i._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&Qn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(p=>{if(p){let{data:d,executable:g,lamports:f,owner:y,rentEpoch:b}=p;return d.length!==2&&d[1]!=="base64"&&Qn.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(d[0],"base64"),executable:g,lamports:f,owner:new $n.PublicKey(y),rentEpoch:b}}return null})))}else try{a=await Promise.all(s.map(u=>i.getMultipleAccountsInfo(u,r)))}catch(u){u instanceof Error&&Qn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return a.flat()}async function mt(i,e,t){let n=await lt(i,e.map(r=>r.pubkey),t);return e.map((r,o)=>j(V({},r),{accountInfo:n[o]}))}async function ar({connection:i,mints:e,config:t}){var o,s,a;if(e.length===0)return{};let n=await mt(i,e.map(u=>({pubkey:Bt(u)})),t),r={};for(let u of n){if(!u.accountInfo||u.accountInfo.data.length<yt.MINT_SIZE){console.log("invalid mint account",u.pubkey.toBase58());continue}let c=(0,yt.unpackMint)(u.pubkey,u.accountInfo,(o=u.accountInfo)==null?void 0:o.owner);r[u.pubkey.toString()]=j(V({},c),{programId:((s=u.accountInfo)==null?void 0:s.owner)||yt.TOKEN_PROGRAM_ID,feeConfig:(a=(0,yt.getTransferFeeConfig)(c))!=null?a:void 0})}return r[$n.PublicKey.default.toBase58()]=r[ne.toBase58()],r}var st=we(require("bn.js"));var pr=we(require("big.js")),en=we(require("bn.js"));var ur=we(require("toformat")),ts=ur.default,Qt=ts;var Jt=we(require("big.js")),lr=we(require("bn.js")),mr=we(require("decimal.js-light"));var Mt=we(require("bn.js"));var cr=9007199254740991;function xe(i){let e=Se("Raydium_parseBigNumberish");if(i instanceof Mt.default)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new Mt.default(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=cr||i<=-cr)&&e.logWithError(`BigNumberish number overflow: ${i}`),new Mt.default(String(i))):typeof i=="bigint"?new Mt.default(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new Mt.default(0))}var hn=Se("module/fraction"),ei=Qt(Jt.default),$t=Qt(mr.default),is={[0]:$t.ROUND_DOWN,[1]:$t.ROUND_HALF_UP,[2]:$t.ROUND_UP},rs={[0]:Jt.default.roundDown,[1]:Jt.default.roundHalfUp,[2]:Jt.default.roundUp},re=class{constructor(e,t=new lr.default(1)){this.numerator=xe(e),this.denominator=xe(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new re(this.denominator,this.numerator)}add(e){let t=e instanceof re?e:new re(xe(e));return this.denominator.eq(t.denominator)?new re(this.numerator.add(t.numerator),this.denominator):new re(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof re?e:new re(xe(e));return this.denominator.eq(t.denominator)?new re(this.numerator.sub(t.numerator),this.denominator):new re(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof re?e:new re(xe(e));return new re(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof re?e:new re(xe(e));return new re(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||hn.logWithError(`${e} is not an integer.`),e<=0&&hn.logWithError(`${e} is not positive.`),$t.set({precision:e+1,rounding:is[n]});let r=new $t(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)||hn.logWithError(`${e} is not an integer.`),e<0&&hn.logWithError(`${e} is negative.`),ei.DP=e,ei.RM=rs[n]||1,new ei(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var os=Se("Raydium_amount"),dr=Qt(pr.default);function ss(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")):os.logWithError(`invalid number string, num: ${i}`)}else t=i;return[t,n.slice(0,e)||n]}var Ce=class extends re{constructor(t,n,r=!0,o){let s=new en.default(0),a=ti.pow(new en.default(t.decimals));if(r)s=xe(n);else{let u=new en.default(0),c=new en.default(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=ss(n.toString(),t.decimals);u=xe(l),c=xe(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 Ce(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new Ce(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 dr.DP=this.token.decimals,new dr(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};var fr=require("@solana/web3.js"),ni=require("@solana/spl-token"),ii={chainId:101,address:fr.PublicKey.default.toBase58(),programId:ni.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},wt={chainId:101,address:"So11111111111111111111111111111111111111112",programId:ni.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var Bn=require("@solana/web3.js");var oe=require("@solana/web3.js"),gr=require("@solana/spl-token");function ri({pubkey:i,isSigner:e=!1,isWritable:t=!0}){return{pubkey:i,isWritable:t,isSigner:e}}var oa=[ri({pubkey:gr.TOKEN_PROGRAM_ID,isWritable:!1}),ri({pubkey:oe.SystemProgram.programId,isWritable:!1}),ri({pubkey:oe.SYSVAR_RENT_PUBKEY,isWritable:!1})];function oi({publicKey:i,transformSol:e}){let t=br(i.toString());if(t instanceof oe.PublicKey)return e&&t.equals(tn)?ne:t;if(e&&t.toString()===tn.toBase58())return ne;if(typeof t=="string"){if(t===oe.PublicKey.default.toBase58())return oe.PublicKey.default;try{return new oe.PublicKey(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function br(i){try{return new oe.PublicKey(i)}catch{return i}}var xn=new oe.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),si=new oe.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Pt=new oe.PublicKey("SysvarRent111111111111111111111111111111111"),sa=new oe.PublicKey("SysvarC1ock11111111111111111111111111111111"),It=new oe.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),aa=new oe.PublicKey("Sysvar1nstructions1111111111111111111111111"),ua=oe.SystemProgram.programId,ca=new oe.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),la=new oe.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),ma=new oe.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),da=new oe.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),pa=new oe.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),fa=new oe.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),ga=new oe.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),ba=new oe.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),ya=new oe.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),wa=new oe.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Pa=new oe.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),ne=new oe.PublicKey("So11111111111111111111111111111111111111112"),tn=oe.PublicKey.default;function Bt(i){return oi({publicKey:i,transformSol:!0})}var ai=class{constructor({mint:e,decimals:t,symbol:n,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===tn.toBase58()||e instanceof Bn.PublicKey&&tn.equals(e)){this.decimals=wt.decimals,this.symbol=wt.symbol,this.name=wt.name,this.mint=new Bn.PublicKey(wt.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.PublicKey.default:oi({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},ot=ai;ot.WSOL=new ai(j(V({},wt),{mint:wt.address}));var ui=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},In=ui;In.SOL=new ui(ii);var wr=we(require("bn.js"));var yr=new re(new wr.default(100)),At=class extends re{toSignificant(e=5,t,n){return this.mul(yr).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(yr).toFixed(e,t,n)}};var as=Se("Raydium_price"),Qe=class extends re{constructor(t){let{baseToken:n,quoteToken:r,numerator:o,denominator:s}=t;super(o,s);this.baseToken=n,this.quoteToken=r,this.scalar=new re(ci(n.decimals),ci(r.decimals))}get raw(){return new re(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new Qe({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&as.logWithError("mul token not equals");let n=super.mul(t);return new Qe({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 us=new st.default(0),ou=new st.default(1),su=new st.default(2),au=new st.default(3),uu=new st.default(5),ti=new st.default(10),cu=new st.default(100),lu=new st.default(1e3),mu=new st.default(1e4);function ci(i){return ti.pow(xe(i))}function Jn(i,e=1,t=[]){let n=[...i];if(e<=0)return t;for(;n.length;)t.push(n.splice(0,e));return t}var kr=require("@solana/web3.js"),hr=require("@solana/spl-token");var Oe=require("@solana/web3.js");var me={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV4Withdraw:"FarmV4Withdraw",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee",TransferTip:"TransferTip"};var Ar=require("@solana/spl-token"),Pr=Se("Raydium_txUtil"),Tr=1644;function Sn(i){let e=[],t=[];return i.microLamports&&(e.push(Oe.ComputeBudgetProgram.setComputeUnitPrice({microLamports:i.microLamports})),t.push(me.SetComputeUnitPrice)),i.units&&(e.push(Oe.ComputeBudgetProgram.setComputeUnitLimit({units:i.units})),t.push(me.SetComputeUnitLimit)),{instructions:e,instructionTypes:t}}async function Ot(i,e){var n,r;let t=e!=null?e:"confirmed";return(r=await((n=i.getLatestBlockhash)==null?void 0:n.call(i,{commitment:t})))==null?void 0:r.blockh