raydium-sdk-v2-custody
Version:
An SDK for building applications on top of Raydium.
1 lines • 389 kB
JavaScript
var Ic=Object.defineProperty,Bc=Object.defineProperties;var xc=Object.getOwnPropertyDescriptors;var no=Object.getOwnPropertySymbols;var Xs=Object.prototype.hasOwnProperty,zs=Object.prototype.propertyIsEnumerable;var Gs=(r,t,e)=>t in r?Ic(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M=(r,t)=>{for(var e in t||(t={}))Xs.call(t,e)&&Gs(r,e,t[e]);if(no)for(var e of no(t))zs.call(t,e)&&Gs(r,e,t[e]);return r},U=(r,t)=>Bc(r,xc(t));var Ue=(r,t)=>{var e={};for(var n in r)Xs.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&no)for(var n of no(r))t.indexOf(n)<0&&zs.call(r,n)&&(e[n]=r[n]);return e};import{merge as hp}from"lodash";import Ma from"axios";import{PublicKey as Hs}from"@solana/web3.js";import{get as Qs,set as Sc}from"lodash";var br=class{constructor(t){this.logLevel=t.logLevel!==void 0?t.logLevel:0,this.name=t.name}set level(t){this.logLevel=t}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(t){return t<=this.logLevel}error(...t){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...t),this):this}logWithError(...t){let e=t.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(e)}warning(...t){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...t),this):this}info(...t){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...t),this):this}debug(...t){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...t),this):this}},Ys={},Kc={};function pe(r){let t=Qs(Ys,r);if(!t){let e=Qs(Kc,r);t=new br({name:r,logLevel:e}),Sc(Ys,r,t)}return t}import{MINT_SIZE as Cc,TOKEN_PROGRAM_ID as Lc,getTransferFeeConfig as Rc,unpackMint as Oc}from"@solana/spl-token";var gr=pe("Raydium_accountInfo_util");async function Vt(r,t,e){let{batchRequest:n,commitment:i="confirmed",chunkCount:o=100}=M({batchRequest:!1},e),s=Pr(t,o),a=new Array(s.length).fill([]);if(n){let c=s.map(m=>{let d=r._buildArgs([m.map(p=>p.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:d}}),u=Pr(c,10);a=(await(await Promise.all(u.map(async m=>await r._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&gr.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:f,lamports:y,owner:b,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&gr.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:f,lamports:y,owner:new Hs(b),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(c=>r.getMultipleAccountsInfo(c,i)))}catch(c){c instanceof Error&&gr.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function ze(r,t,e){let n=await Vt(r,t.map(i=>i.pubkey),e);return t.map((i,o)=>U(M({},i),{accountInfo:n[o]}))}async function Gn({connection:r,mints:t,config:e}){var o,s,a;if(t.length===0)return{};let n=await ze(r,t.map(c=>({pubkey:st(c)})),e),i={};for(let c of n){if(!c.accountInfo||c.accountInfo.data.length<Cc){console.log("invalid mint account",c.pubkey.toBase58());continue}let u=Oc(c.pubkey,c.accountInfo,(o=c.accountInfo)==null?void 0:o.owner);i[c.pubkey.toString()]=U(M({},u),{programId:((s=c.accountInfo)==null?void 0:s.owner)||Lc,feeConfig:(a=Rc(u))!=null?a:void 0})}return i[Hs.default.toBase58()]=i[Z.toBase58()],i}import Jt from"bn.js";var Xn=9e15,dn=1e9,wr="0123456789abcdef",oo="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ro="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ar={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Xn,maxE:Xn,crypto:!1},Js,Zt,ae=!0,ao="[DecimalError] ",mn=ao+"Invalid argument: ",ea=ao+"Precision limit exceeded",ta=ao+"crypto unavailable",na="[object Decimal]",at=Math.floor,Qe=Math.pow,Mc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Nc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,vc=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ia=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Et=1e7,ie=7,Vc=9007199254740991,_c=oo.length-1,kr=ro.length-1,q={toStringTag:na};q.absoluteValue=q.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),ne(r)};q.ceil=function(){return ne(new this.constructor(this),this.e+1,2)};q.clampedTo=q.clamp=function(r,t){var e,n=this,i=n.constructor;if(r=new i(r),t=new i(t),!r.s||!t.s)return new i(NaN);if(r.gt(t))throw Error(mn+t);return e=n.cmp(r),e<0?r:n.cmp(t)>0?t:new i(n)};q.comparedTo=q.cmp=function(r){var t,e,n,i,o=this,s=o.d,a=(r=new o.constructor(r)).d,c=o.s,u=r.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(o.e!==r.e)return o.e>r.e^c<0?1:-1;for(n=s.length,i=a.length,t=0,e=n<i?n:i;t<e;++t)if(s[t]!==a[t])return s[t]>a[t]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};q.cosine=q.cos=function(){var r,t,e=this,n=e.constructor;return e.d?e.d[0]?(r=n.precision,t=n.rounding,n.precision=r+Math.max(e.e,e.sd())+ie,n.rounding=1,e=Ec(n,ua(n,e)),n.precision=r,n.rounding=t,ne(Zt==2||Zt==3?e.neg():e,r,t,!0)):new n(1):new n(NaN)};q.cubeRoot=q.cbrt=function(){var r,t,e,n,i,o,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(ae=!1,o=l.s*Qe(l.s*l,1/3),!o||Math.abs(o)==1/0?(e=et(l.d),r=l.e,(o=(r-e.length+1)%3)&&(e+=o==1||o==-2?"0":"00"),o=Qe(e,1/3),r=at((r+1)/3)-(r%3==(r<0?-1:2)),o==1/0?e="5e"+r:(e=o.toExponential(),e=e.slice(0,e.indexOf("e")+1)+r),n=new m(e),n.s=l.s):n=new m(o.toString()),s=(r=m.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=Ce(u.plus(l).times(a),u.plus(c),s+2,1),et(a.d).slice(0,s)===(e=et(n.d)).slice(0,s))if(e=e.slice(s-3,s+1),e=="9999"||!i&&e=="4999"){if(!i&&(ne(a,r+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(ne(n,r+1,1),t=!n.times(n).times(n).eq(l));break}return ae=!0,ne(n,r,m.rounding,t)};q.decimalPlaces=q.dp=function(){var r,t=this.d,e=NaN;if(t){if(r=t.length-1,e=(r-at(this.e/ie))*ie,r=t[r],r)for(;r%10==0;r/=10)e--;e<0&&(e=0)}return e};q.dividedBy=q.div=function(r){return Ce(this,new this.constructor(r))};q.dividedToIntegerBy=q.divToInt=function(r){var t=this,e=t.constructor;return ne(Ce(t,new e(r),0,1,1),e.precision,e.rounding)};q.equals=q.eq=function(r){return this.cmp(r)===0};q.floor=function(){return ne(new this.constructor(this),this.e+1,3)};q.greaterThan=q.gt=function(r){return this.cmp(r)>0};q.greaterThanOrEqualTo=q.gte=function(r){var t=this.cmp(r);return t==1||t===0};q.hyperbolicCosine=q.cosh=function(){var r,t,e,n,i,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;e=s.precision,n=s.rounding,s.precision=e+Math.max(o.e,o.sd())+4,s.rounding=1,i=o.d.length,i<32?(r=Math.ceil(i/3),t=(1/co(4,r)).toString()):(r=16,t="2.3283064365386962890625e-10"),o=zn(s,1,o.times(t),new s(1),!0);for(var c,u=r,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return ne(o,s.precision=e,s.rounding=n,!0)};q.hyperbolicSine=q.sinh=function(){var r,t,e,n,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(t=o.precision,e=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,n=i.d.length,n<3)i=zn(o,2,i,i,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,i=i.times(1/co(5,r)),i=zn(o,2,i,i,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);r--;)s=i.times(i),i=i.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=t,o.rounding=e,ne(i,t,e,!0)};q.hyperbolicTangent=q.tanh=function(){var r,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(r=n.precision,t=n.rounding,n.precision=r+7,n.rounding=1,Ce(e.sinh(),e.cosh(),n.precision=r,n.rounding=t)):new n(e.s)};q.inverseCosine=q.acos=function(){var r,t=this,e=t.constructor,n=t.abs().cmp(1),i=e.precision,o=e.rounding;return n!==-1?n===0?t.isNeg()?_t(e,i,o):new e(0):new e(NaN):t.isZero()?_t(e,i+4,o).times(.5):(e.precision=i+6,e.rounding=1,t=t.asin(),r=_t(e,i+4,o).times(.5),e.precision=i,e.rounding=o,r.minus(t))};q.inverseHyperbolicCosine=q.acosh=function(){var r,t,e=this,n=e.constructor;return e.lte(1)?new n(e.eq(1)?0:NaN):e.isFinite()?(r=n.precision,t=n.rounding,n.precision=r+Math.max(Math.abs(e.e),e.sd())+4,n.rounding=1,ae=!1,e=e.times(e).minus(1).sqrt().plus(e),ae=!0,n.precision=r,n.rounding=t,e.ln()):new n(e)};q.inverseHyperbolicSine=q.asinh=function(){var r,t,e=this,n=e.constructor;return!e.isFinite()||e.isZero()?new n(e):(r=n.precision,t=n.rounding,n.precision=r+2*Math.max(Math.abs(e.e),e.sd())+6,n.rounding=1,ae=!1,e=e.times(e).plus(1).sqrt().plus(e),ae=!0,n.precision=r,n.rounding=t,e.ln())};q.inverseHyperbolicTangent=q.atanh=function(){var r,t,e,n,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(r=o.precision,t=o.rounding,n=i.sd(),Math.max(n,r)<2*-i.e-1?ne(new o(i),r,t,!0):(o.precision=e=n-i.e,i=Ce(i.plus(1),new o(1).minus(i),e+r,1),o.precision=r+4,o.rounding=1,i=i.ln(),o.precision=r,o.rounding=t,i.times(.5))):new o(NaN)};q.inverseSine=q.asin=function(){var r,t,e,n,i=this,o=i.constructor;return i.isZero()?new o(i):(t=i.abs().cmp(1),e=o.precision,n=o.rounding,t!==-1?t===0?(r=_t(o,e+4,n).times(.5),r.s=i.s,r):new o(NaN):(o.precision=e+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=e,o.rounding=n,i.times(2)))};q.inverseTangent=q.atan=function(){var r,t,e,n,i,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=kr)return s=_t(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=kr)return s=_t(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,e=Math.min(28,a/ie+2|0),r=e;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(ae=!1,t=Math.ceil(a/ie),n=1,c=u.times(u),s=new l(u),i=u;r!==-1;)if(i=i.times(c),o=s.minus(i.div(n+=2)),i=i.times(c),s=o.plus(i.div(n+=2)),s.d[t]!==void 0)for(r=t;s.d[r]===o.d[r]&&r--;);return e&&(s=s.times(2<<e-1)),ae=!0,ne(s,l.precision=m,l.rounding=d,!0)};q.isFinite=function(){return!!this.d};q.isInteger=q.isInt=function(){return!!this.d&&at(this.e/ie)>this.d.length-2};q.isNaN=function(){return!this.s};q.isNegative=q.isNeg=function(){return this.s<0};q.isPositive=q.isPos=function(){return this.s>0};q.isZero=function(){return!!this.d&&this.d[0]===0};q.lessThan=q.lt=function(r){return this.cmp(r)<0};q.lessThanOrEqualTo=q.lte=function(r){return this.cmp(r)<1};q.logarithm=q.log=function(r){var t,e,n,i,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,p=5;if(r==null)r=new l(10),t=!0;else{if(r=new l(r),e=r.d,r.s<0||!e||!e[0]||r.eq(1))return new l(NaN);t=r.eq(10)}if(e=u.d,u.s<0||!e||!e[0]||u.eq(1))return new l(e&&!e[0]?-1/0:u.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)o=!0;else{for(i=e[0];i%10===0;)i/=10;o=i!==1}if(ae=!1,a=m+p,s=ln(u,a),n=t?so(l,a+10):ln(r,a),c=Ce(s,n,a,1),ai(c.d,i=m,d))do if(a+=10,s=ln(u,a),n=t?so(l,a+10):ln(r,a),c=Ce(s,n,a,1),!o){+et(c.d).slice(i+1,i+15)+1==1e14&&(c=ne(c,m+1,0));break}while(ai(c.d,i+=10,d));return ae=!0,ne(c,m,d)};q.minus=q.sub=function(r){var t,e,n,i,o,s,a,c,u,l,m,d,p=this,f=p.constructor;if(r=new f(r),!p.d||!r.d)return!p.s||!r.s?r=new f(NaN):p.d?r.s=-r.s:r=new f(r.d||p.s!==r.s?p:NaN),r;if(p.s!=r.s)return r.s=-r.s,p.plus(r);if(u=p.d,d=r.d,a=f.precision,c=f.rounding,!u[0]||!d[0]){if(d[0])r.s=-r.s;else if(u[0])r=new f(p);else return new f(c===3?-0:0);return ae?ne(r,a,c):r}if(e=at(r.e/ie),l=at(p.e/ie),u=u.slice(),o=l-e,o){for(m=o<0,m?(t=u,o=-o,s=d.length):(t=d,e=l,s=u.length),n=Math.max(Math.ceil(a/ie),s)+2,o>n&&(o=n,t.length=1),t.reverse(),n=o;n--;)t.push(0);t.reverse()}else{for(n=u.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(u[n]!=d[n]){m=u[n]<d[n];break}o=0}for(m&&(t=u,u=d,d=t,r.s=-r.s),s=u.length,n=d.length-s;n>0;--n)u[s++]=0;for(n=d.length;n>o;){if(u[--n]<d[n]){for(i=n;i&&u[--i]===0;)u[i]=Et-1;--u[i],u[n]+=Et}u[n]-=d[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--e;return u[0]?(r.d=u,r.e=uo(u,e),ae?ne(r,a,c):r):new f(c===3?-0:0)};q.modulo=q.mod=function(r){var t,e=this,n=e.constructor;return r=new n(r),!e.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||e.d&&!e.d[0]?ne(new n(e),n.precision,n.rounding):(ae=!1,n.modulo==9?(t=Ce(e,r.abs(),0,3,1),t.s*=r.s):t=Ce(e,r,0,n.modulo,1),t=t.times(r),ae=!0,e.minus(t))};q.naturalExponential=q.exp=function(){return hr(this)};q.naturalLogarithm=q.ln=function(){return ln(this)};q.negated=q.neg=function(){var r=new this.constructor(this);return r.s=-r.s,ne(r)};q.plus=q.add=function(r){var t,e,n,i,o,s,a,c,u,l,m=this,d=m.constructor;if(r=new d(r),!m.d||!r.d)return!m.s||!r.s?r=new d(NaN):m.d||(r=new d(r.d||m.s===r.s?m:NaN)),r;if(m.s!=r.s)return r.s=-r.s,m.minus(r);if(u=m.d,l=r.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(r=new d(m)),ae?ne(r,a,c):r;if(o=at(m.e/ie),n=at(r.e/ie),u=u.slice(),i=o-n,i){for(i<0?(e=u,i=-i,s=l.length):(e=l,n=o,s=u.length),o=Math.ceil(a/ie),s=o>s?o+1:s+1,i>s&&(i=s,e.length=1),e.reverse();i--;)e.push(0);e.reverse()}for(s=u.length,i=l.length,s-i<0&&(i=s,e=l,l=u,u=e),t=0;i;)t=(u[--i]=u[i]+l[i]+t)/Et|0,u[i]%=Et;for(t&&(u.unshift(t),++n),s=u.length;u[--s]==0;)u.pop();return r.d=u,r.e=uo(u,n),ae?ne(r,a,c):r};q.precision=q.sd=function(r){var t,e=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(mn+r);return e.d?(t=oa(e.d),r&&e.e+1>t&&(t=e.e+1)):t=NaN,t};q.round=function(){var r=this,t=r.constructor;return ne(new t(r),r.e+1,t.rounding)};q.sine=q.sin=function(){var r,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(r=n.precision,t=n.rounding,n.precision=r+Math.max(e.e,e.sd())+ie,n.rounding=1,e=Wc(n,ua(n,e)),n.precision=r,n.rounding=t,ne(Zt>2?e.neg():e,r,t,!0)):new n(NaN)};q.squareRoot=q.sqrt=function(){var r,t,e,n,i,o,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(ae=!1,u=Math.sqrt(+s),u==0||u==1/0?(t=et(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=at((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),n=new l(t)):n=new l(u.toString()),e=(c=l.precision)+3;;)if(o=n,n=o.plus(Ce(s,o,e+2,1)).times(.5),et(o.d).slice(0,e)===(t=et(n.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!i&&t=="4999"){if(!i&&(ne(o,c+1,0),o.times(o).eq(s))){n=o;break}e+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(ne(n,c+1,1),r=!n.times(n).eq(s));break}return ae=!0,ne(n,c,l.rounding,r)};q.tangent=q.tan=function(){var r,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(r=n.precision,t=n.rounding,n.precision=r+10,n.rounding=1,e=e.sin(),e.s=1,e=Ce(e,new n(1).minus(e.times(e)).sqrt(),r+10,0),n.precision=r,n.rounding=t,ne(Zt==2||Zt==4?e.neg():e,r,t,!0)):new n(NaN)};q.times=q.mul=function(r){var t,e,n,i,o,s,a,c,u,l=this,m=l.constructor,d=l.d,p=(r=new m(r)).d;if(r.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!r.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?r.s/0:r.s*0);for(e=at(l.e/ie)+at(r.e/ie),c=d.length,u=p.length,c<u&&(o=d,d=p,p=o,s=c,c=u,u=s),o=[],s=c+u,n=s;n--;)o.push(0);for(n=u;--n>=0;){for(t=0,i=c+n;i>n;)a=o[i]+p[n]*d[i-n-1]+t,o[i--]=a%Et|0,t=a/Et|0;o[i]=(o[i]+t)%Et|0}for(;!o[--s];)o.pop();return t?++e:o.shift(),r.d=o,r.e=uo(o,e),ae?ne(r,m.precision,m.rounding):r};q.toBinary=function(r,t){return Ir(this,2,r,t)};q.toDecimalPlaces=q.toDP=function(r,t){var e=this,n=e.constructor;return e=new n(e),r===void 0?e:(Pt(r,0,dn),t===void 0?t=n.rounding:Pt(t,0,8),ne(e,r+e.e+1,t))};q.toExponential=function(r,t){var e,n=this,i=n.constructor;return r===void 0?e=zt(n,!0):(Pt(r,0,dn),t===void 0?t=i.rounding:Pt(t,0,8),n=ne(new i(n),r+1,t),e=zt(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+e:e};q.toFixed=function(r,t){var e,n,i=this,o=i.constructor;return r===void 0?e=zt(i):(Pt(r,0,dn),t===void 0?t=o.rounding:Pt(t,0,8),n=ne(new o(i),r+i.e+1,t),e=zt(n,!1,r+n.e+1)),i.isNeg()&&!i.isZero()?"-"+e:e};q.toFraction=function(r){var t,e,n,i,o,s,a,c,u,l,m,d,p=this,f=p.d,y=p.constructor;if(!f)return new y(p);if(u=e=new y(1),n=c=new y(0),t=new y(n),o=t.e=oa(f)-p.e-1,s=o%ie,t.d[0]=Qe(10,s<0?ie+s:s),r==null)r=o>0?t:u;else{if(a=new y(r),!a.isInt()||a.lt(u))throw Error(mn+a);r=a.gt(t)?o>0?t:u:a}for(ae=!1,a=new y(et(f)),l=y.precision,y.precision=o=f.length*ie*2;m=Ce(a,t,0,1,1),i=e.plus(m.times(n)),i.cmp(r)!=1;)e=n,n=i,i=u,u=c.plus(m.times(i)),c=i,i=t,t=a.minus(m.times(i)),a=i;return i=Ce(r.minus(e),n,0,1,1),c=c.plus(i.times(u)),e=e.plus(i.times(n)),c.s=u.s=p.s,d=Ce(u,n,o,1).minus(p).abs().cmp(Ce(c,e,o,1).minus(p).abs())<1?[u,n]:[c,e],y.precision=l,ae=!0,d};q.toHexadecimal=q.toHex=function(r,t){return Ir(this,16,r,t)};q.toNearest=function(r,t){var e=this,n=e.constructor;if(e=new n(e),r==null){if(!e.d)return e;r=new n(1),t=n.rounding}else{if(r=new n(r),t===void 0?t=n.rounding:Pt(t,0,8),!e.d)return r.s?e:r;if(!r.d)return r.s&&(r.s=e.s),r}return r.d[0]?(ae=!1,e=Ce(e,r,0,t,1).times(r),ae=!0,ne(e)):(r.s=e.s,e=r),e};q.toNumber=function(){return+this};q.toOctal=function(r,t){return Ir(this,8,r,t)};q.toPower=q.pow=function(r){var t,e,n,i,o,s,a=this,c=a.constructor,u=+(r=new c(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new c(Qe(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,o=c.rounding,r.eq(1))return ne(a,n,o);if(t=at(r.e/ie),t>=r.d.length-1&&(e=u<0?-u:u)<=Vc)return i=ra(c,a,e,n),r.s<0?new c(1).div(i):ne(i,n,o);if(s=a.s,s<0){if(t<r.d.length-1)return new c(NaN);if((r.d[t]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return e=Qe(+a,u),t=e==0||!isFinite(e)?at(u*(Math.log("0."+et(a.d))/Math.LN10+a.e+1)):new c(e+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(ae=!1,c.rounding=a.s=1,e=Math.min(12,(t+"").length),i=hr(r.times(ln(a,n+e)),n),i.d&&(i=ne(i,n+5,1),ai(i.d,n,o)&&(t=n+10,i=ne(hr(r.times(ln(a,t+e)),t),t+5,1),+et(i.d).slice(n+1,n+15)+1==1e14&&(i=ne(i,n+1,0)))),i.s=s,ae=!0,c.rounding=o,ne(i,n,o))};q.toPrecision=function(r,t){var e,n=this,i=n.constructor;return r===void 0?e=zt(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Pt(r,1,dn),t===void 0?t=i.rounding:Pt(t,0,8),n=ne(new i(n),r,t),e=zt(n,r<=n.e||n.e<=i.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+e:e};q.toSignificantDigits=q.toSD=function(r,t){var e=this,n=e.constructor;return r===void 0?(r=n.precision,t=n.rounding):(Pt(r,1,dn),t===void 0?t=n.rounding:Pt(t,0,8)),ne(new n(e),r,t)};q.toString=function(){var r=this,t=r.constructor,e=zt(r,r.e<=t.toExpNeg||r.e>=t.toExpPos);return r.isNeg()&&!r.isZero()?"-"+e:e};q.truncated=q.trunc=function(){return ne(new this.constructor(this),this.e+1,1)};q.valueOf=q.toJSON=function(){var r=this,t=r.constructor,e=zt(r,r.e<=t.toExpNeg||r.e>=t.toExpPos);return r.isNeg()?"-"+e:e};function et(r){var t,e,n,i=r.length-1,o="",s=r[0];if(i>0){for(o+=s,t=1;t<i;t++)n=r[t]+"",e=ie-n.length,e&&(o+=cn(e)),o+=n;s=r[t],n=s+"",e=ie-n.length,e&&(o+=cn(e))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Pt(r,t,e){if(r!==~~r||r<t||r>e)throw Error(mn+r)}function ai(r,t,e,n){var i,o,s,a;for(o=r[0];o>=10;o/=10)--t;return--t<0?(t+=ie,i=0):(i=Math.ceil((t+1)/ie),t%=ie),o=Qe(10,ie-t),a=r[i]%o|0,n==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),s=e<4&&a==99999||e>3&&a==49999||a==5e4||a==0):s=(e<4&&a+1==o||e>3&&a+1==o/2)&&(r[i+1]/o/100|0)==Qe(10,t-2)-1||(a==o/2||a==0)&&(r[i+1]/o/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==2&&(a=a/10|0),s=(n||e<4)&&a==9999||!n&&e>3&&a==4999):s=((n||e<4)&&a+1==o||!n&&e>3&&a+1==o/2)&&(r[i+1]/o/1e3|0)==Qe(10,t-3)-1,s}function io(r,t,e){for(var n,i=[0],o,s=0,a=r.length;s<a;){for(o=i.length;o--;)i[o]*=t;for(i[0]+=wr.indexOf(r.charAt(s++)),n=0;n<i.length;n++)i[n]>e-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/e|0,i[n]%=e)}return i.reverse()}function Ec(r,t){var e,n,i;if(t.isZero())return t;n=t.d.length,n<32?(e=Math.ceil(n/3),i=(1/co(4,e)).toString()):(e=16,i="2.3283064365386962890625e-10"),r.precision+=e,t=zn(r,1,t.times(i),new r(1));for(var o=e;o--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return r.precision-=e,t}var Ce=function(){function r(n,i,o){var s,a=0,c=n.length;for(n=n.slice();c--;)s=n[c]*i+a,n[c]=s%o|0,a=s/o|0;return a&&n.unshift(a),n}function t(n,i,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(n[a]!=i[a]){c=n[a]>i[a]?1:-1;break}return c}function e(n,i,o,s){for(var a=0;o--;)n[o]-=a,a=n[o]<i[o]?1:0,n[o]=a*s+n[o]-i[o];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,o,s,a,c){var u,l,m,d,p,f,y,b,g,P,w,A,T,k,x,S,K,I,C,L,R=n.constructor,V=n.s==i.s?1:-1,F=n.d,v=i.d;if(!F||!F[0]||!v||!v[0])return new R(!n.s||!i.s||(F?v&&F[0]==v[0]:!v)?NaN:F&&F[0]==0||!v?V*0:V/0);for(c?(p=1,l=n.e-i.e):(c=Et,p=ie,l=at(n.e/p)-at(i.e/p)),C=v.length,K=F.length,g=new R(V),P=g.d=[],m=0;v[m]==(F[m]||0);m++);if(v[m]>(F[m]||0)&&l--,o==null?(k=o=R.precision,s=R.rounding):a?k=o+(n.e-i.e)+1:k=o,k<0)P.push(1),f=!0;else{if(k=k/p+2|0,m=0,C==1){for(d=0,v=v[0],k++;(m<K||d)&&k--;m++)x=d*c+(F[m]||0),P[m]=x/v|0,d=x%v|0;f=d||m<K}else{for(d=c/(v[0]+1)|0,d>1&&(v=r(v,d,c),F=r(F,d,c),C=v.length,K=F.length),S=C,w=F.slice(0,C),A=w.length;A<C;)w[A++]=0;L=v.slice(),L.unshift(0),I=v[0],v[1]>=c/2&&++I;do d=0,u=t(v,w,C,A),u<0?(T=w[0],C!=A&&(T=T*c+(w[1]||0)),d=T/I|0,d>1?(d>=c&&(d=c-1),y=r(v,d,c),b=y.length,A=w.length,u=t(y,w,b,A),u==1&&(d--,e(y,C<b?L:v,b,c))):(d==0&&(u=d=1),y=v.slice()),b=y.length,b<A&&y.unshift(0),e(w,y,A,c),u==-1&&(A=w.length,u=t(v,w,C,A),u<1&&(d++,e(w,C<A?L:v,A,c))),A=w.length):u===0&&(d++,w=[0]),P[m++]=d,u&&w[0]?w[A++]=F[S]||0:(w=[F[S]],A=1);while((S++<K||w[0]!==void 0)&&k--);f=w[0]!==void 0}P[0]||P.shift()}if(p==1)g.e=l,Js=f;else{for(m=1,d=P[0];d>=10;d/=10)m++;g.e=m+l*p-1,ne(g,a?o+g.e+1:o,s,f)}return g}}();function ne(r,t,e,n){var i,o,s,a,c,u,l,m,d,p=r.constructor;e:if(t!=null){if(m=r.d,!m)return r;for(i=1,a=m[0];a>=10;a/=10)i++;if(o=t-i,o<0)o+=ie,s=t,l=m[d=0],c=l/Qe(10,i-s-1)%10|0;else if(d=Math.ceil((o+1)/ie),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=c=0,i=1,o%=ie,s=o-ie+1}else break e;else{for(l=a=m[d],i=1;a>=10;a/=10)i++;o%=ie,s=o-ie+i,c=s<0?0:l/Qe(10,i-s-1)%10|0}if(n=n||t<0||m[d+1]!==void 0||(s<0?l:l%Qe(10,i-s-1)),u=e<4?(c||n)&&(e==0||e==(r.s<0?3:2)):c>5||c==5&&(e==4||n||e==6&&(o>0?s>0?l/Qe(10,i-s):0:m[d-1])%10&1||e==(r.s<0?8:7)),t<1||!m[0])return m.length=0,u?(t-=r.e+1,m[0]=Qe(10,(ie-t%ie)%ie),r.e=-t||0):m[0]=r.e=0,r;if(o==0?(m.length=d,a=1,d--):(m.length=d+1,a=Qe(10,ie-o),m[d]=s>0?(l/Qe(10,i-s)%Qe(10,s)|0)*a:0),u)for(;;)if(d==0){for(o=1,s=m[0];s>=10;s/=10)o++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(r.e++,m[0]==Et&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=Et)break;m[d--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return ae&&(r.e>p.maxE?(r.d=null,r.e=NaN):r.e<p.minE&&(r.e=0,r.d=[0])),r}function zt(r,t,e){if(!r.isFinite())return aa(r);var n,i=r.e,o=et(r.d),s=o.length;return t?(e&&(n=e-s)>0?o=o.charAt(0)+"."+o.slice(1)+cn(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(r.e<0?"e":"e+")+r.e):i<0?(o="0."+cn(-i-1)+o,e&&(n=e-s)>0&&(o+=cn(n))):i>=s?(o+=cn(i+1-s),e&&(n=e-i-1)>0&&(o=o+"."+cn(n))):((n=i+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),e&&(n=e-s)>0&&(i+1===s&&(o+="."),o+=cn(n))),o}function uo(r,t){var e=r[0];for(t*=ie;e>=10;e/=10)t++;return t}function so(r,t,e){if(t>_c)throw ae=!0,e&&(r.precision=e),Error(ea);return ne(new r(oo),t,1,!0)}function _t(r,t,e){if(t>kr)throw Error(ea);return ne(new r(ro),t,e,!0)}function oa(r){var t=r.length-1,e=t*ie+1;if(t=r[t],t){for(;t%10==0;t/=10)e--;for(t=r[0];t>=10;t/=10)e++}return e}function cn(r){for(var t="";r--;)t+="0";return t}function ra(r,t,e,n){var i,o=new r(1),s=Math.ceil(n/ie+4);for(ae=!1;;){if(e%2&&(o=o.times(t),Zs(o.d,s)&&(i=!0)),e=at(e/2),e===0){e=o.d.length-1,i&&o.d[e]===0&&++o.d[e];break}t=t.times(t),Zs(t.d,s)}return ae=!0,o}function js(r){return r.d[r.d.length-1]&1}function sa(r,t,e){for(var n,i=new r(t[0]),o=0;++o<t.length;)if(n=new r(t[o]),n.s)i[e](n)&&(i=n);else{i=n;break}return i}function hr(r,t){var e,n,i,o,s,a,c,u=0,l=0,m=0,d=r.constructor,p=d.rounding,f=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:0/0);for(t==null?(ae=!1,c=f):c=t,a=new d(.03125);r.e>-2;)r=r.times(a),m+=5;for(n=Math.log(Qe(2,m))/Math.LN10*2+5|0,c+=n,e=o=s=new d(1),d.precision=c;;){if(o=ne(o.times(r),c,1),e=e.times(++l),a=s.plus(Ce(o,e,c,1)),et(a.d).slice(0,c)===et(s.d).slice(0,c)){for(i=m;i--;)s=ne(s.times(s),c,1);if(t==null)if(u<3&&ai(s.d,c-n,p,u))d.precision=c+=10,e=o=a=new d(1),l=0,u++;else return ne(s,d.precision=f,p,ae=!0);else return d.precision=f,s}s=a}}function ln(r,t){var e,n,i,o,s,a,c,u,l,m,d,p=1,f=10,y=r,b=y.d,g=y.constructor,P=g.rounding,w=g.precision;if(y.s<0||!b||!b[0]||!y.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:y.s!=1?NaN:b?0:y);if(t==null?(ae=!1,l=w):l=t,g.precision=l+=f,e=et(b),n=e.charAt(0),Math.abs(o=y.e)<15e14){for(;n<7&&n!=1||n==1&&e.charAt(1)>3;)y=y.times(r),e=et(y.d),n=e.charAt(0),p++;o=y.e,n>1?(y=new g("0."+e),o++):y=new g(n+"."+e.slice(1))}else return u=so(g,l+2,w).times(o+""),y=ln(new g(n+"."+e.slice(1)),l-f).plus(u),g.precision=w,t==null?ne(y,w,P,ae=!0):y;for(m=y,c=s=y=Ce(y.minus(1),y.plus(1),l,1),d=ne(y.times(y),l,1),i=3;;){if(s=ne(s.times(d),l,1),u=c.plus(Ce(s,new g(i),l,1)),et(u.d).slice(0,l)===et(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(so(g,l+2,w).times(o+""))),c=Ce(c,new g(p),l,1),t==null)if(ai(c.d,l-f,P,a))g.precision=l+=f,u=s=y=Ce(m.minus(1),m.plus(1),l,1),d=ne(y.times(y),l,1),i=a=1;else return ne(c,g.precision=w,P,ae=!0);else return g.precision=w,c;c=u,i+=2}}function aa(r){return String(r.s*r.s/0)}function Tr(r,t){var e,n,i;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(e<0&&(e=n),e+=+t.slice(n+1),t=t.substring(0,n)):e<0&&(e=t.length),n=0;t.charCodeAt(n)===48;n++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(n,i),t){if(i-=n,r.e=e=e-n-1,r.d=[],n=(e+1)%ie,e<0&&(n+=ie),n<i){for(n&&r.d.push(+t.slice(0,n)),i-=ie;n<i;)r.d.push(+t.slice(n,n+=ie));t=t.slice(n),n=ie-t.length}else n-=i;for(;n--;)t+="0";r.d.push(+t),ae&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Fc(r,t){var e,n,i,o,s,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),ia.test(t))return Tr(r,t)}else if(t==="Infinity"||t==="NaN")return+t||(r.s=NaN),r.e=NaN,r.d=null,r;if(Nc.test(t))e=16,t=t.toLowerCase();else if(Mc.test(t))e=2;else if(vc.test(t))e=8;else throw Error(mn+t);for(o=t.search(/p/i),o>0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),o=t.indexOf("."),s=o>=0,n=r.constructor,s&&(t=t.replace(".",""),a=t.length,o=a-o,i=ra(n,new n(e),o,o*2)),u=io(t,e,Et),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new n(r.s*0):(r.e=uo(u,l),r.d=u,ae=!1,s&&(r=Ce(r,i,a*4)),c&&(r=r.times(Math.abs(c)<54?Qe(2,c):ui.pow(2,c))),ae=!0,r)}function Wc(r,t){var e,n=t.d.length;if(n<3)return t.isZero()?t:zn(r,2,t,t);e=1.4*Math.sqrt(n),e=e>16?16:e|0,t=t.times(1/co(5,e)),t=zn(r,2,t,t);for(var i,o=new r(5),s=new r(16),a=new r(20);e--;)i=t.times(t),t=t.times(o.plus(i.times(s.times(i).minus(a))));return t}function zn(r,t,e,n,i){var o,s,a,c,u=1,l=r.precision,m=Math.ceil(l/ie);for(ae=!1,c=e.times(e),a=new r(n);;){if(s=Ce(a.times(c),new r(t++*t++),l,1),a=i?n.plus(s):n.minus(s),n=Ce(s.times(c),new r(t++*t++),l,1),s=a.plus(n),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=n,n=s,s=o,u++}return ae=!0,s.d.length=m+1,s}function co(r,t){for(var e=r;--t;)e*=r;return e}function ua(r,t){var e,n=t.s<0,i=_t(r,r.precision,1),o=i.times(.5);if(t=t.abs(),t.lte(o))return Zt=n?4:1,t;if(e=t.divToInt(i),e.isZero())Zt=n?3:2;else{if(t=t.minus(e.times(i)),t.lte(o))return Zt=js(e)?n?2:3:n?4:1,t;Zt=js(e)?n?1:4:n?3:2}return t.minus(i).abs()}function Ir(r,t,e,n){var i,o,s,a,c,u,l,m,d,p=r.constructor,f=e!==void 0;if(f?(Pt(e,1,dn),n===void 0?n=p.rounding:Pt(n,0,8)):(e=p.precision,n=p.rounding),!r.isFinite())l=aa(r);else{for(l=zt(r),s=l.indexOf("."),f?(i=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):i=t,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=io(zt(d),10,i),d.e=d.d.length),m=io(l,10,i),o=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=f?"0p+0":"0";else{if(s<0?o--:(r=new p(r),r.d=m,r.e=o,r=Ce(r,d,e,n,0,i),m=r.d,o=r.e,u=Js),s=m[e],a=i/2,u=u||m[e+1]!==void 0,u=n<4?(s!==void 0||u)&&(n===0||n===(r.s<0?3:2)):s>a||s===a&&(n===4||u||n===6&&m[e-1]&1||n===(r.s<0?8:7)),m.length=e,u)for(;++m[--e]>i-1;)m[e]=0,e||(++o,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=wr.charAt(m[s]);if(f){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(m=io(l,i,t),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=wr.charAt(m[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>c)for(o-=c;o--;)l+="0";else o<c&&(l=l.slice(0,o)+"."+l.slice(o))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return r.s<0?"-"+l:l}function Zs(r,t){if(r.length>t)return r.length=t,!0}function Dc(r){return new this(r).abs()}function qc(r){return new this(r).acos()}function Uc(r){return new this(r).acosh()}function Gc(r,t){return new this(r).plus(t)}function Xc(r){return new this(r).asin()}function zc(r){return new this(r).asinh()}function Qc(r){return new this(r).atan()}function Yc(r){return new this(r).atanh()}function Hc(r,t){r=new this(r),t=new this(t);var e,n=this.precision,i=this.rounding,o=n+4;return!r.s||!t.s?e=new this(NaN):!r.d&&!t.d?(e=_t(this,o,1).times(t.s>0?.25:.75),e.s=r.s):!t.d||r.isZero()?(e=t.s<0?_t(this,n,i):new this(0),e.s=r.s):!r.d||t.isZero()?(e=_t(this,o,1).times(.5),e.s=r.s):t.s<0?(this.precision=o,this.rounding=1,e=this.atan(Ce(r,t,o,1)),t=_t(this,o,1),this.precision=n,this.rounding=i,e=r.s<0?e.minus(t):e.plus(t)):e=this.atan(Ce(r,t,o,1)),e}function jc(r){return new this(r).cbrt()}function Zc(r){return ne(r=new this(r),r.e+1,2)}function $c(r,t,e){return new this(r).clamp(t,e)}function Jc(r){if(!r||typeof r!="object")throw Error(ao+"Object expected");var t,e,n,i=r.defaults===!0,o=["precision",1,dn,"rounding",0,8,"toExpNeg",-Xn,0,"toExpPos",0,Xn,"maxE",0,Xn,"minE",-Xn,0,"modulo",0,9];for(t=0;t<o.length;t+=3)if(e=o[t],i&&(this[e]=Ar[e]),(n=r[e])!==void 0)if(at(n)===n&&n>=o[t+1]&&n<=o[t+2])this[e]=n;else throw Error(mn+e+": "+n);if(e="crypto",i&&(this[e]=Ar[e]),(n=r[e])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(ta);else this[e]=!1;else throw Error(mn+e+": "+n);return this}function el(r){return new this(r).cos()}function tl(r){return new this(r).cosh()}function ca(r){var t,e,n;function i(o){var s,a,c,u=this;if(!(u instanceof i))return new i(o);if(u.constructor=i,$s(o)){u.s=o.s,ae?!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(c=typeof o,c==="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,a=o;a>=10;a/=10)s++;ae?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 Tr(u,o.toString())}else if(c!=="string")throw Error(mn+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),ia.test(o)?Tr(u,o):Fc(u,o)}if(i.prototype=q,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=Jc,i.clone=ca,i.isDecimal=$s,i.abs=Dc,i.acos=qc,i.acosh=Uc,i.add=Gc,i.asin=Xc,i.asinh=zc,i.atan=Qc,i.atanh=Yc,i.atan2=Hc,i.cbrt=jc,i.ceil=Zc,i.clamp=$c,i.cos=el,i.cosh=tl,i.div=nl,i.exp=il,i.floor=ol,i.hypot=rl,i.ln=sl,i.log=al,i.log10=cl,i.log2=ul,i.max=ll,i.min=ml,i.mod=dl,i.mul=pl,i.pow=fl,i.random=yl,i.round=bl,i.sign=gl,i.sin=Pl,i.sinh=wl,i.sqrt=Al,i.sub=kl,i.sum=hl,i.tan=Tl,i.tanh=Il,i.trunc=Bl,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)r.hasOwnProperty(e=n[t++])||(r[e]=this[e]);return i.config(r),i}function nl(r,t){return new this(r).div(t)}function il(r){return new this(r).exp()}function ol(r){return ne(r=new this(r),r.e+1,3)}function rl(){var r,t,e=new this(0);for(ae=!1,r=0;r<arguments.length;)if(t=new this(arguments[r++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return ae=!0,new this(1/0);e=t}return ae=!0,e.sqrt()}function $s(r){return r instanceof ui||r&&r.toStringTag===na||!1}function sl(r){return new this(r).ln()}function al(r,t){return new this(r).log(t)}function ul(r){return new this(r).log(2)}function cl(r){return new this(r).log(10)}function ll(){return sa(this,arguments,"lt")}function ml(){return sa(this,arguments,"gt")}function dl(r,t){return new this(r).mod(t)}function pl(r,t){return new this(r).mul(t)}function fl(r,t){return new this(r).pow(t)}function yl(r){var t,e,n,i,o=0,s=new this(1),a=[];if(r===void 0?r=this.precision:Pt(r,1,dn),n=Math.ceil(r/ie),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));o<n;)i=t[o],i>=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(n*=4);o<n;)i=t[o]+(t[o+1]<<8)+(t[o+2]<<16)+((t[o+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,o):(a.push(i%1e7),o+=4);o=n/4}else throw Error(ta);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],r%=ie,n&&r&&(i=Qe(10,ie-r),a[o]=(n/i|0)*i);a[o]===0;o--)a.pop();if(o<0)e=0,a=[0];else{for(e=-1;a[0]===0;e-=ie)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<ie&&(e-=ie-n)}return s.e=e,s.d=a,s}function bl(r){return ne(r=new this(r),r.e+1,this.rounding)}function gl(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function Pl(r){return new this(r).sin()}function wl(r){return new this(r).sinh()}function Al(r){return new this(r).sqrt()}function kl(r,t){return new this(r).sub(t)}function hl(){var r=0,t=arguments,e=new this(t[r]);for(ae=!1;e.s&&++r<t.length;)e=e.plus(t[r]);return ae=!0,ne(e,this.precision,this.rounding)}function Tl(r){return new this(r).tan()}function Il(r){return new this(r).tanh()}function Bl(r){return ne(r=new this(r),r.e+1,1)}q[Symbol.for("nodejs.util.inspect.custom")]=q.toString;q[Symbol.toStringTag]="Decimal";var ui=q.constructor=ca(Ar);oo=new ui(oo);ro=new ui(ro);var N=ui;import Ml from"big.js";import po from"bn.js";import xl from"toformat";var Sl=xl,ci=Sl;import mo from"big.js";import Cl from"bn.js";import Ll from"decimal.js-light";import li from"bn.js";var la=9007199254740991;function te(r){let t=pe("Raydium_parseBigNumberish");if(r instanceof li)return r;if(typeof r=="string"){if(r.match(/^-?[0-9]+$/))return new li(r);t.logWithError(`invalid BigNumberish string: ${r}`)}return typeof r=="number"?(r%1&&t.logWithError(`BigNumberish number underflow: ${r}`),(r>=la||r<=-la)&&t.logWithError(`BigNumberish number overflow: ${r}`),new li(String(r))):typeof r=="bigint"?new li(r.toString()):(t.error(`invalid BigNumberish value: ${r}`),new li(0))}var lo=pe("module/fraction"),Br=ci(mo),mi=ci(Ll),Rl={[0]:mi.ROUND_DOWN,[1]:mi.ROUND_HALF_UP,[2]:mi.ROUND_UP},Ol={[0]:mo.roundDown,[1]:mo.roundHalfUp,[2]:mo.roundUp},we=class{constructor(t,e=new Cl(1)){this.numerator=te(t),this.denominator=te(e)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new we(this.denominator,this.numerator)}add(t){let e=t instanceof we?t:new we(te(t));return this.denominator.eq(e.denominator)?new we(this.numerator.add(e.numerator),this.denominator):new we(this.numerator.mul(e.denominator).add(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}sub(t){let e=t instanceof we?t:new we(te(t));return this.denominator.eq(e.denominator)?new we(this.numerator.sub(e.numerator),this.denominator):new we(this.numerator.mul(e.denominator).sub(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}mul(t){let e=t instanceof we?t:new we(te(t));return new we(this.numerator.mul(e.numerator),this.denominator.mul(e.denominator))}div(t){let e=t instanceof we?t:new we(te(t));return new we(this.numerator.mul(e.denominator),this.denominator.mul(e.numerator))}toSignificant(t,e={groupSeparator:""},n=1){Number.isInteger(t)||lo.logWithError(`${t} is not an integer.`),t<=0&&lo.logWithError(`${t} is not positive.`),mi.set({precision:t+1,rounding:Rl[n]});let i=new mi(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return i.toFormat(i.decimalPlaces(),e)}toFixed(t,e={groupSeparator:""},n=1){return Number.isInteger(t)||lo.logWithError(`${t} is not an integer.`),t<0&&lo.logWithError(`${t} is negative.`),Br.DP=t,Br.RM=Ol[n]||1,new Br(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)}isZero(){return this.numerator.isZero()}};var Nl=pe("Raydium_amount"),ma=ci(Ml);function vl(r,t){let e="0",n="0";if(r.includes(".")){let i=r.split(".");i.length===2?([e,n]=i,n=n.padEnd(t,"0")):Nl.logWithError(`invalid number string, num: ${r}`)}else e=r;return[e,n.slice(0,t)||n]}var Ie=class extends we{constructor(e,n,i=!0,o){let s=new po(0),a=xr.pow(new po(e.decimals));if(i)s=te(n);else{let c=new po(0),u=new po(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=vl(n.toString(),e.decimals);c=te(l),u=te(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=pe(o||"TokenAmount"),this.token=e}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(e){return this.token.equals(e.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(e.raw)}lt(e){return this.token.equals(e.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(e.raw)}add(e){return this.token.equals(e.token)||this.logger.logWithError("add token not equals"),new Ie(this.token,this.raw.add(e.raw))}subtract(e){return this.token.equals(e.token)||this.logger.logWithError("sub token not equals"),new Ie(this.token,this.raw.sub(e.raw))}toSignificant(e=this.token.decimals,n,i=0){return super.toSignificant(e,n,i)}toFixed(e=this.token.decimals,n,i=0){return e>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(e,n,i)}toExact(e={groupSeparator:""}){return ma.DP=this.token.decimals,new ma(this.numerator.toString()).div(this.denominator.toString()).toFormat(e)}};import{PublicKey as Vl}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as da}from"@solana/spl-token";var pn={chainId:101,address:Vl.default.toBase58(),programId:da.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},ut={chainId:101,address:"So11111111111111111111111111111111111111112",programId:da.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};import{PublicKey as Rr}from"@solana/web3.js";import{PublicKey as Re,SystemProgram as pa,SYSVAR_RENT_PUBKEY as _l}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as El}from"@solana/spl-token";function B({pubkey:r,isSigner:t=!1,isWritable:e=!0}){return{pubkey:r,isWritable:e,isSigner:t}}var Sr=[B({pubkey:El,isWritable:!1}),B({pubkey:pa.programId,isWritable:!1}),B({pubkey:_l,isWritable:!1})];function Kr({publicKey:r,transformSol:t}){let e=Cr(r.toString());if(e instanceof Re)return t&&e.equals(He)?Z:e;if(t&&e.toString()===He.toBase58())return Z;if(typeof e=="string"){if(e===Re.default.toBase58())return Re.default;try{return new Re(e)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Cr(r){try{return new Re(r)}catch{return r}}var Sn=new Re("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),fn=new Re("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),je=new Re("SysvarRent111111111111111111111111111111111"),fa=new Re("SysvarC1ock11111111111111111111111111111111"),$t=new Re("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Fl=new Re("Sysvar1nstructions1111111111111111111111111"),Lr=pa.programId,df=new Re("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),pf=new Re("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),ff=new Re("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),yf=new Re("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),bf=new Re("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),gf=new Re("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Pf=new Re("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),wf=new Re("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Af=new Re("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),kf=new Re("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),hf=new Re("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),Z=new Re("So11111111111111111111111111111111111111112"),He=Re.default;function st(r){return Kr({publicKey:r,transformSol:!0})}var Or=class{constructor({mint:t,decimals:e,symbol:n,name:i,skipMint:o=!1,isToken2022:s=!1}){if(t===He.toBase58()||t instanceof Rr&&He.equals(t)){this.decimals=ut.decimals,this.symbol=ut.symbol,this.name=ut.name,this.mint=new Rr(ut.address),this.isToken2022=!1;return}this.decimals=e,this.symbol=n||t.toString().substring(0,6),this.name=i||t.toString().substring(0,6),this.mint=o?Rr.default:Kr({publicKey:t}),this.isToken2022=s}equals(t){return this===t?!0:this.mint.equals(t.mint)}},Oe=Or;Oe.WSOL=new Or(U(M({},ut),{mint:ut.address}));var Mr=class{constructor({decimals:t,symbol:e="UNKNOWN",name:n="UNKNOWN"}){this.decimals=t,this.symbol=e,this.name=n}equals(t){return this===t}},fo=Mr;fo.SOL=new Mr(pn);import Wl from"bn.js";var ya=new we(new Wl(100)),Ze=class extends we{toSignificant(t=5,e,n){return this.mul(ya).toSignificant(t,e,n)}toFixed(t=2,e,n){return this.mul(ya).toFixed(t,e,n)}};var Dl=pe("Raydium_price"),wt=class extends we{constructor(e){let{baseToken:n,quoteToken:i,numerator:o,denominator:s}=e;super(o,s);this.baseToken=n,this.quoteToken=i,this.scalar=new we(Nr(n.decimals),Nr(i.decimals))}get raw(){return new we(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new wt({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(e){this.quoteToken!==e.baseToken&&Dl.logWithError("mul token not equals");let n=super.mul(e);return new wt({baseToken:this.baseToken,quoteToken:e.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(e=this.quoteToken.decimals,n,i){return this.adjusted.toSignificant(e,n,i)}toFixed(e=this.quoteToken.decimals,n,i){return this.adjusted.toFixed(e,n,i)}};import{PublicKey as ql}from"@solana/web3.js";import Ul from"bn.js";function ba(r){return typeof r=="object"&&r!==null&&![Oe,Ie,ql,we,Ul,wt,Ze].some(t=>typeof t=="object"&&r instanceof t)}function tt(r){return typeof r=="string"?Cr(r):Array.isArray(r)?r.map(t=>tt(t)):ba(r)?Object.fromEntries(Object.entries(r).map(([t,e])=>[t,tt(e)])):r}var At=new Jt(0),ga=new Jt(1),gy=new Jt(2),Py=new Jt(3),wy=new Jt(5),xr=new Jt(10),Ay=new Jt(100),ky=new Jt(1e3),hy=new Jt(1e4);function Nr(r){return xr.pow(te(r))}function yo(r,t){let e=r.divmod(t);return e.mod.isZero()?e.div:e.div.isNeg()?e.div.isubn(1):e.div.iaddn(1)}function Pr(r,t=1,e=[]){let n=[...r];if(t<=0)return e;for(;n.length;)e.push(n.splice(0,t));return e}var Ft=class{constructor(t){this._owner=t}get publicKey(){return Ft.isKeyPair(this._owner)?this._owner.publicKey:this._owner}get signer(){return Ft.isKeyPair(this._owner)?this._owner:void 0}get isKeyPair(){return Ft.isKeyPair(this._owner)}get isPublicKey(){return Ft.isPublicKey(this._owner)}static isKeyPair(t){return t.secretKey!==void 0}static isPublicKey(t){return!Ft.isKeyPair(t)}};import{PublicKey as Hl}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as jl}from"@solana/spl-token";import{ComputeBudgetProgram as Pa,Keypair as Aa,PublicKey as Gl,Transaction as ka,TransactionMessage as Xl,VersionedTransaction as ha}from"@solana/web3.js";var _={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",CustodyInitializeUser:"CustodyInitializeUser",CustodyDeposit:"CustodyDeposit",CustodyWithdraw:"CustodyWithdraw",CustodyOpenPosition:"CustodyOpenPosition",CustodyClosePosition:"CustodyClosePosition",CustodyIncreasePosition:"CustodyIncreasePosition",CustodyDecreasePosition:"CustodyDecreasePosition",CustodySwapBaseIn:"CustodySwapBaseIn",CustodySwapBaseOut:"CustodySwapBaseOut",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV4Withdraw:"FarmV4Withdraw",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee",TransferTip:"TransferTip"};import{TOKEN_PROGRAM_ID as zl}from"@solana/spl-token";var wa=pe("Raydium_txUtil"),Ta=1644;function bo(r){let t=[],e=[];return r.microLamports&&(t.push(Pa.setComputeUnitPrice({microLamports:r.microLamports})),e.push(_.SetComputeUnitPrice)),r.units&&(t.push(Pa.setComputeUnitLimit({units:r.units})),e.push(_.SetComputeUnitLimit)),{instructions:t,instructionTypes:e}}async function Qn(r,t){var n,i;let e=t!=null?t:"confirmed";return(i=await((n=r.getLatestBlockhash)==null?void 0:n.call(r,{commitment:e})))==null?void 0:i.blockhash}async function go(r,t){return r.getSignatureStatuses([t]),new Promise((e,n)=>{let i=setTimeout(n,6e4);r.onSignature(t,o=>{if(clearTimeout(i),!o.err){e("");return}n(Object.assign(o.err,{txId:t}))},"confirmed")})}function vr(r,t){r.length<1&&wa.logWithError(`no instructions provided: ${r.toString()}`),t.length<1&&wa.logWithError(`no signers provided:, ${t.toString()}`);let e=new ka;e.recentBlockhash="11111111111111111111111111111111",e.feePayer=t[0],e.add(...r);try{return Buffer.from(e.serialize({verifySignatures:!1})).toString("base64").length<Ta}catch{return!1}}function fe(r,t){let[e,n]=Gl.findProgramAddressSync(r,t);return{publicKey:e,nonce:n}}function di({instructions:r,payer:t,signers:e}){return vr(r,[t,...e])}function pi({instructions:r,payer:t,lookupTableAddressAccount:e,recentBlockhash:n=Aa.generate().publicKey.toString()}){let o=new Xl({payerKey:t,recentBlockhash:n,instructions:r}).compileToV0Message(Object.values(e!=null?e:{}));try{return Buffer.from(new ha(o).serialize()).toString("base64").length<Ta}catch{return!1}}var Ql=r=>Buffer.isBuffer(r)?r:r instanceof Uint8Array?Buffer.from(r.buffer,r.byteOffset,r.byteLength):Buffer.from(r),Yl=r=>{let t=r.serialize({requireAllSignatures:!1,verifySignatures:!1});r instanceof ha&&(t=Ql(t));try{return t instanceof Buffer?t.toString("base64"):Buffer.from(t).toString("base64")}catch{return t.toString("base64")}};function Kn(r){let t=[];return r.forEach(e=>{e instanceof ka&&(e.recentBlockhash||(e.recentBlockhash=zl.toBase58()),e.feePayer||(e.feePayer=Aa.generate().publicKey)),t.push(Yl(e))}),console.log("simulate tx string:",t),t}function H(r,t,e){return fe([r.toBuffer(),(e!=null?e:jl).toBuffer(),t.toBuffer()],new Hl("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))}import{PublicKey as ce}from"@solana/web3.js";var Ia=new ce("EhhTKczWMGQt46ynN