@cobaltx/sdk-v2
Version:
An SDK for building applications on top of CobaltX.
1 lines • 404 kB
JavaScript
import fu from"axios";import{MINT_SIZE as ml,TOKEN_PROGRAM_ID as dl,getTransferFeeConfig as pl,unpackMint as fl}from"@solana/spl-token";import{PublicKey as xa}from"@solana/web3.js";import{get as Sr,set as Ia}from"lodash";var ll=(o=>(o[o.Error=0]="Error",o[o.Warning=1]="Warning",o[o.Info=2]="Info",o[o.Debug=3]="Debug",o))(ll||{}),Kr=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},Cr={},Ba={};function ce(i){let e=Sr(Cr,i);if(!e){let t=Sr(Ba,i);e=new Kr({name:i,logLevel:t}),Ia(Cr,i,e)}return e}function nb(i,e){Ia(Ba,i,e);let t=Sr(Cr,i);t&&(t.level=e)}var Lr=ce("CobaltX_accountInfo_util");async function Mt(i,e,t){let{batchRequest:n,commitment:o="confirmed",chunkCount:r=100}={batchRequest:!1,...t},s=Rr(e,r),a=new Array(s.length).fill([]);if(n){let u=s.map(m=>{let d=i._buildArgs([m.map(p=>p.toBase58())],o,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=Rr(u,10);a=(await(await Promise.all(c.map(async m=>await i._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&Lr.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:b,lamports:f,owner:y,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&Lr.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:b,lamports:f,owner:new xa(y),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(u=>i.getMultipleAccountsInfo(u,o)))}catch(u){u instanceof Error&&Lr.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return a.flat()}async function Ue(i,e,t){let n=await Mt(i,e.map(o=>o.pubkey),t);return e.map((o,r)=>({...o,accountInfo:n[r]}))}var bl=(n=>(n[n.Uninitialized=0]="Uninitialized",n[n.Mint=1]="Mint",n[n.Account=2]="Account",n))(bl||{}),mb=1;async function zn({connection:i,mints:e,config:t}){var r,s,a;if(e.length===0)return{};let n=await Ue(i,e.map(u=>({pubkey:ot(u)})),t),o={};for(let u of n){if(!u.accountInfo||u.accountInfo.data.length<ml){console.log("invalid mint account",u.pubkey.toBase58());continue}let c=fl(u.pubkey,u.accountInfo,(r=u.accountInfo)==null?void 0:r.owner);o[u.pubkey.toString()]={...c,programId:((s=u.accountInfo)==null?void 0:s.owner)||dl,feeConfig:(a=pl(c))!=null?a:void 0}}return o[xa.default.toBase58()]=o[H.toBase58()],o}import We from"bn.js";var Qn=9e15,fn=1e9,Or="0123456789abcdef",wo="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Po="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Mr={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Qn,maxE:Qn,crypto:!1},La,Zt,oe=!0,ho="[DecimalError] ",pn=ho+"Invalid argument: ",Ra=ho+"Precision limit exceeded",Oa=ho+"crypto unavailable",Ma="[object Decimal]",rt=Math.floor,ze=Math.pow,yl=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,gl=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Al=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Na=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,_t=1e7,te=7,wl=9007199254740991,Pl=wo.length-1,Nr=Po.length-1,E={toStringTag:Ma};E.absoluteValue=E.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),$(i)};E.ceil=function(){return $(new this.constructor(this),this.e+1,2)};E.clampedTo=E.clamp=function(i,e){var t,n=this,o=n.constructor;if(i=new o(i),e=new o(e),!i.s||!e.s)return new o(NaN);if(i.gt(e))throw Error(pn+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new o(n)};E.comparedTo=E.cmp=function(i){var e,t,n,o,r=this,s=r.d,a=(i=new r.constructor(i)).d,u=r.s,c=i.s;if(!s||!a)return!u||!c?NaN:u!==c?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-c:0;if(u!==c)return u;if(r.e!==i.e)return r.e>i.e^u<0?1:-1;for(n=s.length,o=a.length,e=0,t=n<o?n:o;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^u<0?1:-1;return n===o?0:n>o^u<0?1:-1};E.cosine=E.cos=function(){var i,e,t=this,n=t.constructor;return t.d?t.d[0]?(i=n.precision,e=n.rounding,n.precision=i+Math.max(t.e,t.sd())+te,n.rounding=1,t=kl(n,Fa(n,t)),n.precision=i,n.rounding=e,$(Zt==2||Zt==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};E.cubeRoot=E.cbrt=function(){var i,e,t,n,o,r,s,a,u,c,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(oe=!1,r=l.s*ze(l.s*l,1/3),!r||Math.abs(r)==1/0?(t=et(l.d),i=l.e,(r=(i-t.length+1)%3)&&(t+=r==1||r==-2?"0":"00"),r=ze(t,1/3),i=rt((i+1)/3)-(i%3==(i<0?-1:2)),r==1/0?t="5e"+i:(t=r.toExponential(),t=t.slice(0,t.indexOf("e")+1)+i),n=new m(t),n.s=l.s):n=new m(r.toString()),s=(i=m.precision)+3;;)if(a=n,u=a.times(a).times(a),c=u.plus(l),n=he(c.plus(l).times(a),c.plus(u),s+2,1),et(a.d).slice(0,s)===(t=et(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!o&&t=="4999"){if(!o&&($(a,i+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&($(n,i+1,1),e=!n.times(n).times(n).eq(l));break}return oe=!0,$(n,i,m.rounding,e)};E.decimalPlaces=E.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-rt(this.e/te))*te,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};E.dividedBy=E.div=function(i){return he(this,new this.constructor(i))};E.dividedToIntegerBy=E.divToInt=function(i){var e=this,t=e.constructor;return $(he(e,new t(i),0,1,1),t.precision,t.rounding)};E.equals=E.eq=function(i){return this.cmp(i)===0};E.floor=function(){return $(new this.constructor(this),this.e+1,3)};E.greaterThan=E.gt=function(i){return this.cmp(i)>0};E.greaterThanOrEqualTo=E.gte=function(i){var e=this.cmp(i);return e==1||e===0};E.hyperbolicCosine=E.cosh=function(){var i,e,t,n,o,r=this,s=r.constructor,a=new s(1);if(!r.isFinite())return new s(r.s?1/0:NaN);if(r.isZero())return a;t=s.precision,n=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,o=r.d.length,o<32?(i=Math.ceil(o/3),e=(1/Io(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),r=Hn(s,1,r.times(e),new s(1),!0);for(var u,c=i,l=new s(8);c--;)u=r.times(r),r=a.minus(u.times(l.minus(u.times(l))));return $(r,s.precision=t,s.rounding=n,!0)};E.hyperbolicSine=E.sinh=function(){var i,e,t,n,o=this,r=o.constructor;if(!o.isFinite()||o.isZero())return new r(o);if(e=r.precision,t=r.rounding,r.precision=e+Math.max(o.e,o.sd())+4,r.rounding=1,n=o.d.length,n<3)o=Hn(r,2,o,o,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,o=o.times(1/Io(5,i)),o=Hn(r,2,o,o,!0);for(var s,a=new r(5),u=new r(16),c=new r(20);i--;)s=o.times(o),o=o.times(a.plus(s.times(u.times(s).plus(c))))}return r.precision=e,r.rounding=t,$(o,e,t,!0)};E.hyperbolicTangent=E.tanh=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+7,n.rounding=1,he(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};E.inverseCosine=E.acos=function(){var i,e=this,t=e.constructor,n=e.abs().cmp(1),o=t.precision,r=t.rounding;return n!==-1?n===0?e.isNeg()?Nt(t,o,r):new t(0):new t(NaN):e.isZero()?Nt(t,o+4,r).times(.5):(t.precision=o+6,t.rounding=1,e=e.asin(),i=Nt(t,o+4,r).times(.5),t.precision=o,t.rounding=r,i.minus(e))};E.inverseHyperbolicCosine=E.acosh=function(){var i,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(i=n.precision,e=n.rounding,n.precision=i+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,oe=!1,t=t.times(t).minus(1).sqrt().plus(t),oe=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};E.inverseHyperbolicSine=E.asinh=function(){var i,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,oe=!1,t=t.times(t).plus(1).sqrt().plus(t),oe=!0,n.precision=i,n.rounding=e,t.ln())};E.inverseHyperbolicTangent=E.atanh=function(){var i,e,t,n,o=this,r=o.constructor;return o.isFinite()?o.e>=0?new r(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(i=r.precision,e=r.rounding,n=o.sd(),Math.max(n,i)<2*-o.e-1?$(new r(o),i,e,!0):(r.precision=t=n-o.e,o=he(o.plus(1),new r(1).minus(o),t+i,1),r.precision=i+4,r.rounding=1,o=o.ln(),r.precision=i,r.rounding=e,o.times(.5))):new r(NaN)};E.inverseSine=E.asin=function(){var i,e,t,n,o=this,r=o.constructor;return o.isZero()?new r(o):(e=o.abs().cmp(1),t=r.precision,n=r.rounding,e!==-1?e===0?(i=Nt(r,t+4,n).times(.5),i.s=o.s,i):new r(NaN):(r.precision=t+6,r.rounding=1,o=o.div(new r(1).minus(o.times(o)).sqrt().plus(1)).atan(),r.precision=t,r.rounding=n,o.times(2)))};E.inverseTangent=E.atan=function(){var i,e,t,n,o,r,s,a,u,c=this,l=c.constructor,m=l.precision,d=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&m+4<=Nr)return s=Nt(l,m+4,d).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(m+4<=Nr)return s=Nt(l,m+4,d).times(.5),s.s=c.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/te+2|0),i=t;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(oe=!1,e=Math.ceil(a/te),n=1,u=c.times(c),s=new l(c),o=c;i!==-1;)if(o=o.times(u),r=s.minus(o.div(n+=2)),o=o.times(u),s=r.plus(o.div(n+=2)),s.d[e]!==void 0)for(i=e;s.d[i]===r.d[i]&&i--;);return t&&(s=s.times(2<<t-1)),oe=!0,$(s,l.precision=m,l.rounding=d,!0)};E.isFinite=function(){return!!this.d};E.isInteger=E.isInt=function(){return!!this.d&&rt(this.e/te)>this.d.length-2};E.isNaN=function(){return!this.s};E.isNegative=E.isNeg=function(){return this.s<0};E.isPositive=E.isPos=function(){return this.s>0};E.isZero=function(){return!!this.d&&this.d[0]===0};E.lessThan=E.lt=function(i){return this.cmp(i)<0};E.lessThanOrEqualTo=E.lte=function(i){return this.cmp(i)<1};E.logarithm=E.log=function(i){var e,t,n,o,r,s,a,u,c=this,l=c.constructor,m=l.precision,d=l.rounding,p=5;if(i==null)i=new l(10),e=!0;else{if(i=new l(i),t=i.d,i.s<0||!t||!t[0]||i.eq(1))return new l(NaN);e=i.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new l(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)r=!0;else{for(o=t[0];o%10===0;)o/=10;r=o!==1}if(oe=!1,a=m+p,s=dn(c,a),n=e?ko(l,a+10):dn(i,a),u=he(s,n,a,1),di(u.d,o=m,d))do if(a+=10,s=dn(c,a),n=e?ko(l,a+10):dn(i,a),u=he(s,n,a,1),!r){+et(u.d).slice(o+1,o+15)+1==1e14&&(u=$(u,m+1,0));break}while(di(u.d,o+=10,d));return oe=!0,$(u,m,d)};E.minus=E.sub=function(i){var e,t,n,o,r,s,a,u,c,l,m,d,p=this,b=p.constructor;if(i=new b(i),!p.d||!i.d)return!p.s||!i.s?i=new b(NaN):p.d?i.s=-i.s:i=new b(i.d||p.s!==i.s?p:NaN),i;if(p.s!=i.s)return i.s=-i.s,p.plus(i);if(c=p.d,d=i.d,a=b.precision,u=b.rounding,!c[0]||!d[0]){if(d[0])i.s=-i.s;else if(c[0])i=new b(p);else return new b(u===3?-0:0);return oe?$(i,a,u):i}if(t=rt(i.e/te),l=rt(p.e/te),c=c.slice(),r=l-t,r){for(m=r<0,m?(e=c,r=-r,s=d.length):(e=d,t=l,s=c.length),n=Math.max(Math.ceil(a/te),s)+2,r>n&&(r=n,e.length=1),e.reverse(),n=r;n--;)e.push(0);e.reverse()}else{for(n=c.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(c[n]!=d[n]){m=c[n]<d[n];break}r=0}for(m&&(e=c,c=d,d=e,i.s=-i.s),s=c.length,n=d.length-s;n>0;--n)c[s++]=0;for(n=d.length;n>r;){if(c[--n]<d[n]){for(o=n;o&&c[--o]===0;)c[o]=_t-1;--c[o],c[n]+=_t}c[n]-=d[n]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(i.d=c,i.e=To(c,t),oe?$(i,a,u):i):new b(u===3?-0:0)};E.modulo=E.mod=function(i){var e,t=this,n=t.constructor;return i=new n(i),!t.d||!i.s||i.d&&!i.d[0]?new n(NaN):!i.d||t.d&&!t.d[0]?$(new n(t),n.precision,n.rounding):(oe=!1,n.modulo==9?(e=he(t,i.abs(),0,3,1),e.s*=i.s):e=he(t,i,0,n.modulo,1),e=e.times(i),oe=!0,t.minus(e))};E.naturalExponential=E.exp=function(){return _r(this)};E.naturalLogarithm=E.ln=function(){return dn(this)};E.negated=E.neg=function(){var i=new this.constructor(this);return i.s=-i.s,$(i)};E.plus=E.add=function(i){var e,t,n,o,r,s,a,u,c,l,m=this,d=m.constructor;if(i=new d(i),!m.d||!i.d)return!m.s||!i.s?i=new d(NaN):m.d||(i=new d(i.d||m.s===i.s?m:NaN)),i;if(m.s!=i.s)return i.s=-i.s,m.minus(i);if(c=m.d,l=i.d,a=d.precision,u=d.rounding,!c[0]||!l[0])return l[0]||(i=new d(m)),oe?$(i,a,u):i;if(r=rt(m.e/te),n=rt(i.e/te),c=c.slice(),o=r-n,o){for(o<0?(t=c,o=-o,s=l.length):(t=l,n=r,s=c.length),r=Math.ceil(a/te),s=r>s?r+1:s+1,o>s&&(o=s,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(s=c.length,o=l.length,s-o<0&&(o=s,t=l,l=c,c=t),e=0;o;)e=(c[--o]=c[o]+l[o]+e)/_t|0,c[o]%=_t;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=To(c,n),oe?$(i,a,u):i};E.precision=E.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(pn+i);return t.d?(e=_a(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};E.round=function(){var i=this,e=i.constructor;return $(new e(i),i.e+1,e.rounding)};E.sine=E.sin=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+Math.max(t.e,t.sd())+te,n.rounding=1,t=Tl(n,Fa(n,t)),n.precision=i,n.rounding=e,$(Zt>2?t.neg():t,i,e,!0)):new n(NaN)};E.squareRoot=E.sqrt=function(){var i,e,t,n,o,r,s=this,a=s.d,u=s.e,c=s.s,l=s.constructor;if(c!==1||!a||!a[0])return new l(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(oe=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=et(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=rt((u+1)/2)-(u<0||u%2),c==1/0?e="5e"+u:(e=c.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),n=new l(e)):n=new l(c.toString()),t=(u=l.precision)+3;;)if(r=n,n=r.plus(he(s,r,t+2,1)).times(.5),et(r.d).slice(0,t)===(e=et(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!o&&e=="4999"){if(!o&&($(r,u+1,0),r.times(r).eq(s))){n=r;break}t+=4,o=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&($(n,u+1,1),i=!n.times(n).eq(s));break}return oe=!0,$(n,u,l.rounding,i)};E.tangent=E.tan=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+10,n.rounding=1,t=t.sin(),t.s=1,t=he(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,$(Zt==2||Zt==4?t.neg():t,i,e,!0)):new n(NaN)};E.times=E.mul=function(i){var e,t,n,o,r,s,a,u,c,l=this,m=l.constructor,d=l.d,p=(i=new m(i)).d;if(i.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!i.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?i.s/0:i.s*0);for(t=rt(l.e/te)+rt(i.e/te),u=d.length,c=p.length,u<c&&(r=d,d=p,p=r,s=u,u=c,c=s),r=[],s=u+c,n=s;n--;)r.push(0);for(n=c;--n>=0;){for(e=0,o=u+n;o>n;)a=r[o]+p[n]*d[o-n-1]+e,r[o--]=a%_t|0,e=a/_t|0;r[o]=(r[o]+e)%_t|0}for(;!r[--s];)r.pop();return e?++t:r.shift(),i.d=r,i.e=To(r,t),oe?$(i,m.precision,m.rounding):i};E.toBinary=function(i,e){return Vr(this,2,i,e)};E.toDecimalPlaces=E.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(gt(i,0,fn),e===void 0?e=n.rounding:gt(e,0,8),$(t,i+t.e+1,e))};E.toExponential=function(i,e){var t,n=this,o=n.constructor;return i===void 0?t=Gt(n,!0):(gt(i,0,fn),e===void 0?e=o.rounding:gt(e,0,8),n=$(new o(n),i+1,e),t=Gt(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};E.toFixed=function(i,e){var t,n,o=this,r=o.constructor;return i===void 0?t=Gt(o):(gt(i,0,fn),e===void 0?e=r.rounding:gt(e,0,8),n=$(new r(o),i+o.e+1,e),t=Gt(n,!1,i+n.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};E.toFraction=function(i){var e,t,n,o,r,s,a,u,c,l,m,d,p=this,b=p.d,f=p.constructor;if(!b)return new f(p);if(c=t=new f(1),n=u=new f(0),e=new f(n),r=e.e=_a(b)-p.e-1,s=r%te,e.d[0]=ze(10,s<0?te+s:s),i==null)i=r>0?e:c;else{if(a=new f(i),!a.isInt()||a.lt(c))throw Error(pn+a);i=a.gt(e)?r>0?e:c:a}for(oe=!1,a=new f(et(b)),l=f.precision,f.precision=r=b.length*te*2;m=he(a,e,0,1,1),o=t.plus(m.times(n)),o.cmp(i)!=1;)t=n,n=o,o=c,c=u.plus(m.times(o)),u=o,o=e,e=a.minus(m.times(o)),a=o;return o=he(i.minus(t),n,0,1,1),u=u.plus(o.times(c)),t=t.plus(o.times(n)),u.s=c.s=p.s,d=he(c,n,r,1).minus(p).abs().cmp(he(u,t,r,1).minus(p).abs())<1?[c,n]:[u,t],f.precision=l,oe=!0,d};E.toHexadecimal=E.toHex=function(i,e){return Vr(this,16,i,e)};E.toNearest=function(i,e){var t=this,n=t.constructor;if(t=new n(t),i==null){if(!t.d)return t;i=new n(1),e=n.rounding}else{if(i=new n(i),e===void 0?e=n.rounding:gt(e,0,8),!t.d)return i.s?t:i;if(!i.d)return i.s&&(i.s=t.s),i}return i.d[0]?(oe=!1,t=he(t,i,0,e,1).times(i),oe=!0,$(t)):(i.s=t.s,t=i),t};E.toNumber=function(){return+this};E.toOctal=function(i,e){return Vr(this,8,i,e)};E.toPower=E.pow=function(i){var e,t,n,o,r,s,a=this,u=a.constructor,c=+(i=new u(i));if(!a.d||!i.d||!a.d[0]||!i.d[0])return new u(ze(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,r=u.rounding,i.eq(1))return $(a,n,r);if(e=rt(i.e/te),e>=i.d.length-1&&(t=c<0?-c:c)<=wl)return o=va(u,a,t,n),i.s<0?new u(1).div(o):$(o,n,r);if(s=a.s,s<0){if(e<i.d.length-1)return new u(NaN);if((i.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=ze(+a,c),e=t==0||!isFinite(t)?rt(c*(Math.log("0."+et(a.d))/Math.LN10+a.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?s/0:0):(oe=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),o=_r(i.times(dn(a,n+t)),n),o.d&&(o=$(o,n+5,1),di(o.d,n,r)&&(e=n+10,o=$(_r(i.times(dn(a,e+t)),e),e+5,1),+et(o.d).slice(n+1,n+15)+1==1e14&&(o=$(o,n+1,0)))),o.s=s,oe=!0,u.rounding=r,$(o,n,r))};E.toPrecision=function(i,e){var t,n=this,o=n.constructor;return i===void 0?t=Gt(n,n.e<=o.toExpNeg||n.e>=o.toExpPos):(gt(i,1,fn),e===void 0?e=o.rounding:gt(e,0,8),n=$(new o(n),i,e),t=Gt(n,i<=n.e||n.e<=o.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};E.toSignificantDigits=E.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(gt(i,1,fn),e===void 0?e=n.rounding:gt(e,0,8)),$(new n(t),i,e)};E.toString=function(){var i=this,e=i.constructor,t=Gt(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};E.truncated=E.trunc=function(){return $(new this.constructor(this),this.e+1,1)};E.valueOf=E.toJSON=function(){var i=this,e=i.constructor,t=Gt(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function et(i){var e,t,n,o=i.length-1,r="",s=i[0];if(o>0){for(r+=s,e=1;e<o;e++)n=i[e]+"",t=te-n.length,t&&(r+=mn(t)),r+=n;s=i[e],n=s+"",t=te-n.length,t&&(r+=mn(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function gt(i,e,t){if(i!==~~i||i<e||i>t)throw Error(pn+i)}function di(i,e,t,n){var o,r,s,a;for(r=i[0];r>=10;r/=10)--e;return--e<0?(e+=te,o=0):(o=Math.ceil((e+1)/te),e%=te),r=ze(10,te-e),a=i[o]%r|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==r||t>3&&a+1==r/2)&&(i[o+1]/r/100|0)==ze(10,e-2)-1||(a==r/2||a==0)&&(i[o+1]/r/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(n||t<4)&&a==9999||!n&&t>3&&a==4999):s=((n||t<4)&&a+1==r||!n&&t>3&&a+1==r/2)&&(i[o+1]/r/1e3|0)==ze(10,e-3)-1,s}function Ao(i,e,t){for(var n,o=[0],r,s=0,a=i.length;s<a;){for(r=o.length;r--;)o[r]*=e;for(o[0]+=Or.indexOf(i.charAt(s++)),n=0;n<o.length;n++)o[n]>t-1&&(o[n+1]===void 0&&(o[n+1]=0),o[n+1]+=o[n]/t|0,o[n]%=t)}return o.reverse()}function kl(i,e){var t,n,o;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),o=(1/Io(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),i.precision+=t,e=Hn(i,1,e.times(o),new i(1));for(var r=t;r--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return i.precision-=t,e}var he=function(){function i(n,o,r){var s,a=0,u=n.length;for(n=n.slice();u--;)s=n[u]*o+a,n[u]=s%r|0,a=s/r|0;return a&&n.unshift(a),n}function e(n,o,r,s){var a,u;if(r!=s)u=r>s?1:-1;else for(a=u=0;a<r;a++)if(n[a]!=o[a]){u=n[a]>o[a]?1:-1;break}return u}function t(n,o,r,s){for(var a=0;r--;)n[r]-=a,a=n[r]<o[r]?1:0,n[r]=a*s+n[r]-o[r];for(;!n[0]&&n.length>1;)n.shift()}return function(n,o,r,s,a,u){var c,l,m,d,p,b,f,y,g,w,P,h,I,T,S,B,C,x,K,V,R=n.constructor,G=n.s==o.s?1:-1,U=n.d,W=o.d;if(!U||!U[0]||!W||!W[0])return new R(!n.s||!o.s||(U?W&&U[0]==W[0]:!W)?NaN:U&&U[0]==0||!W?G*0:G/0);for(u?(p=1,l=n.e-o.e):(u=_t,p=te,l=rt(n.e/p)-rt(o.e/p)),K=W.length,C=U.length,g=new R(G),w=g.d=[],m=0;W[m]==(U[m]||0);m++);if(W[m]>(U[m]||0)&&l--,r==null?(T=r=R.precision,s=R.rounding):a?T=r+(n.e-o.e)+1:T=r,T<0)w.push(1),b=!0;else{if(T=T/p+2|0,m=0,K==1){for(d=0,W=W[0],T++;(m<C||d)&&T--;m++)S=d*u+(U[m]||0),w[m]=S/W|0,d=S%W|0;b=d||m<C}else{for(d=u/(W[0]+1)|0,d>1&&(W=i(W,d,u),U=i(U,d,u),K=W.length,C=U.length),B=K,P=U.slice(0,K),h=P.length;h<K;)P[h++]=0;V=W.slice(),V.unshift(0),x=W[0],W[1]>=u/2&&++x;do d=0,c=e(W,P,K,h),c<0?(I=P[0],K!=h&&(I=I*u+(P[1]||0)),d=I/x|0,d>1?(d>=u&&(d=u-1),f=i(W,d,u),y=f.length,h=P.length,c=e(f,P,y,h),c==1&&(d--,t(f,K<y?V:W,y,u))):(d==0&&(c=d=1),f=W.slice()),y=f.length,y<h&&f.unshift(0),t(P,f,h,u),c==-1&&(h=P.length,c=e(W,P,K,h),c<1&&(d++,t(P,K<h?V:W,h,u))),h=P.length):c===0&&(d++,P=[0]),w[m++]=d,c&&P[0]?P[h++]=U[B]||0:(P=[U[B]],h=1);while((B++<C||P[0]!==void 0)&&T--);b=P[0]!==void 0}w[0]||w.shift()}if(p==1)g.e=l,La=b;else{for(m=1,d=w[0];d>=10;d/=10)m++;g.e=m+l*p-1,$(g,a?r+g.e+1:r,s,b)}return g}}();function $(i,e,t,n){var o,r,s,a,u,c,l,m,d,p=i.constructor;e:if(e!=null){if(m=i.d,!m)return i;for(o=1,a=m[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=te,s=e,l=m[d=0],u=l/ze(10,o-s-1)%10|0;else if(d=Math.ceil((r+1)/te),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=u=0,o=1,r%=te,s=r-te+1}else break e;else{for(l=a=m[d],o=1;a>=10;a/=10)o++;r%=te,s=r-te+o,u=s<0?0:l/ze(10,o-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%ze(10,o-s-1)),c=t<4?(u||n)&&(t==0||t==(i.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(r>0?s>0?l/ze(10,o-s):0:m[d-1])%10&1||t==(i.s<0?8:7)),e<1||!m[0])return m.length=0,c?(e-=i.e+1,m[0]=ze(10,(te-e%te)%te),i.e=-e||0):m[0]=i.e=0,i;if(r==0?(m.length=d,a=1,d--):(m.length=d+1,a=ze(10,te-r),m[d]=s>0?(l/ze(10,o-s)%ze(10,s)|0)*a:0),c)for(;;)if(d==0){for(r=1,s=m[0];s>=10;s/=10)r++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;r!=a&&(i.e++,m[0]==_t&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=_t)break;m[d--]=0,a=1}for(r=m.length;m[--r]===0;)m.pop()}return oe&&(i.e>p.maxE?(i.d=null,i.e=NaN):i.e<p.minE&&(i.e=0,i.d=[0])),i}function Gt(i,e,t){if(!i.isFinite())return Ea(i);var n,o=i.e,r=et(i.d),s=r.length;return e?(t&&(n=t-s)>0?r=r.charAt(0)+"."+r.slice(1)+mn(n):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(i.e<0?"e":"e+")+i.e):o<0?(r="0."+mn(-o-1)+r,t&&(n=t-s)>0&&(r+=mn(n))):o>=s?(r+=mn(o+1-s),t&&(n=t-o-1)>0&&(r=r+"."+mn(n))):((n=o+1)<s&&(r=r.slice(0,n)+"."+r.slice(n)),t&&(n=t-s)>0&&(o+1===s&&(r+="."),r+=mn(n))),r}function To(i,e){var t=i[0];for(e*=te;t>=10;t/=10)e++;return e}function ko(i,e,t){if(e>Pl)throw oe=!0,t&&(i.precision=t),Error(Ra);return $(new i(wo),e,1,!0)}function Nt(i,e,t){if(e>Nr)throw Error(Ra);return $(new i(Po),e,t,!0)}function _a(i){var e=i.length-1,t=e*te+1;if(e=i[e],e){for(;e%10==0;e/=10)t--;for(e=i[0];e>=10;e/=10)t++}return t}function mn(i){for(var e="";i--;)e+="0";return e}function va(i,e,t,n){var o,r=new i(1),s=Math.ceil(n/te+4);for(oe=!1;;){if(t%2&&(r=r.times(e),Ka(r.d,s)&&(o=!0)),t=rt(t/2),t===0){t=r.d.length-1,o&&r.d[t]===0&&++r.d[t];break}e=e.times(e),Ka(e.d,s)}return oe=!0,r}function Sa(i){return i.d[i.d.length-1]&1}function Va(i,e,t){for(var n,o=new i(e[0]),r=0;++r<e.length;)if(n=new i(e[r]),n.s)o[t](n)&&(o=n);else{o=n;break}return o}function _r(i,e){var t,n,o,r,s,a,u,c=0,l=0,m=0,d=i.constructor,p=d.rounding,b=d.precision;if(!i.d||!i.d[0]||i.e>17)return new d(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:0/0);for(e==null?(oe=!1,u=b):u=e,a=new d(.03125);i.e>-2;)i=i.times(a),m+=5;for(n=Math.log(ze(2,m))/Math.LN10*2+5|0,u+=n,t=r=s=new d(1),d.precision=u;;){if(r=$(r.times(i),u,1),t=t.times(++l),a=s.plus(he(r,t,u,1)),et(a.d).slice(0,u)===et(s.d).slice(0,u)){for(o=m;o--;)s=$(s.times(s),u,1);if(e==null)if(c<3&&di(s.d,u-n,p,c))d.precision=u+=10,t=r=a=new d(1),l=0,c++;else return $(s,d.precision=b,p,oe=!0);else return d.precision=b,s}s=a}}function dn(i,e){var t,n,o,r,s,a,u,c,l,m,d,p=1,b=10,f=i,y=f.d,g=f.constructor,w=g.rounding,P=g.precision;if(f.s<0||!y||!y[0]||!f.e&&y[0]==1&&y.length==1)return new g(y&&!y[0]?-1/0:f.s!=1?NaN:y?0:f);if(e==null?(oe=!1,l=P):l=e,g.precision=l+=b,t=et(y),n=t.charAt(0),Math.abs(r=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(i),t=et(f.d),n=t.charAt(0),p++;r=f.e,n>1?(f=new g("0."+t),r++):f=new g(n+"."+t.slice(1))}else return c=ko(g,l+2,P).times(r+""),f=dn(new g(n+"."+t.slice(1)),l-b).plus(c),g.precision=P,e==null?$(f,P,w,oe=!0):f;for(m=f,u=s=f=he(f.minus(1),f.plus(1),l,1),d=$(f.times(f),l,1),o=3;;){if(s=$(s.times(d),l,1),c=u.plus(he(s,new g(o),l,1)),et(c.d).slice(0,l)===et(u.d).slice(0,l))if(u=u.times(2),r!==0&&(u=u.plus(ko(g,l+2,P).times(r+""))),u=he(u,new g(p),l,1),e==null)if(di(u.d,l-b,w,a))g.precision=l+=b,c=s=f=he(m.minus(1),m.plus(1),l,1),d=$(f.times(f),l,1),o=a=1;else return $(u,g.precision=P,w,oe=!0);else return g.precision=P,u;u=c,o+=2}}function Ea(i){return String(i.s*i.s/0)}function vr(i,e){var t,n,o;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(o=e.length;e.charCodeAt(o-1)===48;--o);if(e=e.slice(n,o),e){if(o-=n,i.e=t=t-n-1,i.d=[],n=(t+1)%te,t<0&&(n+=te),n<o){for(n&&i.d.push(+e.slice(0,n)),o-=te;n<o;)i.d.push(+e.slice(n,n+=te));e=e.slice(n),n=te-e.length}else n-=o;for(;n--;)e+="0";i.d.push(+e),oe&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function hl(i,e){var t,n,o,r,s,a,u,c,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Na.test(e))return vr(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(gl.test(e))t=16,e=e.toLowerCase();else if(yl.test(e))t=2;else if(Al.test(e))t=8;else throw Error(pn+e);for(r=e.search(/p/i),r>0?(u=+e.slice(r+1),e=e.substring(2,r)):e=e.slice(2),r=e.indexOf("."),s=r>=0,n=i.constructor,s&&(e=e.replace(".",""),a=e.length,r=a-r,o=va(n,new n(t),r,r*2)),c=Ao(e,t,_t),l=c.length-1,r=l;c[r]===0;--r)c.pop();return r<0?new n(i.s*0):(i.e=To(c,l),i.d=c,oe=!1,s&&(i=he(i,o,a*4)),u&&(i=i.times(Math.abs(u)<54?ze(2,u):pi.pow(2,u))),oe=!0,i)}function Tl(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:Hn(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Io(5,t)),e=Hn(i,2,e,e);for(var o,r=new i(5),s=new i(16),a=new i(20);t--;)o=e.times(e),e=e.times(r.plus(o.times(s.times(o).minus(a))));return e}function Hn(i,e,t,n,o){var r,s,a,u,c=1,l=i.precision,m=Math.ceil(l/te);for(oe=!1,u=t.times(t),a=new i(n);;){if(s=he(a.times(u),new i(e++*e++),l,1),a=o?n.plus(s):n.minus(s),n=he(s.times(u),new i(e++*e++),l,1),s=a.plus(n),s.d[m]!==void 0){for(r=m;s.d[r]===a.d[r]&&r--;);if(r==-1)break}r=a,a=n,n=s,s=r,c++}return oe=!0,s.d.length=m+1,s}function Io(i,e){for(var t=i;--e;)t*=i;return t}function Fa(i,e){var t,n=e.s<0,o=Nt(i,i.precision,1),r=o.times(.5);if(e=e.abs(),e.lte(r))return Zt=n?4:1,e;if(t=e.divToInt(o),t.isZero())Zt=n?3:2;else{if(e=e.minus(t.times(o)),e.lte(r))return Zt=Sa(t)?n?2:3:n?4:1,e;Zt=Sa(t)?n?1:4:n?3:2}return e.minus(o).abs()}function Vr(i,e,t,n){var o,r,s,a,u,c,l,m,d,p=i.constructor,b=t!==void 0;if(b?(gt(t,1,fn),n===void 0?n=p.rounding:gt(n,0,8)):(t=p.precision,n=p.rounding),!i.isFinite())l=Ea(i);else{for(l=Gt(i),s=l.indexOf("."),b?(o=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):o=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Ao(Gt(d),10,o),d.e=d.d.length),m=Ao(l,10,o),r=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=b?"0p+0":"0";else{if(s<0?r--:(i=new p(i),i.d=m,i.e=r,i=he(i,d,t,n,0,o),m=i.d,r=i.e,c=La),s=m[t],a=o/2,c=c||m[t+1]!==void 0,c=n<4?(s!==void 0||c)&&(n===0||n===(i.s<0?3:2)):s>a||s===a&&(n===4||c||n===6&&m[t-1]&1||n===(i.s<0?8:7)),m.length=t,c)for(;++m[--t]>o-1;)m[t]=0,t||(++r,m.unshift(1));for(u=m.length;!m[u-1];--u);for(s=0,l="";s<u;s++)l+=Or.charAt(m[s]);if(b){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)l+="0";for(m=Ao(l,o,e),u=m.length;!m[u-1];--u);for(s=1,l="1.";s<u;s++)l+=Or.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(r<0?"p":"p+")+r}else if(r<0){for(;++r;)l="0"+l;l="0."+l}else if(++r>u)for(r-=u;r--;)l+="0";else r<u&&(l=l.slice(0,r)+"."+l.slice(r))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return i.s<0?"-"+l:l}function Ka(i,e){if(i.length>e)return i.length=e,!0}function Il(i){return new this(i).abs()}function Bl(i){return new this(i).acos()}function xl(i){return new this(i).acosh()}function Sl(i,e){return new this(i).plus(e)}function Kl(i){return new this(i).asin()}function Cl(i){return new this(i).asinh()}function Ll(i){return new this(i).atan()}function Rl(i){return new this(i).atanh()}function Ol(i,e){i=new this(i),e=new this(e);var t,n=this.precision,o=this.rounding,r=n+4;return!i.s||!e.s?t=new this(NaN):!i.d&&!e.d?(t=Nt(this,r,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?Nt(this,n,o):new this(0),t.s=i.s):!i.d||e.isZero()?(t=Nt(this,r,1).times(.5),t.s=i.s):e.s<0?(this.precision=r,this.rounding=1,t=this.atan(he(i,e,r,1)),e=Nt(this,r,1),this.precision=n,this.rounding=o,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(he(i,e,r,1)),t}function Ml(i){return new this(i).cbrt()}function Nl(i){return $(i=new this(i),i.e+1,2)}function _l(i,e,t){return new this(i).clamp(e,t)}function vl(i){if(!i||typeof i!="object")throw Error(ho+"Object expected");var e,t,n,o=i.defaults===!0,r=["precision",1,fn,"rounding",0,8,"toExpNeg",-Qn,0,"toExpPos",0,Qn,"maxE",0,Qn,"minE",-Qn,0,"modulo",0,9];for(e=0;e<r.length;e+=3)if(t=r[e],o&&(this[t]=Mr[t]),(n=i[t])!==void 0)if(rt(n)===n&&n>=r[e+1]&&n<=r[e+2])this[t]=n;else throw Error(pn+t+": "+n);if(t="crypto",o&&(this[t]=Mr[t]),(n=i[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Oa);else this[t]=!1;else throw Error(pn+t+": "+n);return this}function Vl(i){return new this(i).cos()}function El(i){return new this(i).cosh()}function Da(i){var e,t,n;function o(r){var s,a,u,c=this;if(!(c instanceof o))return new o(r);if(c.constructor=o,Ca(r)){c.s=r.s,oe?!r.d||r.e>o.maxE?(c.e=NaN,c.d=null):r.e<o.minE?(c.e=0,c.d=[0]):(c.e=r.e,c.d=r.d.slice()):(c.e=r.e,c.d=r.d?r.d.slice():r.d);return}if(u=typeof r,u==="number"){if(r===0){c.s=1/r<0?-1:1,c.e=0,c.d=[0];return}if(r<0?(r=-r,c.s=-1):c.s=1,r===~~r&&r<1e7){for(s=0,a=r;a>=10;a/=10)s++;oe?s>o.maxE?(c.e=NaN,c.d=null):s<o.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[r]):(c.e=s,c.d=[r]);return}else if(r*0!==0){r||(c.s=NaN),c.e=NaN,c.d=null;return}return vr(c,r.toString())}else if(u!=="string")throw Error(pn+r);return(a=r.charCodeAt(0))===45?(r=r.slice(1),c.s=-1):(a===43&&(r=r.slice(1)),c.s=1),Na.test(r)?vr(c,r):hl(c,r)}if(o.prototype=E,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=vl,o.clone=Da,o.isDecimal=Ca,o.abs=Il,o.acos=Bl,o.acosh=xl,o.add=Sl,o.asin=Kl,o.asinh=Cl,o.atan=Ll,o.atanh=Rl,o.atan2=Ol,o.cbrt=Ml,o.ceil=Nl,o.clamp=_l,o.cos=Vl,o.cosh=El,o.div=Fl,o.exp=Dl,o.floor=Wl,o.hypot=ql,o.ln=Ul,o.log=Gl,o.log10=zl,o.log2=Xl,o.max=Ql,o.min=Hl,o.mod=jl,o.mul=Yl,o.pow=Zl,o.random=$l,o.round=Jl,o.sign=em,o.sin=tm,o.sinh=nm,o.sqrt=im,o.sub=om,o.sum=rm,o.tan=sm,o.tanh=am,o.trunc=um,i===void 0&&(i={}),i&&i.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)i.hasOwnProperty(t=n[e++])||(i[t]=this[t]);return o.config(i),o}function Fl(i,e){return new this(i).div(e)}function Dl(i){return new this(i).exp()}function Wl(i){return $(i=new this(i),i.e+1,3)}function ql(){var i,e,t=new this(0);for(oe=!1,i=0;i<arguments.length;)if(e=new this(arguments[i++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return oe=!0,new this(1/0);t=e}return oe=!0,t.sqrt()}function Ca(i){return i instanceof pi||i&&i.toStringTag===Ma||!1}function Ul(i){return new this(i).ln()}function Gl(i,e){return new this(i).log(e)}function Xl(i){return new this(i).log(2)}function zl(i){return new this(i).log(10)}function Ql(){return Va(this,arguments,"lt")}function Hl(){return Va(this,arguments,"gt")}function jl(i,e){return new this(i).mod(e)}function Yl(i,e){return new this(i).mul(e)}function Zl(i,e){return new this(i).pow(e)}function $l(i){var e,t,n,o,r=0,s=new this(1),a=[];if(i===void 0?i=this.precision:gt(i,1,fn),n=Math.ceil(i/te),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));r<n;)o=e[r],o>=429e7?e[r]=crypto.getRandomValues(new Uint32Array(1))[0]:a[r++]=o%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);r<n;)o=e[r]+(e[r+1]<<8)+(e[r+2]<<16)+((e[r+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(e,r):(a.push(o%1e7),r+=4);r=n/4}else throw Error(Oa);else for(;r<n;)a[r++]=Math.random()*1e7|0;for(n=a[--r],i%=te,n&&i&&(o=ze(10,te-i),a[r]=(n/o|0)*o);a[r]===0;r--)a.pop();if(r<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=te)a.shift();for(n=1,o=a[0];o>=10;o/=10)n++;n<te&&(t-=te-n)}return s.e=t,s.d=a,s}function Jl(i){return $(i=new this(i),i.e+1,this.rounding)}function em(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function tm(i){return new this(i).sin()}function nm(i){return new this(i).sinh()}function im(i){return new this(i).sqrt()}function om(i,e){return new this(i).sub(e)}function rm(){var i=0,e=arguments,t=new this(e[i]);for(oe=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return oe=!0,$(t,this.precision,this.rounding)}function sm(i){return new this(i).tan()}function am(i){return new this(i).tanh()}function um(i){return $(i=new this(i),i.e+1,1)}E[Symbol.for("nodejs.util.inspect.custom")]=E.toString;E[Symbol.toStringTag]="Decimal";var pi=E.constructor=Da(Mr);wo=new pi(wo);Po=new pi(Po);var M=pi;import bm from"big.js";import bn from"bn.js";import cm from"toformat";var lm=cm,fi=lm;import xo from"big.js";import mm from"bn.js";import dm from"decimal.js-light";import bi from"bn.js";var Er=(n=>(n[n.ROUND_DOWN=0]="ROUND_DOWN",n[n.ROUND_HALF_UP=1]="ROUND_HALF_UP",n[n.ROUND_UP=2]="ROUND_UP",n))(Er||{}),Wa=9007199254740991;function Y(i){let e=ce("CobaltX_parseBigNumberish");if(i instanceof bi)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new bi(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=Wa||i<=-Wa)&&e.logWithError(`BigNumberish number overflow: ${i}`),new bi(String(i))):typeof i=="bigint"?new bi(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new bi(0))}var Bo=ce("module/fraction"),Fr=fi(xo),yi=fi(dm),pm={[0]:yi.ROUND_DOWN,[1]:yi.ROUND_HALF_UP,[2]:yi.ROUND_UP},fm={[0]:xo.roundDown,[1]:xo.roundHalfUp,[2]:xo.roundUp},re=class{constructor(e,t=new mm(1)){this.numerator=Y(e),this.denominator=Y(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new re(this.denominator,this.numerator)}add(e){let t=e instanceof re?e:new re(Y(e));return this.denominator.eq(t.denominator)?new re(this.numerator.add(t.numerator),this.denominator):new re(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof re?e:new re(Y(e));return this.denominator.eq(t.denominator)?new re(this.numerator.sub(t.numerator),this.denominator):new re(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof re?e:new re(Y(e));return new re(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof re?e:new re(Y(e));return new re(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||Bo.logWithError(`${e} is not an integer.`),e<=0&&Bo.logWithError(`${e} is not positive.`),yi.set({precision:e+1,rounding:pm[n]});let o=new yi(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return o.toFormat(o.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||Bo.logWithError(`${e} is not an integer.`),e<0&&Bo.logWithError(`${e} is negative.`),Fr.DP=e,Fr.RM=fm[n]||1,new Fr(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var ym=ce("CobaltX_amount"),So=fi(bm);function qa(i,e){let t="0",n="0";if(i.includes(".")){let o=i.split(".");o.length===2?([t,n]=o,n=n.padEnd(e,"0")):ym.logWithError(`invalid number string, num: ${i}`)}else t=i;return[t,n.slice(0,e)||n]}var fe=class extends re{constructor(t,n,o=!0,r){let s=new bn(0),a=Cn.pow(new bn(t.decimals));if(o)s=Y(n);else{let u=new bn(0),c=new bn(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=qa(n.toString(),t.decimals);u=Y(l),c=Y(m)}u=u.mul(a),s=u.add(c)}super(s,a);this.logger=ce(r||"TokenAmount"),this.token=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.token.equals(t.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(t.raw)}lt(t){return this.token.equals(t.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(t.raw)}add(t){return this.token.equals(t.token)||this.logger.logWithError("add token not equals"),new fe(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new fe(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,n,o=0){return super.toSignificant(t,n,o)}toFixed(t=this.token.decimals,n,o=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,o)}toExact(t={groupSeparator:""}){return So.DP=this.token.decimals,new So(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}},Kn=class extends re{constructor(t,n,o=!0,r){let s=new bn(0),a=Cn.pow(new bn(t.decimals));if(o)s=Y(n);else{let u=new bn(0),c=new bn(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=qa(n.toString(),t.decimals);u=Y(l),c=Y(m)}u=u.mul(a),s=u.add(c)}super(s,a);this.logger=ce(r||"TokenAmount"),this.currency=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.currency.equals(t.currency)||this.logger.logWithError("gt currency not equals"),this.raw.gt(t.raw)}lt(t){return this.currency.equals(t.currency)||this.logger.logWithError("lt currency not equals"),this.raw.lt(t.raw)}add(t){return this.currency.equals(t.currency)||this.logger.logWithError("add currency not equals"),new Kn(this.currency,this.raw.add(t.raw))}sub(t){return this.currency.equals(t.currency)||this.logger.logWithError("sub currency not equals"),new Kn(this.currency,this.raw.sub(t.raw))}toSignificant(t=this.currency.decimals,n,o=0){return super.toSignificant(t,n,o)}toFixed(t=this.currency.decimals,n,o=0){return t>this.currency.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,o)}toExact(t={groupSeparator:""}){return So.DP=this.currency.decimals,new So(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};import{TOKEN_PROGRAM_ID as Ua}from"@solana/spl-token";import{PublicKey as gm}from"@solana/web3.js";var Xt={chainId:101,address:gm.default.toBase58(),programId:Ua.toBase58(),decimals:9,symbol:"ETH",name:"Ethereum",logoURI:"https://raw.githubusercontent.com/cobaltx-io/tokens/main/logo/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"cobaltx",extensions:{coingeckoId:"solana"}},je={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Ua.toBase58(),decimals:9,symbol:"WETH",name:"Wrapped ETH",logoURI:"https://raw.githubusercontent.com/cobaltx-io/tokens/main/logo/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"cobaltx",extensions:{coingeckoId:"solana"}};import{PublicKey as Gr}from"@solana/web3.js";import{PublicKey as tt,SystemProgram as Ga,SYSVAR_RENT_PUBKEY as Am}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as wm}from"@solana/spl-token";function A({pubkey:i,isSigner:e=!1,isWritable:t=!0}){return{pubkey:i,isWritable:t,isSigner:e}}var Dr=[A({pubkey:wm,isWritable:!1}),A({pubkey:Ga.programId,isWritable:!1}),A({pubkey:Am,isWritable:!1})];function Wr({publicKey:i,transformSol:e}){let t=qr(i.toString());if(t instanceof tt)return e&&t.equals(Ye)?H:t;if(e&&t.toString()===Ye.toBase58())return H;if(typeof t=="string"){if(t===tt.default.toBase58())return tt.default;try{return new tt(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function qr(i){try{return new tt(i)}catch{return i}}var Ko=new tt("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),zt=new tt("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Ze=new tt("SysvarRent111111111111111111111111111111111"),Ur=new tt("SysvarC1ock11111111111111111111111111111111"),$t=new tt("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Co=new tt("Sysvar1nstructions1111111111111111111111111"),Lo=Ga.programId,Gb=new tt("a2Gt18uJC8puJT9JRYQLU6rPi6okxQb4WqCjwtYshZB"),Xb=new tt("bXSKiFqYrALF9gJy1KqHm8tv4QXk8nCgbLN8WRsGEbh"),H=new tt("So11111111111111111111111111111111111111112"),Ye=tt.default,zb=new tt("71kRXzJMvSeArtXYNEWa8KAjpRJosdMQ7Dpgy5Jt5zfd"),Qb=new tt("ERFzpDteGNo8LTDKW1WwVGrkRMmA2y9WZHXNHxMA6BSV");function ot(i){return Wr({publicKey:i,transformSol:!0})}var Xr=class{constructor({mint:e,decimals:t,symbol:n,name:o,skipMint:r=!1,isToken2022:s=!1}){if(e===Ye.toBase58()||e instanceof Gr&&Ye.equals(e)){this.decimals=je.decimals,this.symbol=je.symbol,this.name=je.name,this.mint=new Gr(je.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=n||e.toString().substring(0,6),this.name=o||e.toString().substring(0,6),this.mint=r?Gr.default:Wr({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},ge=Xr;ge.WSOL=new Xr({...je,mint:je.address});var zr=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},gi=zr;gi.SOL=new zr(Xt);function ny(i,e){return i instanceof ge&&e instanceof ge?i.equals(e):i instanceof ge||e instanceof ge?!1:i===e}import Pm from"bn.js";var Xa=new re(new Pm(100)),_e=class extends re{toSignificant(e=5,t,n){return this.mul(Xa).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(Xa).toFixed(e,t,n)}};var km=ce("CobaltX_price"),$e=class extends re{constructor(t){let{baseToken:n,quoteToken:o,numerator:r,denominator:s}=t;super(r,s);this.baseToken=n,this.quoteToken=o,this.scalar=new re(Qr(n.decimals),Qr(o.decimals))}get raw(){return new re(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new $e({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&km.logWithError("mul token not equals");let n=super.mul(t);return new $e({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(t=this.quoteToken.decimals,n,o){return this.adjusted.toSignificant(t,n,o)}toFixed(t=this.quoteToken.decimals,n,o){return this.adjusted.toFixed(t,n,o)}};function Fe(i){if(i instanceof _e)return new re(i.numerator,i.denominator);if(i instanceof $e)return i.adjusted;if(i instanceof fe)try{return Fe(i.toExact())}catch{return new re(De)}if(i instanceof re)return i;let e=String(i),t=Ln(e);return new re(t.numerator,t.denominator)}function Ty(i){var n;if(i instanceof _e)return{fr:new re(i.numerator,i.denominator)};if(i instanceof $e)return{fr:i.adjusted};if(i instanceof fe)return{fr:Fe(i.toExact()),decimals:i.token.decimals};if(i instanceof re)return{fr:i};let e=String(i),t=Ln(e);return{fr:new re(t.numerator,t.denominator),decimals:(n=t.dec)==null?void 0:n.length}}function Iy(i,e){if(i==null||e==null)return!1;let t=Fe(i),n=Fe(e);return t.sub(n).numerator,t.sub(n).numerator.lt(De)}function hm(i,e){if(i==null||e==null)return!1;let t=Fe(i),n=Fe(e);return t.sub(n).numerator.gt(De)}function By(i,e){if(i==null||e==null)return!1;let t=Fe(i),n=Fe(e);return t.sub(n).numerator.lte(De)}function xy(i,e){if(i==null||e==null)return!1;let t=Fe(i),n=Fe(e);return t.sub(n).numerator.gte(De)}function Tm(i,e){if(i==null||e==null)return!1;let t=Fe(i),n=Fe(e);return t.sub(n).numerator.eq(De)}function Sy(i,e){if(i==null||e==null)return;let t=Fe(i),n=Fe(e);try{return t.div(n)}catch{return t}}function Ky(i,e){if(i==null||e==null)return;let t=Fe(i),n=Fe(e);return t.sub(n)}function Cy(i){return i==null?!1:!Tm(i,0)}function Ly(i,e){return hm(e,i)?e:i}function Hr(i,e){if(i==null||e==null)return;let t=Fe(i),n=Fe(e);return t.mul(n)}function Ry(i,e){if(i==null||e==null)return;let t=Fe(i),n=Fe(e);return t.add(n)}import{PublicKey as Im}from"@solana/web3.js";import Bm from"bn.js";async function za(i){new Promise(e=>setTimeout(e,i))}function Vy(){return new Date().getTime()}function jr(i){return typeof i=="object"&&i!==null&&![ge,fe,Im,re,Bm,$e,_e].some(e=>typeof e=="object"&&i instanceof e)}function xe(i){return typeof i=="string"?qr(i):Array.isArray(i)?i.map(e=>xe(e)):jr(i)?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,xe(t)])):i}var De=new We(0),ja=new We(1),Yy=new We(2),Zy=new We(3),$y=new We(5),Cn=new We(10),Jy=new We(100),eg=new We(1e3),tg=new We(1e4);function Qr(i){return Cn.pow(Y(i))}function Ln(i){var a;if(i===void 0)return{denominator:"1",numerator:"0"};if(i instanceof We)return{numerator:i.toString(),denominator:"1"};if(i instanceof re)return{denominator:i.denominator.toString(),numerator:i.numerator.toString()};let e=String(i),[,t="",n="",o=""]=(a=e.replace(",","").match(/(-?)(\d*)\.?(\d*)/))!=null?a:[],r="1"+"0".repeat(o.length),s=t+(n==="0"?"":n)+o||"0";return{denominator:r,numerator:s,sign:t,int:n,dec:o}}function Ro(i,e){let t=i.divmod(e);return t.mod.isZero()?t.div:t.div.isNeg()?t.div.isubn(1):t.div.iaddn(1)}function xm(i){var n;let[,e="",t=""]=(n=i.toFixed(2).match(/(-?)(\d*)\.?(\d*)/))!=null?n:[];return`${e}${t}`}function Sm(i,e=0){return i instanceof We?i:new We(xm(Ya(i).mul(Cn.pow(new We(String(e))))))}function Ya(i){if(i instanceof _e)return new re(i.numerator,i.denominator);if(i instanceof $e)return i.adjusted;if(i instanceof fe)try{return Ya(i.toExact())}catch{return new re(De)}if(i instanceof re)return i;let e=String(i),t=Ln(e);return new re(t.numerator,t.denominator)}function ng(i,e){let{numerator:t,denominator:n}=Ln(i);return new _e(new We(t),new We(n).mul(e!=null&&e.alreadyDecimaled?new We(100):new We(1)))}function ig(i){let{token:e,numberPrice:t,decimalDone:n}=i,o=new ge({mint:"",decimals:6,symbol:"usd",name:"usd",skipMint:!0}),{numerator:r,denominator:s}=Ln(t),a=n?new We(r).mul(Cn.pow(new We(e.decimals))):r,u=new We(s).mul(Cn.pow(new We(o.decimals)));return new $e({baseToken:o,denominator:u.toString(),quoteToken:new ge({...e,skipMint:!0,mint:""}),numerator:a.toString()})}function Qa(i){let e=new gi({decimals:6,symbol:"usd",name:"usd"}),t=Sm(Hr(i,10**e.decimals));return new Kn(e,t)}function og(i,e){return Qa(!e||!i?0:Hr(i,e))}function Km(i){if(i==null)return;let{numerator:e,denominator:t}=Ln(i.toString());return new re(e,t)}function Cm(i){return i instanceof M}function Ha(i){return Cm(i)?Km(i):Array.isArray(i)?i.map(e=>Ha(e)):jr(i)?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,Ha(t)])):i}var Za=i=>typeof i=="number",$a=i=>i?new Date(i):new Date,Lm=i=>$a(i).getTime();function Ja(i,e,t){let n=Za(e)?e*((t==null?void 0:t.unit)==="s"?1e3:1):e;return new Date(i).getTime()<=n}function eu(i,e,t){let n=Za(e)?e*((t==null?void 0:t.unit)==="s"?1e3:1):e;return new Date(i).getTime()>n}function sg(i,e){let n=Lm(i)+(e.days?e.days*24*60*60*1e3:0)+(e.hours?e.hours*60*60*1e3:0)+(e.minutes?e.minutes*60*1e3:0)+(e.seconds?e.seconds*1e3:0)+(e.milliseconds?e.milliseconds:0);return $a(n)}function Rr(i,e=1,t=[]){let n=[...i];if(e<=0)return t;for(;n.length;)t.push(n.splice(0,e));return t}function ug(i,...e){return i.filter(t=>e.every(n=>n.includes(t)))}function cg(i,...e){return i.filter(t=>e.every(n=>!n.includes(t)))}function lg(i){return[...new Set(i)]}var vt=class{constructor(e){this._owner=e}get publicKey(){return vt.isKeyPair(this._owner)?this._owner.publicKey:this._owner}get signer(){return vt.isKeyPair(this._owner)?this._owner:void 0}get isKeyPair(){return vt.isKeyPair(this._owner)}get isPublicKey(){return vt.isPublicKey(this._owner)}static isKeyPair(e){return e.secretKey!==void 0}static isPublicKey(e){return!vt.isKeyPair(e)}};import{PublicKey as _m}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as vm}from"@solana/spl-token";import{ComputeBudgetProgram as tu,Keypair as nu,P