UNPKG

@cobaltx/sdk-v2

Version:

An SDK for building applications on top of CobaltX.

1 lines 61.3 kB
import{ComputeBudgetProgram as vr,Keypair as Wr,PublicKey as st,Transaction as Fe,TransactionMessage as qr,VersionedTransaction as Hr}from"@solana/web3.js";import{get as it,set as Ft}from"lodash";var We=class{constructor(t){this.logLevel=t.logLevel!==void 0?t.logLevel:0,this.name=t.name}set level(t){this.logLevel=t}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(t){return t<=this.logLevel}error(...t){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...t),this):this}logWithError(...t){let n=t.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(n)}warning(...t){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...t),this):this}info(...t){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...t),this):this}debug(...t){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...t),this):this}},ot={},Ut={};function O(e){let t=it(ot,e);if(!t){let n=it(Ut,e);t=new We({name:e,logLevel:n}),Ft(ot,e,t)}return t}import{TOKEN_PROGRAM_ID as Qr}from"@solana/spl-token";var z=O("CobaltX_txUtil"),Ht=1644;function Gt(e,t){e.length<1&&z.logWithError(`no instructions provided: ${e.toString()}`),t.length<1&&z.logWithError(`no signers provided:, ${t.toString()}`);let n=new Fe;n.recentBlockhash="11111111111111111111111111111111",n.feePayer=t[0],n.add(...e);try{return Buffer.from(n.serialize({verifySignatures:!1})).toString("base64").length<Ht}catch{return!1}}async function at(e,t,n,r=!0){let o=new st("CobaltXSimuLateTransaction11111111111111111"),i=[],s=new Fe;s.feePayer=o;for(let u of t)Gt([...s.instructions,u],[o])||(i.push(s),s=new Fe,s.feePayer=o),s.add(u);s.instructions.length>0&&i.push(s);let a=[];try{if(a=await jt(e,i,r),a.find(u=>u.err!==null))throw Error("rpc simulateTransaction error")}catch(u){u instanceof Error&&z.logWithError("failed to simulate for instructions","RPC_ERROR",{message:u.message})}let c=[];for(let u of a)if(z.debug("simulate result:",u),u.logs){let l=u.logs.filter(m=>m&&m.includes(n));z.debug("filteredLog:",c),l.length||z.logWithError("simulate log not match keyword","keyword",n),c.push(...l)}return c}function ut(e,t){let n=e.match(/{["\w:,]+}/g);return!n||n.length!==1?z.logWithError(`simulate log fail to match json, keyword: ${t}`):n[0]}function Z(e,t){let r=new RegExp(`"${t}":(\\d+)`,"g").exec(e);return!r||r.length!==2?z.logWithError(`simulate log fail to match key", key: ${t}`):r[1]}function ae(e,t){let[n,r]=st.findProgramAddressSync(e,t);return{publicKey:n,nonce:r}}async function jt(e,t,n){let r=[];if(n){let o=await e.getLatestBlockhash(),i=[];for(let u of t){u.recentBlockhash=o.blockhash,u.lastValidBlockHeight=o.lastValidBlockHeight;let m=u._compile().serialize(),g=u._serialize(m).toString("base64");i.push(g)}let s=i.map(u=>{let l=e._buildArgs([u],void 0,"base64");return{methodName:"simulateTransaction",args:l}}),a=[],c=20;for(let u=0;u<Math.ceil(s.length/c);u++)a.push(s.slice(u*c,(u+1)*c));r=await(await Promise.all(a.map(async u=>(await e._rpcBatchRequest(u)).map(l=>l.result.value)))).flat()}else try{r=await Promise.all(t.map(async o=>await(await e.simulateTransaction(o)).value))}catch(o){o instanceof Error&&z.logWithError("failed to get info for multiple accounts","RPC_ERROR",{message:o.message})}return r}import{TOKEN_PROGRAM_ID as Lr}from"@solana/spl-token";import{PublicKey as Er}from"@solana/web3.js";import Te from"bn.js";var ue=9e15,oe=1e9,Ue="0123456789abcdef",_e="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ne="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",qe={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ue,maxE:ue,crypto:!1},pt,X,T=!0,Ee="[DecimalError] ",ie=Ee+"Invalid argument: ",ft=Ee+"Precision limit exceeded",dt=Ee+"crypto unavailable",gt="[object Decimal]",v=Math.floor,B=Math.pow,Yt=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Qt=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,zt=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ht=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,H=1e7,b=7,Zt=9007199254740991,Xt=_e.length-1,He=Ne.length-1,f={toStringTag:gt};f.absoluteValue=f.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),h(e)};f.ceil=function(){return h(new this.constructor(this),this.e+1,2)};f.clampedTo=f.clamp=function(e,t){var n,r=this,o=r.constructor;if(e=new o(e),t=new o(t),!e.s||!t.s)return new o(NaN);if(e.gt(t))throw Error(ie+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new o(r)};f.comparedTo=f.cmp=function(e){var t,n,r,o,i=this,s=i.d,a=(e=new i.constructor(e)).d,c=i.s,u=e.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(i.e!==e.e)return i.e>e.e^c<0?1:-1;for(r=s.length,o=a.length,t=0,n=r<o?r:o;t<n;++t)if(s[t]!==a[t])return s[t]>a[t]^c<0?1:-1;return r===o?0:r>o^c<0?1:-1};f.cosine=f.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+b,r.rounding=1,n=Jt(r,xt(r,n)),r.precision=e,r.rounding=t,h(X==2||X==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)};f.cubeRoot=f.cbrt=function(){var e,t,n,r,o,i,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(T=!1,i=l.s*B(l.s*l,1/3),!i||Math.abs(i)==1/0?(n=D(l.d),e=l.e,(i=(e-n.length+1)%3)&&(n+=i==1||i==-2?"0":"00"),i=B(n,1/3),e=v((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?n="5e"+e:(n=i.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),r=new m(n),r.s=l.s):r=new m(i.toString()),s=(e=m.precision)+3;;)if(a=r,c=a.times(a).times(a),u=c.plus(l),r=k(u.plus(l).times(a),u.plus(c),s+2,1),D(a.d).slice(0,s)===(n=D(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!o&&n=="4999"){if(!o&&(h(a,e+1,0),a.times(a).times(a).eq(l))){r=a;break}s+=4,o=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(h(r,e+1,1),t=!r.times(r).times(r).eq(l));break}return T=!0,h(r,e,m.rounding,t)};f.decimalPlaces=f.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-v(this.e/b))*b,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};f.dividedBy=f.div=function(e){return k(this,new this.constructor(e))};f.dividedToIntegerBy=f.divToInt=function(e){var t=this,n=t.constructor;return h(k(t,new n(e),0,1,1),n.precision,n.rounding)};f.equals=f.eq=function(e){return this.cmp(e)===0};f.floor=function(){return h(new this.constructor(this),this.e+1,3)};f.greaterThan=f.gt=function(e){return this.cmp(e)>0};f.greaterThanOrEqualTo=f.gte=function(e){var t=this.cmp(e);return t==1||t===0};f.hyperbolicCosine=f.cosh=function(){var e,t,n,r,o,i=this,s=i.constructor,a=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return a;n=s.precision,r=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,o=i.d.length,o<32?(e=Math.ceil(o/3),t=(1/Be(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),i=ce(s,1,i.times(t),new s(1),!0);for(var c,u=e,l=new s(8);u--;)c=i.times(i),i=a.minus(c.times(l.minus(c.times(l))));return h(i,s.precision=n,s.rounding=r,!0)};f.hyperbolicSine=f.sinh=function(){var e,t,n,r,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(t=i.precision,n=i.rounding,i.precision=t+Math.max(o.e,o.sd())+4,i.rounding=1,r=o.d.length,r<3)o=ce(i,2,o,o,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,o=o.times(1/Be(5,e)),o=ce(i,2,o,o,!0);for(var s,a=new i(5),c=new i(16),u=new i(20);e--;)s=o.times(o),o=o.times(a.plus(s.times(c.times(s).plus(u))))}return i.precision=t,i.rounding=n,h(o,t,n,!0)};f.hyperbolicTangent=f.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,k(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)};f.inverseCosine=f.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,o=t.rounding;return n!==-1?n===0?e.isNeg()?G(t,r,o):new t(0):new t(NaN):e.isZero()?G(t,r+4,o).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=o,e.times(2))};f.inverseHyperbolicCosine=f.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,T=!1,n=n.times(n).minus(1).sqrt().plus(n),T=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)};f.inverseHyperbolicSine=f.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,T=!1,n=n.times(n).plus(1).sqrt().plus(n),T=!0,r.precision=e,r.rounding=t,n.ln())};f.inverseHyperbolicTangent=f.atanh=function(){var e,t,n,r,o=this,i=o.constructor;return o.isFinite()?o.e>=0?new i(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(e=i.precision,t=i.rounding,r=o.sd(),Math.max(r,e)<2*-o.e-1?h(new i(o),e,t,!0):(i.precision=n=r-o.e,o=k(o.plus(1),new i(1).minus(o),n+e,1),i.precision=e+4,i.rounding=1,o=o.ln(),i.precision=e,i.rounding=t,o.times(.5))):new i(NaN)};f.inverseSine=f.asin=function(){var e,t,n,r,o=this,i=o.constructor;return o.isZero()?new i(o):(t=o.abs().cmp(1),n=i.precision,r=i.rounding,t!==-1?t===0?(e=G(i,n+4,r).times(.5),e.s=o.s,e):new i(NaN):(i.precision=n+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=n,i.rounding=r,o.times(2)))};f.inverseTangent=f.atan=function(){var e,t,n,r,o,i,s,a,c,u=this,l=u.constructor,m=l.precision,p=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=He)return s=G(l,m+4,p).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=He)return s=G(l,m+4,p).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,n=Math.min(28,a/b+2|0),e=n;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(T=!1,t=Math.ceil(a/b),r=1,c=u.times(u),s=new l(u),o=u;e!==-1;)if(o=o.times(c),i=s.minus(o.div(r+=2)),o=o.times(c),s=i.plus(o.div(r+=2)),s.d[t]!==void 0)for(e=t;s.d[e]===i.d[e]&&e--;);return n&&(s=s.times(2<<n-1)),T=!0,h(s,l.precision=m,l.rounding=p,!0)};f.isFinite=function(){return!!this.d};f.isInteger=f.isInt=function(){return!!this.d&&v(this.e/b)>this.d.length-2};f.isNaN=function(){return!this.s};f.isNegative=f.isNeg=function(){return this.s<0};f.isPositive=f.isPos=function(){return this.s>0};f.isZero=function(){return!!this.d&&this.d[0]===0};f.lessThan=f.lt=function(e){return this.cmp(e)<0};f.lessThanOrEqualTo=f.lte=function(e){return this.cmp(e)<1};f.logarithm=f.log=function(e){var t,n,r,o,i,s,a,c,u=this,l=u.constructor,m=l.precision,p=l.rounding,g=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new l(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(o=n[0];o%10===0;)o/=10;i=o!==1}if(T=!1,a=m+g,s=re(u,a),r=t?Le(l,a+10):re(e,a),c=k(s,r,a,1),me(c.d,o=m,p))do if(a+=10,s=re(u,a),r=t?Le(l,a+10):re(e,a),c=k(s,r,a,1),!i){+D(c.d).slice(o+1,o+15)+1==1e14&&(c=h(c,m+1,0));break}while(me(c.d,o+=10,p));return T=!0,h(c,m,p)};f.minus=f.sub=function(e){var t,n,r,o,i,s,a,c,u,l,m,p,g=this,x=g.constructor;if(e=new x(e),!g.d||!e.d)return!g.s||!e.s?e=new x(NaN):g.d?e.s=-e.s:e=new x(e.d||g.s!==e.s?g:NaN),e;if(g.s!=e.s)return e.s=-e.s,g.plus(e);if(u=g.d,p=e.d,a=x.precision,c=x.rounding,!u[0]||!p[0]){if(p[0])e.s=-e.s;else if(u[0])e=new x(g);else return new x(c===3?-0:0);return T?h(e,a,c):e}if(n=v(e.e/b),l=v(g.e/b),u=u.slice(),i=l-n,i){for(m=i<0,m?(t=u,i=-i,s=p.length):(t=p,n=l,s=u.length),r=Math.max(Math.ceil(a/b),s)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=u.length,s=p.length,m=r<s,m&&(s=r),r=0;r<s;r++)if(u[r]!=p[r]){m=u[r]<p[r];break}i=0}for(m&&(t=u,u=p,p=t,e.s=-e.s),s=u.length,r=p.length-s;r>0;--r)u[s++]=0;for(r=p.length;r>i;){if(u[--r]<p[r]){for(o=r;o&&u[--o]===0;)u[o]=H-1;--u[o],u[r]+=H}u[r]-=p[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(e.d=u,e.e=Ie(u,n),T?h(e,a,c):e):new x(c===3?-0:0)};f.modulo=f.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?h(new r(n),r.precision,r.rounding):(T=!1,r.modulo==9?(t=k(n,e.abs(),0,3,1),t.s*=e.s):t=k(n,e,0,r.modulo,1),t=t.times(e),T=!0,n.minus(t))};f.naturalExponential=f.exp=function(){return Ge(this)};f.naturalLogarithm=f.ln=function(){return re(this)};f.negated=f.neg=function(){var e=new this.constructor(this);return e.s=-e.s,h(e)};f.plus=f.add=function(e){var t,n,r,o,i,s,a,c,u,l,m=this,p=m.constructor;if(e=new p(e),!m.d||!e.d)return!m.s||!e.s?e=new p(NaN):m.d||(e=new p(e.d||m.s===e.s?m:NaN)),e;if(m.s!=e.s)return e.s=-e.s,m.minus(e);if(u=m.d,l=e.d,a=p.precision,c=p.rounding,!u[0]||!l[0])return l[0]||(e=new p(m)),T?h(e,a,c):e;if(i=v(m.e/b),r=v(e.e/b),u=u.slice(),o=i-r,o){for(o<0?(n=u,o=-o,s=l.length):(n=l,r=i,s=u.length),i=Math.ceil(a/b),s=i>s?i+1:s+1,o>s&&(o=s,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,n=l,l=u,u=n),t=0;o;)t=(u[--o]=u[o]+l[o]+t)/H|0,u[o]%=H;for(t&&(u.unshift(t),++r),s=u.length;u[--s]==0;)u.pop();return e.d=u,e.e=Ie(u,r),T?h(e,a,c):e};f.precision=f.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(ie+e);return n.d?(t=bt(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};f.round=function(){var e=this,t=e.constructor;return h(new t(e),e.e+1,t.rounding)};f.sine=f.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+b,r.rounding=1,n=en(r,xt(r,n)),r.precision=e,r.rounding=t,h(X>2?n.neg():n,e,t,!0)):new r(NaN)};f.squareRoot=f.sqrt=function(){var e,t,n,r,o,i,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(T=!1,u=Math.sqrt(+s),u==0||u==1/0?(t=D(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=v((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),r=new l(t)):r=new l(u.toString()),n=(c=l.precision)+3;;)if(i=r,r=i.plus(k(s,i,n+2,1)).times(.5),D(i.d).slice(0,n)===(t=D(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!o&&t=="4999"){if(!o&&(h(i,c+1,0),i.times(i).eq(s))){r=i;break}n+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(h(r,c+1,1),e=!r.times(r).eq(s));break}return T=!0,h(r,c,l.rounding,e)};f.tangent=f.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=k(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,h(X==2||X==4?n.neg():n,e,t,!0)):new r(NaN)};f.times=f.mul=function(e){var t,n,r,o,i,s,a,c,u,l=this,m=l.constructor,p=l.d,g=(e=new m(e)).d;if(e.s*=l.s,!p||!p[0]||!g||!g[0])return new m(!e.s||p&&!p[0]&&!g||g&&!g[0]&&!p?NaN:!p||!g?e.s/0:e.s*0);for(n=v(l.e/b)+v(e.e/b),c=p.length,u=g.length,c<u&&(i=p,p=g,g=i,s=c,c=u,u=s),i=[],s=c+u,r=s;r--;)i.push(0);for(r=u;--r>=0;){for(t=0,o=c+r;o>r;)a=i[o]+g[r]*p[o-r-1]+t,i[o--]=a%H|0,t=a/H|0;i[o]=(i[o]+t)%H|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=Ie(i,n),T?h(e,m.precision,m.rounding):e};f.toBinary=function(e,t){return je(this,2,e,t)};f.toDecimalPlaces=f.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(V(e,0,oe),t===void 0?t=r.rounding:V(t,0,8),h(n,e+n.e+1,t))};f.toExponential=function(e,t){var n,r=this,o=r.constructor;return e===void 0?n=j(r,!0):(V(e,0,oe),t===void 0?t=o.rounding:V(t,0,8),r=h(new o(r),e+1,t),n=j(r,!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toFixed=function(e,t){var n,r,o=this,i=o.constructor;return e===void 0?n=j(o):(V(e,0,oe),t===void 0?t=i.rounding:V(t,0,8),r=h(new i(o),e+o.e+1,t),n=j(r,!1,e+r.e+1)),o.isNeg()&&!o.isZero()?"-"+n:n};f.toFraction=function(e){var t,n,r,o,i,s,a,c,u,l,m,p,g=this,x=g.d,y=g.constructor;if(!x)return new y(g);if(u=n=new y(1),r=c=new y(0),t=new y(r),i=t.e=bt(x)-g.e-1,s=i%b,t.d[0]=B(10,s<0?b+s:s),e==null)e=i>0?t:u;else{if(a=new y(e),!a.isInt()||a.lt(u))throw Error(ie+a);e=a.gt(t)?i>0?t:u:a}for(T=!1,a=new y(D(x)),l=y.precision,y.precision=i=x.length*b*2;m=k(a,t,0,1,1),o=n.plus(m.times(r)),o.cmp(e)!=1;)n=r,r=o,o=u,u=c.plus(m.times(o)),c=o,o=t,t=a.minus(m.times(o)),a=o;return o=k(e.minus(n),r,0,1,1),c=c.plus(o.times(u)),n=n.plus(o.times(r)),c.s=u.s=g.s,p=k(u,r,i,1).minus(g).abs().cmp(k(c,n,i,1).minus(g).abs())<1?[u,r]:[c,n],y.precision=l,T=!0,p};f.toHexadecimal=f.toHex=function(e,t){return je(this,16,e,t)};f.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:V(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(T=!1,n=k(n,e,0,t,1).times(e),T=!0,h(n)):(e.s=n.s,n=e),n};f.toNumber=function(){return+this};f.toOctal=function(e,t){return je(this,8,e,t)};f.toPower=f.pow=function(e){var t,n,r,o,i,s,a=this,c=a.constructor,u=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c(B(+a,u));if(a=new c(a),a.eq(1))return a;if(r=c.precision,i=c.rounding,e.eq(1))return h(a,r,i);if(t=v(e.e/b),t>=e.d.length-1&&(n=u<0?-u:u)<=Zt)return o=yt(c,a,n,r),e.s<0?new c(1).div(o):h(o,r,i);if(s=a.s,s<0){if(t<e.d.length-1)return new c(NaN);if((e.d[t]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=B(+a,u),t=n==0||!isFinite(n)?v(u*(Math.log("0."+D(a.d))/Math.LN10+a.e+1)):new c(n+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(T=!1,c.rounding=a.s=1,n=Math.min(12,(t+"").length),o=Ge(e.times(re(a,r+n)),r),o.d&&(o=h(o,r+5,1),me(o.d,r,i)&&(t=r+10,o=h(Ge(e.times(re(a,t+n)),t),t+5,1),+D(o.d).slice(r+1,r+15)+1==1e14&&(o=h(o,r+1,0)))),o.s=s,T=!0,c.rounding=i,h(o,r,i))};f.toPrecision=function(e,t){var n,r=this,o=r.constructor;return e===void 0?n=j(r,r.e<=o.toExpNeg||r.e>=o.toExpPos):(V(e,1,oe),t===void 0?t=o.rounding:V(t,0,8),r=h(new o(r),e,t),n=j(r,e<=r.e||r.e<=o.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toSignificantDigits=f.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(V(e,1,oe),t===void 0?t=r.rounding:V(t,0,8)),h(new r(n),e,t)};f.toString=function(){var e=this,t=e.constructor,n=j(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n};f.truncated=f.trunc=function(){return h(new this.constructor(this),this.e+1,1)};f.valueOf=f.toJSON=function(){var e=this,t=e.constructor,n=j(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function D(e){var t,n,r,o=e.length-1,i="",s=e[0];if(o>0){for(i+=s,t=1;t<o;t++)r=e[t]+"",n=b-r.length,n&&(i+=ne(n)),i+=r;s=e[t],r=s+"",n=b-r.length,n&&(i+=ne(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function V(e,t,n){if(e!==~~e||e<t||e>n)throw Error(ie+e)}function me(e,t,n,r){var o,i,s,a;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=b,o=0):(o=Math.ceil((t+1)/b),t%=b),i=B(10,b-t),a=e[o]%i|0,r==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==i||n>3&&a+1==i/2)&&(e[o+1]/i/100|0)==B(10,t-2)-1||(a==i/2||a==0)&&(e[o+1]/i/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==2&&(a=a/10|0),s=(r||n<4)&&a==9999||!r&&n>3&&a==4999):s=((r||n<4)&&a+1==i||!r&&n>3&&a+1==i/2)&&(e[o+1]/i/1e3|0)==B(10,t-3)-1,s}function Ae(e,t,n){for(var r,o=[0],i,s=0,a=e.length;s<a;){for(i=o.length;i--;)o[i]*=t;for(o[0]+=Ue.indexOf(e.charAt(s++)),r=0;r<o.length;r++)o[r]>n-1&&(o[r+1]===void 0&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function Jt(e,t){var n,r,o;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),o=(1/Be(4,n)).toString()):(n=16,o="2.3283064365386962890625e-10"),e.precision+=n,t=ce(e,1,t.times(o),new e(1));for(var i=n;i--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}var k=function(){function e(r,o,i){var s,a=0,c=r.length;for(r=r.slice();c--;)s=r[c]*o+a,r[c]=s%i|0,a=s/i|0;return a&&r.unshift(a),r}function t(r,o,i,s){var a,c;if(i!=s)c=i>s?1:-1;else for(a=c=0;a<i;a++)if(r[a]!=o[a]){c=r[a]>o[a]?1:-1;break}return c}function n(r,o,i,s){for(var a=0;i--;)r[i]-=a,a=r[i]<o[i]?1:0,r[i]=a*s+r[i]-o[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,o,i,s,a,c){var u,l,m,p,g,x,y,M,N,W,A,C,we,Q,ve,xe,le,Ke,q,Pe,Se=r.constructor,Ve=r.s==o.s?1:-1,R=r.d,_=o.d;if(!R||!R[0]||!_||!_[0])return new Se(!r.s||!o.s||(R?_&&R[0]==_[0]:!_)?NaN:R&&R[0]==0||!_?Ve*0:Ve/0);for(c?(g=1,l=r.e-o.e):(c=H,g=b,l=v(r.e/g)-v(o.e/g)),q=_.length,le=R.length,N=new Se(Ve),W=N.d=[],m=0;_[m]==(R[m]||0);m++);if(_[m]>(R[m]||0)&&l--,i==null?(Q=i=Se.precision,s=Se.rounding):a?Q=i+(r.e-o.e)+1:Q=i,Q<0)W.push(1),x=!0;else{if(Q=Q/g+2|0,m=0,q==1){for(p=0,_=_[0],Q++;(m<le||p)&&Q--;m++)ve=p*c+(R[m]||0),W[m]=ve/_|0,p=ve%_|0;x=p||m<le}else{for(p=c/(_[0]+1)|0,p>1&&(_=e(_,p,c),R=e(R,p,c),q=_.length,le=R.length),xe=q,A=R.slice(0,q),C=A.length;C<q;)A[C++]=0;Pe=_.slice(),Pe.unshift(0),Ke=_[0],_[1]>=c/2&&++Ke;do p=0,u=t(_,A,q,C),u<0?(we=A[0],q!=C&&(we=we*c+(A[1]||0)),p=we/Ke|0,p>1?(p>=c&&(p=c-1),y=e(_,p,c),M=y.length,C=A.length,u=t(y,A,M,C),u==1&&(p--,n(y,q<M?Pe:_,M,c))):(p==0&&(u=p=1),y=_.slice()),M=y.length,M<C&&y.unshift(0),n(A,y,C,c),u==-1&&(C=A.length,u=t(_,A,q,C),u<1&&(p++,n(A,q<C?Pe:_,C,c))),C=A.length):u===0&&(p++,A=[0]),W[m++]=p,u&&A[0]?A[C++]=R[xe]||0:(A=[R[xe]],C=1);while((xe++<le||A[0]!==void 0)&&Q--);x=A[0]!==void 0}W[0]||W.shift()}if(g==1)N.e=l,pt=x;else{for(m=1,p=W[0];p>=10;p/=10)m++;N.e=m+l*g-1,h(N,a?i+N.e+1:i,s,x)}return N}}();function h(e,t,n,r){var o,i,s,a,c,u,l,m,p,g=e.constructor;e:if(t!=null){if(m=e.d,!m)return e;for(o=1,a=m[0];a>=10;a/=10)o++;if(i=t-o,i<0)i+=b,s=t,l=m[p=0],c=l/B(10,o-s-1)%10|0;else if(p=Math.ceil((i+1)/b),a=m.length,p>=a)if(r){for(;a++<=p;)m.push(0);l=c=0,o=1,i%=b,s=i-b+1}else break e;else{for(l=a=m[p],o=1;a>=10;a/=10)o++;i%=b,s=i-b+o,c=s<0?0:l/B(10,o-s-1)%10|0}if(r=r||t<0||m[p+1]!==void 0||(s<0?l:l%B(10,o-s-1)),u=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(i>0?s>0?l/B(10,o-s):0:m[p-1])%10&1||n==(e.s<0?8:7)),t<1||!m[0])return m.length=0,u?(t-=e.e+1,m[0]=B(10,(b-t%b)%b),e.e=-t||0):m[0]=e.e=0,e;if(i==0?(m.length=p,a=1,p--):(m.length=p+1,a=B(10,b-i),m[p]=s>0?(l/B(10,o-s)%B(10,s)|0)*a:0),u)for(;;)if(p==0){for(i=1,s=m[0];s>=10;s/=10)i++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;i!=a&&(e.e++,m[0]==H&&(m[0]=1));break}else{if(m[p]+=a,m[p]!=H)break;m[p--]=0,a=1}for(i=m.length;m[--i]===0;)m.pop()}return T&&(e.e>g.maxE?(e.d=null,e.e=NaN):e.e<g.minE&&(e.e=0,e.d=[0])),e}function j(e,t,n){if(!e.isFinite())return wt(e);var r,o=e.e,i=D(e.d),s=i.length;return t?(n&&(r=n-s)>0?i=i.charAt(0)+"."+i.slice(1)+ne(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):o<0?(i="0."+ne(-o-1)+i,n&&(r=n-s)>0&&(i+=ne(r))):o>=s?(i+=ne(o+1-s),n&&(r=n-o-1)>0&&(i=i+"."+ne(r))):((r=o+1)<s&&(i=i.slice(0,r)+"."+i.slice(r)),n&&(r=n-s)>0&&(o+1===s&&(i+="."),i+=ne(r))),i}function Ie(e,t){var n=e[0];for(t*=b;n>=10;n/=10)t++;return t}function Le(e,t,n){if(t>Xt)throw T=!0,n&&(e.precision=n),Error(ft);return h(new e(_e),t,1,!0)}function G(e,t,n){if(t>He)throw Error(ft);return h(new e(Ne),t,n,!0)}function bt(e){var t=e.length-1,n=t*b+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ne(e){for(var t="";e--;)t+="0";return t}function yt(e,t,n,r){var o,i=new e(1),s=Math.ceil(r/b+4);for(T=!1;;){if(n%2&&(i=i.times(t),lt(i.d,s)&&(o=!0)),n=v(n/2),n===0){n=i.d.length-1,o&&i.d[n]===0&&++i.d[n];break}t=t.times(t),lt(t.d,s)}return T=!0,i}function ct(e){return e.d[e.d.length-1]&1}function Tt(e,t,n){for(var r,o,i=new e(t[0]),s=0;++s<t.length;){if(o=new e(t[s]),!o.s){i=o;break}r=i.cmp(o),(r===n||r===0&&i.s===n)&&(i=o)}return i}function Ge(e,t){var n,r,o,i,s,a,c,u=0,l=0,m=0,p=e.constructor,g=p.rounding,x=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(T=!1,c=x):c=t,a=new p(.03125);e.e>-2;)e=e.times(a),m+=5;for(r=Math.log(B(2,m))/Math.LN10*2+5|0,c+=r,n=i=s=new p(1),p.precision=c;;){if(i=h(i.times(e),c,1),n=n.times(++l),a=s.plus(k(i,n,c,1)),D(a.d).slice(0,c)===D(s.d).slice(0,c)){for(o=m;o--;)s=h(s.times(s),c,1);if(t==null)if(u<3&&me(s.d,c-r,g,u))p.precision=c+=10,n=i=a=new p(1),l=0,u++;else return h(s,p.precision=x,g,T=!0);else return p.precision=x,s}s=a}}function re(e,t){var n,r,o,i,s,a,c,u,l,m,p,g=1,x=10,y=e,M=y.d,N=y.constructor,W=N.rounding,A=N.precision;if(y.s<0||!M||!M[0]||!y.e&&M[0]==1&&M.length==1)return new N(M&&!M[0]?-1/0:y.s!=1?NaN:M?0:y);if(t==null?(T=!1,l=A):l=t,N.precision=l+=x,n=D(M),r=n.charAt(0),Math.abs(i=y.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)y=y.times(e),n=D(y.d),r=n.charAt(0),g++;i=y.e,r>1?(y=new N("0."+n),i++):y=new N(r+"."+n.slice(1))}else return u=Le(N,l+2,A).times(i+""),y=re(new N(r+"."+n.slice(1)),l-x).plus(u),N.precision=A,t==null?h(y,A,W,T=!0):y;for(m=y,c=s=y=k(y.minus(1),y.plus(1),l,1),p=h(y.times(y),l,1),o=3;;){if(s=h(s.times(p),l,1),u=c.plus(k(s,new N(o),l,1)),D(u.d).slice(0,l)===D(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(Le(N,l+2,A).times(i+""))),c=k(c,new N(g),l,1),t==null)if(me(c.d,l-x,W,a))N.precision=l+=x,u=s=y=k(m.minus(1),m.plus(1),l,1),p=h(y.times(y),l,1),o=a=1;else return h(c,N.precision=A,W,T=!0);else return N.precision=A,c;c=u,o+=2}}function wt(e){return String(e.s*e.s/0)}function ke(e,t){var n,r,o;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(o=t.length;t.charCodeAt(o-1)===48;--o);if(t=t.slice(r,o),t){if(o-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%b,n<0&&(r+=b),r<o){for(r&&e.d.push(+t.slice(0,r)),o-=b;r<o;)e.d.push(+t.slice(r,r+=b));t=t.slice(r),r=b-t.length}else r-=o;for(;r--;)t+="0";e.d.push(+t),T&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function $t(e,t){var n,r,o,i,s,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),ht.test(t))return ke(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Qt.test(t))n=16,t=t.toLowerCase();else if(Yt.test(t))n=2;else if(zt.test(t))n=8;else throw Error(ie+t);for(i=t.search(/p/i),i>0?(c=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),s=i>=0,r=e.constructor,s&&(t=t.replace(".",""),a=t.length,i=a-i,o=yt(r,new r(n),i,i*2)),u=Ae(t,n,H),l=u.length-1,i=l;u[i]===0;--i)u.pop();return i<0?new r(e.s*0):(e.e=Ie(u,l),e.d=u,T=!1,s&&(e=k(e,o,a*4)),c&&(e=e.times(Math.abs(c)<54?B(2,c):pe.pow(2,c))),T=!0,e)}function en(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:ce(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/Be(5,n)),t=ce(e,2,t,t);for(var o,i=new e(5),s=new e(16),a=new e(20);n--;)o=t.times(t),t=t.times(i.plus(o.times(s.times(o).minus(a))));return t}function ce(e,t,n,r,o){var i,s,a,c,u=1,l=e.precision,m=Math.ceil(l/b);for(T=!1,c=n.times(n),a=new e(r);;){if(s=k(a.times(c),new e(t++*t++),l,1),a=o?r.plus(s):r.minus(s),r=k(s.times(c),new e(t++*t++),l,1),s=a.plus(r),s.d[m]!==void 0){for(i=m;s.d[i]===a.d[i]&&i--;);if(i==-1)break}i=a,a=r,r=s,s=i,u++}return T=!0,s.d.length=m+1,s}function Be(e,t){for(var n=e;--t;)n*=e;return n}function xt(e,t){var n,r=t.s<0,o=G(e,e.precision,1),i=o.times(.5);if(t=t.abs(),t.lte(i))return X=r?4:1,t;if(n=t.divToInt(o),n.isZero())X=r?3:2;else{if(t=t.minus(n.times(o)),t.lte(i))return X=ct(n)?r?2:3:r?4:1,t;X=ct(n)?r?1:4:r?3:2}return t.minus(o).abs()}function je(e,t,n,r){var o,i,s,a,c,u,l,m,p,g=e.constructor,x=n!==void 0;if(x?(V(n,1,oe),r===void 0?r=g.rounding:V(r,0,8)):(n=g.precision,r=g.rounding),!e.isFinite())l=wt(e);else{for(l=j(e),s=l.indexOf("."),x?(o=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):o=t,s>=0&&(l=l.replace(".",""),p=new g(1),p.e=l.length-s,p.d=Ae(j(p),10,o),p.e=p.d.length),m=Ae(l,10,o),i=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=x?"0p+0":"0";else{if(s<0?i--:(e=new g(e),e.d=m,e.e=i,e=k(e,p,n,r,0,o),m=e.d,i=e.e,u=pt),s=m[n],a=o/2,u=u||m[n+1]!==void 0,u=r<4?(s!==void 0||u)&&(r===0||r===(e.s<0?3:2)):s>a||s===a&&(r===4||u||r===6&&m[n-1]&1||r===(e.s<0?8:7)),m.length=n,u)for(;++m[--n]>o-1;)m[n]=0,n||(++i,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=Ue.charAt(m[s]);if(x){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(m=Ae(l,o,t),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Ue.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)l="0"+l;l="0."+l}else if(++i>c)for(i-=c;i--;)l+="0";else i<c&&(l=l.slice(0,i)+"."+l.slice(i))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function lt(e,t){if(e.length>t)return e.length=t,!0}function tn(e){return new this(e).abs()}function nn(e){return new this(e).acos()}function rn(e){return new this(e).acosh()}function on(e,t){return new this(e).plus(t)}function sn(e){return new this(e).asin()}function an(e){return new this(e).asinh()}function un(e){return new this(e).atan()}function cn(e){return new this(e).atanh()}function ln(e,t){e=new this(e),t=new this(t);var n,r=this.precision,o=this.rounding,i=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=G(this,i,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?G(this,r,o):new this(0),n.s=e.s):!e.d||t.isZero()?(n=G(this,i,1).times(.5),n.s=e.s):t.s<0?(this.precision=i,this.rounding=1,n=this.atan(k(e,t,i,1)),t=G(this,i,1),this.precision=r,this.rounding=o,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(k(e,t,i,1)),n}function mn(e){return new this(e).cbrt()}function pn(e){return h(e=new this(e),e.e+1,2)}function fn(e,t,n){return new this(e).clamp(t,n)}function dn(e){if(!e||typeof e!="object")throw Error(Ee+"Object expected");var t,n,r,o=e.defaults===!0,i=["precision",1,oe,"rounding",0,8,"toExpNeg",-ue,0,"toExpPos",0,ue,"maxE",0,ue,"minE",-ue,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(n=i[t],o&&(this[n]=qe[n]),(r=e[n])!==void 0)if(v(r)===r&&r>=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(ie+n+": "+r);if(n="crypto",o&&(this[n]=qe[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(dt);else this[n]=!1;else throw Error(ie+n+": "+r);return this}function gn(e){return new this(e).cos()}function hn(e){return new this(e).cosh()}function Pt(e){var t,n,r;function o(i){var s,a,c,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,mt(i)){u.s=i.s,T?!i.d||i.e>o.maxE?(u.e=NaN,u.d=null):i.e<o.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(s=0,a=i;a>=10;a/=10)s++;T?s>o.maxE?(u.e=NaN,u.d=null):s<o.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[i]):(u.e=s,u.d=[i]);return}if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return ke(u,i.toString())}if(c==="string")return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),ht.test(i)?ke(u,i):$t(u,i);if(c==="bigint")return i<0?(i=-i,u.s=-1):u.s=1,ke(u,i.toString());throw Error(ie+i)}if(o.prototype=f,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=dn,o.clone=Pt,o.isDecimal=mt,o.abs=tn,o.acos=nn,o.acosh=rn,o.add=on,o.asin=sn,o.asinh=an,o.atan=un,o.atanh=cn,o.atan2=ln,o.cbrt=mn,o.ceil=pn,o.clamp=fn,o.cos=gn,o.cosh=hn,o.div=bn,o.exp=yn,o.floor=Tn,o.hypot=wn,o.ln=xn,o.log=Pn,o.log10=An,o.log2=Sn,o.max=kn,o.min=_n,o.mod=Nn,o.mul=Ln,o.pow=En,o.random=In,o.round=Bn,o.sign=Mn,o.sin=Dn,o.sinh=Cn,o.sqrt=Rn,o.sub=On,o.sum=vn,o.tan=Kn,o.tanh=Vn,o.trunc=Wn,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return o.config(e),o}function bn(e,t){return new this(e).div(t)}function yn(e){return new this(e).exp()}function Tn(e){return h(e=new this(e),e.e+1,3)}function wn(){var e,t,n=new this(0);for(T=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return T=!0,new this(1/0);n=t}return T=!0,n.sqrt()}function mt(e){return e instanceof pe||e&&e.toStringTag===gt||!1}function xn(e){return new this(e).ln()}function Pn(e,t){return new this(e).log(t)}function Sn(e){return new this(e).log(2)}function An(e){return new this(e).log(10)}function kn(){return Tt(this,arguments,-1)}function _n(){return Tt(this,arguments,1)}function Nn(e,t){return new this(e).mod(t)}function Ln(e,t){return new this(e).mul(t)}function En(e,t){return new this(e).pow(t)}function In(e){var t,n,r,o,i=0,s=new this(1),a=[];if(e===void 0?e=this.precision:V(e,1,oe),r=Math.ceil(e/b),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));i<r;)o=t[i],o>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=o%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);i<r;)o=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(t,i):(a.push(o%1e7),i+=4);i=r/4}else throw Error(dt);else for(;i<r;)a[i++]=Math.random()*1e7|0;for(r=a[--i],e%=b,r&&e&&(o=B(10,b-e),a[i]=(r/o|0)*o);a[i]===0;i--)a.pop();if(i<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=b)a.shift();for(r=1,o=a[0];o>=10;o/=10)r++;r<b&&(n-=b-r)}return s.e=n,s.d=a,s}function Bn(e){return h(e=new this(e),e.e+1,this.rounding)}function Mn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Dn(e){return new this(e).sin()}function Cn(e){return new this(e).sinh()}function Rn(e){return new this(e).sqrt()}function On(e,t){return new this(e).sub(t)}function vn(){var e=0,t=arguments,n=new this(t[e]);for(T=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return T=!0,h(n,this.precision,this.rounding)}function Kn(e){return new this(e).tan()}function Vn(e){return new this(e).tanh()}function Wn(e){return h(e=new this(e),e.e+1,1)}f[Symbol.for("nodejs.util.inspect.custom")]=f.toString;f[Symbol.toStringTag]="Decimal";var pe=f.constructor=Pt(qe);_e=new pe(_e);Ne=new pe(Ne);var fe=pe;import{PublicKey as tu}from"@solana/web3.js";import{MintLayout as ru,TOKEN_PROGRAM_ID as ou}from"@solana/spl-token";import ur from"big.js";import Da from"bn.js";import $ from"bn.js";import{TOKEN_PROGRAM_ID as ei}from"@solana/spl-token";import{PublicKey as ni}from"@solana/web3.js";import{PublicKey as J}from"@solana/web3.js";var Fn={["sooneth"]:{NATIVE_TOKEN_SYMBOL:"ETH",SWAP_HOST:"https://trade-api.cobaltx.io",BASE_HOST:"https://api.cobaltx.io",OWNER_BASE_HOST:"https://api.cobaltx.io",SERVICE_BASE_HOST:"https://api.cobaltx.io",MONITOR_BASE_HOST:"https://api.cobaltx.io",SERVICE_1_BASE_HOST:"https://api.cobaltx.io",ANALYTICS_BASE_HOST:"https://api.cobaltx.io",GITHUB_TOKEN_LIST_URL:"https://raw.githubusercontent.com/cobaltx-io/tokens/main/tokens.json",WSOL_MINT_ADDRESS:"So11111111111111111111111111111111111111112",GITHUB_LOGO_URL:"https://raw.githubusercontent.com/cobaltx-io/tokens/main/logo/So11111111111111111111111111111111111111112.png",LOOKUP_TABLE_CACHE:"6fa5xTGwoYJPMLMXaQ4tQFKMoYvXuvsJFLigMJ9a5QeB",CLMM_PROGRAMM_ID:"2TnjBuwqyBB9to5jURagDT7jLmBPefGRiKL2yh1zPZ4V",BONK_MINT_ADDRESS:"71kRXzJMvSeArtXYNEWa8KAjpRJosdMQ7Dpgy5Jt5zfd",SOL_MINT_ADDRESS:"ERFzpDteGNo8LTDKW1WwVGrkRMmA2y9WZHXNHxMA6BSV",USDC_MINT_ADDRESS:"ExYxyorY2x3h8gLcuypnHFQV3F36rmMkQVn7HHV8mUy9",USDT_MINT_ADDRESS:"742wcXVzkhNuEePAot7L3GvPseh93pvYFPgyHLX8mUy9",FULL_TOKEN_NAME:"Wrapped Ethereum",ETH_MINT_ADDRESS:"71kRXzJMvSeArtXYNEWa8KAjpRJosdMQ7Dpgy5Jt5zfd",WRAPPED_TOKEN_SYMBOL:"WETH",INPUT_MINT_ADDRESS:J.default.toString(),OUTPUT_MINT_ADDRESS:"742wcXVzkhNuEePAot7L3GvPseh93pvYFPgyHLX8mUy9",POPULAR_TOKENS:{SOL:J.default.toString(),ETH:"71kRXzJMvSeArtXYNEWa8KAjpRJosdMQ7Dpgy5Jt5zfd",USDC:"ExYxyorY2x3h8gLcuypnHFQV3F36rmMkQVn7HHV8KjtA",USDT:"742wcXVzkhNuEePAot7L3GvPseh93pvYFPgyHLX8mUy9"},WSOL_DECIMALS:9},["svmbnb"]:{NATIVE_TOKEN_SYMBOL:"BNB",SWAP_HOST:"https://trade-api.svmbnb.cobaltx.io",BASE_HOST:"https://api.svmbnb.cobaltx.io",OWNER_BASE_HOST:"https://api.svmbnb.cobaltx.io",SERVICE_BASE_HOST:"https://api.svmbnb.cobaltx.io",MONITOR_BASE_HOST:"https://api.svmbnb.cobaltx.io",SERVICE_1_BASE_HOST:"https://api.svmbnb.cobaltx.io",ANALYTICS_BASE_HOST:"https://api.svmbnb.cobaltx.io",GITHUB_TOKEN_LIST_URL:"https://raw.githubusercontent.com/cobaltx-io/svmbnb-tokens/main/tokens.json",WSOL_MINT_ADDRESS:"So11111111111111111111111111111111111111112",GITHUB_LOGO_URL:"https://raw.githubusercontent.com/cobaltx-io/svmbnb-tokens/main/logo/So11111111111111111111111111111111111111112.svg",LOOKUP_TABLE_CACHE:"GSR5XQGWhpzV9TTduBJR6qPNjYsepMQSGkpaqfrbrW9w",CLMM_PROGRAMM_ID:"6f1b3xyVZbnWMHXBjgW1KPwxmPAgXcRdrvKNn4Nmf1Cn",ETH_MINT_ADDRESS:"H3xpFH1yN5E1zFdAoBrC9Y7m7RfJUeQNLvkHi8kNf9Qu",USDC_MINT_ADDRESS:"5odzAHDpDETYhupMkc6kjiYen3K2nrf8oPmvqmsoNW4L",USDT_MINT_ADDRESS:"s8cRDxnp3VxjB6khRnGDdxv6QbCUPyY9Vn1bgSQQsnG",SOL_MINT_ADDRESS:"So11111111111111111111111111111111111111112",FULL_TOKEN_NAME:"Wrapped BNB",WRAPPED_TOKEN_SYMBOL:"WBNB",INPUT_MINT_ADDRESS:J.default.toBase58(),OUTPUT_MINT_ADDRESS:"ABoT7umUXnx8RtJTeRqKB6myebVjP2wdJGQuV23jVVH3",POPULAR_TOKENS:{SOL:J.default.toString(),ETH:"H3xpFH1yN5E1zFdAoBrC9Y7m7RfJUeQNLvkHi8kNf9Qu",USDC:"5odzAHDpDETYhupMkc6kjiYen3K2nrf8oPmvqmsoNW4L",USDT:"s8cRDxnp3VxjB6khRnGDdxv6QbCUPyY9Vn1bgSQQsnG"},WSOL_DECIMALS:9},["svmbnb_testnet"]:{NATIVE_TOKEN_SYMBOL:"BNB",SWAP_HOST:"https://trade-api.svmbnb.cobaltx.io",BASE_HOST:"https://api.testnet.svmbnb.cobaltx.io",OWNER_BASE_HOST:"https://api.testnet.svmbnb.cobaltx.io",SERVICE_BASE_HOST:"https://api.testnet.svmbnb.cobaltx.io",MONITOR_BASE_HOST:"https://api.testnet.svmbnb.cobaltx.io",SERVICE_1_BASE_HOST:"https://api.testnet.svmbnb.cobaltx.io",ANALYTICS_BASE_HOST:"https://api.testnet.svmbnb.cobaltx.io",GITHUB_TOKEN_LIST_URL:"https://raw.githubusercontent.com/cobaltx-io/svmbnb-testnet-tokens/main/tokens.json",WSOL_MINT_ADDRESS:"So11111111111111111111111111111111111111112",GITHUB_LOGO_URL:"https://raw.githubusercontent.com/cobaltx-io/svmbnb-testnet-tokens/main/logo/So11111111111111111111111111111111111111112.svg",LOOKUP_TABLE_CACHE:"D79gSiTNV9pyLPJyscW5yZYwdPVDrtKsamL3ZfQi6JiM",CLMM_PROGRAMM_ID:"FgycD57kcCZsjpoTAi2u67GTPxm59bPEhycL2Lw1icm1",ETH_MINT_ADDRESS:"5aLr3sV4UNVcMB6CiA3PZTWbgVBRNyMdEp1s5LNfhR95",USDC_MINT_ADDRESS:"jrhUNRxEDpFmGV3sqaWyveS7bVtRQgtHsfBTCdjfMBw",USDT_MINT_ADDRESS:"Ex86C4gmdjvPRNrfyvsyejbjkP6RstNaBC5g3itZw2iv",FULL_TOKEN_NAME:"Wrapped BNB",WRAPPED_TOKEN_SYMBOL:"WBNB",INPUT_MINT_ADDRESS:"bnb",OUTPUT_MINT_ADDRESS:"jrhUNRxEDpFmGV3sqaWyveS7bVtRQgtHsfBTCdjfMBw",POPULAR_TOKENS:{SOL:J.default.toString(),ETH:"5aLr3sV4UNVcMB6CiA3PZTWbgVBRNyMdEp1s5LNfhR95",USDC:"jrhUNRxEDpFmGV3sqaWyveS7bVtRQgtHsfBTCdjfMBw",USDT:"Ex86C4gmdjvPRNrfyvsyejbjkP6RstNaBC5g3itZw2iv"},WSOL_DECIMALS:9},["svmbase_testnet"]:{NATIVE_TOKEN_SYMBOL:"ETH",SWAP_HOST:"https://trade-api.testnet.svmbase.cobaltx.io",BASE_HOST:"https://api.testnet.svmbase.cobaltx.io",OWNER_BASE_HOST:"https://api.testnet.svmbase.cobaltx.io",SERVICE_BASE_HOST:"https://api.testnet.svmbase.cobaltx.io",MONITOR_BASE_HOST:"https://api.testnet.svmbase.cobaltx.io",SERVICE_1_BASE_HOST:"https://api.testnet.svmbase.cobaltx.io",ANALYTICS_BASE_HOST:"https://api.testnet.svmbase.cobaltx.io",GITHUB_TOKEN_LIST_URL:"https://raw.githubusercontent.com/cobaltx-io/svmbase-testnet-tokens/main/tokens.json",WSOL_MINT_ADDRESS:"So11111111111111111111111111111111111111112",GITHUB_LOGO_URL:"https://raw.githubusercontent.com/cobaltx-io/svmbase-testnet-tokens/main/logo/So11111111111111111111111111111111111111112.png",LOOKUP_TABLE_CACHE:"AyPMvNmUUY2jwZ75NxhkLYPraQGNk5DssVfP4TnMcPJF",CLMM_PROGRAMM_ID:"DnZnBqJKiGSYHUHYvkXAbQmkMbwrjfgo4orR7jWyMsik",ETH_MINT_ADDRESS:"71kRXzJMvSeArtXYNEWa8KAjpRJosdMQ7Dpgy5Jt5zfd",USDC_MINT_ADDRESS:"63tPXWPnYeZ9hA3dJsAY5RcQ8YbwEz8uZ5nKu3uFD1aK",USDT_MINT_ADDRESS:"4fyX7hSmPetQC2wRS3YVAhWeFzif7WStarKwTvCXrBtD",FULL_TOKEN_NAME:"Wrapped Ethereum",WRAPPED_TOKEN_SYMBOL:"WETH",INPUT_MINT_ADDRESS:J.default.toString(),OUTPUT_MINT_ADDRESS:"63tPXWPnYeZ9hA3dJsAY5RcQ8YbwEz8uZ5nKu3uFD1aK",POPULAR_TOKENS:{SOL:J.default.toString(),ETH:"So11111111111111111111111111111111111111112",USDC:"63tPXWPnYeZ9hA3dJsAY5RcQ8YbwEz8uZ5nKu3uFD1aK",USDT:"4fyX7hSmPetQC2wRS3YVAhWeFzif7WStarKwTvCXrBtD"},WSOL_DECIMALS:9},["soonbase_mainnet"]:{NATIVE_TOKEN_SYMBOL:"ETH",SWAP_HOST:"https://trade-api.soonbase.cobaltx.io",BASE_HOST:"https://api.soonbase.cobaltx.io",OWNER_BASE_HOST:"https://api.soonbase.cobaltx.io",SERVICE_BASE_HOST:"https://api.soonbase.cobaltx.io",MONITOR_BASE_HOST:"https://api.soonbase.cobaltx.io",SERVICE_1_BASE_HOST:"https://api.soonbase.cobaltx.io",ANALYTICS_BASE_HOST:"https://api.soonbase.cobaltx.io",GITHUB_TOKEN_LIST_URL:"https://raw.githubusercontent.com/cobaltx-io/soonbase-tokens/main/tokens.json",WSOL_MINT_ADDRESS:"So11111111111111111111111111111111111111112",GITHUB_LOGO_URL:"https://raw.githubusercontent.com/cobaltx-io/soonbase-tokens/main/logo/So11111111111111111111111111111111111111112.png",LOOKUP_TABLE_CACHE:"FGRusuLycV6nhSPQc9VX55YjT6DCzJFc59mvTTarSTjK",CLMM_PROGRAMM_ID:"6f1b3xyVZbnWMHXBjgW1KPwxmPAgXcRdrvKNn4Nmf1Cn",ETH_MINT_ADDRESS:"71kRXzJMvSeArtXYNEWa8KAjpRJosdMQ7Dpgy5Jt5zfd",USDC_MINT_ADDRESS:"BoYN2f2gLQS4jpvMSV9dAZwfzKJiKGk4NPck5BjXfujo",USDT_MINT_ADDRESS:"J87bysZjwfS3n6KR21cwbdPZVJWNSFcXpWF5kiChAwQH",FULL_TOKEN_NAME:"Wrapped Ethereum",WRAPPED_TOKEN_SYMBOL:"WETH",INPUT_MINT_ADDRESS:J.default.toString(),OUTPUT_MINT_ADDRESS:"BoYN2f2gLQS4jpvMSV9dAZwfzKJiKGk4NPck5BjXfujo",POPULAR_TOKENS:{SOL:J.default.toString(),ETH:"FkvCG5DcuYCQ1BnPH4ZzTkCdk3VzutgyDAFBec4qAjhh",USDC:"BoYN2f2gLQS4jpvMSV9dAZwfzKJiKGk4NPck5BjXfujo",USDT:"J87bysZjwfS3n6KR21cwbdPZVJWNSFcXpWF5kiChAwQH"},WSOL_DECIMALS:9}},de=e=>Fn[e];import{PublicKey as Ti}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Un}from"@solana/spl-token";import{PublicKey as I,SystemProgram as St,SYSVAR_RENT_PUBKEY as qn}from"@solana/web3.js";function F({pubkey:e,isSigner:t=!1,isWritable:n=!0}){return{pubkey:e,isWritable:n,isSigner:t}}var li=[F({pubkey:Un,isWritable:!1}),F({pubkey:St.programId,isWritable:!1}),F({pubkey:qn,isWritable:!1})];function At({publicKey:e,transformSol:t,network:n}){let r=kt(e.toString());if(t&&n){let{WSOLMint:o}=_t(n);if(r instanceof I)return t&&r.equals(Ye)?o:r;if(t&&r.toString()===Ye.toBase58())return o}else if(r instanceof I)return r;if(typeof r=="string"){if(r===I.default.toBase58())return I.default;try{return new I(r)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function kt(e){try{return new I(e)}catch{return e}}var mi=new I("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),pi=new I("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Hn=new I("SysvarRent111111111111111111111111111111111"),fi=new I("SysvarC1ock11111111111111111111111111111111"),di=new I("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),gi=new I("Sysvar1nstructions1111111111111111111111111"),hi=St.programId,Ye=I.default;function _t(e){let t=de(e);return{USDCMint:new I(t.USDC_MINT_ADDRESS),USDTMint:new I(t.USDT_MINT_ADDRESS),WSOLMint:new I(t.WSOL_MINT_ADDRESS),ETHMint:new I(t.ETH_MINT_ADDRESS),BONK_Mint:t.BONK_MINT_ADDRESS?new I(t.BONK_MINT_ADDRESS):I.default,SOL_Mint:t.SOL_MINT_ADDRESS?new I(t.SOL_MINT_ADDRESS):I.default,INPUT_MINT:new I(t.INPUT_MINT_ADDRESS),OUTPUT_MINT:new I(t.OUTPUT_MINT_ADDRESS)}}function Qe(e,t){return At({publicKey:e,transformSol:!0,network:t})}import De from"big.js";import Zn from"bn.js";import Xn from"decimal.js-light";import ge from"bn.js";var Nt=9007199254740991;function Y(e){let t=O("CobaltX_parseBigNumberish");if(e instanceof ge)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new ge(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=Nt||e<=-Nt)&&t.logWithError(`BigNumberish number overflow: ${e}`),new ge(String(e))):typeof e=="bigint"?new ge(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new ge(0))}import Yn from"toformat";var Qn=Yn,he=Qn;var Me=O("module/fraction"),Ze=he(De),be=he(Xn),Jn={[0]:be.ROUND_DOWN,[1]:be.ROUND_HALF_UP,[2]:be.ROUND_UP},$n={[0]:De.roundDown,[1]:De.roundHalfUp,[2]:De.roundUp},L=class{constructor(t,n=new Zn(1)){this.numerator=Y(t),this.denominator=Y(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new L(this.denominator,this.numerator)}add(t){let n=t instanceof L?t:new L(Y(t));return this.denominator.eq(n.denominator)?new L(this.numerator.add(n.numerator),this.denominator):new L(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(t){let n=t instanceof L?t:new L(Y(t));return this.denominator.eq(n.denominator)?new L(this.numerator.sub(n.numerator),this.denominator):new L(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(t){let n=t instanceof L?t:new L(Y(t));return new L(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(t){let n=t instanceof L?t:new L(Y(t));return new L(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(t,n={groupSeparator:""},r=1){Number.isInteger(t)||Me.logWithError(`${t} is not an integer.`),t<=0&&Me.logWithError(`${t} is not positive.`),be.set({precision:t+1,rounding:Jn[r]});let o=new be(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return o.toFormat(o.decimalPlaces(),n)}toFixed(t,n={groupSeparator:""},r=1){return Number.isInteger(t)||Me.logWithError(`${t} is not an integer.`),t<0&&Me.logWithError(`${t} is negative.`),Ze.DP=t,Ze.RM=$n[r]||1,new Ze(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)}isZero(){return this.numerator.isZero()}};import er from"bn.js";var Ui=new L(new er(100));var Qi=O("CobaltX_price");import{PublicKey as ro}from"@solana/web3.js";import oo from"bn.js";var It=new $(0),tr=new $(1),Ao=new $(2),ko=new $(3),_o=new $(5),nr=new $(10),No=new $(100),Lo=new $(1e3),Eo=new $(1e4);import{MINT_SIZE as Do,TOKEN_PROGRAM_ID as Co,getTransferFeeConfig as Ro,unpackMint as Oo}from"@solana/spl-token";import{PublicKey as Fo}from"@solana/web3.js";var Ho=O("CobaltX_accountInfo_util");import{PublicKey as Xo}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as $o}from"@solana/spl-token";import{PublicKey as w}from"@solana/web3.js";var is=new w("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),os=new w("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),ss=new w("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),as=new w("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),us=new w("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),cs=new w("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),ls=new w("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),ms=new w("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),ps=new w("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),fs=new w("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo");var ds=new w("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),gs=new w("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),hs=new w("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),bs=new w("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),ys=new w("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Ts=new w("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),ws=new w("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),xs=new w("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),Ps=new w("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Ss=new w("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),As=new w("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),rr=new w("CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"),ir=new w("7rQ1QFNosMkUCuh7Z7fPbTHvh73b68sQYdirycEzJVuw"),or=new w("G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2"),ks=new w("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),sr=new w("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),_s=new w("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),ar=new w("7AFUeLVRjBfzqK3tTGw8hN48KLQWSk6DTE8xprWdPqix");var Ns={SERUM_MARKET:w.default,OPENBOOK_MARKET:new w("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),UTIL1216:w.default,FarmV3:new w("85BFyr98MbCUU9MVTEgzx1nbhWACbJqLzho6zd6DZcWL"),FarmV5:new w("EcLzTrNg9V7qhcdyXDe2qjtPkiGzDM2UbdRaeaadU5r2"),FarmV6:new w("Farm2hJLcqPtPg8M4rR6DMrsRNc5TPm5Cs4bVQrMe2T7"),AmmV4:new w("HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8"),AmmStable:new w("DDg4VmQaJV9ogWce7LpcjBA9bv22wRp5uaTPa5pGjijF"),CLMM:new w("devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH"),CLMM_LOCK_PROGRAM_ID:new w("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),CLMM_LOCK_AUTH_ID:new w("8qmHNvu2Kr2C7U8mJL4Vz1vTDxMhVuXKREwU7TN