UNPKG

goosefx-amm-sdk

Version:

SDK for the GooseFx AMM

1 lines 221 kB
"use strict";var Jo=Object.create;var ht=Object.defineProperty;var Qo=Object.getOwnPropertyDescriptor;var Yo=Object.getOwnPropertyNames;var $o=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty;var tr=(n,t)=>{for(var e in t)ht(n,e,{get:t[e],enumerable:!0})},Ln=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Yo(t))!er.call(n,i)&&i!==e&&ht(n,i,{get:()=>t[i],enumerable:!(o=Qo(t,i))||o.enumerable});return n};var W=(n,t,e)=>(e=n!=null?Jo($o(n)):{},Ln(t||!n||!n.__esModule?ht(e,"default",{value:n,enumerable:!0}):e,n)),nr=n=>Ln(ht({},"__esModule",{value:!0}),n);var Di={};tr(Di,{GfxCpmmClient:()=>ft});module.exports=nr(Di);var Bn=require("@solana/web3.js"),Zo=require("lodash");var go=W(require("axios"));var Ve=require("lodash");var zt=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}},Nn={},or={};function V(n){let t=(0,Ve.get)(Nn,n);if(!t){let e=(0,Ve.get)(or,n);t=new zt({name:n,logLevel:e}),(0,Ve.set)(Nn,n,t)}return t}var cr=require("@solana/web3.js"),mr=W(require("bn.js"));var qn=W(require("big.js")),ur=W(require("bn.js"));var ee=W(require("bn.js"));var yt=new ee.default(0),Wi=new ee.default(1),Vi=new ee.default(2),Gi=new ee.default(3),Hi=new ee.default(5),On=new ee.default(10),zi=new ee.default(100),ji=new ee.default(1e3),Zi=new ee.default(1e4),Rn=9007199254740991;function le(n){let t=V("Gfx_parseBigNumberish");if(n instanceof ee.default)return n;if(typeof n=="string"){if(n.match(/^-?[0-9]+$/))return new ee.default(n);t.logWithError(`invalid BigNumberish string: ${n}`)}return typeof n=="number"?(n%1&&t.logWithError(`BigNumberish number underflow: ${n}`),(n>=Rn||n<=-Rn)&&t.logWithError(`BigNumberish number overflow: ${n}`),new ee.default(String(n))):typeof n=="bigint"?new ee.default(n.toString()):(t.error(`invalid BigNumberish value: ${n}`),new ee.default(0))}var En=W(require("toformat")),rr=En.default,Ge=rr;var He=W(require("big.js")),Dn=W(require("bn.js")),Fn=W(require("decimal.js-light"));var bt=V("module/fraction"),jt=Ge(He.default),ze=Ge(Fn.default),ar={[0]:ze.ROUND_DOWN,[1]:ze.ROUND_HALF_UP,[2]:ze.ROUND_UP},sr={[0]:He.default.roundDown,[1]:He.default.roundHalfUp,[2]:He.default.roundUp},q=class{constructor(t,e=new Dn.default(1)){this.numerator=le(t),this.denominator=le(e)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new q(this.denominator,this.numerator)}add(t){let e=t instanceof q?t:new q(le(t));return this.denominator.eq(e.denominator)?new q(this.numerator.add(e.numerator),this.denominator):new q(this.numerator.mul(e.denominator).add(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}sub(t){let e=t instanceof q?t:new q(le(t));return this.denominator.eq(e.denominator)?new q(this.numerator.sub(e.numerator),this.denominator):new q(this.numerator.mul(e.denominator).sub(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}mul(t){let e=t instanceof q?t:new q(le(t));return new q(this.numerator.mul(e.numerator),this.denominator.mul(e.denominator))}div(t){let e=t instanceof q?t:new q(le(t));return new q(this.numerator.mul(e.denominator),this.denominator.mul(e.numerator))}toSignificant(t,e={groupSeparator:""},o=1){Number.isInteger(t)||bt.logWithError(`${t} is not an integer.`),t<=0&&bt.logWithError(`${t} is not positive.`),ze.set({precision:t+1,rounding:ar[o]});let i=new ze(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return i.toFormat(i.decimalPlaces(),e)}toFixed(t,e={groupSeparator:""},o=1){return Number.isInteger(t)||bt.logWithError(`${t} is not an integer.`),t<0&&bt.logWithError(`${t} is negative.`),jt.DP=t,jt.RM=sr[o]||1,new jt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)}isZero(){return this.numerator.isZero()}};var ma=V("Gfx_amount"),la=Ge(qn.default);var Zt=require("@solana/spl-token"),ie={address:"So11111111111111111111111111111111111111112",programId:Zt.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}},de={address:"So11111111111111111111111111111111111111112",programId:Zt.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}};var wt=require("@solana/web3.js");var Un=require("@solana/spl-token"),R=require("@solana/web3.js");function Xt({pubkey:n,isSigner:t=!1,isWritable:e=!0}){return{pubkey:n,isWritable:e,isSigner:t}}var ga=[Xt({pubkey:Un.TOKEN_PROGRAM_ID,isWritable:!1}),Xt({pubkey:R.SystemProgram.programId,isWritable:!1}),Xt({pubkey:R.SYSVAR_RENT_PUBKEY,isWritable:!1})];function Jt({publicKey:n,transformSol:t}){let e=Wn(n.toString());if(e instanceof R.PublicKey)return t&&e.equals(je)?J:e;if(t&&e.toString()===je.toBase58())return J;if(typeof e=="string"){if(e===R.PublicKey.default.toBase58())return R.PublicKey.default;try{return new R.PublicKey(e)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Wn(n){try{return new R.PublicKey(n)}catch{return n}}var ha=new R.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),ya=new R.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),ba=new R.PublicKey("SysvarRent111111111111111111111111111111111"),wa=new R.PublicKey("SysvarC1ock11111111111111111111111111111111"),ka=new R.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),_a=new R.PublicKey("Sysvar1nstructions1111111111111111111111111"),Ta=R.SystemProgram.programId,Pa=new R.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Aa=new R.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),xa=new R.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),va=new R.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Sa=new R.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ba=new R.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Ca=new R.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ia=new R.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Ma=new R.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Ka=new R.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),La=new R.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),J=new R.PublicKey("So11111111111111111111111111111111111111112"),je=R.PublicKey.default;function Ce(n){return Jt({publicKey:n,transformSol:!0})}var Qt=class{constructor({mint:t,decimals:e,symbol:o,name:i,skipMint:r=!1,isToken2022:a=!1}){if(t===je.toBase58()||t instanceof wt.PublicKey&&je.equals(t)){this.decimals=de.decimals,this.symbol=de.symbol,this.name=de.name,this.mint=new wt.PublicKey(de.address),this.isToken2022=!1;return}this.decimals=e,this.symbol=o||t.toString().substring(0,6),this.name=i||t.toString().substring(0,6),this.mint=r?wt.PublicKey.default:Jt({publicKey:t}),this.isToken2022=a}equals(t){return this===t?!0:this.mint.equals(t.mint)}},Ie=Qt;Ie.WSOL=new Qt({...de,mint:de.address});var Yt=class{constructor({decimals:t,symbol:e="UNKNOWN",name:o="UNKNOWN"}){this.decimals=t,this.symbol=e,this.name=o}equals(t){return this===t}},kt=Yt;kt.SOL=new Yt(ie);var Gn=W(require("bn.js"));var Vn=new q(new Gn.default(100)),pe=class extends q{toSignificant(t=5,e,o){return this.mul(Vn).toSignificant(t,e,o)}toFixed(t=2,e,o){return this.mul(Vn).toFixed(t,e,o)}};var Ja=V("Ray_price");var ri=W(require("bn.js"));var Oe=9e15,Ae=1e9,en="0123456789abcdef",Tt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Pt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",tn={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Oe,maxE:Oe,crypto:!1},Xn,he,I=!0,xt="[DecimalError] ",Pe=xt+"Invalid argument: ",Jn=xt+"Precision limit exceeded",Qn=xt+"crypto unavailable",Yn="[object Decimal]",Q=Math.floor,H=Math.pow,lr=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,dr=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,pr=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,$n=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,se=1e7,B=7,fr=9007199254740991,gr=Tt.length-1,nn=Pt.length-1,w={toStringTag:Yn};w.absoluteValue=w.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),A(n)};w.ceil=function(){return A(new this.constructor(this),this.e+1,2)};w.clampedTo=w.clamp=function(n,t){var e,o=this,i=o.constructor;if(n=new i(n),t=new i(t),!n.s||!t.s)return new i(NaN);if(n.gt(t))throw Error(Pe+t);return e=o.cmp(n),e<0?n:o.cmp(t)>0?t:new i(o)};w.comparedTo=w.cmp=function(n){var t,e,o,i,r=this,a=r.d,s=(n=new r.constructor(n)).d,u=r.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(r.e!==n.e)return r.e>n.e^u<0?1:-1;for(o=a.length,i=s.length,t=0,e=o<i?o:i;t<e;++t)if(a[t]!==s[t])return a[t]>s[t]^u<0?1:-1;return o===i?0:o>i^u<0?1:-1};w.cosine=w.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())+B,o.rounding=1,e=hr(o,ro(o,e)),o.precision=n,o.rounding=t,A(he==2||he==3?e.neg():e,n,t,!0)):new o(1):new o(NaN)};w.cubeRoot=w.cbrt=function(){var n,t,e,o,i,r,a,s,u,c,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(I=!1,r=l.s*H(l.s*l,1/3),!r||Math.abs(r)==1/0?(e=Z(l.d),n=l.e,(r=(n-e.length+1)%3)&&(e+=r==1||r==-2?"0":"00"),r=H(e,1/3),n=Q((n+1)/3)-(n%3==(n<0?-1:2)),r==1/0?e="5e"+n:(e=r.toExponential(),e=e.slice(0,e.indexOf("e")+1)+n),o=new m(e),o.s=l.s):o=new m(r.toString()),a=(n=m.precision)+3;;)if(s=o,u=s.times(s).times(s),c=u.plus(l),o=D(c.plus(l).times(s),c.plus(u),a+2,1),Z(s.d).slice(0,a)===(e=Z(o.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!i&&e=="4999"){if(!i&&(A(s,n+1,0),s.times(s).times(s).eq(l))){o=s;break}a+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(A(o,n+1,1),t=!o.times(o).times(o).eq(l));break}return I=!0,A(o,n,m.rounding,t)};w.decimalPlaces=w.dp=function(){var n,t=this.d,e=NaN;if(t){if(n=t.length-1,e=(n-Q(this.e/B))*B,n=t[n],n)for(;n%10==0;n/=10)e--;e<0&&(e=0)}return e};w.dividedBy=w.div=function(n){return D(this,new this.constructor(n))};w.dividedToIntegerBy=w.divToInt=function(n){var t=this,e=t.constructor;return A(D(t,new e(n),0,1,1),e.precision,e.rounding)};w.equals=w.eq=function(n){return this.cmp(n)===0};w.floor=function(){return A(new this.constructor(this),this.e+1,3)};w.greaterThan=w.gt=function(n){return this.cmp(n)>0};w.greaterThanOrEqualTo=w.gte=function(n){var t=this.cmp(n);return t==1||t===0};w.hyperbolicCosine=w.cosh=function(){var n,t,e,o,i,r=this,a=r.constructor,s=new a(1);if(!r.isFinite())return new a(r.s?1/0:NaN);if(r.isZero())return s;e=a.precision,o=a.rounding,a.precision=e+Math.max(r.e,r.sd())+4,a.rounding=1,i=r.d.length,i<32?(n=Math.ceil(i/3),t=(1/St(4,n)).toString()):(n=16,t="2.3283064365386962890625e-10"),r=Ee(a,1,r.times(t),new a(1),!0);for(var u,c=n,l=new a(8);c--;)u=r.times(r),r=s.minus(u.times(l.minus(u.times(l))));return A(r,a.precision=e,a.rounding=o,!0)};w.hyperbolicSine=w.sinh=function(){var n,t,e,o,i=this,r=i.constructor;if(!i.isFinite()||i.isZero())return new r(i);if(t=r.precision,e=r.rounding,r.precision=t+Math.max(i.e,i.sd())+4,r.rounding=1,o=i.d.length,o<3)i=Ee(r,2,i,i,!0);else{n=1.4*Math.sqrt(o),n=n>16?16:n|0,i=i.times(1/St(5,n)),i=Ee(r,2,i,i,!0);for(var a,s=new r(5),u=new r(16),c=new r(20);n--;)a=i.times(i),i=i.times(s.plus(a.times(u.times(a).plus(c))))}return r.precision=t,r.rounding=e,A(i,t,e,!0)};w.hyperbolicTangent=w.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)};w.inverseCosine=w.acos=function(){var n,t=this,e=t.constructor,o=t.abs().cmp(1),i=e.precision,r=e.rounding;return o!==-1?o===0?t.isNeg()?ae(e,i,r):new e(0):new e(NaN):t.isZero()?ae(e,i+4,r).times(.5):(e.precision=i+6,e.rounding=1,t=t.asin(),n=ae(e,i+4,r).times(.5),e.precision=i,e.rounding=r,n.minus(t))};w.inverseHyperbolicCosine=w.acosh=function(){var n,t,e=this,o=e.constructor;return e.lte(1)?new o(e.eq(1)?0:NaN):e.isFinite()?(n=o.precision,t=o.rounding,o.precision=n+Math.max(Math.abs(e.e),e.sd())+4,o.rounding=1,I=!1,e=e.times(e).minus(1).sqrt().plus(e),I=!0,o.precision=n,o.rounding=t,e.ln()):new o(e)};w.inverseHyperbolicSine=w.asinh=function(){var n,t,e=this,o=e.constructor;return!e.isFinite()||e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+2*Math.max(Math.abs(e.e),e.sd())+6,o.rounding=1,I=!1,e=e.times(e).plus(1).sqrt().plus(e),I=!0,o.precision=n,o.rounding=t,e.ln())};w.inverseHyperbolicTangent=w.atanh=function(){var n,t,e,o,i=this,r=i.constructor;return i.isFinite()?i.e>=0?new r(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(n=r.precision,t=r.rounding,o=i.sd(),Math.max(o,n)<2*-i.e-1?A(new r(i),n,t,!0):(r.precision=e=o-i.e,i=D(i.plus(1),new r(1).minus(i),e+n,1),r.precision=n+4,r.rounding=1,i=i.ln(),r.precision=n,r.rounding=t,i.times(.5))):new r(NaN)};w.inverseSine=w.asin=function(){var n,t,e,o,i=this,r=i.constructor;return i.isZero()?new r(i):(t=i.abs().cmp(1),e=r.precision,o=r.rounding,t!==-1?t===0?(n=ae(r,e+4,o).times(.5),n.s=i.s,n):new r(NaN):(r.precision=e+6,r.rounding=1,i=i.div(new r(1).minus(i.times(i)).sqrt().plus(1)).atan(),r.precision=e,r.rounding=o,i.times(2)))};w.inverseTangent=w.atan=function(){var n,t,e,o,i,r,a,s,u,c=this,l=c.constructor,m=l.precision,d=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&m+4<=nn)return a=ae(l,m+4,d).times(.25),a.s=c.s,a}else{if(!c.s)return new l(NaN);if(m+4<=nn)return a=ae(l,m+4,d).times(.5),a.s=c.s,a}for(l.precision=s=m+10,l.rounding=1,e=Math.min(28,s/B+2|0),n=e;n;--n)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(I=!1,t=Math.ceil(s/B),o=1,u=c.times(c),a=new l(c),i=c;n!==-1;)if(i=i.times(u),r=a.minus(i.div(o+=2)),i=i.times(u),a=r.plus(i.div(o+=2)),a.d[t]!==void 0)for(n=t;a.d[n]===r.d[n]&&n--;);return e&&(a=a.times(2<<e-1)),I=!0,A(a,l.precision=m,l.rounding=d,!0)};w.isFinite=function(){return!!this.d};w.isInteger=w.isInt=function(){return!!this.d&&Q(this.e/B)>this.d.length-2};w.isNaN=function(){return!this.s};w.isNegative=w.isNeg=function(){return this.s<0};w.isPositive=w.isPos=function(){return this.s>0};w.isZero=function(){return!!this.d&&this.d[0]===0};w.lessThan=w.lt=function(n){return this.cmp(n)<0};w.lessThanOrEqualTo=w.lte=function(n){return this.cmp(n)<1};w.logarithm=w.log=function(n){var t,e,o,i,r,a,s,u,c=this,l=c.constructor,m=l.precision,d=l.rounding,p=5;if(n==null)n=new l(10),t=!0;else{if(n=new l(n),e=n.d,n.s<0||!e||!e[0]||n.eq(1))return new l(NaN);t=n.eq(10)}if(e=c.d,c.s<0||!e||!e[0]||c.eq(1))return new l(e&&!e[0]?-1/0:c.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)r=!0;else{for(i=e[0];i%10===0;)i/=10;r=i!==1}if(I=!1,s=m+p,a=Te(c,s),o=t?At(l,s+10):Te(n,s),u=D(a,o,s,1),Ze(u.d,i=m,d))do if(s+=10,a=Te(c,s),o=t?At(l,s+10):Te(n,s),u=D(a,o,s,1),!r){+Z(u.d).slice(i+1,i+15)+1==1e14&&(u=A(u,m+1,0));break}while(Ze(u.d,i+=10,d));return I=!0,A(u,m,d)};w.minus=w.sub=function(n){var t,e,o,i,r,a,s,u,c,l,m,d,p=this,h=p.constructor;if(n=new h(n),!p.d||!n.d)return!p.s||!n.s?n=new h(NaN):p.d?n.s=-n.s:n=new h(n.d||p.s!==n.s?p:NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(c=p.d,d=n.d,s=h.precision,u=h.rounding,!c[0]||!d[0]){if(d[0])n.s=-n.s;else if(c[0])n=new h(p);else return new h(u===3?-0:0);return I?A(n,s,u):n}if(e=Q(n.e/B),l=Q(p.e/B),c=c.slice(),r=l-e,r){for(m=r<0,m?(t=c,r=-r,a=d.length):(t=d,e=l,a=c.length),o=Math.max(Math.ceil(s/B),a)+2,r>o&&(r=o,t.length=1),t.reverse(),o=r;o--;)t.push(0);t.reverse()}else{for(o=c.length,a=d.length,m=o<a,m&&(a=o),o=0;o<a;o++)if(c[o]!=d[o]){m=c[o]<d[o];break}r=0}for(m&&(t=c,c=d,d=t,n.s=-n.s),a=c.length,o=d.length-a;o>0;--o)c[a++]=0;for(o=d.length;o>r;){if(c[--o]<d[o]){for(i=o;i&&c[--i]===0;)c[i]=se-1;--c[i],c[o]+=se}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=vt(c,e),I?A(n,s,u):n):new h(u===3?-0:0)};w.modulo=w.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]?A(new o(e),o.precision,o.rounding):(I=!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),I=!0,e.minus(t))};w.naturalExponential=w.exp=function(){return on(this)};w.naturalLogarithm=w.ln=function(){return Te(this)};w.negated=w.neg=function(){var n=new this.constructor(this);return n.s=-n.s,A(n)};w.plus=w.add=function(n){var t,e,o,i,r,a,s,u,c,l,m=this,d=m.constructor;if(n=new d(n),!m.d||!n.d)return!m.s||!n.s?n=new d(NaN):m.d||(n=new d(n.d||m.s===n.s?m:NaN)),n;if(m.s!=n.s)return n.s=-n.s,m.minus(n);if(c=m.d,l=n.d,s=d.precision,u=d.rounding,!c[0]||!l[0])return l[0]||(n=new d(m)),I?A(n,s,u):n;if(r=Q(m.e/B),o=Q(n.e/B),c=c.slice(),i=r-o,i){for(i<0?(e=c,i=-i,a=l.length):(e=l,o=r,a=c.length),r=Math.ceil(s/B),a=r>a?r+1:a+1,i>a&&(i=a,e.length=1),e.reverse();i--;)e.push(0);e.reverse()}for(a=c.length,i=l.length,a-i<0&&(i=a,e=l,l=c,c=e),t=0;i;)t=(c[--i]=c[i]+l[i]+t)/se|0,c[i]%=se;for(t&&(c.unshift(t),++o),a=c.length;c[--a]==0;)c.pop();return n.d=c,n.e=vt(c,o),I?A(n,s,u):n};w.precision=w.sd=function(n){var t,e=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(Pe+n);return e.d?(t=eo(e.d),n&&e.e+1>t&&(t=e.e+1)):t=NaN,t};w.round=function(){var n=this,t=n.constructor;return A(new t(n),n.e+1,t.rounding)};w.sine=w.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())+B,o.rounding=1,e=br(o,ro(o,e)),o.precision=n,o.rounding=t,A(he>2?e.neg():e,n,t,!0)):new o(NaN)};w.squareRoot=w.sqrt=function(){var n,t,e,o,i,r,a=this,s=a.d,u=a.e,c=a.s,l=a.constructor;if(c!==1||!s||!s[0])return new l(!c||c<0&&(!s||s[0])?NaN:s?a:1/0);for(I=!1,c=Math.sqrt(+a),c==0||c==1/0?(t=Z(s),(t.length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=Q((u+1)/2)-(u<0||u%2),c==1/0?t="5e"+u:(t=c.toExponential(),t=t.slice(0,t.indexOf("e")+1)+u),o=new l(t)):o=new l(c.toString()),e=(u=l.precision)+3;;)if(r=o,o=r.plus(D(a,r,e+2,1)).times(.5),Z(r.d).slice(0,e)===(t=Z(o.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!i&&t=="4999"){if(!i&&(A(r,u+1,0),r.times(r).eq(a))){o=r;break}e+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(A(o,u+1,1),n=!o.times(o).eq(a));break}return I=!0,A(o,u,l.rounding,n)};w.tangent=w.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,A(he==2||he==4?e.neg():e,n,t,!0)):new o(NaN)};w.times=w.mul=function(n){var t,e,o,i,r,a,s,u,c,l=this,m=l.constructor,d=l.d,p=(n=new m(n)).d;if(n.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?n.s/0:n.s*0);for(e=Q(l.e/B)+Q(n.e/B),u=d.length,c=p.length,u<c&&(r=d,d=p,p=r,a=u,u=c,c=a),r=[],a=u+c,o=a;o--;)r.push(0);for(o=c;--o>=0;){for(t=0,i=u+o;i>o;)s=r[i]+p[o]*d[i-o-1]+t,r[i--]=s%se|0,t=s/se|0;r[i]=(r[i]+t)%se|0}for(;!r[--a];)r.pop();return t?++e:r.shift(),n.d=r,n.e=vt(r,e),I?A(n,m.precision,m.rounding):n};w.toBinary=function(n,t){return an(this,2,n,t)};w.toDecimalPlaces=w.toDP=function(n,t){var e=this,o=e.constructor;return e=new o(e),n===void 0?e:(ne(n,0,Ae),t===void 0?t=o.rounding:ne(t,0,8),A(e,n+e.e+1,t))};w.toExponential=function(n,t){var e,o=this,i=o.constructor;return n===void 0?e=fe(o,!0):(ne(n,0,Ae),t===void 0?t=i.rounding:ne(t,0,8),o=A(new i(o),n+1,t),e=fe(o,!0,n+1)),o.isNeg()&&!o.isZero()?"-"+e:e};w.toFixed=function(n,t){var e,o,i=this,r=i.constructor;return n===void 0?e=fe(i):(ne(n,0,Ae),t===void 0?t=r.rounding:ne(t,0,8),o=A(new r(i),n+i.e+1,t),e=fe(o,!1,n+o.e+1)),i.isNeg()&&!i.isZero()?"-"+e:e};w.toFraction=function(n){var t,e,o,i,r,a,s,u,c,l,m,d,p=this,h=p.d,f=p.constructor;if(!h)return new f(p);if(c=e=new f(1),o=u=new f(0),t=new f(o),r=t.e=eo(h)-p.e-1,a=r%B,t.d[0]=H(10,a<0?B+a:a),n==null)n=r>0?t:c;else{if(s=new f(n),!s.isInt()||s.lt(c))throw Error(Pe+s);n=s.gt(t)?r>0?t:c:s}for(I=!1,s=new f(Z(h)),l=f.precision,f.precision=r=h.length*B*2;m=D(s,t,0,1,1),i=e.plus(m.times(o)),i.cmp(n)!=1;)e=o,o=i,i=c,c=u.plus(m.times(i)),u=i,i=t,t=s.minus(m.times(i)),s=i;return i=D(n.minus(e),o,0,1,1),u=u.plus(i.times(c)),e=e.plus(i.times(o)),u.s=c.s=p.s,d=D(c,o,r,1).minus(p).abs().cmp(D(u,e,r,1).minus(p).abs())<1?[c,o]:[u,e],f.precision=l,I=!0,d};w.toHexadecimal=w.toHex=function(n,t){return an(this,16,n,t)};w.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:ne(t,0,8),!e.d)return n.s?e:n;if(!n.d)return n.s&&(n.s=e.s),n}return n.d[0]?(I=!1,e=D(e,n,0,t,1).times(n),I=!0,A(e)):(n.s=e.s,e=n),e};w.toNumber=function(){return+this};w.toOctal=function(n,t){return an(this,8,n,t)};w.toPower=w.pow=function(n){var t,e,o,i,r,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(H(+s,c));if(s=new u(s),s.eq(1))return s;if(o=u.precision,r=u.rounding,n.eq(1))return A(s,o,r);if(t=Q(n.e/B),t>=n.d.length-1&&(e=c<0?-c:c)<=fr)return i=to(u,s,e,o),n.s<0?new u(1).div(i):A(i,o,r);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=H(+s,c),t=e==0||!isFinite(e)?Q(c*(Math.log("0."+Z(s.d))/Math.LN10+s.e+1)):new u(e+"").e,t>u.maxE+1||t<u.minE-1?new u(t>0?a/0:0):(I=!1,u.rounding=s.s=1,e=Math.min(12,(t+"").length),i=on(n.times(Te(s,o+e)),o),i.d&&(i=A(i,o+5,1),Ze(i.d,o,r)&&(t=o+10,i=A(on(n.times(Te(s,t+e)),t),t+5,1),+Z(i.d).slice(o+1,o+15)+1==1e14&&(i=A(i,o+1,0)))),i.s=a,I=!0,u.rounding=r,A(i,o,r))};w.toPrecision=function(n,t){var e,o=this,i=o.constructor;return n===void 0?e=fe(o,o.e<=i.toExpNeg||o.e>=i.toExpPos):(ne(n,1,Ae),t===void 0?t=i.rounding:ne(t,0,8),o=A(new i(o),n,t),e=fe(o,n<=o.e||o.e<=i.toExpNeg,n)),o.isNeg()&&!o.isZero()?"-"+e:e};w.toSignificantDigits=w.toSD=function(n,t){var e=this,o=e.constructor;return n===void 0?(n=o.precision,t=o.rounding):(ne(n,1,Ae),t===void 0?t=o.rounding:ne(t,0,8)),A(new o(e),n,t)};w.toString=function(){var n=this,t=n.constructor,e=fe(n,n.e<=t.toExpNeg||n.e>=t.toExpPos);return n.isNeg()&&!n.isZero()?"-"+e:e};w.truncated=w.trunc=function(){return A(new this.constructor(this),this.e+1,1)};w.valueOf=w.toJSON=function(){var n=this,t=n.constructor,e=fe(n,n.e<=t.toExpNeg||n.e>=t.toExpPos);return n.isNeg()?"-"+e:e};function Z(n){var t,e,o,i=n.length-1,r="",a=n[0];if(i>0){for(r+=a,t=1;t<i;t++)o=n[t]+"",e=B-o.length,e&&(r+=_e(e)),r+=o;a=n[t],o=a+"",e=B-o.length,e&&(r+=_e(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return r+a}function ne(n,t,e){if(n!==~~n||n<t||n>e)throw Error(Pe+n)}function Ze(n,t,e,o){var i,r,a,s;for(r=n[0];r>=10;r/=10)--t;return--t<0?(t+=B,i=0):(i=Math.ceil((t+1)/B),t%=B),r=H(10,B-t),s=n[i]%r|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==r||e>3&&s+1==r/2)&&(n[i+1]/r/100|0)==H(10,t-2)-1||(s==r/2||s==0)&&(n[i+1]/r/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==r||!o&&e>3&&s+1==r/2)&&(n[i+1]/r/1e3|0)==H(10,t-3)-1,a}function _t(n,t,e){for(var o,i=[0],r,a=0,s=n.length;a<s;){for(r=i.length;r--;)i[r]*=t;for(i[0]+=en.indexOf(n.charAt(a++)),o=0;o<i.length;o++)i[o]>e-1&&(i[o+1]===void 0&&(i[o+1]=0),i[o+1]+=i[o]/e|0,i[o]%=e)}return i.reverse()}function hr(n,t){var e,o,i;if(t.isZero())return t;o=t.d.length,o<32?(e=Math.ceil(o/3),i=(1/St(4,e)).toString()):(e=16,i="2.3283064365386962890625e-10"),n.precision+=e,t=Ee(n,1,t.times(i),new n(1));for(var r=e;r--;){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,i,r){var a,s=0,u=o.length;for(o=o.slice();u--;)a=o[u]*i+s,o[u]=a%r|0,s=a/r|0;return s&&o.unshift(s),o}function t(o,i,r,a){var s,u;if(r!=a)u=r>a?1:-1;else for(s=u=0;s<r;s++)if(o[s]!=i[s]){u=o[s]>i[s]?1:-1;break}return u}function e(o,i,r,a){for(var s=0;r--;)o[r]-=s,s=o[r]<i[r]?1:0,o[r]=s*a+o[r]-i[r];for(;!o[0]&&o.length>1;)o.shift()}return function(o,i,r,a,s,u){var c,l,m,d,p,h,f,k,y,b,g,_,P,x,v,C,M,F,N,X,z=o.constructor,$=o.s==i.s?1:-1,O=o.d,L=i.d;if(!O||!O[0]||!L||!L[0])return new z(!o.s||!i.s||(O?L&&O[0]==L[0]:!L)?NaN:O&&O[0]==0||!L?$*0:$/0);for(u?(p=1,l=o.e-i.e):(u=se,p=B,l=Q(o.e/p)-Q(i.e/p)),N=L.length,M=O.length,y=new z($),b=y.d=[],m=0;L[m]==(O[m]||0);m++);if(L[m]>(O[m]||0)&&l--,r==null?(x=r=z.precision,a=z.rounding):s?x=r+(o.e-i.e)+1:x=r,x<0)b.push(1),h=!0;else{if(x=x/p+2|0,m=0,N==1){for(d=0,L=L[0],x++;(m<M||d)&&x--;m++)v=d*u+(O[m]||0),b[m]=v/L|0,d=v%L|0;h=d||m<M}else{for(d=u/(L[0]+1)|0,d>1&&(L=n(L,d,u),O=n(O,d,u),N=L.length,M=O.length),C=N,g=O.slice(0,N),_=g.length;_<N;)g[_++]=0;X=L.slice(),X.unshift(0),F=L[0],L[1]>=u/2&&++F;do d=0,c=t(L,g,N,_),c<0?(P=g[0],N!=_&&(P=P*u+(g[1]||0)),d=P/F|0,d>1?(d>=u&&(d=u-1),f=n(L,d,u),k=f.length,_=g.length,c=t(f,g,k,_),c==1&&(d--,e(f,N<k?X:L,k,u))):(d==0&&(c=d=1),f=L.slice()),k=f.length,k<_&&f.unshift(0),e(g,f,_,u),c==-1&&(_=g.length,c=t(L,g,N,_),c<1&&(d++,e(g,N<_?X:L,_,u))),_=g.length):c===0&&(d++,g=[0]),b[m++]=d,c&&g[0]?g[_++]=O[C]||0:(g=[O[C]],_=1);while((C++<M||g[0]!==void 0)&&x--);h=g[0]!==void 0}b[0]||b.shift()}if(p==1)y.e=l,Xn=h;else{for(m=1,d=b[0];d>=10;d/=10)m++;y.e=m+l*p-1,A(y,s?r+y.e+1:r,a,h)}return y}}();function A(n,t,e,o){var i,r,a,s,u,c,l,m,d,p=n.constructor;e:if(t!=null){if(m=n.d,!m)return n;for(i=1,s=m[0];s>=10;s/=10)i++;if(r=t-i,r<0)r+=B,a=t,l=m[d=0],u=l/H(10,i-a-1)%10|0;else if(d=Math.ceil((r+1)/B),s=m.length,d>=s)if(o){for(;s++<=d;)m.push(0);l=u=0,i=1,r%=B,a=r-B+1}else break e;else{for(l=s=m[d],i=1;s>=10;s/=10)i++;r%=B,a=r-B+i,u=a<0?0:l/H(10,i-a-1)%10|0}if(o=o||t<0||m[d+1]!==void 0||(a<0?l:l%H(10,i-a-1)),c=e<4?(u||o)&&(e==0||e==(n.s<0?3:2)):u>5||u==5&&(e==4||o||e==6&&(r>0?a>0?l/H(10,i-a):0:m[d-1])%10&1||e==(n.s<0?8:7)),t<1||!m[0])return m.length=0,c?(t-=n.e+1,m[0]=H(10,(B-t%B)%B),n.e=-t||0):m[0]=n.e=0,n;if(r==0?(m.length=d,s=1,d--):(m.length=d+1,s=H(10,B-r),m[d]=a>0?(l/H(10,i-a)%H(10,a)|0)*s:0),c)for(;;)if(d==0){for(r=1,a=m[0];a>=10;a/=10)r++;for(a=m[0]+=s,s=1;a>=10;a/=10)s++;r!=s&&(n.e++,m[0]==se&&(m[0]=1));break}else{if(m[d]+=s,m[d]!=se)break;m[d--]=0,s=1}for(r=m.length;m[--r]===0;)m.pop()}return I&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function fe(n,t,e){if(!n.isFinite())return oo(n);var o,i=n.e,r=Z(n.d),a=r.length;return t?(e&&(o=e-a)>0?r=r.charAt(0)+"."+r.slice(1)+_e(o):a>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(n.e<0?"e":"e+")+n.e):i<0?(r="0."+_e(-i-1)+r,e&&(o=e-a)>0&&(r+=_e(o))):i>=a?(r+=_e(i+1-a),e&&(o=e-i-1)>0&&(r=r+"."+_e(o))):((o=i+1)<a&&(r=r.slice(0,o)+"."+r.slice(o)),e&&(o=e-a)>0&&(i+1===a&&(r+="."),r+=_e(o))),r}function vt(n,t){var e=n[0];for(t*=B;e>=10;e/=10)t++;return t}function At(n,t,e){if(t>gr)throw I=!0,e&&(n.precision=e),Error(Jn);return A(new n(Tt),t,1,!0)}function ae(n,t,e){if(t>nn)throw Error(Jn);return A(new n(Pt),t,e,!0)}function eo(n){var t=n.length-1,e=t*B+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 _e(n){for(var t="";n--;)t+="0";return t}function to(n,t,e,o){var i,r=new n(1),a=Math.ceil(o/B+4);for(I=!1;;){if(e%2&&(r=r.times(t),jn(r.d,a)&&(i=!0)),e=Q(e/2),e===0){e=r.d.length-1,i&&r.d[e]===0&&++r.d[e];break}t=t.times(t),jn(t.d,a)}return I=!0,r}function zn(n){return n.d[n.d.length-1]&1}function no(n,t,e){for(var o,i=new n(t[0]),r=0;++r<t.length;)if(o=new n(t[r]),o.s)i[e](o)&&(i=o);else{i=o;break}return i}function on(n,t){var e,o,i,r,a,s,u,c=0,l=0,m=0,d=n.constructor,p=d.rounding,h=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:0/0);for(t==null?(I=!1,u=h):u=t,s=new d(.03125);n.e>-2;)n=n.times(s),m+=5;for(o=Math.log(H(2,m))/Math.LN10*2+5|0,u+=o,e=r=a=new d(1),d.precision=u;;){if(r=A(r.times(n),u,1),e=e.times(++l),s=a.plus(D(r,e,u,1)),Z(s.d).slice(0,u)===Z(a.d).slice(0,u)){for(i=m;i--;)a=A(a.times(a),u,1);if(t==null)if(c<3&&Ze(a.d,u-o,p,c))d.precision=u+=10,e=r=s=new d(1),l=0,c++;else return A(a,d.precision=h,p,I=!0);else return d.precision=h,a}a=s}}function Te(n,t){var e,o,i,r,a,s,u,c,l,m,d,p=1,h=10,f=n,k=f.d,y=f.constructor,b=y.rounding,g=y.precision;if(f.s<0||!k||!k[0]||!f.e&&k[0]==1&&k.length==1)return new y(k&&!k[0]?-1/0:f.s!=1?NaN:k?0:f);if(t==null?(I=!1,l=g):l=t,y.precision=l+=h,e=Z(k),o=e.charAt(0),Math.abs(r=f.e)<15e14){for(;o<7&&o!=1||o==1&&e.charAt(1)>3;)f=f.times(n),e=Z(f.d),o=e.charAt(0),p++;r=f.e,o>1?(f=new y("0."+e),r++):f=new y(o+"."+e.slice(1))}else return c=At(y,l+2,g).times(r+""),f=Te(new y(o+"."+e.slice(1)),l-h).plus(c),y.precision=g,t==null?A(f,g,b,I=!0):f;for(m=f,u=a=f=D(f.minus(1),f.plus(1),l,1),d=A(f.times(f),l,1),i=3;;){if(a=A(a.times(d),l,1),c=u.plus(D(a,new y(i),l,1)),Z(c.d).slice(0,l)===Z(u.d).slice(0,l))if(u=u.times(2),r!==0&&(u=u.plus(At(y,l+2,g).times(r+""))),u=D(u,new y(p),l,1),t==null)if(Ze(u.d,l-h,b,s))y.precision=l+=h,c=a=f=D(m.minus(1),m.plus(1),l,1),d=A(f.times(f),l,1),i=s=1;else return A(u,y.precision=g,b,I=!0);else return y.precision=g,u;u=c,i+=2}}function oo(n){return String(n.s*n.s/0)}function rn(n,t){var e,o,i;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(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(o,i),t){if(i-=o,n.e=e=e-o-1,n.d=[],o=(e+1)%B,e<0&&(o+=B),o<i){for(o&&n.d.push(+t.slice(0,o)),i-=B;o<i;)n.d.push(+t.slice(o,o+=B));t=t.slice(o),o=B-t.length}else o-=i;for(;o--;)t+="0";n.d.push(+t),I&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function yr(n,t){var e,o,i,r,a,s,u,c,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),$n.test(t))return rn(n,t)}else if(t==="Infinity"||t==="NaN")return+t||(n.s=NaN),n.e=NaN,n.d=null,n;if(dr.test(t))e=16,t=t.toLowerCase();else if(lr.test(t))e=2;else if(pr.test(t))e=8;else throw Error(Pe+t);for(r=t.search(/p/i),r>0?(u=+t.slice(r+1),t=t.substring(2,r)):t=t.slice(2),r=t.indexOf("."),a=r>=0,o=n.constructor,a&&(t=t.replace(".",""),s=t.length,r=s-r,i=to(o,new o(e),r,r*2)),c=_t(t,e,se),l=c.length-1,r=l;c[r]===0;--r)c.pop();return r<0?new o(n.s*0):(n.e=vt(c,l),n.d=c,I=!1,a&&(n=D(n,i,s*4)),u&&(n=n.times(Math.abs(u)<54?H(2,u):Xe.pow(2,u))),I=!0,n)}function br(n,t){var e,o=t.d.length;if(o<3)return t.isZero()?t:Ee(n,2,t,t);e=1.4*Math.sqrt(o),e=e>16?16:e|0,t=t.times(1/St(5,e)),t=Ee(n,2,t,t);for(var i,r=new n(5),a=new n(16),s=new n(20);e--;)i=t.times(t),t=t.times(r.plus(i.times(a.times(i).minus(s))));return t}function Ee(n,t,e,o,i){var r,a,s,u,c=1,l=n.precision,m=Math.ceil(l/B);for(I=!1,u=e.times(e),s=new n(o);;){if(a=D(s.times(u),new n(t++*t++),l,1),s=i?o.plus(a):o.minus(a),o=D(a.times(u),new n(t++*t++),l,1),a=s.plus(o),a.d[m]!==void 0){for(r=m;a.d[r]===s.d[r]&&r--;);if(r==-1)break}r=s,s=o,o=a,a=r,c++}return I=!0,a.d.length=m+1,a}function St(n,t){for(var e=n;--t;)e*=n;return e}function ro(n,t){var e,o=t.s<0,i=ae(n,n.precision,1),r=i.times(.5);if(t=t.abs(),t.lte(r))return he=o?4:1,t;if(e=t.divToInt(i),e.isZero())he=o?3:2;else{if(t=t.minus(e.times(i)),t.lte(r))return he=zn(e)?o?2:3:o?4:1,t;he=zn(e)?o?1:4:o?3:2}return t.minus(i).abs()}function an(n,t,e,o){var i,r,a,s,u,c,l,m,d,p=n.constructor,h=e!==void 0;if(h?(ne(e,1,Ae),o===void 0?o=p.rounding:ne(o,0,8)):(e=p.precision,o=p.rounding),!n.isFinite())l=oo(n);else{for(l=fe(n),a=l.indexOf("."),h?(i=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):i=t,a>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-a,d.d=_t(fe(d),10,i),d.e=d.d.length),m=_t(l,10,i),r=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=h?"0p+0":"0";else{if(a<0?r--:(n=new p(n),n.d=m,n.e=r,n=D(n,d,e,o,0,i),m=n.d,r=n.e,c=Xn),a=m[e],s=i/2,c=c||m[e+1]!==void 0,c=o<4?(a!==void 0||c)&&(o===0||o===(n.s<0?3:2)):a>s||a===s&&(o===4||c||o===6&&m[e-1]&1||o===(n.s<0?8:7)),m.length=e,c)for(;++m[--e]>i-1;)m[e]=0,e||(++r,m.unshift(1));for(u=m.length;!m[u-1];--u);for(a=0,l="";a<u;a++)l+=en.charAt(m[a]);if(h){if(u>1)if(t==16||t==8){for(a=t==16?4:3,--u;u%a;u++)l+="0";for(m=_t(l,i,t),u=m.length;!m[u-1];--u);for(a=1,l="1.";a<u;a++)l+=en.charAt(m[a])}else l=l.charAt(0)+"."+l.slice(1);l=l+(r<0?"p":"p+")+r}else if(r<0){for(;++r;)l="0"+l;l="0."+l}else if(++r>u)for(r-=u;r--;)l+="0";else r<u&&(l=l.slice(0,r)+"."+l.slice(r))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return n.s<0?"-"+l:l}function jn(n,t){if(n.length>t)return n.length=t,!0}function wr(n){return new this(n).abs()}function kr(n){return new this(n).acos()}function _r(n){return new this(n).acosh()}function Tr(n,t){return new this(n).plus(t)}function Pr(n){return new this(n).asin()}function Ar(n){return new this(n).asinh()}function xr(n){return new this(n).atan()}function vr(n){return new this(n).atanh()}function Sr(n,t){n=new this(n),t=new this(t);var e,o=this.precision,i=this.rounding,r=o+4;return!n.s||!t.s?e=new this(NaN):!n.d&&!t.d?(e=ae(this,r,1).times(t.s>0?.25:.75),e.s=n.s):!t.d||n.isZero()?(e=t.s<0?ae(this,o,i):new this(0),e.s=n.s):!n.d||t.isZero()?(e=ae(this,r,1).times(.5),e.s=n.s):t.s<0?(this.precision=r,this.rounding=1,e=this.atan(D(n,t,r,1)),t=ae(this,r,1),this.precision=o,this.rounding=i,e=n.s<0?e.minus(t):e.plus(t)):e=this.atan(D(n,t,r,1)),e}function Br(n){return new this(n).cbrt()}function Cr(n){return A(n=new this(n),n.e+1,2)}function Ir(n,t,e){return new this(n).clamp(t,e)}function Mr(n){if(!n||typeof n!="object")throw Error(xt+"Object expected");var t,e,o,i=n.defaults===!0,r=["precision",1,Ae,"rounding",0,8,"toExpNeg",-Oe,0,"toExpPos",0,Oe,"maxE",0,Oe,"minE",-Oe,0,"modulo",0,9];for(t=0;t<r.length;t+=3)if(e=r[t],i&&(this[e]=tn[e]),(o=n[e])!==void 0)if(Q(o)===o&&o>=r[t+1]&&o<=r[t+2])this[e]=o;else throw Error(Pe+e+": "+o);if(e="crypto",i&&(this[e]=tn[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(Qn);else this[e]=!1;else throw Error(Pe+e+": "+o);return this}function Kr(n){return new this(n).cos()}function Lr(n){return new this(n).cosh()}function io(n){var t,e,o;function i(r){var a,s,u,c=this;if(!(c instanceof i))return new i(r);if(c.constructor=i,Zn(r)){c.s=r.s,I?!r.d||r.e>i.maxE?(c.e=NaN,c.d=null):r.e<i.minE?(c.e=0,c.d=[0]):(c.e=r.e,c.d=r.d.slice()):(c.e=r.e,c.d=r.d?r.d.slice():r.d);return}if(u=typeof r,u==="number"){if(r===0){c.s=1/r<0?-1:1,c.e=0,c.d=[0];return}if(r<0?(r=-r,c.s=-1):c.s=1,r===~~r&&r<1e7){for(a=0,s=r;s>=10;s/=10)a++;I?a>i.maxE?(c.e=NaN,c.d=null):a<i.minE?(c.e=0,c.d=[0]):(c.e=a,c.d=[r]):(c.e=a,c.d=[r]);return}else if(r*0!==0){r||(c.s=NaN),c.e=NaN,c.d=null;return}return rn(c,r.toString())}else if(u!=="string")throw Error(Pe+r);return(s=r.charCodeAt(0))===45?(r=r.slice(1),c.s=-1):(s===43&&(r=r.slice(1)),c.s=1),$n.test(r)?rn(c,r):yr(c,r)}if(i.prototype=w,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=Mr,i.clone=io,i.isDecimal=Zn,i.abs=wr,i.acos=kr,i.acosh=_r,i.add=Tr,i.asin=Pr,i.asinh=Ar,i.atan=xr,i.atanh=vr,i.atan2=Sr,i.cbrt=Br,i.ceil=Cr,i.clamp=Ir,i.cos=Kr,i.cosh=Lr,i.div=Nr,i.exp=Rr,i.floor=Or,i.hypot=Er,i.ln=Dr,i.log=Fr,i.log10=Ur,i.log2=qr,i.max=Wr,i.min=Vr,i.mod=Gr,i.mul=Hr,i.pow=zr,i.random=jr,i.round=Zr,i.sign=Xr,i.sin=Jr,i.sinh=Qr,i.sqrt=Yr,i.sub=$r,i.sum=ei,i.tan=ti,i.tanh=ni,i.trunc=oi,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 i.config(n),i}function Nr(n,t){return new this(n).div(t)}function Rr(n){return new this(n).exp()}function Or(n){return A(n=new this(n),n.e+1,3)}function Er(){var n,t,e=new this(0);for(I=!1,n=0;n<arguments.length;)if(t=new this(arguments[n++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return I=!0,new this(1/0);e=t}return I=!0,e.sqrt()}function Zn(n){return n instanceof Xe||n&&n.toStringTag===Yn||!1}function Dr(n){return new this(n).ln()}function Fr(n,t){return new this(n).log(t)}function qr(n){return new this(n).log(2)}function Ur(n){return new this(n).log(10)}function Wr(){return no(this,arguments,"lt")}function Vr(){return no(this,arguments,"gt")}function Gr(n,t){return new this(n).mod(t)}function Hr(n,t){return new this(n).mul(t)}function zr(n,t){return new this(n).pow(t)}function jr(n){var t,e,o,i,r=0,a=new this(1),s=[];if(n===void 0?n=this.precision:ne(n,1,Ae),o=Math.ceil(n/B),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(o));r<o;)i=t[r],i>=429e7?t[r]=crypto.getRandomValues(new Uint32Array(1))[0]:s[r++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(o*=4);r<o;)i=t[r]+(t[r+1]<<8)+(t[r+2]<<16)+((t[r+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,r):(s.push(i%1e7),r+=4);r=o/4}else throw Error(Qn);else for(;r<o;)s[r++]=Math.random()*1e7|0;for(o=s[--r],n%=B,o&&n&&(i=H(10,B-n),s[r]=(o/i|0)*i);s[r]===0;r--)s.pop();if(r<0)e=0,s=[0];else{for(e=-1;s[0]===0;e-=B)s.shift();for(o=1,i=s[0];i>=10;i/=10)o++;o<B&&(e-=B-o)}return a.e=e,a.d=s,a}function Zr(n){return A(n=new this(n),n.e+1,this.rounding)}function Xr(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function Jr(n){return new this(n).sin()}function Qr(n){return new this(n).sinh()}function Yr(n){return new this(n).sqrt()}function $r(n,t){return new this(n).sub(t)}function ei(){var n=0,t=arguments,e=new this(t[n]);for(I=!1;e.s&&++n<t.length;)e=e.plus(t[n]);return I=!0,A(e,this.precision,this.rounding)}function ti(n){return new this(n).tan()}function ni(n){return new this(n).tanh()}function oi(n){return A(n=new this(n),n.e+1,1)}w[Symbol.for("nodejs.util.inspect.custom")]=w.toString;w[Symbol.toStringTag]="Decimal";var Xe=w.constructor=io(tn);Tt=new Xe(Tt);Pt=new Xe(Pt);var te=Xe;var E=require("@solana/web3.js"),mo=W(require("axios"));var U={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",CpmmInitUserLiquidity:"CpmmInitUserLiquidity",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmOracleSwapBaseIn:"CpmmOracleSwapBaseIn"};var Y=require("@solana/web3.js"),so=require("@solana/spl-token");var ao=V("Gfx_txUtil"),uo=1644;function Bt(n){let t=[],e=[];return n.microLamports&&(t.push(Y.ComputeBudgetProgram.setComputeUnitPrice({microLamports:n.microLamports})),e.push(U.SetComputeUnitPrice)),n.units&&(t.push(Y.ComputeBudgetProgram.setComputeUnitLimit({units:n.units})),e.push(U.SetComputeUnitLimit)),{instructions:t,instructionTypes:e}}async function De(n,t){var o,i;let e=t!=null?t:"confirmed";try{return((i=await((o=n.getLatestBlockhash)==null?void 0:o.call(n,{commitment:e})))==null?void 0:i.blockhash)||(await n.getRecentBlockhash(e)).blockhash}catch{return(await n.getRecentBlockhash(e)).blockhash}}function ii(n,t){n.length<1&&ao.logWithError(`no instructions provided: ${n.toString()}`),t.length<1&&ao.logWithError(`no signers provided:, ${t.toString()}`);let e=new Y.Transaction;e.recentBlockhash="11111111111111111111111111111111",e.feePayer=t[0],e.add(...n);try{return e.serialize({verifySignatures:!1}).toString("base64").length<uo}catch{return!1}}function ye(n,t){let[e,o]=Y.PublicKey.findProgramAddressSync(n,t);return{publicKey:e,nonce:o}}function Je({instructions:n,payer:t,signers:e}){return ii(n,[t,...e])}function Qe({instructions:n,payer:t,lookupTableAddressAccount:e,recentBlockhash:o=Y.Keypair.generate().publicKey.toString()}){let r=new Y.TransactionMessage({payerKey:t,recentBlockhash:o,instructions:n}).compileToV0Message(Object.values(e!=null?e:{}));try{return Buffer.from(new Y.VersionedTransaction(r).serialize()).toString("base64").length<uo}catch{return!1}}var ai=n=>Buffer.isBuffer(n)?n:n instanceof Uint8Array?Buffer.from(n.buffer,n.byteOffset,n.byteLength):Buffer.from(n);function Me(n){let t=[];return n.forEach(e=>{e instanceof Y.Transaction&&(e.recentBlockhash||(e.recentBlockhash=so.TOKEN_PROGRAM_ID.toBase58()),e.feePayer||(e.feePayer=Y.Keypair.generate().publicKey));let o=e.serialize({requireAllSignatures:!1,verifySignatures:!1});e instanceof Y.VersionedTransaction&&(o=ai(o));let i=o.toString("base64");t.push(i)}),console.log("simulate tx string:",t),t}var ve=require("@solana/web3.js");var cn=require("@solana/web3.js"),xe=require("@solana/spl-token");var sn=V("Gfx_accountInfo_util");async function mn(n,t,e){let{batchRequest:o,commitment:i="confirmed",chunkCount:r=100}={batchRequest:!1,...e},a=un(t,r),s=new Array(a.length).fill([]);if(o){let u=a.map(m=>{let d=n._buildArgs([m.map(p=>p.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=un(u,10);s=(await(await Promise.all(c.map(async m=>await n._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&sn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:h,lamports:f,owner:k,rentEpoch:y}=d;return p.length!==2&&p[1]!=="base64"&&sn.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:h,lamports:f,owner:new cn.PublicKey(k),rentEpoch:y}}return null})))}else try{s=await Promise.all(a.map(u=>n.getMultipleAccountsInfo(u,i)))}catch(u){u instanceof Error&&sn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return s.flat()}async function si(n,t,e){let o=await mn(n,t.map(i=>i.pubkey),e);return t.map((i,r)=>({...i,accountInfo:o[r]}))}async function co({connection:n,mints:t,config:e}){var r,a,s;if(t.length===0)return{};let o=await si(n,t.map(u=>({pubkey:Ce(u)})),e),i={};for(let u of o){if(!u.accountInfo||u.accountInfo.data.length<xe.MINT_SIZE){console.log("invalid mint account",u.pubkey.toBase58());continue}let c=(0,xe.unpackMint)(u.pubkey,u.accountInfo,(r=u.accountInfo)==null?void 0:r.owner);i[u.pubkey.toString()]={...c,programId:((a=u.accountInfo)==null?void 0:a.owner)||xe.TOKEN_PROGRAM_ID,feeConfig:(s=(0,xe.getTransferFeeConfig)(c))!=null?s:void 0}}return i[cn.PublicKey.default.toBase58()]=i[J.toBase58()],i}async function ln({connection:n,address:t}){let e=await mn(n,[...new Set(t.map(i=>i.toString()))].map(i=>new ve.PublicKey(i))),o={};for(let i=0;i<t.length;i++){let r=e[i],a=t[i];if(!r)continue;let s=new ve.AddressLookupTableAccount({key:a,state:ve.AddressLookupTableAccount.deserialize(new Uint8Array(r.data))});o[a.toString()]=s,Ct[a.toString()]=s}return o}var Ct={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new ve.AddressLookupTableAccount({key:new ve.PublicKey("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:ve.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 It=class{constructor(t){this.instructions=[];this.endInstructions=[];this.lookupTableAddress=[];this.signers=[];this.instructionTypes=[];this.endInstructionTypes=[];this.connection=t.connection,this.feePayer=t.feePayer,this.signAllTransactions=t.signAllTransactions,this.owner=t.owner,this.cluster=t.cluster,this.blockhashCommitment=t.blockhashCommitment,this.api=t.api}get AllTxData(){return{instructions:this.instructions,endInstructions:this.endInstructions,signers:this.signers,instructionTypes:this.instructionTypes,endInstructionTypes:this.endInstructionTypes,lookupTableAddress:this.lookupTableAddress}}get allInstructions(){return[...this.instructions,...this.endInstructions]}async getComputeBudgetConfig(){var o;let t=(await mo.default.get(`https://solanacompass.com/api/fees?cacheFreshTime=${3e5}`)).data,{avg:e}=(o=t==null?void 0:t[15])!=null?o:{};if(!!e)return{units:6e5,microLamports:Math.min(Math.ceil(e*1e6/6e5),25e3)}}addCustomComputeBudget(t){if(t){let{instructions:e,instructionTypes:o}=Bt(t);return this.instructions.unshift(...e),this.instructionTypes.unshift(...o),!0}return!1}async calComputeBudget({config:t,defaultIns:e}){try{let o=t||await this.getComputeBudgetConfig();if(this.addCustomComputeBudget(o))return;e&&this.instructions.unshift(...e)}catch{e&&this.instructions.unshift(...e)}}addInstruction({instructions:t=[],endInstructions:e=[],signers:o=[],instructionTypes:i=[],endInstructionTypes:r=[],lookupTableAddress:a=[]}){return this.instructions.push(...t),this.endInstructions.push(...e),this.signers.push(...o),this.instructionTypes.push(...i),this.endInstructionTypes.push(...r),this.lookupTableAddress.push(...a.filter(s=>s!==E.PublicKey.default.toString())),this}async versionBuild({txVersion:t,extInfo:e}){return t===0?await this.buildV0({...e||{}}):this.build(e)}build(t){var o;let e=new E.Transaction;return this.allInstructions.length&&e.add(...this.allInstructions),e.feePayer=this.feePayer,((o=this.owner)==null?void 0:o.signer)&&!this.signers.some(i=>i.publicKey.equals(this.owner.publicKey))&&this.signers.push(this.owner.signer),{builder:this,transaction:e,signers:this.signers,instructionTypes:[...this.instructionTypes,...this.endInstructionTypes],execute:async i=>{var c;let{recentBlockHash:r,skipPreflight:a=!0,sendAndConfirm:s}=i||{},u=r!=null?r:await De(this.connection,this.blockhashCommitment);if(e.recentBlockhash=u,this.signers.length&&e.sign(...this.signers),Me([e]),(c=this.owner)!=null&&c.isKeyPair)return{txId:s?await(0,E.sendAndConfirmTransaction)(this.connection,e,this.signers.find(m=>m.publicKey.equals(this.owner.publicKey))?this.signers:[...this.signers,this.owner.signer],{skipPreflight:a}):await this.connection.sendRawTransaction(e.serialize(),{skipPreflight:a}),signedTx:e};if(this.signAllTransactions){let l=await this.signAllTransactions([e]);return{txId:await this.connection.sendRawTransaction(l[0].serialize(),{skipPreflight:a}),signedTx:l[0]}}throw new Error("please provide owner in keypair format or signAllTransactions function")},extInfo:t||{}}}buildMultiTx(t){var c;let{extraPreBuildData:e=[],extInfo:o}=t,{transaction:i}=this.build(o),r=e.filter(l=>l.transaction.instructions.length>0),a=[i,...r.map(l=>l.transaction)],s=[this.signers,...r.map(l=>l.signers)],u=[...this.instructionTypes,...r.map(l=>l.instructionTypes).flat()];return(c=this.owner)!=null&&c.signer&&s.forEach(l=>{l.some(m=>m.publicKey.equals(this.owner.publicKey))||this.signers.push(this.owner.signer)}),{builder:this,transactions:a,signers:s,instructionTypes:u,execute:async l=>{var k;let{sequentially:m,onTxUpdate:d,recentBlockHash:p,skipPreflight:h=!0}=l||{},f=p!=null?p:await De(this.connection,this.blockhashCommitment);if((k=this.owner)!=null&&k.isKeyPair){if(m){let y=[];for(let b of a