@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 368 kB
JavaScript
var Jc=Object.create;var Po=Object.defineProperty,el=Object.defineProperties,tl=Object.getOwnPropertyDescriptor,nl=Object.getOwnPropertyDescriptors,ol=Object.getOwnPropertyNames,br=Object.getOwnPropertySymbols,rl=Object.getPrototypeOf,_i=Object.prototype.hasOwnProperty,Ea=Object.prototype.propertyIsEnumerable;var Fa=(r,e,t)=>e in r?Po(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e)=>{for(var t in e||(e={}))_i.call(e,t)&&Fa(r,t,e[t]);if(br)for(var t of br(e))Ea.call(e,t)&&Fa(r,t,e[t]);return r},E=(r,e)=>el(r,nl(e));var Me=(r,e)=>{var t={};for(var n in r)_i.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&br)for(var n of br(r))e.indexOf(n)<0&&Ea.call(r,n)&&(t[n]=r[n]);return t};var il=(r,e)=>{for(var t in e)Po(r,t,{get:e[t],enumerable:!0})},Da=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ol(e))!_i.call(r,o)&&o!==t&&Po(r,o,{get:()=>e[o],enumerable:!(n=tl(e,o))||n.enumerable});return r};var ce=(r,e,t)=>(t=r!=null?Jc(rl(r)):{},Da(e||!r||!r.__esModule?Po(t,"default",{value:r,enumerable:!0}):t,r)),sl=r=>Da(Po({},"__esModule",{value:!0}),r);var Sd={};il(Sd,{AMM_CONFIG_SEED:()=>kc,BIT_PRECISION:()=>Zs,Clmm:()=>uo,ClmmConfigLayout:()=>aa,ClmmInstrument:()=>Ce,ConstantProductCurve:()=>tr,CpmmConfigInfoLayout:()=>Ia,CpmmFee:()=>er,CpmmPoolInfoLayout:()=>ar,CurveCalculator:()=>or,DataElement:()=>fc,EXTENSION_TICKARRAY_BITMAP_SIZE:()=>hi,FARM_LOCK_MINT:()=>Is,FARM_LOCK_VAULT:()=>Bs,FARM_PROGRAM_TO_VERSION:()=>wt,FARM_VERSION_TO_LEDGER_LAYOUT:()=>Ss,FARM_VERSION_TO_STATE_LAYOUT:()=>xs,FEE_RATE_DENOMINATOR:()=>Yo,FEE_RATE_DENOMINATOR_VALUE:()=>Ii,FETCH_TICKARRAY_COUNT:()=>Oc,Fee:()=>Rc,LIQUIDITY_FEES_DENOMINATOR:()=>Ho,LIQUIDITY_FEES_NUMERATOR:()=>ki,LIQUIDITY_VERSION_TO_SERUM_VERSION:()=>Fc,LIQUIDITY_VERSION_TO_STATE_LAYOUT:()=>Wm,LOG_B_2_X32:()=>$s,LOG_B_P_ERR_MARGIN_LOWER_X64:()=>Js,LOG_B_P_ERR_MARGIN_UPPER_X64:()=>ea,LiquidityMath:()=>me,MARKET_STATE_LAYOUT_V2:()=>Ci,MARKET_STATE_LAYOUT_V3:()=>Si,MARKET_VERSION_TO_STATE_LAYOUT:()=>Ka,MAX_SQRT_PRICE_X64:()=>Tt,MAX_SQRT_PRICE_X64_SUB_ONE:()=>Qo,MAX_TICK:()=>rt,MIN_SQRT_PRICE_X64:()=>kt,MIN_SQRT_PRICE_X64_ADD_ONE:()=>zo,MIN_TICK:()=>Ze,MODEL_DATA_PUBKEY:()=>On,Market:()=>cr,MathUtil:()=>oe,MaxU64:()=>Pi,MaxUint128:()=>Hs,NEGATIVE_ONE:()=>qt,OBSERVATION_SEED:()=>Cc,ONE:()=>yt,OPERATION_SEED:()=>Sc,ObservationInfoLayout:()=>ua,ObservationLayout:()=>Nc,OperationLayout:()=>ca,POOL_REWARD_VAULT_SEED:()=>Bc,POOL_SEED:()=>Tc,POOL_TICK_ARRAY_BITMAP_SEED:()=>Kc,POOL_VAULT_SEED:()=>Ic,POSITION_SEED:()=>zs,PoolInfoLayout:()=>gn,PoolUtils:()=>Le,PositionInfoLayout:()=>jo,PositionRewardInfoLayout:()=>_c,PositionUtils:()=>io,ProtocolPositionLayout:()=>sd,Q128:()=>Xo,Q64:()=>bt,Raydium:()=>fr,RewardInfo:()=>Mc,RoundDirection:()=>ga,SERUM_PROGRAMID_TO_VERSION:()=>xa,SERUM_VERSION_TO_PROGRAMID:()=>Sa,SOL_INFO:()=>Ot,SPL_MINT_LAYOUT:()=>_m,SqrtPriceMath:()=>te,StableLayout:()=>Rn,SwapMath:()=>bn,TICK_ARRAY_BITMAP_SIZE:()=>yn,TICK_ARRAY_SEED:()=>xc,TICK_ARRAY_SIZE:()=>Fe,TICK_SPACINGS:()=>td,TOKEN_WSOL:()=>Ve,TickArrayBitmap:()=>Ut,TickArrayBitmapExtensionLayout:()=>ia,TickArrayBitmapExtensionUtils:()=>ro,TickArrayLayout:()=>oo,TickLayout:()=>vc,TickMath:()=>An,TickQuery:()=>de,TickUtils:()=>Y,U64Resolution:()=>no,U64_IGNORE_RANGE:()=>od,Voter:()=>ks,VoterDepositEntry:()=>tc,VoterLockup:()=>ec,VoterRegistrar:()=>hs,VoterVotingMintConfig:()=>Ju,ZERO:()=>fe,addLiquidityLayout:()=>fi,associatedLedgerAccountLayout:()=>Yr,calFarmRewardAmount:()=>ai,ceilDiv:()=>Gc,claimLayout:()=>bo,clmmComputeInfoToApiInfo:()=>ra,closeAccountInstruction:()=>vt,createAssociatedLedgerAccountInstruction:()=>Yn,createPoolFeeLayout:()=>_s,createPoolV4InstructionV2:()=>Ws,createPoolV4Layout:()=>Dm,createWSolAccountInstructions:()=>Wt,dwLayout:()=>nt,farmAddRewardLayout:()=>$r,farmLedgerLayoutV3_1:()=>Sm,farmLedgerLayoutV3_2:()=>zn,farmLedgerLayoutV5_1:()=>Km,farmLedgerLayoutV5_2:()=>ws,farmLedgerLayoutV6_1:()=>Ps,farmRewardInfoToConfig:()=>Cs,farmRewardLayout:()=>Hr,farmRewardRestartLayout:()=>Zr,farmRewardTimeInfoLayout:()=>$u,farmStateV3Layout:()=>gs,farmStateV5Layout:()=>As,farmStateV6Layout:()=>Xn,fetchMultipleFarmInfoAndUpdate:()=>Cm,fetchMultipleInfo:()=>ud,fixedSwapInLayout:()=>mi,fixedSwapOutLayout:()=>di,floorDiv:()=>ya,formatLayout:()=>Ac,generatePubKey:()=>ut,getAssociatedAuthority:()=>Ks,getAssociatedConfigId:()=>Zo,getAssociatedLedgerAccount:()=>He,getAssociatedLedgerPoolAccount:()=>Qn,getAssociatedOpenOrders:()=>Uc,getAssociatedPoolKeys:()=>fa,getCpmmPdaAmmConfigId:()=>bd,getCpmmPdaPoolId:()=>Xc,getCreatePoolKeys:()=>wa,getDepositEntryIndex:()=>ui,getDxByDyBaseIn:()=>Fs,getDyByDxBaseIn:()=>Vs,getFarmLedgerLayout:()=>Kn,getFarmStateLayout:()=>nc,getLiquidityAssociatedAuthority:()=>Ti,getLiquidityAssociatedId:()=>wn,getLiquidityFromAmounts:()=>rd,getPdaAmmConfigId:()=>ed,getPdaExBitmapAccount:()=>lt,getPdaLpMint:()=>zc,getPdaMetadataKey:()=>Go,getPdaObservationAccount:()=>js,getPdaObservationId:()=>rr,getPdaOperationAccount:()=>to,getPdaPersonalPositionAddress:()=>Pt,getPdaPoolAuthority:()=>Nn,getPdaPoolId:()=>Qs,getPdaPoolRewardVaulId:()=>Ys,getPdaPoolVaultId:()=>wi,getPdaProtocolPositionAddress:()=>fn,getPdaTickArrayAddress:()=>ke,getPdaVault:()=>Aa,getRegistrarAddress:()=>ti,getStablePrice:()=>Es,getTokenOwnerRecordAddress:()=>si,getVoterAddress:()=>ri,getVoterWeightRecordAddress:()=>ii,getVotingMintAuthority:()=>oi,getVotingTokenMint:()=>ni,governanceCreateTokenOwnerRecord:()=>ac,i16ToBytes:()=>$m,i32ToBytes:()=>Uo,initPoolLayout:()=>pi,initTokenAccountInstruction:()=>Qr,initializeMarket:()=>jc,isValidFarmVersion:()=>Jr,isZero:()=>eo,judgeFarmType:()=>Rm,leadingZeros:()=>gi,leastSignificantBit:()=>Xs,liquidityStateV4Layout:()=>Jn,liquidityStateV5Layout:()=>dc,makeAMMSwapInstruction:()=>qo,makeAddLiquidityInstruction:()=>Ds,makeAddNewRewardInstruction:()=>li,makeClaimInstruction:()=>dr,makeClaimInstructionV4:()=>Ni,makeCreateCpmmPoolInInstruction:()=>Pa,makeCreateFarmInstruction:()=>Rs,makeCreateMarketInstruction:()=>Na,makeCreatorWithdrawFarmRewardInstruction:()=>Os,makeDepositCpmmInInstruction:()=>ha,makeDepositInstructionV3:()=>Ls,makeDepositInstructionV5:()=>Ns,makeDepositInstructionV6:()=>Ms,makeDepositTokenInstruction:()=>Lm,makeDepositWithdrawInstruction:()=>Mm,makeInitPoolInstructionV4:()=>Zm,makePurchaseInstruction:()=>Id,makeRestartRewardInstruction:()=>ci,makeSimulatePoolInfoInstruction:()=>qs,makeSwapCpmmBaseInInInstruction:()=>sr,makeSwapCpmmBaseOutInInstruction:()=>Ta,makeSwapFixedInInstruction:()=>Pc,makeSwapFixedOutInstruction:()=>hc,makeSwapInstruction:()=>Ba,makeTransferInstruction:()=>Gn,makeWithdrawCpmmInInstruction:()=>ka,makeWithdrawInstructionV3:()=>Zn,makeWithdrawInstructionV5:()=>Hn,makeWithdrawInstructionV6:()=>jn,makeWithdrawTokenInstruction:()=>Nm,mockCreatePoolInfo:()=>nd,mockV3CreatePoolInfo:()=>ta,modelDataInfoLayout:()=>yc,mostSignificantBit:()=>Gs,parseTokenAccountResp:()=>bs,parseTokenInfo:()=>vm,poolTypeV6:()=>Zt,purchaseLayout:()=>Oi,realFarmStateV3Layout:()=>ju,realFarmStateV5Layout:()=>Hu,realFarmV6Layout:()=>Zu,removeLiquidityInstruction:()=>bi,removeLiquidityLayout:()=>yi,route1Instruction:()=>Pd,route2Instruction:()=>hd,routeInstruction:()=>Qc,simulatePoolInfoInstruction:()=>Hm,solToWSolToken:()=>Fm,splAccountLayout:()=>Ht,toAmmComputePoolInfo:()=>$o,toApiV3Token:()=>ot,toFeeConfig:()=>$t,toToken:()=>Wo,toTokenAmount:()=>$n,toTokenInfo:()=>Vm,trailingZeros:()=>Ai,u16ToBytes:()=>Us,u32ToBytes:()=>Jm,unionArr:()=>xd,updateFarmPoolInfo:()=>oc,validateFarmRewards:()=>ei,voterStakeRegistryCreateDepositEntry:()=>cc,voterStakeRegistryCreateVoter:()=>uc,voterStakeRegistryDeposit:()=>rc,voterStakeRegistryUpdateVoterWeightRecord:()=>ic,voterStakeRegistryWithdraw:()=>sc,wSolToSolToken:()=>Em,withdrawRewardLayout:()=>jr});module.exports=sl(Sd);var Zc=require("lodash");var ss=ce(require("axios"));var ho=require("lodash");var vi=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}},Wa={},al={};function le(r){let e=(0,ho.get)(Wa,r);if(!e){let t=(0,ho.get)(al,r);e=new vi({name:r,logLevel:t}),(0,ho.set)(Wa,r,e)}return e}var fu=require("@solana/web3.js"),yu=ce(require("bn.js"));var pu=ce(require("big.js")),So=ce(require("bn.js"));var at=ce(require("bn.js"));var Vn=9e15,un=1e9,Vi="0123456789abcdef",Ar="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",wr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Fi={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Vn,maxE:Vn,crypto:!1},Xa,zt,re=!0,hr="[DecimalError] ",an=hr+"Invalid argument: ",za=hr+"Precision limit exceeded",Qa=hr+"crypto unavailable",Ya="[object Decimal]",et=Math.floor,Ee=Math.pow,ul=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,cl=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,ll=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ja=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Rt=1e7,ne=7,ml=9007199254740991,dl=Ar.length-1,Ei=wr.length-1,M={toStringTag:Ya};M.absoluteValue=M.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),$(r)};M.ceil=function(){return $(new this.constructor(this),this.e+1,2)};M.clampedTo=M.clamp=function(r,e){var t,n=this,o=n.constructor;if(r=new o(r),e=new o(e),!r.s||!e.s)return new o(NaN);if(r.gt(e))throw Error(an+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new o(n)};M.comparedTo=M.cmp=function(r){var e,t,n,o,i=this,s=i.d,a=(r=new i.constructor(r)).d,c=i.s,u=r.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(i.e!==r.e)return i.e>r.e^c<0?1:-1;for(n=s.length,o=a.length,e=0,t=n<o?n:o;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return n===o?0:n>o^c<0?1:-1};M.cosine=M.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+ne,n.rounding=1,t=pl(n,eu(n,t)),n.precision=r,n.rounding=e,$(zt==2||zt==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};M.cubeRoot=M.cbrt=function(){var r,e,t,n,o,i,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(re=!1,i=l.s*Ee(l.s*l,1/3),!i||Math.abs(i)==1/0?(t=ze(l.d),r=l.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Ee(t,1/3),r=et((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new m(t),n.s=l.s):n=new m(i.toString()),s=(r=m.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=xe(u.plus(l).times(a),u.plus(c),s+2,1),ze(a.d).slice(0,s)===(t=ze(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!o&&t=="4999"){if(!o&&($(a,r+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&($(n,r+1,1),e=!n.times(n).times(n).eq(l));break}return re=!0,$(n,r,m.rounding,e)};M.decimalPlaces=M.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-et(this.e/ne))*ne,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};M.dividedBy=M.div=function(r){return xe(this,new this.constructor(r))};M.dividedToIntegerBy=M.divToInt=function(r){var e=this,t=e.constructor;return $(xe(e,new t(r),0,1,1),t.precision,t.rounding)};M.equals=M.eq=function(r){return this.cmp(r)===0};M.floor=function(){return $(new this.constructor(this),this.e+1,3)};M.greaterThan=M.gt=function(r){return this.cmp(r)>0};M.greaterThanOrEqualTo=M.gte=function(r){var e=this.cmp(r);return e==1||e===0};M.hyperbolicCosine=M.cosh=function(){var r,e,t,n,o,i=this,s=i.constructor,a=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return a;t=s.precision,n=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,o=i.d.length,o<32?(r=Math.ceil(o/3),e=(1/Tr(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=Fn(s,1,i.times(e),new s(1),!0);for(var c,u=r,l=new s(8);u--;)c=i.times(i),i=a.minus(c.times(l.minus(c.times(l))));return $(i,s.precision=t,s.rounding=n,!0)};M.hyperbolicSine=M.sinh=function(){var r,e,t,n,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(o.e,o.sd())+4,i.rounding=1,n=o.d.length,n<3)o=Fn(i,2,o,o,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,o=o.times(1/Tr(5,r)),o=Fn(i,2,o,o,!0);for(var s,a=new i(5),c=new i(16),u=new i(20);r--;)s=o.times(o),o=o.times(a.plus(s.times(c.times(s).plus(u))))}return i.precision=e,i.rounding=t,$(o,e,t,!0)};M.hyperbolicTangent=M.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,xe(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};M.inverseCosine=M.acos=function(){var r,e=this,t=e.constructor,n=e.abs().cmp(1),o=t.precision,i=t.rounding;return n!==-1?n===0?e.isNeg()?Ct(t,o,i):new t(0):new t(NaN):e.isZero()?Ct(t,o+4,i).times(.5):(t.precision=o+6,t.rounding=1,e=e.asin(),r=Ct(t,o+4,i).times(.5),t.precision=o,t.rounding=i,r.minus(e))};M.inverseHyperbolicCosine=M.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,re=!1,t=t.times(t).minus(1).sqrt().plus(t),re=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};M.inverseHyperbolicSine=M.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,re=!1,t=t.times(t).plus(1).sqrt().plus(t),re=!0,n.precision=r,n.rounding=e,t.ln())};M.inverseHyperbolicTangent=M.atanh=function(){var r,e,t,n,o=this,i=o.constructor;return o.isFinite()?o.e>=0?new i(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(r=i.precision,e=i.rounding,n=o.sd(),Math.max(n,r)<2*-o.e-1?$(new i(o),r,e,!0):(i.precision=t=n-o.e,o=xe(o.plus(1),new i(1).minus(o),t+r,1),i.precision=r+4,i.rounding=1,o=o.ln(),i.precision=r,i.rounding=e,o.times(.5))):new i(NaN)};M.inverseSine=M.asin=function(){var r,e,t,n,o=this,i=o.constructor;return o.isZero()?new i(o):(e=o.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=Ct(i,t+4,n).times(.5),r.s=o.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,o.times(2)))};M.inverseTangent=M.atan=function(){var r,e,t,n,o,i,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<=Ei)return s=Ct(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=Ei)return s=Ct(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/ne+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(re=!1,e=Math.ceil(a/ne),n=1,c=u.times(u),s=new l(u),o=u;r!==-1;)if(o=o.times(c),i=s.minus(o.div(n+=2)),o=o.times(c),s=i.plus(o.div(n+=2)),s.d[e]!==void 0)for(r=e;s.d[r]===i.d[r]&&r--;);return t&&(s=s.times(2<<t-1)),re=!0,$(s,l.precision=m,l.rounding=d,!0)};M.isFinite=function(){return!!this.d};M.isInteger=M.isInt=function(){return!!this.d&&et(this.e/ne)>this.d.length-2};M.isNaN=function(){return!this.s};M.isNegative=M.isNeg=function(){return this.s<0};M.isPositive=M.isPos=function(){return this.s>0};M.isZero=function(){return!!this.d&&this.d[0]===0};M.lessThan=M.lt=function(r){return this.cmp(r)<0};M.lessThanOrEqualTo=M.lte=function(r){return this.cmp(r)<1};M.logarithm=M.log=function(r){var e,t,n,o,i,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,p=5;if(r==null)r=new l(10),e=!0;else{if(r=new l(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new l(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new l(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(o=t[0];o%10===0;)o/=10;i=o!==1}if(re=!1,a=m+p,s=sn(u,a),n=e?Pr(l,a+10):sn(r,a),c=xe(s,n,a,1),ko(c.d,o=m,d))do if(a+=10,s=sn(u,a),n=e?Pr(l,a+10):sn(r,a),c=xe(s,n,a,1),!i){+ze(c.d).slice(o+1,o+15)+1==1e14&&(c=$(c,m+1,0));break}while(ko(c.d,o+=10,d));return re=!0,$(c,m,d)};M.minus=M.sub=function(r){var e,t,n,o,i,s,a,c,u,l,m,d,p=this,y=p.constructor;if(r=new y(r),!p.d||!r.d)return!p.s||!r.s?r=new y(NaN):p.d?r.s=-r.s:r=new y(r.d||p.s!==r.s?p:NaN),r;if(p.s!=r.s)return r.s=-r.s,p.plus(r);if(u=p.d,d=r.d,a=y.precision,c=y.rounding,!u[0]||!d[0]){if(d[0])r.s=-r.s;else if(u[0])r=new y(p);else return new y(c===3?-0:0);return re?$(r,a,c):r}if(t=et(r.e/ne),l=et(p.e/ne),u=u.slice(),i=l-t,i){for(m=i<0,m?(e=u,i=-i,s=d.length):(e=d,t=l,s=u.length),n=Math.max(Math.ceil(a/ne),s)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=u.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(u[n]!=d[n]){m=u[n]<d[n];break}i=0}for(m&&(e=u,u=d,d=e,r.s=-r.s),s=u.length,n=d.length-s;n>0;--n)u[s++]=0;for(n=d.length;n>i;){if(u[--n]<d[n]){for(o=n;o&&u[--o]===0;)u[o]=Rt-1;--u[o],u[n]+=Rt}u[n]-=d[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=kr(u,t),re?$(r,a,c):r):new y(c===3?-0:0)};M.modulo=M.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?$(new n(t),n.precision,n.rounding):(re=!1,n.modulo==9?(e=xe(t,r.abs(),0,3,1),e.s*=r.s):e=xe(t,r,0,n.modulo,1),e=e.times(r),re=!0,t.minus(e))};M.naturalExponential=M.exp=function(){return Di(this)};M.naturalLogarithm=M.ln=function(){return sn(this)};M.negated=M.neg=function(){var r=new this.constructor(this);return r.s=-r.s,$(r)};M.plus=M.add=function(r){var e,t,n,o,i,s,a,c,u,l,m=this,d=m.constructor;if(r=new d(r),!m.d||!r.d)return!m.s||!r.s?r=new d(NaN):m.d||(r=new d(r.d||m.s===r.s?m:NaN)),r;if(m.s!=r.s)return r.s=-r.s,m.minus(r);if(u=m.d,l=r.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(r=new d(m)),re?$(r,a,c):r;if(i=et(m.e/ne),n=et(r.e/ne),u=u.slice(),o=i-n,o){for(o<0?(t=u,o=-o,s=l.length):(t=l,n=i,s=u.length),i=Math.ceil(a/ne),s=i>s?i+1:s+1,o>s&&(o=s,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,t=l,l=u,u=t),e=0;o;)e=(u[--o]=u[o]+l[o]+e)/Rt|0,u[o]%=Rt;for(e&&(u.unshift(e),++n),s=u.length;u[--s]==0;)u.pop();return r.d=u,r.e=kr(u,n),re?$(r,a,c):r};M.precision=M.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(an+r);return t.d?(e=Ha(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};M.round=function(){var r=this,e=r.constructor;return $(new e(r),r.e+1,e.rounding)};M.sine=M.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+ne,n.rounding=1,t=yl(n,eu(n,t)),n.precision=r,n.rounding=e,$(zt>2?t.neg():t,r,e,!0)):new n(NaN)};M.squareRoot=M.sqrt=function(){var r,e,t,n,o,i,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(re=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=ze(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=et((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),n=new l(e)):n=new l(u.toString()),t=(c=l.precision)+3;;)if(i=n,n=i.plus(xe(s,i,t+2,1)).times(.5),ze(i.d).slice(0,t)===(e=ze(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!o&&e=="4999"){if(!o&&($(i,c+1,0),i.times(i).eq(s))){n=i;break}t+=4,o=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&($(n,c+1,1),r=!n.times(n).eq(s));break}return re=!0,$(n,c,l.rounding,r)};M.tangent=M.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=xe(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,$(zt==2||zt==4?t.neg():t,r,e,!0)):new n(NaN)};M.times=M.mul=function(r){var e,t,n,o,i,s,a,c,u,l=this,m=l.constructor,d=l.d,p=(r=new m(r)).d;if(r.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!r.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?r.s/0:r.s*0);for(t=et(l.e/ne)+et(r.e/ne),c=d.length,u=p.length,c<u&&(i=d,d=p,p=i,s=c,c=u,u=s),i=[],s=c+u,n=s;n--;)i.push(0);for(n=u;--n>=0;){for(e=0,o=c+n;o>n;)a=i[o]+p[n]*d[o-n-1]+e,i[o--]=a%Rt|0,e=a/Rt|0;i[o]=(i[o]+e)%Rt|0}for(;!i[--s];)i.pop();return e?++t:i.shift(),r.d=i,r.e=kr(i,t),re?$(r,m.precision,m.rounding):r};M.toBinary=function(r,e){return qi(this,2,r,e)};M.toDecimalPlaces=M.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(dt(r,0,un),e===void 0?e=n.rounding:dt(e,0,8),$(t,r+t.e+1,e))};M.toExponential=function(r,e){var t,n=this,o=n.constructor;return r===void 0?t=Dt(n,!0):(dt(r,0,un),e===void 0?e=o.rounding:dt(e,0,8),n=$(new o(n),r+1,e),t=Dt(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};M.toFixed=function(r,e){var t,n,o=this,i=o.constructor;return r===void 0?t=Dt(o):(dt(r,0,un),e===void 0?e=i.rounding:dt(e,0,8),n=$(new i(o),r+o.e+1,e),t=Dt(n,!1,r+n.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};M.toFraction=function(r){var e,t,n,o,i,s,a,c,u,l,m,d,p=this,y=p.d,f=p.constructor;if(!y)return new f(p);if(u=t=new f(1),n=c=new f(0),e=new f(n),i=e.e=Ha(y)-p.e-1,s=i%ne,e.d[0]=Ee(10,s<0?ne+s:s),r==null)r=i>0?e:u;else{if(a=new f(r),!a.isInt()||a.lt(u))throw Error(an+a);r=a.gt(e)?i>0?e:u:a}for(re=!1,a=new f(ze(y)),l=f.precision,f.precision=i=y.length*ne*2;m=xe(a,e,0,1,1),o=t.plus(m.times(n)),o.cmp(r)!=1;)t=n,n=o,o=u,u=c.plus(m.times(o)),c=o,o=e,e=a.minus(m.times(o)),a=o;return o=xe(r.minus(t),n,0,1,1),c=c.plus(o.times(u)),t=t.plus(o.times(n)),c.s=u.s=p.s,d=xe(u,n,i,1).minus(p).abs().cmp(xe(c,t,i,1).minus(p).abs())<1?[u,n]:[c,t],f.precision=l,re=!0,d};M.toHexadecimal=M.toHex=function(r,e){return qi(this,16,r,e)};M.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:dt(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(re=!1,t=xe(t,r,0,e,1).times(r),re=!0,$(t)):(r.s=t.s,t=r),t};M.toNumber=function(){return+this};M.toOctal=function(r,e){return qi(this,8,r,e)};M.toPower=M.pow=function(r){var e,t,n,o,i,s,a=this,c=a.constructor,u=+(r=new c(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new c(Ee(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,i=c.rounding,r.eq(1))return $(a,n,i);if(e=et(r.e/ne),e>=r.d.length-1&&(t=u<0?-u:u)<=ml)return o=Za(c,a,t,n),r.s<0?new c(1).div(o):$(o,n,i);if(s=a.s,s<0){if(e<r.d.length-1)return new c(NaN);if((r.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=Ee(+a,u),e=t==0||!isFinite(t)?et(u*(Math.log("0."+ze(a.d))/Math.LN10+a.e+1)):new c(t+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(re=!1,c.rounding=a.s=1,t=Math.min(12,(e+"").length),o=Di(r.times(sn(a,n+t)),n),o.d&&(o=$(o,n+5,1),ko(o.d,n,i)&&(e=n+10,o=$(Di(r.times(sn(a,e+t)),e),e+5,1),+ze(o.d).slice(n+1,n+15)+1==1e14&&(o=$(o,n+1,0)))),o.s=s,re=!0,c.rounding=i,$(o,n,i))};M.toPrecision=function(r,e){var t,n=this,o=n.constructor;return r===void 0?t=Dt(n,n.e<=o.toExpNeg||n.e>=o.toExpPos):(dt(r,1,un),e===void 0?e=o.rounding:dt(e,0,8),n=$(new o(n),r,e),t=Dt(n,r<=n.e||n.e<=o.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};M.toSignificantDigits=M.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(dt(r,1,un),e===void 0?e=n.rounding:dt(e,0,8)),$(new n(t),r,e)};M.toString=function(){var r=this,e=r.constructor,t=Dt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};M.truncated=M.trunc=function(){return $(new this.constructor(this),this.e+1,1)};M.valueOf=M.toJSON=function(){var r=this,e=r.constructor,t=Dt(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function ze(r){var e,t,n,o=r.length-1,i="",s=r[0];if(o>0){for(i+=s,e=1;e<o;e++)n=r[e]+"",t=ne-n.length,t&&(i+=rn(t)),i+=n;s=r[e],n=s+"",t=ne-n.length,t&&(i+=rn(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function dt(r,e,t){if(r!==~~r||r<e||r>t)throw Error(an+r)}function ko(r,e,t,n){var o,i,s,a;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=ne,o=0):(o=Math.ceil((e+1)/ne),e%=ne),i=Ee(10,ne-e),a=r[o]%i|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==i||t>3&&a+1==i/2)&&(r[o+1]/i/100|0)==Ee(10,e-2)-1||(a==i/2||a==0)&&(r[o+1]/i/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==i||!n&&t>3&&a+1==i/2)&&(r[o+1]/i/1e3|0)==Ee(10,e-3)-1,s}function gr(r,e,t){for(var n,o=[0],i,s=0,a=r.length;s<a;){for(i=o.length;i--;)o[i]*=e;for(o[0]+=Vi.indexOf(r.charAt(s++)),n=0;n<o.length;n++)o[n]>t-1&&(o[n+1]===void 0&&(o[n+1]=0),o[n+1]+=o[n]/t|0,o[n]%=t)}return o.reverse()}function pl(r,e){var t,n,o;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),o=(1/Tr(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),r.precision+=t,e=Fn(r,1,e.times(o),new r(1));for(var i=t;i--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return r.precision-=t,e}var xe=function(){function r(n,o,i){var s,a=0,c=n.length;for(n=n.slice();c--;)s=n[c]*o+a,n[c]=s%i|0,a=s/i|0;return a&&n.unshift(a),n}function e(n,o,i,s){var a,c;if(i!=s)c=i>s?1:-1;else for(a=c=0;a<i;a++)if(n[a]!=o[a]){c=n[a]>o[a]?1:-1;break}return c}function t(n,o,i,s){for(var a=0;i--;)n[i]-=a,a=n[i]<o[i]?1:0,n[i]=a*s+n[i]-o[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,o,i,s,a,c){var u,l,m,d,p,y,f,b,g,w,A,k,I,T,S,x,R,B,L,D,v=n.constructor,Z=n.s==o.s?1:-1,X=n.d,U=o.d;if(!X||!X[0]||!U||!U[0])return new v(!n.s||!o.s||(X?U&&X[0]==U[0]:!U)?NaN:X&&X[0]==0||!U?Z*0:Z/0);for(c?(p=1,l=n.e-o.e):(c=Rt,p=ne,l=et(n.e/p)-et(o.e/p)),L=U.length,R=X.length,g=new v(Z),w=g.d=[],m=0;U[m]==(X[m]||0);m++);if(U[m]>(X[m]||0)&&l--,i==null?(T=i=v.precision,s=v.rounding):a?T=i+(n.e-o.e)+1:T=i,T<0)w.push(1),y=!0;else{if(T=T/p+2|0,m=0,L==1){for(d=0,U=U[0],T++;(m<R||d)&&T--;m++)S=d*c+(X[m]||0),w[m]=S/U|0,d=S%U|0;y=d||m<R}else{for(d=c/(U[0]+1)|0,d>1&&(U=r(U,d,c),X=r(X,d,c),L=U.length,R=X.length),x=L,A=X.slice(0,L),k=A.length;k<L;)A[k++]=0;D=U.slice(),D.unshift(0),B=U[0],U[1]>=c/2&&++B;do d=0,u=e(U,A,L,k),u<0?(I=A[0],L!=k&&(I=I*c+(A[1]||0)),d=I/B|0,d>1?(d>=c&&(d=c-1),f=r(U,d,c),b=f.length,k=A.length,u=e(f,A,b,k),u==1&&(d--,t(f,L<b?D:U,b,c))):(d==0&&(u=d=1),f=U.slice()),b=f.length,b<k&&f.unshift(0),t(A,f,k,c),u==-1&&(k=A.length,u=e(U,A,L,k),u<1&&(d++,t(A,L<k?D:U,k,c))),k=A.length):u===0&&(d++,A=[0]),w[m++]=d,u&&A[0]?A[k++]=X[x]||0:(A=[X[x]],k=1);while((x++<R||A[0]!==void 0)&&T--);y=A[0]!==void 0}w[0]||w.shift()}if(p==1)g.e=l,Xa=y;else{for(m=1,d=w[0];d>=10;d/=10)m++;g.e=m+l*p-1,$(g,a?i+g.e+1:i,s,y)}return g}}();function $(r,e,t,n){var o,i,s,a,c,u,l,m,d,p=r.constructor;e:if(e!=null){if(m=r.d,!m)return r;for(o=1,a=m[0];a>=10;a/=10)o++;if(i=e-o,i<0)i+=ne,s=e,l=m[d=0],c=l/Ee(10,o-s-1)%10|0;else if(d=Math.ceil((i+1)/ne),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=c=0,o=1,i%=ne,s=i-ne+1}else break e;else{for(l=a=m[d],o=1;a>=10;a/=10)o++;i%=ne,s=i-ne+o,c=s<0?0:l/Ee(10,o-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%Ee(10,o-s-1)),u=t<4?(c||n)&&(t==0||t==(r.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(i>0?s>0?l/Ee(10,o-s):0:m[d-1])%10&1||t==(r.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=r.e+1,m[0]=Ee(10,(ne-e%ne)%ne),r.e=-e||0):m[0]=r.e=0,r;if(i==0?(m.length=d,a=1,d--):(m.length=d+1,a=Ee(10,ne-i),m[d]=s>0?(l/Ee(10,o-s)%Ee(10,s)|0)*a:0),u)for(;;)if(d==0){for(i=1,s=m[0];s>=10;s/=10)i++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;i!=a&&(r.e++,m[0]==Rt&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=Rt)break;m[d--]=0,a=1}for(i=m.length;m[--i]===0;)m.pop()}return re&&(r.e>p.maxE?(r.d=null,r.e=NaN):r.e<p.minE&&(r.e=0,r.d=[0])),r}function Dt(r,e,t){if(!r.isFinite())return Ja(r);var n,o=r.e,i=ze(r.d),s=i.length;return e?(t&&(n=t-s)>0?i=i.charAt(0)+"."+i.slice(1)+rn(n):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):o<0?(i="0."+rn(-o-1)+i,t&&(n=t-s)>0&&(i+=rn(n))):o>=s?(i+=rn(o+1-s),t&&(n=t-o-1)>0&&(i=i+"."+rn(n))):((n=o+1)<s&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-s)>0&&(o+1===s&&(i+="."),i+=rn(n))),i}function kr(r,e){var t=r[0];for(e*=ne;t>=10;t/=10)e++;return e}function Pr(r,e,t){if(e>dl)throw re=!0,t&&(r.precision=t),Error(za);return $(new r(Ar),e,1,!0)}function Ct(r,e,t){if(e>Ei)throw Error(za);return $(new r(wr),e,t,!0)}function Ha(r){var e=r.length-1,t=e*ne+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function rn(r){for(var e="";r--;)e+="0";return e}function Za(r,e,t,n){var o,i=new r(1),s=Math.ceil(n/ne+4);for(re=!1;;){if(t%2&&(i=i.times(e),Ua(i.d,s)&&(o=!0)),t=et(t/2),t===0){t=i.d.length-1,o&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Ua(e.d,s)}return re=!0,i}function qa(r){return r.d[r.d.length-1]&1}function $a(r,e,t){for(var n,o=new r(e[0]),i=0;++i<e.length;)if(n=new r(e[i]),n.s)o[t](n)&&(o=n);else{o=n;break}return o}function Di(r,e){var t,n,o,i,s,a,c,u=0,l=0,m=0,d=r.constructor,p=d.rounding,y=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(e==null?(re=!1,c=y):c=e,a=new d(.03125);r.e>-2;)r=r.times(a),m+=5;for(n=Math.log(Ee(2,m))/Math.LN10*2+5|0,c+=n,t=i=s=new d(1),d.precision=c;;){if(i=$(i.times(r),c,1),t=t.times(++l),a=s.plus(xe(i,t,c,1)),ze(a.d).slice(0,c)===ze(s.d).slice(0,c)){for(o=m;o--;)s=$(s.times(s),c,1);if(e==null)if(u<3&&ko(s.d,c-n,p,u))d.precision=c+=10,t=i=a=new d(1),l=0,u++;else return $(s,d.precision=y,p,re=!0);else return d.precision=y,s}s=a}}function sn(r,e){var t,n,o,i,s,a,c,u,l,m,d,p=1,y=10,f=r,b=f.d,g=f.constructor,w=g.rounding,A=g.precision;if(f.s<0||!b||!b[0]||!f.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:f.s!=1?NaN:b?0:f);if(e==null?(re=!1,l=A):l=e,g.precision=l+=y,t=ze(b),n=t.charAt(0),Math.abs(i=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(r),t=ze(f.d),n=t.charAt(0),p++;i=f.e,n>1?(f=new g("0."+t),i++):f=new g(n+"."+t.slice(1))}else return u=Pr(g,l+2,A).times(i+""),f=sn(new g(n+"."+t.slice(1)),l-y).plus(u),g.precision=A,e==null?$(f,A,w,re=!0):f;for(m=f,c=s=f=xe(f.minus(1),f.plus(1),l,1),d=$(f.times(f),l,1),o=3;;){if(s=$(s.times(d),l,1),u=c.plus(xe(s,new g(o),l,1)),ze(u.d).slice(0,l)===ze(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(Pr(g,l+2,A).times(i+""))),c=xe(c,new g(p),l,1),e==null)if(ko(c.d,l-y,w,a))g.precision=l+=y,u=s=f=xe(m.minus(1),m.plus(1),l,1),d=$(f.times(f),l,1),o=a=1;else return $(c,g.precision=A,w,re=!0);else return g.precision=A,c;c=u,o+=2}}function Ja(r){return String(r.s*r.s/0)}function Wi(r,e){var t,n,o;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(o=e.length;e.charCodeAt(o-1)===48;--o);if(e=e.slice(n,o),e){if(o-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%ne,t<0&&(n+=ne),n<o){for(n&&r.d.push(+e.slice(0,n)),o-=ne;n<o;)r.d.push(+e.slice(n,n+=ne));e=e.slice(n),n=ne-e.length}else n-=o;for(;n--;)e+="0";r.d.push(+e),re&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function fl(r,e){var t,n,o,i,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),ja.test(e))return Wi(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(cl.test(e))t=16,e=e.toLowerCase();else if(ul.test(e))t=2;else if(ll.test(e))t=8;else throw Error(an+e);for(i=e.search(/p/i),i>0?(c=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),s=i>=0,n=r.constructor,s&&(e=e.replace(".",""),a=e.length,i=a-i,o=Za(n,new n(t),i,i*2)),u=gr(e,t,Rt),l=u.length-1,i=l;u[i]===0;--i)u.pop();return i<0?new n(r.s*0):(r.e=kr(u,l),r.d=u,re=!1,s&&(r=xe(r,o,a*4)),c&&(r=r.times(Math.abs(c)<54?Ee(2,c):To.pow(2,c))),re=!0,r)}function yl(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:Fn(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Tr(5,t)),e=Fn(r,2,e,e);for(var o,i=new r(5),s=new r(16),a=new r(20);t--;)o=e.times(e),e=e.times(i.plus(o.times(s.times(o).minus(a))));return e}function Fn(r,e,t,n,o){var i,s,a,c,u=1,l=r.precision,m=Math.ceil(l/ne);for(re=!1,c=t.times(t),a=new r(n);;){if(s=xe(a.times(c),new r(e++*e++),l,1),a=o?n.plus(s):n.minus(s),n=xe(s.times(c),new r(e++*e++),l,1),s=a.plus(n),s.d[m]!==void 0){for(i=m;s.d[i]===a.d[i]&&i--;);if(i==-1)break}i=a,a=n,n=s,s=i,u++}return re=!0,s.d.length=m+1,s}function Tr(r,e){for(var t=r;--e;)t*=r;return t}function eu(r,e){var t,n=e.s<0,o=Ct(r,r.precision,1),i=o.times(.5);if(e=e.abs(),e.lte(i))return zt=n?4:1,e;if(t=e.divToInt(o),t.isZero())zt=n?3:2;else{if(e=e.minus(t.times(o)),e.lte(i))return zt=qa(t)?n?2:3:n?4:1,e;zt=qa(t)?n?1:4:n?3:2}return e.minus(o).abs()}function qi(r,e,t,n){var o,i,s,a,c,u,l,m,d,p=r.constructor,y=t!==void 0;if(y?(dt(t,1,un),n===void 0?n=p.rounding:dt(n,0,8)):(t=p.precision,n=p.rounding),!r.isFinite())l=Ja(r);else{for(l=Dt(r),s=l.indexOf("."),y?(o=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):o=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=gr(Dt(d),10,o),d.e=d.d.length),m=gr(l,10,o),i=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=y?"0p+0":"0";else{if(s<0?i--:(r=new p(r),r.d=m,r.e=i,r=xe(r,d,t,n,0,o),m=r.d,i=r.e,u=Xa),s=m[t],a=o/2,u=u||m[t+1]!==void 0,u=n<4?(s!==void 0||u)&&(n===0||n===(r.s<0?3:2)):s>a||s===a&&(n===4||u||n===6&&m[t-1]&1||n===(r.s<0?8:7)),m.length=t,u)for(;++m[--t]>o-1;)m[t]=0,t||(++i,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=Vi.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=gr(l,o,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Vi.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)l="0"+l;l="0."+l}else if(++i>c)for(i-=c;i--;)l+="0";else i<c&&(l=l.slice(0,i)+"."+l.slice(i))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return r.s<0?"-"+l:l}function Ua(r,e){if(r.length>e)return r.length=e,!0}function bl(r){return new this(r).abs()}function gl(r){return new this(r).acos()}function Al(r){return new this(r).acosh()}function wl(r,e){return new this(r).plus(e)}function Pl(r){return new this(r).asin()}function hl(r){return new this(r).asinh()}function kl(r){return new this(r).atan()}function Tl(r){return new this(r).atanh()}function Il(r,e){r=new this(r),e=new this(e);var t,n=this.precision,o=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=Ct(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?Ct(this,n,o):new this(0),t.s=r.s):!r.d||e.isZero()?(t=Ct(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(xe(r,e,i,1)),e=Ct(this,i,1),this.precision=n,this.rounding=o,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(xe(r,e,i,1)),t}function Bl(r){return new this(r).cbrt()}function xl(r){return $(r=new this(r),r.e+1,2)}function Sl(r,e,t){return new this(r).clamp(e,t)}function Kl(r){if(!r||typeof r!="object")throw Error(hr+"Object expected");var e,t,n,o=r.defaults===!0,i=["precision",1,un,"rounding",0,8,"toExpNeg",-Vn,0,"toExpPos",0,Vn,"maxE",0,Vn,"minE",-Vn,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],o&&(this[t]=Fi[t]),(n=r[t])!==void 0)if(et(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(an+t+": "+n);if(t="crypto",o&&(this[t]=Fi[t]),(n=r[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(Qa);else this[t]=!1;else throw Error(an+t+": "+n);return this}function Cl(r){return new this(r).cos()}function Rl(r){return new this(r).cosh()}function tu(r){var e,t,n;function o(i){var s,a,c,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,Ga(i)){u.s=i.s,re?!i.d||i.e>o.maxE?(u.e=NaN,u.d=null):i.e<o.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(s=0,a=i;a>=10;a/=10)s++;re?s>o.maxE?(u.e=NaN,u.d=null):s<o.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[i]):(u.e=s,u.d=[i]);return}else if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return Wi(u,i.toString())}else if(c!=="string")throw Error(an+i);return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),ja.test(i)?Wi(u,i):fl(u,i)}if(o.prototype=M,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Kl,o.clone=tu,o.isDecimal=Ga,o.abs=bl,o.acos=gl,o.acosh=Al,o.add=wl,o.asin=Pl,o.asinh=hl,o.atan=kl,o.atanh=Tl,o.atan2=Il,o.cbrt=Bl,o.ceil=xl,o.clamp=Sl,o.cos=Cl,o.cosh=Rl,o.div=Ol,o.exp=Ll,o.floor=Nl,o.hypot=Ml,o.ln=_l,o.log=vl,o.log10=Fl,o.log2=Vl,o.max=El,o.min=Dl,o.mod=Wl,o.mul=ql,o.pow=Ul,o.random=Gl,o.round=Xl,o.sign=zl,o.sin=Ql,o.sinh=Yl,o.sqrt=jl,o.sub=Hl,o.sum=Zl,o.tan=$l,o.tanh=Jl,o.trunc=em,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return o.config(r),o}function Ol(r,e){return new this(r).div(e)}function Ll(r){return new this(r).exp()}function Nl(r){return $(r=new this(r),r.e+1,3)}function Ml(){var r,e,t=new this(0);for(re=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return re=!0,new this(1/0);t=e}return re=!0,t.sqrt()}function Ga(r){return r instanceof To||r&&r.toStringTag===Ya||!1}function _l(r){return new this(r).ln()}function vl(r,e){return new this(r).log(e)}function Vl(r){return new this(r).log(2)}function Fl(r){return new this(r).log(10)}function El(){return $a(this,arguments,"lt")}function Dl(){return $a(this,arguments,"gt")}function Wl(r,e){return new this(r).mod(e)}function ql(r,e){return new this(r).mul(e)}function Ul(r,e){return new this(r).pow(e)}function Gl(r){var e,t,n,o,i=0,s=new this(1),a=[];if(r===void 0?r=this.precision:dt(r,1,un),n=Math.ceil(r/ne),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)o=e[i],o>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=o%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)o=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(e,i):(a.push(o%1e7),i+=4);i=n/4}else throw Error(Qa);else for(;i<n;)a[i++]=Math.random()*1e7|0;for(n=a[--i],r%=ne,n&&r&&(o=Ee(10,ne-r),a[i]=(n/o|0)*o);a[i]===0;i--)a.pop();if(i<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=ne)a.shift();for(n=1,o=a[0];o>=10;o/=10)n++;n<ne&&(t-=ne-n)}return s.e=t,s.d=a,s}function Xl(r){return $(r=new this(r),r.e+1,this.rounding)}function zl(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function Ql(r){return new this(r).sin()}function Yl(r){return new this(r).sinh()}function jl(r){return new this(r).sqrt()}function Hl(r,e){return new this(r).sub(e)}function Zl(){var r=0,e=arguments,t=new this(e[r]);for(re=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return re=!0,$(t,this.precision,this.rounding)}function $l(r){return new this(r).tan()}function Jl(r){return new this(r).tanh()}function em(r){return $(r=new this(r),r.e+1,1)}M[Symbol.for("nodejs.util.inspect.custom")]=M.toString;M[Symbol.toStringTag]="Decimal";var To=M.constructor=tu(Fi);Ar=new To(Ar);wr=new To(wr);var O=To;var Kr=require("@solana/web3.js");var nu=require("@solana/spl-token"),Ae=require("@solana/web3.js");function P({pubkey:r,isSigner:e=!1,isWritable:t=!0}){return{pubkey:r,isWritable:t,isSigner:e}}var Ui=[P({pubkey:nu.TOKEN_PROGRAM_ID,isWritable:!1}),P({pubkey:Ae.SystemProgram.programId,isWritable:!1}),P({pubkey:Ae.SYSVAR_RENT_PUBKEY,isWritable:!1})];function Gi({publicKey:r,transformSol:e}){let t=Xi(r.toString());if(t instanceof Ae.PublicKey)return e&&t.equals(De)?j:t;if(e&&t.toString()===De.toBase58())return j;if(typeof t=="string"){if(t===Ae.PublicKey.default.toBase58())return Ae.PublicKey.default;try{return new Ae.PublicKey(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Xi(r){try{return new Ae.PublicKey(r)}catch{return r}}var Ir=new Ae.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Br=new Ae.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),pt=new Ae.PublicKey("SysvarRent111111111111111111111111111111111"),zi=new Ae.PublicKey("SysvarC1ock11111111111111111111111111111111"),En=new Ae.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),xr=new Ae.PublicKey("Sysvar1nstructions1111111111111111111111111"),Sr=Ae.SystemProgram.programId,Ld=new Ae.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Nd=new Ae.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Md=new Ae.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),_d=new Ae.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),vd=new Ae.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Vd=new Ae.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Fd=new Ae.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ed=new Ae.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Dd=new Ae.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Wd=new Ae.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),qd=new Ae.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),j=new Ae.PublicKey("So11111111111111111111111111111111111111112"),De=Ae.PublicKey.default;function gt(r){return Gi({publicKey:r,transformSol:!0})}var ou=require("@solana/web3.js"),Qi=require("@solana/spl-token"),Ot={chainId:101,address:ou.PublicKey.default.toBase58(),programId:Qi.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},Ve={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Qi.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var Yi=class{constructor({mint:e,decimals:t,symbol:n,name:o,skipMint:i=!1,isToken2022:s=!1}){if(e===De.toBase58()||e instanceof Kr.PublicKey&&De.equals(e)){this.decimals=Ve.decimals,this.symbol=Ve.symbol,this.name=Ve.name,this.mint=new Kr.PublicKey(Ve.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=n||e.toString().substring(0,6),this.name=o||e.toString().substring(0,6),this.mint=i?Kr.PublicKey.default:Gi({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Re=Yi;Re.WSOL=new Yi(E(C({},Ve),{mint:Ve.address}));var Bo=ce(require("big.js")),iu=ce(require("bn.js")),su=ce(require("decimal.js-light"));var ru=ce(require("toformat")),tm=ru.default,Io=tm;var Cr=le("module/fraction"),ji=Io(Bo.default),xo=Io(su.default),nm={[0]:xo.ROUND_DOWN,[1]:xo.ROUND_HALF_UP,[2]:xo.ROUND_UP},om={[0]:Bo.default.roundDown,[1]:Bo.default.roundHalfUp,[2]:Bo.default.roundUp},be=class{constructor(e,t=new iu.default(1)){this.numerator=J(e),this.denominator=J(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new be(this.denominator,this.numerator)}add(e){let t=e instanceof be?e:new be(J(e));return this.denominator.eq(t.denominator)?new be(this.numerator.add(t.numerator),this.denominator):new be(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof be?e:new be(J(e));return this.denominator.eq(t.denominator)?new be(this.numerator.sub(t.numerator),this.denominator):new be(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof be?e:new be(J(e));return new be(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof be?e:new be(J(e));return new be(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||Cr.logWithError(`${e} is not an integer.`),e<=0&&Cr.logWithError(`${e} is not positive.`),xo.set({precision:e+1,rounding:nm[n]});let o=new xo(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return o.toFormat(o.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||Cr.logWithError(`${e} is not an integer.`),e<0&&Cr.logWithError(`${e} is negative.`),ji.DP=e,ji.RM=om[n]||1,new ji(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var im=le("Raydium_price"),ft=class extends be{constructor(t){let{baseToken:n,quoteToken:o,numerator:i,denominator:s}=t;super(i,s);this.baseToken=n,this.quoteToken=o,this.scalar=new be(Hi(n.decimals),Hi(o.decimals))}get raw(){return new be(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new ft({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&im.logWithError("mul token not equals");let n=super.mul(t);return new ft({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(t=this.quoteToken.decimals,n,o){return this.adjusted.toSignificant(t,n,o)}toFixed(t=this.quoteToken.decimals,n,o){return this.adjusted.toFixed(t,n,o)}};var Zi=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},Rr=Zi;Rr.SOL=new Zi(Ot);var uu=ce(require("bn.js"));var au=new be(new uu.default(100)),tt=class extends be{toSignificant(e=5,t,n){return this.mul(au).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(au).toFixed(e,t,n)}};var It=new at.default(0),lu=new at.default(1),Cp=new at.default(2),Rp=new at.default(3),Op=new at.default(5),$i=new at.default(10),Lp=new at.default(100),Np=new at.default(1e3),Mp=new at.default(1e4),cu=9007199254740991;function J(r){let e=le("Raydium_parseBigNumberish");if(r instanceof at.default)return r;if(typeof r=="string"){if(r.match(/^-?[0-9]+$/))return new at.default(r);e.logWithError(`invalid BigNumberish string: ${r}`)}return typeof r=="number"?(r%1&&e.logWithError(`BigNumberish number underflow: ${r}`),(r>=cu||r<=-cu)&&e.logWithError(`BigNumberish number overflow: ${r}`),new at.default(String(r))):typeof r=="bigint"?new at.default(r.toString()):(e.error(`invalid BigNumberish value: ${r}`),new at.default(0))}function Hi(r){return $i.pow(J(r))}function Or(r,e){let t=r.divmod(e);return t.mod.isZero()?t.div:t.div.isNeg()?t.div.isubn(1):t.div.iaddn(1)}var sm=le("Raydium_amount"),du=Io(pu.default);function am(r,e){let t="0",n="0";if(r.includes(".")){let o=r.split(".");o.length===2?([t,n]=o,n=n.padEnd(e,"0")):sm.logWithError(`invalid number string, num: ${r}`)}else t=r;return[t,n.slice(0,e)||n]}var Te=class extends be{constructor(t,n,o=!0,i){let s=new So.default(0),a=$i.pow(new So.default(t.decimals));if(o)s=J(n);else{let c=new So.default(0),u=new So.default(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=am(n.toString(),t.decimals);c=J(l),u=J(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=le(i||"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 Te(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new Te(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,n,o=0){return super.toSignificant(t,n,o)}toFixed(t=this.token.decimals,n,o=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,o)}toExact(t={groupSeparator:""}){return du.DP=this.token.decimals,new du(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};function m