UNPKG

raydium-sdk-v2-custody

Version:

An SDK for building applications on top of Raydium.

1 lines 446 kB
var Dl=Object.create;var Gi=Object.defineProperty,ql=Object.defineProperties,Ul=Object.getOwnPropertyDescriptor,Gl=Object.getOwnPropertyDescriptors,Xl=Object.getOwnPropertyNames,qo=Object.getOwnPropertySymbols,zl=Object.getPrototypeOf,fs=Object.prototype.hasOwnProperty,Iu=Object.prototype.propertyIsEnumerable;var Tu=(o,t,e)=>t in o?Gi(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,N=(o,t)=>{for(var e in t||(t={}))fs.call(t,e)&&Tu(o,e,t[e]);if(qo)for(var e of qo(t))Iu.call(t,e)&&Tu(o,e,t[e]);return o},z=(o,t)=>ql(o,Gl(t));var He=(o,t)=>{var e={};for(var n in o)fs.call(o,n)&&t.indexOf(n)<0&&(e[n]=o[n]);if(o!=null&&qo)for(var n of qo(o))t.indexOf(n)<0&&Iu.call(o,n)&&(e[n]=o[n]);return e};var Ql=(o,t)=>{for(var e in t)Gi(o,e,{get:t[e],enumerable:!0})},Bu=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Xl(t))!fs.call(o,i)&&i!==e&&Gi(o,i,{get:()=>t[i],enumerable:!(n=Ul(t,i))||n.enumerable});return o};var be=(o,t,e)=>(e=o!=null?Dl(zl(o)):{},Bu(t||!o||!o.__esModule?Gi(e,"default",{value:o,enumerable:!0}):e,o)),Yl=o=>Bu(Gi({},"__esModule",{value:!0}),o);var Ip={};Ql(Ip,{AMM_CONFIG_SEED:()=>Qc,BIT_PRECISION:()=>wa,Clmm:()=>vi,ClmmConfigLayout:()=>Ea,ClmmInstrument:()=>Ne,ConstantProductCurve:()=>So,CpmmConfigInfoLayout:()=>lu,CpmmFee:()=>Co,CpmmPoolInfoLayout:()=>No,CurveCalculator:()=>Ro,DataElement:()=>bl,EXTENSION_TICKARRAY_BITMAP_SIZE:()=>Xr,FARM_LOCK_MINT:()=>aa,FARM_LOCK_VAULT:()=>ua,FARM_PROGRAM_TO_VERSION:()=>qt,FARM_VERSION_TO_LEDGER_LAYOUT:()=>la,FARM_VERSION_TO_STATE_LAYOUT:()=>ca,FEE_RATE_DENOMINATOR:()=>Po,FEE_RATE_DENOMINATOR_VALUE:()=>rs,FETCH_TICKARRAY_COUNT:()=>il,Fee:()=>zc,LIQUIDITY_FEES_DENOMINATOR:()=>ho,LIQUIDITY_FEES_NUMERATOR:()=>Qr,LIQUIDITY_VERSION_TO_SERUM_VERSION:()=>pl,LIQUIDITY_VERSION_TO_STATE_LAYOUT:()=>zd,LOCK_LIQUIDITY_SEED:()=>Ol,LOG_B_2_X32:()=>ka,LOG_B_P_ERR_MARGIN_LOWER_X64:()=>ha,LOG_B_P_ERR_MARGIN_UPPER_X64:()=>Ta,LiquidityMath:()=>Ae,LockClPositionLayoutV2:()=>Fd,LockPositionLayout:()=>Ed,MARKET_STATE_LAYOUT_V2:()=>is,MARKET_STATE_LAYOUT_V3:()=>us,MARKET_VERSION_TO_STATE_LAYOUT:()=>pu,MAX_SQRT_PRICE_X64:()=>Ft,MAX_SQRT_PRICE_X64_SUB_ONE:()=>go,MAX_TICK:()=>Tt,MIN_SQRT_PRICE_X64:()=>Et,MIN_SQRT_PRICE_X64_ADD_ONE:()=>bo,MIN_TICK:()=>yt,MODEL_DATA_PUBKEY:()=>ei,Market:()=>Vo,MathUtil:()=>ue,MaxU64:()=>Fr,MaxUint128:()=>Aa,NEGATIVE_ONE:()=>dn,OBSERVATION_SEED:()=>el,ONE:()=>Vt,OPERATION_SEED:()=>$c,ObservationInfoLayout:()=>Fa,ObservationLayout:()=>rl,OperationLayout:()=>Wa,POOL_LOCK_ID_SEED:()=>Oa,POOL_REWARD_VAULT_SEED:()=>jc,POOL_SEED:()=>Yc,POOL_TICK_ARRAY_BITMAP_SEED:()=>Jc,POOL_VAULT_SEED:()=>Hc,POSITION_SEED:()=>Sa,PoolInfoLayout:()=>Dn,PoolUtils:()=>he,PositionInfoLayout:()=>Ki,PositionRewardInfoLayout:()=>al,PositionUtils:()=>Ii,ProtocolPositionLayout:()=>_d,Q128:()=>yo,Q64:()=>_t,Raydium:()=>Do,RewardInfo:()=>sl,RoundDirection:()=>Ja,SERUM_PROGRAMID_TO_VERSION:()=>mu,SERUM_VERSION_TO_PROGRAMID:()=>du,SOL_INFO:()=>Jt,SPL_MINT_LAYOUT:()=>Wd,SUPPORT_MINT_SEED:()=>tl,SqrtPriceMath:()=>se,StableLayout:()=>Jn,SwapMath:()=>Wn,TICK_ARRAY_BITMAP_SIZE:()=>Fn,TICK_ARRAY_SEED:()=>Zc,TICK_ARRAY_SIZE:()=>Je,TICK_SPACINGS:()=>Cd,TOKEN_WSOL:()=>tt,TickArrayBitmap:()=>pn,TickArrayBitmapExtensionLayout:()=>Va,TickArrayBitmapExtensionUtils:()=>xi,TickArrayLayout:()=>Bi,TickLayout:()=>ul,TickMath:()=>qn,TickQuery:()=>we,TickUtils:()=>j,U64Resolution:()=>wi,U64_IGNORE_RANGE:()=>Rd,USER_STATE_SEED:()=>nl,Voter:()=>ra,VoterDepositEntry:()=>Vc,VoterLockup:()=>vc,VoterRegistrar:()=>oa,VoterVotingMintConfig:()=>Nc,ZERO:()=>Pe,addLiquidityLayout:()=>Zr,associatedLedgerAccountLayout:()=>hr,calFarmRewardAmount:()=>vr,ceilDiv:()=>Ll,claimLayout:()=>Fi,clmmComputeInfoToApiInfo:()=>va,closeAccountInstruction:()=>mn,collectCpFeeInstruction:()=>cu,cpmmLockPositionInstruction:()=>Ml,createAssociatedLedgerAccountInstruction:()=>bi,createPoolFeeLayout:()=>qa,createPoolV4InstructionV2:()=>es,createPoolV4Layout:()=>Xd,createWSolAccountInstructions:()=>hn,dwLayout:()=>ht,farmAddRewardLayout:()=>xr,farmLedgerLayoutV3_1:()=>kd,farmLedgerLayoutV3_2:()=>fi,farmLedgerLayoutV5_1:()=>hd,farmLedgerLayoutV5_2:()=>na,farmLedgerLayoutV6_1:()=>ia,farmRewardInfoToConfig:()=>da,farmRewardLayout:()=>Ir,farmRewardRestartLayout:()=>Br,farmRewardTimeInfoLayout:()=>Mc,farmStateV3Layout:()=>ea,farmStateV5Layout:()=>ta,farmStateV6Layout:()=>pi,fetchMultipleFarmInfoAndUpdate:()=>Td,fetchMultipleInfo:()=>op,fixedSwapInLayout:()=>Yr,fixedSwapOutLayout:()=>Hr,floorDiv:()=>eu,formatLayout:()=>wl,generatePubKey:()=>qe,getAssociatedAuthority:()=>ma,getAssociatedConfigId:()=>Io,getAssociatedLedgerAccount:()=>ft,getAssociatedLedgerPoolAccount:()=>yi,getAssociatedOpenOrders:()=>Sl,getAssociatedPoolKeys:()=>ns,getCpLockPda:()=>Oo,getCpmmPdaAmmConfigId:()=>pp,getCpmmPdaPoolId:()=>as,getCreatePoolKeys:()=>iu,getDepositEntryIndex:()=>Vr,getDxByDyBaseIn:()=>Xa,getDyByDxBaseIn:()=>Ga,getFarmLedgerLayout:()=>Zn,getFarmStateLayout:()=>_c,getLiquidityAssociatedAuthority:()=>ts,getLiquidityAssociatedId:()=>Un,getLiquidityFromAmounts:()=>vd,getPdaAmmConfigId:()=>Nd,getPdaExBitmapAccount:()=>Ce,getPdaLockClPositionIdV2:()=>Ti,getPdaLockPositionId:()=>Ur,getPdaLpMint:()=>Rl,getPdaMetadataKey:()=>En,getPdaMintExAccount:()=>Gr,getPdaObservationAccount:()=>Ra,getPdaObservationId:()=>Ei,getPdaOperationAccount:()=>hi,getPdaPersonalPositionAddress:()=>Ue,getPdaPoolAuthority:()=>ni,getPdaPoolId:()=>Ca,getPdaPoolRewardVaulId:()=>La,getPdaPoolVaultId:()=>qr,getPdaProtocolPositionAddress:()=>ut,getPdaTickArrayAddress:()=>ce,getPdaUserState:()=>It,getPdaVault:()=>nu,getRegistrarAddress:()=>Cr,getStablePrice:()=>za,getTokenOwnerRecordAddress:()=>Nr,getVoterAddress:()=>Or,getVoterWeightRecordAddress:()=>Mr,getVotingMintAuthority:()=>Rr,getVotingTokenMint:()=>Lr,governanceCreateTokenOwnerRecord:()=>qc,i16ToBytes:()=>Od,i32ToBytes:()=>Ao,initPoolLayout:()=>jr,initTokenAccountInstruction:()=>kr,initializeMarket:()=>Cl,isValidFarmVersion:()=>Kr,isZero:()=>ki,judgeFarmType:()=>Id,leadingZeros:()=>Wr,leastSignificantBit:()=>Ka,liquidityStateV4Layout:()=>Ci,liquidityStateV5Layout:()=>fl,makeAMMSwapInstruction:()=>To,makeAddLiquidityInstruction:()=>Qa,makeAddNewRewardInstruction:()=>Er,makeClaimInstruction:()=>Fo,makeClaimInstructionV4:()=>ds,makeCpmmLockInstruction:()=>uu,makeCreateCpmmPoolInInstruction:()=>ou,makeCreateFarmInstruction:()=>pa,makeCreateMarketInstruction:()=>xo,makeCreatorWithdrawFarmRewardInstruction:()=>fa,makeDepositCpmmInInstruction:()=>ru,makeDepositInstructionV3:()=>ba,makeDepositInstructionV5:()=>ga,makeDepositInstructionV6:()=>Pa,makeDepositTokenInstruction:()=>xd,makeDepositWithdrawInstruction:()=>Sd,makeInitPoolInstructionV4:()=>np,makePurchaseInstruction:()=>kp,makeRestartRewardInstruction:()=>_r,makeSimulatePoolInfoInstruction:()=>Ya,makeSwapCpmmBaseInInstruction:()=>Mo,makeSwapCpmmBaseOutInstruction:()=>au,makeSwapFixedInInstruction:()=>hl,makeSwapFixedOutInstruction:()=>Tl,makeSwapInstruction:()=>bu,makeTransferInstruction:()=>Js,makeWithdrawCpmmInInstruction:()=>su,makeWithdrawInstructionV3:()=>Ai,makeWithdrawInstructionV4:()=>ya,makeWithdrawInstructionV5:()=>Pi,makeWithdrawInstructionV6:()=>gi,makeWithdrawTokenInstruction:()=>Kd,mockCreatePoolInfo:()=>Ld,mockV3CreatePoolInfo:()=>Ia,modelDataInfoLayout:()=>gl,mostSignificantBit:()=>xa,parseTokenAccountResp:()=>$s,parseTokenInfo:()=>Dd,poolTypeV6:()=>Tn,purchaseLayout:()=>ls,realFarmStateV3Layout:()=>Lc,realFarmStateV5Layout:()=>Rc,realFarmV6Layout:()=>Oc,removeLiquidityInstruction:()=>Jr,removeLiquidityLayout:()=>$r,route1Instruction:()=>gp,route2Instruction:()=>Pp,routeInstruction:()=>Nl,simulatePoolInfoInstruction:()=>tp,solToWSolToken:()=>Ud,splAccountLayout:()=>kn,swapBaseInAutoAccount:()=>Ap,swapBaseOutAutoAccount:()=>wp,toAmmComputePoolInfo:()=>Bo,toApiV3Token:()=>bt,toFeeConfig:()=>In,toToken:()=>ko,toTokenAmount:()=>Si,toTokenInfo:()=>qd,trailingZeros:()=>Dr,u16ToBytes:()=>Ba,u32ToBytes:()=>Md,unionArr:()=>Tp,updateFarmPoolInfo:()=>Ec,validateFarmRewards:()=>Sr,voterStakeRegistryCreateDepositEntry:()=>Gc,voterStakeRegistryCreateVoter:()=>Uc,voterStakeRegistryDeposit:()=>Fc,voterStakeRegistryUpdateVoterWeightRecord:()=>Wc,voterStakeRegistryWithdraw:()=>Dc,wSolToSolToken:()=>Gd,withdrawRewardLayout:()=>Tr});module.exports=Yl(Ip);var _l=require("lodash");var qs=be(require("axios"));var Ps=require("@solana/web3.js");var Xi=require("lodash");var ys=class{constructor(t){this.logLevel=t.logLevel!==void 0?t.logLevel:0,this.name=t.name}set level(t){this.logLevel=t}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(t){return t<=this.logLevel}error(...t){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...t),this):this}logWithError(...t){let e=t.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(e)}warning(...t){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...t),this):this}info(...t){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...t),this):this}debug(...t){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...t),this):this}},xu={},Hl={};function ge(o){let t=(0,Xi.get)(xu,o);if(!t){let e=(0,Xi.get)(Hl,o);t=new ys({name:o,logLevel:e}),(0,Xi.set)(xu,o,t)}return t}var Sn=require("@solana/spl-token"),bs=ge("Raydium_accountInfo_util");async function jt(o,t,e){let{batchRequest:n,commitment:i="confirmed",chunkCount:r=100}=N({batchRequest:!1},e),s=gs(t,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=gs(c,10);a=(await(await Promise.all(u.map(async m=>await o._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&bs.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:y,lamports:f,owner:b,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&bs.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:y,lamports:f,owner:new Ps.PublicKey(b),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(c=>o.getMultipleAccountsInfo(c,i)))}catch(c){c instanceof Error&&bs.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function $e(o,t,e){let n=await jt(o,t.map(i=>i.pubkey),e);return t.map((i,r)=>z(N({},i),{accountInfo:n[r]}))}async function oi({connection:o,mints:t,config:e}){var r,s,a;if(t.length===0)return{};let n=await $e(o,t.map(c=>({pubkey:wt(c)})),e),i={};for(let c of n){if(!c.accountInfo||c.accountInfo.data.length<Sn.MINT_SIZE){console.log("invalid mint account",c.pubkey.toBase58());continue}let u=(0,Sn.unpackMint)(c.pubkey,c.accountInfo,(r=c.accountInfo)==null?void 0:r.owner);i[c.pubkey.toString()]=z(N({},u),{programId:((s=c.accountInfo)==null?void 0:s.owner)||Sn.TOKEN_PROGRAM_ID,feeConfig:(a=(0,Sn.getTransferFeeConfig)(u))!=null?a:void 0})}return i[Ps.PublicKey.default.toBase58()]=i[$.toBase58()],i}var ln=be(require("bn.js"));var ri=9e15,On=1e9,As="0123456789abcdef",Go="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Xo="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ws={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ri,maxE:ri,crypto:!1},Lu,bn,le=!0,Qo="[DecimalError] ",Rn=Qo+"Invalid argument: ",Ru=Qo+"Precision limit exceeded",Ou=Qo+"crypto unavailable",Mu="[object Decimal]",kt=Math.floor,et=Math.pow,jl=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Zl=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,$l=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Nu=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$t=1e7,ae=7,Jl=9007199254740991,em=Go.length-1,ks=Xo.length-1,U={toStringTag:Mu};U.absoluteValue=U.abs=function(){var o=new this.constructor(this);return o.s<0&&(o.s=1),re(o)};U.ceil=function(){return re(new this.constructor(this),this.e+1,2)};U.clampedTo=U.clamp=function(o,t){var e,n=this,i=n.constructor;if(o=new i(o),t=new i(t),!o.s||!t.s)return new i(NaN);if(o.gt(t))throw Error(Rn+t);return e=n.cmp(o),e<0?o:n.cmp(t)>0?t:new i(n)};U.comparedTo=U.cmp=function(o){var t,e,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,t=0,e=n<i?n:i;t<e;++t)if(s[t]!==a[t])return s[t]>a[t]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};U.cosine=U.cos=function(){var o,t,e=this,n=e.constructor;return e.d?e.d[0]?(o=n.precision,t=n.rounding,n.precision=o+Math.max(e.e,e.sd())+ae,n.rounding=1,e=tm(n,Fu(n,e)),n.precision=o,n.rounding=t,re(bn==2||bn==3?e.neg():e,o,t,!0)):new n(1):new n(NaN)};U.cubeRoot=U.cbrt=function(){var o,t,e,n,i,r,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(le=!1,r=l.s*et(l.s*l,1/3),!r||Math.abs(r)==1/0?(e=dt(l.d),o=l.e,(r=(o-e.length+1)%3)&&(e+=r==1||r==-2?"0":"00"),r=et(e,1/3),o=kt((o+1)/3)-(o%3==(o<0?-1:2)),r==1/0?e="5e"+o:(e=r.toExponential(),e=e.slice(0,e.indexOf("e")+1)+o),n=new m(e),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=Ve(u.plus(l).times(a),u.plus(c),s+2,1),dt(a.d).slice(0,s)===(e=dt(n.d)).slice(0,s))if(e=e.slice(s-3,s+1),e=="9999"||!i&&e=="4999"){if(!i&&(re(a,o+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(re(n,o+1,1),t=!n.times(n).times(n).eq(l));break}return le=!0,re(n,o,m.rounding,t)};U.decimalPlaces=U.dp=function(){var o,t=this.d,e=NaN;if(t){if(o=t.length-1,e=(o-kt(this.e/ae))*ae,o=t[o],o)for(;o%10==0;o/=10)e--;e<0&&(e=0)}return e};U.dividedBy=U.div=function(o){return Ve(this,new this.constructor(o))};U.dividedToIntegerBy=U.divToInt=function(o){var t=this,e=t.constructor;return re(Ve(t,new e(o),0,1,1),e.precision,e.rounding)};U.equals=U.eq=function(o){return this.cmp(o)===0};U.floor=function(){return re(new this.constructor(this),this.e+1,3)};U.greaterThan=U.gt=function(o){return this.cmp(o)>0};U.greaterThanOrEqualTo=U.gte=function(o){var t=this.cmp(o);return t==1||t===0};U.hyperbolicCosine=U.cosh=function(){var o,t,e,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;e=s.precision,n=s.rounding,s.precision=e+Math.max(r.e,r.sd())+4,s.rounding=1,i=r.d.length,i<32?(o=Math.ceil(i/3),t=(1/Ho(4,o)).toString()):(o=16,t="2.3283064365386962890625e-10"),r=si(s,1,r.times(t),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 re(r,s.precision=e,s.rounding=n,!0)};U.hyperbolicSine=U.sinh=function(){var o,t,e,n,i=this,r=i.constructor;if(!i.isFinite()||i.isZero())return new r(i);if(t=r.precision,e=r.rounding,r.precision=t+Math.max(i.e,i.sd())+4,r.rounding=1,n=i.d.length,n<3)i=si(r,2,i,i,!0);else{o=1.4*Math.sqrt(n),o=o>16?16:o|0,i=i.times(1/Ho(5,o)),i=si(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=t,r.rounding=e,re(i,t,e,!0)};U.hyperbolicTangent=U.tanh=function(){var o,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(o=n.precision,t=n.rounding,n.precision=o+7,n.rounding=1,Ve(e.sinh(),e.cosh(),n.precision=o,n.rounding=t)):new n(e.s)};U.inverseCosine=U.acos=function(){var o,t=this,e=t.constructor,n=t.abs().cmp(1),i=e.precision,r=e.rounding;return n!==-1?n===0?t.isNeg()?Zt(e,i,r):new e(0):new e(NaN):t.isZero()?Zt(e,i+4,r).times(.5):(e.precision=i+6,e.rounding=1,t=t.asin(),o=Zt(e,i+4,r).times(.5),e.precision=i,e.rounding=r,o.minus(t))};U.inverseHyperbolicCosine=U.acosh=function(){var o,t,e=this,n=e.constructor;return e.lte(1)?new n(e.eq(1)?0:NaN):e.isFinite()?(o=n.precision,t=n.rounding,n.precision=o+Math.max(Math.abs(e.e),e.sd())+4,n.rounding=1,le=!1,e=e.times(e).minus(1).sqrt().plus(e),le=!0,n.precision=o,n.rounding=t,e.ln()):new n(e)};U.inverseHyperbolicSine=U.asinh=function(){var o,t,e=this,n=e.constructor;return!e.isFinite()||e.isZero()?new n(e):(o=n.precision,t=n.rounding,n.precision=o+2*Math.max(Math.abs(e.e),e.sd())+6,n.rounding=1,le=!1,e=e.times(e).plus(1).sqrt().plus(e),le=!0,n.precision=o,n.rounding=t,e.ln())};U.inverseHyperbolicTangent=U.atanh=function(){var o,t,e,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,t=r.rounding,n=i.sd(),Math.max(n,o)<2*-i.e-1?re(new r(i),o,t,!0):(r.precision=e=n-i.e,i=Ve(i.plus(1),new r(1).minus(i),e+o,1),r.precision=o+4,r.rounding=1,i=i.ln(),r.precision=o,r.rounding=t,i.times(.5))):new r(NaN)};U.inverseSine=U.asin=function(){var o,t,e,n,i=this,r=i.constructor;return i.isZero()?new r(i):(t=i.abs().cmp(1),e=r.precision,n=r.rounding,t!==-1?t===0?(o=Zt(r,e+4,n).times(.5),o.s=i.s,o):new r(NaN):(r.precision=e+6,r.rounding=1,i=i.div(new r(1).minus(i.times(i)).sqrt().plus(1)).atan(),r.precision=e,r.rounding=n,i.times(2)))};U.inverseTangent=U.atan=function(){var o,t,e,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<=ks)return s=Zt(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=ks)return s=Zt(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,e=Math.min(28,a/ae+2|0),o=e;o;--o)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(le=!1,t=Math.ceil(a/ae),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[t]!==void 0)for(o=t;s.d[o]===r.d[o]&&o--;);return e&&(s=s.times(2<<e-1)),le=!0,re(s,l.precision=m,l.rounding=d,!0)};U.isFinite=function(){return!!this.d};U.isInteger=U.isInt=function(){return!!this.d&&kt(this.e/ae)>this.d.length-2};U.isNaN=function(){return!this.s};U.isNegative=U.isNeg=function(){return this.s<0};U.isPositive=U.isPos=function(){return this.s>0};U.isZero=function(){return!!this.d&&this.d[0]===0};U.lessThan=U.lt=function(o){return this.cmp(o)<0};U.lessThanOrEqualTo=U.lte=function(o){return this.cmp(o)<1};U.logarithm=U.log=function(o){var t,e,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),t=!0;else{if(o=new l(o),e=o.d,o.s<0||!e||!e[0]||o.eq(1))return new l(NaN);t=o.eq(10)}if(e=u.d,u.s<0||!e||!e[0]||u.eq(1))return new l(e&&!e[0]?-1/0:u.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)r=!0;else{for(i=e[0];i%10===0;)i/=10;r=i!==1}if(le=!1,a=m+p,s=Ln(u,a),n=t?zo(l,a+10):Ln(o,a),c=Ve(s,n,a,1),zi(c.d,i=m,d))do if(a+=10,s=Ln(u,a),n=t?zo(l,a+10):Ln(o,a),c=Ve(s,n,a,1),!r){+dt(c.d).slice(i+1,i+15)+1==1e14&&(c=re(c,m+1,0));break}while(zi(c.d,i+=10,d));return le=!0,re(c,m,d)};U.minus=U.sub=function(o){var t,e,n,i,r,s,a,c,u,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(u=p.d,d=o.d,a=y.precision,c=y.rounding,!u[0]||!d[0]){if(d[0])o.s=-o.s;else if(u[0])o=new y(p);else return new y(c===3?-0:0);return le?re(o,a,c):o}if(e=kt(o.e/ae),l=kt(p.e/ae),u=u.slice(),r=l-e,r){for(m=r<0,m?(t=u,r=-r,s=d.length):(t=d,e=l,s=u.length),n=Math.max(Math.ceil(a/ae),s)+2,r>n&&(r=n,t.length=1),t.reverse(),n=r;n--;)t.push(0);t.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&&(t=u,u=d,d=t,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]=$t-1;--u[i],u[n]+=$t}u[n]-=d[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--e;return u[0]?(o.d=u,o.e=Yo(u,e),le?re(o,a,c):o):new y(c===3?-0:0)};U.modulo=U.mod=function(o){var t,e=this,n=e.constructor;return o=new n(o),!e.d||!o.s||o.d&&!o.d[0]?new n(NaN):!o.d||e.d&&!e.d[0]?re(new n(e),n.precision,n.rounding):(le=!1,n.modulo==9?(t=Ve(e,o.abs(),0,3,1),t.s*=o.s):t=Ve(e,o,0,n.modulo,1),t=t.times(o),le=!0,e.minus(t))};U.naturalExponential=U.exp=function(){return hs(this)};U.naturalLogarithm=U.ln=function(){return Ln(this)};U.negated=U.neg=function(){var o=new this.constructor(this);return o.s=-o.s,re(o)};U.plus=U.add=function(o){var t,e,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)),le?re(o,a,c):o;if(r=kt(m.e/ae),n=kt(o.e/ae),u=u.slice(),i=r-n,i){for(i<0?(e=u,i=-i,s=l.length):(e=l,n=r,s=u.length),r=Math.ceil(a/ae),s=r>s?r+1:s+1,i>s&&(i=s,e.length=1),e.reverse();i--;)e.push(0);e.reverse()}for(s=u.length,i=l.length,s-i<0&&(i=s,e=l,l=u,u=e),t=0;i;)t=(u[--i]=u[i]+l[i]+t)/$t|0,u[i]%=$t;for(t&&(u.unshift(t),++n),s=u.length;u[--s]==0;)u.pop();return o.d=u,o.e=Yo(u,n),le?re(o,a,c):o};U.precision=U.sd=function(o){var t,e=this;if(o!==void 0&&o!==!!o&&o!==1&&o!==0)throw Error(Rn+o);return e.d?(t=vu(e.d),o&&e.e+1>t&&(t=e.e+1)):t=NaN,t};U.round=function(){var o=this,t=o.constructor;return re(new t(o),o.e+1,t.rounding)};U.sine=U.sin=function(){var o,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(o=n.precision,t=n.rounding,n.precision=o+Math.max(e.e,e.sd())+ae,n.rounding=1,e=im(n,Fu(n,e)),n.precision=o,n.rounding=t,re(bn>2?e.neg():e,o,t,!0)):new n(NaN)};U.squareRoot=U.sqrt=function(){var o,t,e,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(le=!1,u=Math.sqrt(+s),u==0||u==1/0?(t=dt(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=kt((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),n=new l(t)):n=new l(u.toString()),e=(c=l.precision)+3;;)if(r=n,n=r.plus(Ve(s,r,e+2,1)).times(.5),dt(r.d).slice(0,e)===(t=dt(n.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!i&&t=="4999"){if(!i&&(re(r,c+1,0),r.times(r).eq(s))){n=r;break}e+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(re(n,c+1,1),o=!n.times(n).eq(s));break}return le=!0,re(n,c,l.rounding,o)};U.tangent=U.tan=function(){var o,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(o=n.precision,t=n.rounding,n.precision=o+10,n.rounding=1,e=e.sin(),e.s=1,e=Ve(e,new n(1).minus(e.times(e)).sqrt(),o+10,0),n.precision=o,n.rounding=t,re(bn==2||bn==4?e.neg():e,o,t,!0)):new n(NaN)};U.times=U.mul=function(o){var t,e,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(e=kt(l.e/ae)+kt(o.e/ae),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(t=0,i=c+n;i>n;)a=r[i]+p[n]*d[i-n-1]+t,r[i--]=a%$t|0,t=a/$t|0;r[i]=(r[i]+t)%$t|0}for(;!r[--s];)r.pop();return t?++e:r.shift(),o.d=r,o.e=Yo(r,e),le?re(o,m.precision,m.rounding):o};U.toBinary=function(o,t){return Is(this,2,o,t)};U.toDecimalPlaces=U.toDP=function(o,t){var e=this,n=e.constructor;return e=new n(e),o===void 0?e:(Mt(o,0,On),t===void 0?t=n.rounding:Mt(t,0,8),re(e,o+e.e+1,t))};U.toExponential=function(o,t){var e,n=this,i=n.constructor;return o===void 0?e=un(n,!0):(Mt(o,0,On),t===void 0?t=i.rounding:Mt(t,0,8),n=re(new i(n),o+1,t),e=un(n,!0,o+1)),n.isNeg()&&!n.isZero()?"-"+e:e};U.toFixed=function(o,t){var e,n,i=this,r=i.constructor;return o===void 0?e=un(i):(Mt(o,0,On),t===void 0?t=r.rounding:Mt(t,0,8),n=re(new r(i),o+i.e+1,t),e=un(n,!1,o+n.e+1)),i.isNeg()&&!i.isZero()?"-"+e:e};U.toFraction=function(o){var t,e,n,i,r,s,a,c,u,l,m,d,p=this,y=p.d,f=p.constructor;if(!y)return new f(p);if(u=e=new f(1),n=c=new f(0),t=new f(n),r=t.e=vu(y)-p.e-1,s=r%ae,t.d[0]=et(10,s<0?ae+s:s),o==null)o=r>0?t:u;else{if(a=new f(o),!a.isInt()||a.lt(u))throw Error(Rn+a);o=a.gt(t)?r>0?t:u:a}for(le=!1,a=new f(dt(y)),l=f.precision,f.precision=r=y.length*ae*2;m=Ve(a,t,0,1,1),i=e.plus(m.times(n)),i.cmp(o)!=1;)e=n,n=i,i=u,u=c.plus(m.times(i)),c=i,i=t,t=a.minus(m.times(i)),a=i;return i=Ve(o.minus(e),n,0,1,1),c=c.plus(i.times(u)),e=e.plus(i.times(n)),c.s=u.s=p.s,d=Ve(u,n,r,1).minus(p).abs().cmp(Ve(c,e,r,1).minus(p).abs())<1?[u,n]:[c,e],f.precision=l,le=!0,d};U.toHexadecimal=U.toHex=function(o,t){return Is(this,16,o,t)};U.toNearest=function(o,t){var e=this,n=e.constructor;if(e=new n(e),o==null){if(!e.d)return e;o=new n(1),t=n.rounding}else{if(o=new n(o),t===void 0?t=n.rounding:Mt(t,0,8),!e.d)return o.s?e:o;if(!o.d)return o.s&&(o.s=e.s),o}return o.d[0]?(le=!1,e=Ve(e,o,0,t,1).times(o),le=!0,re(e)):(o.s=e.s,e=o),e};U.toNumber=function(){return+this};U.toOctal=function(o,t){return Is(this,8,o,t)};U.toPower=U.pow=function(o){var t,e,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(et(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,r=c.rounding,o.eq(1))return re(a,n,r);if(t=kt(o.e/ae),t>=o.d.length-1&&(e=u<0?-u:u)<=Jl)return i=Vu(c,a,e,n),o.s<0?new c(1).div(i):re(i,n,r);if(s=a.s,s<0){if(t<o.d.length-1)return new c(NaN);if((o.d[t]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return e=et(+a,u),t=e==0||!isFinite(e)?kt(u*(Math.log("0."+dt(a.d))/Math.LN10+a.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(le=!1,c.rounding=a.s=1,e=Math.min(12,(t+"").length),i=hs(o.times(Ln(a,n+e)),n),i.d&&(i=re(i,n+5,1),zi(i.d,n,r)&&(t=n+10,i=re(hs(o.times(Ln(a,t+e)),t),t+5,1),+dt(i.d).slice(n+1,n+15)+1==1e14&&(i=re(i,n+1,0)))),i.s=s,le=!0,c.rounding=r,re(i,n,r))};U.toPrecision=function(o,t){var e,n=this,i=n.constructor;return o===void 0?e=un(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Mt(o,1,On),t===void 0?t=i.rounding:Mt(t,0,8),n=re(new i(n),o,t),e=un(n,o<=n.e||n.e<=i.toExpNeg,o)),n.isNeg()&&!n.isZero()?"-"+e:e};U.toSignificantDigits=U.toSD=function(o,t){var e=this,n=e.constructor;return o===void 0?(o=n.precision,t=n.rounding):(Mt(o,1,On),t===void 0?t=n.rounding:Mt(t,0,8)),re(new n(e),o,t)};U.toString=function(){var o=this,t=o.constructor,e=un(o,o.e<=t.toExpNeg||o.e>=t.toExpPos);return o.isNeg()&&!o.isZero()?"-"+e:e};U.truncated=U.trunc=function(){return re(new this.constructor(this),this.e+1,1)};U.valueOf=U.toJSON=function(){var o=this,t=o.constructor,e=un(o,o.e<=t.toExpNeg||o.e>=t.toExpPos);return o.isNeg()?"-"+e:e};function dt(o){var t,e,n,i=o.length-1,r="",s=o[0];if(i>0){for(r+=s,t=1;t<i;t++)n=o[t]+"",e=ae-n.length,e&&(r+=Cn(e)),r+=n;s=o[t],n=s+"",e=ae-n.length,e&&(r+=Cn(e))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function Mt(o,t,e){if(o!==~~o||o<t||o>e)throw Error(Rn+o)}function zi(o,t,e,n){var i,r,s,a;for(r=o[0];r>=10;r/=10)--t;return--t<0?(t+=ae,i=0):(i=Math.ceil((t+1)/ae),t%=ae),r=et(10,ae-t),a=o[i]%r|0,n==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),s=e<4&&a==99999||e>3&&a==49999||a==5e4||a==0):s=(e<4&&a+1==r||e>3&&a+1==r/2)&&(o[i+1]/r/100|0)==et(10,t-2)-1||(a==r/2||a==0)&&(o[i+1]/r/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==2&&(a=a/10|0),s=(n||e<4)&&a==9999||!n&&e>3&&a==4999):s=((n||e<4)&&a+1==r||!n&&e>3&&a+1==r/2)&&(o[i+1]/r/1e3|0)==et(10,t-3)-1,s}function Uo(o,t,e){for(var n,i=[0],r,s=0,a=o.length;s<a;){for(r=i.length;r--;)i[r]*=t;for(i[0]+=As.indexOf(o.charAt(s++)),n=0;n<i.length;n++)i[n]>e-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/e|0,i[n]%=e)}return i.reverse()}function tm(o,t){var e,n,i;if(t.isZero())return t;n=t.d.length,n<32?(e=Math.ceil(n/3),i=(1/Ho(4,e)).toString()):(e=16,i="2.3283064365386962890625e-10"),o.precision+=e,t=si(o,1,t.times(i),new o(1));for(var r=e;r--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return o.precision-=e,t}var Ve=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 t(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 e(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,y,f,b,g,A,w,k,I,h,x,K,S,B,C,L,O=n.constructor,F=n.s==i.s?1:-1,q=n.d,E=i.d;if(!q||!q[0]||!E||!E[0])return new O(!n.s||!i.s||(q?E&&q[0]==E[0]:!E)?NaN:q&&q[0]==0||!E?F*0:F/0);for(c?(p=1,l=n.e-i.e):(c=$t,p=ae,l=kt(n.e/p)-kt(i.e/p)),C=E.length,S=q.length,g=new O(F),A=g.d=[],m=0;E[m]==(q[m]||0);m++);if(E[m]>(q[m]||0)&&l--,r==null?(h=r=O.precision,s=O.rounding):a?h=r+(n.e-i.e)+1:h=r,h<0)A.push(1),y=!0;else{if(h=h/p+2|0,m=0,C==1){for(d=0,E=E[0],h++;(m<S||d)&&h--;m++)x=d*c+(q[m]||0),A[m]=x/E|0,d=x%E|0;y=d||m<S}else{for(d=c/(E[0]+1)|0,d>1&&(E=o(E,d,c),q=o(q,d,c),C=E.length,S=q.length),K=C,w=q.slice(0,C),k=w.length;k<C;)w[k++]=0;L=E.slice(),L.unshift(0),B=E[0],E[1]>=c/2&&++B;do d=0,u=t(E,w,C,k),u<0?(I=w[0],C!=k&&(I=I*c+(w[1]||0)),d=I/B|0,d>1?(d>=c&&(d=c-1),f=o(E,d,c),b=f.length,k=w.length,u=t(f,w,b,k),u==1&&(d--,e(f,C<b?L:E,b,c))):(d==0&&(u=d=1),f=E.slice()),b=f.length,b<k&&f.unshift(0),e(w,f,k,c),u==-1&&(k=w.length,u=t(E,w,C,k),u<1&&(d++,e(w,C<k?L:E,k,c))),k=w.length):u===0&&(d++,w=[0]),A[m++]=d,u&&w[0]?w[k++]=q[K]||0:(w=[q[K]],k=1);while((K++<S||w[0]!==void 0)&&h--);y=w[0]!==void 0}A[0]||A.shift()}if(p==1)g.e=l,Lu=y;else{for(m=1,d=A[0];d>=10;d/=10)m++;g.e=m+l*p-1,re(g,a?r+g.e+1:r,s,y)}return g}}();function re(o,t,e,n){var i,r,s,a,c,u,l,m,d,p=o.constructor;e:if(t!=null){if(m=o.d,!m)return o;for(i=1,a=m[0];a>=10;a/=10)i++;if(r=t-i,r<0)r+=ae,s=t,l=m[d=0],c=l/et(10,i-s-1)%10|0;else if(d=Math.ceil((r+1)/ae),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=c=0,i=1,r%=ae,s=r-ae+1}else break e;else{for(l=a=m[d],i=1;a>=10;a/=10)i++;r%=ae,s=r-ae+i,c=s<0?0:l/et(10,i-s-1)%10|0}if(n=n||t<0||m[d+1]!==void 0||(s<0?l:l%et(10,i-s-1)),u=e<4?(c||n)&&(e==0||e==(o.s<0?3:2)):c>5||c==5&&(e==4||n||e==6&&(r>0?s>0?l/et(10,i-s):0:m[d-1])%10&1||e==(o.s<0?8:7)),t<1||!m[0])return m.length=0,u?(t-=o.e+1,m[0]=et(10,(ae-t%ae)%ae),o.e=-t||0):m[0]=o.e=0,o;if(r==0?(m.length=d,a=1,d--):(m.length=d+1,a=et(10,ae-r),m[d]=s>0?(l/et(10,i-s)%et(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]==$t&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=$t)break;m[d--]=0,a=1}for(r=m.length;m[--r]===0;)m.pop()}return le&&(o.e>p.maxE?(o.d=null,o.e=NaN):o.e<p.minE&&(o.e=0,o.d=[0])),o}function un(o,t,e){if(!o.isFinite())return Eu(o);var n,i=o.e,r=dt(o.d),s=r.length;return t?(e&&(n=e-s)>0?r=r.charAt(0)+"."+r.slice(1)+Cn(n):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(o.e<0?"e":"e+")+o.e):i<0?(r="0."+Cn(-i-1)+r,e&&(n=e-s)>0&&(r+=Cn(n))):i>=s?(r+=Cn(i+1-s),e&&(n=e-i-1)>0&&(r=r+"."+Cn(n))):((n=i+1)<s&&(r=r.slice(0,n)+"."+r.slice(n)),e&&(n=e-s)>0&&(i+1===s&&(r+="."),r+=Cn(n))),r}function Yo(o,t){var e=o[0];for(t*=ae;e>=10;e/=10)t++;return t}function zo(o,t,e){if(t>em)throw le=!0,e&&(o.precision=e),Error(Ru);return re(new o(Go),t,1,!0)}function Zt(o,t,e){if(t>ks)throw Error(Ru);return re(new o(Xo),t,e,!0)}function vu(o){var t=o.length-1,e=t*ae+1;if(t=o[t],t){for(;t%10==0;t/=10)e--;for(t=o[0];t>=10;t/=10)e++}return e}function Cn(o){for(var t="";o--;)t+="0";return t}function Vu(o,t,e,n){var i,r=new o(1),s=Math.ceil(n/ae+4);for(le=!1;;){if(e%2&&(r=r.times(t),Su(r.d,s)&&(i=!0)),e=kt(e/2),e===0){e=r.d.length-1,i&&r.d[e]===0&&++r.d[e];break}t=t.times(t),Su(t.d,s)}return le=!0,r}function Ku(o){return o.d[o.d.length-1]&1}function _u(o,t,e){for(var n,i=new o(t[0]),r=0;++r<t.length;)if(n=new o(t[r]),n.s)i[e](n)&&(i=n);else{i=n;break}return i}function hs(o,t){var e,n,i,r,s,a,c,u=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(t==null?(le=!1,c=y):c=t,a=new d(.03125);o.e>-2;)o=o.times(a),m+=5;for(n=Math.log(et(2,m))/Math.LN10*2+5|0,c+=n,e=r=s=new d(1),d.precision=c;;){if(r=re(r.times(o),c,1),e=e.times(++l),a=s.plus(Ve(r,e,c,1)),dt(a.d).slice(0,c)===dt(s.d).slice(0,c)){for(i=m;i--;)s=re(s.times(s),c,1);if(t==null)if(u<3&&zi(s.d,c-n,p,u))d.precision=c+=10,e=r=a=new d(1),l=0,u++;else return re(s,d.precision=y,p,le=!0);else return d.precision=y,s}s=a}}function Ln(o,t){var e,n,i,r,s,a,c,u,l,m,d,p=1,y=10,f=o,b=f.d,g=f.constructor,A=g.rounding,w=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(t==null?(le=!1,l=w):l=t,g.precision=l+=y,e=dt(b),n=e.charAt(0),Math.abs(r=f.e)<15e14){for(;n<7&&n!=1||n==1&&e.charAt(1)>3;)f=f.times(o),e=dt(f.d),n=e.charAt(0),p++;r=f.e,n>1?(f=new g("0."+e),r++):f=new g(n+"."+e.slice(1))}else return u=zo(g,l+2,w).times(r+""),f=Ln(new g(n+"."+e.slice(1)),l-y).plus(u),g.precision=w,t==null?re(f,w,A,le=!0):f;for(m=f,c=s=f=Ve(f.minus(1),f.plus(1),l,1),d=re(f.times(f),l,1),i=3;;){if(s=re(s.times(d),l,1),u=c.plus(Ve(s,new g(i),l,1)),dt(u.d).slice(0,l)===dt(c.d).slice(0,l))if(c=c.times(2),r!==0&&(c=c.plus(zo(g,l+2,w).times(r+""))),c=Ve(c,new g(p),l,1),t==null)if(zi(c.d,l-y,A,a))g.precision=l+=y,u=s=f=Ve(m.minus(1),m.plus(1),l,1),d=re(f.times(f),l,1),i=a=1;else return re(c,g.precision=w,A,le=!0);else return g.precision=w,c;c=u,i+=2}}function Eu(o){return String(o.s*o.s/0)}function Ts(o,t){var e,n,i;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(e<0&&(e=n),e+=+t.slice(n+1),t=t.substring(0,n)):e<0&&(e=t.length),n=0;t.charCodeAt(n)===48;n++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(n,i),t){if(i-=n,o.e=e=e-n-1,o.d=[],n=(e+1)%ae,e<0&&(n+=ae),n<i){for(n&&o.d.push(+t.slice(0,n)),i-=ae;n<i;)o.d.push(+t.slice(n,n+=ae));t=t.slice(n),n=ae-t.length}else n-=i;for(;n--;)t+="0";o.d.push(+t),le&&(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 nm(o,t){var e,n,i,r,s,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Nu.test(t))return Ts(o,t)}else if(t==="Infinity"||t==="NaN")return+t||(o.s=NaN),o.e=NaN,o.d=null,o;if(Zl.test(t))e=16,t=t.toLowerCase();else if(jl.test(t))e=2;else if($l.test(t))e=8;else throw Error(Rn+t);for(r=t.search(/p/i),r>0?(c=+t.slice(r+1),t=t.substring(2,r)):t=t.slice(2),r=t.indexOf("."),s=r>=0,n=o.constructor,s&&(t=t.replace(".",""),a=t.length,r=a-r,i=Vu(n,new n(e),r,r*2)),u=Uo(t,e,$t),l=u.length-1,r=l;u[r]===0;--r)u.pop();return r<0?new n(o.s*0):(o.e=Yo(u,l),o.d=u,le=!1,s&&(o=Ve(o,i,a*4)),c&&(o=o.times(Math.abs(c)<54?et(2,c):Qi.pow(2,c))),le=!0,o)}function im(o,t){var e,n=t.d.length;if(n<3)return t.isZero()?t:si(o,2,t,t);e=1.4*Math.sqrt(n),e=e>16?16:e|0,t=t.times(1/Ho(5,e)),t=si(o,2,t,t);for(var i,r=new o(5),s=new o(16),a=new o(20);e--;)i=t.times(t),t=t.times(r.plus(i.times(s.times(i).minus(a))));return t}function si(o,t,e,n,i){var r,s,a,c,u=1,l=o.precision,m=Math.ceil(l/ae);for(le=!1,c=e.times(e),a=new o(n);;){if(s=Ve(a.times(c),new o(t++*t++),l,1),a=i?n.plus(s):n.minus(s),n=Ve(s.times(c),new o(t++*t++),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 le=!0,s.d.length=m+1,s}function Ho(o,t){for(var e=o;--t;)e*=o;return e}function Fu(o,t){var e,n=t.s<0,i=Zt(o,o.precision,1),r=i.times(.5);if(t=t.abs(),t.lte(r))return bn=n?4:1,t;if(e=t.divToInt(i),e.isZero())bn=n?3:2;else{if(t=t.minus(e.times(i)),t.lte(r))return bn=Ku(e)?n?2:3:n?4:1,t;bn=Ku(e)?n?1:4:n?3:2}return t.minus(i).abs()}function Is(o,t,e,n){var i,r,s,a,c,u,l,m,d,p=o.constructor,y=e!==void 0;if(y?(Mt(e,1,On),n===void 0?n=p.rounding:Mt(n,0,8)):(e=p.precision,n=p.rounding),!o.isFinite())l=Eu(o);else{for(l=un(o),s=l.indexOf("."),y?(i=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):i=t,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Uo(un(d),10,i),d.e=d.d.length),m=Uo(l,10,i),r=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=y?"0p+0":"0";else{if(s<0?r--:(o=new p(o),o.d=m,o.e=r,o=Ve(o,d,e,n,0,i),m=o.d,r=o.e,u=Lu),s=m[e],a=i/2,u=u||m[e+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[e-1]&1||n===(o.s<0?8:7)),m.length=e,u)for(;++m[--e]>i-1;)m[e]=0,e||(++r,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=As.charAt(m[s]);if(y){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(m=Uo(l,i,t),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=As.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=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return o.s<0?"-"+l:l}function Su(o,t){if(o.length>t)return o.length=t,!0}function om(o){return new this(o).abs()}function rm(o){return new this(o).acos()}function sm(o){return new this(o).acosh()}function am(o,t){return new this(o).plus(t)}function um(o){return new this(o).asin()}function cm(o){return new this(o).asinh()}function lm(o){return new this(o).atan()}function mm(o){return new this(o).atanh()}function dm(o,t){o=new this(o),t=new this(t);var e,n=this.precision,i=this.rounding,r=n+4;return!o.s||!t.s?e=new this(NaN):!o.d&&!t.d?(e=Zt(this,r,1).times(t.s>0?.25:.75),e.s=o.s):!t.d||o.isZero()?(e=t.s<0?Zt(this,n,i):new this(0),e.s=o.s):!o.d||t.isZero()?(e=Zt(this,r,1).times(.5),e.s=o.s):t.s<0?(this.precision=r,this.rounding=1,e=this.atan(Ve(o,t,r,1)),t=Zt(this,r,1),this.precision=n,this.rounding=i,e=o.s<0?e.minus(t):e.plus(t)):e=this.atan(Ve(o,t,r,1)),e}function pm(o){return new this(o).cbrt()}function fm(o){return re(o=new this(o),o.e+1,2)}function ym(o,t,e){return new this(o).clamp(t,e)}function bm(o){if(!o||typeof o!="object")throw Error(Qo+"Object expected");var t,e,n,i=o.defaults===!0,r=["precision",1,On,"rounding",0,8,"toExpNeg",-ri,0,"toExpPos",0,ri,"maxE",0,ri,"minE",-ri,0,"modulo",0,9];for(t=0;t<r.length;t+=3)if(e=r[t],i&&(this[e]=ws[e]),(n=o[e])!==void 0)if(kt(n)===n&&n>=r[t+1]&&n<=r[t+2])this[e]=n;else throw Error(Rn+e+": "+n);if(e="crypto",i&&(this[e]=ws[e]),(n=o[e])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(Ou);else this[e]=!1;else throw Error(Rn+e+": "+n);return this}function gm(o){return new this(o).cos()}function Pm(o){return new this(o).cosh()}function Wu(o){var t,e,n;function i(r){var s,a,c,u=this;if(!(u instanceof i))return new i(r);if(u.constructor=i,Cu(r)){u.s=r.s,le?!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++;le?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 Ts(u,r.toString())}else if(c!=="string")throw Error(Rn+r);return(a=r.charCodeAt(0))===45?(r=r.slice(1),u.s=-1):(a===43&&(r=r.slice(1)),u.s=1),Nu.test(r)?Ts(u,r):nm(u,r)}if(i.prototype=U,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=bm,i.clone=Wu,i.isDecimal=Cu,i.abs=om,i.acos=rm,i.acosh=sm,i.add=am,i.asin=um,i.asinh=cm,i.atan=lm,i.atanh=mm,i.atan2=dm,i.cbrt=pm,i.ceil=fm,i.clamp=ym,i.cos=gm,i.cosh=Pm,i.div=Am,i.exp=wm,i.floor=km,i.hypot=hm,i.ln=Tm,i.log=Im,i.log10=xm,i.log2=Bm,i.max=Km,i.min=Sm,i.mod=Cm,i.mul=Lm,i.pow=Rm,i.random=Om,i.round=Mm,i.sign=Nm,i.sin=vm,i.sinh=Vm,i.sqrt=_m,i.sub=Em,i.sum=Fm,i.tan=Wm,i.tanh=Dm,i.trunc=qm,o===void 0&&(o={}),o&&o.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)o.hasOwnProperty(e=n[t++])||(o[e]=this[e]);return i.config(o),i}function Am(o,t){return new this(o).div(t)}function wm(o){return new this(o).exp()}function km(o){return re(o=new this(o),o.e+1,3)}function hm(){var o,t,e=new this(0);for(le=!1,o=0;o<arguments.length;)if(t=new this(arguments[o++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return le=!0,new this(1/0);e=t}return le=!0,e.sqrt()}function Cu(o){return o instanceof Qi||o&&o.toStringTag===Mu||!1}function Tm(o){return new this(o).ln()}function Im(o,t){return new this(o).log(t)}function Bm(o){return new this(o).log(2)}function xm(o){return new this(o).log(10)}function Km(){return _u(this,arguments,"lt")}function Sm(){return _u(this,arguments,"gt")}function Cm(o,t){return new this(o).mod(t)}function Lm(o,t){return new this(o).mul(t)}function Rm(o,t){return new this(o).pow(t)}function Om(o){var t,e,n,i,r=0,s=new this(1),a=[];if(o===void 0?o=this.precision:Mt(o,1,On),n=Math.ceil(o/ae),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));r<n;)i=t[r],i>=429e7?t[r]=crypto.getRandomValues(new Uint32Array(1))[0]:a[r++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(n*=4);r<n;)i=t[r]+(t[r+1]<<8)+(t[r+2]<<16)+((t[r+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,r):(a.push(i%1e7),r+=4);r=n/4}else throw Error(Ou);else for(;r<n;)a[r++]=Math.random()*1e7|0;for(n=a[--r],o%=ae,n&&o&&(i=et(10,ae-o),a[r]=(n/i|0)*i);a[r]===0;r--)a.pop();if(r<0)e=0,a=[0];else{for(e=-1;a[0]===0;e-=ae)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<ae&&(e-=ae-n)}return s.e=e,s.d=a,s}function Mm(o){return re(o=new this(o),o.e+1,this.rounding)}function Nm(o){return o=new this(o),o.d?o.d[0]?o.s:0*o.s:o.s||NaN}function vm(o){return new this(o).sin()}function Vm(o){return new this(o).sinh()}function _m(o){return new this(o).sqrt()}function Em(o,t){return new this(o).sub(t)}function Fm(){var o=0,t=arguments,e=new this(t[o]);for(le=!1;e.s&&++o<t.length;)e=e.plus(t[o]);return le=!0,re(e,this.precision,this.rounding)}function Wm(o){return new this(o).tan()}function Dm(o){return new this(o).tanh()}function qm(o){return re(o=new this(o),o.e+1,1)}U[Symbol.for("nodejs.util.inspect.custom")]=U.toString;U[Symbol.toStringTag]="Decimal";var Qi=U.constructor=Wu(ws);Go=new Qi(Go);Xo=new Qi(Xo);var _=Qi;var zu=be(require("big.js")),Zi=be(require("bn.js"));var Du=be(require("toformat")),Um=Du.default,Yi=Um;var Hi=be(require("big.js")),Uu=be(require("bn.js")),Gu=be(require("decimal.js-light"));var ai=be(require("bn.js"));var qu=9007199254740991;function ie(o){let t=ge("Raydium_parseBigNumberish");if(o instanceof ai.default)return o;if(typeof o=="string"){if(o.match(/^-?[0-9]+$/))return new ai.default(o);t.logWithError(`invalid BigNumberish string: ${o}`)}return typeof o=="number"?(o%1&&t.logWithError(`BigNumberish number underflow: ${o}`),(o>=qu||o<=-qu)&&t.logWithError(`BigNumberish number overflow: ${o}`),new ai.default(String(o))):typeof o=="bigint"?new ai.default(o.toString()):(t.error(`invalid BigNumberish value: ${o}`),new ai.default(0))}var jo=ge("module/fraction"),Bs=Yi(Hi.default),ji=Yi(Gu.default),Xm={[0]:ji.ROUND_DOWN,[1]:ji.ROUND_HALF_UP,[2]:ji.ROUND_UP},zm={[0]:Hi.default.roundDown,[1]:Hi.default.roundHalfUp,[2]:Hi.default.roundUp},xe=class{constructor(t,e=new Uu.default(1)){this.numerator=ie(t),this.denominator=ie(e)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new xe(this.denominator,this.numerator)}add(t){let e=t instanceof xe?t:new xe(ie(t));return this.denominator.eq(e.denominator)?new xe(this.numerator.add(e.numerator),this.denominator):new xe(this.numerator.mul(e.denominator).add(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}sub(t){let e=t instanceof xe?t:new xe(ie(t));return this.denominator.eq(e.denominator)?new xe(this.numerator.sub(e.numerator),this.denominator):new xe(this.numerator.mul(e.denominator).sub(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}mul(t){let e=t instanceof xe?t:new xe(ie(t));return new xe(this.numerator.mul(e.numerator),this.denominator.mul(e.denominator))}div(t){let e=t instanceof xe?t:new xe(ie(t));return new xe(this.numerator.mul(e.denominator),this.denominator.mul(e.numerator))}toSignificant(t,e={groupSeparator:""},n=1){Number.isInteger(t)||jo.logWithError(`${t} is not an integer.`),t<=0&&jo.logWithError(`${t} is not positive.`),ji.set({precision:t+1,rounding:Xm[n]});let i=new ji(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return i.toFormat(i.decimalPlaces(),e)}toFixed(t,e={groupSeparator:""},n=1){return Number.isInteger(t)||jo.logWithError(`${t} is not an integer.`),t<0&&jo.logWithError(`${t} is negative.`),Bs.DP=t,Bs.RM=zm[n]||1,new Bs(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)}isZero(){return this.numerator.isZero()}};var Qm=ge("Raydium_amount"),Xu=Yi(zu.default);function Ym(o,t){let e="0",n="0";if(o.includes(".")){let i=o.split(".");i.length===2?([e,n]=i,n=n.padEnd(t,"0")):Qm.logWithError(`invalid number string, num: ${o}`)}else e=o;return[e,n.slice(0,t)||n]}var ve=class extends xe{constructor(e,n,i=!0,r){let s=new Zi.default(0),a=xs.pow(new Zi.default(e.decimals));if(i)s=ie(n);else{let c=new Zi.default(0),u=new Zi.default(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=Ym(n.toString(),e.decimals);c=ie(l),u=ie(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=ge(r||"TokenAmount"),this.token=e}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(e){return this.token.equals(e.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(e.raw)}lt(e){return this.token.equals(e.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(e.raw)}add(e){return this.token.equals(e.token)||this.logger.logWithError("add token not equals"),new ve(this.token,this.raw.add(e.raw))}subtract(e){return this.token.equals(e.token)||this.logger.logWithError("sub token not equals"),new ve(this.token,this.raw.sub(e.raw))}toSignificant(e=this.token.decimals,n,i=0){return super.toSignificant(e,n,i)}toFixed(e=this.token.decimals,n,i=0){return e>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(e,n,i)}toExact(e={groupSeparator:""}){return Xu.DP=this.token.decimals,new Xu(this.numerator.toString()).div(this.denominator.toString()).toFormat(e)}};var Qu=require("@solana/web3.js"),Ks=require("@solana/spl-token"),Jt={chainId:101,address:Qu.PublicKey.default.toBase58(),programId:Ks.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},tt={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Ks.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var Jo=require("@solana/web3.js");var Oe=require("@solana/web3.js"),Yu=require("@solana/spl-token");function P({pubkey:o,isSigner:t=!1,isWritable:e=!0}){return{pubkey:o,isWritable:e,isSigner:t}}var Ss=[P({pubkey:Yu.TOKEN_PROGRAM_ID,isWritable:!1}),P({pubkey:Oe.SystemProgram.programId,isWritable:!1}),P({pubkey:Oe.SYSVAR_RENT_PUBKEY,isWritable:!1})];function Cs({publicKey:o,transformSol:t}){let e=Ls(o.toString());if(e instanceof Oe.PublicKey)return t&&e.equals(rt)?$:e;if(t&&e.toString()===rt.toBase58())return $;if(typeof e=="string"){if(e===Oe.PublicKey.default.toBase58())return Oe.PublicKey.default;try{return new Oe.PublicKey(e)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Ls(o){try{return new Oe.PublicKey(o)}catch{return o}}var Qn=new Oe.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),cn=new Oe.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),je=new Oe.PublicKey("SysvarRent111111111111111111111111111111111"),Rs=new Oe.PublicKey("SysvarC1ock11111111111111111111111111111111"),gn=new Oe.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Zo=new Oe.PublicKey("Sysvar1nstructions1111111111111111111111111"),$o=Oe.SystemProgram.programId,Jp=new Oe.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),ef=new Oe.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),tf=new Oe.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),nf=new Oe.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),of=new Oe.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),rf=new Oe.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),sf=new Oe.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),af=new Oe.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),uf=new Oe.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),cf=new Oe.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),lf=new Oe.PublicKey("7vf