goosefx-amm-sdk
Version:
SDK for the GooseFx AMM
1 lines • 229 kB
JavaScript
"use strict";var ar=Object.create;var At=Object.defineProperty;var sr=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var cr=Object.getPrototypeOf,mr=Object.prototype.hasOwnProperty;var lr=(n,t)=>{for(var e in t)At(n,e,{get:t[e],enumerable:!0})},$n=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ur(t))!mr.call(n,r)&&r!==e&&At(n,r,{get:()=>t[r],enumerable:!(o=sr(t,r))||o.enumerable});return n};var W=(n,t,e)=>(e=n!=null?ar(cr(n)):{},$n(t||!n||!n.__esModule?At(e,"default",{value:n,enumerable:!0}):e,n)),dr=n=>$n(At({},"__esModule",{value:!0}),n);var ma={};lr(ma,{ConstantProductCurve:()=>ke,CpmmCoder:()=>rr,CurveCalculator:()=>fe,DynamicFee:()=>Le,FEE_RATE_DENOMINATOR_VALUE:()=>re,GfxCpmmClient:()=>_t,ONE_BASIS_POINT:()=>jo,OracleBasedCurveCalculator:()=>Ve,RoundDirection:()=>$t,SOL_INFO:()=>ne,TOKEN_WSOL:()=>ae,closeAccountInstruction:()=>Xe,createWSolAccountInstructions:()=>Jt,generatePubKey:()=>gt,getCpmmPdaAmmConfigId:()=>Di,getCpmmPdaPoolId:()=>Zo,getCreatePoolKeys:()=>En,getPdaLpMint:()=>qi,getPdaObservationId:()=>Ue,getPdaPoolAuthority:()=>Ye,getPdaPoolPartners:()=>tn,getPdaUserLiquidity:()=>en,getPdaVault:()=>On,initTokenAccountInstruction:()=>Yt,makeAddPartnerInstruction:()=>zn,makeCalculatePartnerFeesInstruction:()=>ji,makeCalculateRewardsInstruction:()=>Hi,makeClaimPartnerFeesInstruction:()=>Zi,makeClaimRewardsInstruction:()=>Gi,makeCreateCpmmPoolInInstruction:()=>Dn,makeCreateRewardsInstruction:()=>Vi,makeDepositCpmmInInstruction:()=>qn,makeInitUserPoolLiquidityInstruction:()=>Fn,makeInitializePartnerInstruction:()=>Hn,makeSwapCpmmBaseInInstruction:()=>Wn,makeSwapCpmmBaseOutInstruction:()=>Vn,makeSwapCpmmOracleBaseInInstruction:()=>Gn,makeTransferInstruction:()=>Mn,makeUpdatePartnerInstruction:()=>zi,makeWithdrawCpmmInInstruction:()=>Un,parseTokenAccountResp:()=>In,parseTokenInfo:()=>Xi,solToWSolToken:()=>$i,splAccountLayout:()=>Ze,toFeeConfig:()=>Qe,toGammaApiToken:()=>Je,toToken:()=>Ji,toTokenAmount:()=>Qi,toTokenInfo:()=>Yi,unionArr:()=>ca,wSolToSolToken:()=>ea});module.exports=dr(ma);var Zn=require("@solana/web3.js"),or=require("lodash");var Lo=W(require("axios"));var nt=require("lodash");var on=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(o=>typeof o=="object"?JSON.stringify(o):o).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}},eo={},pr={};function V(n){let t=(0,nt.get)(eo,n);if(!t){let e=(0,nt.get)(pr,n);t=new on({name:n,logLevel:e}),(0,nt.set)(eo,n,t)}return t}var kr=require("@solana/web3.js"),_r=W(require("bn.js"));var ao=W(require("big.js")),at=W(require("bn.js"));var ee=W(require("bn.js"));var xt=new ee.default(0),fa=new ee.default(1),ga=new ee.default(2),ha=new ee.default(3),ya=new ee.default(5),rn=new ee.default(10),ba=new ee.default(100),wa=new ee.default(1e3),ka=new ee.default(1e4),to=9007199254740991;function ie(n){let t=V("Gfx_parseBigNumberish");if(n instanceof ee.default)return n;if(typeof n=="string"){if(n.match(/^-?[0-9]+$/))return new ee.default(n);t.logWithError(`invalid BigNumberish string: ${n}`)}return typeof n=="number"?(n%1&&t.logWithError(`BigNumberish number underflow: ${n}`),(n>=to||n<=-to)&&t.logWithError(`BigNumberish number overflow: ${n}`),new ee.default(String(n))):typeof n=="bigint"?new ee.default(n.toString()):(t.error(`invalid BigNumberish value: ${n}`),new ee.default(0))}var no=W(require("toformat")),fr=no.default,ot=fr;var rt=W(require("big.js")),oo=W(require("bn.js")),ro=W(require("decimal.js-light"));var vt=V("module/fraction"),an=ot(rt.default),it=ot(ro.default),hr={[0]:it.ROUND_DOWN,[1]:it.ROUND_HALF_UP,[2]:it.ROUND_UP},yr={[0]:rt.default.roundDown,[1]:rt.default.roundHalfUp,[2]:rt.default.roundUp},D=class{constructor(t,e=new oo.default(1)){this.numerator=ie(t),this.denominator=ie(e)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new D(this.denominator,this.numerator)}add(t){let e=t instanceof D?t:new D(ie(t));return this.denominator.eq(e.denominator)?new D(this.numerator.add(e.numerator),this.denominator):new D(this.numerator.mul(e.denominator).add(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}sub(t){let e=t instanceof D?t:new D(ie(t));return this.denominator.eq(e.denominator)?new D(this.numerator.sub(e.numerator),this.denominator):new D(this.numerator.mul(e.denominator).sub(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}mul(t){let e=t instanceof D?t:new D(ie(t));return new D(this.numerator.mul(e.numerator),this.denominator.mul(e.denominator))}div(t){let e=t instanceof D?t:new D(ie(t));return new D(this.numerator.mul(e.denominator),this.denominator.mul(e.numerator))}toSignificant(t,e={groupSeparator:""},o=1){Number.isInteger(t)||vt.logWithError(`${t} is not an integer.`),t<=0&&vt.logWithError(`${t} is not positive.`),it.set({precision:t+1,rounding:hr[o]});let r=new it(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return r.toFormat(r.decimalPlaces(),e)}toFixed(t,e={groupSeparator:""},o=1){return Number.isInteger(t)||vt.logWithError(`${t} is not an integer.`),t<0&&vt.logWithError(`${t} is negative.`),an.DP=t,an.RM=yr[o]||1,new an(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)}isZero(){return this.numerator.isZero()}};var br=V("Gfx_amount"),io=ot(ao.default);function wr(n,t){let e="0",o="0";if(n.includes(".")){let r=n.split(".");r.length===2?([e,o]=r,o=o.padEnd(t,"0")):br.logWithError(`invalid number string, num: ${n}`)}else e=n;return[e,o.slice(0,t)||o]}var he=class extends D{constructor(e,o,r=!0,i){let a=new at.default(0),s=rn.pow(new at.default(e.decimals));if(r)a=ie(o);else{let u=new at.default(0),c=new at.default(0);if(typeof o=="string"||typeof o=="number"||typeof o=="bigint"){let[l,m]=wr(o.toString(),e.decimals);u=ie(l),c=ie(m)}u=u.mul(s),a=u.add(c)}super(a,s);this.logger=V(i||"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 he(this.token,this.raw.add(e.raw))}subtract(e){return this.token.equals(e.token)||this.logger.logWithError("sub token not equals"),new he(this.token,this.raw.sub(e.raw))}toSignificant(e=this.token.decimals,o,r=0){return super.toSignificant(e,o,r)}toFixed(e=this.token.decimals,o,r=0){return e>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(e,o,r)}toExact(e={groupSeparator:""}){return io.DP=this.token.decimals,new io(this.numerator.toString()).div(this.denominator.toString()).toFormat(e)}};var sn=require("@solana/spl-token"),ne={address:"So11111111111111111111111111111111111111112",programId:sn.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}},ae={address:"So11111111111111111111111111111111111111112",programId:sn.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}};var St=require("@solana/web3.js");var so=require("@solana/spl-token"),L=require("@solana/web3.js");function un({pubkey:n,isSigner:t=!1,isWritable:e=!0}){return{pubkey:n,isWritable:e,isSigner:t}}var Da=[un({pubkey:so.TOKEN_PROGRAM_ID,isWritable:!1}),un({pubkey:L.SystemProgram.programId,isWritable:!1}),un({pubkey:L.SYSVAR_RENT_PUBKEY,isWritable:!1})];function cn({publicKey:n,transformSol:t}){let e=uo(n.toString());if(e instanceof L.PublicKey)return t&&e.equals(st)?J:e;if(t&&e.toString()===st.toBase58())return J;if(typeof e=="string"){if(e===L.PublicKey.default.toBase58())return L.PublicKey.default;try{return new L.PublicKey(e)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function uo(n){try{return new L.PublicKey(n)}catch{return n}}var qa=new L.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Ua=new L.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Wa=new L.PublicKey("SysvarRent111111111111111111111111111111111"),Va=new L.PublicKey("SysvarC1ock11111111111111111111111111111111"),Ga=new L.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Ha=new L.PublicKey("Sysvar1nstructions1111111111111111111111111"),za=L.SystemProgram.programId,ja=new L.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Za=new L.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Xa=new L.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Ya=new L.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Ja=new L.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Qa=new L.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),$a=new L.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),es=new L.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),ts=new L.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),ns=new L.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),os=new L.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),J=new L.PublicKey("So11111111111111111111111111111111111111112"),st=L.PublicKey.default;function ve(n){return cn({publicKey:n,transformSol:!0})}var mn=class{constructor({mint:t,decimals:e,symbol:o,name:r,skipMint:i=!1,isToken2022:a=!1}){if(t===st.toBase58()||t instanceof St.PublicKey&&st.equals(t)){this.decimals=ae.decimals,this.symbol=ae.symbol,this.name=ae.name,this.mint=new St.PublicKey(ae.address),this.isToken2022=!1;return}this.decimals=e,this.symbol=o||t.toString().substring(0,6),this.name=r||t.toString().substring(0,6),this.mint=i?St.PublicKey.default:cn({publicKey:t}),this.isToken2022=a}equals(t){return this===t?!0:this.mint.equals(t.mint)}},_e=mn;_e.WSOL=new mn({...ae,mint:ae.address});var ln=class{constructor({decimals:t,symbol:e="UNKNOWN",name:o="UNKNOWN"}){this.decimals=t,this.symbol=e,this.name=o}equals(t){return this===t}},Bt=ln;Bt.SOL=new ln(ne);var mo=W(require("bn.js"));var co=new D(new mo.default(100)),ye=class extends D{toSignificant(t=5,e,o){return this.mul(co).toSignificant(t,e,o)}toFixed(t=2,e,o){return this.mul(co).toFixed(t,e,o)}};var ks=V("Ray_price");var gi=W(require("bn.js"));var Ge=9e15,Ie=1e9,dn="0123456789abcdef",It="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Mt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",pn={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Ge,maxE:Ge,crypto:!1},ho,Te,I=!0,Nt="[DecimalError] ",Ce=Nt+"Invalid argument: ",yo=Nt+"Precision limit exceeded",bo=Nt+"crypto unavailable",wo="[object Decimal]",Q=Math.floor,j=Math.pow,Tr=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Pr=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ar=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ko=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,me=1e7,C=7,xr=9007199254740991,vr=It.length-1,fn=Mt.length-1,k={toStringTag:wo};k.absoluteValue=k.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),S(n)};k.ceil=function(){return S(new this.constructor(this),this.e+1,2)};k.clampedTo=k.clamp=function(n,t){var e,o=this,r=o.constructor;if(n=new r(n),t=new r(t),!n.s||!t.s)return new r(NaN);if(n.gt(t))throw Error(Ce+t);return e=o.cmp(n),e<0?n:o.cmp(t)>0?t:new r(o)};k.comparedTo=k.cmp=function(n){var t,e,o,r,i=this,a=i.d,s=(n=new i.constructor(n)).d,u=i.s,c=n.s;if(!a||!s)return!u||!c?NaN:u!==c?u:a===s?0:!a^u<0?1:-1;if(!a[0]||!s[0])return a[0]?u:s[0]?-c:0;if(u!==c)return u;if(i.e!==n.e)return i.e>n.e^u<0?1:-1;for(o=a.length,r=s.length,t=0,e=o<r?o:r;t<e;++t)if(a[t]!==s[t])return a[t]>s[t]^u<0?1:-1;return o===r?0:o>r^u<0?1:-1};k.cosine=k.cos=function(){var n,t,e=this,o=e.constructor;return e.d?e.d[0]?(n=o.precision,t=o.rounding,o.precision=n+Math.max(e.e,e.sd())+C,o.rounding=1,e=Sr(o,xo(o,e)),o.precision=n,o.rounding=t,S(Te==2||Te==3?e.neg():e,n,t,!0)):new o(1):new o(NaN)};k.cubeRoot=k.cbrt=function(){var n,t,e,o,r,i,a,s,u,c,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(I=!1,i=l.s*j(l.s*l,1/3),!i||Math.abs(i)==1/0?(e=Y(l.d),n=l.e,(i=(n-e.length+1)%3)&&(e+=i==1||i==-2?"0":"00"),i=j(e,1/3),n=Q((n+1)/3)-(n%3==(n<0?-1:2)),i==1/0?e="5e"+n:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+n),o=new m(e),o.s=l.s):o=new m(i.toString()),a=(n=m.precision)+3;;)if(s=o,u=s.times(s).times(s),c=u.plus(l),o=q(c.plus(l).times(s),c.plus(u),a+2,1),Y(s.d).slice(0,a)===(e=Y(o.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!r&&e=="4999"){if(!r&&(S(s,n+1,0),s.times(s).times(s).eq(l))){o=s;break}a+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(S(o,n+1,1),t=!o.times(o).times(o).eq(l));break}return I=!0,S(o,n,m.rounding,t)};k.decimalPlaces=k.dp=function(){var n,t=this.d,e=NaN;if(t){if(n=t.length-1,e=(n-Q(this.e/C))*C,n=t[n],n)for(;n%10==0;n/=10)e--;e<0&&(e=0)}return e};k.dividedBy=k.div=function(n){return q(this,new this.constructor(n))};k.dividedToIntegerBy=k.divToInt=function(n){var t=this,e=t.constructor;return S(q(t,new e(n),0,1,1),e.precision,e.rounding)};k.equals=k.eq=function(n){return this.cmp(n)===0};k.floor=function(){return S(new this.constructor(this),this.e+1,3)};k.greaterThan=k.gt=function(n){return this.cmp(n)>0};k.greaterThanOrEqualTo=k.gte=function(n){var t=this.cmp(n);return t==1||t===0};k.hyperbolicCosine=k.cosh=function(){var n,t,e,o,r,i=this,a=i.constructor,s=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return s;e=a.precision,o=a.rounding,a.precision=e+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<32?(n=Math.ceil(r/3),t=(1/Lt(4,n)).toString()):(n=16,t="2.3283064365386962890625e-10"),i=He(a,1,i.times(t),new a(1),!0);for(var u,c=n,l=new a(8);c--;)u=i.times(i),i=s.minus(u.times(l.minus(u.times(l))));return S(i,a.precision=e,a.rounding=o,!0)};k.hyperbolicSine=k.sinh=function(){var n,t,e,o,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(t=i.precision,e=i.rounding,i.precision=t+Math.max(r.e,r.sd())+4,i.rounding=1,o=r.d.length,o<3)r=He(i,2,r,r,!0);else{n=1.4*Math.sqrt(o),n=n>16?16:n|0,r=r.times(1/Lt(5,n)),r=He(i,2,r,r,!0);for(var a,s=new i(5),u=new i(16),c=new i(20);n--;)a=r.times(r),r=r.times(s.plus(a.times(u.times(a).plus(c))))}return i.precision=t,i.rounding=e,S(r,t,e,!0)};k.hyperbolicTangent=k.tanh=function(){var n,t,e=this,o=e.constructor;return e.isFinite()?e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+7,o.rounding=1,q(e.sinh(),e.cosh(),o.precision=n,o.rounding=t)):new o(e.s)};k.inverseCosine=k.acos=function(){var n,t=this,e=t.constructor,o=t.abs().cmp(1),r=e.precision,i=e.rounding;return o!==-1?o===0?t.isNeg()?ce(e,r,i):new e(0):new e(NaN):t.isZero()?ce(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,t=t.asin(),n=ce(e,r+4,i).times(.5),e.precision=r,e.rounding=i,n.minus(t))};k.inverseHyperbolicCosine=k.acosh=function(){var n,t,e=this,o=e.constructor;return e.lte(1)?new o(e.eq(1)?0:NaN):e.isFinite()?(n=o.precision,t=o.rounding,o.precision=n+Math.max(Math.abs(e.e),e.sd())+4,o.rounding=1,I=!1,e=e.times(e).minus(1).sqrt().plus(e),I=!0,o.precision=n,o.rounding=t,e.ln()):new o(e)};k.inverseHyperbolicSine=k.asinh=function(){var n,t,e=this,o=e.constructor;return!e.isFinite()||e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+2*Math.max(Math.abs(e.e),e.sd())+6,o.rounding=1,I=!1,e=e.times(e).plus(1).sqrt().plus(e),I=!0,o.precision=n,o.rounding=t,e.ln())};k.inverseHyperbolicTangent=k.atanh=function(){var n,t,e,o,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=i.precision,t=i.rounding,o=r.sd(),Math.max(o,n)<2*-r.e-1?S(new i(r),n,t,!0):(i.precision=e=o-r.e,r=q(r.plus(1),new i(1).minus(r),e+n,1),i.precision=n+4,i.rounding=1,r=r.ln(),i.precision=n,i.rounding=t,r.times(.5))):new i(NaN)};k.inverseSine=k.asin=function(){var n,t,e,o,r=this,i=r.constructor;return r.isZero()?new i(r):(t=r.abs().cmp(1),e=i.precision,o=i.rounding,t!==-1?t===0?(n=ce(i,e+4,o).times(.5),n.s=r.s,n):new i(NaN):(i.precision=e+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=o,r.times(2)))};k.inverseTangent=k.atan=function(){var n,t,e,o,r,i,a,s,u,c=this,l=c.constructor,m=l.precision,d=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&m+4<=fn)return a=ce(l,m+4,d).times(.25),a.s=c.s,a}else{if(!c.s)return new l(NaN);if(m+4<=fn)return a=ce(l,m+4,d).times(.5),a.s=c.s,a}for(l.precision=s=m+10,l.rounding=1,e=Math.min(28,s/C+2|0),n=e;n;--n)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(I=!1,t=Math.ceil(s/C),o=1,u=c.times(c),a=new l(c),r=c;n!==-1;)if(r=r.times(u),i=a.minus(r.div(o+=2)),r=r.times(u),a=i.plus(r.div(o+=2)),a.d[t]!==void 0)for(n=t;a.d[n]===i.d[n]&&n--;);return e&&(a=a.times(2<<e-1)),I=!0,S(a,l.precision=m,l.rounding=d,!0)};k.isFinite=function(){return!!this.d};k.isInteger=k.isInt=function(){return!!this.d&&Q(this.e/C)>this.d.length-2};k.isNaN=function(){return!this.s};k.isNegative=k.isNeg=function(){return this.s<0};k.isPositive=k.isPos=function(){return this.s>0};k.isZero=function(){return!!this.d&&this.d[0]===0};k.lessThan=k.lt=function(n){return this.cmp(n)<0};k.lessThanOrEqualTo=k.lte=function(n){return this.cmp(n)<1};k.logarithm=k.log=function(n){var t,e,o,r,i,a,s,u,c=this,l=c.constructor,m=l.precision,d=l.rounding,p=5;if(n==null)n=new l(10),t=!0;else{if(n=new l(n),e=n.d,n.s<0||!e||!e[0]||n.eq(1))return new l(NaN);t=n.eq(10)}if(e=c.d,c.s<0||!e||!e[0]||c.eq(1))return new l(e&&!e[0]?-1/0:c.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)i=!0;else{for(r=e[0];r%10===0;)r/=10;i=r!==1}if(I=!1,s=m+p,a=Be(c,s),o=t?Kt(l,s+10):Be(n,s),u=q(a,o,s,1),ut(u.d,r=m,d))do if(s+=10,a=Be(c,s),o=t?Kt(l,s+10):Be(n,s),u=q(a,o,s,1),!i){+Y(u.d).slice(r+1,r+15)+1==1e14&&(u=S(u,m+1,0));break}while(ut(u.d,r+=10,d));return I=!0,S(u,m,d)};k.minus=k.sub=function(n){var t,e,o,r,i,a,s,u,c,l,m,d,p=this,h=p.constructor;if(n=new h(n),!p.d||!n.d)return!p.s||!n.s?n=new h(NaN):p.d?n.s=-n.s:n=new h(n.d||p.s!==n.s?p:NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(c=p.d,d=n.d,s=h.precision,u=h.rounding,!c[0]||!d[0]){if(d[0])n.s=-n.s;else if(c[0])n=new h(p);else return new h(u===3?-0:0);return I?S(n,s,u):n}if(e=Q(n.e/C),l=Q(p.e/C),c=c.slice(),i=l-e,i){for(m=i<0,m?(t=c,i=-i,a=d.length):(t=d,e=l,a=c.length),o=Math.max(Math.ceil(s/C),a)+2,i>o&&(i=o,t.length=1),t.reverse(),o=i;o--;)t.push(0);t.reverse()}else{for(o=c.length,a=d.length,m=o<a,m&&(a=o),o=0;o<a;o++)if(c[o]!=d[o]){m=c[o]<d[o];break}i=0}for(m&&(t=c,c=d,d=t,n.s=-n.s),a=c.length,o=d.length-a;o>0;--o)c[a++]=0;for(o=d.length;o>i;){if(c[--o]<d[o]){for(r=o;r&&c[--r]===0;)c[r]=me-1;--c[r],c[o]+=me}c[o]-=d[o]}for(;c[--a]===0;)c.pop();for(;c[0]===0;c.shift())--e;return c[0]?(n.d=c,n.e=Rt(c,e),I?S(n,s,u):n):new h(u===3?-0:0)};k.modulo=k.mod=function(n){var t,e=this,o=e.constructor;return n=new o(n),!e.d||!n.s||n.d&&!n.d[0]?new o(NaN):!n.d||e.d&&!e.d[0]?S(new o(e),o.precision,o.rounding):(I=!1,o.modulo==9?(t=q(e,n.abs(),0,3,1),t.s*=n.s):t=q(e,n,0,o.modulo,1),t=t.times(n),I=!0,e.minus(t))};k.naturalExponential=k.exp=function(){return gn(this)};k.naturalLogarithm=k.ln=function(){return Be(this)};k.negated=k.neg=function(){var n=new this.constructor(this);return n.s=-n.s,S(n)};k.plus=k.add=function(n){var t,e,o,r,i,a,s,u,c,l,m=this,d=m.constructor;if(n=new d(n),!m.d||!n.d)return!m.s||!n.s?n=new d(NaN):m.d||(n=new d(n.d||m.s===n.s?m:NaN)),n;if(m.s!=n.s)return n.s=-n.s,m.minus(n);if(c=m.d,l=n.d,s=d.precision,u=d.rounding,!c[0]||!l[0])return l[0]||(n=new d(m)),I?S(n,s,u):n;if(i=Q(m.e/C),o=Q(n.e/C),c=c.slice(),r=i-o,r){for(r<0?(e=c,r=-r,a=l.length):(e=l,o=i,a=c.length),i=Math.ceil(s/C),a=i>a?i+1:a+1,r>a&&(r=a,e.length=1),e.reverse();r--;)e.push(0);e.reverse()}for(a=c.length,r=l.length,a-r<0&&(r=a,e=l,l=c,c=e),t=0;r;)t=(c[--r]=c[r]+l[r]+t)/me|0,c[r]%=me;for(t&&(c.unshift(t),++o),a=c.length;c[--a]==0;)c.pop();return n.d=c,n.e=Rt(c,o),I?S(n,s,u):n};k.precision=k.sd=function(n){var t,e=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(Ce+n);return e.d?(t=_o(e.d),n&&e.e+1>t&&(t=e.e+1)):t=NaN,t};k.round=function(){var n=this,t=n.constructor;return S(new t(n),n.e+1,t.rounding)};k.sine=k.sin=function(){var n,t,e=this,o=e.constructor;return e.isFinite()?e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+Math.max(e.e,e.sd())+C,o.rounding=1,e=Cr(o,xo(o,e)),o.precision=n,o.rounding=t,S(Te>2?e.neg():e,n,t,!0)):new o(NaN)};k.squareRoot=k.sqrt=function(){var n,t,e,o,r,i,a=this,s=a.d,u=a.e,c=a.s,l=a.constructor;if(c!==1||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?a:1/0);for(I=!1,c=Math.sqrt(+a),c==0||c==1/0?(t=Y(s),(t.length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=Q((u+1)/2)-(u<0||u%2),c==1/0?t="5e"+u:(t=c.toExponential(),t=t.slice(0,t.indexOf("e")+1)+u),o=new l(t)):o=new l(c.toString()),e=(u=l.precision)+3;;)if(i=o,o=i.plus(q(a,i,e+2,1)).times(.5),Y(i.d).slice(0,e)===(t=Y(o.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!r&&t=="4999"){if(!r&&(S(i,u+1,0),i.times(i).eq(a))){o=i;break}e+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(S(o,u+1,1),n=!o.times(o).eq(a));break}return I=!0,S(o,u,l.rounding,n)};k.tangent=k.tan=function(){var n,t,e=this,o=e.constructor;return e.isFinite()?e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+10,o.rounding=1,e=e.sin(),e.s=1,e=q(e,new o(1).minus(e.times(e)).sqrt(),n+10,0),o.precision=n,o.rounding=t,S(Te==2||Te==4?e.neg():e,n,t,!0)):new o(NaN)};k.times=k.mul=function(n){var t,e,o,r,i,a,s,u,c,l=this,m=l.constructor,d=l.d,p=(n=new m(n)).d;if(n.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?n.s/0:n.s*0);for(e=Q(l.e/C)+Q(n.e/C),u=d.length,c=p.length,u<c&&(i=d,d=p,p=i,a=u,u=c,c=a),i=[],a=u+c,o=a;o--;)i.push(0);for(o=c;--o>=0;){for(t=0,r=u+o;r>o;)s=i[r]+p[o]*d[r-o-1]+t,i[r--]=s%me|0,t=s/me|0;i[r]=(i[r]+t)%me|0}for(;!i[--a];)i.pop();return t?++e:i.shift(),n.d=i,n.e=Rt(i,e),I?S(n,m.precision,m.rounding):n};k.toBinary=function(n,t){return yn(this,2,n,t)};k.toDecimalPlaces=k.toDP=function(n,t){var e=this,o=e.constructor;return e=new o(e),n===void 0?e:(oe(n,0,Ie),t===void 0?t=o.rounding:oe(t,0,8),S(e,n+e.e+1,t))};k.toExponential=function(n,t){var e,o=this,r=o.constructor;return n===void 0?e=be(o,!0):(oe(n,0,Ie),t===void 0?t=r.rounding:oe(t,0,8),o=S(new r(o),n+1,t),e=be(o,!0,n+1)),o.isNeg()&&!o.isZero()?"-"+e:e};k.toFixed=function(n,t){var e,o,r=this,i=r.constructor;return n===void 0?e=be(r):(oe(n,0,Ie),t===void 0?t=i.rounding:oe(t,0,8),o=S(new i(r),n+r.e+1,t),e=be(o,!1,n+o.e+1)),r.isNeg()&&!r.isZero()?"-"+e:e};k.toFraction=function(n){var t,e,o,r,i,a,s,u,c,l,m,d,p=this,h=p.d,f=p.constructor;if(!h)return new f(p);if(c=e=new f(1),o=u=new f(0),t=new f(o),i=t.e=_o(h)-p.e-1,a=i%C,t.d[0]=j(10,a<0?C+a:a),n==null)n=i>0?t:c;else{if(s=new f(n),!s.isInt()||s.lt(c))throw Error(Ce+s);n=s.gt(t)?i>0?t:c:s}for(I=!1,s=new f(Y(h)),l=f.precision,f.precision=i=h.length*C*2;m=q(s,t,0,1,1),r=e.plus(m.times(o)),r.cmp(n)!=1;)e=o,o=r,r=c,c=u.plus(m.times(r)),u=r,r=t,t=s.minus(m.times(r)),s=r;return r=q(n.minus(e),o,0,1,1),u=u.plus(r.times(c)),e=e.plus(r.times(o)),u.s=c.s=p.s,d=q(c,o,i,1).minus(p).abs().cmp(q(u,e,i,1).minus(p).abs())<1?[c,o]:[u,e],f.precision=l,I=!0,d};k.toHexadecimal=k.toHex=function(n,t){return yn(this,16,n,t)};k.toNearest=function(n,t){var e=this,o=e.constructor;if(e=new o(e),n==null){if(!e.d)return e;n=new o(1),t=o.rounding}else{if(n=new o(n),t===void 0?t=o.rounding:oe(t,0,8),!e.d)return n.s?e:n;if(!n.d)return n.s&&(n.s=e.s),n}return n.d[0]?(I=!1,e=q(e,n,0,t,1).times(n),I=!0,S(e)):(n.s=e.s,e=n),e};k.toNumber=function(){return+this};k.toOctal=function(n,t){return yn(this,8,n,t)};k.toPower=k.pow=function(n){var t,e,o,r,i,a,s=this,u=s.constructor,c=+(n=new u(n));if(!s.d||!n.d||!s.d[0]||!n.d[0])return new u(j(+s,c));if(s=new u(s),s.eq(1))return s;if(o=u.precision,i=u.rounding,n.eq(1))return S(s,o,i);if(t=Q(n.e/C),t>=n.d.length-1&&(e=c<0?-c:c)<=xr)return r=To(u,s,e,o),n.s<0?new u(1).div(r):S(r,o,i);if(a=s.s,a<0){if(t<n.d.length-1)return new u(NaN);if((n.d[t]&1)==0&&(a=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=a,s}return e=j(+s,c),t=e==0||!isFinite(e)?Q(c*(Math.log("0."+Y(s.d))/Math.LN10+s.e+1)):new u(e+"").e,t>u.maxE+1||t<u.minE-1?new u(t>0?a/0:0):(I=!1,u.rounding=s.s=1,e=Math.min(12,(t+"").length),r=gn(n.times(Be(s,o+e)),o),r.d&&(r=S(r,o+5,1),ut(r.d,o,i)&&(t=o+10,r=S(gn(n.times(Be(s,t+e)),t),t+5,1),+Y(r.d).slice(o+1,o+15)+1==1e14&&(r=S(r,o+1,0)))),r.s=a,I=!0,u.rounding=i,S(r,o,i))};k.toPrecision=function(n,t){var e,o=this,r=o.constructor;return n===void 0?e=be(o,o.e<=r.toExpNeg||o.e>=r.toExpPos):(oe(n,1,Ie),t===void 0?t=r.rounding:oe(t,0,8),o=S(new r(o),n,t),e=be(o,n<=o.e||o.e<=r.toExpNeg,n)),o.isNeg()&&!o.isZero()?"-"+e:e};k.toSignificantDigits=k.toSD=function(n,t){var e=this,o=e.constructor;return n===void 0?(n=o.precision,t=o.rounding):(oe(n,1,Ie),t===void 0?t=o.rounding:oe(t,0,8)),S(new o(e),n,t)};k.toString=function(){var n=this,t=n.constructor,e=be(n,n.e<=t.toExpNeg||n.e>=t.toExpPos);return n.isNeg()&&!n.isZero()?"-"+e:e};k.truncated=k.trunc=function(){return S(new this.constructor(this),this.e+1,1)};k.valueOf=k.toJSON=function(){var n=this,t=n.constructor,e=be(n,n.e<=t.toExpNeg||n.e>=t.toExpPos);return n.isNeg()?"-"+e:e};function Y(n){var t,e,o,r=n.length-1,i="",a=n[0];if(r>0){for(i+=a,t=1;t<r;t++)o=n[t]+"",e=C-o.length,e&&(i+=Se(e)),i+=o;a=n[t],o=a+"",e=C-o.length,e&&(i+=Se(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function oe(n,t,e){if(n!==~~n||n<t||n>e)throw Error(Ce+n)}function ut(n,t,e,o){var r,i,a,s;for(i=n[0];i>=10;i/=10)--t;return--t<0?(t+=C,r=0):(r=Math.ceil((t+1)/C),t%=C),i=j(10,C-t),s=n[r]%i|0,o==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),a=e<4&&s==99999||e>3&&s==49999||s==5e4||s==0):a=(e<4&&s+1==i||e>3&&s+1==i/2)&&(n[r+1]/i/100|0)==j(10,t-2)-1||(s==i/2||s==0)&&(n[r+1]/i/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),a=(o||e<4)&&s==9999||!o&&e>3&&s==4999):a=((o||e<4)&&s+1==i||!o&&e>3&&s+1==i/2)&&(n[r+1]/i/1e3|0)==j(10,t-3)-1,a}function Ct(n,t,e){for(var o,r=[0],i,a=0,s=n.length;a<s;){for(i=r.length;i--;)r[i]*=t;for(r[0]+=dn.indexOf(n.charAt(a++)),o=0;o<r.length;o++)r[o]>e-1&&(r[o+1]===void 0&&(r[o+1]=0),r[o+1]+=r[o]/e|0,r[o]%=e)}return r.reverse()}function Sr(n,t){var e,o,r;if(t.isZero())return t;o=t.d.length,o<32?(e=Math.ceil(o/3),r=(1/Lt(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),n.precision+=e,t=He(n,1,t.times(r),new n(1));for(var i=e;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return n.precision-=e,t}var q=function(){function n(o,r,i){var a,s=0,u=o.length;for(o=o.slice();u--;)a=o[u]*r+s,o[u]=a%i|0,s=a/i|0;return s&&o.unshift(s),o}function t(o,r,i,a){var s,u;if(i!=a)u=i>a?1:-1;else for(s=u=0;s<i;s++)if(o[s]!=r[s]){u=o[s]>r[s]?1:-1;break}return u}function e(o,r,i,a){for(var s=0;i--;)o[i]-=s,s=o[i]<r[i]?1:0,o[i]=s*a+o[i]-r[i];for(;!o[0]&&o.length>1;)o.shift()}return function(o,r,i,a,s,u){var c,l,m,d,p,h,f,w,y,b,g,_,P,x,v,B,M,O,K,z,H=o.constructor,Z=o.s==r.s?1:-1,E=o.d,R=r.d;if(!E||!E[0]||!R||!R[0])return new H(!o.s||!r.s||(E?R&&E[0]==R[0]:!R)?NaN:E&&E[0]==0||!R?Z*0:Z/0);for(u?(p=1,l=o.e-r.e):(u=me,p=C,l=Q(o.e/p)-Q(r.e/p)),K=R.length,M=E.length,y=new H(Z),b=y.d=[],m=0;R[m]==(E[m]||0);m++);if(R[m]>(E[m]||0)&&l--,i==null?(x=i=H.precision,a=H.rounding):s?x=i+(o.e-r.e)+1:x=i,x<0)b.push(1),h=!0;else{if(x=x/p+2|0,m=0,K==1){for(d=0,R=R[0],x++;(m<M||d)&&x--;m++)v=d*u+(E[m]||0),b[m]=v/R|0,d=v%R|0;h=d||m<M}else{for(d=u/(R[0]+1)|0,d>1&&(R=n(R,d,u),E=n(E,d,u),K=R.length,M=E.length),B=K,g=E.slice(0,K),_=g.length;_<K;)g[_++]=0;z=R.slice(),z.unshift(0),O=R[0],R[1]>=u/2&&++O;do d=0,c=t(R,g,K,_),c<0?(P=g[0],K!=_&&(P=P*u+(g[1]||0)),d=P/O|0,d>1?(d>=u&&(d=u-1),f=n(R,d,u),w=f.length,_=g.length,c=t(f,g,w,_),c==1&&(d--,e(f,K<w?z:R,w,u))):(d==0&&(c=d=1),f=R.slice()),w=f.length,w<_&&f.unshift(0),e(g,f,_,u),c==-1&&(_=g.length,c=t(R,g,K,_),c<1&&(d++,e(g,K<_?z:R,_,u))),_=g.length):c===0&&(d++,g=[0]),b[m++]=d,c&&g[0]?g[_++]=E[B]||0:(g=[E[B]],_=1);while((B++<M||g[0]!==void 0)&&x--);h=g[0]!==void 0}b[0]||b.shift()}if(p==1)y.e=l,ho=h;else{for(m=1,d=b[0];d>=10;d/=10)m++;y.e=m+l*p-1,S(y,s?i+y.e+1:i,a,h)}return y}}();function S(n,t,e,o){var r,i,a,s,u,c,l,m,d,p=n.constructor;e:if(t!=null){if(m=n.d,!m)return n;for(r=1,s=m[0];s>=10;s/=10)r++;if(i=t-r,i<0)i+=C,a=t,l=m[d=0],u=l/j(10,r-a-1)%10|0;else if(d=Math.ceil((i+1)/C),s=m.length,d>=s)if(o){for(;s++<=d;)m.push(0);l=u=0,r=1,i%=C,a=i-C+1}else break e;else{for(l=s=m[d],r=1;s>=10;s/=10)r++;i%=C,a=i-C+r,u=a<0?0:l/j(10,r-a-1)%10|0}if(o=o||t<0||m[d+1]!==void 0||(a<0?l:l%j(10,r-a-1)),c=e<4?(u||o)&&(e==0||e==(n.s<0?3:2)):u>5||u==5&&(e==4||o||e==6&&(i>0?a>0?l/j(10,r-a):0:m[d-1])%10&1||e==(n.s<0?8:7)),t<1||!m[0])return m.length=0,c?(t-=n.e+1,m[0]=j(10,(C-t%C)%C),n.e=-t||0):m[0]=n.e=0,n;if(i==0?(m.length=d,s=1,d--):(m.length=d+1,s=j(10,C-i),m[d]=a>0?(l/j(10,r-a)%j(10,a)|0)*s:0),c)for(;;)if(d==0){for(i=1,a=m[0];a>=10;a/=10)i++;for(a=m[0]+=s,s=1;a>=10;a/=10)s++;i!=s&&(n.e++,m[0]==me&&(m[0]=1));break}else{if(m[d]+=s,m[d]!=me)break;m[d--]=0,s=1}for(i=m.length;m[--i]===0;)m.pop()}return I&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function be(n,t,e){if(!n.isFinite())return Ao(n);var o,r=n.e,i=Y(n.d),a=i.length;return t?(e&&(o=e-a)>0?i=i.charAt(0)+"."+i.slice(1)+Se(o):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(n.e<0?"e":"e+")+n.e):r<0?(i="0."+Se(-r-1)+i,e&&(o=e-a)>0&&(i+=Se(o))):r>=a?(i+=Se(r+1-a),e&&(o=e-r-1)>0&&(i=i+"."+Se(o))):((o=r+1)<a&&(i=i.slice(0,o)+"."+i.slice(o)),e&&(o=e-a)>0&&(r+1===a&&(i+="."),i+=Se(o))),i}function Rt(n,t){var e=n[0];for(t*=C;e>=10;e/=10)t++;return t}function Kt(n,t,e){if(t>vr)throw I=!0,e&&(n.precision=e),Error(yo);return S(new n(It),t,1,!0)}function ce(n,t,e){if(t>fn)throw Error(yo);return S(new n(Mt),t,e,!0)}function _o(n){var t=n.length-1,e=t*C+1;if(t=n[t],t){for(;t%10==0;t/=10)e--;for(t=n[0];t>=10;t/=10)e++}return e}function Se(n){for(var t="";n--;)t+="0";return t}function To(n,t,e,o){var r,i=new n(1),a=Math.ceil(o/C+4);for(I=!1;;){if(e%2&&(i=i.times(t),fo(i.d,a)&&(r=!0)),e=Q(e/2),e===0){e=i.d.length-1,r&&i.d[e]===0&&++i.d[e];break}t=t.times(t),fo(t.d,a)}return I=!0,i}function po(n){return n.d[n.d.length-1]&1}function Po(n,t,e){for(var o,r=new n(t[0]),i=0;++i<t.length;)if(o=new n(t[i]),o.s)r[e](o)&&(r=o);else{r=o;break}return r}function gn(n,t){var e,o,r,i,a,s,u,c=0,l=0,m=0,d=n.constructor,p=d.rounding,h=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:0/0);for(t==null?(I=!1,u=h):u=t,s=new d(.03125);n.e>-2;)n=n.times(s),m+=5;for(o=Math.log(j(2,m))/Math.LN10*2+5|0,u+=o,e=i=a=new d(1),d.precision=u;;){if(i=S(i.times(n),u,1),e=e.times(++l),s=a.plus(q(i,e,u,1)),Y(s.d).slice(0,u)===Y(a.d).slice(0,u)){for(r=m;r--;)a=S(a.times(a),u,1);if(t==null)if(c<3&&ut(a.d,u-o,p,c))d.precision=u+=10,e=i=s=new d(1),l=0,c++;else return S(a,d.precision=h,p,I=!0);else return d.precision=h,a}a=s}}function Be(n,t){var e,o,r,i,a,s,u,c,l,m,d,p=1,h=10,f=n,w=f.d,y=f.constructor,b=y.rounding,g=y.precision;if(f.s<0||!w||!w[0]||!f.e&&w[0]==1&&w.length==1)return new y(w&&!w[0]?-1/0:f.s!=1?NaN:w?0:f);if(t==null?(I=!1,l=g):l=t,y.precision=l+=h,e=Y(w),o=e.charAt(0),Math.abs(i=f.e)<15e14){for(;o<7&&o!=1||o==1&&e.charAt(1)>3;)f=f.times(n),e=Y(f.d),o=e.charAt(0),p++;i=f.e,o>1?(f=new y("0."+e),i++):f=new y(o+"."+e.slice(1))}else return c=Kt(y,l+2,g).times(i+""),f=Be(new y(o+"."+e.slice(1)),l-h).plus(c),y.precision=g,t==null?S(f,g,b,I=!0):f;for(m=f,u=a=f=q(f.minus(1),f.plus(1),l,1),d=S(f.times(f),l,1),r=3;;){if(a=S(a.times(d),l,1),c=u.plus(q(a,new y(r),l,1)),Y(c.d).slice(0,l)===Y(u.d).slice(0,l))if(u=u.times(2),i!==0&&(u=u.plus(Kt(y,l+2,g).times(i+""))),u=q(u,new y(p),l,1),t==null)if(ut(u.d,l-h,b,s))y.precision=l+=h,c=a=f=q(m.minus(1),m.plus(1),l,1),d=S(f.times(f),l,1),r=s=1;else return S(u,y.precision=g,b,I=!0);else return y.precision=g,u;u=c,r+=2}}function Ao(n){return String(n.s*n.s/0)}function hn(n,t){var e,o,r;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(o=t.search(/e/i))>0?(e<0&&(e=o),e+=+t.slice(o+1),t=t.substring(0,o)):e<0&&(e=t.length),o=0;t.charCodeAt(o)===48;o++);for(r=t.length;t.charCodeAt(r-1)===48;--r);if(t=t.slice(o,r),t){if(r-=o,n.e=e=e-o-1,n.d=[],o=(e+1)%C,e<0&&(o+=C),o<r){for(o&&n.d.push(+t.slice(0,o)),r-=C;o<r;)n.d.push(+t.slice(o,o+=C));t=t.slice(o),o=C-t.length}else o-=r;for(;o--;)t+="0";n.d.push(+t),I&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function Br(n,t){var e,o,r,i,a,s,u,c,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),ko.test(t))return hn(n,t)}else if(t==="Infinity"||t==="NaN")return+t||(n.s=NaN),n.e=NaN,n.d=null,n;if(Pr.test(t))e=16,t=t.toLowerCase();else if(Tr.test(t))e=2;else if(Ar.test(t))e=8;else throw Error(Ce+t);for(i=t.search(/p/i),i>0?(u=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),a=i>=0,o=n.constructor,a&&(t=t.replace(".",""),s=t.length,i=s-i,r=To(o,new o(e),i,i*2)),c=Ct(t,e,me),l=c.length-1,i=l;c[i]===0;--i)c.pop();return i<0?new o(n.s*0):(n.e=Rt(c,l),n.d=c,I=!1,a&&(n=q(n,r,s*4)),u&&(n=n.times(Math.abs(u)<54?j(2,u):ct.pow(2,u))),I=!0,n)}function Cr(n,t){var e,o=t.d.length;if(o<3)return t.isZero()?t:He(n,2,t,t);e=1.4*Math.sqrt(o),e=e>16?16:e|0,t=t.times(1/Lt(5,e)),t=He(n,2,t,t);for(var r,i=new n(5),a=new n(16),s=new n(20);e--;)r=t.times(t),t=t.times(i.plus(r.times(a.times(r).minus(s))));return t}function He(n,t,e,o,r){var i,a,s,u,c=1,l=n.precision,m=Math.ceil(l/C);for(I=!1,u=e.times(e),s=new n(o);;){if(a=q(s.times(u),new n(t++*t++),l,1),s=r?o.plus(a):o.minus(a),o=q(a.times(u),new n(t++*t++),l,1),a=s.plus(o),a.d[m]!==void 0){for(i=m;a.d[i]===s.d[i]&&i--;);if(i==-1)break}i=s,s=o,o=a,a=i,c++}return I=!0,a.d.length=m+1,a}function Lt(n,t){for(var e=n;--t;)e*=n;return e}function xo(n,t){var e,o=t.s<0,r=ce(n,n.precision,1),i=r.times(.5);if(t=t.abs(),t.lte(i))return Te=o?4:1,t;if(e=t.divToInt(r),e.isZero())Te=o?3:2;else{if(t=t.minus(e.times(r)),t.lte(i))return Te=po(e)?o?2:3:o?4:1,t;Te=po(e)?o?1:4:o?3:2}return t.minus(r).abs()}function yn(n,t,e,o){var r,i,a,s,u,c,l,m,d,p=n.constructor,h=e!==void 0;if(h?(oe(e,1,Ie),o===void 0?o=p.rounding:oe(o,0,8)):(e=p.precision,o=p.rounding),!n.isFinite())l=Ao(n);else{for(l=be(n),a=l.indexOf("."),h?(r=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):r=t,a>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-a,d.d=Ct(be(d),10,r),d.e=d.d.length),m=Ct(l,10,r),i=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=h?"0p+0":"0";else{if(a<0?i--:(n=new p(n),n.d=m,n.e=i,n=q(n,d,e,o,0,r),m=n.d,i=n.e,c=ho),a=m[e],s=r/2,c=c||m[e+1]!==void 0,c=o<4?(a!==void 0||c)&&(o===0||o===(n.s<0?3:2)):a>s||a===s&&(o===4||c||o===6&&m[e-1]&1||o===(n.s<0?8:7)),m.length=e,c)for(;++m[--e]>r-1;)m[e]=0,e||(++i,m.unshift(1));for(u=m.length;!m[u-1];--u);for(a=0,l="";a<u;a++)l+=dn.charAt(m[a]);if(h){if(u>1)if(t==16||t==8){for(a=t==16?4:3,--u;u%a;u++)l+="0";for(m=Ct(l,r,t),u=m.length;!m[u-1];--u);for(a=1,l="1.";a<u;a++)l+=dn.charAt(m[a])}else l=l.charAt(0)+"."+l.slice(1);l=l+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)l="0"+l;l="0."+l}else if(++i>u)for(i-=u;i--;)l+="0";else i<u&&(l=l.slice(0,i)+"."+l.slice(i))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return n.s<0?"-"+l:l}function fo(n,t){if(n.length>t)return n.length=t,!0}function Ir(n){return new this(n).abs()}function Mr(n){return new this(n).acos()}function Kr(n){return new this(n).acosh()}function Nr(n,t){return new this(n).plus(t)}function Rr(n){return new this(n).asin()}function Lr(n){return new this(n).asinh()}function Or(n){return new this(n).atan()}function Er(n){return new this(n).atanh()}function Fr(n,t){n=new this(n),t=new this(t);var e,o=this.precision,r=this.rounding,i=o+4;return!n.s||!t.s?e=new this(NaN):!n.d&&!t.d?(e=ce(this,i,1).times(t.s>0?.25:.75),e.s=n.s):!t.d||n.isZero()?(e=t.s<0?ce(this,o,r):new this(0),e.s=n.s):!n.d||t.isZero()?(e=ce(this,i,1).times(.5),e.s=n.s):t.s<0?(this.precision=i,this.rounding=1,e=this.atan(q(n,t,i,1)),t=ce(this,i,1),this.precision=o,this.rounding=r,e=n.s<0?e.minus(t):e.plus(t)):e=this.atan(q(n,t,i,1)),e}function Dr(n){return new this(n).cbrt()}function qr(n){return S(n=new this(n),n.e+1,2)}function Ur(n,t,e){return new this(n).clamp(t,e)}function Wr(n){if(!n||typeof n!="object")throw Error(Nt+"Object expected");var t,e,o,r=n.defaults===!0,i=["precision",1,Ie,"rounding",0,8,"toExpNeg",-Ge,0,"toExpPos",0,Ge,"maxE",0,Ge,"minE",-Ge,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(e=i[t],r&&(this[e]=pn[e]),(o=n[e])!==void 0)if(Q(o)===o&&o>=i[t+1]&&o<=i[t+2])this[e]=o;else throw Error(Ce+e+": "+o);if(e="crypto",r&&(this[e]=pn[e]),(o=n[e])!==void 0)if(o===!0||o===!1||o===0||o===1)if(o)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(bo);else this[e]=!1;else throw Error(Ce+e+": "+o);return this}function Vr(n){return new this(n).cos()}function Gr(n){return new this(n).cosh()}function vo(n){var t,e,o;function r(i){var a,s,u,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,go(i)){c.s=i.s,I?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(u=typeof i,u==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(a=0,s=i;s>=10;s/=10)a++;I?a>r.maxE?(c.e=NaN,c.d=null):a<r.minE?(c.e=0,c.d=[0]):(c.e=a,c.d=[i]):(c.e=a,c.d=[i]);return}else if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return hn(c,i.toString())}else if(u!=="string")throw Error(Ce+i);return(s=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(s===43&&(i=i.slice(1)),c.s=1),ko.test(i)?hn(c,i):Br(c,i)}if(r.prototype=k,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Wr,r.clone=vo,r.isDecimal=go,r.abs=Ir,r.acos=Mr,r.acosh=Kr,r.add=Nr,r.asin=Rr,r.asinh=Lr,r.atan=Or,r.atanh=Er,r.atan2=Fr,r.cbrt=Dr,r.ceil=qr,r.clamp=Ur,r.cos=Vr,r.cosh=Gr,r.div=Hr,r.exp=zr,r.floor=jr,r.hypot=Zr,r.ln=Xr,r.log=Yr,r.log10=Qr,r.log2=Jr,r.max=$r,r.min=ei,r.mod=ti,r.mul=ni,r.pow=oi,r.random=ri,r.round=ii,r.sign=ai,r.sin=si,r.sinh=ui,r.sqrt=ci,r.sub=mi,r.sum=li,r.tan=di,r.tanh=pi,r.trunc=fi,n===void 0&&(n={}),n&&n.defaults!==!0)for(o=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<o.length;)n.hasOwnProperty(e=o[t++])||(n[e]=this[e]);return r.config(n),r}function Hr(n,t){return new this(n).div(t)}function zr(n){return new this(n).exp()}function jr(n){return S(n=new this(n),n.e+1,3)}function Zr(){var n,t,e=new this(0);for(I=!1,n=0;n<arguments.length;)if(t=new this(arguments[n++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return I=!0,new this(1/0);e=t}return I=!0,e.sqrt()}function go(n){return n instanceof ct||n&&n.toStringTag===wo||!1}function Xr(n){return new this(n).ln()}function Yr(n,t){return new this(n).log(t)}function Jr(n){return new this(n).log(2)}function Qr(n){return new this(n).log(10)}function $r(){return Po(this,arguments,"lt")}function ei(){return Po(this,arguments,"gt")}function ti(n,t){return new this(n).mod(t)}function ni(n,t){return new this(n).mul(t)}function oi(n,t){return new this(n).pow(t)}function ri(n){var t,e,o,r,i=0,a=new this(1),s=[];if(n===void 0?n=this.precision:oe(n,1,Ie),o=Math.ceil(n/C),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(o));i<o;)r=t[i],r>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:s[i++]=r%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(o*=4);i<o;)r=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(t,i):(s.push(r%1e7),i+=4);i=o/4}else throw Error(bo);else for(;i<o;)s[i++]=Math.random()*1e7|0;for(o=s[--i],n%=C,o&&n&&(r=j(10,C-n),s[i]=(o/r|0)*r);s[i]===0;i--)s.pop();if(i<0)e=0,s=[0];else{for(e=-1;s[0]===0;e-=C)s.shift();for(o=1,r=s[0];r>=10;r/=10)o++;o<C&&(e-=C-o)}return a.e=e,a.d=s,a}function ii(n){return S(n=new this(n),n.e+1,this.rounding)}function ai(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function si(n){return new this(n).sin()}function ui(n){return new this(n).sinh()}function ci(n){return new this(n).sqrt()}function mi(n,t){return new this(n).sub(t)}function li(){var n=0,t=arguments,e=new this(t[n]);for(I=!1;e.s&&++n<t.length;)e=e.plus(t[n]);return I=!0,S(e,this.precision,this.rounding)}function di(n){return new this(n).tan()}function pi(n){return new this(n).tanh()}function fi(n){return S(n=new this(n),n.e+1,1)}k[Symbol.for("nodejs.util.inspect.custom")]=k.toString;k[Symbol.toStringTag]="Decimal";var ct=k.constructor=vo(pn);It=new ct(It);Mt=new ct(Mt);var te=ct;var F=require("@solana/web3.js"),Mo=W(require("axios"));var U={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",CpmmInitUserLiquidity:"CpmmInitUserLiquidity",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmOracleSwapBaseIn:"CpmmOracleSwapBaseIn"};var $=require("@solana/web3.js"),Bo=require("@solana/spl-token");var So=V("Gfx_txUtil"),Co=1644;function Ot(n){let t=[],e=[];return n.microLamports&&(t.push($.ComputeBudgetProgram.setComputeUnitPrice({microLamports:n.microLamports})),e.push(U.SetComputeUnitPrice)),n.units&&(t.push($.ComputeBudgetProgram.setComputeUnitLimit({units:n.units})),e.push(U.SetComputeUnitLimit)),{instructions:t,instructionTypes:e}}async function ze(n,t){var o,r;let e=t!=null?t:"confirmed";try{return((r=await((o=n.getLatestBlockhash)==null?void 0:o.call(n,{commitment:e})))==null?void 0:r.blockhash)||(await n.getRecentBlockhash(e)).blockhash}catch{return(await n.getRecentBlockhash(e)).blockhash}}function hi(n,t){n.length<1&&So.logWithError(`no instructions provided: ${n.toString()}`),t.length<1&&So.logWithError(`no signers provided:, ${t.toString()}`);let e=new $.Transaction;e.recentBlockhash="11111111111111111111111111111111",e.feePayer=t[0],e.add(...n);try{return e.serialize({verifySignatures:!1}).toString("base64").length<Co}catch{return!1}}function le(n,t){let[e,o]=$.PublicKey.findProgramAddressSync(n,t);return{publicKey:e,nonce:o}}function mt({instructions:n,payer:t,signers:e}){return hi(n,[t,...e])}function lt({instructions:n,payer:t,lookupTableAddressAccount:e,recentBlockhash:o=$.Keypair.generate().publicKey.toString()}){let i=new $.TransactionMessage({payerKey:t,recentBlockhash:o,instructions:n}).compileToV0Message(Object.values(e!=null?e:{}));try{return Buffer.from(new $.VersionedTransaction(i).serialize()).toString("base64").length<Co}catch{return!1}}var yi=n=>Buffer.isBuffer(n)?n:n instanceof Uint8Array?Buffer.from(n.buffer,n.byteOffset,n.byteLength):Buffer.from(n);function Ee(n){let t=[];return n.forEach(e=>{e instanceof $.Transaction&&(e.recentBlockhash||(e.recentBlockhash=Bo.TOKEN_PROGRAM_ID.toBase58()),e.feePayer||(e.feePayer=$.Keypair.generate().publicKey));let o=e.serialize({requireAllSignatures:!1,verifySignatures:!1});e instanceof $.VersionedTransaction&&(o=yi(o));let r=o.toString("base64");t.push(r)}),console.log("simulate tx string:",t),t}var Ke=require("@solana/web3.js");var kn=require("@solana/web3.js"),Me=require("@solana/spl-token");var bn=V("Gfx_accountInfo_util");async function _n(n,t,e){let{batchRequest:o,commitment:r="confirmed",chunkCount:i=100}={batchRequest:!1,...e},a=wn(t,i),s=new Array(a.length).fill([]);if(o){let u=a.map(m=>{let d=n._buildArgs([m.map(p=>p.toBase58())],r,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=wn(u,10);s=(await(await Promise.all(c.map(async m=>await n._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&bn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:h,lamports:f,owner:w,rentEpoch:y}=d;return p.length!==2&&p[1]!=="base64"&&bn.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:h,lamports:f,owner:new kn.PublicKey(w),rentEpoch:y}}return null})))}else try{s=await Promise.all(a.map(u=>n.getMultipleAccountsInfo(u,r)))}catch(u){u instanceof Error&&bn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return s.flat()}async function bi(n,t,e){let o=await _n(n,t.map(r=>r.pubkey),e);return t.map((r,i)=>({...r,accountInfo:o[i]}))}async function Io({connection:n,mints:t,config:e}){var i,a,s;if(t.length===0)return{};let o=await bi(n,t.map(u=>({pubkey:ve(u)})),e),r={};for(let u of o){if(!u.accountInfo||u.accountInfo.data.length<Me.MINT_SIZE){console.log("invalid mint account",u.pubkey.toBase58());continue}let c=(0,Me.unpackMint)(u.pubkey,u.accountInfo,(i=u.accountInfo)==null?void 0:i.owner);r[u.pubkey.toString()]={...c,programId:((a=u.accountInfo)==null?void 0:a.owner)||Me.TOKEN_PROGRAM_ID,feeConfig:(s=(0,Me.getTransferFeeConfig)(c))!=null?s:void 0}}return r[kn.PublicKey.default.toBase58()]=r[J.toBase58()],r}async function Tn({connection:n,address:t}){let e=await _n(n,[...new Set(t.map(r=>r.toString()))].map(r=>new Ke.PublicKey(r))),o={};for(let r=0;r<t.length;r++){let i=e[r],a=t[r];if(!i)continue;let s=new Ke.AddressLookupTableAccount({key:a,state:Ke.AddressLookupTableAccount.deserialize(new Uint8Array(i.data))});o[a.toString()]=s,Et[a.toString()]=s}return o}var Et={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new Ke.AddressLookupTableAccount({key:new Ke.PublicKey("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:Ke.AddressLookupTableAccount.deserialize(new Uint8Array(Buffer.from("AQAAAP//////////d49+DAAAAAAAAQZMWvw7GUNJdaccNBVnb57OKakxL2BHLYvhRwVILRsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkG3fbh7nWP3hhCXbzkbM3athr8TYO5DSf+vfko2KGL/AVKU1D4XciC1hSlVnJ4iilt3x6rq9CmBniISTL07vagBqfVFxksXFEhjMlMPUrxf1ja7gibof1E49vZigAAAAAGp9UXGMd0yShWY5hpHV62i164o5tLbVxzVVshAAAAAIyXJY9OJInxuz0QKRSODYMLWhOZ2v8QhASOe9jb6fhZC3BlsePRfEU4nVJ/awTDzVi4bHMaoP21SbbRvAP4KUbIScv+6Yw2LHF/6K0ZjUPibbSWXCirYPGuuVl7zT789IUPLW4CpHr4JNCatp3ELXDLKMv6JJ+37le50lbBJ2LvDQdRqCgtphMF/imcN7mY5YRx2xE1A3MQ+L4QRaYK9u4GRfZP3LsAd00a+IkCpA22UNQMKdq5BFbJuwuOLqc8zxCTDlqxBG8J0HcxtfogQHDK06ukzfaXiNDKAob1MqBHS9lJxDYCwz8gd5DtFqNSTKG5l1zxIaKpDP/sffi2is1H9aKveyXSu5StXElYRl9SD5As0DHE4N0GLnf84/siiKXVyp4Ez121kLcUui/jLLFZEz/BwZK3Ilf9B9OcsEAeDMKAy2vjGSxQODgBz0QwGA+eP4ZjIjrIAQaXENv31QfLlOdXSRCkaybRniDHF4C8YcwhcvsqrOVuTP4B2Na+9wLdtrB31uz2rtlFI5kahdsnp/d1SrASDInYCtTYtdoke4kX+hoKWcEWM4Tle8pTUkUVv4BxS6fje/EzKBE4Qu9N9LMnrw/JNO0hqMVB4rk/2ou4AB1loQ7FZoPwut2o4KZB+0p9xnbrQKw038qjpHar+PyDwvxBRcu5hpHw3dguezeWv+IwvgW5icu8EGkhGa9AkFPPJT7VMSFb8xowveU=","base64")))})};var Ft=class{constructor(t){this.instructions=[];this.endInstructions=[];this.lookupTableAddress=[];this.signers=[];this.instructionTypes=[];this.endInstructionTypes=[];this.connection=t.connection,this.feePayer=t.feePayer,this.signAllTransactions=t.signAllTransactions,this.owner=t.owner,this.cluster=t.cluster,this.blockhashCommitment=t.blockhashCommitment,this.api=t.api}get AllTxData(){return{instructions:this.instructions,endInstructions:this.endInstructions,signers:this.signers,instructionTypes:this.instructionTypes,endInstructionTypes:this.endInstructionTypes,lookupTableAddress:this.lookupTableAddress}}get allInstructions(){return[...this.instructions,...this.endInstructions]}async getComputeBudgetConfig(){var o;let t=(await Mo.default.get(`https://solanacompass.com/api/fees?cacheFreshTime=${3e5}`)).data,{avg:e}=(o=t==null?void 0:t[15])!=null?o