UNPKG

goosefx-amm-sdk

Version:

SDK for the GooseFx AMM

1 lines 77.6 kB
"use strict";var Bn=Object.create;var Me=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var Sn=Object.getPrototypeOf,Nn=Object.prototype.hasOwnProperty;var En=(e,t)=>{for(var n in t)Me(e,n,{get:t[n],enumerable:!0})},Ct=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Cn(t))!Nn.call(e,i)&&i!==n&&Me(e,i,{get:()=>t[i],enumerable:!(r=In(t,i))||r.enumerable});return e};var G=(e,t,n)=>(n=e!=null?Bn(Sn(e)):{},Ct(t||!e||!e.__esModule?Me(n,"default",{value:e,enumerable:!0}):n,e)),Ln=e=>Ct(Me({},"__esModule",{value:!0}),e);var Gr={};En(Gr,{default:()=>it});module.exports=Ln(Gr);var K=require("@solana/spl-token"),he=require("@solana/web3.js");var ye=require("lodash");var ot=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 n=t.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(n)}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}},St={},Dn={};function q(e){let t=(0,ye.get)(St,e);if(!t){let n=(0,ye.get)(Dn,e);t=new ot({name:e,logLevel:n}),(0,ye.set)(St,e,t)}return t}var vn=require("@solana/web3.js"),Fn=G(require("bn.js"));var Kt=G(require("big.js")),_n=G(require("bn.js"));var j=G(require("bn.js"));var Et=new j.default(0),Yr=new j.default(1),Xr=new j.default(2),Jr=new j.default(3),Qr=new j.default(5),Lt=new j.default(10),$r=new j.default(100),ei=new j.default(1e3),ti=new j.default(1e4),Nt=9007199254740991;function $(e){let t=q("Gfx_parseBigNumberish");if(e instanceof j.default)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new j.default(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=Nt||e<=-Nt)&&t.logWithError(`BigNumberish number overflow: ${e}`),new j.default(String(e))):typeof e=="bigint"?new j.default(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new j.default(0))}var Dt=G(require("toformat")),Rn=Dt.default,Ae=Rn;var ke=G(require("big.js")),Rt=G(require("bn.js")),Mt=G(require("decimal.js-light"));var Ke=q("module/fraction"),st=Ae(ke.default),Pe=Ae(Mt.default),Kn={[0]:Pe.ROUND_DOWN,[1]:Pe.ROUND_HALF_UP,[2]:Pe.ROUND_UP},On={[0]:ke.default.roundDown,[1]:ke.default.roundHalfUp,[2]:ke.default.roundUp},R=class{constructor(t,n=new Rt.default(1)){this.numerator=$(t),this.denominator=$(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new R(this.denominator,this.numerator)}add(t){let n=t instanceof R?t:new R($(t));return this.denominator.eq(n.denominator)?new R(this.numerator.add(n.numerator),this.denominator):new R(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(t){let n=t instanceof R?t:new R($(t));return this.denominator.eq(n.denominator)?new R(this.numerator.sub(n.numerator),this.denominator):new R(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(t){let n=t instanceof R?t:new R($(t));return new R(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(t){let n=t instanceof R?t:new R($(t));return new R(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(t,n={groupSeparator:""},r=1){Number.isInteger(t)||Ke.logWithError(`${t} is not an integer.`),t<=0&&Ke.logWithError(`${t} is not positive.`),Pe.set({precision:t+1,rounding:Kn[r]});let i=new Pe(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return i.toFormat(i.decimalPlaces(),n)}toFixed(t,n={groupSeparator:""},r=1){return Number.isInteger(t)||Ke.logWithError(`${t} is not an integer.`),t<0&&Ke.logWithError(`${t} is negative.`),st.DP=t,st.RM=On[r]||1,new st(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)}isZero(){return this.numerator.isZero()}};var bi=q("Gfx_amount"),wi=Ae(Kt.default);var ct=require("@solana/spl-token"),Ot={address:"So11111111111111111111111111111111111111112",programId:ct.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}},te={address:"So11111111111111111111111111111111111111112",programId:ct.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}};var Oe=require("@solana/web3.js");var _t=require("@solana/spl-token"),C=require("@solana/web3.js");function at({pubkey:e,isSigner:t=!1,isWritable:n=!0}){return{pubkey:e,isWritable:n,isSigner:t}}var Ai=[at({pubkey:_t.TOKEN_PROGRAM_ID,isWritable:!1}),at({pubkey:C.SystemProgram.programId,isWritable:!1}),at({pubkey:C.SYSVAR_RENT_PUBKEY,isWritable:!1})];function vt({publicKey:e,transformSol:t}){let n=Ft(e.toString());if(n instanceof C.PublicKey)return t&&n.equals(Be)?oe:n;if(t&&n.toString()===Be.toBase58())return oe;if(typeof n=="string"){if(n===C.PublicKey.default.toBase58())return C.PublicKey.default;try{return new C.PublicKey(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Ft(e){try{return new C.PublicKey(e)}catch{return e}}var ki=new C.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Pi=new C.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Bi=new C.PublicKey("SysvarRent111111111111111111111111111111111"),Ii=new C.PublicKey("SysvarC1ock11111111111111111111111111111111"),Ci=new C.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Si=new C.PublicKey("Sysvar1nstructions1111111111111111111111111"),Ni=C.SystemProgram.programId,Ei=new C.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Li=new C.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Di=new C.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Ri=new C.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Mi=new C.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ki=new C.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Oi=new C.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),_i=new C.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),vi=new C.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Fi=new C.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Wi=new C.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),oe=new C.PublicKey("So11111111111111111111111111111111111111112"),Be=C.PublicKey.default;var ut=class{constructor({mint:t,decimals:n,symbol:r,name:i,skipMint:o=!1,isToken2022:s=!1}){if(t===Be.toBase58()||t instanceof Oe.PublicKey&&Be.equals(t)){this.decimals=te.decimals,this.symbol=te.symbol,this.name=te.name,this.mint=new Oe.PublicKey(te.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=r||t.toString().substring(0,6),this.name=i||t.toString().substring(0,6),this.mint=o?Oe.PublicKey.default:vt({publicKey:t}),this.isToken2022=s}equals(t){return this===t?!0:this.mint.equals(t.mint)}},ge=ut;ge.WSOL=new ut({...te,mint:te.address});var lt=class{constructor({decimals:t,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=t,this.symbol=n,this.name=r}equals(t){return this===t}},_e=lt;_e.SOL=new lt(Ot);var Wt=G(require("bn.js"));var Xi=new R(new Wt.default(100));var io=q("Ray_price");var Rr=G(require("bn.js"));var be=9e15,ue=1e9,ft="0123456789abcdef",Fe="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",We="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",pt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-be,maxE:be,crypto:!1},Zt,ne,P=!0,qe="[DecimalError] ",ae=qe+"Invalid argument: ",zt=qe+"Precision limit exceeded",Yt=qe+"crypto unavailable",Xt="[object Decimal]",H=Math.floor,_=Math.pow,Wn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Un=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,qn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Jt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,X=1e7,k=7,Hn=9007199254740991,Vn=Fe.length-1,dt=We.length-1,m={toStringTag:Xt};m.absoluteValue=m.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),A(e)};m.ceil=function(){return A(new this.constructor(this),this.e+1,2)};m.clampedTo=m.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(ae+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)};m.comparedTo=m.cmp=function(e){var t,n,r,i,o=this,s=o.d,c=(e=new o.constructor(e)).d,a=o.s,u=e.s;if(!s||!c)return!a||!u?NaN:a!==u?a:s===c?0:!s^a<0?1:-1;if(!s[0]||!c[0])return s[0]?a:c[0]?-u:0;if(a!==u)return a;if(o.e!==e.e)return o.e>e.e^a<0?1:-1;for(r=s.length,i=c.length,t=0,n=r<i?r:i;t<n;++t)if(s[t]!==c[t])return s[t]>c[t]^a<0?1:-1;return r===i?0:r>i^a<0?1:-1};m.cosine=m.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+k,r.rounding=1,n=Gn(r,nn(r,n)),r.precision=e,r.rounding=t,A(ne==2||ne==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)};m.cubeRoot=m.cbrt=function(){var e,t,n,r,i,o,s,c,a,u,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(P=!1,o=l.s*_(l.s*l,1/3),!o||Math.abs(o)==1/0?(n=W(l.d),e=l.e,(o=(e-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=_(n,1/3),e=H((e+1)/3)-(e%3==(e<0?-1:2)),o==1/0?n="5e"+e:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),r=new f(n),r.s=l.s):r=new f(o.toString()),s=(e=f.precision)+3;;)if(c=r,a=c.times(c).times(c),u=a.plus(l),r=L(u.plus(l).times(c),u.plus(a),s+2,1),W(c.d).slice(0,s)===(n=W(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!i&&n=="4999"){if(!i&&(A(c,e+1,0),c.times(c).times(c).eq(l))){r=c;break}s+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(A(r,e+1,1),t=!r.times(r).times(r).eq(l));break}return P=!0,A(r,e,f.rounding,t)};m.decimalPlaces=m.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-H(this.e/k))*k,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};m.dividedBy=m.div=function(e){return L(this,new this.constructor(e))};m.dividedToIntegerBy=m.divToInt=function(e){var t=this,n=t.constructor;return A(L(t,new n(e),0,1,1),n.precision,n.rounding)};m.equals=m.eq=function(e){return this.cmp(e)===0};m.floor=function(){return A(new this.constructor(this),this.e+1,3)};m.greaterThan=m.gt=function(e){return this.cmp(e)>0};m.greaterThanOrEqualTo=m.gte=function(e){var t=this.cmp(e);return t==1||t===0};m.hyperbolicCosine=m.cosh=function(){var e,t,n,r,i,o=this,s=o.constructor,c=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return c;n=s.precision,r=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,i=o.d.length,i<32?(e=Math.ceil(i/3),t=(1/Ve(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),o=we(s,1,o.times(t),new s(1),!0);for(var a,u=e,l=new s(8);u--;)a=o.times(o),o=c.minus(a.times(l.minus(a.times(l))));return A(o,s.precision=n,s.rounding=r,!0)};m.hyperbolicSine=m.sinh=function(){var e,t,n,r,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(t=o.precision,n=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,r=i.d.length,r<3)i=we(o,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/Ve(5,e)),i=we(o,2,i,i,!0);for(var s,c=new o(5),a=new o(16),u=new o(20);e--;)s=i.times(i),i=i.times(c.plus(s.times(a.times(s).plus(u))))}return o.precision=t,o.rounding=n,A(i,t,n,!0)};m.hyperbolicTangent=m.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,L(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)};m.inverseCosine=m.acos=function(){var e,t=this,n=t.constructor,r=t.abs().cmp(1),i=n.precision,o=n.rounding;return r!==-1?r===0?t.isNeg()?Y(n,i,o):new n(0):new n(NaN):t.isZero()?Y(n,i+4,o).times(.5):(n.precision=i+6,n.rounding=1,t=t.asin(),e=Y(n,i+4,o).times(.5),n.precision=i,n.rounding=o,e.minus(t))};m.inverseHyperbolicCosine=m.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,P=!1,n=n.times(n).minus(1).sqrt().plus(n),P=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)};m.inverseHyperbolicSine=m.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,P=!1,n=n.times(n).plus(1).sqrt().plus(n),P=!0,r.precision=e,r.rounding=t,n.ln())};m.inverseHyperbolicTangent=m.atanh=function(){var e,t,n,r,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=o.precision,t=o.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?A(new o(i),e,t,!0):(o.precision=n=r-i.e,i=L(i.plus(1),new o(1).minus(i),n+e,1),o.precision=e+4,o.rounding=1,i=i.ln(),o.precision=e,o.rounding=t,i.times(.5))):new o(NaN)};m.inverseSine=m.asin=function(){var e,t,n,r,i=this,o=i.constructor;return i.isZero()?new o(i):(t=i.abs().cmp(1),n=o.precision,r=o.rounding,t!==-1?t===0?(e=Y(o,n+4,r).times(.5),e.s=i.s,e):new o(NaN):(o.precision=n+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=r,i.times(2)))};m.inverseTangent=m.atan=function(){var e,t,n,r,i,o,s,c,a,u=this,l=u.constructor,f=l.precision,p=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&f+4<=dt)return s=Y(l,f+4,p).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(f+4<=dt)return s=Y(l,f+4,p).times(.5),s.s=u.s,s}for(l.precision=c=f+10,l.rounding=1,n=Math.min(28,c/k+2|0),e=n;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(P=!1,t=Math.ceil(c/k),r=1,a=u.times(u),s=new l(u),i=u;e!==-1;)if(i=i.times(a),o=s.minus(i.div(r+=2)),i=i.times(a),s=o.plus(i.div(r+=2)),s.d[t]!==void 0)for(e=t;s.d[e]===o.d[e]&&e--;);return n&&(s=s.times(2<<n-1)),P=!0,A(s,l.precision=f,l.rounding=p,!0)};m.isFinite=function(){return!!this.d};m.isInteger=m.isInt=function(){return!!this.d&&H(this.e/k)>this.d.length-2};m.isNaN=function(){return!this.s};m.isNegative=m.isNeg=function(){return this.s<0};m.isPositive=m.isPos=function(){return this.s>0};m.isZero=function(){return!!this.d&&this.d[0]===0};m.lessThan=m.lt=function(e){return this.cmp(e)<0};m.lessThanOrEqualTo=m.lte=function(e){return this.cmp(e)<1};m.logarithm=m.log=function(e){var t,n,r,i,o,s,c,a,u=this,l=u.constructor,f=l.precision,p=l.rounding,d=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new l(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)o=!0;else{for(i=n[0];i%10===0;)i/=10;o=i!==1}if(P=!1,c=f+d,s=ce(u,c),r=t?Ue(l,c+10):ce(e,c),a=L(s,r,c,1),Ie(a.d,i=f,p))do if(c+=10,s=ce(u,c),r=t?Ue(l,c+10):ce(e,c),a=L(s,r,c,1),!o){+W(a.d).slice(i+1,i+15)+1==1e14&&(a=A(a,f+1,0));break}while(Ie(a.d,i+=10,p));return P=!0,A(a,f,p)};m.minus=m.sub=function(e){var t,n,r,i,o,s,c,a,u,l,f,p,d=this,x=d.constructor;if(e=new x(e),!d.d||!e.d)return!d.s||!e.s?e=new x(NaN):d.d?e.s=-e.s:e=new x(e.d||d.s!==e.s?d:NaN),e;if(d.s!=e.s)return e.s=-e.s,d.plus(e);if(u=d.d,p=e.d,c=x.precision,a=x.rounding,!u[0]||!p[0]){if(p[0])e.s=-e.s;else if(u[0])e=new x(d);else return new x(a===3?-0:0);return P?A(e,c,a):e}if(n=H(e.e/k),l=H(d.e/k),u=u.slice(),o=l-n,o){for(f=o<0,f?(t=u,o=-o,s=p.length):(t=p,n=l,s=u.length),r=Math.max(Math.ceil(c/k),s)+2,o>r&&(o=r,t.length=1),t.reverse(),r=o;r--;)t.push(0);t.reverse()}else{for(r=u.length,s=p.length,f=r<s,f&&(s=r),r=0;r<s;r++)if(u[r]!=p[r]){f=u[r]<p[r];break}o=0}for(f&&(t=u,u=p,p=t,e.s=-e.s),s=u.length,r=p.length-s;r>0;--r)u[s++]=0;for(r=p.length;r>o;){if(u[--r]<p[r]){for(i=r;i&&u[--i]===0;)u[i]=X-1;--u[i],u[r]+=X}u[r]-=p[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(e.d=u,e.e=He(u,n),P?A(e,c,a):e):new x(a===3?-0:0)};m.modulo=m.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?A(new r(n),r.precision,r.rounding):(P=!1,r.modulo==9?(t=L(n,e.abs(),0,3,1),t.s*=e.s):t=L(n,e,0,r.modulo,1),t=t.times(e),P=!0,n.minus(t))};m.naturalExponential=m.exp=function(){return mt(this)};m.naturalLogarithm=m.ln=function(){return ce(this)};m.negated=m.neg=function(){var e=new this.constructor(this);return e.s=-e.s,A(e)};m.plus=m.add=function(e){var t,n,r,i,o,s,c,a,u,l,f=this,p=f.constructor;if(e=new p(e),!f.d||!e.d)return!f.s||!e.s?e=new p(NaN):f.d||(e=new p(e.d||f.s===e.s?f:NaN)),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(u=f.d,l=e.d,c=p.precision,a=p.rounding,!u[0]||!l[0])return l[0]||(e=new p(f)),P?A(e,c,a):e;if(o=H(f.e/k),r=H(e.e/k),u=u.slice(),i=o-r,i){for(i<0?(n=u,i=-i,s=l.length):(n=l,r=o,s=u.length),o=Math.ceil(c/k),s=o>s?o+1:s+1,i>s&&(i=s,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(s=u.length,i=l.length,s-i<0&&(i=s,n=l,l=u,u=n),t=0;i;)t=(u[--i]=u[i]+l[i]+t)/X|0,u[i]%=X;for(t&&(u.unshift(t),++r),s=u.length;u[--s]==0;)u.pop();return e.d=u,e.e=He(u,r),P?A(e,c,a):e};m.precision=m.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(ae+e);return n.d?(t=Qt(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};m.round=function(){var e=this,t=e.constructor;return A(new t(e),e.e+1,t.rounding)};m.sine=m.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+k,r.rounding=1,n=Zn(r,nn(r,n)),r.precision=e,r.rounding=t,A(ne>2?n.neg():n,e,t,!0)):new r(NaN)};m.squareRoot=m.sqrt=function(){var e,t,n,r,i,o,s=this,c=s.d,a=s.e,u=s.s,l=s.constructor;if(u!==1||!c||!c[0])return new l(!u||u<0&&(!c||c[0])?NaN:c?s:1/0);for(P=!1,u=Math.sqrt(+s),u==0||u==1/0?(t=W(c),(t.length+a)%2==0&&(t+="0"),u=Math.sqrt(t),a=H((a+1)/2)-(a<0||a%2),u==1/0?t="5e"+a:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+a),r=new l(t)):r=new l(u.toString()),n=(a=l.precision)+3;;)if(o=r,r=o.plus(L(s,o,n+2,1)).times(.5),W(o.d).slice(0,n)===(t=W(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!i&&t=="4999"){if(!i&&(A(o,a+1,0),o.times(o).eq(s))){r=o;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(A(r,a+1,1),e=!r.times(r).eq(s));break}return P=!0,A(r,a,l.rounding,e)};m.tangent=m.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=L(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,A(ne==2||ne==4?n.neg():n,e,t,!0)):new r(NaN)};m.times=m.mul=function(e){var t,n,r,i,o,s,c,a,u,l=this,f=l.constructor,p=l.d,d=(e=new f(e)).d;if(e.s*=l.s,!p||!p[0]||!d||!d[0])return new f(!e.s||p&&!p[0]&&!d||d&&!d[0]&&!p?NaN:!p||!d?e.s/0:e.s*0);for(n=H(l.e/k)+H(e.e/k),a=p.length,u=d.length,a<u&&(o=p,p=d,d=o,s=a,a=u,u=s),o=[],s=a+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(t=0,i=a+r;i>r;)c=o[i]+d[r]*p[i-r-1]+t,o[i--]=c%X|0,t=c/X|0;o[i]=(o[i]+t)%X|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=He(o,n),P?A(e,f.precision,f.rounding):e};m.toBinary=function(e,t){return gt(this,2,e,t)};m.toDecimalPlaces=m.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Z(e,0,ue),t===void 0?t=r.rounding:Z(t,0,8),A(n,e+n.e+1,t))};m.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=ee(r,!0):(Z(e,0,ue),t===void 0?t=i.rounding:Z(t,0,8),r=A(new i(r),e+1,t),n=ee(r,!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};m.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?n=ee(i):(Z(e,0,ue),t===void 0?t=o.rounding:Z(t,0,8),r=A(new o(i),e+i.e+1,t),n=ee(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n};m.toFraction=function(e){var t,n,r,i,o,s,c,a,u,l,f,p,d=this,x=d.d,g=d.constructor;if(!x)return new g(d);if(u=n=new g(1),r=a=new g(0),t=new g(r),o=t.e=Qt(x)-d.e-1,s=o%k,t.d[0]=_(10,s<0?k+s:s),e==null)e=o>0?t:u;else{if(c=new g(e),!c.isInt()||c.lt(u))throw Error(ae+c);e=c.gt(t)?o>0?t:u:c}for(P=!1,c=new g(W(x)),l=g.precision,g.precision=o=x.length*k*2;f=L(c,t,0,1,1),i=n.plus(f.times(r)),i.cmp(e)!=1;)n=r,r=i,i=u,u=a.plus(f.times(i)),a=i,i=t,t=c.minus(f.times(i)),c=i;return i=L(e.minus(n),r,0,1,1),a=a.plus(i.times(u)),n=n.plus(i.times(r)),a.s=u.s=d.s,p=L(u,r,o,1).minus(d).abs().cmp(L(a,n,o,1).minus(d).abs())<1?[u,r]:[a,n],g.precision=l,P=!0,p};m.toHexadecimal=m.toHex=function(e,t){return gt(this,16,e,t)};m.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:Z(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(P=!1,n=L(n,e,0,t,1).times(e),P=!0,A(n)):(e.s=n.s,n=e),n};m.toNumber=function(){return+this};m.toOctal=function(e,t){return gt(this,8,e,t)};m.toPower=m.pow=function(e){var t,n,r,i,o,s,c=this,a=c.constructor,u=+(e=new a(e));if(!c.d||!e.d||!c.d[0]||!e.d[0])return new a(_(+c,u));if(c=new a(c),c.eq(1))return c;if(r=a.precision,o=a.rounding,e.eq(1))return A(c,r,o);if(t=H(e.e/k),t>=e.d.length-1&&(n=u<0?-u:u)<=Hn)return i=$t(a,c,n,r),e.s<0?new a(1).div(i):A(i,r,o);if(s=c.s,s<0){if(t<e.d.length-1)return new a(NaN);if((e.d[t]&1)==0&&(s=1),c.e==0&&c.d[0]==1&&c.d.length==1)return c.s=s,c}return n=_(+c,u),t=n==0||!isFinite(n)?H(u*(Math.log("0."+W(c.d))/Math.LN10+c.e+1)):new a(n+"").e,t>a.maxE+1||t<a.minE-1?new a(t>0?s/0:0):(P=!1,a.rounding=c.s=1,n=Math.min(12,(t+"").length),i=mt(e.times(ce(c,r+n)),r),i.d&&(i=A(i,r+5,1),Ie(i.d,r,o)&&(t=r+10,i=A(mt(e.times(ce(c,t+n)),t),t+5,1),+W(i.d).slice(r+1,r+15)+1==1e14&&(i=A(i,r+1,0)))),i.s=s,P=!0,a.rounding=o,A(i,r,o))};m.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=ee(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Z(e,1,ue),t===void 0?t=i.rounding:Z(t,0,8),r=A(new i(r),e,t),n=ee(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n};m.toSignificantDigits=m.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Z(e,1,ue),t===void 0?t=r.rounding:Z(t,0,8)),A(new r(n),e,t)};m.toString=function(){var e=this,t=e.constructor,n=ee(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n};m.truncated=m.trunc=function(){return A(new this.constructor(this),this.e+1,1)};m.valueOf=m.toJSON=function(){var e=this,t=e.constructor,n=ee(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function W(e){var t,n,r,i=e.length-1,o="",s=e[0];if(i>0){for(o+=s,t=1;t<i;t++)r=e[t]+"",n=k-r.length,n&&(o+=se(n)),o+=r;s=e[t],r=s+"",n=k-r.length,n&&(o+=se(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Z(e,t,n){if(e!==~~e||e<t||e>n)throw Error(ae+e)}function Ie(e,t,n,r){var i,o,s,c;for(o=e[0];o>=10;o/=10)--t;return--t<0?(t+=k,i=0):(i=Math.ceil((t+1)/k),t%=k),o=_(10,k-t),c=e[i]%o|0,r==null?t<3?(t==0?c=c/100|0:t==1&&(c=c/10|0),s=n<4&&c==99999||n>3&&c==49999||c==5e4||c==0):s=(n<4&&c+1==o||n>3&&c+1==o/2)&&(e[i+1]/o/100|0)==_(10,t-2)-1||(c==o/2||c==0)&&(e[i+1]/o/100|0)==0:t<4?(t==0?c=c/1e3|0:t==1?c=c/100|0:t==2&&(c=c/10|0),s=(r||n<4)&&c==9999||!r&&n>3&&c==4999):s=((r||n<4)&&c+1==o||!r&&n>3&&c+1==o/2)&&(e[i+1]/o/1e3|0)==_(10,t-3)-1,s}function ve(e,t,n){for(var r,i=[0],o,s=0,c=e.length;s<c;){for(o=i.length;o--;)i[o]*=t;for(i[0]+=ft.indexOf(e.charAt(s++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function Gn(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/Ve(4,n)).toString()):(n=16,i="2.3283064365386962890625e-10"),e.precision+=n,t=we(e,1,t.times(i),new e(1));for(var o=n;o--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}var L=function(){function e(r,i,o){var s,c=0,a=r.length;for(r=r.slice();a--;)s=r[a]*i+c,r[a]=s%o|0,c=s/o|0;return c&&r.unshift(c),r}function t(r,i,o,s){var c,a;if(o!=s)a=o>s?1:-1;else for(c=a=0;c<o;c++)if(r[c]!=i[c]){a=r[c]>i[c]?1:-1;break}return a}function n(r,i,o,s){for(var c=0;o--;)r[o]-=c,c=r[o]<i[o]?1:0,r[o]=c*s+r[o]-i[o];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,o,s,c,a){var u,l,f,p,d,x,g,y,b,w,h,T,B,S,E,M,O,Q,v,pe,de=r.constructor,Te=r.s==i.s?1:-1,U=r.d,D=i.d;if(!U||!U[0]||!D||!D[0])return new de(!r.s||!i.s||(U?D&&U[0]==D[0]:!D)?NaN:U&&U[0]==0||!D?Te*0:Te/0);for(a?(d=1,l=r.e-i.e):(a=X,d=k,l=H(r.e/d)-H(i.e/d)),v=D.length,O=U.length,b=new de(Te),w=b.d=[],f=0;D[f]==(U[f]||0);f++);if(D[f]>(U[f]||0)&&l--,o==null?(S=o=de.precision,s=de.rounding):c?S=o+(r.e-i.e)+1:S=o,S<0)w.push(1),x=!0;else{if(S=S/d+2|0,f=0,v==1){for(p=0,D=D[0],S++;(f<O||p)&&S--;f++)E=p*a+(U[f]||0),w[f]=E/D|0,p=E%D|0;x=p||f<O}else{for(p=a/(D[0]+1)|0,p>1&&(D=e(D,p,a),U=e(U,p,a),v=D.length,O=U.length),M=v,h=U.slice(0,v),T=h.length;T<v;)h[T++]=0;pe=D.slice(),pe.unshift(0),Q=D[0],D[1]>=a/2&&++Q;do p=0,u=t(D,h,v,T),u<0?(B=h[0],v!=T&&(B=B*a+(h[1]||0)),p=B/Q|0,p>1?(p>=a&&(p=a-1),g=e(D,p,a),y=g.length,T=h.length,u=t(g,h,y,T),u==1&&(p--,n(g,v<y?pe:D,y,a))):(p==0&&(u=p=1),g=D.slice()),y=g.length,y<T&&g.unshift(0),n(h,g,T,a),u==-1&&(T=h.length,u=t(D,h,v,T),u<1&&(p++,n(h,v<T?pe:D,T,a))),T=h.length):u===0&&(p++,h=[0]),w[f++]=p,u&&h[0]?h[T++]=U[M]||0:(h=[U[M]],T=1);while((M++<O||h[0]!==void 0)&&S--);x=h[0]!==void 0}w[0]||w.shift()}if(d==1)b.e=l,Zt=x;else{for(f=1,p=w[0];p>=10;p/=10)f++;b.e=f+l*d-1,A(b,c?o+b.e+1:o,s,x)}return b}}();function A(e,t,n,r){var i,o,s,c,a,u,l,f,p,d=e.constructor;e:if(t!=null){if(f=e.d,!f)return e;for(i=1,c=f[0];c>=10;c/=10)i++;if(o=t-i,o<0)o+=k,s=t,l=f[p=0],a=l/_(10,i-s-1)%10|0;else if(p=Math.ceil((o+1)/k),c=f.length,p>=c)if(r){for(;c++<=p;)f.push(0);l=a=0,i=1,o%=k,s=o-k+1}else break e;else{for(l=c=f[p],i=1;c>=10;c/=10)i++;o%=k,s=o-k+i,a=s<0?0:l/_(10,i-s-1)%10|0}if(r=r||t<0||f[p+1]!==void 0||(s<0?l:l%_(10,i-s-1)),u=n<4?(a||r)&&(n==0||n==(e.s<0?3:2)):a>5||a==5&&(n==4||r||n==6&&(o>0?s>0?l/_(10,i-s):0:f[p-1])%10&1||n==(e.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=e.e+1,f[0]=_(10,(k-t%k)%k),e.e=-t||0):f[0]=e.e=0,e;if(o==0?(f.length=p,c=1,p--):(f.length=p+1,c=_(10,k-o),f[p]=s>0?(l/_(10,i-s)%_(10,s)|0)*c:0),u)for(;;)if(p==0){for(o=1,s=f[0];s>=10;s/=10)o++;for(s=f[0]+=c,c=1;s>=10;s/=10)c++;o!=c&&(e.e++,f[0]==X&&(f[0]=1));break}else{if(f[p]+=c,f[p]!=X)break;f[p--]=0,c=1}for(o=f.length;f[--o]===0;)f.pop()}return P&&(e.e>d.maxE?(e.d=null,e.e=NaN):e.e<d.minE&&(e.e=0,e.d=[0])),e}function ee(e,t,n){if(!e.isFinite())return tn(e);var r,i=e.e,o=W(e.d),s=o.length;return t?(n&&(r=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+se(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(e.e<0?"e":"e+")+e.e):i<0?(o="0."+se(-i-1)+o,n&&(r=n-s)>0&&(o+=se(r))):i>=s?(o+=se(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+se(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(o+="."),o+=se(r))),o}function He(e,t){var n=e[0];for(t*=k;n>=10;n/=10)t++;return t}function Ue(e,t,n){if(t>Vn)throw P=!0,n&&(e.precision=n),Error(zt);return A(new e(Fe),t,1,!0)}function Y(e,t,n){if(t>dt)throw Error(zt);return A(new e(We),t,n,!0)}function Qt(e){var t=e.length-1,n=t*k+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function se(e){for(var t="";e--;)t+="0";return t}function $t(e,t,n,r){var i,o=new e(1),s=Math.ceil(r/k+4);for(P=!1;;){if(n%2&&(o=o.times(t),Gt(o.d,s)&&(i=!0)),n=H(n/2),n===0){n=o.d.length-1,i&&o.d[n]===0&&++o.d[n];break}t=t.times(t),Gt(t.d,s)}return P=!0,o}function Vt(e){return e.d[e.d.length-1]&1}function en(e,t,n){for(var r,i=new e(t[0]),o=0;++o<t.length;)if(r=new e(t[o]),r.s)i[n](r)&&(i=r);else{i=r;break}return i}function mt(e,t){var n,r,i,o,s,c,a,u=0,l=0,f=0,p=e.constructor,d=p.rounding,x=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(P=!1,a=x):a=t,c=new p(.03125);e.e>-2;)e=e.times(c),f+=5;for(r=Math.log(_(2,f))/Math.LN10*2+5|0,a+=r,n=o=s=new p(1),p.precision=a;;){if(o=A(o.times(e),a,1),n=n.times(++l),c=s.plus(L(o,n,a,1)),W(c.d).slice(0,a)===W(s.d).slice(0,a)){for(i=f;i--;)s=A(s.times(s),a,1);if(t==null)if(u<3&&Ie(s.d,a-r,d,u))p.precision=a+=10,n=o=c=new p(1),l=0,u++;else return A(s,p.precision=x,d,P=!0);else return p.precision=x,s}s=c}}function ce(e,t){var n,r,i,o,s,c,a,u,l,f,p,d=1,x=10,g=e,y=g.d,b=g.constructor,w=b.rounding,h=b.precision;if(g.s<0||!y||!y[0]||!g.e&&y[0]==1&&y.length==1)return new b(y&&!y[0]?-1/0:g.s!=1?NaN:y?0:g);if(t==null?(P=!1,l=h):l=t,b.precision=l+=x,n=W(y),r=n.charAt(0),Math.abs(o=g.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=W(g.d),r=n.charAt(0),d++;o=g.e,r>1?(g=new b("0."+n),o++):g=new b(r+"."+n.slice(1))}else return u=Ue(b,l+2,h).times(o+""),g=ce(new b(r+"."+n.slice(1)),l-x).plus(u),b.precision=h,t==null?A(g,h,w,P=!0):g;for(f=g,a=s=g=L(g.minus(1),g.plus(1),l,1),p=A(g.times(g),l,1),i=3;;){if(s=A(s.times(p),l,1),u=a.plus(L(s,new b(i),l,1)),W(u.d).slice(0,l)===W(a.d).slice(0,l))if(a=a.times(2),o!==0&&(a=a.plus(Ue(b,l+2,h).times(o+""))),a=L(a,new b(d),l,1),t==null)if(Ie(a.d,l-x,w,c))b.precision=l+=x,u=s=g=L(f.minus(1),f.plus(1),l,1),p=A(g.times(g),l,1),i=c=1;else return A(a,b.precision=h,w,P=!0);else return b.precision=h,a;a=u,i+=2}}function tn(e){return String(e.s*e.s/0)}function ht(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%k,n<0&&(r+=k),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=k;r<i;)e.d.push(+t.slice(r,r+=k));t=t.slice(r),r=k-t.length}else r-=i;for(;r--;)t+="0";e.d.push(+t),P&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function jn(e,t){var n,r,i,o,s,c,a,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Jt.test(t))return ht(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Un.test(t))n=16,t=t.toLowerCase();else if(Wn.test(t))n=2;else if(qn.test(t))n=8;else throw Error(ae+t);for(o=t.search(/p/i),o>0?(a=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),o=t.indexOf("."),s=o>=0,r=e.constructor,s&&(t=t.replace(".",""),c=t.length,o=c-o,i=$t(r,new r(n),o,o*2)),u=ve(t,n,X),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new r(e.s*0):(e.e=He(u,l),e.d=u,P=!1,s&&(e=L(e,i,c*4)),a&&(e=e.times(Math.abs(a)<54?_(2,a):Ge.pow(2,a))),P=!0,e)}function Zn(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:we(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/Ve(5,n)),t=we(e,2,t,t);for(var i,o=new e(5),s=new e(16),c=new e(20);n--;)i=t.times(t),t=t.times(o.plus(i.times(s.times(i).minus(c))));return t}function we(e,t,n,r,i){var o,s,c,a,u=1,l=e.precision,f=Math.ceil(l/k);for(P=!1,a=n.times(n),c=new e(r);;){if(s=L(c.times(a),new e(t++*t++),l,1),c=i?r.plus(s):r.minus(s),r=L(s.times(a),new e(t++*t++),l,1),s=c.plus(r),s.d[f]!==void 0){for(o=f;s.d[o]===c.d[o]&&o--;);if(o==-1)break}o=c,c=r,r=s,s=o,u++}return P=!0,s.d.length=f+1,s}function Ve(e,t){for(var n=e;--t;)n*=e;return n}function nn(e,t){var n,r=t.s<0,i=Y(e,e.precision,1),o=i.times(.5);if(t=t.abs(),t.lte(o))return ne=r?4:1,t;if(n=t.divToInt(i),n.isZero())ne=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(o))return ne=Vt(n)?r?2:3:r?4:1,t;ne=Vt(n)?r?1:4:r?3:2}return t.minus(i).abs()}function gt(e,t,n,r){var i,o,s,c,a,u,l,f,p,d=e.constructor,x=n!==void 0;if(x?(Z(n,1,ue),r===void 0?r=d.rounding:Z(r,0,8)):(n=d.precision,r=d.rounding),!e.isFinite())l=tn(e);else{for(l=ee(e),s=l.indexOf("."),x?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,s>=0&&(l=l.replace(".",""),p=new d(1),p.e=l.length-s,p.d=ve(ee(p),10,i),p.e=p.d.length),f=ve(l,10,i),o=a=f.length;f[--a]==0;)f.pop();if(!f[0])l=x?"0p+0":"0";else{if(s<0?o--:(e=new d(e),e.d=f,e.e=o,e=L(e,p,n,r,0,i),f=e.d,o=e.e,u=Zt),s=f[n],c=i/2,u=u||f[n+1]!==void 0,u=r<4?(s!==void 0||u)&&(r===0||r===(e.s<0?3:2)):s>c||s===c&&(r===4||u||r===6&&f[n-1]&1||r===(e.s<0?8:7)),f.length=n,u)for(;++f[--n]>i-1;)f[n]=0,n||(++o,f.unshift(1));for(a=f.length;!f[a-1];--a);for(s=0,l="";s<a;s++)l+=ft.charAt(f[s]);if(x){if(a>1)if(t==16||t==8){for(s=t==16?4:3,--a;a%s;a++)l+="0";for(f=ve(l,i,t),a=f.length;!f[a-1];--a);for(s=1,l="1.";s<a;s++)l+=ft.charAt(f[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>a)for(o-=a;o--;)l+="0";else o<a&&(l=l.slice(0,o)+"."+l.slice(o))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function Gt(e,t){if(e.length>t)return e.length=t,!0}function zn(e){return new this(e).abs()}function Yn(e){return new this(e).acos()}function Xn(e){return new this(e).acosh()}function Jn(e,t){return new this(e).plus(t)}function Qn(e){return new this(e).asin()}function $n(e){return new this(e).asinh()}function er(e){return new this(e).atan()}function tr(e){return new this(e).atanh()}function nr(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,o=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=Y(this,o,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Y(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Y(this,o,1).times(.5),n.s=e.s):t.s<0?(this.precision=o,this.rounding=1,n=this.atan(L(e,t,o,1)),t=Y(this,o,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(L(e,t,o,1)),n}function rr(e){return new this(e).cbrt()}function ir(e){return A(e=new this(e),e.e+1,2)}function or(e,t,n){return new this(e).clamp(t,n)}function sr(e){if(!e||typeof e!="object")throw Error(qe+"Object expected");var t,n,r,i=e.defaults===!0,o=["precision",1,ue,"rounding",0,8,"toExpNeg",-be,0,"toExpPos",0,be,"maxE",0,be,"minE",-be,0,"modulo",0,9];for(t=0;t<o.length;t+=3)if(n=o[t],i&&(this[n]=pt[n]),(r=e[n])!==void 0)if(H(r)===r&&r>=o[t+1]&&r<=o[t+2])this[n]=r;else throw Error(ae+n+": "+r);if(n="crypto",i&&(this[n]=pt[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Yt);else this[n]=!1;else throw Error(ae+n+": "+r);return this}function cr(e){return new this(e).cos()}function ar(e){return new this(e).cosh()}function rn(e){var t,n,r;function i(o){var s,c,a,u=this;if(!(u instanceof i))return new i(o);if(u.constructor=i,jt(o)){u.s=o.s,P?!o.d||o.e>i.maxE?(u.e=NaN,u.d=null):o.e<i.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(a=typeof o,a==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,c=o;c>=10;c/=10)s++;P?s>i.maxE?(u.e=NaN,u.d=null):s<i.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}else if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return ht(u,o.toString())}else if(a!=="string")throw Error(ae+o);return(c=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(c===43&&(o=o.slice(1)),u.s=1),Jt.test(o)?ht(u,o):jn(u,o)}if(i.prototype=m,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=sr,i.clone=rn,i.isDecimal=jt,i.abs=zn,i.acos=Yn,i.acosh=Xn,i.add=Jn,i.asin=Qn,i.asinh=$n,i.atan=er,i.atanh=tr,i.atan2=nr,i.cbrt=rr,i.ceil=ir,i.clamp=or,i.cos=cr,i.cosh=ar,i.div=ur,i.exp=lr,i.floor=fr,i.hypot=pr,i.ln=dr,i.log=mr,i.log10=gr,i.log2=hr,i.max=br,i.min=wr,i.mod=xr,i.mul=Tr,i.pow=yr,i.random=Ar,i.round=kr,i.sign=Pr,i.sin=Br,i.sinh=Ir,i.sqrt=Cr,i.sub=Sr,i.sum=Nr,i.tan=Er,i.tanh=Lr,i.trunc=Dr,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function ur(e,t){return new this(e).div(t)}function lr(e){return new this(e).exp()}function fr(e){return A(e=new this(e),e.e+1,3)}function pr(){var e,t,n=new this(0);for(P=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return P=!0,new this(1/0);n=t}return P=!0,n.sqrt()}function jt(e){return e instanceof Ge||e&&e.toStringTag===Xt||!1}function dr(e){return new this(e).ln()}function mr(e,t){return new this(e).log(t)}function hr(e){return new this(e).log(2)}function gr(e){return new this(e).log(10)}function br(){return en(this,arguments,"lt")}function wr(){return en(this,arguments,"gt")}function xr(e,t){return new this(e).mod(t)}function Tr(e,t){return new this(e).mul(t)}function yr(e,t){return new this(e).pow(t)}function Ar(e){var t,n,r,i,o=0,s=new this(1),c=[];if(e===void 0?e=this.precision:Z(e,1,ue),r=Math.ceil(e/k),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));o<r;)i=t[o],i>=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:c[o++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);o<r;)i=t[o]+(t[o+1]<<8)+(t[o+2]<<16)+((t[o+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,o):(c.push(i%1e7),o+=4);o=r/4}else throw Error(Yt);else for(;o<r;)c[o++]=Math.random()*1e7|0;for(r=c[--o],e%=k,r&&e&&(i=_(10,k-e),c[o]=(r/i|0)*i);c[o]===0;o--)c.pop();if(o<0)n=0,c=[0];else{for(n=-1;c[0]===0;n-=k)c.shift();for(r=1,i=c[0];i>=10;i/=10)r++;r<k&&(n-=k-r)}return s.e=n,s.d=c,s}function kr(e){return A(e=new this(e),e.e+1,this.rounding)}function Pr(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Br(e){return new this(e).sin()}function Ir(e){return new this(e).sinh()}function Cr(e){return new this(e).sqrt()}function Sr(e,t){return new this(e).sub(t)}function Nr(){var e=0,t=arguments,n=new this(t[e]);for(P=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return P=!0,A(n,this.precision,this.rounding)}function Er(e){return new this(e).tan()}function Lr(e){return new this(e).tanh()}function Dr(e){return A(e=new this(e),e.e+1,1)}m[Symbol.for("nodejs.util.inspect.custom")]=m.toString;m[Symbol.toStringTag]="Decimal";var Ge=m.constructor=rn(pt);Fe=new Ge(Fe);We=new Ge(We);var N=require("@solana/web3.js"),fn=G(require("axios"));var F={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 V=require("@solana/web3.js"),sn=require("@solana/spl-token");var on=q("Gfx_txUtil"),cn=1644;function je(e){let t=[],n=[];return e.microLamports&&(t.push(V.ComputeBudgetProgram.setComputeUnitPrice({microLamports:e.microLamports})),n.push(F.SetComputeUnitPrice)),e.units&&(t.push(V.ComputeBudgetProgram.setComputeUnitLimit({units:e.units})),n.push(F.SetComputeUnitLimit)),{instructions:t,instructionTypes:n}}async function xe(e,t){var r,i;let n=t!=null?t:"confirmed";try{return((i=await((r=e.getLatestBlockhash)==null?void 0:r.call(e,{commitment:n})))==null?void 0:i.blockhash)||(await e.getRecentBlockhash(n)).blockhash}catch{return(await e.getRecentBlockhash(n)).blockhash}}function Mr(e,t){e.length<1&&on.logWithError(`no instructions provided: ${e.toString()}`),t.length<1&&on.logWithError(`no signers provided:, ${t.toString()}`);let n=new V.Transaction;n.recentBlockhash="11111111111111111111111111111111",n.feePayer=t[0],n.add(...e);try{return n.serialize({verifySignatures:!1}).toString("base64").length<cn}catch{return!1}}function an(e,t){let[n,r]=V.PublicKey.findProgramAddressSync(e,t);return{publicKey:n,nonce:r}}function Ce({instructions:e,payer:t,signers:n}){return Mr(e,[t,...n])}function Se({instructions:e,payer:t,lookupTableAddressAccount:n,recentBlockhash:r=V.Keypair.generate().publicKey.toString()}){let o=new V.TransactionMessage({payerKey:t,recentBlockhash:r,instructions:e}).compileToV0Message(Object.values(n!=null?n:{}));try{return Buffer.from(new V.VersionedTransaction(o).serialize()).toString("base64").length<cn}catch{return!1}}var Kr=e=>Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);function me(e){let t=[];return e.forEach(n=>{n instanceof V.Transaction&&(n.recentBlockhash||(n.recentBlockhash=sn.TOKEN_PROGRAM_ID.toBase58()),n.feePayer||(n.feePayer=V.Keypair.generate().publicKey));let r=n.serialize({requireAllSignatures:!1,verifySignatures:!1});n instanceof V.VersionedTransaction&&(r=Kr(r));let i=r.toString("base64");t.push(i)}),console.log("simulate tx string:",t),t}var le=require("@solana/web3.js");var un=require("@solana/web3.js"),Ze=require("@solana/spl-token");var bt=q("Gfx_accountInfo_util");async function ln(e,t,n){let{batchRequest:r,commitment:i="confirmed",chunkCount:o=100}={batchRequest:!1,...n},s=wt(t,o),c=new Array(s.length).fill([]);if(r){let a=s.map(f=>{let p=e._buildArgs([f.map(d=>d.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:p}}),u=wt(a,10);c=(await(await Promise.all(u.map(async f=>await e._rpcBatchRequest(f)))).flat()).map(f=>(f.error&&bt.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${f.error.message}`),f.result.value.map(p=>{if(p){let{data:d,executable:x,lamports:g,owner:y,rentEpoch:b}=p;return d.length!==2&&d[1]!=="base64"&&bt.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(d[0],"base64"),executable:x,lamports:g,owner:new un.PublicKey(y),rentEpoch:b}}return null})))}else try{c=await Promise.all(s.map(a=>e.getMultipleAccountsInfo(a,i)))}catch(a){a instanceof Error&&bt.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${a.message}`)}return c.flat()}async function xt({connection:e,address:t}){let n=await ln(e,[...new Set(t.map(i=>i.toString()))].map(i=>new le.PublicKey(i))),r={};for(let i=0;i<t.length;i++){let o=n[i],s=t[i];if(!o)continue;let c=new le.AddressLookupTableAccount({key:s,state:le.AddressLookupTableAccount.deserialize(new Uint8Array(o.data))});r[s.toString()]=c,ze[s.toString()]=c}return r}var ze={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new le.AddressLookupTableAccount({key:new le.PublicKey("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:le.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 Ye=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 r;let t=(await fn.default.get(`https://solanacompass.com/api/fees?cacheFreshTime=${3e5}`)).data,{avg:n}=(r=t==null?void 0:t[15])!=null?r:{};if(!!n)return{units:6e5,microLamports:Math.min(Math.ceil(n*1e6/6e5),25e3)}}addCustomComputeBudget(t){if(t){let{instructions:n,instructionTypes:r}=je(t);return this.instructions.unshift(...n),this.instructionTypes.unshift(...r),!0}return!1}async calComputeBudget({config:t,defaultIns:n}){try{let r=t||await this.getComputeBudgetConfig();if(this.addCustomComputeBudget(r))return;n&&this.instructions.unshift(...n)}catch{n&&this.instructions.unshift(...n)}}addInstruction({instructions:t=[],endInstructions:n=[],signers:r=[],instructionTypes:i=[],endInstructionTypes:o=[],lookupTableAddress:s=[]}){return this.instructions.push(...t),this.endInstructions.push(...n),this.signers.push(...r),this.instructionTypes.push(...i),this.endInstructionTypes.push(...o),this.lookupTableAddress.push(...s.filter(c=>c!==N.PublicKey.default.toString())),this}async versionBuild({txVersion:t,extInfo:n}){return t===0?await this.buildV0({...n||{}}):this.build(n)}build(t){var r;let n=new N.Transaction;return this.allInstructions.length&&n.add(...this.allInstructions),n.feePayer=this.feePayer,((r=this.owner)==null?void 0:r.signer)&&!this.signers.some(i=>i.publicKey.equals(this.owner.publicKey))&&this.signers.push(this.owner.signer),{builder:this,transaction:n,signers:this.signers,instructionTypes:[...this.instructionTypes,...this.endInstructionTypes],execute:async i=>{var u;let{recentBlockHash:o,skipPreflight:s=!0,sendAndConfirm:c}=i||{},a=o!=null?o:await xe(this.connection,this.blockhashCommitment);if(n.recentBlockhash=a,this.signers.length&&n.sign(...this.signers),me([n]),(u=this.owner)!=null&&u.isKeyPair)return{txId:c?await(0,N.sendAndConfirmTransaction)(this.connection,n,this.signers.find(f=>f.publicKey.equals(this.owner.publicKey))?this.signers:[...this.signers,this.owner.signer],{skipPreflight:s}):await this.connection.sendRawTransaction(n.serialize(),{skipPreflight:s}),signedTx:n};if(this.signAllTransactions){let l=await this.signAllTransactions([n]);return{txId:await this.connection.sendRawTransaction(l[0].serialize(),{skipPreflight:s}),signedTx:l[0]}}throw new Error("please provide owner in keypair format or signAllTransactions function")},extInfo:t||{}}}buildMultiTx(t){var u;let{extraPreBuildData:n=[],extInfo:r}=t,{transaction:i}=this.build(r),o=n.filter(l=>l.transaction.instructions.length>0),s=[i,...o.map(l=>l.transaction)],c=[this.signers,...o.map(l=>l.signers)],a=[...this.instructionTypes,...o.map(l=>l.instructionTypes).flat()];return(u=this.owner)!=null&&u.signer&&c.forEach(l=>{l.some(f=>f.publicKey.equals(this.owner.publicKey))||this.signers.push(this.owner.signer)}),{builder:this,transactions:s,signers:c,instructionTypes:a,execute:async l=>{var y;let{sequentially:f,onTxUpdate:p,recentBlockHash:d,skipPreflight:x=!0}=l||{},g=d!=null?d:await xe(this.connection,this.blockhashCommitment);if((y=this.owner)!=null&&y.isKeyPair){if(f){let b=[];for(let w of s){let h=await(0,N.sendAndConfirmTransaction)(this.connection,w,this.signers.find(T=>T.publicKey.equals(this.owner.publicKey))?this.signers:[...this.signers,this.owner.signer],{skipPreflight:x});b.push(h)}return{txIds:b,signedTxs:s}}return{txIds:await await Promise.all(s.map(async b=>(b.recentBlockhash=g,await this.connection.sendRawTransaction(b.serialize(),{skipPreflight:x})))),signedTxs:s}}if(this.signAllTransactions){let b=s.map((h,T)=>(h.recentBlockhash=g,c[T].length&&h.sign(...c[T]),h));me(b);let w=await this.signAllTransactions(b);if(f){let h=0,T=[],B=async()=>{if(!w[h])return;let S=await this.connection.sendRawTransaction(w[h].serialize(),{skipPreflight:x});T.push({txId:S,status:"sent",signedTx:w[h]}),p==null||p([...T]),h++,this.connection.onSignature(S,E=>{let M=T.findIndex(O=>O.txId===S);M>-1&&(T[M].status=E.err?"error":"success"),p==null||p([...T]),E.err||B()},"processed"),this.connection.getSignatureStatus(S)};return await B(),{txIds:T.map(S=>