@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 87.7 kB
JavaScript
var ri=Object.defineProperty,oi=Object.defineProperties;var si=Object.getOwnPropertyDescriptors;var nn=Object.getOwnPropertySymbols;var ai=Object.prototype.hasOwnProperty,ui=Object.prototype.propertyIsEnumerable;var rn=(t,e,n)=>e in t?ri(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,V=(t,e)=>{for(var n in e||(e={}))ai.call(e,n)&&rn(t,n,e[n]);if(nn)for(var n of nn(e))ui.call(e,n)&&rn(t,n,e[n]);return t},q=(t,e)=>oi(t,si(e));import{PublicKey as jo}from"@solana/web3.js";import{get as on,set as ci}from"lodash";var kt=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 n=e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(", ");throw new Error(n)}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}},sn={},li={};function $(t){let e=on(sn,t);if(!e){let n=on(li,t);e=new kt({name:t,logLevel:n}),ci(sn,t,e)}return e}import{MINT_SIZE as es,TOKEN_PROGRAM_ID as ts,getTransferFeeConfig as ns,unpackMint as is}from"@solana/spl-token";var rs=$("Raydium_accountInfo_util");import ge from"bn.js";var Me=9e15,Ie=1e9,ht="0123456789abcdef",it="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",rt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Bt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Me,maxE:Me,crypto:!1},mn,we,K=!0,st="[DecimalError] ",xe=st+"Invalid argument: ",dn=st+"Precision limit exceeded",pn=st+"crypto unavailable",fn="[object Decimal]",Q=Math.floor,U=Math.pow,mi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,di=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,pi=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,bn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,de=1e7,S=7,fi=9007199254740991,bi=it.length-1,xt=rt.length-1,f={toStringTag:fn};f.absoluteValue=f.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),B(t)};f.ceil=function(){return B(new this.constructor(this),this.e+1,2)};f.clampedTo=f.clamp=function(t,e){var n,i=this,r=i.constructor;if(t=new r(t),e=new r(e),!t.s||!e.s)return new r(NaN);if(t.gt(e))throw Error(xe+e);return n=i.cmp(t),n<0?t:i.cmp(e)>0?e:new r(i)};f.comparedTo=f.cmp=function(t){var e,n,i,r,o=this,s=o.d,a=(t=new o.constructor(t)).d,c=o.s,u=t.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(o.e!==t.e)return o.e>t.e^c<0?1:-1;for(i=s.length,r=a.length,e=0,n=i<r?i:r;e<n;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return i===r?0:i>r^c<0?1:-1};f.cosine=f.cos=function(){var t,e,n=this,i=n.constructor;return n.d?n.d[0]?(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+S,i.rounding=1,n=yi(i,An(i,n)),i.precision=t,i.rounding=e,B(we==2||we==3?n.neg():n,t,e,!0)):new i(1):new i(NaN)};f.cubeRoot=f.cbrt=function(){var t,e,n,i,r,o,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(K=!1,o=l.s*U(l.s*l,1/3),!o||Math.abs(o)==1/0?(n=z(l.d),t=l.e,(o=(t-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=U(n,1/3),t=Q((t+1)/3)-(t%3==(t<0?-1:2)),o==1/0?n="5e"+t:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),i=new m(n),i.s=l.s):i=new m(o.toString()),s=(t=m.precision)+3;;)if(a=i,c=a.times(a).times(a),u=c.plus(l),i=E(u.plus(l).times(a),u.plus(c),s+2,1),z(a.d).slice(0,s)===(n=z(i.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!r&&n=="4999"){if(!r&&(B(a,t+1,0),a.times(a).times(a).eq(l))){i=a;break}s+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(B(i,t+1,1),e=!i.times(i).times(i).eq(l));break}return K=!0,B(i,t,m.rounding,e)};f.decimalPlaces=f.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-Q(this.e/S))*S,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};f.dividedBy=f.div=function(t){return E(this,new this.constructor(t))};f.dividedToIntegerBy=f.divToInt=function(t){var e=this,n=e.constructor;return B(E(e,new n(t),0,1,1),n.precision,n.rounding)};f.equals=f.eq=function(t){return this.cmp(t)===0};f.floor=function(){return B(new this.constructor(this),this.e+1,3)};f.greaterThan=f.gt=function(t){return this.cmp(t)>0};f.greaterThanOrEqualTo=f.gte=function(t){var e=this.cmp(t);return e==1||e===0};f.hyperbolicCosine=f.cosh=function(){var t,e,n,i,r,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;n=s.precision,i=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(t=Math.ceil(r/3),e=(1/ut(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=ve(s,1,o.times(e),new s(1),!0);for(var c,u=t,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return B(o,s.precision=n,s.rounding=i,!0)};f.hyperbolicSine=f.sinh=function(){var t,e,n,i,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,n=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,i=r.d.length,i<3)r=ve(o,2,r,r,!0);else{t=1.4*Math.sqrt(i),t=t>16?16:t|0,r=r.times(1/ut(5,t)),r=ve(o,2,r,r,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);t--;)s=r.times(r),r=r.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=e,o.rounding=n,B(r,e,n,!0)};f.hyperbolicTangent=f.tanh=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+7,i.rounding=1,E(n.sinh(),n.cosh(),i.precision=t,i.rounding=e)):new i(n.s)};f.inverseCosine=f.acos=function(){var t=this,e=t.constructor,n=t.abs().cmp(1),i=e.precision,r=e.rounding;return n!==-1?n===0?t.isNeg()?fe(e,i,r):new e(0):new e(NaN):t.isZero()?fe(e,i+4,r).times(.5):(e.precision=i+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=i,e.rounding=r,t.times(2))};f.inverseHyperbolicCosine=f.acosh=function(){var t,e,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(t=i.precision,e=i.rounding,i.precision=t+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,K=!1,n=n.times(n).minus(1).sqrt().plus(n),K=!0,i.precision=t,i.rounding=e,n.ln()):new i(n)};f.inverseHyperbolicSine=f.asinh=function(){var t,e,n=this,i=n.constructor;return!n.isFinite()||n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,K=!1,n=n.times(n).plus(1).sqrt().plus(n),K=!0,i.precision=t,i.rounding=e,n.ln())};f.inverseHyperbolicTangent=f.atanh=function(){var t,e,n,i,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(t=o.precision,e=o.rounding,i=r.sd(),Math.max(i,t)<2*-r.e-1?B(new o(r),t,e,!0):(o.precision=n=i-r.e,r=E(r.plus(1),new o(1).minus(r),n+t,1),o.precision=t+4,o.rounding=1,r=r.ln(),o.precision=t,o.rounding=e,r.times(.5))):new o(NaN)};f.inverseSine=f.asin=function(){var t,e,n,i,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),n=o.precision,i=o.rounding,e!==-1?e===0?(t=fe(o,n+4,i).times(.5),t.s=r.s,t):new o(NaN):(o.precision=n+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=i,r.times(2)))};f.inverseTangent=f.atan=function(){var t,e,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,p=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=xt)return s=fe(l,m+4,p).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=xt)return s=fe(l,m+4,p).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,n=Math.min(28,a/S+2|0),t=n;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(K=!1,e=Math.ceil(a/S),i=1,c=u.times(u),s=new l(u),r=u;t!==-1;)if(r=r.times(c),o=s.minus(r.div(i+=2)),r=r.times(c),s=o.plus(r.div(i+=2)),s.d[e]!==void 0)for(t=e;s.d[t]===o.d[t]&&t--;);return n&&(s=s.times(2<<n-1)),K=!0,B(s,l.precision=m,l.rounding=p,!0)};f.isFinite=function(){return!!this.d};f.isInteger=f.isInt=function(){return!!this.d&&Q(this.e/S)>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(t){return this.cmp(t)<0};f.lessThanOrEqualTo=f.lte=function(t){return this.cmp(t)<1};f.logarithm=f.log=function(t){var e,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,p=l.rounding,b=5;if(t==null)t=new l(10),e=!0;else{if(t=new l(t),n=t.d,t.s<0||!n||!n[0]||t.eq(1))return new l(NaN);e=t.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new l(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(e)if(n.length>1)o=!0;else{for(r=n[0];r%10===0;)r/=10;o=r!==1}if(K=!1,a=m+b,s=Be(u,a),i=e?ot(l,a+10):Be(t,a),c=E(s,i,a,1),De(c.d,r=m,p))do if(a+=10,s=Be(u,a),i=e?ot(l,a+10):Be(t,a),c=E(s,i,a,1),!o){+z(c.d).slice(r+1,r+15)+1==1e14&&(c=B(c,m+1,0));break}while(De(c.d,r+=10,p));return K=!0,B(c,m,p)};f.minus=f.sub=function(t){var e,n,i,r,o,s,a,c,u,l,m,p,b=this,g=b.constructor;if(t=new g(t),!b.d||!t.d)return!b.s||!t.s?t=new g(NaN):b.d?t.s=-t.s:t=new g(t.d||b.s!==t.s?b:NaN),t;if(b.s!=t.s)return t.s=-t.s,b.plus(t);if(u=b.d,p=t.d,a=g.precision,c=g.rounding,!u[0]||!p[0]){if(p[0])t.s=-t.s;else if(u[0])t=new g(b);else return new g(c===3?-0:0);return K?B(t,a,c):t}if(n=Q(t.e/S),l=Q(b.e/S),u=u.slice(),o=l-n,o){for(m=o<0,m?(e=u,o=-o,s=p.length):(e=p,n=l,s=u.length),i=Math.max(Math.ceil(a/S),s)+2,o>i&&(o=i,e.length=1),e.reverse(),i=o;i--;)e.push(0);e.reverse()}else{for(i=u.length,s=p.length,m=i<s,m&&(s=i),i=0;i<s;i++)if(u[i]!=p[i]){m=u[i]<p[i];break}o=0}for(m&&(e=u,u=p,p=e,t.s=-t.s),s=u.length,i=p.length-s;i>0;--i)u[s++]=0;for(i=p.length;i>o;){if(u[--i]<p[i]){for(r=i;r&&u[--r]===0;)u[r]=de-1;--u[r],u[i]+=de}u[i]-=p[i]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(t.d=u,t.e=at(u,n),K?B(t,a,c):t):new g(c===3?-0:0)};f.modulo=f.mod=function(t){var e,n=this,i=n.constructor;return t=new i(t),!n.d||!t.s||t.d&&!t.d[0]?new i(NaN):!t.d||n.d&&!n.d[0]?B(new i(n),i.precision,i.rounding):(K=!1,i.modulo==9?(e=E(n,t.abs(),0,3,1),e.s*=t.s):e=E(n,t,0,i.modulo,1),e=e.times(t),K=!0,n.minus(e))};f.naturalExponential=f.exp=function(){return It(this)};f.naturalLogarithm=f.ln=function(){return Be(this)};f.negated=f.neg=function(){var t=new this.constructor(this);return t.s=-t.s,B(t)};f.plus=f.add=function(t){var e,n,i,r,o,s,a,c,u,l,m=this,p=m.constructor;if(t=new p(t),!m.d||!t.d)return!m.s||!t.s?t=new p(NaN):m.d||(t=new p(t.d||m.s===t.s?m:NaN)),t;if(m.s!=t.s)return t.s=-t.s,m.minus(t);if(u=m.d,l=t.d,a=p.precision,c=p.rounding,!u[0]||!l[0])return l[0]||(t=new p(m)),K?B(t,a,c):t;if(o=Q(m.e/S),i=Q(t.e/S),u=u.slice(),r=o-i,r){for(r<0?(n=u,r=-r,s=l.length):(n=l,i=o,s=u.length),o=Math.ceil(a/S),s=o>s?o+1:s+1,r>s&&(r=s,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for(s=u.length,r=l.length,s-r<0&&(r=s,n=l,l=u,u=n),e=0;r;)e=(u[--r]=u[r]+l[r]+e)/de|0,u[r]%=de;for(e&&(u.unshift(e),++i),s=u.length;u[--s]==0;)u.pop();return t.d=u,t.e=at(u,i),K?B(t,a,c):t};f.precision=f.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(xe+t);return n.d?(e=yn(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};f.round=function(){var t=this,e=t.constructor;return B(new e(t),t.e+1,e.rounding)};f.sine=f.sin=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+S,i.rounding=1,n=Pi(i,An(i,n)),i.precision=t,i.rounding=e,B(we>2?n.neg():n,t,e,!0)):new i(NaN)};f.squareRoot=f.sqrt=function(){var t,e,n,i,r,o,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(K=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=z(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=Q((c+1)/2)-(c<0||c%2),u==1/0?e="5e"+c:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),i=new l(e)):i=new l(u.toString()),n=(c=l.precision)+3;;)if(o=i,i=o.plus(E(s,o,n+2,1)).times(.5),z(o.d).slice(0,n)===(e=z(i.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!r&&e=="4999"){if(!r&&(B(o,c+1,0),o.times(o).eq(s))){i=o;break}n+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(B(i,c+1,1),t=!i.times(i).eq(s));break}return K=!0,B(i,c,l.rounding,t)};f.tangent=f.tan=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+10,i.rounding=1,n=n.sin(),n.s=1,n=E(n,new i(1).minus(n.times(n)).sqrt(),t+10,0),i.precision=t,i.rounding=e,B(we==2||we==4?n.neg():n,t,e,!0)):new i(NaN)};f.times=f.mul=function(t){var e,n,i,r,o,s,a,c,u,l=this,m=l.constructor,p=l.d,b=(t=new m(t)).d;if(t.s*=l.s,!p||!p[0]||!b||!b[0])return new m(!t.s||p&&!p[0]&&!b||b&&!b[0]&&!p?NaN:!p||!b?t.s/0:t.s*0);for(n=Q(l.e/S)+Q(t.e/S),c=p.length,u=b.length,c<u&&(o=p,p=b,b=o,s=c,c=u,u=s),o=[],s=c+u,i=s;i--;)o.push(0);for(i=u;--i>=0;){for(e=0,r=c+i;r>i;)a=o[r]+b[i]*p[r-i-1]+e,o[r--]=a%de|0,e=a/de|0;o[r]=(o[r]+e)%de|0}for(;!o[--s];)o.pop();return e?++n:o.shift(),t.d=o,t.e=at(o,n),K?B(t,m.precision,m.rounding):t};f.toBinary=function(t,e){return St(this,2,t,e)};f.toDecimalPlaces=f.toDP=function(t,e){var n=this,i=n.constructor;return n=new i(n),t===void 0?n:(se(t,0,Ie),e===void 0?e=i.rounding:se(e,0,8),B(n,t+n.e+1,e))};f.toExponential=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=be(i,!0):(se(t,0,Ie),e===void 0?e=r.rounding:se(e,0,8),i=B(new r(i),t+1,e),n=be(i,!0,t+1)),i.isNeg()&&!i.isZero()?"-"+n:n};f.toFixed=function(t,e){var n,i,r=this,o=r.constructor;return t===void 0?n=be(r):(se(t,0,Ie),e===void 0?e=o.rounding:se(e,0,8),i=B(new o(r),t+r.e+1,e),n=be(i,!1,t+i.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toFraction=function(t){var e,n,i,r,o,s,a,c,u,l,m,p,b=this,g=b.d,y=b.constructor;if(!g)return new y(b);if(u=n=new y(1),i=c=new y(0),e=new y(i),o=e.e=yn(g)-b.e-1,s=o%S,e.d[0]=U(10,s<0?S+s:s),t==null)t=o>0?e:u;else{if(a=new y(t),!a.isInt()||a.lt(u))throw Error(xe+a);t=a.gt(e)?o>0?e:u:a}for(K=!1,a=new y(z(g)),l=y.precision,y.precision=o=g.length*S*2;m=E(a,e,0,1,1),r=n.plus(m.times(i)),r.cmp(t)!=1;)n=i,i=r,r=u,u=c.plus(m.times(r)),c=r,r=e,e=a.minus(m.times(r)),a=r;return r=E(t.minus(n),i,0,1,1),c=c.plus(r.times(u)),n=n.plus(r.times(i)),c.s=u.s=b.s,p=E(u,i,o,1).minus(b).abs().cmp(E(c,n,o,1).minus(b).abs())<1?[u,i]:[c,n],y.precision=l,K=!0,p};f.toHexadecimal=f.toHex=function(t,e){return St(this,16,t,e)};f.toNearest=function(t,e){var n=this,i=n.constructor;if(n=new i(n),t==null){if(!n.d)return n;t=new i(1),e=i.rounding}else{if(t=new i(t),e===void 0?e=i.rounding:se(e,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(K=!1,n=E(n,t,0,e,1).times(t),K=!0,B(n)):(t.s=n.s,n=t),n};f.toNumber=function(){return+this};f.toOctal=function(t,e){return St(this,8,t,e)};f.toPower=f.pow=function(t){var e,n,i,r,o,s,a=this,c=a.constructor,u=+(t=new c(t));if(!a.d||!t.d||!a.d[0]||!t.d[0])return new c(U(+a,u));if(a=new c(a),a.eq(1))return a;if(i=c.precision,o=c.rounding,t.eq(1))return B(a,i,o);if(e=Q(t.e/S),e>=t.d.length-1&&(n=u<0?-u:u)<=fi)return r=gn(c,a,n,i),t.s<0?new c(1).div(r):B(r,i,o);if(s=a.s,s<0){if(e<t.d.length-1)return new c(NaN);if((t.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=U(+a,u),e=n==0||!isFinite(n)?Q(u*(Math.log("0."+z(a.d))/Math.LN10+a.e+1)):new c(n+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(K=!1,c.rounding=a.s=1,n=Math.min(12,(e+"").length),r=It(t.times(Be(a,i+n)),i),r.d&&(r=B(r,i+5,1),De(r.d,i,o)&&(e=i+10,r=B(It(t.times(Be(a,e+n)),e),e+5,1),+z(r.d).slice(i+1,i+15)+1==1e14&&(r=B(r,i+1,0)))),r.s=s,K=!0,c.rounding=o,B(r,i,o))};f.toPrecision=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=be(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(se(t,1,Ie),e===void 0?e=r.rounding:se(e,0,8),i=B(new r(i),t,e),n=be(i,t<=i.e||i.e<=r.toExpNeg,t)),i.isNeg()&&!i.isZero()?"-"+n:n};f.toSignificantDigits=f.toSD=function(t,e){var n=this,i=n.constructor;return t===void 0?(t=i.precision,e=i.rounding):(se(t,1,Ie),e===void 0?e=i.rounding:se(e,0,8)),B(new i(n),t,e)};f.toString=function(){var t=this,e=t.constructor,n=be(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};f.truncated=f.trunc=function(){return B(new this.constructor(this),this.e+1,1)};f.valueOf=f.toJSON=function(){var t=this,e=t.constructor,n=be(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function z(t){var e,n,i,r=t.length-1,o="",s=t[0];if(r>0){for(o+=s,e=1;e<r;e++)i=t[e]+"",n=S-i.length,n&&(o+=he(n)),o+=i;s=t[e],i=s+"",n=S-i.length,n&&(o+=he(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function se(t,e,n){if(t!==~~t||t<e||t>n)throw Error(xe+t)}function De(t,e,n,i){var r,o,s,a;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=S,r=0):(r=Math.ceil((e+1)/S),e%=S),o=U(10,S-e),a=t[r]%o|0,i==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==o||n>3&&a+1==o/2)&&(t[r+1]/o/100|0)==U(10,e-2)-1||(a==o/2||a==0)&&(t[r+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(i||n<4)&&a==9999||!i&&n>3&&a==4999):s=((i||n<4)&&a+1==o||!i&&n>3&&a+1==o/2)&&(t[r+1]/o/1e3|0)==U(10,e-3)-1,s}function tt(t,e,n){for(var i,r=[0],o,s=0,a=t.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=ht.indexOf(t.charAt(s++)),i=0;i<r.length;i++)r[i]>n-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/n|0,r[i]%=n)}return r.reverse()}function yi(t,e){var n,i,r;if(e.isZero())return e;i=e.d.length,i<32?(n=Math.ceil(i/3),r=(1/ut(4,n)).toString()):(n=16,r="2.3283064365386962890625e-10"),t.precision+=n,e=ve(t,1,e.times(r),new t(1));for(var o=n;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return t.precision-=n,e}var E=function(){function t(i,r,o){var s,a=0,c=i.length;for(i=i.slice();c--;)s=i[c]*r+a,i[c]=s%o|0,a=s/o|0;return a&&i.unshift(a),i}function e(i,r,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(i[a]!=r[a]){c=i[a]>r[a]?1:-1;break}return c}function n(i,r,o,s){for(var a=0;o--;)i[o]-=a,a=i[o]<r[o]?1:0,i[o]=a*s+i[o]-r[o];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,o,s,a,c){var u,l,m,p,b,g,y,w,C,N,I,R,L,v,ne,ie,re,ce,G,pe,oe=i.constructor,Tt=i.s==r.s?1:-1,j=i.d,O=r.d;if(!j||!j[0]||!O||!O[0])return new oe(!i.s||!r.s||(j?O&&j[0]==O[0]:!O)?NaN:j&&j[0]==0||!O?Tt*0:Tt/0);for(c?(b=1,l=i.e-r.e):(c=de,b=S,l=Q(i.e/b)-Q(r.e/b)),G=O.length,re=j.length,C=new oe(Tt),N=C.d=[],m=0;O[m]==(j[m]||0);m++);if(O[m]>(j[m]||0)&&l--,o==null?(v=o=oe.precision,s=oe.rounding):a?v=o+(i.e-r.e)+1:v=o,v<0)N.push(1),g=!0;else{if(v=v/b+2|0,m=0,G==1){for(p=0,O=O[0],v++;(m<re||p)&&v--;m++)ne=p*c+(j[m]||0),N[m]=ne/O|0,p=ne%O|0;g=p||m<re}else{for(p=c/(O[0]+1)|0,p>1&&(O=t(O,p,c),j=t(j,p,c),G=O.length,re=j.length),ie=G,I=j.slice(0,G),R=I.length;R<G;)I[R++]=0;pe=O.slice(),pe.unshift(0),ce=O[0],O[1]>=c/2&&++ce;do p=0,u=e(O,I,G,R),u<0?(L=I[0],G!=R&&(L=L*c+(I[1]||0)),p=L/ce|0,p>1?(p>=c&&(p=c-1),y=t(O,p,c),w=y.length,R=I.length,u=e(y,I,w,R),u==1&&(p--,n(y,G<w?pe:O,w,c))):(p==0&&(u=p=1),y=O.slice()),w=y.length,w<R&&y.unshift(0),n(I,y,R,c),u==-1&&(R=I.length,u=e(O,I,G,R),u<1&&(p++,n(I,G<R?pe:O,R,c))),R=I.length):u===0&&(p++,I=[0]),N[m++]=p,u&&I[0]?I[R++]=j[ie]||0:(I=[j[ie]],R=1);while((ie++<re||I[0]!==void 0)&&v--);g=I[0]!==void 0}N[0]||N.shift()}if(b==1)C.e=l,mn=g;else{for(m=1,p=N[0];p>=10;p/=10)m++;C.e=m+l*b-1,B(C,a?o+C.e+1:o,s,g)}return C}}();function B(t,e,n,i){var r,o,s,a,c,u,l,m,p,b=t.constructor;e:if(e!=null){if(m=t.d,!m)return t;for(r=1,a=m[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=S,s=e,l=m[p=0],c=l/U(10,r-s-1)%10|0;else if(p=Math.ceil((o+1)/S),a=m.length,p>=a)if(i){for(;a++<=p;)m.push(0);l=c=0,r=1,o%=S,s=o-S+1}else break e;else{for(l=a=m[p],r=1;a>=10;a/=10)r++;o%=S,s=o-S+r,c=s<0?0:l/U(10,r-s-1)%10|0}if(i=i||e<0||m[p+1]!==void 0||(s<0?l:l%U(10,r-s-1)),u=n<4?(c||i)&&(n==0||n==(t.s<0?3:2)):c>5||c==5&&(n==4||i||n==6&&(o>0?s>0?l/U(10,r-s):0:m[p-1])%10&1||n==(t.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=t.e+1,m[0]=U(10,(S-e%S)%S),t.e=-e||0):m[0]=t.e=0,t;if(o==0?(m.length=p,a=1,p--):(m.length=p+1,a=U(10,S-o),m[p]=s>0?(l/U(10,r-s)%U(10,s)|0)*a:0),u)for(;;)if(p==0){for(o=1,s=m[0];s>=10;s/=10)o++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(t.e++,m[0]==de&&(m[0]=1));break}else{if(m[p]+=a,m[p]!=de)break;m[p--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return K&&(t.e>b.maxE?(t.d=null,t.e=NaN):t.e<b.minE&&(t.e=0,t.d=[0])),t}function be(t,e,n){if(!t.isFinite())return wn(t);var i,r=t.e,o=z(t.d),s=o.length;return e?(n&&(i=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+he(i):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):r<0?(o="0."+he(-r-1)+o,n&&(i=n-s)>0&&(o+=he(i))):r>=s?(o+=he(r+1-s),n&&(i=n-r-1)>0&&(o=o+"."+he(i))):((i=r+1)<s&&(o=o.slice(0,i)+"."+o.slice(i)),n&&(i=n-s)>0&&(r+1===s&&(o+="."),o+=he(i))),o}function at(t,e){var n=t[0];for(e*=S;n>=10;n/=10)e++;return e}function ot(t,e,n){if(e>bi)throw K=!0,n&&(t.precision=n),Error(dn);return B(new t(it),e,1,!0)}function fe(t,e,n){if(e>xt)throw Error(dn);return B(new t(rt),e,n,!0)}function yn(t){var e=t.length-1,n=e*S+1;if(e=t[e],e){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function he(t){for(var e="";t--;)e+="0";return e}function gn(t,e,n,i){var r,o=new t(1),s=Math.ceil(i/S+4);for(K=!1;;){if(n%2&&(o=o.times(e),cn(o.d,s)&&(r=!0)),n=Q(n/2),n===0){n=o.d.length-1,r&&o.d[n]===0&&++o.d[n];break}e=e.times(e),cn(e.d,s)}return K=!0,o}function un(t){return t.d[t.d.length-1]&1}function Pn(t,e,n){for(var i,r,o=new t(e[0]),s=0;++s<e.length;){if(r=new t(e[s]),!r.s){o=r;break}i=o.cmp(r),(i===n||i===0&&o.s===n)&&(o=r)}return o}function It(t,e){var n,i,r,o,s,a,c,u=0,l=0,m=0,p=t.constructor,b=p.rounding,g=p.precision;if(!t.d||!t.d[0]||t.e>17)return new p(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:0/0);for(e==null?(K=!1,c=g):c=e,a=new p(.03125);t.e>-2;)t=t.times(a),m+=5;for(i=Math.log(U(2,m))/Math.LN10*2+5|0,c+=i,n=o=s=new p(1),p.precision=c;;){if(o=B(o.times(t),c,1),n=n.times(++l),a=s.plus(E(o,n,c,1)),z(a.d).slice(0,c)===z(s.d).slice(0,c)){for(r=m;r--;)s=B(s.times(s),c,1);if(e==null)if(u<3&&De(s.d,c-i,b,u))p.precision=c+=10,n=o=a=new p(1),l=0,u++;else return B(s,p.precision=g,b,K=!0);else return p.precision=g,s}s=a}}function Be(t,e){var n,i,r,o,s,a,c,u,l,m,p,b=1,g=10,y=t,w=y.d,C=y.constructor,N=C.rounding,I=C.precision;if(y.s<0||!w||!w[0]||!y.e&&w[0]==1&&w.length==1)return new C(w&&!w[0]?-1/0:y.s!=1?NaN:w?0:y);if(e==null?(K=!1,l=I):l=e,C.precision=l+=g,n=z(w),i=n.charAt(0),Math.abs(o=y.e)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)y=y.times(t),n=z(y.d),i=n.charAt(0),b++;o=y.e,i>1?(y=new C("0."+n),o++):y=new C(i+"."+n.slice(1))}else return u=ot(C,l+2,I).times(o+""),y=Be(new C(i+"."+n.slice(1)),l-g).plus(u),C.precision=I,e==null?B(y,I,N,K=!0):y;for(m=y,c=s=y=E(y.minus(1),y.plus(1),l,1),p=B(y.times(y),l,1),r=3;;){if(s=B(s.times(p),l,1),u=c.plus(E(s,new C(r),l,1)),z(u.d).slice(0,l)===z(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(ot(C,l+2,I).times(o+""))),c=E(c,new C(b),l,1),e==null)if(De(c.d,l-g,N,a))C.precision=l+=g,u=s=y=E(m.minus(1),m.plus(1),l,1),p=B(y.times(y),l,1),r=a=1;else return B(c,C.precision=I,N,K=!0);else return C.precision=I,c;c=u,r+=2}}function wn(t){return String(t.s*t.s/0)}function nt(t,e){var n,i,r;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(n<0&&(n=i),n+=+e.slice(i+1),e=e.substring(0,i)):n<0&&(n=e.length),i=0;e.charCodeAt(i)===48;i++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(i,r),e){if(r-=i,t.e=n=n-i-1,t.d=[],i=(n+1)%S,n<0&&(i+=S),i<r){for(i&&t.d.push(+e.slice(0,i)),r-=S;i<r;)t.d.push(+e.slice(i,i+=S));e=e.slice(i),i=S-e.length}else i-=r;for(;i--;)e+="0";t.d.push(+e),K&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function gi(t,e){var n,i,r,o,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),bn.test(e))return nt(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(di.test(e))n=16,e=e.toLowerCase();else if(mi.test(e))n=2;else if(pi.test(e))n=8;else throw Error(xe+e);for(o=e.search(/p/i),o>0?(c=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,i=t.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=gn(i,new i(n),o,o*2)),u=tt(e,n,de),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new i(t.s*0):(t.e=at(u,l),t.d=u,K=!1,s&&(t=E(t,r,a*4)),c&&(t=t.times(Math.abs(c)<54?U(2,c):_e.pow(2,c))),K=!0,t)}function Pi(t,e){var n,i=e.d.length;if(i<3)return e.isZero()?e:ve(t,2,e,e);n=1.4*Math.sqrt(i),n=n>16?16:n|0,e=e.times(1/ut(5,n)),e=ve(t,2,e,e);for(var r,o=new t(5),s=new t(16),a=new t(20);n--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function ve(t,e,n,i,r){var o,s,a,c,u=1,l=t.precision,m=Math.ceil(l/S);for(K=!1,c=n.times(n),a=new t(i);;){if(s=E(a.times(c),new t(e++*e++),l,1),a=r?i.plus(s):i.minus(s),i=E(s.times(c),new t(e++*e++),l,1),s=a.plus(i),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=i,i=s,s=o,u++}return K=!0,s.d.length=m+1,s}function ut(t,e){for(var n=t;--e;)n*=t;return n}function An(t,e){var n,i=e.s<0,r=fe(t,t.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return we=i?4:1,e;if(n=e.divToInt(r),n.isZero())we=i?3:2;else{if(e=e.minus(n.times(r)),e.lte(o))return we=un(n)?i?2:3:i?4:1,e;we=un(n)?i?1:4:i?3:2}return e.minus(r).abs()}function St(t,e,n,i){var r,o,s,a,c,u,l,m,p,b=t.constructor,g=n!==void 0;if(g?(se(n,1,Ie),i===void 0?i=b.rounding:se(i,0,8)):(n=b.precision,i=b.rounding),!t.isFinite())l=wn(t);else{for(l=be(t),s=l.indexOf("."),g?(r=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):r=e,s>=0&&(l=l.replace(".",""),p=new b(1),p.e=l.length-s,p.d=tt(be(p),10,r),p.e=p.d.length),m=tt(l,10,r),o=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=g?"0p+0":"0";else{if(s<0?o--:(t=new b(t),t.d=m,t.e=o,t=E(t,p,n,i,0,r),m=t.d,o=t.e,u=mn),s=m[n],a=r/2,u=u||m[n+1]!==void 0,u=i<4?(s!==void 0||u)&&(i===0||i===(t.s<0?3:2)):s>a||s===a&&(i===4||u||i===6&&m[n-1]&1||i===(t.s<0?8:7)),m.length=n,u)for(;++m[--n]>r-1;)m[n]=0,n||(++o,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=ht.charAt(m[s]);if(g){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=tt(l,r,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=ht.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>c)for(o-=c;o--;)l+="0";else o<c&&(l=l.slice(0,o)+"."+l.slice(o))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return t.s<0?"-"+l:l}function cn(t,e){if(t.length>e)return t.length=e,!0}function wi(t){return new this(t).abs()}function Ai(t){return new this(t).acos()}function Ti(t){return new this(t).acosh()}function ki(t,e){return new this(t).plus(e)}function hi(t){return new this(t).asin()}function Bi(t){return new this(t).asinh()}function xi(t){return new this(t).atan()}function Ii(t){return new this(t).atanh()}function Si(t,e){t=new this(t),e=new this(e);var n,i=this.precision,r=this.rounding,o=i+4;return!t.s||!e.s?n=new this(NaN):!t.d&&!e.d?(n=fe(this,o,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?fe(this,i,r):new this(0),n.s=t.s):!t.d||e.isZero()?(n=fe(this,o,1).times(.5),n.s=t.s):e.s<0?(this.precision=o,this.rounding=1,n=this.atan(E(t,e,o,1)),e=fe(this,o,1),this.precision=i,this.rounding=r,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(E(t,e,o,1)),n}function Ci(t){return new this(t).cbrt()}function Ki(t){return B(t=new this(t),t.e+1,2)}function Ni(t,e,n){return new this(t).clamp(e,n)}function Ri(t){if(!t||typeof t!="object")throw Error(st+"Object expected");var e,n,i,r=t.defaults===!0,o=["precision",1,Ie,"rounding",0,8,"toExpNeg",-Me,0,"toExpPos",0,Me,"maxE",0,Me,"minE",-Me,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(n=o[e],r&&(this[n]=Bt[n]),(i=t[n])!==void 0)if(Q(i)===i&&i>=o[e+1]&&i<=o[e+2])this[n]=i;else throw Error(xe+n+": "+i);if(n="crypto",r&&(this[n]=Bt[n]),(i=t[n])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(pn);else this[n]=!1;else throw Error(xe+n+": "+i);return this}function Li(t){return new this(t).cos()}function Fi(t){return new this(t).cosh()}function Tn(t){var e,n,i;function r(o){var s,a,c,u=this;if(!(u instanceof r))return new r(o);if(u.constructor=r,ln(o)){u.s=o.s,K?!o.d||o.e>r.maxE?(u.e=NaN,u.d=null):o.e<r.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(c=typeof o,c==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;K?s>r.maxE?(u.e=NaN,u.d=null):s<r.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return nt(u,o.toString())}if(c==="string")return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),bn.test(o)?nt(u,o):gi(u,o);if(c==="bigint")return o<0?(o=-o,u.s=-1):u.s=1,nt(u,o.toString());throw Error(xe+o)}if(r.prototype=f,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Ri,r.clone=Tn,r.isDecimal=ln,r.abs=wi,r.acos=Ai,r.acosh=Ti,r.add=ki,r.asin=hi,r.asinh=Bi,r.atan=xi,r.atanh=Ii,r.atan2=Si,r.cbrt=Ci,r.ceil=Ki,r.clamp=Ni,r.cos=Li,r.cosh=Fi,r.div=Mi,r.exp=vi,r.floor=Ei,r.hypot=Oi,r.ln=Vi,r.log=Wi,r.log10=_i,r.log2=Di,r.max=qi,r.min=Gi,r.mod=Ui,r.mul=Xi,r.pow=zi,r.random=Hi,r.round=Yi,r.sign=Zi,r.sin=ji,r.sinh=Qi,r.sqrt=Ji,r.sub=$i,r.sum=er,r.tan=tr,r.tanh=nr,r.trunc=ir,t===void 0&&(t={}),t&&t.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)t.hasOwnProperty(n=i[e++])||(t[n]=this[n]);return r.config(t),r}function Mi(t,e){return new this(t).div(e)}function vi(t){return new this(t).exp()}function Ei(t){return B(t=new this(t),t.e+1,3)}function Oi(){var t,e,n=new this(0);for(K=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)n.d&&(n=n.plus(e.times(e)));else{if(e.s)return K=!0,new this(1/0);n=e}return K=!0,n.sqrt()}function ln(t){return t instanceof _e||t&&t.toStringTag===fn||!1}function Vi(t){return new this(t).ln()}function Wi(t,e){return new this(t).log(e)}function Di(t){return new this(t).log(2)}function _i(t){return new this(t).log(10)}function qi(){return Pn(this,arguments,-1)}function Gi(){return Pn(this,arguments,1)}function Ui(t,e){return new this(t).mod(e)}function Xi(t,e){return new this(t).mul(e)}function zi(t,e){return new this(t).pow(e)}function Hi(t){var e,n,i,r,o=0,s=new this(1),a=[];if(t===void 0?t=this.precision:se(t,1,Ie),i=Math.ceil(t/S),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));o<i;)r=e[o],r>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);o<i;)r=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(r%1e7),o+=4);o=i/4}else throw Error(pn);else for(;o<i;)a[o++]=Math.random()*1e7|0;for(i=a[--o],t%=S,i&&t&&(r=U(10,S-t),a[o]=(i/r|0)*r);a[o]===0;o--)a.pop();if(o<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=S)a.shift();for(i=1,r=a[0];r>=10;r/=10)i++;i<S&&(n-=S-i)}return s.e=n,s.d=a,s}function Yi(t){return B(t=new this(t),t.e+1,this.rounding)}function Zi(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function ji(t){return new this(t).sin()}function Qi(t){return new this(t).sinh()}function Ji(t){return new this(t).sqrt()}function $i(t,e){return new this(t).sub(e)}function er(){var t=0,e=arguments,n=new this(e[t]);for(K=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return K=!0,B(n,this.precision,this.rounding)}function tr(t){return new this(t).tan()}function nr(t){return new this(t).tanh()}function ir(t){return B(t=new this(t),t.e+1,1)}f[Symbol.for("nodejs.util.inspect.custom")]=f.toString;f[Symbol.toStringTag]="Decimal";var _e=f.constructor=Tn(Bt);it=new _e(it);rt=new _e(rt);var F=_e;import mr from"big.js";import hs from"bn.js";import rr from"toformat";var or=rr,qe=or;import lt from"big.js";import ar from"bn.js";import ur from"decimal.js-light";import Ge from"bn.js";var kn=9007199254740991;function ye(t){let e=$("Raydium_parseBigNumberish");if(t instanceof Ge)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new Ge(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=kn||t<=-kn)&&e.logWithError(`BigNumberish number overflow: ${t}`),new Ge(String(t))):typeof t=="bigint"?new Ge(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new Ge(0))}var ct=$("module/fraction"),Ct=qe(lt),Ue=qe(ur),cr={[0]:Ue.ROUND_DOWN,[1]:Ue.ROUND_HALF_UP,[2]:Ue.ROUND_UP},lr={[0]:lt.roundDown,[1]:lt.roundHalfUp,[2]:lt.roundUp},W=class{constructor(e,n=new ar(1)){this.numerator=ye(e),this.denominator=ye(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new W(this.denominator,this.numerator)}add(e){let n=e instanceof W?e:new W(ye(e));return this.denominator.eq(n.denominator)?new W(this.numerator.add(n.numerator),this.denominator):new W(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof W?e:new W(ye(e));return this.denominator.eq(n.denominator)?new W(this.numerator.sub(n.numerator),this.denominator):new W(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof W?e:new W(ye(e));return new W(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof W?e:new W(ye(e));return new W(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},i=1){Number.isInteger(e)||ct.logWithError(`${e} is not an integer.`),e<=0&&ct.logWithError(`${e} is not positive.`),Ue.set({precision:e+1,rounding:cr[i]});let r=new Ue(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),n)}toFixed(e,n={groupSeparator:""},i=1){return Number.isInteger(e)||ct.logWithError(`${e} is not an integer.`),e<0&&ct.logWithError(`${e} is negative.`),Ct.DP=e,Ct.RM=lr[i]||1,new Ct(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var Ls=$("Raydium_amount"),Fs=qe(mr);import{PublicKey as pr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as hn}from"@solana/spl-token";var Kt={chainId:101,address:pr.default.toBase58(),programId:hn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},Se={chainId:101,address:"So11111111111111111111111111111111111111112",programId:hn.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};import{PublicKey as Rt}from"@solana/web3.js";import{PublicKey as D,SystemProgram as Bn,SYSVAR_RENT_PUBKEY as fr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as br}from"@solana/spl-token";function Nt({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var _s=[Nt({pubkey:br,isWritable:!1}),Nt({pubkey:Bn.programId,isWritable:!1}),Nt({pubkey:fr,isWritable:!1})];function xn({publicKey:t,transformSol:e}){let n=In(t.toString());if(n instanceof D)return e&&n.equals(Xe)?et:n;if(e&&n.toString()===Xe.toBase58())return et;if(typeof n=="string"){if(n===D.default.toBase58())return D.default;try{return new D(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function In(t){try{return new D(t)}catch{return t}}var yr=new D("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),gr=new D("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),mt=new D("SysvarRent111111111111111111111111111111111"),qs=new D("SysvarC1ock11111111111111111111111111111111"),ze=new D("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Gs=new D("Sysvar1nstructions1111111111111111111111111"),Us=Bn.programId,Xs=new D("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),zs=new D("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Hs=new D("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Ys=new D("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Zs=new D("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),js=new D("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Qs=new D("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Js=new D("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),$s=new D("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),ea=new D("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),ta=new D("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),et=new D("So11111111111111111111111111111111111111112"),Xe=D.default;var Lt=class{constructor({mint:e,decimals:n,symbol:i,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===Xe.toBase58()||e instanceof Rt&&Xe.equals(e)){this.decimals=Se.decimals,this.symbol=Se.symbol,this.name=Se.name,this.mint=new Rt(Se.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=i||e.toString().substring(0,6),this.name=r||e.toString().substring(0,6),this.mint=o?Rt.default:xn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Ce=Lt;Ce.WSOL=new Lt(q(V({},Se),{mint:Se.address}));var Ft=class{constructor({decimals:e,symbol:n="UNKNOWN",name:i="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=i}equals(e){return this===e}},dt=Ft;dt.SOL=new Ft(Kt);import Pr from"bn.js";var pa=new W(new Pr(100));var wa=$("Raydium_price");var wr=new ge(0),Ha=new ge(1),Ya=new ge(2),Za=new ge(3),ja=new ge(5),dr=new ge(10),Qa=new ge(100),Ja=new ge(1e3),$a=new ge(1e4);function Sn(t,e,n){return t.mul(e).add(n).sub(new ge(1)).div(n)}import{PublicKey as hu}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as xu}from"@solana/spl-token";import{ComputeBudgetProgram as au,Keypair as lu,PublicKey as Ar,Transaction as du,TransactionMessage as fu,VersionedTransaction as bu}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as wu}from"@solana/spl-token";var Au=$("Raydium_txUtil");function ee(t,e){let[n,i]=Ar.findProgramAddressSync(t,e);return{publicKey:n,nonce:i}}import{PublicKey as x}from"@solana/web3.js";var Ku=new x("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),Nu=new x("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),Ru=new x("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Lu=new x("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Fu=new x("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Mu=new x("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),vu=new x("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Eu=new x("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Ou=new x("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Vu=new x("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Tr=new x("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),kr=new x("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),hr=new x("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),Wu=new x("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Du=new x("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),_u=new x("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),qu=new x("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Gu=new x("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Uu=new x("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Xu=new x("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),zu=new x("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Hu=new x("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),Yu=new x("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),Zu=new x("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),ju=new x("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),Br=new x("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),Qu=new x("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),Ju=new x("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),$u=new x("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),ec=new x("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),tc=new x("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var nc={OPEN_BOOK_PROGRAM:new x("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new x("Ray1111111111111111111111111111111111111111"),AMM_V4:new x("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new x("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new x("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new x("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new x("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new x("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new x("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new x("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new x("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new x("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:x.default,Router:new x("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new x("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new x("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new x("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new x("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new x("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new x("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new x("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new x("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new x("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new x("Ray1111111111111111111111111111111111111111")};import J from"bn.js";var He=1e4;function Ot(t,e){let{div:n,mod:i}=t.divmod(e);return i.gt(new J(0))?n.add(new J(1)):n}function Re(t,e){if(t.isZero())return new J(0);let n=t.div(e);return n.isZero()?new J(1):t.mod(e).gt(new J(0))?n.add(new J(1)):n}function Vt(t,e,n){if(e===void 0)return{amount:t,fee:void 0,expirationTime:void 0};let i=Math.floor(n/432e3),r=i<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,o=new J(r.maximumFee.toString()),s=i<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*432e3-n)*400/1e3:void 0,a=Ot(t.mul(new J(r.transferFeeBasisPoints)),new J(He)),c=a.gt(o)?o:a;return{amount:t,fee:c,expirationTime:s}}function Wt(t,e,n){if(e===void 0)return{amount:t,fee:void 0,expirationTime:void 0};let i=Math.floor(n/432e3),r=i<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,o=new J(r.maximumFee.toString()),s=i<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*432e3-n)*400/1e3:void 0;if(r.transferFeeBasisPoints===He){let a=new J(r.maximumFee.toString());return{amount:t.add(a),fee:a,expirationTime:s}}else{let a=Ot(t.mul(new J(He)),new J(He-r.transferFeeBasisPoints)),c=new J(r.maximumFee.toString()),u=a.sub(t).gt(c)?t.add(c):a,l=Ot(u.mul(new J(r.transferFeeBasisPoints)),new J(He)),m=l.gt(o)?o:l;return{amount:u,fee:m,expirationTime:s}}}import{PublicKey as uc,AddressLookupTableAccount as cc}from"@solana/web3.js";import{PublicKey as Bc,sendAndConfirmTransaction as xc,SystemProgram as Cc,Transaction as Kc,TransactionMessage as Rc,VersionedTransaction as Lc}from"@solana/web3.js";import Mc from"axios";import{PublicKey as _c}from"@solana/web3.js";import Gc from"bn.js";import xr from"bn.js";var Le=new xr(1e6);import{PublicKey as Er}from"@solana/web3.js";import Mn,{isBN as vn}from"bn.js";import{bits as bl,BitStructure as yl,blob as Ir,Blob as gl,cstr as Pl,f32 as wl,f32be as Al,f64 as Tl,f64be as kl,greedy as hl,Layout as Sr,ns64 as Bl,ns64be as xl,nu64 as Il,nu64be as Sl,offset as Cr,s16 as Cl,s16be as Kl,s24 as Nl,s24be as Rl,s32 as Kr,s32be as Ll,s40 as Fl,s40be as Ml,s48 as vl,s48be as El,s8 as Ol,seq as Nr,struct as Vl,Structure as Rr,u16 as Lr,u16be as Wl,u24 as Dl,u24be as _l,u32 as Fr,u32be as ql,u40 as Gl,u40be as Ul,u48 as Xl,u48be as zl,u8 as Mr,UInt as vr,union as Hl,Union as Yl,unionLayoutDiscriminator as Zl,utf8 as jl}from"@solana/buffer-layout";var Dt=Sr,Rn=Rr;var _t=vr;var Ln=Mr,Ae=Lr;var qt=Fr;var Te=Kr;var Fn=Nr;var ae=Ir;var Gt=Cr;var Ee=class extends Dt{constructor(n,i,r){super(n,r);this.blob=ae(n),this.signed=i}decode(n,i=0){let r=new Mn(this.blob.decode(n,i),10,"le");return this.signed?r.fromTwos(this.span*8).clone():r}encode(n,i,r=0){return typeof n=="number"&&(n=new Mn(n)),this.signed&&(n=n.toTwos(this.span*8)),this.blob.encode(n.toArrayLike(Buffer,"le",this.span),i,r)}};function P(t){return new _t(1,t)}function Oe(t){return new _t(4,t)}function d(t){return new Ee(8,!1,t)}function _(t){return new Ee(16,!1,t)}function En(t){return new Ee(8,!0,t)}function On(t){return new Ee(16,!0,t)}var Fe=class extends Dt{constructor(n,i,r,o){super(n.span,o);this.layout=n,this.decoder=i,this.encoder=r}decode(n,i){return this.decoder(this.layout.decode(n,i))}encode(n,i,r){return this.layout.encode(this.encoder(n),i,r)}getSpan(n,i){return this.layout.getSpan(n,i)}};function k(t){return new Fe(ae(32),e=>new Er(e),e=>e.toBuffer(),t)}function Xt(t){return new Fe(Ln(),Or,Vr,t)}function Or(t){if(t===0)return!1;if(t===1)return!0;throw new Error("Invalid bool: "+t)}function Vr(t){return t?1:0}function Vn(t,e){let n=qt("length"),i=h([n,M(t,Gt(n,-n.span),"values")]);return new Fe(i,({values:r})=>r,r=>({values:r}),e)}function Wr(t){let e=qt("length"),n=h([e,ae(Gt(e,-e.span),"data")]);return new Fe(n,({data:i})=>i,i=>({data:i}),t)}function H(t){return new Fe(Wr(),e=>e.toString("utf-8"),e=>Buffer.from(e,"utf-8"),t)}var Ut=class extends Rn{decode(e,n){return super.decode(e,n)}};function h(t,e,n){return new Ut(t,e,n)}function M(t,e,n){let i,r=typeof e=="number"?e:vn(e)?e.toNumber():new Proxy(e,{get(o,s){if(!i){let a=Reflect.get(o,"count");i=vn(a)?a.toNumber():a,Reflect.set(o,"count",i)}return Reflect.get(o,s)},set(o,s,a){return s==="count"&&(i=a),Reflect.set(o,s,a)}});return Fn(t,r,n)}import{ASSOCIATED_TOKEN_PROGRAM_ID as bt,TOKEN_2022_PROGRAM_ID as So,TOKEN_PROGRAM_ID as Qe}from"@solana/spl-token";import{SystemProgram as te,TransactionInstruction as Y}from"@solana/web3.js";import ke from"bn.js";var Dr=h([d(),d("epoch"),P("curveType"),Ae("index"),d("migrateFee"),d("tradeFeeRate"),d("maxShareFeeRate"),d("minSupplyA"),d("maxLockRate"),d("minSellRateA"),d("minMigrateRateA"),d("minFundRaisingB"),k("mintB"),k("protocolFeeOwner"),k("migrateFeeOwner"),k("migrateToAmmWallet"),k("migrateToCpmmWallet"),M(d(),16)]),_r=h([d("totalLockedAmount"),d("cliffPeriod"),d("unlockPeriod"),d("startTime"),d("totalAllocatedShare")]),qr=h([d(),d("epoch"),P("bump"),P("status"),P("mintDecimalsA"),P("mintDecimalsB"),P("migrateType"),d("supply"),d("totalSellA"),d("virtualA"),d("virtualB"),d("realA"),d("realB"),d("totalFundRaisingB"),d("protocolFee"),d("platformFee"),d("migrateFee"),_r.replicate("vestingSchedule"),k("configId"),k("platformId"),k("mintA"),k("mintB"),k("vaultA"),k("vaultB"),k("creator"),P("mintProgramFlag"),P("cpmmCreatorFeeOn"),d("platformVestingShare"),M(P(),54)]),um=h([d(),d("epoch"),k("poolId"),k("beneficiary"),d("claimedAmount"),d("tokenShareAmount"),M(d(),8)]),zt=h([P("migrateType"),P("migrateCpmmFeeOn"),d("supply"),d("totalSellA"),d("totalFundRaisingB"),d("totalLockedAmount"),d("cliffPeriod"),d("unlockPeriod")]),Gr=h([d("epoch"),P("index"),k("configId"),zt.replicate("bondingCurveParam"),M(d(),50)]),Ur=h([d(),d("epoch"),k("platformClaimFeeWallet"),k("platformLockNftWallet"),d("platformScale"),d("creatorScale"),d("burnScale"),d("feeRate"),M(P(),64,"name"),M(P(),256,"web"),M(P(),256,"img"),k("cpConfigId"),d("creatorFeeRate"),k("transferFeeExtensionAuth"),k("platformVestingWallet"),d("platformVestingScale"),k("platformCpCreator"),M(P(),108),Vn(Gr,"platformCurve")]);import{PublicKey as af}from"@solana/web3.js";import cf from"bn.js";import{AccountLayout as pf,createAssociatedTokenAccountIdempotentInstruction as ff,TOKEN_2022_PROGRAM_ID as bf,TOKEN_PROGRAM_ID as yf}from"@solana/spl-token";import{PublicKey as dm}from"@solana/web3.js";import{MintLayout as fm,TOKEN_PROGRAM_ID as ym}from"@solana/spl-token";import{Keypair as Np,PublicKey as Rp,SystemProgram as Fp,TransactionInstruction as Mp}from"@sol