@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 76.5 kB
JavaScript
var An=Object.defineProperty,Sn=Object.defineProperties;var Ln=Object.getOwnPropertyDescriptors;var Ue=Object.getOwnPropertySymbols;var Ot=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var _t=(e,t,n)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,z=(e,t)=>{for(var n in t||(t={}))Ot.call(t,n)&&_t(e,n,t[n]);if(Ue)for(var n of Ue(t))vt.call(t,n)&&_t(e,n,t[n]);return e},re=(e,t)=>Sn(e,Ln(t));var qe=(e,t)=>{var n={};for(var r in e)Ot.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ue)for(var r of Ue(e))t.indexOf(r)<0&&vt.call(e,r)&&(n[r]=e[r]);return n};import{PublicKey as Jr,Transaction as Mt,TransactionInstruction as Xr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Qr}from"@solana/spl-token";import xn from"bn.js";import{PublicKey as kn}from"@solana/web3.js";import{get as Ft,set as Bn}from"lodash";var ut=class{constructor(t){this.logLevel=t.logLevel!==void 0?t.logLevel:0,this.name=t.name}set level(t){this.logLevel=t}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(t){return t<=this.logLevel}error(...t){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...t),this):this}logWithError(...t){let n=t.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(n)}warning(...t){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...t),this):this}info(...t){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...t),this):this}debug(...t){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...t),this):this}},Vt={},Nn={};function Y(e){let t=Ft(Vt,e);if(!t){let n=Ft(Nn,e);t=new ut({name:e,logLevel:n}),Bn(Vt,e,t)}return t}import{MINT_SIZE as ci,TOKEN_PROGRAM_ID as li,getTransferFeeConfig as fi,unpackMint as mi}from"@solana/spl-token";var ct=Y("Raydium_accountInfo_util");async function Ge(e,t,n){let{batchRequest:r,commitment:o="confirmed",chunkCount:i=100}=z({batchRequest:!1},n),s=lt(t,i),a=new Array(s.length).fill([]);if(r){let c=s.map(f=>{let m=e._buildArgs([f.map(p=>p.toBase58())],o,"base64");return{methodName:"getMultipleAccounts",args:m}}),u=lt(c,10);a=(await(await Promise.all(u.map(async f=>await e._rpcBatchRequest(f)))).flat()).map(f=>(f.error&&ct.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${f.error.message}`),f.result.value.map(m=>{if(m){let{data:p,executable:b,lamports:g,owner:w,rentEpoch:h}=m;return p.length!==2&&p[1]!=="base64"&&ct.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:b,lamports:g,owner:new kn(w),rentEpoch:h}}return null})))}else try{a=await Promise.all(s.map(c=>e.getMultipleAccountsInfo(c,o)))}catch(c){c instanceof Error&&ct.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}import se from"bn.js";var be=9e15,fe=1e9,mt="0123456789abcdef",ze="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ye="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",dt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-be,maxE:be,crypto:!1},qt,ie,I=!0,Je="[DecimalError] ",le=Je+"Invalid argument: ",Gt=Je+"Precision limit exceeded",Ht=Je+"crypto unavailable",jt="[object Decimal]",H=Math.floor,q=Math.pow,Cn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,In=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Rn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,zt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,X=1e7,B=7,En=9007199254740991,Mn=ze.length-1,pt=Ye.length-1,d={toStringTag:jt};d.absoluteValue=d.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),S(e)};d.ceil=function(){return S(new this.constructor(this),this.e+1,2)};d.clampedTo=d.clamp=function(e,t){var n,r=this,o=r.constructor;if(e=new o(e),t=new o(t),!e.s||!t.s)return new o(NaN);if(e.gt(t))throw Error(le+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new o(r)};d.comparedTo=d.cmp=function(e){var t,n,r,o,i=this,s=i.d,a=(e=new i.constructor(e)).d,c=i.s,u=e.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(i.e!==e.e)return i.e>e.e^c<0?1:-1;for(r=s.length,o=a.length,t=0,n=r<o?r:o;t<n;++t)if(s[t]!==a[t])return s[t]>a[t]^c<0?1:-1;return r===o?0:r>o^c<0?1:-1};d.cosine=d.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+B,r.rounding=1,n=Dn(r,Qt(r,n)),r.precision=e,r.rounding=t,S(ie==2||ie==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)};d.cubeRoot=d.cbrt=function(){var e,t,n,r,o,i,s,a,c,u,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(I=!1,i=l.s*q(l.s*l,1/3),!i||Math.abs(i)==1/0?(n=G(l.d),e=l.e,(i=(e-n.length+1)%3)&&(n+=i==1||i==-2?"0":"00"),i=q(n,1/3),e=H((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?n="5e"+e:(n=i.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),r=new f(n),r.s=l.s):r=new f(i.toString()),s=(e=f.precision)+3;;)if(a=r,c=a.times(a).times(a),u=c.plus(l),r=F(u.plus(l).times(a),u.plus(c),s+2,1),G(a.d).slice(0,s)===(n=G(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!o&&n=="4999"){if(!o&&(S(a,e+1,0),a.times(a).times(a).eq(l))){r=a;break}s+=4,o=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(S(r,e+1,1),t=!r.times(r).times(r).eq(l));break}return I=!0,S(r,e,f.rounding,t)};d.decimalPlaces=d.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-H(this.e/B))*B,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};d.dividedBy=d.div=function(e){return F(this,new this.constructor(e))};d.dividedToIntegerBy=d.divToInt=function(e){var t=this,n=t.constructor;return S(F(t,new n(e),0,1,1),n.precision,n.rounding)};d.equals=d.eq=function(e){return this.cmp(e)===0};d.floor=function(){return S(new this.constructor(this),this.e+1,3)};d.greaterThan=d.gt=function(e){return this.cmp(e)>0};d.greaterThanOrEqualTo=d.gte=function(e){var t=this.cmp(e);return t==1||t===0};d.hyperbolicCosine=d.cosh=function(){var e,t,n,r,o,i=this,s=i.constructor,a=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return a;n=s.precision,r=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,o=i.d.length,o<32?(e=Math.ceil(o/3),t=(1/Qe(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),i=ye(s,1,i.times(t),new s(1),!0);for(var c,u=e,l=new s(8);u--;)c=i.times(i),i=a.minus(c.times(l.minus(c.times(l))));return S(i,s.precision=n,s.rounding=r,!0)};d.hyperbolicSine=d.sinh=function(){var e,t,n,r,o=this,i=o.constructor;if(!o.isFinite()||o.isZero())return new i(o);if(t=i.precision,n=i.rounding,i.precision=t+Math.max(o.e,o.sd())+4,i.rounding=1,r=o.d.length,r<3)o=ye(i,2,o,o,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,o=o.times(1/Qe(5,e)),o=ye(i,2,o,o,!0);for(var s,a=new i(5),c=new i(16),u=new i(20);e--;)s=o.times(o),o=o.times(a.plus(s.times(c.times(s).plus(u))))}return i.precision=t,i.rounding=n,S(o,t,n,!0)};d.hyperbolicTangent=d.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,F(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)};d.inverseCosine=d.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,o=t.rounding;return n!==-1?n===0?e.isNeg()?Q(t,r,o):new t(0):new t(NaN):e.isZero()?Q(t,r+4,o).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=o,e.times(2))};d.inverseHyperbolicCosine=d.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,I=!1,n=n.times(n).minus(1).sqrt().plus(n),I=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)};d.inverseHyperbolicSine=d.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,I=!1,n=n.times(n).plus(1).sqrt().plus(n),I=!0,r.precision=e,r.rounding=t,n.ln())};d.inverseHyperbolicTangent=d.atanh=function(){var e,t,n,r,o=this,i=o.constructor;return o.isFinite()?o.e>=0?new i(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(e=i.precision,t=i.rounding,r=o.sd(),Math.max(r,e)<2*-o.e-1?S(new i(o),e,t,!0):(i.precision=n=r-o.e,o=F(o.plus(1),new i(1).minus(o),n+e,1),i.precision=e+4,i.rounding=1,o=o.ln(),i.precision=e,i.rounding=t,o.times(.5))):new i(NaN)};d.inverseSine=d.asin=function(){var e,t,n,r,o=this,i=o.constructor;return o.isZero()?new i(o):(t=o.abs().cmp(1),n=i.precision,r=i.rounding,t!==-1?t===0?(e=Q(i,n+4,r).times(.5),e.s=o.s,e):new i(NaN):(i.precision=n+6,i.rounding=1,o=o.div(new i(1).minus(o.times(o)).sqrt().plus(1)).atan(),i.precision=n,i.rounding=r,o.times(2)))};d.inverseTangent=d.atan=function(){var e,t,n,r,o,i,s,a,c,u=this,l=u.constructor,f=l.precision,m=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&f+4<=pt)return s=Q(l,f+4,m).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(f+4<=pt)return s=Q(l,f+4,m).times(.5),s.s=u.s,s}for(l.precision=a=f+10,l.rounding=1,n=Math.min(28,a/B+2|0),e=n;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(I=!1,t=Math.ceil(a/B),r=1,c=u.times(u),s=new l(u),o=u;e!==-1;)if(o=o.times(c),i=s.minus(o.div(r+=2)),o=o.times(c),s=i.plus(o.div(r+=2)),s.d[t]!==void 0)for(e=t;s.d[e]===i.d[e]&&e--;);return n&&(s=s.times(2<<n-1)),I=!0,S(s,l.precision=f,l.rounding=m,!0)};d.isFinite=function(){return!!this.d};d.isInteger=d.isInt=function(){return!!this.d&&H(this.e/B)>this.d.length-2};d.isNaN=function(){return!this.s};d.isNegative=d.isNeg=function(){return this.s<0};d.isPositive=d.isPos=function(){return this.s>0};d.isZero=function(){return!!this.d&&this.d[0]===0};d.lessThan=d.lt=function(e){return this.cmp(e)<0};d.lessThanOrEqualTo=d.lte=function(e){return this.cmp(e)<1};d.logarithm=d.log=function(e){var t,n,r,o,i,s,a,c,u=this,l=u.constructor,f=l.precision,m=l.rounding,p=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new l(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(o=n[0];o%10===0;)o/=10;i=o!==1}if(I=!1,a=f+p,s=ce(u,a),r=t?Ze(l,a+10):ce(e,a),c=F(s,r,a,1),ke(c.d,o=f,m))do if(a+=10,s=ce(u,a),r=t?Ze(l,a+10):ce(e,a),c=F(s,r,a,1),!i){+G(c.d).slice(o+1,o+15)+1==1e14&&(c=S(c,f+1,0));break}while(ke(c.d,o+=10,m));return I=!0,S(c,f,m)};d.minus=d.sub=function(e){var t,n,r,o,i,s,a,c,u,l,f,m,p=this,b=p.constructor;if(e=new b(e),!p.d||!e.d)return!p.s||!e.s?e=new b(NaN):p.d?e.s=-e.s:e=new b(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(u=p.d,m=e.d,a=b.precision,c=b.rounding,!u[0]||!m[0]){if(m[0])e.s=-e.s;else if(u[0])e=new b(p);else return new b(c===3?-0:0);return I?S(e,a,c):e}if(n=H(e.e/B),l=H(p.e/B),u=u.slice(),i=l-n,i){for(f=i<0,f?(t=u,i=-i,s=m.length):(t=m,n=l,s=u.length),r=Math.max(Math.ceil(a/B),s)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=u.length,s=m.length,f=r<s,f&&(s=r),r=0;r<s;r++)if(u[r]!=m[r]){f=u[r]<m[r];break}i=0}for(f&&(t=u,u=m,m=t,e.s=-e.s),s=u.length,r=m.length-s;r>0;--r)u[s++]=0;for(r=m.length;r>i;){if(u[--r]<m[r]){for(o=r;o&&u[--o]===0;)u[o]=X-1;--u[o],u[r]+=X}u[r]-=m[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(e.d=u,e.e=Xe(u,n),I?S(e,a,c):e):new b(c===3?-0:0)};d.modulo=d.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?S(new r(n),r.precision,r.rounding):(I=!1,r.modulo==9?(t=F(n,e.abs(),0,3,1),t.s*=e.s):t=F(n,e,0,r.modulo,1),t=t.times(e),I=!0,n.minus(t))};d.naturalExponential=d.exp=function(){return gt(this)};d.naturalLogarithm=d.ln=function(){return ce(this)};d.negated=d.neg=function(){var e=new this.constructor(this);return e.s=-e.s,S(e)};d.plus=d.add=function(e){var t,n,r,o,i,s,a,c,u,l,f=this,m=f.constructor;if(e=new m(e),!f.d||!e.d)return!f.s||!e.s?e=new m(NaN):f.d||(e=new m(e.d||f.s===e.s?f:NaN)),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(u=f.d,l=e.d,a=m.precision,c=m.rounding,!u[0]||!l[0])return l[0]||(e=new m(f)),I?S(e,a,c):e;if(i=H(f.e/B),r=H(e.e/B),u=u.slice(),o=i-r,o){for(o<0?(n=u,o=-o,s=l.length):(n=l,r=i,s=u.length),i=Math.ceil(a/B),s=i>s?i+1:s+1,o>s&&(o=s,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,n=l,l=u,u=n),t=0;o;)t=(u[--o]=u[o]+l[o]+t)/X|0,u[o]%=X;for(t&&(u.unshift(t),++r),s=u.length;u[--s]==0;)u.pop();return e.d=u,e.e=Xe(u,r),I?S(e,a,c):e};d.precision=d.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(le+e);return n.d?(t=Yt(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};d.round=function(){var e=this,t=e.constructor;return S(new t(e),e.e+1,t.rounding)};d.sine=d.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+B,r.rounding=1,n=On(r,Qt(r,n)),r.precision=e,r.rounding=t,S(ie>2?n.neg():n,e,t,!0)):new r(NaN)};d.squareRoot=d.sqrt=function(){var e,t,n,r,o,i,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(I=!1,u=Math.sqrt(+s),u==0||u==1/0?(t=G(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=H((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new l(t)):r=new l(u.toString()),n=(c=l.precision)+3;;)if(i=r,r=i.plus(F(s,i,n+2,1)).times(.5),G(i.d).slice(0,n)===(t=G(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!o&&t=="4999"){if(!o&&(S(i,c+1,0),i.times(i).eq(s))){r=i;break}n+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(S(r,c+1,1),e=!r.times(r).eq(s));break}return I=!0,S(r,c,l.rounding,e)};d.tangent=d.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=F(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,S(ie==2||ie==4?n.neg():n,e,t,!0)):new r(NaN)};d.times=d.mul=function(e){var t,n,r,o,i,s,a,c,u,l=this,f=l.constructor,m=l.d,p=(e=new f(e)).d;if(e.s*=l.s,!m||!m[0]||!p||!p[0])return new f(!e.s||m&&!m[0]&&!p||p&&!p[0]&&!m?NaN:!m||!p?e.s/0:e.s*0);for(n=H(l.e/B)+H(e.e/B),c=m.length,u=p.length,c<u&&(i=m,m=p,p=i,s=c,c=u,u=s),i=[],s=c+u,r=s;r--;)i.push(0);for(r=u;--r>=0;){for(t=0,o=c+r;o>r;)a=i[o]+p[r]*m[o-r-1]+t,i[o--]=a%X|0,t=a/X|0;i[o]=(i[o]+t)%X|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=Xe(i,n),I?S(e,f.precision,f.rounding):e};d.toBinary=function(e,t){return ht(this,2,e,t)};d.toDecimalPlaces=d.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Z(e,0,fe),t===void 0?t=r.rounding:Z(t,0,8),S(n,e+n.e+1,t))};d.toExponential=function(e,t){var n,r=this,o=r.constructor;return e===void 0?n=$(r,!0):(Z(e,0,fe),t===void 0?t=o.rounding:Z(t,0,8),r=S(new o(r),e+1,t),n=$(r,!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};d.toFixed=function(e,t){var n,r,o=this,i=o.constructor;return e===void 0?n=$(o):(Z(e,0,fe),t===void 0?t=i.rounding:Z(t,0,8),r=S(new i(o),e+o.e+1,t),n=$(r,!1,e+r.e+1)),o.isNeg()&&!o.isZero()?"-"+n:n};d.toFraction=function(e){var t,n,r,o,i,s,a,c,u,l,f,m,p=this,b=p.d,g=p.constructor;if(!b)return new g(p);if(u=n=new g(1),r=c=new g(0),t=new g(r),i=t.e=Yt(b)-p.e-1,s=i%B,t.d[0]=q(10,s<0?B+s:s),e==null)e=i>0?t:u;else{if(a=new g(e),!a.isInt()||a.lt(u))throw Error(le+a);e=a.gt(t)?i>0?t:u:a}for(I=!1,a=new g(G(b)),l=g.precision,g.precision=i=b.length*B*2;f=F(a,t,0,1,1),o=n.plus(f.times(r)),o.cmp(e)!=1;)n=r,r=o,o=u,u=c.plus(f.times(o)),c=o,o=t,t=a.minus(f.times(o)),a=o;return o=F(e.minus(n),r,0,1,1),c=c.plus(o.times(u)),n=n.plus(o.times(r)),c.s=u.s=p.s,m=F(u,r,i,1).minus(p).abs().cmp(F(c,n,i,1).minus(p).abs())<1?[u,r]:[c,n],g.precision=l,I=!0,m};d.toHexadecimal=d.toHex=function(e,t){return ht(this,16,e,t)};d.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:Z(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(I=!1,n=F(n,e,0,t,1).times(e),I=!0,S(n)):(e.s=n.s,n=e),n};d.toNumber=function(){return+this};d.toOctal=function(e,t){return ht(this,8,e,t)};d.toPower=d.pow=function(e){var t,n,r,o,i,s,a=this,c=a.constructor,u=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c(q(+a,u));if(a=new c(a),a.eq(1))return a;if(r=c.precision,i=c.rounding,e.eq(1))return S(a,r,i);if(t=H(e.e/B),t>=e.d.length-1&&(n=u<0?-u:u)<=En)return o=Zt(c,a,n,r),e.s<0?new c(1).div(o):S(o,r,i);if(s=a.s,s<0){if(t<e.d.length-1)return new c(NaN);if((e.d[t]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=q(+a,u),t=n==0||!isFinite(n)?H(u*(Math.log("0."+G(a.d))/Math.LN10+a.e+1)):new c(n+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(I=!1,c.rounding=a.s=1,n=Math.min(12,(t+"").length),o=gt(e.times(ce(a,r+n)),r),o.d&&(o=S(o,r+5,1),ke(o.d,r,i)&&(t=r+10,o=S(gt(e.times(ce(a,t+n)),t),t+5,1),+G(o.d).slice(r+1,r+15)+1==1e14&&(o=S(o,r+1,0)))),o.s=s,I=!0,c.rounding=i,S(o,r,i))};d.toPrecision=function(e,t){var n,r=this,o=r.constructor;return e===void 0?n=$(r,r.e<=o.toExpNeg||r.e>=o.toExpPos):(Z(e,1,fe),t===void 0?t=o.rounding:Z(t,0,8),r=S(new o(r),e,t),n=$(r,e<=r.e||r.e<=o.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n};d.toSignificantDigits=d.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Z(e,1,fe),t===void 0?t=r.rounding:Z(t,0,8)),S(new r(n),e,t)};d.toString=function(){var e=this,t=e.constructor,n=$(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n};d.truncated=d.trunc=function(){return S(new this.constructor(this),this.e+1,1)};d.valueOf=d.toJSON=function(){var e=this,t=e.constructor,n=$(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function G(e){var t,n,r,o=e.length-1,i="",s=e[0];if(o>0){for(i+=s,t=1;t<o;t++)r=e[t]+"",n=B-r.length,n&&(i+=ue(n)),i+=r;s=e[t],r=s+"",n=B-r.length,n&&(i+=ue(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function Z(e,t,n){if(e!==~~e||e<t||e>n)throw Error(le+e)}function ke(e,t,n,r){var o,i,s,a;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=B,o=0):(o=Math.ceil((t+1)/B),t%=B),i=q(10,B-t),a=e[o]%i|0,r==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==i||n>3&&a+1==i/2)&&(e[o+1]/i/100|0)==q(10,t-2)-1||(a==i/2||a==0)&&(e[o+1]/i/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==2&&(a=a/10|0),s=(r||n<4)&&a==9999||!r&&n>3&&a==4999):s=((r||n<4)&&a+1==i||!r&&n>3&&a+1==i/2)&&(e[o+1]/i/1e3|0)==q(10,t-3)-1,s}function He(e,t,n){for(var r,o=[0],i,s=0,a=e.length;s<a;){for(i=o.length;i--;)o[i]*=t;for(o[0]+=mt.indexOf(e.charAt(s++)),r=0;r<o.length;r++)o[r]>n-1&&(o[r+1]===void 0&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function Dn(e,t){var n,r,o;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),o=(1/Qe(4,n)).toString()):(n=16,o="2.3283064365386962890625e-10"),e.precision+=n,t=ye(e,1,t.times(o),new e(1));for(var i=n;i--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}var F=function(){function e(r,o,i){var s,a=0,c=r.length;for(r=r.slice();c--;)s=r[c]*o+a,r[c]=s%i|0,a=s/i|0;return a&&r.unshift(a),r}function t(r,o,i,s){var a,c;if(i!=s)c=i>s?1:-1;else for(a=c=0;a<i;a++)if(r[a]!=o[a]){c=r[a]>o[a]?1:-1;break}return c}function n(r,o,i,s){for(var a=0;i--;)r[i]-=a,a=r[i]<o[i]?1:0,r[i]=a*s+r[i]-o[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,o,i,s,a,c){var u,l,f,m,p,b,g,w,h,x,P,N,y,T,A,k,C,M,V,v,D=r.constructor,U=r.s==o.s?1:-1,E=r.d,R=o.d;if(!E||!E[0]||!R||!R[0])return new D(!r.s||!o.s||(E?R&&E[0]==R[0]:!R)?NaN:E&&E[0]==0||!R?U*0:U/0);for(c?(p=1,l=r.e-o.e):(c=X,p=B,l=H(r.e/p)-H(o.e/p)),V=R.length,C=E.length,h=new D(U),x=h.d=[],f=0;R[f]==(E[f]||0);f++);if(R[f]>(E[f]||0)&&l--,i==null?(T=i=D.precision,s=D.rounding):a?T=i+(r.e-o.e)+1:T=i,T<0)x.push(1),b=!0;else{if(T=T/p+2|0,f=0,V==1){for(m=0,R=R[0],T++;(f<C||m)&&T--;f++)A=m*c+(E[f]||0),x[f]=A/R|0,m=A%R|0;b=m||f<C}else{for(m=c/(R[0]+1)|0,m>1&&(R=e(R,m,c),E=e(E,m,c),V=R.length,C=E.length),k=V,P=E.slice(0,V),N=P.length;N<V;)P[N++]=0;v=R.slice(),v.unshift(0),M=R[0],R[1]>=c/2&&++M;do m=0,u=t(R,P,V,N),u<0?(y=P[0],V!=N&&(y=y*c+(P[1]||0)),m=y/M|0,m>1?(m>=c&&(m=c-1),g=e(R,m,c),w=g.length,N=P.length,u=t(g,P,w,N),u==1&&(m--,n(g,V<w?v:R,w,c))):(m==0&&(u=m=1),g=R.slice()),w=g.length,w<N&&g.unshift(0),n(P,g,N,c),u==-1&&(N=P.length,u=t(R,P,V,N),u<1&&(m++,n(P,V<N?v:R,N,c))),N=P.length):u===0&&(m++,P=[0]),x[f++]=m,u&&P[0]?P[N++]=E[k]||0:(P=[E[k]],N=1);while((k++<C||P[0]!==void 0)&&T--);b=P[0]!==void 0}x[0]||x.shift()}if(p==1)h.e=l,qt=b;else{for(f=1,m=x[0];m>=10;m/=10)f++;h.e=f+l*p-1,S(h,a?i+h.e+1:i,s,b)}return h}}();function S(e,t,n,r){var o,i,s,a,c,u,l,f,m,p=e.constructor;e:if(t!=null){if(f=e.d,!f)return e;for(o=1,a=f[0];a>=10;a/=10)o++;if(i=t-o,i<0)i+=B,s=t,l=f[m=0],c=l/q(10,o-s-1)%10|0;else if(m=Math.ceil((i+1)/B),a=f.length,m>=a)if(r){for(;a++<=m;)f.push(0);l=c=0,o=1,i%=B,s=i-B+1}else break e;else{for(l=a=f[m],o=1;a>=10;a/=10)o++;i%=B,s=i-B+o,c=s<0?0:l/q(10,o-s-1)%10|0}if(r=r||t<0||f[m+1]!==void 0||(s<0?l:l%q(10,o-s-1)),u=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(i>0?s>0?l/q(10,o-s):0:f[m-1])%10&1||n==(e.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=e.e+1,f[0]=q(10,(B-t%B)%B),e.e=-t||0):f[0]=e.e=0,e;if(i==0?(f.length=m,a=1,m--):(f.length=m+1,a=q(10,B-i),f[m]=s>0?(l/q(10,o-s)%q(10,s)|0)*a:0),u)for(;;)if(m==0){for(i=1,s=f[0];s>=10;s/=10)i++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;i!=a&&(e.e++,f[0]==X&&(f[0]=1));break}else{if(f[m]+=a,f[m]!=X)break;f[m--]=0,a=1}for(i=f.length;f[--i]===0;)f.pop()}return I&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function $(e,t,n){if(!e.isFinite())return Xt(e);var r,o=e.e,i=G(e.d),s=i.length;return t?(n&&(r=n-s)>0?i=i.charAt(0)+"."+i.slice(1)+ue(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):o<0?(i="0."+ue(-o-1)+i,n&&(r=n-s)>0&&(i+=ue(r))):o>=s?(i+=ue(o+1-s),n&&(r=n-o-1)>0&&(i=i+"."+ue(r))):((r=o+1)<s&&(i=i.slice(0,r)+"."+i.slice(r)),n&&(r=n-s)>0&&(o+1===s&&(i+="."),i+=ue(r))),i}function Xe(e,t){var n=e[0];for(t*=B;n>=10;n/=10)t++;return t}function Ze(e,t,n){if(t>Mn)throw I=!0,n&&(e.precision=n),Error(Gt);return S(new e(ze),t,1,!0)}function Q(e,t,n){if(t>pt)throw Error(Gt);return S(new e(Ye),t,n,!0)}function Yt(e){var t=e.length-1,n=t*B+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ue(e){for(var t="";e--;)t+="0";return t}function Zt(e,t,n,r){var o,i=new e(1),s=Math.ceil(r/B+4);for(I=!1;;){if(n%2&&(i=i.times(t),Wt(i.d,s)&&(o=!0)),n=H(n/2),n===0){n=i.d.length-1,o&&i.d[n]===0&&++i.d[n];break}t=t.times(t),Wt(t.d,s)}return I=!0,i}function Kt(e){return e.d[e.d.length-1]&1}function Jt(e,t,n){for(var r,o,i=new e(t[0]),s=0;++s<t.length;){if(o=new e(t[s]),!o.s){i=o;break}r=i.cmp(o),(r===n||r===0&&i.s===n)&&(i=o)}return i}function gt(e,t){var n,r,o,i,s,a,c,u=0,l=0,f=0,m=e.constructor,p=m.rounding,b=m.precision;if(!e.d||!e.d[0]||e.e>17)return new m(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(I=!1,c=b):c=t,a=new m(.03125);e.e>-2;)e=e.times(a),f+=5;for(r=Math.log(q(2,f))/Math.LN10*2+5|0,c+=r,n=i=s=new m(1),m.precision=c;;){if(i=S(i.times(e),c,1),n=n.times(++l),a=s.plus(F(i,n,c,1)),G(a.d).slice(0,c)===G(s.d).slice(0,c)){for(o=f;o--;)s=S(s.times(s),c,1);if(t==null)if(u<3&&ke(s.d,c-r,p,u))m.precision=c+=10,n=i=a=new m(1),l=0,u++;else return S(s,m.precision=b,p,I=!0);else return m.precision=b,s}s=a}}function ce(e,t){var n,r,o,i,s,a,c,u,l,f,m,p=1,b=10,g=e,w=g.d,h=g.constructor,x=h.rounding,P=h.precision;if(g.s<0||!w||!w[0]||!g.e&&w[0]==1&&w.length==1)return new h(w&&!w[0]?-1/0:g.s!=1?NaN:w?0:g);if(t==null?(I=!1,l=P):l=t,h.precision=l+=b,n=G(w),r=n.charAt(0),Math.abs(i=g.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=G(g.d),r=n.charAt(0),p++;i=g.e,r>1?(g=new h("0."+n),i++):g=new h(r+"."+n.slice(1))}else return u=Ze(h,l+2,P).times(i+""),g=ce(new h(r+"."+n.slice(1)),l-b).plus(u),h.precision=P,t==null?S(g,P,x,I=!0):g;for(f=g,c=s=g=F(g.minus(1),g.plus(1),l,1),m=S(g.times(g),l,1),o=3;;){if(s=S(s.times(m),l,1),u=c.plus(F(s,new h(o),l,1)),G(u.d).slice(0,l)===G(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(Ze(h,l+2,P).times(i+""))),c=F(c,new h(p),l,1),t==null)if(ke(c.d,l-b,x,a))h.precision=l+=b,u=s=g=F(f.minus(1),f.plus(1),l,1),m=S(g.times(g),l,1),o=a=1;else return S(c,h.precision=P,x,I=!0);else return h.precision=P,c;c=u,o+=2}}function Xt(e){return String(e.s*e.s/0)}function je(e,t){var n,r,o;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(o=t.length;t.charCodeAt(o-1)===48;--o);if(t=t.slice(r,o),t){if(o-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%B,n<0&&(r+=B),r<o){for(r&&e.d.push(+t.slice(0,r)),o-=B;r<o;)e.d.push(+t.slice(r,r+=B));t=t.slice(r),r=B-t.length}else r-=o;for(;r--;)t+="0";e.d.push(+t),I&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function _n(e,t){var n,r,o,i,s,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),zt.test(t))return je(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(In.test(t))n=16,t=t.toLowerCase();else if(Cn.test(t))n=2;else if(Rn.test(t))n=8;else throw Error(le+t);for(i=t.search(/p/i),i>0?(c=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),s=i>=0,r=e.constructor,s&&(t=t.replace(".",""),a=t.length,i=a-i,o=Zt(r,new r(n),i,i*2)),u=He(t,n,X),l=u.length-1,i=l;u[i]===0;--i)u.pop();return i<0?new r(e.s*0):(e.e=Xe(u,l),e.d=u,I=!1,s&&(e=F(e,o,a*4)),c&&(e=e.times(Math.abs(c)<54?q(2,c):$e.pow(2,c))),I=!0,e)}function On(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:ye(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/Qe(5,n)),t=ye(e,2,t,t);for(var o,i=new e(5),s=new e(16),a=new e(20);n--;)o=t.times(t),t=t.times(i.plus(o.times(s.times(o).minus(a))));return t}function ye(e,t,n,r,o){var i,s,a,c,u=1,l=e.precision,f=Math.ceil(l/B);for(I=!1,c=n.times(n),a=new e(r);;){if(s=F(a.times(c),new e(t++*t++),l,1),a=o?r.plus(s):r.minus(s),r=F(s.times(c),new e(t++*t++),l,1),s=a.plus(r),s.d[f]!==void 0){for(i=f;s.d[i]===a.d[i]&&i--;);if(i==-1)break}i=a,a=r,r=s,s=i,u++}return I=!0,s.d.length=f+1,s}function Qe(e,t){for(var n=e;--t;)n*=e;return n}function Qt(e,t){var n,r=t.s<0,o=Q(e,e.precision,1),i=o.times(.5);if(t=t.abs(),t.lte(i))return ie=r?4:1,t;if(n=t.divToInt(o),n.isZero())ie=r?3:2;else{if(t=t.minus(n.times(o)),t.lte(i))return ie=Kt(n)?r?2:3:r?4:1,t;ie=Kt(n)?r?1:4:r?3:2}return t.minus(o).abs()}function ht(e,t,n,r){var o,i,s,a,c,u,l,f,m,p=e.constructor,b=n!==void 0;if(b?(Z(n,1,fe),r===void 0?r=p.rounding:Z(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())l=Xt(e);else{for(l=$(e),s=l.indexOf("."),b?(o=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):o=t,s>=0&&(l=l.replace(".",""),m=new p(1),m.e=l.length-s,m.d=He($(m),10,o),m.e=m.d.length),f=He(l,10,o),i=c=f.length;f[--c]==0;)f.pop();if(!f[0])l=b?"0p+0":"0";else{if(s<0?i--:(e=new p(e),e.d=f,e.e=i,e=F(e,m,n,r,0,o),f=e.d,i=e.e,u=qt),s=f[n],a=o/2,u=u||f[n+1]!==void 0,u=r<4?(s!==void 0||u)&&(r===0||r===(e.s<0?3:2)):s>a||s===a&&(r===4||u||r===6&&f[n-1]&1||r===(e.s<0?8:7)),f.length=n,u)for(;++f[--n]>o-1;)f[n]=0,n||(++i,f.unshift(1));for(c=f.length;!f[c-1];--c);for(s=0,l="";s<c;s++)l+=mt.charAt(f[s]);if(b){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(f=He(l,o,t),c=f.length;!f[c-1];--c);for(s=1,l="1.";s<c;s++)l+=mt.charAt(f[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)l="0"+l;l="0."+l}else if(++i>c)for(i-=c;i--;)l+="0";else i<c&&(l=l.slice(0,i)+"."+l.slice(i))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function Wt(e,t){if(e.length>t)return e.length=t,!0}function vn(e){return new this(e).abs()}function Fn(e){return new this(e).acos()}function Vn(e){return new this(e).acosh()}function Kn(e,t){return new this(e).plus(t)}function Wn(e){return new this(e).asin()}function Un(e){return new this(e).asinh()}function qn(e){return new this(e).atan()}function Gn(e){return new this(e).atanh()}function Hn(e,t){e=new this(e),t=new this(t);var n,r=this.precision,o=this.rounding,i=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=Q(this,i,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Q(this,r,o):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Q(this,i,1).times(.5),n.s=e.s):t.s<0?(this.precision=i,this.rounding=1,n=this.atan(F(e,t,i,1)),t=Q(this,i,1),this.precision=r,this.rounding=o,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(F(e,t,i,1)),n}function jn(e){return new this(e).cbrt()}function zn(e){return S(e=new this(e),e.e+1,2)}function Yn(e,t,n){return new this(e).clamp(t,n)}function Zn(e){if(!e||typeof e!="object")throw Error(Je+"Object expected");var t,n,r,o=e.defaults===!0,i=["precision",1,fe,"rounding",0,8,"toExpNeg",-be,0,"toExpPos",0,be,"maxE",0,be,"minE",-be,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(n=i[t],o&&(this[n]=dt[n]),(r=e[n])!==void 0)if(H(r)===r&&r>=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(le+n+": "+r);if(n="crypto",o&&(this[n]=dt[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Ht);else this[n]=!1;else throw Error(le+n+": "+r);return this}function Jn(e){return new this(e).cos()}function Xn(e){return new this(e).cosh()}function $t(e){var t,n,r;function o(i){var s,a,c,u=this;if(!(u instanceof o))return new o(i);if(u.constructor=o,Ut(i)){u.s=i.s,I?!i.d||i.e>o.maxE?(u.e=NaN,u.d=null):i.e<o.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(s=0,a=i;a>=10;a/=10)s++;I?s>o.maxE?(u.e=NaN,u.d=null):s<o.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[i]):(u.e=s,u.d=[i]);return}if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return je(u,i.toString())}if(c==="string")return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),zt.test(i)?je(u,i):_n(u,i);if(c==="bigint")return i<0?(i=-i,u.s=-1):u.s=1,je(u,i.toString());throw Error(le+i)}if(o.prototype=d,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=Zn,o.clone=$t,o.isDecimal=Ut,o.abs=vn,o.acos=Fn,o.acosh=Vn,o.add=Kn,o.asin=Wn,o.asinh=Un,o.atan=qn,o.atanh=Gn,o.atan2=Hn,o.cbrt=jn,o.ceil=zn,o.clamp=Yn,o.cos=Jn,o.cosh=Xn,o.div=Qn,o.exp=$n,o.floor=er,o.hypot=tr,o.ln=nr,o.log=rr,o.log10=or,o.log2=ir,o.max=sr,o.min=ar,o.mod=ur,o.mul=cr,o.pow=lr,o.random=fr,o.round=mr,o.sign=dr,o.sin=pr,o.sinh=gr,o.sqrt=hr,o.sub=br,o.sum=yr,o.tan=wr,o.tanh=Tr,o.trunc=xr,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return o.config(e),o}function Qn(e,t){return new this(e).div(t)}function $n(e){return new this(e).exp()}function er(e){return S(e=new this(e),e.e+1,3)}function tr(){var e,t,n=new this(0);for(I=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return I=!0,new this(1/0);n=t}return I=!0,n.sqrt()}function Ut(e){return e instanceof $e||e&&e.toStringTag===jt||!1}function nr(e){return new this(e).ln()}function rr(e,t){return new this(e).log(t)}function ir(e){return new this(e).log(2)}function or(e){return new this(e).log(10)}function sr(){return Jt(this,arguments,-1)}function ar(){return Jt(this,arguments,1)}function ur(e,t){return new this(e).mod(t)}function cr(e,t){return new this(e).mul(t)}function lr(e,t){return new this(e).pow(t)}function fr(e){var t,n,r,o,i=0,s=new this(1),a=[];if(e===void 0?e=this.precision:Z(e,1,fe),r=Math.ceil(e/B),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));i<r;)o=t[i],o>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=o%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);i<r;)o=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(t,i):(a.push(o%1e7),i+=4);i=r/4}else throw Error(Ht);else for(;i<r;)a[i++]=Math.random()*1e7|0;for(r=a[--i],e%=B,r&&e&&(o=q(10,B-e),a[i]=(r/o|0)*o);a[i]===0;i--)a.pop();if(i<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=B)a.shift();for(r=1,o=a[0];o>=10;o/=10)r++;r<B&&(n-=B-r)}return s.e=n,s.d=a,s}function mr(e){return S(e=new this(e),e.e+1,this.rounding)}function dr(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function pr(e){return new this(e).sin()}function gr(e){return new this(e).sinh()}function hr(e){return new this(e).sqrt()}function br(e,t){return new this(e).sub(t)}function yr(){var e=0,t=arguments,n=new this(t[e]);for(I=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return I=!0,S(n,this.precision,this.rounding)}function wr(e){return new this(e).tan()}function Tr(e){return new this(e).tanh()}function xr(e){return S(e=new this(e),e.e+1,1)}d[Symbol.for("nodejs.util.inspect.custom")]=d.toString;d[Symbol.toStringTag]="Decimal";var $e=d.constructor=$t(dt);ze=new $e(ze);Ye=new $e(Ye);import Cr from"big.js";import Ri from"bn.js";import Pr from"toformat";var Ar=Pr,Ce=Ar;import tt from"big.js";import Lr from"bn.js";import Br from"decimal.js-light";import Ie from"bn.js";var en=9007199254740991;function oe(e){let t=Y("Raydium_parseBigNumberish");if(e instanceof Ie)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new Ie(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=en||e<=-en)&&t.logWithError(`BigNumberish number overflow: ${e}`),new Ie(String(e))):typeof e=="bigint"?new Ie(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new Ie(0))}var et=Y("module/fraction"),bt=Ce(tt),Re=Ce(Br),Nr={[0]:Re.ROUND_DOWN,[1]:Re.ROUND_HALF_UP,[2]:Re.ROUND_UP},kr={[0]:tt.roundDown,[1]:tt.roundHalfUp,[2]:tt.roundUp},K=class{constructor(t,n=new Lr(1)){this.numerator=oe(t),this.denominator=oe(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new K(this.denominator,this.numerator)}add(t){let n=t instanceof K?t:new K(oe(t));return this.denominator.eq(n.denominator)?new K(this.numerator.add(n.numerator),this.denominator):new K(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(t){let n=t instanceof K?t:new K(oe(t));return this.denominator.eq(n.denominator)?new K(this.numerator.sub(n.numerator),this.denominator):new K(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(t){let n=t instanceof K?t:new K(oe(t));return new K(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(t){let n=t instanceof K?t:new K(oe(t));return new K(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(t,n={groupSeparator:""},r=1){Number.isInteger(t)||et.logWithError(`${t} is not an integer.`),t<=0&&et.logWithError(`${t} is not positive.`),Re.set({precision:t+1,rounding:Nr[r]});let o=new Re(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return o.toFormat(o.decimalPlaces(),n)}toFixed(t,n={groupSeparator:""},r=1){return Number.isInteger(t)||et.logWithError(`${t} is not an integer.`),t<0&&et.logWithError(`${t} is negative.`),bt.DP=t,bt.RM=kr[r]||1,new bt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)}isZero(){return this.numerator.isZero()}};var Ki=Y("Raydium_amount"),Wi=Ce(Cr);import{PublicKey as Rr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as tn}from"@solana/spl-token";var nn={chainId:101,address:Rr.default.toBase58(),programId:tn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},de={chainId:101,address:"So11111111111111111111111111111111111111112",programId:tn.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 wt}from"@solana/web3.js";import{PublicKey as W,SystemProgram as rn,SYSVAR_RENT_PUBKEY as Er}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Mr}from"@solana/spl-token";function yt({pubkey:e,isSigner:t=!1,isWritable:n=!0}){return{pubkey:e,isWritable:n,isSigner:t}}var Zi=[yt({pubkey:Mr,isWritable:!1}),yt({pubkey:rn.programId,isWritable:!1}),yt({pubkey:Er,isWritable:!1})];function on({publicKey:e,transformSol:t}){let n=sn(e.toString());if(n instanceof W)return t&&n.equals(Ee)?ft:n;if(t&&n.toString()===Ee.toBase58())return ft;if(typeof n=="string"){if(n===W.default.toBase58())return W.default;try{return new W(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function sn(e){try{return new W(e)}catch{return e}}var Ji=new W("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Xi=new W("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Qi=new W("SysvarRent111111111111111111111111111111111"),$i=new W("SysvarC1ock11111111111111111111111111111111"),eo=new W("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),to=new W("Sysvar1nstructions1111111111111111111111111"),no=rn.programId,ro=new W("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),io=new W("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),oo=new W("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),so=new W("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),ao=new W("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),uo=new W("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),co=new W("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),lo=new W("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),fo=new W("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),mo=new W("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),po=new W("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),ft=new W("So11111111111111111111111111111111111111112"),Ee=W.default;var Tt=class{constructor({mint:t,decimals:n,symbol:r,name:o,skipMint:i=!1,isToken2022:s=!1}){if(t===Ee.toBase58()||t instanceof wt&&Ee.equals(t)){this.decimals=de.decimals,this.symbol=de.symbol,this.name=de.name,this.mint=new wt(de.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=r||t.toString().substring(0,6),this.name=o||t.toString().substring(0,6),this.mint=i?wt.default:on({publicKey:t}),this.isToken2022=s}equals(t){return this===t?!0:this.mint.equals(t.mint)}},J=Tt;J.WSOL=new Tt(re(z({},de),{mint:de.address}));var xt=class{constructor({decimals:t,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=t,this.symbol=n,this.name=r}equals(t){return this===t}},nt=xt;nt.SOL=new xt(nn);import Dr from"bn.js";var Bo=new K(new Dr(100));var Eo=Y("Raydium_price");var _r=new se(0),as=new se(1),us=new se(2),cs=new se(3),ls=new se(5),Ir=new se(10),fs=new se(100),ms=new se(1e3),ds=new se(1e4);function lt(e,t=1,n=[]){let r=[...e];if(t<=0)return n;for(;r.length;)n.push(r.splice(0,t));return n}import{PublicKey as Is}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Es}from"@solana/spl-token";import{ComputeBudgetProgram as ln,Keypair as mn,PublicKey as Or,Transaction as dn,TransactionMessage as vr,VersionedTransaction as pn}from"@solana/web3.js";var Me={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV4Withdraw:"FarmV4Withdraw",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee",TransferTip:"TransferTip"};import{TOKEN_PROGRAM_ID as Fr}from"@solana/spl-token";var fn=Y("Raydium_txUtil"),gn=1644;function rt(e){let t=[],n=[];return e.microLamports&&(t.push(ln.setComputeUnitPrice({microLamports:e.microLamports})),n.push(Me.SetComputeUnitPrice)),e.units&&(t.push(ln.setComputeUnitLimit({units:e.units})),n.push(Me.SetComputeUnitLimit)),{instructions:t,instructionTypes:n}}async function we(e,t){var r,o;let n=t!=null?t:"confirmed";return(o=await((r=e.getLatestBlockhash)==null?void 0:r.call(e,{commitment:n})))==null?void 0:o.blockhash}async function it(e,t){return e.getSignatureStatuses([t]),new Promise((n,r)=>{let o=setTimeout(r,6e4);e.onSignature(t,i=>{if(clearTimeout(o),!i.err){n("");return}r(Object.assign(i.err,{txId:t}))},"confirmed")})}function Pt(e,t){e.length<1&&fn.logWithError(`no instructions provided: ${e.toString()}`),t.length<1&&fn.logWithError(`no signers provided:, ${t.toString()}`);let n=new dn;n.recentBlockhash="11111111111111111111111111111111",n.feePayer=t[0],n.add(...e);try{return Buffer.from(n.serialize({verifySignatures:!1})).toString("base64").length<gn}catch{return!1}}function ot(e,t){let[n,r]=Or.findProgramAddressSync(e,t);return{publicKey:n,nonce:r}}function De({instructions:e,payer:t,signers:n}){return Pt(e,[t,...n])}function _e({instructions:e,payer:t,lookupTableAddressAccount:n,recentBlockhash:r=mn.generate().publicKey.toString()}){let i=new vr({payerKey:t,recentBlockhash:r,instructions:e}).compileToV0Message(Object.values(n!=null?n:{}));try{return Buffer.from(new pn(i).serialize()).toString("base64").length<gn}catch{return!1}}var Vr=e=>Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e),Kr=e=>{let t=e.serialize({requireAllSignatures:!1,verifySignatures:!1});e instanceof pn&&(t=Vr(t));try{return t instanceof Buffer?t.toString("base64"):Buffer.from(t).toString("base64")}catch{return t.toString("base64")}};function pe(e){let t=[];return e.forEach(n=>{n instanceof dn&&(n.recentBlockhash||(n.recentBlockhash=Fr.toBase58()),n.feePayer||(n.feePayer=mn.generate().publicKey)),t.push(Kr(n))}),console.log("simulate tx string:",t),t}import{PublicKey as L}from"@solana/web3.js";var Os=new L("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),vs=new L("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),Fs=new L("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Vs=new L("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Ks=new L("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Ws=new L("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Us=new L("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),qs=new L("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Gs=new L("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Hs=new L("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),js=new L("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),zs=new L("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Ys=new L("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),Zs=new L("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Js=new L("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),Xs=new L("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),Qs=new L("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),$s=new L("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),ea=new L("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),ta=new L("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),na=new L("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),ra=new L("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),ia=new L("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),oa=new L("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),sa=new L("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),aa=new L("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),ua=new L("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),ca=new L("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),la=new L("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),fa=new L("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),ma=new L("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var da={OPEN_BOOK_PROGRAM:new L("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new L("Ray1111111111111111111111111111111111111111"),AMM_V4:new L("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new L("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new L("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new L("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new L("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new L("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new L("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new L("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new L("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new L("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:L.default,Router:new L("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new L("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new L("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new L("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new L("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new L("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new L("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new L("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new L("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new L("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new L("Ray1111111111111111111111111111111111111111")};import ha from"bn.js";import{PublicKey as At,AddressLookupTableAccount as Pe}from"@solana/web3.js";async function St({connection:e,address:t,cluster:n="mainnet"}){let r=await Ge(e,[...new Set(t.map(i=>i.toString()))].map(i=>new At(i))),o={};for(let i=0;i<t.length;i++){let s=r[i],a=t[i];if(!s)continue;let c=new Pe({key:a,state:Pe.deserialize(s.data)});o[a.toString()]=c,n==="devnet"?xe[a.toString()]=c:Te[a.toString()]=c}return o}var Te={},Lt=async e=>{let t="AcL1Vo8oy1ULiavEcjSUcwfBSForXMudcZvDZy5nzJkU";if(Te[t])return Te;let n=new At(t),r=await e.getAccountInfo(n);return r&&(Te[t]=new Pe({key:n,state:Pe.deserialize(r.data)})),Te},xe={},Bt=async e=>{let t="EFhMuDw1PKEuckuFRW9PavNfTH4LKP5uKHgyXDmWpFCq";if(xe[t])return xe;let n=new At(t),r=await e.getAccountInfo(n);return r&&(xe[t]=new Pe({key:n,state:Pe.deserialize(r.data)})),xe};import{PublicKey as Ae,sendAndConfirmTransaction as Nt,SystemProgram as Wr,Transaction as Oe,TransactionMessage as ve,VersionedTransaction as Fe}from"@solana/web3.js";import Ur from"axios";var st=2e3,at=class{constructor(t){this.instructions=[];this.endInstructions=[];this.lookupTableAddress=[];this.signers=[];this.instructionTypes=[