UNPKG

@cobaltx/sdk-v2

Version:

An SDK for building applications on top of CobaltX.

1 lines 74.8 kB
"use strict";var vt=Object.create;var Ne=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var Ut=Object.getPrototypeOf,Ht=Object.prototype.hasOwnProperty;var qt=(e,t)=>{for(var n in t)Ne(e,n,{get:t[n],enumerable:!0})},nt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Wt(t))!Ht.call(e,o)&&o!==n&&Ne(e,o,{get:()=>t[o],enumerable:!(r=Kt(t,o))||r.enumerable});return e};var z=(e,t,n)=>(n=e!=null?vt(Ut(e)):{},nt(t||!e||!e.__esModule?Ne(n,"default",{value:e,enumerable:!0}):n,e)),Gt=e=>nt(Ne({},"__esModule",{value:!0}),e);var lr={};qt(lr,{default:()=>Ke});module.exports=Gt(lr);var te=require("@solana/spl-token"),Ft=require("@solana/web3.js");var he=require("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}},rt={},jt={};function G(e){let t=(0,he.get)(rt,e);if(!t){let n=(0,he.get)(jt,e);t=new We({name:e,logLevel:n}),(0,he.set)(rt,e,t)}return t}var B=require("@solana/web3.js"),Lt=z(require("axios"));var ue=require("@solana/web3.js");var Fe=require("@solana/spl-token"),Dt=require("@solana/web3.js");var ee=z(require("bn.js"));var le=9e15,ae=1e9,Ue="0123456789abcdef",_e="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ie="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",He={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-le,maxE:le,crypto:!1},at,ne,k=!0,Ce="[DecimalError] ",se=Ce+"Invalid argument: ",ut=Ce+"Precision limit exceeded",ct=Ce+"crypto unavailable",lt="[object Decimal]",H=Math.floor,v=Math.pow,Yt=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,zt=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Qt=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,mt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,X=1e7,N=7,Xt=9007199254740991,Zt=_e.length-1,qe=Ie.length-1,f={toStringTag:lt};f.absoluteValue=f.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),A(e)};f.ceil=function(){return A(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(se+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,u=(e=new i.constructor(e)).d,c=i.s,a=e.s;if(!s||!u)return!c||!a?NaN:c!==a?c:s===u?0:!s^c<0?1:-1;if(!s[0]||!u[0])return s[0]?c:u[0]?-a:0;if(c!==a)return c;if(i.e!==e.e)return i.e>e.e^c<0?1:-1;for(r=s.length,o=u.length,t=0,n=r<o?r:o;t<n;++t)if(s[t]!==u[t])return s[t]>u[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())+N,r.rounding=1,n=Jt(r,ht(r,n)),r.precision=e,r.rounding=t,A(ne==2||ne==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)};f.cubeRoot=f.cbrt=function(){var e,t,n,r,o,i,s,u,c,a,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(k=!1,i=l.s*v(l.s*l,1/3),!i||Math.abs(i)==1/0?(n=U(l.d),e=l.e,(i=(e-n.length+1)%3)&&(n+=i==1||i==-2?"0":"00"),i=v(n,1/3),e=H((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(u=r,c=u.times(u).times(u),a=c.plus(l),r=R(a.plus(l).times(u),a.plus(c),s+2,1),U(u.d).slice(0,s)===(n=U(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!o&&n=="4999"){if(!o&&(A(u,e+1,0),u.times(u).times(u).eq(l))){r=u;break}s+=4,o=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(A(r,e+1,1),t=!r.times(r).times(r).eq(l));break}return k=!0,A(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-H(this.e/N))*N,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};f.dividedBy=f.div=function(e){return R(this,new this.constructor(e))};f.dividedToIntegerBy=f.divToInt=function(e){var t=this,n=t.constructor;return A(R(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 A(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,u=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return u;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=me(s,1,i.times(t),new s(1),!0);for(var c,a=e,l=new s(8);a--;)c=i.times(i),i=u.minus(c.times(l.minus(c.times(l))));return A(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=me(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=me(i,2,o,o,!0);for(var s,u=new i(5),c=new i(16),a=new i(20);e--;)s=o.times(o),o=o.times(u.plus(s.times(c.times(s).plus(a))))}return i.precision=t,i.rounding=n,A(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,R(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()?Z(t,r,o):new t(0):new t(NaN):e.isZero()?Z(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,k=!1,n=n.times(n).minus(1).sqrt().plus(n),k=!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,k=!1,n=n.times(n).plus(1).sqrt().plus(n),k=!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?A(new i(o),e,t,!0):(i.precision=n=r-o.e,o=R(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=Z(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,u,c,a=this,l=a.constructor,m=l.precision,p=l.rounding;if(a.isFinite()){if(a.isZero())return new l(a);if(a.abs().eq(1)&&m+4<=qe)return s=Z(l,m+4,p).times(.25),s.s=a.s,s}else{if(!a.s)return new l(NaN);if(m+4<=qe)return s=Z(l,m+4,p).times(.5),s.s=a.s,s}for(l.precision=u=m+10,l.rounding=1,n=Math.min(28,u/N+2|0),e=n;e;--e)a=a.div(a.times(a).plus(1).sqrt().plus(1));for(k=!1,t=Math.ceil(u/N),r=1,c=a.times(a),s=new l(a),o=a;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)),k=!0,A(s,l.precision=m,l.rounding=p,!0)};f.isFinite=function(){return!!this.d};f.isInteger=f.isInt=function(){return!!this.d&&H(this.e/N)>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,u,c,a=this,l=a.constructor,m=l.precision,p=l.rounding,d=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(n=a.d,a.s<0||!n||!n[0]||a.eq(1))return new l(n&&!n[0]?-1/0:a.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(k=!1,u=m+d,s=oe(a,u),r=t?Ee(l,u+10):oe(e,u),c=R(s,r,u,1),be(c.d,o=m,p))do if(u+=10,s=oe(a,u),r=t?Ee(l,u+10):oe(e,u),c=R(s,r,u,1),!i){+U(c.d).slice(o+1,o+15)+1==1e14&&(c=A(c,m+1,0));break}while(be(c.d,o+=10,p));return k=!0,A(c,m,p)};f.minus=f.sub=function(e){var t,n,r,o,i,s,u,c,a,l,m,p,d=this,h=d.constructor;if(e=new h(e),!d.d||!e.d)return!d.s||!e.s?e=new h(NaN):d.d?e.s=-e.s:e=new h(e.d||d.s!==e.s?d:NaN),e;if(d.s!=e.s)return e.s=-e.s,d.plus(e);if(a=d.d,p=e.d,u=h.precision,c=h.rounding,!a[0]||!p[0]){if(p[0])e.s=-e.s;else if(a[0])e=new h(d);else return new h(c===3?-0:0);return k?A(e,u,c):e}if(n=H(e.e/N),l=H(d.e/N),a=a.slice(),i=l-n,i){for(m=i<0,m?(t=a,i=-i,s=p.length):(t=p,n=l,s=a.length),r=Math.max(Math.ceil(u/N),s)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=a.length,s=p.length,m=r<s,m&&(s=r),r=0;r<s;r++)if(a[r]!=p[r]){m=a[r]<p[r];break}i=0}for(m&&(t=a,a=p,p=t,e.s=-e.s),s=a.length,r=p.length-s;r>0;--r)a[s++]=0;for(r=p.length;r>i;){if(a[--r]<p[r]){for(o=r;o&&a[--o]===0;)a[o]=X-1;--a[o],a[r]+=X}a[r]-=p[r]}for(;a[--s]===0;)a.pop();for(;a[0]===0;a.shift())--n;return a[0]?(e.d=a,e.e=Me(a,n),k?A(e,u,c):e):new h(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]?A(new r(n),r.precision,r.rounding):(k=!1,r.modulo==9?(t=R(n,e.abs(),0,3,1),t.s*=e.s):t=R(n,e,0,r.modulo,1),t=t.times(e),k=!0,n.minus(t))};f.naturalExponential=f.exp=function(){return Ge(this)};f.naturalLogarithm=f.ln=function(){return oe(this)};f.negated=f.neg=function(){var e=new this.constructor(this);return e.s=-e.s,A(e)};f.plus=f.add=function(e){var t,n,r,o,i,s,u,c,a,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(a=m.d,l=e.d,u=p.precision,c=p.rounding,!a[0]||!l[0])return l[0]||(e=new p(m)),k?A(e,u,c):e;if(i=H(m.e/N),r=H(e.e/N),a=a.slice(),o=i-r,o){for(o<0?(n=a,o=-o,s=l.length):(n=l,r=i,s=a.length),i=Math.ceil(u/N),s=i>s?i+1:s+1,o>s&&(o=s,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(s=a.length,o=l.length,s-o<0&&(o=s,n=l,l=a,a=n),t=0;o;)t=(a[--o]=a[o]+l[o]+t)/X|0,a[o]%=X;for(t&&(a.unshift(t),++r),s=a.length;a[--s]==0;)a.pop();return e.d=a,e.e=Me(a,r),k?A(e,u,c):e};f.precision=f.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(se+e);return n.d?(t=pt(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};f.round=function(){var e=this,t=e.constructor;return A(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())+N,r.rounding=1,n=en(r,ht(r,n)),r.precision=e,r.rounding=t,A(ne>2?n.neg():n,e,t,!0)):new r(NaN)};f.squareRoot=f.sqrt=function(){var e,t,n,r,o,i,s=this,u=s.d,c=s.e,a=s.s,l=s.constructor;if(a!==1||!u||!u[0])return new l(!a||a<0&&(!u||u[0])?NaN:u?s:1/0);for(k=!1,a=Math.sqrt(+s),a==0||a==1/0?(t=U(u),(t.length+c)%2==0&&(t+="0"),a=Math.sqrt(t),c=H((c+1)/2)-(c<0||c%2),a==1/0?t="5e"+c:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new l(t)):r=new l(a.toString()),n=(c=l.precision)+3;;)if(i=r,r=i.plus(R(s,i,n+2,1)).times(.5),U(i.d).slice(0,n)===(t=U(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!o&&t=="4999"){if(!o&&(A(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")&&(A(r,c+1,1),e=!r.times(r).eq(s));break}return k=!0,A(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=R(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,A(ne==2||ne==4?n.neg():n,e,t,!0)):new r(NaN)};f.times=f.mul=function(e){var t,n,r,o,i,s,u,c,a,l=this,m=l.constructor,p=l.d,d=(e=new m(e)).d;if(e.s*=l.s,!p||!p[0]||!d||!d[0])return new m(!e.s||p&&!p[0]&&!d||d&&!d[0]&&!p?NaN:!p||!d?e.s/0:e.s*0);for(n=H(l.e/N)+H(e.e/N),c=p.length,a=d.length,c<a&&(i=p,p=d,d=i,s=c,c=a,a=s),i=[],s=c+a,r=s;r--;)i.push(0);for(r=a;--r>=0;){for(t=0,o=c+r;o>r;)u=i[o]+d[r]*p[o-r-1]+t,i[o--]=u%X|0,t=u/X|0;i[o]=(i[o]+t)%X|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=Me(i,n),k?A(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:(j(e,0,ae),t===void 0?t=r.rounding:j(t,0,8),A(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):(j(e,0,ae),t===void 0?t=o.rounding:j(t,0,8),r=A(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):(j(e,0,ae),t===void 0?t=i.rounding:j(t,0,8),r=A(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,u,c,a,l,m,p,d=this,h=d.d,g=d.constructor;if(!h)return new g(d);if(a=n=new g(1),r=c=new g(0),t=new g(r),i=t.e=pt(h)-d.e-1,s=i%N,t.d[0]=v(10,s<0?N+s:s),e==null)e=i>0?t:a;else{if(u=new g(e),!u.isInt()||u.lt(a))throw Error(se+u);e=u.gt(t)?i>0?t:a:u}for(k=!1,u=new g(U(h)),l=g.precision,g.precision=i=h.length*N*2;m=R(u,t,0,1,1),o=n.plus(m.times(r)),o.cmp(e)!=1;)n=r,r=o,o=a,a=c.plus(m.times(o)),c=o,o=t,t=u.minus(m.times(o)),u=o;return o=R(e.minus(n),r,0,1,1),c=c.plus(o.times(a)),n=n.plus(o.times(r)),c.s=a.s=d.s,p=R(a,r,i,1).minus(d).abs().cmp(R(c,n,i,1).minus(d).abs())<1?[a,r]:[c,n],g.precision=l,k=!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:j(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]?(k=!1,n=R(n,e,0,t,1).times(e),k=!0,A(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,u=this,c=u.constructor,a=+(e=new c(e));if(!u.d||!e.d||!u.d[0]||!e.d[0])return new c(v(+u,a));if(u=new c(u),u.eq(1))return u;if(r=c.precision,i=c.rounding,e.eq(1))return A(u,r,i);if(t=H(e.e/N),t>=e.d.length-1&&(n=a<0?-a:a)<=Xt)return o=ft(c,u,n,r),e.s<0?new c(1).div(o):A(o,r,i);if(s=u.s,s<0){if(t<e.d.length-1)return new c(NaN);if((e.d[t]&1)==0&&(s=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=s,u}return n=v(+u,a),t=n==0||!isFinite(n)?H(a*(Math.log("0."+U(u.d))/Math.LN10+u.e+1)):new c(n+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(k=!1,c.rounding=u.s=1,n=Math.min(12,(t+"").length),o=Ge(e.times(oe(u,r+n)),r),o.d&&(o=A(o,r+5,1),be(o.d,r,i)&&(t=r+10,o=A(Ge(e.times(oe(u,t+n)),t),t+5,1),+U(o.d).slice(r+1,r+15)+1==1e14&&(o=A(o,r+1,0)))),o.s=s,k=!0,c.rounding=i,A(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):(j(e,1,ae),t===void 0?t=o.rounding:j(t,0,8),r=A(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):(j(e,1,ae),t===void 0?t=r.rounding:j(t,0,8)),A(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 A(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 U(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=N-r.length,n&&(i+=ie(n)),i+=r;s=e[t],r=s+"",n=N-r.length,n&&(i+=ie(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function j(e,t,n){if(e!==~~e||e<t||e>n)throw Error(se+e)}function be(e,t,n,r){var o,i,s,u;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=N,o=0):(o=Math.ceil((t+1)/N),t%=N),i=v(10,N-t),u=e[o]%i|0,r==null?t<3?(t==0?u=u/100|0:t==1&&(u=u/10|0),s=n<4&&u==99999||n>3&&u==49999||u==5e4||u==0):s=(n<4&&u+1==i||n>3&&u+1==i/2)&&(e[o+1]/i/100|0)==v(10,t-2)-1||(u==i/2||u==0)&&(e[o+1]/i/100|0)==0:t<4?(t==0?u=u/1e3|0:t==1?u=u/100|0:t==2&&(u=u/10|0),s=(r||n<4)&&u==9999||!r&&n>3&&u==4999):s=((r||n<4)&&u+1==i||!r&&n>3&&u+1==i/2)&&(e[o+1]/i/1e3|0)==v(10,t-3)-1,s}function Pe(e,t,n){for(var r,o=[0],i,s=0,u=e.length;s<u;){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=me(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 R=function(){function e(r,o,i){var s,u=0,c=r.length;for(r=r.slice();c--;)s=r[c]*o+u,r[c]=s%i|0,u=s/i|0;return u&&r.unshift(u),r}function t(r,o,i,s){var u,c;if(i!=s)c=i>s?1:-1;else for(u=c=0;u<i;u++)if(r[u]!=o[u]){c=r[u]>o[u]?1:-1;break}return c}function n(r,o,i,s){for(var u=0;i--;)r[i]-=u,u=r[i]<o[i]?1:0,r[i]=u*s+r[i]-o[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,o,i,s,u,c){var a,l,m,p,d,h,g,w,b,P,x,T,S,y,I,E,L,Q,D,F,W=r.constructor,K=r.s==o.s?1:-1,V=r.d,C=o.d;if(!V||!V[0]||!C||!C[0])return new W(!r.s||!o.s||(V?C&&V[0]==C[0]:!C)?NaN:V&&V[0]==0||!C?K*0:K/0);for(c?(d=1,l=r.e-o.e):(c=X,d=N,l=H(r.e/d)-H(o.e/d)),D=C.length,L=V.length,b=new W(K),P=b.d=[],m=0;C[m]==(V[m]||0);m++);if(C[m]>(V[m]||0)&&l--,i==null?(y=i=W.precision,s=W.rounding):u?y=i+(r.e-o.e)+1:y=i,y<0)P.push(1),h=!0;else{if(y=y/d+2|0,m=0,D==1){for(p=0,C=C[0],y++;(m<L||p)&&y--;m++)I=p*c+(V[m]||0),P[m]=I/C|0,p=I%C|0;h=p||m<L}else{for(p=c/(C[0]+1)|0,p>1&&(C=e(C,p,c),V=e(V,p,c),D=C.length,L=V.length),E=D,x=V.slice(0,D),T=x.length;T<D;)x[T++]=0;F=C.slice(),F.unshift(0),Q=C[0],C[1]>=c/2&&++Q;do p=0,a=t(C,x,D,T),a<0?(S=x[0],D!=T&&(S=S*c+(x[1]||0)),p=S/Q|0,p>1?(p>=c&&(p=c-1),g=e(C,p,c),w=g.length,T=x.length,a=t(g,x,w,T),a==1&&(p--,n(g,D<w?F:C,w,c))):(p==0&&(a=p=1),g=C.slice()),w=g.length,w<T&&g.unshift(0),n(x,g,T,c),a==-1&&(T=x.length,a=t(C,x,D,T),a<1&&(p++,n(x,D<T?F:C,T,c))),T=x.length):a===0&&(p++,x=[0]),P[m++]=p,a&&x[0]?x[T++]=V[E]||0:(x=[V[E]],T=1);while((E++<L||x[0]!==void 0)&&y--);h=x[0]!==void 0}P[0]||P.shift()}if(d==1)b.e=l,at=h;else{for(m=1,p=P[0];p>=10;p/=10)m++;b.e=m+l*d-1,A(b,u?i+b.e+1:i,s,h)}return b}}();function A(e,t,n,r){var o,i,s,u,c,a,l,m,p,d=e.constructor;e:if(t!=null){if(m=e.d,!m)return e;for(o=1,u=m[0];u>=10;u/=10)o++;if(i=t-o,i<0)i+=N,s=t,l=m[p=0],c=l/v(10,o-s-1)%10|0;else if(p=Math.ceil((i+1)/N),u=m.length,p>=u)if(r){for(;u++<=p;)m.push(0);l=c=0,o=1,i%=N,s=i-N+1}else break e;else{for(l=u=m[p],o=1;u>=10;u/=10)o++;i%=N,s=i-N+o,c=s<0?0:l/v(10,o-s-1)%10|0}if(r=r||t<0||m[p+1]!==void 0||(s<0?l:l%v(10,o-s-1)),a=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/v(10,o-s):0:m[p-1])%10&1||n==(e.s<0?8:7)),t<1||!m[0])return m.length=0,a?(t-=e.e+1,m[0]=v(10,(N-t%N)%N),e.e=-t||0):m[0]=e.e=0,e;if(i==0?(m.length=p,u=1,p--):(m.length=p+1,u=v(10,N-i),m[p]=s>0?(l/v(10,o-s)%v(10,s)|0)*u:0),a)for(;;)if(p==0){for(i=1,s=m[0];s>=10;s/=10)i++;for(s=m[0]+=u,u=1;s>=10;s/=10)u++;i!=u&&(e.e++,m[0]==X&&(m[0]=1));break}else{if(m[p]+=u,m[p]!=X)break;m[p--]=0,u=1}for(i=m.length;m[--i]===0;)m.pop()}return k&&(e.e>d.maxE?(e.d=null,e.e=NaN):e.e<d.minE&&(e.e=0,e.d=[0])),e}function J(e,t,n){if(!e.isFinite())return gt(e);var r,o=e.e,i=U(e.d),s=i.length;return t?(n&&(r=n-s)>0?i=i.charAt(0)+"."+i.slice(1)+ie(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):o<0?(i="0."+ie(-o-1)+i,n&&(r=n-s)>0&&(i+=ie(r))):o>=s?(i+=ie(o+1-s),n&&(r=n-o-1)>0&&(i=i+"."+ie(r))):((r=o+1)<s&&(i=i.slice(0,r)+"."+i.slice(r)),n&&(r=n-s)>0&&(o+1===s&&(i+="."),i+=ie(r))),i}function Me(e,t){var n=e[0];for(t*=N;n>=10;n/=10)t++;return t}function Ee(e,t,n){if(t>Zt)throw k=!0,n&&(e.precision=n),Error(ut);return A(new e(_e),t,1,!0)}function Z(e,t,n){if(t>qe)throw Error(ut);return A(new e(Ie),t,n,!0)}function pt(e){var t=e.length-1,n=t*N+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 ie(e){for(var t="";e--;)t+="0";return t}function ft(e,t,n,r){var o,i=new e(1),s=Math.ceil(r/N+4);for(k=!1;;){if(n%2&&(i=i.times(t),ot(i.d,s)&&(o=!0)),n=H(n/2),n===0){n=i.d.length-1,o&&i.d[n]===0&&++i.d[n];break}t=t.times(t),ot(t.d,s)}return k=!0,i}function it(e){return e.d[e.d.length-1]&1}function dt(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,u,c,a=0,l=0,m=0,p=e.constructor,d=p.rounding,h=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?(k=!1,c=h):c=t,u=new p(.03125);e.e>-2;)e=e.times(u),m+=5;for(r=Math.log(v(2,m))/Math.LN10*2+5|0,c+=r,n=i=s=new p(1),p.precision=c;;){if(i=A(i.times(e),c,1),n=n.times(++l),u=s.plus(R(i,n,c,1)),U(u.d).slice(0,c)===U(s.d).slice(0,c)){for(o=m;o--;)s=A(s.times(s),c,1);if(t==null)if(a<3&&be(s.d,c-r,d,a))p.precision=c+=10,n=i=u=new p(1),l=0,a++;else return A(s,p.precision=h,d,k=!0);else return p.precision=h,s}s=u}}function oe(e,t){var n,r,o,i,s,u,c,a,l,m,p,d=1,h=10,g=e,w=g.d,b=g.constructor,P=b.rounding,x=b.precision;if(g.s<0||!w||!w[0]||!g.e&&w[0]==1&&w.length==1)return new b(w&&!w[0]?-1/0:g.s!=1?NaN:w?0:g);if(t==null?(k=!1,l=x):l=t,b.precision=l+=h,n=U(w),r=n.charAt(0),Math.abs(i=g.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=U(g.d),r=n.charAt(0),d++;i=g.e,r>1?(g=new b("0."+n),i++):g=new b(r+"."+n.slice(1))}else return a=Ee(b,l+2,x).times(i+""),g=oe(new b(r+"."+n.slice(1)),l-h).plus(a),b.precision=x,t==null?A(g,x,P,k=!0):g;for(m=g,c=s=g=R(g.minus(1),g.plus(1),l,1),p=A(g.times(g),l,1),o=3;;){if(s=A(s.times(p),l,1),a=c.plus(R(s,new b(o),l,1)),U(a.d).slice(0,l)===U(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(Ee(b,l+2,x).times(i+""))),c=R(c,new b(d),l,1),t==null)if(be(c.d,l-h,P,u))b.precision=l+=h,a=s=g=R(m.minus(1),m.plus(1),l,1),p=A(g.times(g),l,1),o=u=1;else return A(c,b.precision=x,P,k=!0);else return b.precision=x,c;c=a,o+=2}}function gt(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)%N,n<0&&(r+=N),r<o){for(r&&e.d.push(+t.slice(0,r)),o-=N;r<o;)e.d.push(+t.slice(r,r+=N));t=t.slice(r),r=N-t.length}else r-=o;for(;r--;)t+="0";e.d.push(+t),k&&(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,u,c,a,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),mt.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(zt.test(t))n=16,t=t.toLowerCase();else if(Yt.test(t))n=2;else if(Qt.test(t))n=8;else throw Error(se+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(".",""),u=t.length,i=u-i,o=ft(r,new r(n),i,i*2)),a=Pe(t,n,X),l=a.length-1,i=l;a[i]===0;--i)a.pop();return i<0?new r(e.s*0):(e.e=Me(a,l),e.d=a,k=!1,s&&(e=R(e,o,u*4)),c&&(e=e.times(Math.abs(c)<54?v(2,c):Re.pow(2,c))),k=!0,e)}function en(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:me(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/Be(5,n)),t=me(e,2,t,t);for(var o,i=new e(5),s=new e(16),u=new e(20);n--;)o=t.times(t),t=t.times(i.plus(o.times(s.times(o).minus(u))));return t}function me(e,t,n,r,o){var i,s,u,c,a=1,l=e.precision,m=Math.ceil(l/N);for(k=!1,c=n.times(n),u=new e(r);;){if(s=R(u.times(c),new e(t++*t++),l,1),u=o?r.plus(s):r.minus(s),r=R(s.times(c),new e(t++*t++),l,1),s=u.plus(r),s.d[m]!==void 0){for(i=m;s.d[i]===u.d[i]&&i--;);if(i==-1)break}i=u,u=r,r=s,s=i,a++}return k=!0,s.d.length=m+1,s}function Be(e,t){for(var n=e;--t;)n*=e;return n}function ht(e,t){var n,r=t.s<0,o=Z(e,e.precision,1),i=o.times(.5);if(t=t.abs(),t.lte(i))return ne=r?4:1,t;if(n=t.divToInt(o),n.isZero())ne=r?3:2;else{if(t=t.minus(n.times(o)),t.lte(i))return ne=it(n)?r?2:3:r?4:1,t;ne=it(n)?r?1:4:r?3:2}return t.minus(o).abs()}function je(e,t,n,r){var o,i,s,u,c,a,l,m,p,d=e.constructor,h=n!==void 0;if(h?(j(n,1,ae),r===void 0?r=d.rounding:j(r,0,8)):(n=d.precision,r=d.rounding),!e.isFinite())l=gt(e);else{for(l=J(e),s=l.indexOf("."),h?(o=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):o=t,s>=0&&(l=l.replace(".",""),p=new d(1),p.e=l.length-s,p.d=Pe(J(p),10,o),p.e=p.d.length),m=Pe(l,10,o),i=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=h?"0p+0":"0";else{if(s<0?i--:(e=new d(e),e.d=m,e.e=i,e=R(e,p,n,r,0,o),m=e.d,i=e.e,a=at),s=m[n],u=o/2,a=a||m[n+1]!==void 0,a=r<4?(s!==void 0||a)&&(r===0||r===(e.s<0?3:2)):s>u||s===u&&(r===4||a||r===6&&m[n-1]&1||r===(e.s<0?8:7)),m.length=n,a)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(h){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(m=Pe(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 ot(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=Z(this,i,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Z(this,r,o):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Z(this,i,1).times(.5),n.s=e.s):t.s<0?(this.precision=i,this.rounding=1,n=this.atan(R(e,t,i,1)),t=Z(this,i,1),this.precision=r,this.rounding=o,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(R(e,t,i,1)),n}function mn(e){return new this(e).cbrt()}function pn(e){return A(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(Ce+"Object expected");var t,n,r,o=e.defaults===!0,i=["precision",1,ae,"rounding",0,8,"toExpNeg",-le,0,"toExpPos",0,le,"maxE",0,le,"minE",-le,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(n=i[t],o&&(this[n]=He[n]),(r=e[n])!==void 0)if(H(r)===r&&r>=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(se+n+": "+r);if(n="crypto",o&&(this[n]=He[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(ct);else this[n]=!1;else throw Error(se+n+": "+r);return this}function gn(e){return new this(e).cos()}function hn(e){return new this(e).cosh()}function bt(e){var t,n,r;function o(i){var s,u,c,a=this;if(!(a instanceof o))return new o(i);if(a.constructor=o,st(i)){a.s=i.s,k?!i.d||i.e>o.maxE?(a.e=NaN,a.d=null):i.e<o.minE?(a.e=0,a.d=[0]):(a.e=i.e,a.d=i.d.slice()):(a.e=i.e,a.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){a.s=1/i<0?-1:1,a.e=0,a.d=[0];return}if(i<0?(i=-i,a.s=-1):a.s=1,i===~~i&&i<1e7){for(s=0,u=i;u>=10;u/=10)s++;k?s>o.maxE?(a.e=NaN,a.d=null):s<o.minE?(a.e=0,a.d=[0]):(a.e=s,a.d=[i]):(a.e=s,a.d=[i]);return}if(i*0!==0){i||(a.s=NaN),a.e=NaN,a.d=null;return}return ke(a,i.toString())}if(c==="string")return(u=i.charCodeAt(0))===45?(i=i.slice(1),a.s=-1):(u===43&&(i=i.slice(1)),a.s=1),mt.test(i)?ke(a,i):$t(a,i);if(c==="bigint")return i<0?(i=-i,a.s=-1):a.s=1,ke(a,i.toString());throw Error(se+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=bt,o.isDecimal=st,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=Tn,o.floor=wn,o.hypot=An,o.ln=Sn,o.log=yn,o.log10=Nn,o.log2=xn,o.max=Pn,o.min=kn,o.mod=_n,o.mul=In,o.pow=En,o.random=Cn,o.round=Mn,o.sign=Bn,o.sin=Rn,o.sinh=Dn,o.sqrt=On,o.sub=Ln,o.sum=Fn,o.tan=Vn,o.tanh=vn,o.trunc=Kn,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 Tn(e){return new this(e).exp()}function wn(e){return A(e=new this(e),e.e+1,3)}function An(){var e,t,n=new this(0);for(k=!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 k=!0,new this(1/0);n=t}return k=!0,n.sqrt()}function st(e){return e instanceof Re||e&&e.toStringTag===lt||!1}function Sn(e){return new this(e).ln()}function yn(e,t){return new this(e).log(t)}function xn(e){return new this(e).log(2)}function Nn(e){return new this(e).log(10)}function Pn(){return dt(this,arguments,-1)}function kn(){return dt(this,arguments,1)}function _n(e,t){return new this(e).mod(t)}function In(e,t){return new this(e).mul(t)}function En(e,t){return new this(e).pow(t)}function Cn(e){var t,n,r,o,i=0,s=new this(1),u=[];if(e===void 0?e=this.precision:j(e,1,ae),r=Math.ceil(e/N),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]:u[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):(u.push(o%1e7),i+=4);i=r/4}else throw Error(ct);else for(;i<r;)u[i++]=Math.random()*1e7|0;for(r=u[--i],e%=N,r&&e&&(o=v(10,N-e),u[i]=(r/o|0)*o);u[i]===0;i--)u.pop();if(i<0)n=0,u=[0];else{for(n=-1;u[0]===0;n-=N)u.shift();for(r=1,o=u[0];o>=10;o/=10)r++;r<N&&(n-=N-r)}return s.e=n,s.d=u,s}function Mn(e){return A(e=new this(e),e.e+1,this.rounding)}function Bn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Rn(e){return new this(e).sin()}function Dn(e){return new this(e).sinh()}function On(e){return new this(e).sqrt()}function Ln(e,t){return new this(e).sub(t)}function Fn(){var e=0,t=arguments,n=new this(t[e]);for(k=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return k=!0,A(n,this.precision,this.rounding)}function Vn(e){return new this(e).tan()}function vn(e){return new this(e).tanh()}function Kn(e){return A(e=new this(e),e.e+1,1)}f[Symbol.for("nodejs.util.inspect.custom")]=f.toString;f[Symbol.toStringTag]="Decimal";var Re=f.constructor=bt(He);_e=new Re(_e);Ie=new Re(Ie);var yt=z(require("big.js")),Gn=z(require("bn.js"));var Tt=z(require("toformat")),Wn=Tt.default,Te=Wn;var we=z(require("big.js")),At=z(require("bn.js")),St=z(require("decimal.js-light"));var pe=z(require("bn.js"));var wt=9007199254740991;function re(e){let t=G("CobaltX_parseBigNumberish");if(e instanceof pe.default)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new pe.default(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=wt||e<=-wt)&&t.logWithError(`BigNumberish number overflow: ${e}`),new pe.default(String(e))):typeof e=="bigint"?new pe.default(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new pe.default(0))}var De=G("module/fraction"),Ye=Te(we.default),Ae=Te(St.default),Hn={[0]:Ae.ROUND_DOWN,[1]:Ae.ROUND_HALF_UP,[2]:Ae.ROUND_UP},qn={[0]:we.default.roundDown,[1]:we.default.roundHalfUp,[2]:we.default.roundUp},O=class{constructor(t,n=new At.default(1)){this.numerator=re(t),this.denominator=re(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new O(this.denominator,this.numerator)}add(t){let n=t instanceof O?t:new O(re(t));return this.denominator.eq(n.denominator)?new O(this.numerator.add(n.numerator),this.denominator):new O(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(t){let n=t instanceof O?t:new O(re(t));return this.denominator.eq(n.denominator)?new O(this.numerator.sub(n.numerator),this.denominator):new O(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(t){let n=t instanceof O?t:new O(re(t));return new O(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(t){let n=t instanceof O?t:new O(re(t));return new O(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(t,n={groupSeparator:""},r=1){Number.isInteger(t)||De.logWithError(`${t} is not an integer.`),t<=0&&De.logWithError(`${t} is not positive.`),Ae.set({precision:t+1,rounding:Hn[r]});let o=new Ae(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)||De.logWithError(`${t} is not an integer.`),t<0&&De.logWithError(`${t} is negative.`),Ye.DP=t,Ye.RM=qn[r]||1,new Ye(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)}isZero(){return this.numerator.isZero()}};var Mr=G("CobaltX_amount"),Br=Te(yt.default);var xt=require("@solana/spl-token"),Nt=require("@solana/web3.js");var $=require("@solana/web3.js");var Yn={["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:$.PublicKey.default.toString(),OUTPUT_MINT_ADDRESS:"742wcXVzkhNuEePAot7L3GvPseh93pvYFPgyHLX8mUy9",POPULAR_TOKENS:{SOL:$.PublicKey.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:$.PublicKey.default.toBase58(),OUTPUT_MINT_ADDRESS:"ABoT7umUXnx8RtJTeRqKB6myebVjP2wdJGQuV23jVVH3",POPULAR_TOKENS:{SOL:$.PublicKey.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:$.PublicKey.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:$.PublicKey.default.toString(),OUTPUT_MINT_ADDRESS:"63tPXWPnYeZ9hA3dJsAY5RcQ8YbwEz8uZ5nKu3uFD1aK",POPULAR_TOKENS:{SOL:$.PublicKey.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:$.PublicKey.default.toString(),OUTPUT_MINT_ADDRESS:"BoYN2f2gLQS4jpvMSV9dAZwfzKJiKGk4NPck5BjXfujo",POPULAR_TOKENS:{SOL:$.PublicKey.default.toString(),ETH:"FkvCG5DcuYCQ1BnPH4ZzTkCdk3VzutgyDAFBec4qAjhh",USDC:"BoYN2f2gLQS4jpvMSV9dAZwfzKJiKGk4NPck5BjXfujo",USDT:"J87bysZjwfS3n6KR21cwbdPZVJWNSFcXpWF5kiChAwQH"},WSOL_DECIMALS:9}},fe=e=>Yn[e];function de(e){let t=fe(e);return{chainId:101,address:Nt.PublicKey.default.toBase58(),programId:xt.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:t.NATIVE_TOKEN_SYMBOL,name:t.FULL_TOKEN_NAME,logoURI:t.GITHUB_LOGO_URL,tags:[],priority:2,type:"cobaltx",extensions:{coingeckoId:"solana"}}}var Qn=require("@solana/web3.js");var Pt=require("@solana/spl-token"),Y=require("@solana/web3.js");function ze({pubkey:e,isSigner:t=!1,isWritable:n=!0}){return{pubkey:e,isWritable:n,isSigner:t}}var Kr=[ze({pubkey:Pt.TOKEN_PROGRAM_ID,isWritable:!1}),ze({pubkey:Y.SystemProgram.programId,isWritable:!1}),ze({pubkey:Y.SYSVAR_RENT_PUBKEY,isWritable:!1})];var Wr=new Y.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Ur=new Y.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Hr=new Y.PublicKey("SysvarRent111111111111111111111111111111111"),qr=new Y.PublicKey("SysvarC1ock11111111111111111111111111111111"),Gr=new Y.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),jr=new Y.PublicKey("Sysvar1nstructions1111111111111111111111111"),Yr=Y.SystemProgram.programId,zn=Y.PublicKey.default;var _t=z(require("bn.js"));var oi=new O(new _t.default(100));var mi=G("CobaltX_price");var Zn=require("@solana/web3.js"),Jn=z(require("bn.js"));var Xn=new ee.default(0),ji=new ee.default(1),Yi=new ee.default(2),zi=new ee.default(3),Qi=new ee.default(5),jn=new ee.default(10),Xi=new ee.default(100),Zi=new ee.default(1e3),Ji=new ee.default(1e4);function Qe(e,t=1,n=[]){let r=[...e];if(t<=0)return n;for(;r.length;)n.push(r.splice(0,t));return n}var nr=require("@solana/web3.js"),rr=require("@solana/spl-token");var q=require("@solana/web3.js");var Xe={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",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"};var Bt=require("@solana/spl-token"),Mt=G("CobaltX_txUtil"),Rt=1644;function Oe(e){let t=[],n=[];return e.microLamports&&(t.push(q.ComputeBudgetProgram.setComputeUnitPrice({microLamports:e.microLamports})),n.push(Xe.SetComputeUnitPrice)),e.units&&(t.push(q.ComputeBudgetProgram.setComputeUnitLimit({units:e.units})),n.push(Xe.SetComputeUnitLimit)),{instructions:t,instructionTypes:n}}async function ge(e,t){var r,o;let n=t!=null?t:"confirmed";return(o=await((r=e.getLatestBlockhash)==null?void 0:r.call(e,{commitment:n})))==null?void 0:o.blockhash}async function Le(e,t){return e.getSignatureStatuses([t]),new Promise((n,r)=>{let o=setTimeout(r,6e4);e.onSignature(t,i=>{if(clearTimeout(o),!i.err){n("");return}r(i.err.toString())},"confirmed")})}function $n(e,t){e.length<1&&Mt.logWithError(`no instructions provided: ${e.toString()}`),t.length<1&&Mt.logWithError(`no signers provided:, ${t.toString()}`);let n=new q.Transaction;n.recentBlockhash="11111111111111111111111111111111",n.feePayer=t[0],n.add(...e);try{return Buffer.from(n.serialize({verifySignatures:!1})).toString("base64").length<Rt}catch{return!1}}function Se({instructions:e,payer:t,signers:n}){return $n(e,[t,...n])}function ye({instructions:e,payer:t,lookupTableAddressAccount:n,recentBlockhash:r=q.Keypair.generate().publicKey.toString()}){let i=new q.TransactionMessage({payerKey:t,recentBlockhash:r,instructions:e}).compileToV0Message(Object.values(n!=null?n:{}));try{return Buffer.from(new q.VersionedTransaction(i).serialize()).toString("base64").length<Rt}catch{return!1}}var er=e=>Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e),tr=e=>{let t=e.serialize({requireAllSignatures:!1,verifySignatures:!1});e instanceof q.VersionedTransaction&&(t=er(t));try{return t instanceof Buffer?t.toString("base64"):Buffer.from(t).toString("base64")}catch{return t.toString("base64")}};function ce(e){let t=[];return e.forEach(n=>{n instanceof q.Transaction&&(n.recentBlockhash||(n.recentBlockhash=Bt.TOKEN_PROGRAM_ID.toBase58()),n.feePayer||(n.feePayer=q.Keypair.generate().publicKey)),t.push(tr(n))}),console.log("simulate tx string:",t),t}var _=require("@solana/web3.js"),bo=new _.PublicKey("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),To=new _.PublicKey("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),wo=new _.PublicKey("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Ao=new _.PublicKey("FarmqiPv5e