@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 384 kB
JavaScript
var Hl=Object.create;var _o=Object.defineProperty,Zl=Object.defineProperties,$l=Object.getOwnPropertyDescriptor,Jl=Object.getOwnPropertyDescriptors,em=Object.getOwnPropertyNames,Fr=Object.getOwnPropertySymbols,tm=Object.getPrototypeOf,ps=Object.prototype.hasOwnProperty,Su=Object.prototype.propertyIsEnumerable;var xu=(o,e,t)=>e in o?_o(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,C=(o,e)=>{for(var t in e||(e={}))ps.call(e,t)&&xu(o,t,e[t]);if(Fr)for(var t of Fr(e))Su.call(e,t)&&xu(o,t,e[t]);return o},E=(o,e)=>Zl(o,Jl(e));var _e=(o,e)=>{var t={};for(var n in o)ps.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&Fr)for(var n of Fr(o))e.indexOf(n)<0&&Su.call(o,n)&&(t[n]=o[n]);return t};var nm=(o,e)=>{for(var t in e)_o(o,t,{get:e[t],enumerable:!0})},Ku=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of em(e))!ps.call(o,r)&&r!==t&&_o(o,r,{get:()=>e[r],enumerable:!(n=$l(e,r))||n.enumerable});return o};var me=(o,e,t)=>(t=o!=null?Hl(tm(o)):{},Ku(e||!o||!o.__esModule?_o(t,"default",{value:o,enumerable:!0}):t,o)),om=o=>Ku(_o({},"__esModule",{value:!0}),o);var Ff={};nm(Ff,{ACCOUNT_TYPE_SIZE:()=>_d,ALL_PROGRAM_ID:()=>qd,AMM_CONFIG_SEED:()=>wl,AMM_STABLE:()=>yc,AMM_V4:()=>ci,ANAMint:()=>ad,API_URLS:()=>Me,AccountType:()=>lc,Api:()=>Jo,BIT_PRECISION:()=>Ea,BNDivCeil:()=>Ct,BNLayout:()=>hn,BN_100:()=>xd,BN_1000:()=>Sd,BN_10000:()=>Kd,BN_FIVE:()=>Bd,BN_ONE:()=>Ks,BN_TEN:()=>yn,BN_THREE:()=>Id,BN_TWO:()=>Td,BN_ZERO:()=>Ue,BitStructure:()=>Qd,Blob:()=>js,CLMM_PROGRAM_ID:()=>li,CLOCK_PROGRAM_ID:()=>Hr,CREATE_CPMM_POOL_AUTH:()=>hc,CREATE_CPMM_POOL_FEE_ACC:()=>kc,CREATE_CPMM_POOL_PROGRAM:()=>mi,Clmm:()=>Bo,ClmmConfigLayout:()=>ja,ClmmInstrument:()=>Oe,ConstantProductCurve:()=>Tr,CpmmConfigInfoLayout:()=>du,CpmmFee:()=>kr,CpmmPoolInfoLayout:()=>Cr,Currency:()=>Jn,CurrencyAmount:()=>bn,CurveCalculator:()=>Br,DEVNET_PROGRAM_ID:()=>Ud,DEV_API_URLS:()=>Xd,DEV_CREATE_CPMM_POOL_AUTH:()=>Ic,DEV_CREATE_CPMM_POOL_FEE_ACC:()=>Bc,DEV_CREATE_CPMM_POOL_PROGRAM:()=>Tc,DataElement:()=>ml,ETHMint:()=>ud,EXTENSION_TICKARRAY_BITMAP_SIZE:()=>Ji,FARM_LOCK_MINT:()=>da,FARM_LOCK_VAULT:()=>pa,FARM_PROGRAM_ID_V3:()=>ai,FARM_PROGRAM_ID_V5:()=>ui,FARM_PROGRAM_ID_V6:()=>En,FARM_PROGRAM_TO_VERSION:()=>kt,FARM_VERSION_TO_LEDGER_LAYOUT:()=>ya,FARM_VERSION_TO_STATE_LAYOUT:()=>fa,FEE_DESTINATION_ID:()=>Wd,FEE_RATE_DENOMINATOR:()=>br,FEE_RATE_DENOMINATOR_VALUE:()=>ns,FETCH_TICKARRAY_COUNT:()=>Kl,Fee:()=>Sl,Fraction:()=>ie,IDO_ALL_PROGRAM:()=>no,IDO_PROGRAM_ID_V1:()=>gc,IDO_PROGRAM_ID_V2:()=>Ac,IDO_PROGRAM_ID_V3:()=>wc,IDO_PROGRAM_ID_V4:()=>Pc,INSTRUCTION_PROGRAM_ID:()=>Wo,InstructionType:()=>V,JupTokenType:()=>Us,LIQUIDITY_FEES_DENOMINATOR:()=>Ar,LIQUIDITY_FEES_NUMERATOR:()=>es,LIQUIDITY_POOL_PROGRAM_ID_V5_MODEL:()=>qs,LIQUIDITY_VERSION_TO_SERUM_VERSION:()=>vl,LIQUIDITY_VERSION_TO_STATE_LAYOUT:()=>Zp,LOG_B_2_X32:()=>Da,LOG_B_P_ERR_MARGIN_LOWER_X64:()=>Wa,LOG_B_P_ERR_MARGIN_UPPER_X64:()=>qa,LOOKUP_TABLE_CACHE:()=>jo,Layout:()=>ro,LiquidityMath:()=>de,LogLevel:()=>Cu,Logger:()=>Er,MARKET_STATE_LAYOUT_V2:()=>as,MARKET_STATE_LAYOUT_V3:()=>is,MARKET_VERSION_TO_STATE_LAYOUT:()=>bu,MAX_BASE64_SIZE:()=>Ls,MAX_SQRT_PRICE_X64:()=>xt,MAX_SQRT_PRICE_X64_SUB_ONE:()=>yr,MAX_TICK:()=>ct,MEMO_PROGRAM_ID:()=>Eo,MEMO_PROGRAM_ID2:()=>Do,METADATA_PROGRAM_ID:()=>_n,MIN_SQRT_PRICE_X64:()=>Bt,MIN_SQRT_PRICE_X64_ADD_ONE:()=>fr,MIN_TICK:()=>ot,MODEL_DATA_PUBKEY:()=>Xn,Market:()=>Or,MathUtil:()=>oe,MaxU64:()=>$i,MaxUint128:()=>Fa,NEGATIVE_ONE:()=>Yt,NRVMint:()=>sd,OBSERVATION_SEED:()=>xl,ONE:()=>wt,OPEN_BOOK_PROGRAM:()=>fc,OPERATION_SEED:()=>Il,ObservationInfoLayout:()=>Ha,ObservationLayout:()=>Rl,OperationLayout:()=>Za,OptionLayout:()=>Ai,Owner:()=>Kt,PAIMint:()=>Jm,POOL_REWARD_VAULT_SEED:()=>kl,POOL_SEED:()=>Pl,POOL_TICK_ARRAY_BITMAP_SEED:()=>Bl,POOL_VAULT_SEED:()=>hl,POSITION_SEED:()=>Ma,Percent:()=>Ve,PoolFetchType:()=>Gs,PoolInfoLayout:()=>Sn,PoolUtils:()=>Ne,PositionInfoLayout:()=>gr,PositionRewardInfoLayout:()=>Ll,PositionUtils:()=>ko,Price:()=>Ye,ProtocolPositionLayout:()=>gf,Q128:()=>pr,Q64:()=>Pt,RAYMint:()=>$m,RENT_PROGRAM_ID:()=>dt,Raydium:()=>_r,RewardInfo:()=>Ol,RoundDirection:()=>iu,Rounding:()=>Jr,Router:()=>bc,SERUM_PROGRAMID_TO_VERSION:()=>fu,SERUM_PROGRAM_ID_V3:()=>Zo,SERUM_VERSION_TO_PROGRAMID:()=>yu,SESSION_KEY:()=>Xs,SOLMint:()=>We,SOL_INFO:()=>_t,SPL_MINT_LAYOUT:()=>Xp,SRMMint:()=>ed,STORAGE_KEY:()=>di,SYSTEM_PROGRAM_ID:()=>qo,SqrtPriceMath:()=>te,StableLayout:()=>Gn,Structure:()=>wi,SwapMath:()=>xn,TICK_ARRAY_BITMAP_SIZE:()=>Bn,TICK_ARRAY_SEED:()=>Tl,TICK_ARRAY_SIZE:()=>ze,TICK_SPACINGS:()=>df,TOKEN_WSOL:()=>qe,TickArrayBitmap:()=>jt,TickArrayBitmapExtensionLayout:()=>Qa,TickArrayBitmapExtensionUtils:()=>ho,TickArrayLayout:()=>Po,TickLayout:()=>Nl,TickMath:()=>Kn,TickQuery:()=>pe,TickUtils:()=>Z,Token:()=>Ae,TokenAmount:()=>be,TxBuilder:()=>Ho,TxVersion:()=>gn,U64Resolution:()=>wo,U64_IGNORE_RANGE:()=>ff,UInt:()=>fi,USDCMint:()=>td,USDHMint:()=>id,USDTMint:()=>nd,UTIL1216:()=>pc,Union:()=>Pi,Voter:()=>la,VoterDepositEntry:()=>$c,VoterLockup:()=>Zc,VoterRegistrar:()=>ca,VoterVotingMintConfig:()=>Hc,WSOLMint:()=>H,WideBits:()=>tr,WrappedLayout:()=>zt,ZERO:()=>ye,_100_PERCENT:()=>Bs,accountMeta:()=>P,add:()=>kd,addComputeBudget:()=>Qo,addLiquidityLayout:()=>zi,array:()=>Kp,associatedLedgerAccountLayout:()=>xi,bits:()=>bi,blob:()=>Pe,bool:()=>Ze,calFarmRewardAmount:()=>Ei,ceilDiv:()=>Wl,checkLegacyTxSize:()=>eo,checkV0TxSize:()=>to,chunkArray:()=>ii,claimLayout:()=>Lo,clmmComputeInfoToApiInfo:()=>za,closeAccountInstruction:()=>Ft,commonSystemAccountMeta:()=>Qr,createAssociatedLedgerAccountInstruction:()=>lo,createLogger:()=>le,createPoolFeeLayout:()=>Ta,createPoolV4InstructionV2:()=>Ca,createPoolV4Layout:()=>Hp,createWSolAccountInstructions:()=>Qt,cstr:()=>hp,currencyEquals:()=>pd,decimalToFraction:()=>nc,decodeBool:()=>vc,div:()=>Ad,divCeil:()=>zo,dwLayout:()=>at,encodeBool:()=>_c,endlessRetry:()=>zd,eq:()=>$u,f32:()=>bp,f32be:()=>gp,f64:()=>Ap,f64be:()=>wp,farmAddRewardLayout:()=>Ri,farmLedgerLayoutV3_1:()=>Vp,farmLedgerLayoutV3_2:()=>uo,farmLedgerLayoutV5_1:()=>Fp,farmLedgerLayoutV5_2:()=>aa,farmLedgerLayoutV6_1:()=>ua,farmRewardInfoToConfig:()=>ga,farmRewardLayout:()=>Ki,farmRewardRestartLayout:()=>Ci,farmRewardTimeInfoLayout:()=>jc,farmStateV3Layout:()=>ia,farmStateV5Layout:()=>sa,farmStateV6Layout:()=>ao,fetchMultipleFarmInfoAndUpdate:()=>Ep,fetchMultipleInfo:()=>wf,fetchMultipleMintInfos:()=>Fn,findProgramAddress:()=>ce,fixedSwapInLayout:()=>Ui,fixedSwapOutLayout:()=>Gi,floorDiv:()=>ou,forecastTransactionSize:()=>Yo,formatLayout:()=>yl,generatePubKey:()=>pt,getATAAddress:()=>Ie,getAssociatedAuthority:()=>ba,getAssociatedConfigId:()=>wr,getAssociatedLedgerAccount:()=>nt,getAssociatedLedgerPoolAccount:()=>co,getAssociatedOpenOrders:()=>Dl,getAssociatedPoolKeys:()=>nu,getCpmmPdaAmmConfigId:()=>Sf,getCpmmPdaPoolId:()=>ql,getCreatePoolKeys:()=>au,getDate:()=>Es,getDepositEntryIndex:()=>Di,getDxByDyBaseIn:()=>xa,getDyByDxBaseIn:()=>Ba,getEpochInfo:()=>Md,getFarmLedgerLayout:()=>qn,getFarmStateLayout:()=>Jc,getLiquidityAssociatedAuthority:()=>ts,getLiquidityAssociatedId:()=>Cn,getLiquidityFromAmounts:()=>yf,getMax:()=>hd,getMultipleAccountsInfo:()=>St,getMultipleAccountsInfoWithCustomFlags:()=>Xe,getMultipleLookupTableInfo:()=>si,getPdaAmmConfigId:()=>mf,getPdaExBitmapAccount:()=>yt,getPdaLpMint:()=>Ul,getPdaMetadataKey:()=>dr,getPdaObservationAccount:()=>Va,getPdaObservationId:()=>xr,getPdaOperationAccount:()=>Ao,getPdaPersonalPositionAddress:()=>Tt,getPdaPoolAuthority:()=>Qn,getPdaPoolId:()=>va,getPdaPoolRewardVaulId:()=>_a,getPdaPoolVaultId:()=>Zi,getPdaProtocolPositionAddress:()=>In,getPdaTickArrayAddress:()=>Be,getPdaVault:()=>su,getRecentBlockHash:()=>Vn,getRegistrarAddress:()=>Ni,getSessionKey:()=>Kc,getStablePrice:()=>Sa,getTime:()=>dc,getTimestamp:()=>Nd,getTokenOwnerRecordAddress:()=>Fi,getTransferAmountFee:()=>Gd,getTransferAmountFeeV2:()=>we,getVoterAddress:()=>_i,getVoterWeightRecordAddress:()=>Vi,getVotingMintAuthority:()=>vi,getVotingTokenMint:()=>Mi,governanceCreateTokenOwnerRecord:()=>rl,greedy:()=>Yd,gt:()=>Zu,gte:()=>gd,i128:()=>Js,i16ToBytes:()=>cf,i32ToBytes:()=>mr,i64:()=>Dn,i8:()=>$s,initPoolLayout:()=>Xi,initTokenAccountInstruction:()=>Bi,initializeMarket:()=>zl,intersection:()=>Vd,isDateAfter:()=>Ws,isDateBefore:()=>Ds,isDecimal:()=>oc,isMeaningfulNumber:()=>Pd,isNumber:()=>Fs,isValidFarmVersion:()=>Oi,isZero:()=>go,jsonInfo2PoolKeys:()=>Ce,judgeFarmType:()=>Dp,leadingZeros:()=>ji,leastSignificantBit:()=>Na,liquidityStateV4Layout:()=>bo,liquidityStateV5Layout:()=>cl,lt:()=>yd,lte:()=>bd,mSOLMint:()=>od,makeAMMSwapInstruction:()=>lr,makeAddLiquidityInstruction:()=>Ka,makeAddNewRewardInstruction:()=>qi,makeClaimInstruction:()=>Mr,makeClaimInstructionV4:()=>ms,makeCreateCpmmPoolInInstruction:()=>uu,makeCreateFarmInstruction:()=>Aa,makeCreateMarketInstruction:()=>hu,makeCreatorWithdrawFarmRewardInstruction:()=>wa,makeDepositCpmmInInstruction:()=>cu,makeDepositInstructionV3:()=>Pa,makeDepositInstructionV5:()=>ha,makeDepositInstructionV6:()=>ka,makeDepositTokenInstruction:()=>qp,makeDepositWithdrawInstruction:()=>Gp,makeInitPoolInstructionV4:()=>uf,makePurchaseInstruction:()=>vf,makeRestartRewardInstruction:()=>Wi,makeSimulatePoolInfoInstruction:()=>Ra,makeSwapCpmmBaseInInInstruction:()=>Kr,makeSwapCpmmBaseOutInInstruction:()=>mu,makeSwapFixedInInstruction:()=>gl,makeSwapFixedOutInstruction:()=>Al,makeSwapInstruction:()=>pu,makeTransferInstruction:()=>so,makeWithdrawCpmmInInstruction:()=>lu,makeWithdrawInstructionV3:()=>fo,makeWithdrawInstructionV5:()=>po,makeWithdrawInstructionV6:()=>mo,makeWithdrawTokenInstruction:()=>Up,minExpirationTime:()=>Rt,mockCreatePoolInfo:()=>pf,mockV3CreatePoolInfo:()=>Ua,modelDataInfoLayout:()=>dl,mostSignificantBit:()=>La,mul:()=>ti,notInnerObject:()=>ni,ns64:()=>cp,ns64be:()=>yp,nu64:()=>Hs,nu64be:()=>op,offset:()=>gi,offsetDateTime:()=>Dd,option:()=>Tp,parseBigNumberish:()=>j,parseNumberInfo:()=>fn,parseSimulateLogToJson:()=>Ms,parseSimulateValue:()=>Ut,parseTokenAccountResp:()=>ra,parseTokenInfo:()=>zp,poolTypeV6:()=>nn,printSimulate:()=>An,publicKey:()=>K,purchaseLayout:()=>cs,realFarmStateV3Layout:()=>zc,realFarmStateV5Layout:()=>Qc,realFarmV6Layout:()=>Yc,recursivelyDecimalToFraction:()=>Ss,removeLiquidityInstruction:()=>Yi,removeLiquidityLayout:()=>Qi,route1Instruction:()=>Of,route2Instruction:()=>Lf,routeInstruction:()=>Gl,rustEnum:()=>Sp,s16:()=>ip,s16be:()=>lp,s24:()=>sp,s24be:()=>mp,s32:()=>je,s32be:()=>dp,s40:()=>ap,s40be:()=>pp,s48:()=>up,s48be:()=>fp,s8:()=>rp,seq:()=>Q,setLoggerLevel:()=>rm,shakeFractionDecimal:()=>ec,simulateMultipleInstruction:()=>Ns,simulatePoolInfoInstruction:()=>af,simulateTransaction:()=>uc,sleep:()=>Os,solToWSol:()=>At,solToWSolToken:()=>Yp,splAccountLayout:()=>tn,splitNumber:()=>Rs,stSOLMint:()=>rd,str:()=>xp,struct:()=>M,sub:()=>wd,tagged:()=>Bp,tenExponential:()=>ei,toAmmComputePoolInfo:()=>Pr,toApiV3Token:()=>ut,toBN:()=>tc,toBuffer:()=>vs,toFeeConfig:()=>on,toFraction:()=>Cs,toFractionWithDecimals:()=>fd,toPercent:()=>Cd,toToken:()=>cr,toTokenAmount:()=>yo,toTokenInfo:()=>Qp,toTokenPrice:()=>Rd,toTotalPrice:()=>Od,toUsdCurrency:()=>xs,trailingZeros:()=>Hi,transformTxToBase64:()=>vd,tryParsePublicKey:()=>jr,txToBase64:()=>cc,u128:()=>ee,u16:()=>Xt,u16ToBytes:()=>Oa,u16be:()=>$d,u24:()=>jd,u24be:()=>Jd,u32:()=>He,u32ToBytes:()=>lf,u32be:()=>ep,u40:()=>Hd,u40be:()=>tp,u48:()=>Zd,u48be:()=>np,u64:()=>h,u8:()=>W,union:()=>Cp,unionArr:()=>Vf,unionLayoutDiscriminator:()=>Pp,uniq:()=>Ed,updateFarmPoolInfo:()=>el,updateReqHistory:()=>$o,utf8:()=>kp,validateAndParsePublicKey:()=>Yr,validateFarmRewards:()=>Li,vec:()=>Ip,vecU8:()=>Vc,voterStakeRegistryCreateDepositEntry:()=>sl,voterStakeRegistryCreateVoter:()=>il,voterStakeRegistryDeposit:()=>tl,voterStakeRegistryUpdateVoterWeightRecord:()=>nl,voterStakeRegistryWithdraw:()=>ol,wSolToSolToken:()=>jp,withdrawRewardLayout:()=>Si,xor:()=>Fd,zeros:()=>Rp});module.exports=om(Ff);var Qs=me(require("axios"));var vn=require("lodash"),Cu=(r=>(r[r.Error=0]="Error",r[r.Warning=1]="Warning",r[r.Info=2]="Info",r[r.Debug=3]="Debug",r))(Cu||{}),Er=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}},fs={},Ru={};function le(o){let e=(0,vn.get)(fs,o);if(!e){let t=(0,vn.get)(Ru,o);e=new Er({name:o,logLevel:t}),(0,vn.set)(fs,o,e)}return e}function rm(o,e){(0,vn.set)(Ru,o,e);let t=(0,vn.get)(fs,o);t&&(t.level=e)}var ic=require("@solana/web3.js"),sc=me(require("bn.js"));var rc=me(require("big.js")),Jt=me(require("bn.js"));var Ke=me(require("bn.js"));var Zn=9e15,pn=1e9,ys="0123456789abcdef",Wr="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",qr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",bs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Zn,maxE:Zn,crypto:!1},Mu,$t,re=!0,Gr="[DecimalError] ",dn=Gr+"Invalid argument: ",vu=Gr+"Precision limit exceeded",_u=Gr+"crypto unavailable",Vu="[object Decimal]",st=Math.floor,Qe=Math.pow,im=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,sm=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,am=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Fu=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,vt=1e7,ne=7,um=9007199254740991,cm=Wr.length-1,gs=qr.length-1,v={toStringTag:Vu};v.absoluteValue=v.abs=function(){var o=new this.constructor(this);return o.s<0&&(o.s=1),J(o)};v.ceil=function(){return J(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(o,e){var t,n=this,r=n.constructor;if(o=new r(o),e=new r(e),!o.s||!e.s)return new r(NaN);if(o.gt(e))throw Error(dn+e);return t=n.cmp(o),t<0?o:n.cmp(e)>0?e:new r(n)};v.comparedTo=v.cmp=function(o){var e,t,n,r,i=this,s=i.d,a=(o=new i.constructor(o)).d,u=i.s,c=o.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(i.e!==o.e)return i.e>o.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};v.cosine=v.cos=function(){var o,e,t=this,n=t.constructor;return t.d?t.d[0]?(o=n.precision,e=n.rounding,n.precision=o+Math.max(t.e,t.sd())+ne,n.rounding=1,t=lm(n,Uu(n,t)),n.precision=o,n.rounding=e,J($t==2||$t==3?t.neg():t,o,e,!0)):new n(1):new n(NaN)};v.cubeRoot=v.cbrt=function(){var o,e,t,n,r,i,s,a,u,c,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(re=!1,i=l.s*Qe(l.s*l,1/3),!i||Math.abs(i)==1/0?(t=tt(l.d),o=l.e,(i=(o-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Qe(t,1/3),o=st((o+1)/3)-(o%3==(o<0?-1:2)),i==1/0?t="5e"+o:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+o),n=new m(t),n.s=l.s):n=new m(i.toString()),s=(o=m.precision)+3;;)if(a=n,u=a.times(a).times(a),c=u.plus(l),n=Se(c.plus(l).times(a),c.plus(u),s+2,1),tt(a.d).slice(0,s)===(t=tt(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(J(a,o+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")&&(J(n,o+1,1),e=!n.times(n).times(n).eq(l));break}return re=!0,J(n,o,m.rounding,e)};v.decimalPlaces=v.dp=function(){var o,e=this.d,t=NaN;if(e){if(o=e.length-1,t=(o-st(this.e/ne))*ne,o=e[o],o)for(;o%10==0;o/=10)t--;t<0&&(t=0)}return t};v.dividedBy=v.div=function(o){return Se(this,new this.constructor(o))};v.dividedToIntegerBy=v.divToInt=function(o){var e=this,t=e.constructor;return J(Se(e,new t(o),0,1,1),t.precision,t.rounding)};v.equals=v.eq=function(o){return this.cmp(o)===0};v.floor=function(){return J(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(o){return this.cmp(o)>0};v.greaterThanOrEqualTo=v.gte=function(o){var e=this.cmp(o);return e==1||e===0};v.hyperbolicCosine=v.cosh=function(){var o,e,t,n,r,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,r=i.d.length,r<32?(o=Math.ceil(r/3),e=(1/zr(4,o)).toString()):(o=16,e="2.3283064365386962890625e-10"),i=$n(s,1,i.times(e),new s(1),!0);for(var u,c=o,l=new s(8);c--;)u=i.times(i),i=a.minus(u.times(l.minus(u.times(l))));return J(i,s.precision=t,s.rounding=n,!0)};v.hyperbolicSine=v.sinh=function(){var o,e,t,n,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(r.e,r.sd())+4,i.rounding=1,n=r.d.length,n<3)r=$n(i,2,r,r,!0);else{o=1.4*Math.sqrt(n),o=o>16?16:o|0,r=r.times(1/zr(5,o)),r=$n(i,2,r,r,!0);for(var s,a=new i(5),u=new i(16),c=new i(20);o--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(c))))}return i.precision=e,i.rounding=t,J(r,e,t,!0)};v.hyperbolicTangent=v.tanh=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+7,n.rounding=1,Se(t.sinh(),t.cosh(),n.precision=o,n.rounding=e)):new n(t.s)};v.inverseCosine=v.acos=function(){var o,e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n!==-1?n===0?e.isNeg()?Mt(t,r,i):new t(0):new t(NaN):e.isZero()?Mt(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=e.asin(),o=Mt(t,r+4,i).times(.5),t.precision=r,t.rounding=i,o.minus(e))};v.inverseHyperbolicCosine=v.acosh=function(){var o,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(o=n.precision,e=n.rounding,n.precision=o+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=o,n.rounding=e,t.ln()):new n(t)};v.inverseHyperbolicSine=v.asinh=function(){var o,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+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=o,n.rounding=e,t.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var o,e,t,n,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(o=i.precision,e=i.rounding,n=r.sd(),Math.max(n,o)<2*-r.e-1?J(new i(r),o,e,!0):(i.precision=t=n-r.e,r=Se(r.plus(1),new i(1).minus(r),t+o,1),i.precision=o+4,i.rounding=1,r=r.ln(),i.precision=o,i.rounding=e,r.times(.5))):new i(NaN)};v.inverseSine=v.asin=function(){var o,e,t,n,r=this,i=r.constructor;return r.isZero()?new i(r):(e=r.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(o=Mt(i,t+4,n).times(.5),o.s=r.s,o):new i(NaN):(i.precision=t+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,r.times(2)))};v.inverseTangent=v.atan=function(){var o,e,t,n,r,i,s,a,u,c=this,l=c.constructor,m=l.precision,d=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&m+4<=gs)return s=Mt(l,m+4,d).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(m+4<=gs)return s=Mt(l,m+4,d).times(.5),s.s=c.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/ne+2|0),o=t;o;--o)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(re=!1,e=Math.ceil(a/ne),n=1,u=c.times(c),s=new l(c),r=c;o!==-1;)if(r=r.times(u),i=s.minus(r.div(n+=2)),r=r.times(u),s=i.plus(r.div(n+=2)),s.d[e]!==void 0)for(o=e;s.d[o]===i.d[o]&&o--;);return t&&(s=s.times(2<<t-1)),re=!0,J(s,l.precision=m,l.rounding=d,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&st(this.e/ne)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(o){return this.cmp(o)<0};v.lessThanOrEqualTo=v.lte=function(o){return this.cmp(o)<1};v.logarithm=v.log=function(o){var e,t,n,r,i,s,a,u,c=this,l=c.constructor,m=l.precision,d=l.rounding,p=5;if(o==null)o=new l(10),e=!0;else{if(o=new l(o),t=o.d,o.s<0||!t||!t[0]||o.eq(1))return new l(NaN);e=o.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)i=!0;else{for(r=t[0];r%10===0;)r/=10;i=r!==1}if(re=!1,a=m+p,s=mn(c,a),n=e?Ur(l,a+10):mn(o,a),u=Se(s,n,a,1),Vo(u.d,r=m,d))do if(a+=10,s=mn(c,a),n=e?Ur(l,a+10):mn(o,a),u=Se(s,n,a,1),!i){+tt(u.d).slice(r+1,r+15)+1==1e14&&(u=J(u,m+1,0));break}while(Vo(u.d,r+=10,d));return re=!0,J(u,m,d)};v.minus=v.sub=function(o){var e,t,n,r,i,s,a,u,c,l,m,d,p=this,y=p.constructor;if(o=new y(o),!p.d||!o.d)return!p.s||!o.s?o=new y(NaN):p.d?o.s=-o.s:o=new y(o.d||p.s!==o.s?p:NaN),o;if(p.s!=o.s)return o.s=-o.s,p.plus(o);if(c=p.d,d=o.d,a=y.precision,u=y.rounding,!c[0]||!d[0]){if(d[0])o.s=-o.s;else if(c[0])o=new y(p);else return new y(u===3?-0:0);return re?J(o,a,u):o}if(t=st(o.e/ne),l=st(p.e/ne),c=c.slice(),i=l-t,i){for(m=i<0,m?(e=c,i=-i,s=d.length):(e=d,t=l,s=c.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=c.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(c[n]!=d[n]){m=c[n]<d[n];break}i=0}for(m&&(e=c,c=d,d=e,o.s=-o.s),s=c.length,n=d.length-s;n>0;--n)c[s++]=0;for(n=d.length;n>i;){if(c[--n]<d[n]){for(r=n;r&&c[--r]===0;)c[r]=vt-1;--c[r],c[n]+=vt}c[n]-=d[n]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(o.d=c,o.e=Xr(c,t),re?J(o,a,u):o):new y(u===3?-0:0)};v.modulo=v.mod=function(o){var e,t=this,n=t.constructor;return o=new n(o),!t.d||!o.s||o.d&&!o.d[0]?new n(NaN):!o.d||t.d&&!t.d[0]?J(new n(t),n.precision,n.rounding):(re=!1,n.modulo==9?(e=Se(t,o.abs(),0,3,1),e.s*=o.s):e=Se(t,o,0,n.modulo,1),e=e.times(o),re=!0,t.minus(e))};v.naturalExponential=v.exp=function(){return As(this)};v.naturalLogarithm=v.ln=function(){return mn(this)};v.negated=v.neg=function(){var o=new this.constructor(this);return o.s=-o.s,J(o)};v.plus=v.add=function(o){var e,t,n,r,i,s,a,u,c,l,m=this,d=m.constructor;if(o=new d(o),!m.d||!o.d)return!m.s||!o.s?o=new d(NaN):m.d||(o=new d(o.d||m.s===o.s?m:NaN)),o;if(m.s!=o.s)return o.s=-o.s,m.minus(o);if(c=m.d,l=o.d,a=d.precision,u=d.rounding,!c[0]||!l[0])return l[0]||(o=new d(m)),re?J(o,a,u):o;if(i=st(m.e/ne),n=st(o.e/ne),c=c.slice(),r=i-n,r){for(r<0?(t=c,r=-r,s=l.length):(t=l,n=i,s=c.length),i=Math.ceil(a/ne),s=i>s?i+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)/vt|0,c[r]%=vt;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return o.d=c,o.e=Xr(c,n),re?J(o,a,u):o};v.precision=v.sd=function(o){var e,t=this;if(o!==void 0&&o!==!!o&&o!==1&&o!==0)throw Error(dn+o);return t.d?(e=Eu(t.d),o&&t.e+1>e&&(e=t.e+1)):e=NaN,e};v.round=function(){var o=this,e=o.constructor;return J(new e(o),o.e+1,e.rounding)};v.sine=v.sin=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+Math.max(t.e,t.sd())+ne,n.rounding=1,t=dm(n,Uu(n,t)),n.precision=o,n.rounding=e,J($t>2?t.neg():t,o,e,!0)):new n(NaN)};v.squareRoot=v.sqrt=function(){var o,e,t,n,r,i,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(re=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=tt(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=st((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(i=n,n=i.plus(Se(s,i,t+2,1)).times(.5),tt(i.d).slice(0,t)===(e=tt(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(J(i,u+1,0),i.times(i).eq(s))){n=i;break}t+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(J(n,u+1,1),o=!n.times(n).eq(s));break}return re=!0,J(n,u,l.rounding,o)};v.tangent=v.tan=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+10,n.rounding=1,t=t.sin(),t.s=1,t=Se(t,new n(1).minus(t.times(t)).sqrt(),o+10,0),n.precision=o,n.rounding=e,J($t==2||$t==4?t.neg():t,o,e,!0)):new n(NaN)};v.times=v.mul=function(o){var e,t,n,r,i,s,a,u,c,l=this,m=l.constructor,d=l.d,p=(o=new m(o)).d;if(o.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!o.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?o.s/0:o.s*0);for(t=st(l.e/ne)+st(o.e/ne),u=d.length,c=p.length,u<c&&(i=d,d=p,p=i,s=u,u=c,c=s),i=[],s=u+c,n=s;n--;)i.push(0);for(n=c;--n>=0;){for(e=0,r=u+n;r>n;)a=i[r]+p[n]*d[r-n-1]+e,i[r--]=a%vt|0,e=a/vt|0;i[r]=(i[r]+e)%vt|0}for(;!i[--s];)i.pop();return e?++t:i.shift(),o.d=i,o.e=Xr(i,t),re?J(o,m.precision,m.rounding):o};v.toBinary=function(o,e){return Ps(this,2,o,e)};v.toDecimalPlaces=v.toDP=function(o,e){var t=this,n=t.constructor;return t=new n(t),o===void 0?t:(gt(o,0,pn),e===void 0?e=n.rounding:gt(e,0,8),J(t,o+t.e+1,e))};v.toExponential=function(o,e){var t,n=this,r=n.constructor;return o===void 0?t=qt(n,!0):(gt(o,0,pn),e===void 0?e=r.rounding:gt(e,0,8),n=J(new r(n),o+1,e),t=qt(n,!0,o+1)),n.isNeg()&&!n.isZero()?"-"+t:t};v.toFixed=function(o,e){var t,n,r=this,i=r.constructor;return o===void 0?t=qt(r):(gt(o,0,pn),e===void 0?e=i.rounding:gt(e,0,8),n=J(new i(r),o+r.e+1,e),t=qt(n,!1,o+n.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};v.toFraction=function(o){var e,t,n,r,i,s,a,u,c,l,m,d,p=this,y=p.d,f=p.constructor;if(!y)return new f(p);if(c=t=new f(1),n=u=new f(0),e=new f(n),i=e.e=Eu(y)-p.e-1,s=i%ne,e.d[0]=Qe(10,s<0?ne+s:s),o==null)o=i>0?e:c;else{if(a=new f(o),!a.isInt()||a.lt(c))throw Error(dn+a);o=a.gt(e)?i>0?e:c:a}for(re=!1,a=new f(tt(y)),l=f.precision,f.precision=i=y.length*ne*2;m=Se(a,e,0,1,1),r=t.plus(m.times(n)),r.cmp(o)!=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=Se(o.minus(t),n,0,1,1),u=u.plus(r.times(c)),t=t.plus(r.times(n)),u.s=c.s=p.s,d=Se(c,n,i,1).minus(p).abs().cmp(Se(u,t,i,1).minus(p).abs())<1?[c,n]:[u,t],f.precision=l,re=!0,d};v.toHexadecimal=v.toHex=function(o,e){return Ps(this,16,o,e)};v.toNearest=function(o,e){var t=this,n=t.constructor;if(t=new n(t),o==null){if(!t.d)return t;o=new n(1),e=n.rounding}else{if(o=new n(o),e===void 0?e=n.rounding:gt(e,0,8),!t.d)return o.s?t:o;if(!o.d)return o.s&&(o.s=t.s),o}return o.d[0]?(re=!1,t=Se(t,o,0,e,1).times(o),re=!0,J(t)):(o.s=t.s,t=o),t};v.toNumber=function(){return+this};v.toOctal=function(o,e){return Ps(this,8,o,e)};v.toPower=v.pow=function(o){var e,t,n,r,i,s,a=this,u=a.constructor,c=+(o=new u(o));if(!a.d||!o.d||!a.d[0]||!o.d[0])return new u(Qe(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,i=u.rounding,o.eq(1))return J(a,n,i);if(e=st(o.e/ne),e>=o.d.length-1&&(t=c<0?-c:c)<=um)return r=Du(u,a,t,n),o.s<0?new u(1).div(r):J(r,n,i);if(s=a.s,s<0){if(e<o.d.length-1)return new u(NaN);if((o.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=Qe(+a,c),e=t==0||!isFinite(t)?st(c*(Math.log("0."+tt(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):(re=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),r=As(o.times(mn(a,n+t)),n),r.d&&(r=J(r,n+5,1),Vo(r.d,n,i)&&(e=n+10,r=J(As(o.times(mn(a,e+t)),e),e+5,1),+tt(r.d).slice(n+1,n+15)+1==1e14&&(r=J(r,n+1,0)))),r.s=s,re=!0,u.rounding=i,J(r,n,i))};v.toPrecision=function(o,e){var t,n=this,r=n.constructor;return o===void 0?t=qt(n,n.e<=r.toExpNeg||n.e>=r.toExpPos):(gt(o,1,pn),e===void 0?e=r.rounding:gt(e,0,8),n=J(new r(n),o,e),t=qt(n,o<=n.e||n.e<=r.toExpNeg,o)),n.isNeg()&&!n.isZero()?"-"+t:t};v.toSignificantDigits=v.toSD=function(o,e){var t=this,n=t.constructor;return o===void 0?(o=n.precision,e=n.rounding):(gt(o,1,pn),e===void 0?e=n.rounding:gt(e,0,8)),J(new n(t),o,e)};v.toString=function(){var o=this,e=o.constructor,t=qt(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()&&!o.isZero()?"-"+t:t};v.truncated=v.trunc=function(){return J(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var o=this,e=o.constructor,t=qt(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()?"-"+t:t};function tt(o){var e,t,n,r=o.length-1,i="",s=o[0];if(r>0){for(i+=s,e=1;e<r;e++)n=o[e]+"",t=ne-n.length,t&&(i+=ln(t)),i+=n;s=o[e],n=s+"",t=ne-n.length,t&&(i+=ln(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function gt(o,e,t){if(o!==~~o||o<e||o>t)throw Error(dn+o)}function Vo(o,e,t,n){var r,i,s,a;for(i=o[0];i>=10;i/=10)--e;return--e<0?(e+=ne,r=0):(r=Math.ceil((e+1)/ne),e%=ne),i=Qe(10,ne-e),a=o[r]%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)&&(o[r+1]/i/100|0)==Qe(10,e-2)-1||(a==i/2||a==0)&&(o[r+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)&&(o[r+1]/i/1e3|0)==Qe(10,e-3)-1,s}function Dr(o,e,t){for(var n,r=[0],i,s=0,a=o.length;s<a;){for(i=r.length;i--;)r[i]*=e;for(r[0]+=ys.indexOf(o.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 lm(o,e){var t,n,r;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),r=(1/zr(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),o.precision+=t,e=$n(o,1,e.times(r),new o(1));for(var i=t;i--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return o.precision-=t,e}var Se=function(){function o(n,r,i){var s,a=0,u=n.length;for(n=n.slice();u--;)s=n[u]*r+a,n[u]=s%i|0,a=s/i|0;return a&&n.unshift(a),n}function e(n,r,i,s){var a,u;if(i!=s)u=i>s?1:-1;else for(a=u=0;a<i;a++)if(n[a]!=r[a]){u=n[a]>r[a]?1:-1;break}return u}function t(n,r,i,s){for(var a=0;i--;)n[i]-=a,a=n[i]<r[i]?1:0,n[i]=a*s+n[i]-r[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,r,i,s,a,u){var c,l,m,d,p,y,f,b,g,w,A,k,I,T,S,x,R,B,N,q,_=n.constructor,$=n.s==r.s?1:-1,z=n.d,G=r.d;if(!z||!z[0]||!G||!G[0])return new _(!n.s||!r.s||(z?G&&z[0]==G[0]:!G)?NaN:z&&z[0]==0||!G?$*0:$/0);for(u?(p=1,l=n.e-r.e):(u=vt,p=ne,l=st(n.e/p)-st(r.e/p)),N=G.length,R=z.length,g=new _($),w=g.d=[],m=0;G[m]==(z[m]||0);m++);if(G[m]>(z[m]||0)&&l--,i==null?(T=i=_.precision,s=_.rounding):a?T=i+(n.e-r.e)+1:T=i,T<0)w.push(1),y=!0;else{if(T=T/p+2|0,m=0,N==1){for(d=0,G=G[0],T++;(m<R||d)&&T--;m++)S=d*u+(z[m]||0),w[m]=S/G|0,d=S%G|0;y=d||m<R}else{for(d=u/(G[0]+1)|0,d>1&&(G=o(G,d,u),z=o(z,d,u),N=G.length,R=z.length),x=N,A=z.slice(0,N),k=A.length;k<N;)A[k++]=0;q=G.slice(),q.unshift(0),B=G[0],G[1]>=u/2&&++B;do d=0,c=e(G,A,N,k),c<0?(I=A[0],N!=k&&(I=I*u+(A[1]||0)),d=I/B|0,d>1?(d>=u&&(d=u-1),f=o(G,d,u),b=f.length,k=A.length,c=e(f,A,b,k),c==1&&(d--,t(f,N<b?q:G,b,u))):(d==0&&(c=d=1),f=G.slice()),b=f.length,b<k&&f.unshift(0),t(A,f,k,u),c==-1&&(k=A.length,c=e(G,A,N,k),c<1&&(d++,t(A,N<k?q:G,k,u))),k=A.length):c===0&&(d++,A=[0]),w[m++]=d,c&&A[0]?A[k++]=z[x]||0:(A=[z[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,Mu=y;else{for(m=1,d=w[0];d>=10;d/=10)m++;g.e=m+l*p-1,J(g,a?i+g.e+1:i,s,y)}return g}}();function J(o,e,t,n){var r,i,s,a,u,c,l,m,d,p=o.constructor;e:if(e!=null){if(m=o.d,!m)return o;for(r=1,a=m[0];a>=10;a/=10)r++;if(i=e-r,i<0)i+=ne,s=e,l=m[d=0],u=l/Qe(10,r-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=u=0,r=1,i%=ne,s=i-ne+1}else break e;else{for(l=a=m[d],r=1;a>=10;a/=10)r++;i%=ne,s=i-ne+r,u=s<0?0:l/Qe(10,r-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%Qe(10,r-s-1)),c=t<4?(u||n)&&(t==0||t==(o.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(i>0?s>0?l/Qe(10,r-s):0:m[d-1])%10&1||t==(o.s<0?8:7)),e<1||!m[0])return m.length=0,c?(e-=o.e+1,m[0]=Qe(10,(ne-e%ne)%ne),o.e=-e||0):m[0]=o.e=0,o;if(i==0?(m.length=d,a=1,d--):(m.length=d+1,a=Qe(10,ne-i),m[d]=s>0?(l/Qe(10,r-s)%Qe(10,s)|0)*a:0),c)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&&(o.e++,m[0]==vt&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=vt)break;m[d--]=0,a=1}for(i=m.length;m[--i]===0;)m.pop()}return re&&(o.e>p.maxE?(o.d=null,o.e=NaN):o.e<p.minE&&(o.e=0,o.d=[0])),o}function qt(o,e,t){if(!o.isFinite())return qu(o);var n,r=o.e,i=tt(o.d),s=i.length;return e?(t&&(n=t-s)>0?i=i.charAt(0)+"."+i.slice(1)+ln(n):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(o.e<0?"e":"e+")+o.e):r<0?(i="0."+ln(-r-1)+i,t&&(n=t-s)>0&&(i+=ln(n))):r>=s?(i+=ln(r+1-s),t&&(n=t-r-1)>0&&(i=i+"."+ln(n))):((n=r+1)<s&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-s)>0&&(r+1===s&&(i+="."),i+=ln(n))),i}function Xr(o,e){var t=o[0];for(e*=ne;t>=10;t/=10)e++;return e}function Ur(o,e,t){if(e>cm)throw re=!0,t&&(o.precision=t),Error(vu);return J(new o(Wr),e,1,!0)}function Mt(o,e,t){if(e>gs)throw Error(vu);return J(new o(qr),e,t,!0)}function Eu(o){var e=o.length-1,t=e*ne+1;if(e=o[e],e){for(;e%10==0;e/=10)t--;for(e=o[0];e>=10;e/=10)t++}return t}function ln(o){for(var e="";o--;)e+="0";return e}function Du(o,e,t,n){var r,i=new o(1),s=Math.ceil(n/ne+4);for(re=!1;;){if(t%2&&(i=i.times(e),Lu(i.d,s)&&(r=!0)),t=st(t/2),t===0){t=i.d.length-1,r&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Lu(e.d,s)}return re=!0,i}function Ou(o){return o.d[o.d.length-1]&1}function Wu(o,e,t){for(var n,r=new o(e[0]),i=0;++i<e.length;)if(n=new o(e[i]),n.s)r[t](n)&&(r=n);else{r=n;break}return r}function As(o,e){var t,n,r,i,s,a,u,c=0,l=0,m=0,d=o.constructor,p=d.rounding,y=d.precision;if(!o.d||!o.d[0]||o.e>17)return new d(o.d?o.d[0]?o.s<0?0:1/0:1:o.s?o.s<0?0:o:0/0);for(e==null?(re=!1,u=y):u=e,a=new d(.03125);o.e>-2;)o=o.times(a),m+=5;for(n=Math.log(Qe(2,m))/Math.LN10*2+5|0,u+=n,t=i=s=new d(1),d.precision=u;;){if(i=J(i.times(o),u,1),t=t.times(++l),a=s.plus(Se(i,t,u,1)),tt(a.d).slice(0,u)===tt(s.d).slice(0,u)){for(r=m;r--;)s=J(s.times(s),u,1);if(e==null)if(c<3&&Vo(s.d,u-n,p,c))d.precision=u+=10,t=i=a=new d(1),l=0,c++;else return J(s,d.precision=y,p,re=!0);else return d.precision=y,s}s=a}}function mn(o,e){var t,n,r,i,s,a,u,c,l,m,d,p=1,y=10,f=o,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=tt(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(o),t=tt(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 c=Ur(g,l+2,A).times(i+""),f=mn(new g(n+"."+t.slice(1)),l-y).plus(c),g.precision=A,e==null?J(f,A,w,re=!0):f;for(m=f,u=s=f=Se(f.minus(1),f.plus(1),l,1),d=J(f.times(f),l,1),r=3;;){if(s=J(s.times(d),l,1),c=u.plus(Se(s,new g(r),l,1)),tt(c.d).slice(0,l)===tt(u.d).slice(0,l))if(u=u.times(2),i!==0&&(u=u.plus(Ur(g,l+2,A).times(i+""))),u=Se(u,new g(p),l,1),e==null)if(Vo(u.d,l-y,w,a))g.precision=l+=y,c=s=f=Se(m.minus(1),m.plus(1),l,1),d=J(f.times(f),l,1),r=a=1;else return J(u,g.precision=A,w,re=!0);else return g.precision=A,u;u=c,r+=2}}function qu(o){return String(o.s*o.s/0)}function ws(o,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,o.e=t=t-n-1,o.d=[],n=(t+1)%ne,t<0&&(n+=ne),n<r){for(n&&o.d.push(+e.slice(0,n)),r-=ne;n<r;)o.d.push(+e.slice(n,n+=ne));e=e.slice(n),n=ne-e.length}else n-=r;for(;n--;)e+="0";o.d.push(+e),re&&(o.e>o.constructor.maxE?(o.d=null,o.e=NaN):o.e<o.constructor.minE&&(o.e=0,o.d=[0]))}else o.e=0,o.d=[0];return o}function mm(o,e){var t,n,r,i,s,a,u,c,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Fu.test(e))return ws(o,e)}else if(e==="Infinity"||e==="NaN")return+e||(o.s=NaN),o.e=NaN,o.d=null,o;if(sm.test(e))t=16,e=e.toLowerCase();else if(im.test(e))t=2;else if(am.test(e))t=8;else throw Error(dn+e);for(i=e.search(/p/i),i>0?(u=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),s=i>=0,n=o.constructor,s&&(e=e.replace(".",""),a=e.length,i=a-i,r=Du(n,new n(t),i,i*2)),c=Dr(e,t,vt),l=c.length-1,i=l;c[i]===0;--i)c.pop();return i<0?new n(o.s*0):(o.e=Xr(c,l),o.d=c,re=!1,s&&(o=Se(o,r,a*4)),u&&(o=o.times(Math.abs(u)<54?Qe(2,u):Fo.pow(2,u))),re=!0,o)}function dm(o,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:$n(o,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/zr(5,t)),e=$n(o,2,e,e);for(var r,i=new o(5),s=new o(16),a=new o(20);t--;)r=e.times(e),e=e.times(i.plus(r.times(s.times(r).minus(a))));return e}function $n(o,e,t,n,r){var i,s,a,u,c=1,l=o.precision,m=Math.ceil(l/ne);for(re=!1,u=t.times(t),a=new o(n);;){if(s=Se(a.times(u),new o(e++*e++),l,1),a=r?n.plus(s):n.minus(s),n=Se(s.times(u),new o(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,c++}return re=!0,s.d.length=m+1,s}function zr(o,e){for(var t=o;--e;)t*=o;return t}function Uu(o,e){var t,n=e.s<0,r=Mt(o,o.precision,1),i=r.times(.5);if(e=e.abs(),e.lte(i))return $t=n?4:1,e;if(t=e.divToInt(r),t.isZero())$t=n?3:2;else{if(e=e.minus(t.times(r)),e.lte(i))return $t=Ou(t)?n?2:3:n?4:1,e;$t=Ou(t)?n?1:4:n?3:2}return e.minus(r).abs()}function Ps(o,e,t,n){var r,i,s,a,u,c,l,m,d,p=o.constructor,y=t!==void 0;if(y?(gt(t,1,pn),n===void 0?n=p.rounding:gt(n,0,8)):(t=p.precision,n=p.rounding),!o.isFinite())l=qu(o);else{for(l=qt(o),s=l.indexOf("."),y?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Dr(qt(d),10,r),d.e=d.d.length),m=Dr(l,10,r),i=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=y?"0p+0":"0";else{if(s<0?i--:(o=new p(o),o.d=m,o.e=i,o=Se(o,d,t,n,0,r),m=o.d,i=o.e,c=Mu),s=m[t],a=r/2,c=c||m[t+1]!==void 0,c=n<4?(s!==void 0||c)&&(n===0||n===(o.s<0?3:2)):s>a||s===a&&(n===4||c||n===6&&m[t-1]&1||n===(o.s<0?8:7)),m.length=t,c)for(;++m[--t]>r-1;)m[t]=0,t||(++i,m.unshift(1));for(u=m.length;!m[u-1];--u);for(s=0,l="";s<u;s++)l+=ys.charAt(m[s]);if(y){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)l+="0";for(m=Dr(l,r,e),u=m.length;!m[u-1];--u);for(s=1,l="1.";s<u;s++)l+=ys.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>u)for(i-=u;i--;)l+="0";else i<u&&(l=l.slice(0,i)+"."+l.slice(i))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return o.s<0?"-"+l:l}function Lu(o,e){if(o.length>e)return o.length=e,!0}function pm(o){return new this(o).abs()}function fm(o){return new this(o).acos()}function ym(o){return new this(o).acosh()}function bm(o,e){return new this(o).plus(e)}function gm(o){return new this(o).asin()}function Am(o){return new this(o).asinh()}function wm(o){return new this(o).atan()}function Pm(o){return new this(o).atanh()}function hm(o,e){o=new this(o),e=new this(e);var t,n=this.precision,r=this.rounding,i=n+4;return!o.s||!e.s?t=new this(NaN):!o.d&&!e.d?(t=Mt(this,i,1).times(e.s>0?.25:.75),t.s=o.s):!e.d||o.isZero()?(t=e.s<0?Mt(this,n,r):new this(0),t.s=o.s):!o.d||e.isZero()?(t=Mt(this,i,1).times(.5),t.s=o.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(Se(o,e,i,1)),e=Mt(this,i,1),this.precision=n,this.rounding=r,t=o.s<0?t.minus(e):t.plus(e)):t=this.atan(Se(o,e,i,1)),t}function km(o){return new this(o).cbrt()}function Tm(o){return J(o=new this(o),o.e+1,2)}function Im(o,e,t){return new this(o).clamp(e,t)}function Bm(o){if(!o||typeof o!="object")throw Error(Gr+"Object expected");var e,t,n,r=o.defaults===!0,i=["precision",1,pn,"rounding",0,8,"toExpNeg",-Zn,0,"toExpPos",0,Zn,"maxE",0,Zn,"minE",-Zn,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],r&&(this[t]=bs[t]),(n=o[t])!==void 0)if(st(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(dn+t+": "+n);if(t="crypto",r&&(this[t]=bs[t]),(n=o[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(_u);else this[t]=!1;else throw Error(dn+t+": "+n);return this}function xm(o){return new this(o).cos()}function Sm(o){return new this(o).cosh()}function Gu(o){var e,t,n;function r(i){var s,a,u,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,Nu(i)){c.s=i.s,re?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(u=typeof i,u==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(s=0,a=i;a>=10;a/=10)s++;re?s>r.maxE?(c.e=NaN,c.d=null):s<r.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[i]):(c.e=s,c.d=[i]);return}else if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return ws(c,i.toString())}else if(u!=="string")throw Error(dn+i);return(a=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(a===43&&(i=i.slice(1)),c.s=1),Fu.test(i)?ws(c,i):mm(c,i)}if(r.prototype=v,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=Bm,r.clone=Gu,r.isDecimal=Nu,r.abs=pm,r.acos=fm,r.acosh=ym,r.add=bm,r.asin=gm,r.asinh=Am,r.atan=wm,r.atanh=Pm,r.atan2=hm,r.cbrt=km,r.ceil=Tm,r.clamp=Im,r.cos=xm,r.cosh=Sm,r.div=Km,r.exp=Cm,r.floor=Rm,r.hypot=Om,r.ln=Lm,r.log=Nm,r.log10=vm,r.log2=Mm,r.max=_m,r.min=Vm,r.mod=Fm,r.mul=Em,r.pow=Dm,r.random=Wm,r.round=qm,r.sign=Um,r.sin=Gm,r.sinh=Xm,r.sqrt=zm,r.sub=Qm,r.sum=Ym,r.tan=jm,r.tanh=Hm,r.trunc=Zm,o===void 0&&(o={}),o&&o.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)o.hasOwnProperty(t=n[e++])||(o[t]=this[t]);return r.config(o),r}function Km(o,e){return new this(o).div(e)}function Cm(o){return new this(o).exp()}function Rm(o){return J(o=new this(o),o.e+1,3)}function Om(){var o,e,t=new this(0);for(re=!1,o=0;o<arguments.length;)if(e=new this(arguments[o++]),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 Nu(o){return o instanceof Fo||o&&o.toStringTag===Vu||!1}function Lm(o){return new this(o).ln()}function Nm(o,e){return new this(o).log(e)}function Mm(o){return new this(o).log(2)}function vm(o){return new this(o).log(10)}function _m(){return Wu(this,arguments,"lt")}function Vm(){return Wu(this,arguments,"gt")}function Fm(o,e){return new this(o).mod(e)}function Em(o,e){return new this(o).mul(e)}function Dm(o,e){return new this(o).pow(e)}function Wm(o){var e,t,n,r,i=0,s=new this(1),a=[];if(o===void 0?o=this.precision:gt(o,1,pn),n=Math.ceil(o/ne),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)r=e[i],r>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)r=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,i):(a.push(r%1e7),i+=4);i=n/4}else throw Error(_u);else for(;i<n;)a[i++]=Math.random()*1e7|0;for(n=a[--i],o%=ne,n&&o&&(r=Qe(10,ne-o),a[i]=(n/r|0)*r);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,r=a[0];r>=10;r/=10)n++;n<ne&&(t-=ne-n)}return s.e=t,s.d=a,s}function qm(o){return J(o=new this(o),o.e+1,this.rounding)}function Um(o){return o=new this(o),o.d?o.d[0]?o.s:0*o.s:o.s||NaN}function Gm(o){return new this(o).sin()}function Xm(o){return new this(o).sinh()}function zm(o){return new this(o).sqrt()}function Qm(o,e){return new this(o).sub(e)}function Ym(){var o=0,e=arguments,t=new this(e[o]);for(re=!1;t.s&&++o<e.length;)t=t.plus(e[o]);return re=!0,J(t,this.precision,this.rounding)}function jm(o){return new this(o).tan()}function Hm(o){return new this(o).tanh()}function Zm(o){return J(o=new this(o),o.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var Fo=v.constructor=Gu(bs);Wr=new Fo(Wr);qr=new Fo(qr);var O=Fo;var Zr=require("@solana/web3.js");var Xu=require("@solana/spl-token"),ke=require("@solana/web3.js");function P({pubkey:o,isSigner:e=!1,isWritable:t=!0}){return{pubkey:o,isWritable:t,isSigner:e}}var Qr=[P({pubkey:Xu.TOKEN_PROGRAM_ID,isWritable:!1}),P({pubkey:ke.SystemProgram.programId,isWritable:!1}),P({pubkey:ke.SYSVAR_RENT_PUBKEY,isWritable:!1})];function Yr({publicKey:o,transformSol:e}){let t=jr(o.toString());if(t instanceof ke.PublicKey)return e&&t.equals(We)?H:t;if(e&&t.toString()===We.toBase58())return H;if(typeof t=="string"){if(t===ke.PublicKey.default.toBase58())return ke.PublicKey.default;try{return new ke.PublicKey(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function jr(o){try{return new ke.PublicKey(o)}catch{return o}}var Eo=new ke.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Do=new ke.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),dt=new ke.PublicKey("SysvarRent111111111111111111111111111111111"),Hr=new ke.PublicKey("SysvarC1ock11111111111111111111111111111111"),_n=new ke.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Wo=new ke.PublicKey("Sysvar1nstructions1111111111111111111111111"),qo=ke.SystemProgram.programId,$m=new ke.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Jm=new ke.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),ed=new ke.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),td=new ke.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),nd=new ke.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),od=new ke.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),rd=new ke.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),id=new ke.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),sd=new ke.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),ad=new ke.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),ud=new ke.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),H=new ke.PublicKey("So11111111111111111111111111111111111111112"),We=ke.PublicKey.default;function At(o){return Yr({publicKey:o,transformSol:!0})}var zu=require("@solana/web3.js"),hs=require("@solana/spl-token"),_t={chainId:101,address:zu.PublicKey.default.toBase58(),programId:hs.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"}},qe={chainId:101,address:"So11111111111111111111111111111111111111112",programId:hs.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 ks=class{constructor({mint:e,decimals:t,symbol:n,name:r,skipMint:i=!1,isToken2022:s=!1}){if(e===We.toBase58()||e instanceof Zr.PublicKey&&We.equals(e)){this.decimals=qe.decimals,this.symbol=qe.symbol,this.name=qe.name,this.mint=new Zr.PublicKey(qe.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=i?Zr.PublicKey.default:Yr({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Ae=ks;Ae.WSOL=new ks(E(C({},qe),{mint:qe.address}));var Go=me(require("big.js")),Yu=me(require("bn.js")),ju=me(require("decimal.js-light"));var Qu=me(require("toformat")),cd=Qu.default,Uo=cd;var $r=le("module/fraction"),Ts=Uo(Go.default),Xo=Uo(ju.default),ld={[0]:Xo.ROUND_DOWN,[1]:Xo.ROUND_HALF_UP,[2]:Xo.ROUND_UP},md={[0]:Go.default.roundDown,[1]:Go.default.roundHalfUp,[2]:Go.default.roundUp},ie=class{constructor(e,t=new Yu.default(1)){this.numerator=j(e),this.denominator=j(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new ie(this.denominator,this.numerator)}add(e){let t=e instanceof ie?e:new ie(j(e));return this.denominator.eq(t.denominator)?new ie(this.numerator.add(t.numerator),this.denominator):new ie(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof ie?e:new ie(j(e));return this.denominator.eq(t.denominator)?new ie(this.numerator.sub(t.numerator),this.denominator):new ie(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof ie?e:new ie(j(e));return new ie(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof ie?e:new ie(j(e));return ne