UNPKG

goosefx-amm-sdk

Version:

SDK for the GooseFx AMM

1 lines 238 kB
import Qi from"axios";import{get as tn,set as zn}from"lodash";var br=(r=>(r[r.Error=0]="Error",r[r.Warning=1]="Warning",r[r.Info=2]="Info",r[r.Debug=3]="Debug",r))(br||{}),nn=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}},on={},jn={};function U(n){let t=tn(on,n);if(!t){let e=tn(jn,n);t=new nn({name:n,logLevel:e}),zn(on,n,t)}return t}function $a(n,t){zn(jn,n,t);let e=tn(on,n);e&&(e.level=t)}import{PublicKey as Mr}from"@solana/web3.js";import Kr from"bn.js";import xr from"big.js";import Se from"bn.js";import oe from"bn.js";var rn=(o=>(o[o.ROUND_DOWN=0]="ROUND_DOWN",o[o.ROUND_HALF_UP=1]="ROUND_HALF_UP",o[o.ROUND_UP=2]="ROUND_UP",o))(rn||{}),le=new oe(0),os=new oe(1),rs=new oe(2),is=new oe(3),as=new oe(5),ve=new oe(10),ss=new oe(100),us=new oe(1e3),cs=new oe(1e4),Zn=9007199254740991;function X(n){let t=U("Gfx_parseBigNumberish");if(n instanceof oe)return n;if(typeof n=="string"){if(n.match(/^-?[0-9]+$/))return new oe(n);t.logWithError(`invalid BigNumberish string: ${n}`)}return typeof n=="number"?(n%1&&t.logWithError(`BigNumberish number underflow: ${n}`),(n>=Zn||n<=-Zn)&&t.logWithError(`BigNumberish number overflow: ${n}`),new oe(String(n))):typeof n=="bigint"?new oe(n.toString()):(t.error(`invalid BigNumberish value: ${n}`),new oe(0))}function an(n){return ve.pow(X(n))}import wr from"toformat";var kr=wr,$e=kr;import xt from"big.js";import _r from"bn.js";import Tr from"decimal.js-light";var At=U("module/fraction"),sn=$e(xt),et=$e(Tr),Pr={[0]:et.ROUND_DOWN,[1]:et.ROUND_HALF_UP,[2]:et.ROUND_UP},Ar={[0]:xt.roundDown,[1]:xt.roundHalfUp,[2]:xt.roundUp},K=class{constructor(t,e=new _r(1)){this.numerator=X(t),this.denominator=X(e)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new K(this.denominator,this.numerator)}add(t){let e=t instanceof K?t:new K(X(t));return this.denominator.eq(e.denominator)?new K(this.numerator.add(e.numerator),this.denominator):new K(this.numerator.mul(e.denominator).add(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}sub(t){let e=t instanceof K?t:new K(X(t));return this.denominator.eq(e.denominator)?new K(this.numerator.sub(e.numerator),this.denominator):new K(this.numerator.mul(e.denominator).sub(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}mul(t){let e=t instanceof K?t:new K(X(t));return new K(this.numerator.mul(e.numerator),this.denominator.mul(e.denominator))}div(t){let e=t instanceof K?t:new K(X(t));return new K(this.numerator.mul(e.denominator),this.denominator.mul(e.numerator))}toSignificant(t,e={groupSeparator:""},o=1){Number.isInteger(t)||At.logWithError(`${t} is not an integer.`),t<=0&&At.logWithError(`${t} is not positive.`),et.set({precision:t+1,rounding:Pr[o]});let r=new et(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)||At.logWithError(`${t} is not an integer.`),t<0&&At.logWithError(`${t} is negative.`),sn.DP=t,sn.RM=Ar[o]||1,new sn(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)}isZero(){return this.numerator.isZero()}};var vr=U("Gfx_amount"),vt=$e(xr);function Xn(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")):vr.logWithError(`invalid number string, num: ${n}`)}else e=n;return[e,o.slice(0,t)||o]}var re=class extends K{constructor(e,o,r=!0,i){let a=new Se(0),s=ve.pow(new Se(e.decimals));if(r)a=X(o);else{let u=new Se(0),c=new Se(0);if(typeof o=="string"||typeof o=="number"||typeof o=="bigint"){let[m,l]=Xn(o.toString(),e.decimals);u=X(m),c=X(l)}u=u.mul(s),a=u.add(c)}super(a,s);this.logger=U(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 re(this.token,this.raw.add(e.raw))}subtract(e){return this.token.equals(e.token)||this.logger.logWithError("sub token not equals"),new re(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 vt.DP=this.token.decimals,new vt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e)}},Ee=class extends K{constructor(e,o,r=!0,i){let a=new Se(0),s=ve.pow(new Se(e.decimals));if(r)a=X(o);else{let u=new Se(0),c=new Se(0);if(typeof o=="string"||typeof o=="number"||typeof o=="bigint"){let[m,l]=Xn(o.toString(),e.decimals);u=X(m),c=X(l)}u=u.mul(s),a=u.add(c)}super(a,s);this.logger=U(i||"TokenAmount"),this.currency=e}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(e){return this.currency.equals(e.currency)||this.logger.logWithError("gt currency not equals"),this.raw.gt(e.raw)}lt(e){return this.currency.equals(e.currency)||this.logger.logWithError("lt currency not equals"),this.raw.lt(e.raw)}add(e){return this.currency.equals(e.currency)||this.logger.logWithError("add currency not equals"),new Ee(this.currency,this.raw.add(e.raw))}sub(e){return this.currency.equals(e.currency)||this.logger.logWithError("sub currency not equals"),new Ee(this.currency,this.raw.sub(e.raw))}toSignificant(e=this.currency.decimals,o,r=0){return super.toSignificant(e,o,r)}toFixed(e=this.currency.decimals,o,r=0){return e>this.currency.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(e,o,r)}toExact(e={groupSeparator:""}){return vt.DP=this.currency.decimals,new vt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e)}};import{TOKEN_PROGRAM_ID as Yn}from"@solana/spl-token";var ae={address:"So11111111111111111111111111111111111111112",programId:Yn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}},ce={address:"So11111111111111111111111111111111111111112",programId:Yn.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}};import{PublicKey as ln}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Sr}from"@solana/spl-token";import{PublicKey as W,SystemProgram as Jn,SYSVAR_RENT_PUBKEY as Br}from"@solana/web3.js";function un({pubkey:n,isSigner:t=!1,isWritable:e=!0}){return{pubkey:n,isWritable:e,isSigner:t}}var Es=[un({pubkey:Sr,isWritable:!1}),un({pubkey:Jn.programId,isWritable:!1}),un({pubkey:Br,isWritable:!1})];function cn({publicKey:n,transformSol:t}){let e=mn(n.toString());if(e instanceof W)return t&&e.equals(tt)?Q:e;if(t&&e.toString()===tt.toBase58())return Q;if(typeof e=="string"){if(e===W.default.toBase58())return W.default;try{return new W(e)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function mn(n){try{return new W(n)}catch{return n}}var Fs=new W("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Ds=new W("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),qs=new W("SysvarRent111111111111111111111111111111111"),Us=new W("SysvarC1ock11111111111111111111111111111111"),Ws=new W("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Vs=new W("Sysvar1nstructions1111111111111111111111111"),Gs=Jn.programId,Hs=new W("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),zs=new W("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),js=new W("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Zs=new W("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Xs=new W("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ys=new W("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Js=new W("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Qs=new W("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),$s=new W("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),eu=new W("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),tu=new W("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),Q=new W("So11111111111111111111111111111111111111112"),tt=W.default;function Be(n){return cn({publicKey:n,transformSol:!0})}var dn=class{constructor({mint:t,decimals:e,symbol:o,name:r,skipMint:i=!1,isToken2022:a=!1}){if(t===tt.toBase58()||t instanceof ln&&tt.equals(t)){this.decimals=ce.decimals,this.symbol=ce.symbol,this.name=ce.name,this.mint=new ln(ce.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?ln.default:cn({publicKey:t}),this.isToken2022=a}equals(t){return this===t?!0:this.mint.equals(t.mint)}},$=dn;$.WSOL=new dn({...ce,mint:ce.address});var pn=class{constructor({decimals:t,symbol:e="UNKNOWN",name:o="UNKNOWN"}){this.decimals=t,this.symbol=e,this.name=o}equals(t){return this===t}},nt=pn;nt.SOL=new pn(ae);function mu(n,t){return n instanceof $&&t instanceof $?n.equals(t):n instanceof $||t instanceof $?!1:n===t}import Cr from"bn.js";var Qn=new K(new Cr(100)),ne=class extends K{toSignificant(t=5,e,o){return this.mul(Qn).toSignificant(t,e,o)}toFixed(t=2,e,o){return this.mul(Qn).toFixed(t,e,o)}};var Ir=U("Ray_price"),se=class extends K{constructor(e){let{baseToken:o,quoteToken:r,numerator:i,denominator:a}=e;super(i,a);this.baseToken=o,this.quoteToken=r,this.scalar=new K(an(o.decimals),an(r.decimals))}get raw(){return new K(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new se({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(e){this.quoteToken!==e.baseToken&&Ir.logWithError("mul token not equals");let o=super.mul(e);return new se({baseToken:this.baseToken,quoteToken:e.quoteToken,denominator:o.denominator,numerator:o.numerator})}toSignificant(e=this.quoteToken.decimals,o,r){return this.adjusted.toSignificant(e,o,r)}toFixed(e=this.quoteToken.decimals,o,r){return this.adjusted.toFixed(e,o,r)}};async function eo(n){new Promise(t=>setTimeout(t,n))}function Nu(){return new Date().getTime()}function fn(n){return typeof n=="object"&&n!==null&&![$,re,Mr,K,Kr,se,ne].some(t=>typeof t=="object"&&n instanceof t)}function $n(n){return typeof n=="string"?mn(n):Array.isArray(n)?n.map(t=>$n(t)):fn(n)?Object.fromEntries(Object.entries(n).map(([t,e])=>[t,$n(e)])):n}import me from"bn.js";var We=9e15,Ke=1e9,gn="0123456789abcdef",Bt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ct="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",hn={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-We,maxE:We,crypto:!1},ro,_e,M=!0,Mt="[DecimalError] ",Me=Mt+"Invalid argument: ",io=Mt+"Precision limit exceeded",ao=Mt+"crypto unavailable",so="[object Decimal]",ee=Math.floor,j=Math.pow,Nr=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Rr=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Lr=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,uo=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,pe=1e7,I=7,Or=9007199254740991,Er=Bt.length-1,yn=Ct.length-1,k={toStringTag:so};k.absoluteValue=k.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),B(n)};k.ceil=function(){return B(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(Me+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())+I,o.rounding=1,e=Fr(o,fo(o,e)),o.precision=n,o.rounding=t,B(_e==2||_e==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,m=this,l=m.constructor;if(!m.isFinite()||m.isZero())return new l(m);for(M=!1,i=m.s*j(m.s*m,1/3),!i||Math.abs(i)==1/0?(e=Y(m.d),n=m.e,(i=(n-e.length+1)%3)&&(e+=i==1||i==-2?"0":"00"),i=j(e,1/3),n=ee((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 l(e),o.s=m.s):o=new l(i.toString()),a=(n=l.precision)+3;;)if(s=o,u=s.times(s).times(s),c=u.plus(m),o=D(c.plus(m).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&&(B(s,n+1,0),s.times(s).times(s).eq(m))){o=s;break}a+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(B(o,n+1,1),t=!o.times(o).times(o).eq(m));break}return M=!0,B(o,n,l.rounding,t)};k.decimalPlaces=k.dp=function(){var n,t=this.d,e=NaN;if(t){if(n=t.length-1,e=(n-ee(this.e/I))*I,n=t[n],n)for(;n%10==0;n/=10)e--;e<0&&(e=0)}return e};k.dividedBy=k.div=function(n){return D(this,new this.constructor(n))};k.dividedToIntegerBy=k.divToInt=function(n){var t=this,e=t.constructor;return B(D(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 B(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/Nt(4,n)).toString()):(n=16,t="2.3283064365386962890625e-10"),i=Ve(a,1,i.times(t),new a(1),!0);for(var u,c=n,m=new a(8);c--;)u=i.times(i),i=s.minus(u.times(m.minus(u.times(m))));return B(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=Ve(i,2,r,r,!0);else{n=1.4*Math.sqrt(o),n=n>16?16:n|0,r=r.times(1/Nt(5,n)),r=Ve(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,B(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,D(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()?de(e,r,i):new e(0):new e(NaN):t.isZero()?de(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,t=t.asin(),n=de(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,M=!1,e=e.times(e).minus(1).sqrt().plus(e),M=!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,M=!1,e=e.times(e).plus(1).sqrt().plus(e),M=!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?B(new i(r),n,t,!0):(i.precision=e=o-r.e,r=D(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=de(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,m=c.constructor,l=m.precision,d=m.rounding;if(c.isFinite()){if(c.isZero())return new m(c);if(c.abs().eq(1)&&l+4<=yn)return a=de(m,l+4,d).times(.25),a.s=c.s,a}else{if(!c.s)return new m(NaN);if(l+4<=yn)return a=de(m,l+4,d).times(.5),a.s=c.s,a}for(m.precision=s=l+10,m.rounding=1,e=Math.min(28,s/I+2|0),n=e;n;--n)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(M=!1,t=Math.ceil(s/I),o=1,u=c.times(c),a=new m(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)),M=!0,B(a,m.precision=l,m.rounding=d,!0)};k.isFinite=function(){return!!this.d};k.isInteger=k.isInt=function(){return!!this.d&&ee(this.e/I)>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,m=c.constructor,l=m.precision,d=m.rounding,p=5;if(n==null)n=new m(10),t=!0;else{if(n=new m(n),e=n.d,n.s<0||!e||!e[0]||n.eq(1))return new m(NaN);t=n.eq(10)}if(e=c.d,c.s<0||!e||!e[0]||c.eq(1))return new m(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(M=!1,s=l+p,a=Ie(c,s),o=t?It(m,s+10):Ie(n,s),u=D(a,o,s,1),ot(u.d,r=l,d))do if(s+=10,a=Ie(c,s),o=t?It(m,s+10):Ie(n,s),u=D(a,o,s,1),!i){+Y(u.d).slice(r+1,r+15)+1==1e14&&(u=B(u,l+1,0));break}while(ot(u.d,r+=10,d));return M=!0,B(u,l,d)};k.minus=k.sub=function(n){var t,e,o,r,i,a,s,u,c,m,l,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 M?B(n,s,u):n}if(e=ee(n.e/I),m=ee(p.e/I),c=c.slice(),i=m-e,i){for(l=i<0,l?(t=c,i=-i,a=d.length):(t=d,e=m,a=c.length),o=Math.max(Math.ceil(s/I),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,l=o<a,l&&(a=o),o=0;o<a;o++)if(c[o]!=d[o]){l=c[o]<d[o];break}i=0}for(l&&(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]=pe-1;--c[r],c[o]+=pe}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=Kt(c,e),M?B(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]?B(new o(e),o.precision,o.rounding):(M=!1,o.modulo==9?(t=D(e,n.abs(),0,3,1),t.s*=n.s):t=D(e,n,0,o.modulo,1),t=t.times(n),M=!0,e.minus(t))};k.naturalExponential=k.exp=function(){return bn(this)};k.naturalLogarithm=k.ln=function(){return Ie(this)};k.negated=k.neg=function(){var n=new this.constructor(this);return n.s=-n.s,B(n)};k.plus=k.add=function(n){var t,e,o,r,i,a,s,u,c,m,l=this,d=l.constructor;if(n=new d(n),!l.d||!n.d)return!l.s||!n.s?n=new d(NaN):l.d||(n=new d(n.d||l.s===n.s?l:NaN)),n;if(l.s!=n.s)return n.s=-n.s,l.minus(n);if(c=l.d,m=n.d,s=d.precision,u=d.rounding,!c[0]||!m[0])return m[0]||(n=new d(l)),M?B(n,s,u):n;if(i=ee(l.e/I),o=ee(n.e/I),c=c.slice(),r=i-o,r){for(r<0?(e=c,r=-r,a=m.length):(e=m,o=i,a=c.length),i=Math.ceil(s/I),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=m.length,a-r<0&&(r=a,e=m,m=c,c=e),t=0;r;)t=(c[--r]=c[r]+m[r]+t)/pe|0,c[r]%=pe;for(t&&(c.unshift(t),++o),a=c.length;c[--a]==0;)c.pop();return n.d=c,n.e=Kt(c,o),M?B(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(Me+n);return e.d?(t=co(e.d),n&&e.e+1>t&&(t=e.e+1)):t=NaN,t};k.round=function(){var n=this,t=n.constructor;return B(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())+I,o.rounding=1,e=qr(o,fo(o,e)),o.precision=n,o.rounding=t,B(_e>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,m=a.constructor;if(c!==1||!s||!s[0])return new m(!c||c<0&&(!s||s[0])?NaN:s?a:1/0);for(M=!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=ee((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 m(t)):o=new m(c.toString()),e=(u=m.precision)+3;;)if(i=o,o=i.plus(D(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&&(B(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")&&(B(o,u+1,1),n=!o.times(o).eq(a));break}return M=!0,B(o,u,m.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=D(e,new o(1).minus(e.times(e)).sqrt(),n+10,0),o.precision=n,o.rounding=t,B(_e==2||_e==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,m=this,l=m.constructor,d=m.d,p=(n=new l(n)).d;if(n.s*=m.s,!d||!d[0]||!p||!p[0])return new l(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?n.s/0:n.s*0);for(e=ee(m.e/I)+ee(n.e/I),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%pe|0,t=s/pe|0;i[r]=(i[r]+t)%pe|0}for(;!i[--a];)i.pop();return t?++e:i.shift(),n.d=i,n.e=Kt(i,e),M?B(n,l.precision,l.rounding):n};k.toBinary=function(n,t){return kn(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:(ie(n,0,Ke),t===void 0?t=o.rounding:ie(t,0,8),B(e,n+e.e+1,t))};k.toExponential=function(n,t){var e,o=this,r=o.constructor;return n===void 0?e=ye(o,!0):(ie(n,0,Ke),t===void 0?t=r.rounding:ie(t,0,8),o=B(new r(o),n+1,t),e=ye(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=ye(r):(ie(n,0,Ke),t===void 0?t=i.rounding:ie(t,0,8),o=B(new i(r),n+r.e+1,t),e=ye(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,m,l,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=co(h)-p.e-1,a=i%I,t.d[0]=j(10,a<0?I+a:a),n==null)n=i>0?t:c;else{if(s=new f(n),!s.isInt()||s.lt(c))throw Error(Me+s);n=s.gt(t)?i>0?t:c:s}for(M=!1,s=new f(Y(h)),m=f.precision,f.precision=i=h.length*I*2;l=D(s,t,0,1,1),r=e.plus(l.times(o)),r.cmp(n)!=1;)e=o,o=r,r=c,c=u.plus(l.times(r)),u=r,r=t,t=s.minus(l.times(r)),s=r;return r=D(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=D(c,o,i,1).minus(p).abs().cmp(D(u,e,i,1).minus(p).abs())<1?[c,o]:[u,e],f.precision=m,M=!0,d};k.toHexadecimal=k.toHex=function(n,t){return kn(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:ie(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]?(M=!1,e=D(e,n,0,t,1).times(n),M=!0,B(e)):(n.s=e.s,e=n),e};k.toNumber=function(){return+this};k.toOctal=function(n,t){return kn(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 B(s,o,i);if(t=ee(n.e/I),t>=n.d.length-1&&(e=c<0?-c:c)<=Or)return r=mo(u,s,e,o),n.s<0?new u(1).div(r):B(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)?ee(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):(M=!1,u.rounding=s.s=1,e=Math.min(12,(t+"").length),r=bn(n.times(Ie(s,o+e)),o),r.d&&(r=B(r,o+5,1),ot(r.d,o,i)&&(t=o+10,r=B(bn(n.times(Ie(s,t+e)),t),t+5,1),+Y(r.d).slice(o+1,o+15)+1==1e14&&(r=B(r,o+1,0)))),r.s=a,M=!0,u.rounding=i,B(r,o,i))};k.toPrecision=function(n,t){var e,o=this,r=o.constructor;return n===void 0?e=ye(o,o.e<=r.toExpNeg||o.e>=r.toExpPos):(ie(n,1,Ke),t===void 0?t=r.rounding:ie(t,0,8),o=B(new r(o),n,t),e=ye(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):(ie(n,1,Ke),t===void 0?t=o.rounding:ie(t,0,8)),B(new o(e),n,t)};k.toString=function(){var n=this,t=n.constructor,e=ye(n,n.e<=t.toExpNeg||n.e>=t.toExpPos);return n.isNeg()&&!n.isZero()?"-"+e:e};k.truncated=k.trunc=function(){return B(new this.constructor(this),this.e+1,1)};k.valueOf=k.toJSON=function(){var n=this,t=n.constructor,e=ye(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=I-o.length,e&&(i+=Ce(e)),i+=o;a=n[t],o=a+"",e=I-o.length,e&&(i+=Ce(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function ie(n,t,e){if(n!==~~n||n<t||n>e)throw Error(Me+n)}function ot(n,t,e,o){var r,i,a,s;for(i=n[0];i>=10;i/=10)--t;return--t<0?(t+=I,r=0):(r=Math.ceil((t+1)/I),t%=I),i=j(10,I-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 St(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]+=gn.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 Fr(n,t){var e,o,r;if(t.isZero())return t;o=t.d.length,o<32?(e=Math.ceil(o/3),r=(1/Nt(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),n.precision+=e,t=Ve(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 D=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,m,l,d,p,h,f,w,y,b,g,_,P,v,S,C,N,E,R,z,V=o.constructor,Z=o.s==r.s?1:-1,F=o.d,O=r.d;if(!F||!F[0]||!O||!O[0])return new V(!o.s||!r.s||(F?O&&F[0]==O[0]:!O)?NaN:F&&F[0]==0||!O?Z*0:Z/0);for(u?(p=1,m=o.e-r.e):(u=pe,p=I,m=ee(o.e/p)-ee(r.e/p)),R=O.length,N=F.length,y=new V(Z),b=y.d=[],l=0;O[l]==(F[l]||0);l++);if(O[l]>(F[l]||0)&&m--,i==null?(v=i=V.precision,a=V.rounding):s?v=i+(o.e-r.e)+1:v=i,v<0)b.push(1),h=!0;else{if(v=v/p+2|0,l=0,R==1){for(d=0,O=O[0],v++;(l<N||d)&&v--;l++)S=d*u+(F[l]||0),b[l]=S/O|0,d=S%O|0;h=d||l<N}else{for(d=u/(O[0]+1)|0,d>1&&(O=n(O,d,u),F=n(F,d,u),R=O.length,N=F.length),C=R,g=F.slice(0,R),_=g.length;_<R;)g[_++]=0;z=O.slice(),z.unshift(0),E=O[0],O[1]>=u/2&&++E;do d=0,c=t(O,g,R,_),c<0?(P=g[0],R!=_&&(P=P*u+(g[1]||0)),d=P/E|0,d>1?(d>=u&&(d=u-1),f=n(O,d,u),w=f.length,_=g.length,c=t(f,g,w,_),c==1&&(d--,e(f,R<w?z:O,w,u))):(d==0&&(c=d=1),f=O.slice()),w=f.length,w<_&&f.unshift(0),e(g,f,_,u),c==-1&&(_=g.length,c=t(O,g,R,_),c<1&&(d++,e(g,R<_?z:O,_,u))),_=g.length):c===0&&(d++,g=[0]),b[l++]=d,c&&g[0]?g[_++]=F[C]||0:(g=[F[C]],_=1);while((C++<N||g[0]!==void 0)&&v--);h=g[0]!==void 0}b[0]||b.shift()}if(p==1)y.e=m,ro=h;else{for(l=1,d=b[0];d>=10;d/=10)l++;y.e=l+m*p-1,B(y,s?i+y.e+1:i,a,h)}return y}}();function B(n,t,e,o){var r,i,a,s,u,c,m,l,d,p=n.constructor;e:if(t!=null){if(l=n.d,!l)return n;for(r=1,s=l[0];s>=10;s/=10)r++;if(i=t-r,i<0)i+=I,a=t,m=l[d=0],u=m/j(10,r-a-1)%10|0;else if(d=Math.ceil((i+1)/I),s=l.length,d>=s)if(o){for(;s++<=d;)l.push(0);m=u=0,r=1,i%=I,a=i-I+1}else break e;else{for(m=s=l[d],r=1;s>=10;s/=10)r++;i%=I,a=i-I+r,u=a<0?0:m/j(10,r-a-1)%10|0}if(o=o||t<0||l[d+1]!==void 0||(a<0?m:m%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?m/j(10,r-a):0:l[d-1])%10&1||e==(n.s<0?8:7)),t<1||!l[0])return l.length=0,c?(t-=n.e+1,l[0]=j(10,(I-t%I)%I),n.e=-t||0):l[0]=n.e=0,n;if(i==0?(l.length=d,s=1,d--):(l.length=d+1,s=j(10,I-i),l[d]=a>0?(m/j(10,r-a)%j(10,a)|0)*s:0),c)for(;;)if(d==0){for(i=1,a=l[0];a>=10;a/=10)i++;for(a=l[0]+=s,s=1;a>=10;a/=10)s++;i!=s&&(n.e++,l[0]==pe&&(l[0]=1));break}else{if(l[d]+=s,l[d]!=pe)break;l[d--]=0,s=1}for(i=l.length;l[--i]===0;)l.pop()}return M&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function ye(n,t,e){if(!n.isFinite())return po(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)+Ce(o):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(n.e<0?"e":"e+")+n.e):r<0?(i="0."+Ce(-r-1)+i,e&&(o=e-a)>0&&(i+=Ce(o))):r>=a?(i+=Ce(r+1-a),e&&(o=e-r-1)>0&&(i=i+"."+Ce(o))):((o=r+1)<a&&(i=i.slice(0,o)+"."+i.slice(o)),e&&(o=e-a)>0&&(r+1===a&&(i+="."),i+=Ce(o))),i}function Kt(n,t){var e=n[0];for(t*=I;e>=10;e/=10)t++;return t}function It(n,t,e){if(t>Er)throw M=!0,e&&(n.precision=e),Error(io);return B(new n(Bt),t,1,!0)}function de(n,t,e){if(t>yn)throw Error(io);return B(new n(Ct),t,e,!0)}function co(n){var t=n.length-1,e=t*I+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 Ce(n){for(var t="";n--;)t+="0";return t}function mo(n,t,e,o){var r,i=new n(1),a=Math.ceil(o/I+4);for(M=!1;;){if(e%2&&(i=i.times(t),no(i.d,a)&&(r=!0)),e=ee(e/2),e===0){e=i.d.length-1,r&&i.d[e]===0&&++i.d[e];break}t=t.times(t),no(t.d,a)}return M=!0,i}function to(n){return n.d[n.d.length-1]&1}function lo(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 bn(n,t){var e,o,r,i,a,s,u,c=0,m=0,l=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?(M=!1,u=h):u=t,s=new d(.03125);n.e>-2;)n=n.times(s),l+=5;for(o=Math.log(j(2,l))/Math.LN10*2+5|0,u+=o,e=i=a=new d(1),d.precision=u;;){if(i=B(i.times(n),u,1),e=e.times(++m),s=a.plus(D(i,e,u,1)),Y(s.d).slice(0,u)===Y(a.d).slice(0,u)){for(r=l;r--;)a=B(a.times(a),u,1);if(t==null)if(c<3&&ot(a.d,u-o,p,c))d.precision=u+=10,e=i=s=new d(1),m=0,c++;else return B(a,d.precision=h,p,M=!0);else return d.precision=h,a}a=s}}function Ie(n,t){var e,o,r,i,a,s,u,c,m,l,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?(M=!1,m=g):m=t,y.precision=m+=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=It(y,m+2,g).times(i+""),f=Ie(new y(o+"."+e.slice(1)),m-h).plus(c),y.precision=g,t==null?B(f,g,b,M=!0):f;for(l=f,u=a=f=D(f.minus(1),f.plus(1),m,1),d=B(f.times(f),m,1),r=3;;){if(a=B(a.times(d),m,1),c=u.plus(D(a,new y(r),m,1)),Y(c.d).slice(0,m)===Y(u.d).slice(0,m))if(u=u.times(2),i!==0&&(u=u.plus(It(y,m+2,g).times(i+""))),u=D(u,new y(p),m,1),t==null)if(ot(u.d,m-h,b,s))y.precision=m+=h,c=a=f=D(l.minus(1),l.plus(1),m,1),d=B(f.times(f),m,1),r=s=1;else return B(u,y.precision=g,b,M=!0);else return y.precision=g,u;u=c,r+=2}}function po(n){return String(n.s*n.s/0)}function wn(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)%I,e<0&&(o+=I),o<r){for(o&&n.d.push(+t.slice(0,o)),r-=I;o<r;)n.d.push(+t.slice(o,o+=I));t=t.slice(o),o=I-t.length}else o-=r;for(;o--;)t+="0";n.d.push(+t),M&&(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 Dr(n,t){var e,o,r,i,a,s,u,c,m;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),uo.test(t))return wn(n,t)}else if(t==="Infinity"||t==="NaN")return+t||(n.s=NaN),n.e=NaN,n.d=null,n;if(Rr.test(t))e=16,t=t.toLowerCase();else if(Nr.test(t))e=2;else if(Lr.test(t))e=8;else throw Error(Me+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=mo(o,new o(e),i,i*2)),c=St(t,e,pe),m=c.length-1,i=m;c[i]===0;--i)c.pop();return i<0?new o(n.s*0):(n.e=Kt(c,m),n.d=c,M=!1,a&&(n=D(n,r,s*4)),u&&(n=n.times(Math.abs(u)<54?j(2,u):rt.pow(2,u))),M=!0,n)}function qr(n,t){var e,o=t.d.length;if(o<3)return t.isZero()?t:Ve(n,2,t,t);e=1.4*Math.sqrt(o),e=e>16?16:e|0,t=t.times(1/Nt(5,e)),t=Ve(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 Ve(n,t,e,o,r){var i,a,s,u,c=1,m=n.precision,l=Math.ceil(m/I);for(M=!1,u=e.times(e),s=new n(o);;){if(a=D(s.times(u),new n(t++*t++),m,1),s=r?o.plus(a):o.minus(a),o=D(a.times(u),new n(t++*t++),m,1),a=s.plus(o),a.d[l]!==void 0){for(i=l;a.d[i]===s.d[i]&&i--;);if(i==-1)break}i=s,s=o,o=a,a=i,c++}return M=!0,a.d.length=l+1,a}function Nt(n,t){for(var e=n;--t;)e*=n;return e}function fo(n,t){var e,o=t.s<0,r=de(n,n.precision,1),i=r.times(.5);if(t=t.abs(),t.lte(i))return _e=o?4:1,t;if(e=t.divToInt(r),e.isZero())_e=o?3:2;else{if(t=t.minus(e.times(r)),t.lte(i))return _e=to(e)?o?2:3:o?4:1,t;_e=to(e)?o?1:4:o?3:2}return t.minus(r).abs()}function kn(n,t,e,o){var r,i,a,s,u,c,m,l,d,p=n.constructor,h=e!==void 0;if(h?(ie(e,1,Ke),o===void 0?o=p.rounding:ie(o,0,8)):(e=p.precision,o=p.rounding),!n.isFinite())m=po(n);else{for(m=ye(n),a=m.indexOf("."),h?(r=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):r=t,a>=0&&(m=m.replace(".",""),d=new p(1),d.e=m.length-a,d.d=St(ye(d),10,r),d.e=d.d.length),l=St(m,10,r),i=u=l.length;l[--u]==0;)l.pop();if(!l[0])m=h?"0p+0":"0";else{if(a<0?i--:(n=new p(n),n.d=l,n.e=i,n=D(n,d,e,o,0,r),l=n.d,i=n.e,c=ro),a=l[e],s=r/2,c=c||l[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&&l[e-1]&1||o===(n.s<0?8:7)),l.length=e,c)for(;++l[--e]>r-1;)l[e]=0,e||(++i,l.unshift(1));for(u=l.length;!l[u-1];--u);for(a=0,m="";a<u;a++)m+=gn.charAt(l[a]);if(h){if(u>1)if(t==16||t==8){for(a=t==16?4:3,--u;u%a;u++)m+="0";for(l=St(m,r,t),u=l.length;!l[u-1];--u);for(a=1,m="1.";a<u;a++)m+=gn.charAt(l[a])}else m=m.charAt(0)+"."+m.slice(1);m=m+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)m="0"+m;m="0."+m}else if(++i>u)for(i-=u;i--;)m+="0";else i<u&&(m=m.slice(0,i)+"."+m.slice(i))}m=(t==16?"0x":t==2?"0b":t==8?"0o":"")+m}return n.s<0?"-"+m:m}function no(n,t){if(n.length>t)return n.length=t,!0}function Ur(n){return new this(n).abs()}function Wr(n){return new this(n).acos()}function Vr(n){return new this(n).acosh()}function Gr(n,t){return new this(n).plus(t)}function Hr(n){return new this(n).asin()}function zr(n){return new this(n).asinh()}function jr(n){return new this(n).atan()}function Zr(n){return new this(n).atanh()}function Xr(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=de(this,i,1).times(t.s>0?.25:.75),e.s=n.s):!t.d||n.isZero()?(e=t.s<0?de(this,o,r):new this(0),e.s=n.s):!n.d||t.isZero()?(e=de(this,i,1).times(.5),e.s=n.s):t.s<0?(this.precision=i,this.rounding=1,e=this.atan(D(n,t,i,1)),t=de(this,i,1),this.precision=o,this.rounding=r,e=n.s<0?e.minus(t):e.plus(t)):e=this.atan(D(n,t,i,1)),e}function Yr(n){return new this(n).cbrt()}function Jr(n){return B(n=new this(n),n.e+1,2)}function Qr(n,t,e){return new this(n).clamp(t,e)}function $r(n){if(!n||typeof n!="object")throw Error(Mt+"Object expected");var t,e,o,r=n.defaults===!0,i=["precision",1,Ke,"rounding",0,8,"toExpNeg",-We,0,"toExpPos",0,We,"maxE",0,We,"minE",-We,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(e=i[t],r&&(this[e]=hn[e]),(o=n[e])!==void 0)if(ee(o)===o&&o>=i[t+1]&&o<=i[t+2])this[e]=o;else throw Error(Me+e+": "+o);if(e="crypto",r&&(this[e]=hn[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(ao);else this[e]=!1;else throw Error(Me+e+": "+o);return this}function ei(n){return new this(n).cos()}function ti(n){return new this(n).cosh()}function go(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,oo(i)){c.s=i.s,M?!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++;M?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 wn(c,i.toString())}else if(u!=="string")throw Error(Me+i);return(s=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(s===43&&(i=i.slice(1)),c.s=1),uo.test(i)?wn(c,i):Dr(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=$r,r.clone=go,r.isDecimal=oo,r.abs=Ur,r.acos=Wr,r.acosh=Vr,r.add=Gr,r.asin=Hr,r.asinh=zr,r.atan=jr,r.atanh=Zr,r.atan2=Xr,r.cbrt=Yr,r.ceil=Jr,r.clamp=Qr,r.cos=ei,r.cosh=ti,r.div=ni,r.exp=oi,r.floor=ri,r.hypot=ii,r.ln=ai,r.log=si,r.log10=ci,r.log2=ui,r.max=mi,r.min=li,r.mod=di,r.mul=pi,r.pow=fi,r.random=gi,r.round=hi,r.sign=yi,r.sin=bi,r.sinh=wi,r.sqrt=ki,r.sub=_i,r.sum=Ti,r.tan=Pi,r.tanh=Ai,r.trunc=xi,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 ni(n,t){return new this(n).div(t)}function oi(n){return new this(n).exp()}function ri(n){return B(n=new this(n),n.e+1,3)}function ii(){var n,t,e=new this(0);for(M=!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 M=!0,new this(1/0);e=t}return M=!0,e.sqrt()}function oo(n){return n instanceof rt||n&&n.toStringTag===so||!1}function ai(n){return new this(n).ln()}function si(n,t){return new this(n).log(t)}function ui(n){return new this(n).log(2)}function ci(n){return new this(n).log(10)}function mi(){return lo(this,arguments,"lt")}function li(){return lo(this,arguments,"gt")}function di(n,t){return new this(n).mod(t)}function pi(n,t){return new this(n).mul(t)}function fi(n,t){return new this(n).pow(t)}function gi(n){var t,e,o,r,i=0,a=new this(1),s=[];if(n===void 0?n=this.precision:ie(n,1,Ke),o=Math.ceil(n/I),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(ao);else for(;i<o;)s[i++]=Math.random()*1e7|0;for(o=s[--i],n%=I,o&&n&&(r=j(10,I-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-=I)s.shift();for(o=1,r=s[0];r>=10;r/=10)o++;o<I&&(e-=I-o)}return a.e=e,a.d=s,a}function hi(n){return B(n=new this(n),n.e+1,this.rounding)}function yi(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function bi(n){return new this(n).sin()}function wi(n){return new this(n).sinh()}function ki(n){return new this(n).sqrt()}function _i(n,t){return new this(n).sub(t)}function Ti(){var n=0,t=arguments,e=new this(t[n]);for(M=!1;e.s&&++n<t.length;)e=e.plus(t[n]);return M=!0,B(e,this.precision,this.rounding)}function Pi(n){return new this(n).tan()}function Ai(n){return new this(n).tanh()}function xi(n){return B(n=new this(n),n.e+1,1)}k[Symbol.for("nodejs.util.inspect.custom")]=k.toString;k[Symbol.toStringTag]="Decimal";var rt=k.constructor=go(hn);Bt=new rt(Bt);Ct=new rt(Ct);var te=rt;function G(n){if(n instanceof ne)return new K(n.numerator,n.denominator);if(n instanceof se)return n.adjusted;if(n instanceof re)try{return G(n.toExact())}catch{return new K(le)}if(n instanceof K)return n;let t=String(n),e=Fe(t);return new K(e.numerator,e.denominator)}function qu(n){var o;if(n instanceof ne)return{fr:new K(n.numerator,n.denominator)};if(n instanceof se)return{fr:n.adjusted};if(n instanceof re)return{fr:G(n.toExact()),decimals:n.token.decimals};if(n instanceof K)return{fr:n};let t=String(n),e=Fe(t);return{fr:new K(e.numerator,e.denominator),decimals:(o=e.dec)==null?void 0:o.length}}function Uu(n,t){if(n==null||t==null)return!1;let e=G(n),o=G(t);return e.sub(o).numerator,e.sub(o).numerator.lt(le)}function vi(n,t){if(n==null||t==null)return!1;let e=G(n),o=G(t);return e.sub(o).numerator.gt(le)}function Wu(n,t){if(n==null||t==null)return!1;let e=G(n),o=G(t);return e.sub(o).numerator.lte(le)}function Vu(n,t){if(n==null||t==null)return!1;let e=G(n),o=G(t);return e.sub(o).numerator.gte(le)}function Si(n,t){if(n==null||t==null)return!1;let e=G(n),o=G(t);return e.sub(o).numerator.eq(le)}function Gu(n,t){if(n==null||t==null)return;let e=G(n),o=G(t);try{return e.div(o)}catch{return e}}function Hu(n,t){if(n==null||t==null)return;let e=G(n),o=G(t);return e.sub(o)}function zu(n){return n==null?!1:!Si(n,0)}function ju(n,t){return vi(t,n)?t:n}function _n(n,t){if(n==null||t==null)return;let e=G(n),o=G(t);return e.mul(o)}function Zu(n,t){if(n==null||t==null)return;let e=G(n),o=G(t);return e.add(o)}function Fe(n){var s;if(n===void 0)return{denominator:"1",numerator:"0"};if(n instanceof me)return{numerator:n.toString(),denominator:"1"};if(n instanceof K)return{denominator:n.denominator.toString(),numerator:n.numerator.toString()};let t=String(n),[,e="",o="",r=""]=(s=t.replace(",","").match(/(-?)(\d*)\.?(\d*)/))!=null?s:[],i="1"+"0".repeat(r.length),a=e+(o==="0"?"":o)+r||"0";return{denominator:i,numerator:a,sign:e,int:o,dec:r}}function uc(n,t){let e=n.divmod(t);return e.mod.isZero()?e.div:e.div.isNeg()?e.div.isubn(1):e.div.iaddn(1)}function Bi(n){var o;let[,t="",e=""]=(o=n.toFixed(2).match(/(-?)(\d*)\.?(\d*)/))!=null?o:[];return`${t}${e}`}function Ci(n,t=0){return n instanceof me?n:new me(Bi(bo(n).mul(ve.pow(new me(String(t))))))}function bo(n){if(n instanceof ne)return new K(n.numerator,n.denominator);if(n instanceof se)return n.adjusted;if(n instanceof re)try{return bo(n.toExact())}catch{return new K(le)}if(n instanceof K)return n;let t=String(n),e=Fe(t);return new K(e.numerator,e.denominator)}function cc(n,t){let{numerator:e,denominator:o}=Fe(n);return new ne(new me(e),new me(o).mul(t!=null&&t.alreadyDecimaled?new me(100):new me(1)))}function mc(n){let{token:t,numberPrice:e,decimalDone:o}=n,r=new $({mint:"",decimals:6,symbol:"usd",name:"usd",skipMint:!0}),{numerator:i,denominator:a}=Fe(e),s=o?new me(i).mul(ve.pow(new me(t.decimals))):i,u=new me(a).mul(ve.pow(new me(r.decimals)));return new se({baseToken:r,denominator:u.toString(),quoteToken:new $({...t,skipMint:!0,mint:""}),numerator:s.toString()})}function ho(n){let t=new nt({decimals:6,symbol:"usd",name:"usd"}),e=Ci(_n(n,10**t.decimals));return new Ee(t,e)}function lc(n,t){return ho(!t||!n?0:_n(n,t))}function Ii(n){if(n==null)return;let{numerator:t,denominator:e}=Fe(n.toString());return new K(t,e)}function Mi(n){return n instanceof te}function yo(n){return Mi(n)?Ii(n):Array.isArray(n)?n.map(t=>yo(t)):fn(n)?Object.fromEntries(Object.entries(n).map(([t,e])=>[t,yo(e)])):n}import{PublicKey as st,sendAndConfirmTransaction as Sn,Transaction as ut,TransactionMessage as ct,VersionedTransaction as mt}from"@solana/web3.js";import Ui from"axios";var wo=(e=>(e[e.V0=0]="V0",e[e.LEGACY=1]="LEGACY",e))(wo||{}),q={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"};import{PublicKey as _o,ComputeBudgetProgram as ko,Transaction as Lt,TransactionMessage as Ki,Keypair as To,VersionedTransaction as Tn}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Ni}from"@solana/spl-token";var Te=U("Gfx_txUtil"),Po=1644;function Ot(n){let t=[],e=[];return n.microLamports&&(t.push(ko.setComputeUnitPrice({microLamports:n.microLamports})),e.push(q.SetComputeUnitPrice)),n.units&&(t.push(ko.setComputeUnitLimit({units:n.units})),e.push(q.SetComputeUnitLimit)),{instructions:t,instructionTypes:e}}async function Ge(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 Ao(n,t){n.length<1&&Te.logWithError(`no instructions provided: ${n.toString()}`),t.length<1&&Te.logWithError(`no signers provided:, ${t.toString()}`);let e=new Lt;e.recentBlockhash="11111111111111111111111111111111",e.feePayer=t[0],e.add(...n);try{return e.serialize({verifySignatures:!1}).toString("base64").length<Po}catch{return!1}}async function Pc(n,t,e,o=!0){let r=new _o("GfxSimuLateTransaction11111111111111111"),i=[],a=new Lt;a.feePayer=r;for(let c of t)Ao([...a.instructions,c],[r])||(i.push(a),a=new Lt,a.feePayer=r),a.add(c);a.instructions.length>0&&i.push(a);let s=[];try{if(s=await Ri(n,i,o),s.find(c=>c.err!==null))throw Error("rpc simulateTransaction error")}catch(c){c instanceof Error&&Te.logWithError("failed to simulate for instructions","RPC_ERROR",{message:c.message})}let u=[];for(let c of s)if(Te.debug("simulate result:",c),c.logs){let m=c.logs.filter(l=>l&&l.includes(e));Te.debug("filteredLog:",u),m.length||Te.logWithError("simulate log not match keyword","keyword",e),u.push(...m)}return u}function Ac(n,t){let e=n.match(/{["\w:,]+}/g);return!e||e.length!==1?Te.logWithError(`simulate log fail to match json, keyword: ${t}`):e[0]}function xc(n,t){let o=new RegExp(`"${t}":(\\d+)`,"g").exec(n);return!o||o.length!==2?Te.logWithError(`simulate log fail to match key", key: ${t}`):o[1]}function fe(n,t){let[e,o]=_o.findProgramAddressSync(n,t);return{publicKey:e,nonce:o}}async function Ri(n,t,e){let o=[];if(e){let r=await n.getLatestBlockhash(),i=[];for(let c of t){c.recentBlockhash=r.blockhash,c.lastValidBlockHeight=r.lastValidBlockHeight;let l=c._compile().serialize(),p=c._serialize(l).toString("base64");i.push(p)}let a=i.map(c=>{let m=n._buildArgs([c],void 0,"base64");return{methodName:"simulateTransaction",args:m}}),s=[],u=2