@cobaltx/sdk-v2
Version:
An SDK for building applications on top of CobaltX.
1 lines • 409 kB
JavaScript
"use strict";var Bl=Object.create;var Lo=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var Sl=Object.getOwnPropertyNames;var Kl=Object.getPrototypeOf,Cl=Object.prototype.hasOwnProperty;var Ll=(o,e)=>{for(var t in e)Lo(o,t,{get:e[t],enumerable:!0})},uu=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Sl(e))!Cl.call(o,i)&&i!==t&&Lo(o,i,{get:()=>e[i],enumerable:!(n=xl(e,i))||n.enumerable});return o};var le=(o,e,t)=>(t=o!=null?Bl(Kl(o)):{},uu(e||!o||!o.__esModule?Lo(t,"default",{value:o,enumerable:!0}):t,o)),Rl=o=>uu(Lo({},"__esModule",{value:!0}),o);var up={};Ll(up,{AMM_CONFIG_SEED:()=>pc,BIT_PRECISION:()=>Es,Clmm:()=>di,ClmmConfigLayout:()=>na,ClmmInstrument:()=>ke,CobaltX:()=>Ko,ConstantProductCurve:()=>oo,CpmmConfigInfoLayout:()=>wa,CpmmFee:()=>ro,CpmmPoolInfoLayout:()=>lo,CurveCalculator:()=>ao,DataElement:()=>tl,EXTENSION_TICKARRAY_BITMAP_SIZE:()=>mr,FARM_LOCK_MINT:()=>Sa,FARM_LOCK_VAULT:()=>Ka,FARM_PROGRAM_TO_VERSION:()=>Vt,FARM_VERSION_TO_LEDGER_LAYOUT:()=>La,FARM_VERSION_TO_STATE_LAYOUT:()=>Ca,FEE_RATE_DENOMINATOR:()=>to,FEE_RATE_DENOMINATOR_VALUE:()=>Ar,FETCH_TICKARRAY_COUNT:()=>kc,Fee:()=>dc,LIQUIDITY_FEES_DENOMINATOR:()=>Ao,LIQUIDITY_FEES_NUMERATOR:()=>Wr,LIQUIDITY_VERSION_TO_SERUM_VERSION:()=>$c,LIQUIDITY_VERSION_TO_STATE_LAYOUT:()=>qd,LOCK_LIQUIDITY_SEED:()=>Nc,LOG_B_2_X32:()=>Fs,LOG_B_P_ERR_MARGIN_LOWER_X64:()=>Ds,LOG_B_P_ERR_MARGIN_UPPER_X64:()=>Ws,LiquidityMath:()=>pe,LockClPositionLayoutV2:()=>yd,LockPositionLayout:()=>bd,MARKET_STATE_LAYOUT_V2:()=>Zr,MARKET_STATE_LAYOUT_V3:()=>$r,MARKET_VERSION_TO_STATE_LAYOUT:()=>Ja,MAX_SQRT_PRICE_X64:()=>_t,MAX_SQRT_PRICE_X64_SUB_ONE:()=>eo,MAX_TICK:()=>ct,MIN_SQRT_PRICE_X64:()=>Nt,MIN_SQRT_PRICE_X64_ADD_ONE:()=>Ji,MIN_TICK:()=>ot,MODEL_DATA_PUBKEY:()=>Gn,Market:()=>Io,MathUtil:()=>oe,MaxU64:()=>sr,MaxUint128:()=>Vs,NEGATIVE_ONE:()=>on,OBSERVATION_SEED:()=>Pc,ONE:()=>St,OPERATION_SEED:()=>Ac,ObservationInfoLayout:()=>ia,ObservationLayout:()=>Tc,OperationLayout:()=>oa,POOL_LOCK_ID_SEED:()=>Ys,POOL_REWARD_VAULT_SEED:()=>yc,POOL_SEED:()=>fc,POOL_TICK_ARRAY_BITMAP_SEED:()=>wc,POOL_VAULT_SEED:()=>bc,POSITION_SEED:()=>zs,PoolInfoLayout:()=>Rn,PoolUtils:()=>Be,PositionInfoLayout:()=>mi,PositionRewardInfoLayout:()=>Bc,PositionUtils:()=>ui,ProtocolPositionLayout:()=>fd,Q128:()=>$i,Q64:()=>Kt,RewardInfo:()=>Ic,RoundDirection:()=>ua,SERUM_PROGRAMID_TO_VERSION:()=>Za,SERUM_VERSION_TO_PROGRAMID:()=>$a,SOL_INFO:()=>zt,SPL_MINT_LAYOUT:()=>wd,SqrtPriceMath:()=>ne,StableLayout:()=>Un,SwapMath:()=>Ln,TICK_ARRAY_BITMAP_SIZE:()=>Cn,TICK_ARRAY_SEED:()=>gc,TICK_ARRAY_SIZE:()=>Ue,TICK_SPACINGS:()=>sd,TOKEN_WSOL:()=>ze,TickArrayBitmap:()=>rn,TickArrayBitmapExtensionLayout:()=>ea,TickArrayBitmapExtensionUtils:()=>li,TickArrayLayout:()=>ci,TickLayout:()=>xc,TickMath:()=>On,TickQuery:()=>fe,TickUtils:()=>H,U64Resolution:()=>oi,U64_IGNORE_RANGE:()=>ud,Voter:()=>Ba,VoterDepositEntry:()=>qc,VoterLockup:()=>Wc,VoterRegistrar:()=>Ia,VoterVotingMintConfig:()=>Dc,ZERO:()=>be,addLiquidityLayout:()=>Xr,associatedLedgerAccountLayout:()=>kr,calFarmRewardAmount:()=>Nr,ceilDiv:()=>Oc,claimLayout:()=>Ti,clmmComputeInfoToApiInfo:()=>Js,closeAccountInstruction:()=>tn,collectCpFeeInstruction:()=>Aa,computeSwap:()=>sp,cpmmLockPositionInstruction:()=>_c,createAssociatedLedgerAccountInstruction:()=>wi,createPoolFeeLayout:()=>Wa,createPoolV4InstructionV2:()=>Hr,createPoolV4Layout:()=>Wd,createWSolAccountInstructions:()=>nn,dwLayout:()=>pt,farmAddRewardLayout:()=>Br,farmLedgerLayoutV3_1:()=>Rd,farmLedgerLayoutV3_2:()=>gi,farmLedgerLayoutV5_1:()=>Od,farmLedgerLayoutV5_2:()=>ha,farmLedgerLayoutV6_1:()=>Ta,farmRewardInfoToConfig:()=>Oa,farmRewardLayout:()=>Tr,farmRewardRestartLayout:()=>Ir,farmRewardTimeInfoLayout:()=>Fc,farmStateV3Layout:()=>Pa,farmStateV5Layout:()=>ka,farmStateV6Layout:()=>yi,fetchMultipleFarmInfoAndUpdate:()=>Md,fetchMultipleInfo:()=>ep,fixedSwapInLayout:()=>qr,fixedSwapOutLayout:()=>Ur,floorDiv:()=>ca,formatLayout:()=>rl,generatePubKey:()=>ve,getAssociatedAuthority:()=>Ra,getAssociatedConfigId:()=>Po,getAssociatedLedgerAccount:()=>rt,getAssociatedLedgerPoolAccount:()=>Ai,getAssociatedOpenOrders:()=>pl,getAssociatedPoolKeys:()=>Yr,getCpLockPda:()=>uo,getCpmmPdaAmmConfigId:()=>xd,getCpmmPdaPoolId:()=>Pr,getCreatePoolKeys:()=>da,getDepositEntryIndex:()=>_r,getDxByDyBaseIn:()=>Ga,getDyByDxBaseIn:()=>Ua,getFarmLedgerLayout:()=>Wn,getFarmStateLayout:()=>Uc,getLiquidityAssociatedAuthority:()=>jr,getLiquidityAssociatedId:()=>Mn,getLiquidityFromAmounts:()=>dd,getPdaAmmConfigId:()=>md,getPdaExBitmapAccount:()=>Ee,getPdaLockClPositionIdV2:()=>ai,getPdaLockPositionId:()=>lr,getPdaLpMint:()=>Mc,getPdaMetadataKey:()=>Kn,getPdaObservationAccount:()=>js,getPdaObservationId:()=>bi,getPdaOperationAccount:()=>si,getPdaPersonalPositionAddress:()=>lt,getPdaPoolAuthority:()=>Fn,getPdaPoolId:()=>Qs,getPdaPoolRewardVaulId:()=>Hs,getPdaPoolVaultId:()=>cr,getPdaProtocolPositionAddress:()=>Ft,getPdaTickArrayAddress:()=>de,getPdaVault:()=>ma,getRegistrarAddress:()=>Kr,getStablePrice:()=>Xa,getTokenOwnerRecordAddress:()=>Mr,getVoterAddress:()=>Rr,getVoterWeightRecordAddress:()=>Or,getVotingMintAuthority:()=>Lr,getVotingTokenMint:()=>Cr,governanceCreateTokenOwnerRecord:()=>Hc,i16ToBytes:()=>cd,i32ToBytes:()=>no,initPoolLayout:()=>Gr,initTokenAccountInstruction:()=>rr,initializeMarket:()=>fl,isValidFarmVersion:()=>xr,isZero:()=>ri,judgeFarmType:()=>Nd,leadingZeros:()=>ar,leastSignificantBit:()=>Xs,liquidityStateV4Layout:()=>Si,liquidityStateV5Layout:()=>Jc,makeAMMSwapInstruction:()=>wo,makeAddLiquidityInstruction:()=>za,makeAddNewRewardInstruction:()=>Vr,makeClaimInstruction:()=>go,makeClaimInstructionV4:()=>Dr,makeCpmmLockInstruction:()=>ga,makeCreateCpmmPoolInInstruction:()=>pa,makeCreateFarmInstruction:()=>Ma,makeCreateMarketInstruction:()=>ho,makeCreatorWithdrawFarmRewardInstruction:()=>Na,makeDepositCpmmInInstruction:()=>fa,makeDepositInstructionV3:()=>va,makeDepositInstructionV5:()=>Va,makeDepositInstructionV6:()=>Ea,makeDepositTokenInstruction:()=>vd,makeDepositWithdrawInstruction:()=>Ed,makeInitPoolInstructionV4:()=>$d,makePurchaseInstruction:()=>Fd,makeRestartRewardInstruction:()=>vr,makeSimulatePoolInfoInstruction:()=>Qa,makeSwapCpmmBaseInInInstruction:()=>co,makeSwapCpmmBaseOutInInstruction:()=>ya,makeSwapFixedInInstruction:()=>al,makeSwapFixedOutInstruction:()=>ul,makeSwapInstruction:()=>nu,makeTransferInstruction:()=>_s,makeWithdrawCpmmInInstruction:()=>ba,makeWithdrawInstructionV3:()=>hi,makeWithdrawInstructionV4:()=>_a,makeWithdrawInstructionV5:()=>ki,makeWithdrawInstructionV6:()=>Pi,makeWithdrawTokenInstruction:()=>Vd,mockCreatePoolInfo:()=>ad,mockV3CreatePoolInfo:()=>qs,modelDataInfoLayout:()=>nl,mostSignificantBit:()=>Gs,parseTokenAccountResp:()=>Ns,parseTokenInfo:()=>nd,poolTypeV6:()=>bn,purchaseLayout:()=>Er,realFarmStateV3Layout:()=>vc,realFarmStateV5Layout:()=>Vc,realFarmV6Layout:()=>Ec,removeLiquidityInstruction:()=>Qr,removeLiquidityLayout:()=>zr,route1Instruction:()=>np,route2Instruction:()=>ip,routeInstruction:()=>bl,simulatePoolInfoInstruction:()=>Zd,solToWSolToken:()=>od,splAccountLayout:()=>cn,swapBaseInAutoAccount:()=>op,swapBaseOutAutoAccount:()=>rp,toAmmComputePoolInfo:()=>ko,toApiV3Token:()=>it,toFeeConfig:()=>fn,toToken:()=>Zi,toTokenAmount:()=>ii,toTokenInfo:()=>id,trailingZeros:()=>ur,u16ToBytes:()=>Us,u32ToBytes:()=>ld,unionArr:()=>ap,updateFarmPoolInfo:()=>Gc,validateFarmRewards:()=>Sr,voterStakeRegistryCreateDepositEntry:()=>Yc,voterStakeRegistryCreateVoter:()=>jc,voterStakeRegistryDeposit:()=>Xc,voterStakeRegistryUpdateVoterWeightRecord:()=>zc,voterStakeRegistryWithdraw:()=>Qc,wSolToSolToken:()=>rd,withdrawRewardLayout:()=>hr});module.exports=Rl(up);var pu=require("@solana/web3.js"),Qn=le(require("bn.js"));var $=require("@solana/buffer-layout"),Ro=$.Layout,cu=$.Structure;var ts=$.UInt;var lu=$.u8,un=$.u16;var ns=$.u32;var mu=$.nu64;var Ce=$.s32;var du=$.seq;var Pe=$.blob;var is=$.bits;var vn=class extends Ro{constructor(t,n,i){super(t,i);this.blob=Pe(t),this.signed=n}decode(t,n=0){let i=new Qn.default(this.blob.decode(t,n),10,"le");return this.signed?i.fromTwos(this.span*8).clone():i}encode(t,n,i=0){return typeof t=="number"&&(t=new Qn.default(t)),this.signed&&(t=t.toTwos(this.span*8)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),n,i)}},Oo=class extends Ro{constructor(t){super(8,t);this._lower=is(ns(),!1),this._upper=is(ns(),!1)}addBoolean(t){this._lower.fields.length<32?this._lower.addBoolean(t):this._upper.addBoolean(t)}decode(t,n=0){let i=this._lower.decode(t,n),r=this._upper.decode(t,n+this._lower.span);return{...i,...r}}encode(t,n,i=0){return this._lower.encode(t,n,i)+this._upper.encode(t,n,i+this._lower.span)}};function D(o){return new ts(1,o)}function tt(o){return new ts(4,o)}function k(o){return new vn(8,!1,o)}function J(o){return new vn(16,!1,o)}function fu(o){return new vn(1,!0,o)}function Hn(o){return new vn(8,!0,o)}function bu(o){return new vn(16,!0,o)}var Mo=class extends Ro{constructor(t,n,i,r){super(t.span,r);this.layout=t,this.decoder=n,this.encoder=i}decode(t,n){return this.decoder(this.layout.decode(t,n))}encode(t,n,i){return this.layout.encode(this.encoder(t),n,i)}getSpan(t,n){return this.layout.getSpan(t,n)}};function O(o){return new Mo(Pe(32),e=>new pu.PublicKey(e),e=>e.toBuffer(),o)}function Re(o){return new Mo(lu(),Ol,Ml,o)}function Ol(o){if(o===0)return!1;if(o===1)return!0;throw new Error("Invalid bool: "+o)}function Ml(o){return o?1:0}var os=class extends cu{decode(e,t){return super.decode(e,t)}};function _(o,e,t){return new os(o,e,t)}function Q(o,e,t){let n,i=typeof e=="number"?e:(0,Qn.isBN)(e)?e.toNumber():new Proxy(e,{get(r,s){if(!n){let a=Reflect.get(r,"count");n=(0,Qn.isBN)(a)?a.toNumber():a,Reflect.set(r,"count",n)}return Reflect.get(r,s)},set(r,s,a){return s==="count"&&(n=a),Reflect.set(r,s,a)}});return du(o,i,t)}var cn=_([O("mint"),O("owner"),k("amount"),tt("delegateOption"),O("delegate"),D("state"),tt("isNativeOption"),k("isNative"),k("delegatedAmount"),tt("closeAuthorityOption"),O("closeAuthority")]);function Nl(o){return o instanceof Uint8Array||ArrayBuffer.isView(o)&&o.constructor.name==="Uint8Array"}function rs(o,...e){if(!Nl(o))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(o.length))throw new Error("Uint8Array expected of length "+e+", got length="+o.length)}function ss(o,e=!0){if(o.destroyed)throw new Error("Hash instance has been destroyed");if(e&&o.finished)throw new Error("Hash#digest() has already been called")}function yu(o,e){rs(o);let t=e.outputLen;if(o.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var _o=o=>new DataView(o.buffer,o.byteOffset,o.byteLength),qt=(o,e)=>o<<32-e|o>>>e;function _l(o){if(typeof o!="string")throw new Error("utf8ToBytes expected string, got "+typeof o);return new Uint8Array(new TextEncoder().encode(o))}function as(o){return typeof o=="string"&&(o=_l(o)),rs(o),o}var No=class{clone(){return this._cloneInto()}};function gu(o){let e=n=>o().update(as(n)).digest(),t=o();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>o(),e}function vl(o,e,t,n){if(typeof o.setBigUint64=="function")return o.setBigUint64(e,t,n);let i=BigInt(32),r=BigInt(4294967295),s=Number(t>>i&r),a=Number(t&r),c=n?4:0,u=n?0:4;o.setUint32(e+c,s,n),o.setUint32(e+u,a,n)}var Au=(o,e,t)=>o&e^~o&t,wu=(o,e,t)=>o&e^o&t^e&t,vo=class extends No{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=_o(this.buffer)}update(e){ss(this);let{view:t,buffer:n,blockLen:i}=this;e=as(e);let r=e.length;for(let s=0;s<r;){let a=Math.min(i-this.pos,r-s);if(a===i){let c=_o(e);for(;i<=r-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ss(this),yu(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:r}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let m=s;m<i;m++)t[m]=0;vl(n,i-8,BigInt(this.length*8),r),this.process(n,0);let a=_o(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<u;m++)a.setUint32(4*m,l[m],r)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:r,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=r,e.destroyed=s,i%t&&e.buffer.set(n),e}};var Vl=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),An=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),wn=new Uint32Array(64),us=class extends vo{constructor(){super(64,32,8,!1),this.A=An[0]|0,this.B=An[1]|0,this.C=An[2]|0,this.D=An[3]|0,this.E=An[4]|0,this.F=An[5]|0,this.G=An[6]|0,this.H=An[7]|0}get(){let{A:e,B:t,C:n,D:i,E:r,F:s,G:a,H:c}=this;return[e,t,n,i,r,s,a,c]}set(e,t,n,i,r,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=r|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let m=0;m<16;m++,t+=4)wn[m]=e.getUint32(t,!1);for(let m=16;m<64;m++){let d=wn[m-15],p=wn[m-2],b=qt(d,7)^qt(d,18)^d>>>3,f=qt(p,17)^qt(p,19)^p>>>10;wn[m]=f+wn[m-7]+b+wn[m-16]|0}let{A:n,B:i,C:r,D:s,E:a,F:c,G:u,H:l}=this;for(let m=0;m<64;m++){let d=qt(a,6)^qt(a,11)^qt(a,25),p=l+d+Au(a,c,u)+Vl[m]+wn[m]|0,f=(qt(n,2)^qt(n,13)^qt(n,22))+wu(n,i,r)|0;l=u,u=c,c=a,a=s+p|0,s=r,r=i,i=n,n=p+f|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,i,r,s,a,c,u,l)}roundClean(){wn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Pu=gu(()=>new us);var uc=require("@solana/spl-token"),ji=require("@solana/web3.js"),cc=le(require("bn.js"));var Pn=require("@solana/spl-token"),ds=require("@solana/web3.js");var Mi=require("lodash");var cs=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}},ku={},El={};function me(o){let e=(0,Mi.get)(ku,o);if(!e){let t=(0,Mi.get)(El,o);e=new cs({name:o,logLevel:t}),(0,Mi.set)(ku,o,e)}return e}var ls=me("CobaltX_accountInfo_util");async function Ut(o,e,t){let{batchRequest:n,commitment:i="confirmed",chunkCount:r=100}={batchRequest:!1,...t},s=ms(e,r),a=new Array(s.length).fill([]);if(n){let c=s.map(m=>{let d=o._buildArgs([m.map(p=>p.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:d}}),u=ms(c,10);a=(await(await Promise.all(u.map(async m=>await o._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&ls.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:b,lamports:f,owner:y,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&ls.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:b,lamports:f,owner:new ds.PublicKey(y),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(c=>o.getMultipleAccountsInfo(c,i)))}catch(c){c instanceof Error&&ls.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function qe(o,e,t){let n=await Ut(o,e.map(i=>i.pubkey),t);return e.map((i,r)=>({...i,accountInfo:n[r]}))}async function jn({connection:o,mints:e,config:t}){var r,s,a;if(e.length===0)return{};let n=await qe(o,e.map(c=>({pubkey:at(c)})),t),i={};for(let c of n){if(!c.accountInfo||c.accountInfo.data.length<Pn.MINT_SIZE){console.log("invalid mint account",c.pubkey.toBase58());continue}let u=(0,Pn.unpackMint)(c.pubkey,c.accountInfo,(r=c.accountInfo)==null?void 0:r.owner);i[c.pubkey.toString()]={...u,programId:((s=c.accountInfo)==null?void 0:s.owner)||Pn.TOKEN_PROGRAM_ID,feeConfig:(a=(0,Pn.getTransferFeeConfig)(u))!=null?a:void 0}}return i[ds.PublicKey.default.toBase58()]=i[j.toBase58()],i}var en=le(require("bn.js"));var Yn=9e15,In=1e9,ps="0123456789abcdef",Eo="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Fo="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",fs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Yn,maxE:Yn,crypto:!1},Bu,ln,re=!0,Wo="[DecimalError] ",Tn=Wo+"Invalid argument: ",xu=Wo+"Precision limit exceeded",Su=Wo+"crypto unavailable",Ku="[object Decimal]",ut=Math.floor,Xe=Math.pow,Fl=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Dl=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Wl=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Cu=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Xt=1e7,ie=7,ql=9007199254740991,Ul=Eo.length-1,bs=Fo.length-1,E={toStringTag:Ku};E.absoluteValue=E.abs=function(){var o=new this.constructor(this);return o.s<0&&(o.s=1),ee(o)};E.ceil=function(){return ee(new this.constructor(this),this.e+1,2)};E.clampedTo=E.clamp=function(o,e){var t,n=this,i=n.constructor;if(o=new i(o),e=new i(e),!o.s||!e.s)return new i(NaN);if(o.gt(e))throw Error(Tn+e);return t=n.cmp(o),t<0?o:n.cmp(e)>0?e:new i(n)};E.comparedTo=E.cmp=function(o){var e,t,n,i,r=this,s=r.d,a=(o=new r.constructor(o)).d,c=r.s,u=o.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(r.e!==o.e)return r.e>o.e^c<0?1:-1;for(n=s.length,i=a.length,e=0,t=n<i?n:i;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};E.cosine=E.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())+ie,n.rounding=1,t=Gl(n,Nu(n,t)),n.precision=o,n.rounding=e,ee(ln==2||ln==3?t.neg():t,o,e,!0)):new n(1):new n(NaN)};E.cubeRoot=E.cbrt=function(){var o,e,t,n,i,r,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(re=!1,r=l.s*Xe(l.s*l,1/3),!r||Math.abs(r)==1/0?(t=nt(l.d),o=l.e,(r=(o-t.length+1)%3)&&(t+=r==1||r==-2?"0":"00"),r=Xe(t,1/3),o=ut((o+1)/3)-(o%3==(o<0?-1:2)),r==1/0?t="5e"+o:(t=r.toExponential(),t=t.slice(0,t.indexOf("e")+1)+o),n=new m(t),n.s=l.s):n=new m(r.toString()),s=(o=m.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=Ie(u.plus(l).times(a),u.plus(c),s+2,1),nt(a.d).slice(0,s)===(t=nt(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!i&&t=="4999"){if(!i&&(ee(a,o+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(ee(n,o+1,1),e=!n.times(n).times(n).eq(l));break}return re=!0,ee(n,o,m.rounding,e)};E.decimalPlaces=E.dp=function(){var o,e=this.d,t=NaN;if(e){if(o=e.length-1,t=(o-ut(this.e/ie))*ie,o=e[o],o)for(;o%10==0;o/=10)t--;t<0&&(t=0)}return t};E.dividedBy=E.div=function(o){return Ie(this,new this.constructor(o))};E.dividedToIntegerBy=E.divToInt=function(o){var e=this,t=e.constructor;return ee(Ie(e,new t(o),0,1,1),t.precision,t.rounding)};E.equals=E.eq=function(o){return this.cmp(o)===0};E.floor=function(){return ee(new this.constructor(this),this.e+1,3)};E.greaterThan=E.gt=function(o){return this.cmp(o)>0};E.greaterThanOrEqualTo=E.gte=function(o){var e=this.cmp(o);return e==1||e===0};E.hyperbolicCosine=E.cosh=function(){var o,e,t,n,i,r=this,s=r.constructor,a=new s(1);if(!r.isFinite())return new s(r.s?1/0:NaN);if(r.isZero())return a;t=s.precision,n=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,i=r.d.length,i<32?(o=Math.ceil(i/3),e=(1/Uo(4,o)).toString()):(o=16,e="2.3283064365386962890625e-10"),r=Zn(s,1,r.times(e),new s(1),!0);for(var c,u=o,l=new s(8);u--;)c=r.times(r),r=a.minus(c.times(l.minus(c.times(l))));return ee(r,s.precision=t,s.rounding=n,!0)};E.hyperbolicSine=E.sinh=function(){var o,e,t,n,i=this,r=i.constructor;if(!i.isFinite()||i.isZero())return new r(i);if(e=r.precision,t=r.rounding,r.precision=e+Math.max(i.e,i.sd())+4,r.rounding=1,n=i.d.length,n<3)i=Zn(r,2,i,i,!0);else{o=1.4*Math.sqrt(n),o=o>16?16:o|0,i=i.times(1/Uo(5,o)),i=Zn(r,2,i,i,!0);for(var s,a=new r(5),c=new r(16),u=new r(20);o--;)s=i.times(i),i=i.times(a.plus(s.times(c.times(s).plus(u))))}return r.precision=e,r.rounding=t,ee(i,e,t,!0)};E.hyperbolicTangent=E.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,Ie(t.sinh(),t.cosh(),n.precision=o,n.rounding=e)):new n(t.s)};E.inverseCosine=E.acos=function(){var o,e=this,t=e.constructor,n=e.abs().cmp(1),i=t.precision,r=t.rounding;return n!==-1?n===0?e.isNeg()?Gt(t,i,r):new t(0):new t(NaN):e.isZero()?Gt(t,i+4,r).times(.5):(t.precision=i+6,t.rounding=1,e=e.asin(),o=Gt(t,i+4,r).times(.5),t.precision=i,t.rounding=r,o.minus(e))};E.inverseHyperbolicCosine=E.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)};E.inverseHyperbolicSine=E.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())};E.inverseHyperbolicTangent=E.atanh=function(){var o,e,t,n,i=this,r=i.constructor;return i.isFinite()?i.e>=0?new r(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(o=r.precision,e=r.rounding,n=i.sd(),Math.max(n,o)<2*-i.e-1?ee(new r(i),o,e,!0):(r.precision=t=n-i.e,i=Ie(i.plus(1),new r(1).minus(i),t+o,1),r.precision=o+4,r.rounding=1,i=i.ln(),r.precision=o,r.rounding=e,i.times(.5))):new r(NaN)};E.inverseSine=E.asin=function(){var o,e,t,n,i=this,r=i.constructor;return i.isZero()?new r(i):(e=i.abs().cmp(1),t=r.precision,n=r.rounding,e!==-1?e===0?(o=Gt(r,t+4,n).times(.5),o.s=i.s,o):new r(NaN):(r.precision=t+6,r.rounding=1,i=i.div(new r(1).minus(i.times(i)).sqrt().plus(1)).atan(),r.precision=t,r.rounding=n,i.times(2)))};E.inverseTangent=E.atan=function(){var o,e,t,n,i,r,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<=bs)return s=Gt(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=bs)return s=Gt(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/ie+2|0),o=t;o;--o)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(re=!1,e=Math.ceil(a/ie),n=1,c=u.times(u),s=new l(u),i=u;o!==-1;)if(i=i.times(c),r=s.minus(i.div(n+=2)),i=i.times(c),s=r.plus(i.div(n+=2)),s.d[e]!==void 0)for(o=e;s.d[o]===r.d[o]&&o--;);return t&&(s=s.times(2<<t-1)),re=!0,ee(s,l.precision=m,l.rounding=d,!0)};E.isFinite=function(){return!!this.d};E.isInteger=E.isInt=function(){return!!this.d&&ut(this.e/ie)>this.d.length-2};E.isNaN=function(){return!this.s};E.isNegative=E.isNeg=function(){return this.s<0};E.isPositive=E.isPos=function(){return this.s>0};E.isZero=function(){return!!this.d&&this.d[0]===0};E.lessThan=E.lt=function(o){return this.cmp(o)<0};E.lessThanOrEqualTo=E.lte=function(o){return this.cmp(o)<1};E.logarithm=E.log=function(o){var e,t,n,i,r,s,a,c,u=this,l=u.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=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)r=!0;else{for(i=t[0];i%10===0;)i/=10;r=i!==1}if(re=!1,a=m+p,s=hn(u,a),n=e?Do(l,a+10):hn(o,a),c=Ie(s,n,a,1),Ni(c.d,i=m,d))do if(a+=10,s=hn(u,a),n=e?Do(l,a+10):hn(o,a),c=Ie(s,n,a,1),!r){+nt(c.d).slice(i+1,i+15)+1==1e14&&(c=ee(c,m+1,0));break}while(Ni(c.d,i+=10,d));return re=!0,ee(c,m,d)};E.minus=E.sub=function(o){var e,t,n,i,r,s,a,c,u,l,m,d,p=this,b=p.constructor;if(o=new b(o),!p.d||!o.d)return!p.s||!o.s?o=new b(NaN):p.d?o.s=-o.s:o=new b(o.d||p.s!==o.s?p:NaN),o;if(p.s!=o.s)return o.s=-o.s,p.plus(o);if(u=p.d,d=o.d,a=b.precision,c=b.rounding,!u[0]||!d[0]){if(d[0])o.s=-o.s;else if(u[0])o=new b(p);else return new b(c===3?-0:0);return re?ee(o,a,c):o}if(t=ut(o.e/ie),l=ut(p.e/ie),u=u.slice(),r=l-t,r){for(m=r<0,m?(e=u,r=-r,s=d.length):(e=d,t=l,s=u.length),n=Math.max(Math.ceil(a/ie),s)+2,r>n&&(r=n,e.length=1),e.reverse(),n=r;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}r=0}for(m&&(e=u,u=d,d=e,o.s=-o.s),s=u.length,n=d.length-s;n>0;--n)u[s++]=0;for(n=d.length;n>r;){if(u[--n]<d[n]){for(i=n;i&&u[--i]===0;)u[i]=Xt-1;--u[i],u[n]+=Xt}u[n]-=d[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(o.d=u,o.e=qo(u,t),re?ee(o,a,c):o):new b(c===3?-0:0)};E.modulo=E.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]?ee(new n(t),n.precision,n.rounding):(re=!1,n.modulo==9?(e=Ie(t,o.abs(),0,3,1),e.s*=o.s):e=Ie(t,o,0,n.modulo,1),e=e.times(o),re=!0,t.minus(e))};E.naturalExponential=E.exp=function(){return ys(this)};E.naturalLogarithm=E.ln=function(){return hn(this)};E.negated=E.neg=function(){var o=new this.constructor(this);return o.s=-o.s,ee(o)};E.plus=E.add=function(o){var e,t,n,i,r,s,a,c,u,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(u=m.d,l=o.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(o=new d(m)),re?ee(o,a,c):o;if(r=ut(m.e/ie),n=ut(o.e/ie),u=u.slice(),i=r-n,i){for(i<0?(t=u,i=-i,s=l.length):(t=l,n=r,s=u.length),r=Math.ceil(a/ie),s=r>s?r+1:s+1,i>s&&(i=s,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(s=u.length,i=l.length,s-i<0&&(i=s,t=l,l=u,u=t),e=0;i;)e=(u[--i]=u[i]+l[i]+e)/Xt|0,u[i]%=Xt;for(e&&(u.unshift(e),++n),s=u.length;u[--s]==0;)u.pop();return o.d=u,o.e=qo(u,n),re?ee(o,a,c):o};E.precision=E.sd=function(o){var e,t=this;if(o!==void 0&&o!==!!o&&o!==1&&o!==0)throw Error(Tn+o);return t.d?(e=Lu(t.d),o&&t.e+1>e&&(e=t.e+1)):e=NaN,e};E.round=function(){var o=this,e=o.constructor;return ee(new e(o),o.e+1,e.rounding)};E.sine=E.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())+ie,n.rounding=1,t=zl(n,Nu(n,t)),n.precision=o,n.rounding=e,ee(ln>2?t.neg():t,o,e,!0)):new n(NaN)};E.squareRoot=E.sqrt=function(){var o,e,t,n,i,r,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=nt(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=ut((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(r=n,n=r.plus(Ie(s,r,t+2,1)).times(.5),nt(r.d).slice(0,t)===(e=nt(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(ee(r,c+1,0),r.times(r).eq(s))){n=r;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(ee(n,c+1,1),o=!n.times(n).eq(s));break}return re=!0,ee(n,c,l.rounding,o)};E.tangent=E.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=Ie(t,new n(1).minus(t.times(t)).sqrt(),o+10,0),n.precision=o,n.rounding=e,ee(ln==2||ln==4?t.neg():t,o,e,!0)):new n(NaN)};E.times=E.mul=function(o){var e,t,n,i,r,s,a,c,u,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=ut(l.e/ie)+ut(o.e/ie),c=d.length,u=p.length,c<u&&(r=d,d=p,p=r,s=c,c=u,u=s),r=[],s=c+u,n=s;n--;)r.push(0);for(n=u;--n>=0;){for(e=0,i=c+n;i>n;)a=r[i]+p[n]*d[i-n-1]+e,r[i--]=a%Xt|0,e=a/Xt|0;r[i]=(r[i]+e)%Xt|0}for(;!r[--s];)r.pop();return e?++t:r.shift(),o.d=r,o.e=qo(r,t),re?ee(o,m.precision,m.rounding):o};E.toBinary=function(o,e){return As(this,2,o,e)};E.toDecimalPlaces=E.toDP=function(o,e){var t=this,n=t.constructor;return t=new n(t),o===void 0?t:(It(o,0,In),e===void 0?e=n.rounding:It(e,0,8),ee(t,o+t.e+1,e))};E.toExponential=function(o,e){var t,n=this,i=n.constructor;return o===void 0?t=$t(n,!0):(It(o,0,In),e===void 0?e=i.rounding:It(e,0,8),n=ee(new i(n),o+1,e),t=$t(n,!0,o+1)),n.isNeg()&&!n.isZero()?"-"+t:t};E.toFixed=function(o,e){var t,n,i=this,r=i.constructor;return o===void 0?t=$t(i):(It(o,0,In),e===void 0?e=r.rounding:It(e,0,8),n=ee(new r(i),o+i.e+1,e),t=$t(n,!1,o+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};E.toFraction=function(o){var e,t,n,i,r,s,a,c,u,l,m,d,p=this,b=p.d,f=p.constructor;if(!b)return new f(p);if(u=t=new f(1),n=c=new f(0),e=new f(n),r=e.e=Lu(b)-p.e-1,s=r%ie,e.d[0]=Xe(10,s<0?ie+s:s),o==null)o=r>0?e:u;else{if(a=new f(o),!a.isInt()||a.lt(u))throw Error(Tn+a);o=a.gt(e)?r>0?e:u:a}for(re=!1,a=new f(nt(b)),l=f.precision,f.precision=r=b.length*ie*2;m=Ie(a,e,0,1,1),i=t.plus(m.times(n)),i.cmp(o)!=1;)t=n,n=i,i=u,u=c.plus(m.times(i)),c=i,i=e,e=a.minus(m.times(i)),a=i;return i=Ie(o.minus(t),n,0,1,1),c=c.plus(i.times(u)),t=t.plus(i.times(n)),c.s=u.s=p.s,d=Ie(u,n,r,1).minus(p).abs().cmp(Ie(c,t,r,1).minus(p).abs())<1?[u,n]:[c,t],f.precision=l,re=!0,d};E.toHexadecimal=E.toHex=function(o,e){return As(this,16,o,e)};E.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:It(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=Ie(t,o,0,e,1).times(o),re=!0,ee(t)):(o.s=t.s,t=o),t};E.toNumber=function(){return+this};E.toOctal=function(o,e){return As(this,8,o,e)};E.toPower=E.pow=function(o){var e,t,n,i,r,s,a=this,c=a.constructor,u=+(o=new c(o));if(!a.d||!o.d||!a.d[0]||!o.d[0])return new c(Xe(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,r=c.rounding,o.eq(1))return ee(a,n,r);if(e=ut(o.e/ie),e>=o.d.length-1&&(t=u<0?-u:u)<=ql)return i=Ru(c,a,t,n),o.s<0?new c(1).div(i):ee(i,n,r);if(s=a.s,s<0){if(e<o.d.length-1)return new c(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=Xe(+a,u),e=t==0||!isFinite(t)?ut(u*(Math.log("0."+nt(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),i=ys(o.times(hn(a,n+t)),n),i.d&&(i=ee(i,n+5,1),Ni(i.d,n,r)&&(e=n+10,i=ee(ys(o.times(hn(a,e+t)),e),e+5,1),+nt(i.d).slice(n+1,n+15)+1==1e14&&(i=ee(i,n+1,0)))),i.s=s,re=!0,c.rounding=r,ee(i,n,r))};E.toPrecision=function(o,e){var t,n=this,i=n.constructor;return o===void 0?t=$t(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(It(o,1,In),e===void 0?e=i.rounding:It(e,0,8),n=ee(new i(n),o,e),t=$t(n,o<=n.e||n.e<=i.toExpNeg,o)),n.isNeg()&&!n.isZero()?"-"+t:t};E.toSignificantDigits=E.toSD=function(o,e){var t=this,n=t.constructor;return o===void 0?(o=n.precision,e=n.rounding):(It(o,1,In),e===void 0?e=n.rounding:It(e,0,8)),ee(new n(t),o,e)};E.toString=function(){var o=this,e=o.constructor,t=$t(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()&&!o.isZero()?"-"+t:t};E.truncated=E.trunc=function(){return ee(new this.constructor(this),this.e+1,1)};E.valueOf=E.toJSON=function(){var o=this,e=o.constructor,t=$t(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()?"-"+t:t};function nt(o){var e,t,n,i=o.length-1,r="",s=o[0];if(i>0){for(r+=s,e=1;e<i;e++)n=o[e]+"",t=ie-n.length,t&&(r+=kn(t)),r+=n;s=o[e],n=s+"",t=ie-n.length,t&&(r+=kn(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function It(o,e,t){if(o!==~~o||o<e||o>t)throw Error(Tn+o)}function Ni(o,e,t,n){var i,r,s,a;for(r=o[0];r>=10;r/=10)--e;return--e<0?(e+=ie,i=0):(i=Math.ceil((e+1)/ie),e%=ie),r=Xe(10,ie-e),a=o[i]%r|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==r||t>3&&a+1==r/2)&&(o[i+1]/r/100|0)==Xe(10,e-2)-1||(a==r/2||a==0)&&(o[i+1]/r/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==r||!n&&t>3&&a+1==r/2)&&(o[i+1]/r/1e3|0)==Xe(10,e-3)-1,s}function Vo(o,e,t){for(var n,i=[0],r,s=0,a=o.length;s<a;){for(r=i.length;r--;)i[r]*=e;for(i[0]+=ps.indexOf(o.charAt(s++)),n=0;n<i.length;n++)i[n]>t-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/t|0,i[n]%=t)}return i.reverse()}function Gl(o,e){var t,n,i;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),i=(1/Uo(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),o.precision+=t,e=Zn(o,1,e.times(i),new o(1));for(var r=t;r--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return o.precision-=t,e}var Ie=function(){function o(n,i,r){var s,a=0,c=n.length;for(n=n.slice();c--;)s=n[c]*i+a,n[c]=s%r|0,a=s/r|0;return a&&n.unshift(a),n}function e(n,i,r,s){var a,c;if(r!=s)c=r>s?1:-1;else for(a=c=0;a<r;a++)if(n[a]!=i[a]){c=n[a]>i[a]?1:-1;break}return c}function t(n,i,r,s){for(var a=0;r--;)n[r]-=a,a=n[r]<i[r]?1:0,n[r]=a*s+n[r]-i[r];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,r,s,a,c){var u,l,m,d,p,b,f,y,g,w,P,h,I,T,S,B,L,x,K,V,R=n.constructor,G=n.s==i.s?1:-1,q=n.d,W=i.d;if(!q||!q[0]||!W||!W[0])return new R(!n.s||!i.s||(q?W&&q[0]==W[0]:!W)?NaN:q&&q[0]==0||!W?G*0:G/0);for(c?(p=1,l=n.e-i.e):(c=Xt,p=ie,l=ut(n.e/p)-ut(i.e/p)),K=W.length,L=q.length,g=new R(G),w=g.d=[],m=0;W[m]==(q[m]||0);m++);if(W[m]>(q[m]||0)&&l--,r==null?(T=r=R.precision,s=R.rounding):a?T=r+(n.e-i.e)+1:T=r,T<0)w.push(1),b=!0;else{if(T=T/p+2|0,m=0,K==1){for(d=0,W=W[0],T++;(m<L||d)&&T--;m++)S=d*c+(q[m]||0),w[m]=S/W|0,d=S%W|0;b=d||m<L}else{for(d=c/(W[0]+1)|0,d>1&&(W=o(W,d,c),q=o(q,d,c),K=W.length,L=q.length),B=K,P=q.slice(0,K),h=P.length;h<K;)P[h++]=0;V=W.slice(),V.unshift(0),x=W[0],W[1]>=c/2&&++x;do d=0,u=e(W,P,K,h),u<0?(I=P[0],K!=h&&(I=I*c+(P[1]||0)),d=I/x|0,d>1?(d>=c&&(d=c-1),f=o(W,d,c),y=f.length,h=P.length,u=e(f,P,y,h),u==1&&(d--,t(f,K<y?V:W,y,c))):(d==0&&(u=d=1),f=W.slice()),y=f.length,y<h&&f.unshift(0),t(P,f,h,c),u==-1&&(h=P.length,u=e(W,P,K,h),u<1&&(d++,t(P,K<h?V:W,h,c))),h=P.length):u===0&&(d++,P=[0]),w[m++]=d,u&&P[0]?P[h++]=q[B]||0:(P=[q[B]],h=1);while((B++<L||P[0]!==void 0)&&T--);b=P[0]!==void 0}w[0]||w.shift()}if(p==1)g.e=l,Bu=b;else{for(m=1,d=w[0];d>=10;d/=10)m++;g.e=m+l*p-1,ee(g,a?r+g.e+1:r,s,b)}return g}}();function ee(o,e,t,n){var i,r,s,a,c,u,l,m,d,p=o.constructor;e:if(e!=null){if(m=o.d,!m)return o;for(i=1,a=m[0];a>=10;a/=10)i++;if(r=e-i,r<0)r+=ie,s=e,l=m[d=0],c=l/Xe(10,i-s-1)%10|0;else if(d=Math.ceil((r+1)/ie),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=c=0,i=1,r%=ie,s=r-ie+1}else break e;else{for(l=a=m[d],i=1;a>=10;a/=10)i++;r%=ie,s=r-ie+i,c=s<0?0:l/Xe(10,i-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%Xe(10,i-s-1)),u=t<4?(c||n)&&(t==0||t==(o.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(r>0?s>0?l/Xe(10,i-s):0:m[d-1])%10&1||t==(o.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=o.e+1,m[0]=Xe(10,(ie-e%ie)%ie),o.e=-e||0):m[0]=o.e=0,o;if(r==0?(m.length=d,a=1,d--):(m.length=d+1,a=Xe(10,ie-r),m[d]=s>0?(l/Xe(10,i-s)%Xe(10,s)|0)*a:0),u)for(;;)if(d==0){for(r=1,s=m[0];s>=10;s/=10)r++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;r!=a&&(o.e++,m[0]==Xt&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=Xt)break;m[d--]=0,a=1}for(r=m.length;m[--r]===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 $t(o,e,t){if(!o.isFinite())return Mu(o);var n,i=o.e,r=nt(o.d),s=r.length;return e?(t&&(n=t-s)>0?r=r.charAt(0)+"."+r.slice(1)+kn(n):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(o.e<0?"e":"e+")+o.e):i<0?(r="0."+kn(-i-1)+r,t&&(n=t-s)>0&&(r+=kn(n))):i>=s?(r+=kn(i+1-s),t&&(n=t-i-1)>0&&(r=r+"."+kn(n))):((n=i+1)<s&&(r=r.slice(0,n)+"."+r.slice(n)),t&&(n=t-s)>0&&(i+1===s&&(r+="."),r+=kn(n))),r}function qo(o,e){var t=o[0];for(e*=ie;t>=10;t/=10)e++;return e}function Do(o,e,t){if(e>Ul)throw re=!0,t&&(o.precision=t),Error(xu);return ee(new o(Eo),e,1,!0)}function Gt(o,e,t){if(e>bs)throw Error(xu);return ee(new o(Fo),e,t,!0)}function Lu(o){var e=o.length-1,t=e*ie+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 kn(o){for(var e="";o--;)e+="0";return e}function Ru(o,e,t,n){var i,r=new o(1),s=Math.ceil(n/ie+4);for(re=!1;;){if(t%2&&(r=r.times(e),Tu(r.d,s)&&(i=!0)),t=ut(t/2),t===0){t=r.d.length-1,i&&r.d[t]===0&&++r.d[t];break}e=e.times(e),Tu(e.d,s)}return re=!0,r}function hu(o){return o.d[o.d.length-1]&1}function Ou(o,e,t){for(var n,i=new o(e[0]),r=0;++r<e.length;)if(n=new o(e[r]),n.s)i[t](n)&&(i=n);else{i=n;break}return i}function ys(o,e){var t,n,i,r,s,a,c,u=0,l=0,m=0,d=o.constructor,p=d.rounding,b=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,c=b):c=e,a=new d(.03125);o.e>-2;)o=o.times(a),m+=5;for(n=Math.log(Xe(2,m))/Math.LN10*2+5|0,c+=n,t=r=s=new d(1),d.precision=c;;){if(r=ee(r.times(o),c,1),t=t.times(++l),a=s.plus(Ie(r,t,c,1)),nt(a.d).slice(0,c)===nt(s.d).slice(0,c)){for(i=m;i--;)s=ee(s.times(s),c,1);if(e==null)if(u<3&&Ni(s.d,c-n,p,u))d.precision=c+=10,t=r=a=new d(1),l=0,u++;else return ee(s,d.precision=b,p,re=!0);else return d.precision=b,s}s=a}}function hn(o,e){var t,n,i,r,s,a,c,u,l,m,d,p=1,b=10,f=o,y=f.d,g=f.constructor,w=g.rounding,P=g.precision;if(f.s<0||!y||!y[0]||!f.e&&y[0]==1&&y.length==1)return new g(y&&!y[0]?-1/0:f.s!=1?NaN:y?0:f);if(e==null?(re=!1,l=P):l=e,g.precision=l+=b,t=nt(y),n=t.charAt(0),Math.abs(r=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(o),t=nt(f.d),n=t.charAt(0),p++;r=f.e,n>1?(f=new g("0."+t),r++):f=new g(n+"."+t.slice(1))}else return u=Do(g,l+2,P).times(r+""),f=hn(new g(n+"."+t.slice(1)),l-b).plus(u),g.precision=P,e==null?ee(f,P,w,re=!0):f;for(m=f,c=s=f=Ie(f.minus(1),f.plus(1),l,1),d=ee(f.times(f),l,1),i=3;;){if(s=ee(s.times(d),l,1),u=c.plus(Ie(s,new g(i),l,1)),nt(u.d).slice(0,l)===nt(c.d).slice(0,l))if(c=c.times(2),r!==0&&(c=c.plus(Do(g,l+2,P).times(r+""))),c=Ie(c,new g(p),l,1),e==null)if(Ni(c.d,l-b,w,a))g.precision=l+=b,u=s=f=Ie(m.minus(1),m.plus(1),l,1),d=ee(f.times(f),l,1),i=a=1;else return ee(c,g.precision=P,w,re=!0);else return g.precision=P,c;c=u,i+=2}}function Mu(o){return String(o.s*o.s/0)}function gs(o,e){var t,n,i;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(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(n,i),e){if(i-=n,o.e=t=t-n-1,o.d=[],n=(t+1)%ie,t<0&&(n+=ie),n<i){for(n&&o.d.push(+e.slice(0,n)),i-=ie;n<i;)o.d.push(+e.slice(n,n+=ie));e=e.slice(n),n=ie-e.length}else n-=i;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 Xl(o,e){var t,n,i,r,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Cu.test(e))return gs(o,e)}else if(e==="Infinity"||e==="NaN")return+e||(o.s=NaN),o.e=NaN,o.d=null,o;if(Dl.test(e))t=16,e=e.toLowerCase();else if(Fl.test(e))t=2;else if(Wl.test(e))t=8;else throw Error(Tn+e);for(r=e.search(/p/i),r>0?(c=+e.slice(r+1),e=e.substring(2,r)):e=e.slice(2),r=e.indexOf("."),s=r>=0,n=o.constructor,s&&(e=e.replace(".",""),a=e.length,r=a-r,i=Ru(n,new n(t),r,r*2)),u=Vo(e,t,Xt),l=u.length-1,r=l;u[r]===0;--r)u.pop();return r<0?new n(o.s*0):(o.e=qo(u,l),o.d=u,re=!1,s&&(o=Ie(o,i,a*4)),c&&(o=o.times(Math.abs(c)<54?Xe(2,c):_i.pow(2,c))),re=!0,o)}function zl(o,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:Zn(o,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Uo(5,t)),e=Zn(o,2,e,e);for(var i,r=new o(5),s=new o(16),a=new o(20);t--;)i=e.times(e),e=e.times(r.plus(i.times(s.times(i).minus(a))));return e}function Zn(o,e,t,n,i){var r,s,a,c,u=1,l=o.precision,m=Math.ceil(l/ie);for(re=!1,c=t.times(t),a=new o(n);;){if(s=Ie(a.times(c),new o(e++*e++),l,1),a=i?n.plus(s):n.minus(s),n=Ie(s.times(c),new o(e++*e++),l,1),s=a.plus(n),s.d[m]!==void 0){for(r=m;s.d[r]===a.d[r]&&r--;);if(r==-1)break}r=a,a=n,n=s,s=r,u++}return re=!0,s.d.length=m+1,s}function Uo(o,e){for(var t=o;--e;)t*=o;return t}function Nu(o,e){var t,n=e.s<0,i=Gt(o,o.precision,1),r=i.times(.5);if(e=e.abs(),e.lte(r))return ln=n?4:1,e;if(t=e.divToInt(i),t.isZero())ln=n?3:2;else{if(e=e.minus(t.times(i)),e.lte(r))return ln=hu(t)?n?2:3:n?4:1,e;ln=hu(t)?n?1:4:n?3:2}return e.minus(i).abs()}function As(o,e,t,n){var i,r,s,a,c,u,l,m,d,p=o.constructor,b=t!==void 0;if(b?(It(t,1,In),n===void 0?n=p.rounding:It(n,0,8)):(t=p.precision,n=p.rounding),!o.isFinite())l=Mu(o);else{for(l=$t(o),s=l.indexOf("."),b?(i=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):i=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Vo($t(d),10,i),d.e=d.d.length),m=Vo(l,10,i),r=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=b?"0p+0":"0";else{if(s<0?r--:(o=new p(o),o.d=m,o.e=r,o=Ie(o,d,t,n,0,i),m=o.d,r=o.e,u=Bu),s=m[t],a=i/2,u=u||m[t+1]!==void 0,u=n<4?(s!==void 0||u)&&(n===0||n===(o.s<0?3:2)):s>a||s===a&&(n===4||u||n===6&&m[t-1]&1||n===(o.s<0?8:7)),m.length=t,u)for(;++m[--t]>i-1;)m[t]=0,t||(++r,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=ps.charAt(m[s]);if(b){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=Vo(l,i,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=ps.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(r<0?"p":"p+")+r}else if(r<0){for(;++r;)l="0"+l;l="0."+l}else if(++r>c)for(r-=c;r--;)l+="0";else r<c&&(l=l.slice(0,r)+"."+l.slice(r))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return o.s<0?"-"+l:l}function Tu(o,e){if(o.length>e)return o.length=e,!0}function Ql(o){return new this(o).abs()}function Hl(o){return new this(o).acos()}function jl(o){return new this(o).acosh()}function Yl(o,e){return new this(o).plus(e)}function Zl(o){return new this(o).asin()}function $l(o){return new this(o).asinh()}function Jl(o){return new this(o).atan()}function em(o){return new this(o).atanh()}function tm(o,e){o=new this(o),e=new this(e);var t,n=this.precision,i=this.rounding,r=n+4;return!o.s||!e.s?t=new this(NaN):!o.d&&!e.d?(t=Gt(this,r,1).times(e.s>0?.25:.75),t.s=o.s):!e.d||o.isZero()?(t=e.s<0?Gt(this,n,i):new this(0),t.s=o.s):!o.d||e.isZero()?(t=Gt(this,r,1).times(.5),t.s=o.s):e.s<0?(this.precision=r,this.rounding=1,t=this.atan(Ie(o,e,r,1)),e=Gt(this,r,1),this.precision=n,this.rounding=i,t=o.s<0?t.minus(e):t.plus(e)):t=this.atan(Ie(o,e,r,1)),t}function nm(o){return new this(o).cbrt()}function im(o){return ee(o=new this(o),o.e+1,2)}function om(o,e,t){return new this(o).clamp(e,t)}function rm(o){if(!o||typeof o!="object")throw Error(Wo+"Object expected");var e,t,n,i=o.defaults===!0,r=["precision",1,In,"rounding",0,8,"toExpNeg",-Yn,0,"toExpPos",0,Yn,"maxE",0,Yn,"minE",-Yn,0,"modulo",0,9];for(e=0;e<r.length;e+=3)if(t=r[e],i&&(this[t]=fs[t]),(n=o[t])!==void 0)if(ut(n)===n&&n>=r[e+1]&&n<=r[e+2])this[t]=n;else throw Error(Tn+t+": "+n);if(t="crypto",i&&(this[t]=fs[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(Su);else this[t]=!1;else throw Error(Tn+t+": "+n);return this}function sm(o){return new this(o).cos()}function am(o){return new this(o).cosh()}function _u(o){var e,t,n;function i(r){var s,a,c,u=this;if(!(u instanceof i))return new i(r);if(u.constructor=i,Iu(r)){u.s=r.s,re?!r.d||r.e>i.maxE?(u.e=NaN,u.d=null):r.e<i.minE?(u.e=0,u.d=[0]):(u.e=r.e,u.d=r.d.slice()):(u.e=r.e,u.d=r.d?r.d.slice():r.d);return}if(c=typeof r,c==="number"){if(r===0){u.s=1/r<0?-1:1,u.e=0,u.d=[0];return}if(r<0?(r=-r,u.s=-1):u.s=1,r===~~r&&r<1e7){for(s=0,a=r;a>=10;a/=10)s++;re?s>i.maxE?(u.e=NaN,u.d=null):s<i.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[r]):(u.e=s,u.d=[r]);return}else if(r*0!==0){r||(u.s=NaN),u.e=NaN,u.d=null;return}return gs(u,r.toString())}else if(c!=="string")throw Error(Tn+r);return(a=r.charCodeAt(0))===45?(r=r.slice(1),u.s=-1):(a===43&&(r=r.slice(1)),u.s=1),Cu.test(r)?gs(u,r):Xl(u,r)}if(i.prototype=E,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=rm,i.clone=_u,i.isDecimal=Iu,i.abs=Ql,i.acos=Hl,i.acosh=jl,i.add=Yl,i.asin=Zl,i.asinh=$l,i.atan=Jl,i.atanh=em,i.atan2=tm,i.cbrt=nm,i.ceil=im,i.clamp=om,i.cos=sm,i.cosh=am,i.div=um,i.exp=cm,i.floor=lm,i.hypot=mm,i.ln=dm,i.log=pm,i.log10=bm,i.log2=fm,i.max=ym,i.min=gm,i.mod=Am,i.mul=wm,i.pow=Pm,i.random=km,i.round=hm,i.sign=Tm,i.sin=Im,i.sinh=Bm,i.sqrt=xm,i.sub=Sm,i.sum=Km,i.tan=Cm,i.tanh=Lm,i.trunc=Rm,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 i.config(o),i}function um(o,e){return new this(o).div(e)}function cm(o){return new this(o).exp()}function lm(o){return ee(o=new this(o),o.e+1,3)}function mm(){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 Iu(o){return o instanceof _i||o&&o.toStringTag===Ku||!1}function dm(o){return new this(o).ln()}function pm(o,e){return new this(o).log(e)}function fm(o){return new this(o).log(2)}function bm(o){return new this(o).log(10)}function ym(){return Ou(this,arguments,"lt")}function gm(){return Ou(this,arguments,"gt")}function Am(o,e){return new this(o).mod(e)}function wm(o,e){return new this(o).mul(e)}function Pm(o,e){return new this(o).pow(e)}function km(o){var e,t,n,i,r=0,s=new this(1),a=[];if(o===void 0?o=this.precision:It(o,1,In),n=Math.ceil(o/ie),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));r<n;)i=e[r],i>=429e7?e[r]=crypto.getRandomValues(new Uint32Array(1))[0]:a[r++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);r<n;)i=e[r]+(e[r+1]<<8)+(e[r+2]<<16)+((e[r+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,r):(a.push(i%1e7),r+=4);r=n/4}else throw Error(Su);else for(;r<n;)a[r++]=Math.random()*1e7|0;for(n=a[--r],o%=ie,n&&o&&(i=Xe(10,ie-o),a[r]=(n/i|0)*i);a[r]===0;r--)a.pop();if(r<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=ie)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<ie&&(t-=ie-n)}return s.e=t,s.d=a,s}function hm(o){return ee(o=new this(o),o.e+1,this.rounding)}function Tm(o){return o=new this(o),o.d?o.d[0]?o.s:0*o.s:o.s||NaN}function Im(o){return new this(o).sin()}function Bm(o){return new this(o).sinh()}function xm(o){return new this(o).sqrt()}function Sm(o,e){return new this(o).sub(e)}function Km(){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,ee(t,this.precision,this.rounding)}function Cm(o){return new this(o).tan()}function Lm(o){return new this(o).tanh()}function Rm(o){return ee(o=new this(o),o.e+1,1)}E[Symbol.for("nodejs.util.inspect.custom")]=E.toString;E[Symbol.toStringTag]="Decimal";var _i=E.constructor=_u(fs);Eo=new _i(Eo);Fo=new _i(Fo);var N=_i;var Wu=le(require("big.js")),Fi=le(require("bn.js"));var vu=le(require("toformat")),Om=vu.default,vi=Om;var Vi=le(require("big.js")),Eu=le(require("bn.js")),Fu=le(require("decimal.js-light"));var $n=le(require("bn.js"));var Vu=9007199254740991;function Z(o){let e=me("CobaltX_parseBigNumberish");if(o instanceof $n.default)return o;if(typeof o=="string"