@powrldgr/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 132 kB
JavaScript
var Ci=Object.defineProperty,Li=Object.defineProperties;var Ri=Object.getOwnPropertyDescriptors;var Cn=Object.getOwnPropertySymbols;var Mi=Object.prototype.hasOwnProperty,Ei=Object.prototype.propertyIsEnumerable;var Ln=(i,e,t)=>e in i?Ci(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,$=(i,e)=>{for(var t in e||(e={}))Mi.call(e,t)&&Ln(i,t,e[t]);if(Cn)for(var t of Cn(e))Ei.call(e,t)&&Ln(i,t,e[t]);return i},se=(i,e)=>Li(i,Ri(e));import{Keypair as zt,PublicKey as P,SystemProgram as Ze,TransactionInstruction as Pe}from"@solana/web3.js";import Nn from"bn.js";import{PublicKey as Fi}from"@solana/web3.js";import{get as Rn,set as vi}from"lodash";var jt=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},Mn={},Oi={};function Be(i){let e=Rn(Mn,i);if(!e){let t=Rn(Oi,i);e=new jt({name:i,logLevel:t}),vi(Mn,i,e)}return e}import{MINT_SIZE as vo,TOKEN_PROGRAM_ID as Oo,getTransferFeeConfig as Fo,unpackMint as Wo}from"@solana/spl-token";var Qt=Be("Raydium_accountInfo_util");async function je(i,e,t){let{batchRequest:n,commitment:r="confirmed",chunkCount:o=100}=$({batchRequest:!1},t),s=Yt(e,o),a=new Array(s.length).fill([]);if(n){let u=s.map(m=>{let d=i._buildArgs([m.map(f=>f.toBase58())],r,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=Yt(u,10);a=(await(await Promise.all(c.map(async m=>await i._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&Qt.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:f,executable:b,lamports:p,owner:y,rentEpoch:g}=d;return f.length!==2&&f[1]!=="base64"&&Qt.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(f[0],"base64"),executable:b,lamports:p,owner:new Fi(y),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(u=>i.getMultipleAccountsInfo(u,r)))}catch(u){u instanceof Error&&Qt.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return a.flat()}async function Jt(i,e,t){let n=await je(i,e.map(r=>r.pubkey),t);return e.map((r,o)=>se($({},r),{accountInfo:n[o]}))}import Xe from"bn.js";var mt=9e15,$e=1e9,en="0123456789abcdef",Rt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Mt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",tn={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-mt,maxE:mt,crypto:!1},Fn,Ge,M=!0,vt="[DecimalError] ",Je=vt+"Invalid argument: ",Wn=vt+"Precision limit exceeded",Dn=vt+"crypto unavailable",_n="[object Decimal]",Ae=Math.floor,fe=Math.pow,Wi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Di=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,_i=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,qn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Fe=1e7,R=7,qi=9007199254740991,Vi=Rt.length-1,nn=Mt.length-1,h={toStringTag:_n};h.absoluteValue=h.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),S(i)};h.ceil=function(){return S(new this.constructor(this),this.e+1,2)};h.clampedTo=h.clamp=function(i,e){var t,n=this,r=n.constructor;if(i=new r(i),e=new r(e),!i.s||!e.s)return new r(NaN);if(i.gt(e))throw Error(Je+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new r(n)};h.comparedTo=h.cmp=function(i){var e,t,n,r,o=this,s=o.d,a=(i=new o.constructor(i)).d,u=o.s,c=i.s;if(!s||!a)return!u||!c?NaN:u!==c?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-c:0;if(u!==c)return u;if(o.e!==i.e)return o.e>i.e^u<0?1:-1;for(n=s.length,r=a.length,e=0,t=n<r?n:r;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^u<0?1:-1;return n===r?0:n>r^u<0?1:-1};h.cosine=h.cos=function(){var i,e,t=this,n=t.constructor;return t.d?t.d[0]?(i=n.precision,e=n.rounding,n.precision=i+Math.max(t.e,t.sd())+R,n.rounding=1,t=Gi(n,Hn(n,t)),n.precision=i,n.rounding=e,S(Ge==2||Ge==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};h.cubeRoot=h.cbrt=function(){var i,e,t,n,r,o,s,a,u,c,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(M=!1,o=l.s*fe(l.s*l,1/3),!o||Math.abs(o)==1/0?(t=we(l.d),i=l.e,(o=(i-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=fe(t,1/3),i=Ae((i+1)/3)-(i%3==(i<0?-1:2)),o==1/0?t="5e"+i:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+i),n=new m(t),n.s=l.s):n=new m(o.toString()),s=(i=m.precision)+3;;)if(a=n,u=a.times(a).times(a),c=u.plus(l),n=Y(c.plus(l).times(a),c.plus(u),s+2,1),we(a.d).slice(0,s)===(t=we(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(S(a,i+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(S(n,i+1,1),e=!n.times(n).times(n).eq(l));break}return M=!0,S(n,i,m.rounding,e)};h.decimalPlaces=h.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-Ae(this.e/R))*R,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};h.dividedBy=h.div=function(i){return Y(this,new this.constructor(i))};h.dividedToIntegerBy=h.divToInt=function(i){var e=this,t=e.constructor;return S(Y(e,new t(i),0,1,1),t.precision,t.rounding)};h.equals=h.eq=function(i){return this.cmp(i)===0};h.floor=function(){return S(new this.constructor(this),this.e+1,3)};h.greaterThan=h.gt=function(i){return this.cmp(i)>0};h.greaterThanOrEqualTo=h.gte=function(i){var e=this.cmp(i);return e==1||e===0};h.hyperbolicCosine=h.cosh=function(){var i,e,t,n,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;t=s.precision,n=s.rounding,s.precision=t+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(i=Math.ceil(r/3),e=(1/Ft(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),o=dt(s,1,o.times(e),new s(1),!0);for(var u,c=i,l=new s(8);c--;)u=o.times(o),o=a.minus(u.times(l.minus(u.times(l))));return S(o,s.precision=t,s.rounding=n,!0)};h.hyperbolicSine=h.sinh=function(){var i,e,t,n,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,t=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,n=r.d.length,n<3)r=dt(o,2,r,r,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,r=r.times(1/Ft(5,i)),r=dt(o,2,r,r,!0);for(var s,a=new o(5),u=new o(16),c=new o(20);i--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(c))))}return o.precision=e,o.rounding=t,S(r,e,t,!0)};h.hyperbolicTangent=h.tanh=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+7,n.rounding=1,Y(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};h.inverseCosine=h.acos=function(){var i,e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,o=t.rounding;return n!==-1?n===0?e.isNeg()?Oe(t,r,o):new t(0):new t(NaN):e.isZero()?Oe(t,r+4,o).times(.5):(t.precision=r+6,t.rounding=1,e=e.asin(),i=Oe(t,r+4,o).times(.5),t.precision=r,t.rounding=o,i.minus(e))};h.inverseHyperbolicCosine=h.acosh=function(){var i,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(i=n.precision,e=n.rounding,n.precision=i+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,M=!1,t=t.times(t).minus(1).sqrt().plus(t),M=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};h.inverseHyperbolicSine=h.asinh=function(){var i,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,M=!1,t=t.times(t).plus(1).sqrt().plus(t),M=!0,n.precision=i,n.rounding=e,t.ln())};h.inverseHyperbolicTangent=h.atanh=function(){var i,e,t,n,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(i=o.precision,e=o.rounding,n=r.sd(),Math.max(n,i)<2*-r.e-1?S(new o(r),i,e,!0):(o.precision=t=n-r.e,r=Y(r.plus(1),new o(1).minus(r),t+i,1),o.precision=i+4,o.rounding=1,r=r.ln(),o.precision=i,o.rounding=e,r.times(.5))):new o(NaN)};h.inverseSine=h.asin=function(){var i,e,t,n,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),t=o.precision,n=o.rounding,e!==-1?e===0?(i=Oe(o,t+4,n).times(.5),i.s=r.s,i):new o(NaN):(o.precision=t+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=t,o.rounding=n,r.times(2)))};h.inverseTangent=h.atan=function(){var i,e,t,n,r,o,s,a,u,c=this,l=c.constructor,m=l.precision,d=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&m+4<=nn)return s=Oe(l,m+4,d).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(m+4<=nn)return s=Oe(l,m+4,d).times(.5),s.s=c.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/R+2|0),i=t;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(M=!1,e=Math.ceil(a/R),n=1,u=c.times(c),s=new l(c),r=c;i!==-1;)if(r=r.times(u),o=s.minus(r.div(n+=2)),r=r.times(u),s=o.plus(r.div(n+=2)),s.d[e]!==void 0)for(i=e;s.d[i]===o.d[i]&&i--;);return t&&(s=s.times(2<<t-1)),M=!0,S(s,l.precision=m,l.rounding=d,!0)};h.isFinite=function(){return!!this.d};h.isInteger=h.isInt=function(){return!!this.d&&Ae(this.e/R)>this.d.length-2};h.isNaN=function(){return!this.s};h.isNegative=h.isNeg=function(){return this.s<0};h.isPositive=h.isPos=function(){return this.s>0};h.isZero=function(){return!!this.d&&this.d[0]===0};h.lessThan=h.lt=function(i){return this.cmp(i)<0};h.lessThanOrEqualTo=h.lte=function(i){return this.cmp(i)<1};h.logarithm=h.log=function(i){var e,t,n,r,o,s,a,u,c=this,l=c.constructor,m=l.precision,d=l.rounding,f=5;if(i==null)i=new l(10),e=!0;else{if(i=new l(i),t=i.d,i.s<0||!t||!t[0]||i.eq(1))return new l(NaN);e=i.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new l(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)o=!0;else{for(r=t[0];r%10===0;)r/=10;o=r!==1}if(M=!1,a=m+f,s=Ye(c,a),n=e?Et(l,a+10):Ye(i,a),u=Y(s,n,a,1),bt(u.d,r=m,d))do if(a+=10,s=Ye(c,a),n=e?Et(l,a+10):Ye(i,a),u=Y(s,n,a,1),!o){+we(u.d).slice(r+1,r+15)+1==1e14&&(u=S(u,m+1,0));break}while(bt(u.d,r+=10,d));return M=!0,S(u,m,d)};h.minus=h.sub=function(i){var e,t,n,r,o,s,a,u,c,l,m,d,f=this,b=f.constructor;if(i=new b(i),!f.d||!i.d)return!f.s||!i.s?i=new b(NaN):f.d?i.s=-i.s:i=new b(i.d||f.s!==i.s?f:NaN),i;if(f.s!=i.s)return i.s=-i.s,f.plus(i);if(c=f.d,d=i.d,a=b.precision,u=b.rounding,!c[0]||!d[0]){if(d[0])i.s=-i.s;else if(c[0])i=new b(f);else return new b(u===3?-0:0);return M?S(i,a,u):i}if(t=Ae(i.e/R),l=Ae(f.e/R),c=c.slice(),o=l-t,o){for(m=o<0,m?(e=c,o=-o,s=d.length):(e=d,t=l,s=c.length),n=Math.max(Math.ceil(a/R),s)+2,o>n&&(o=n,e.length=1),e.reverse(),n=o;n--;)e.push(0);e.reverse()}else{for(n=c.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(c[n]!=d[n]){m=c[n]<d[n];break}o=0}for(m&&(e=c,c=d,d=e,i.s=-i.s),s=c.length,n=d.length-s;n>0;--n)c[s++]=0;for(n=d.length;n>o;){if(c[--n]<d[n]){for(r=n;r&&c[--r]===0;)c[r]=Fe-1;--c[r],c[n]+=Fe}c[n]-=d[n]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(i.d=c,i.e=Ot(c,t),M?S(i,a,u):i):new b(u===3?-0:0)};h.modulo=h.mod=function(i){var e,t=this,n=t.constructor;return i=new n(i),!t.d||!i.s||i.d&&!i.d[0]?new n(NaN):!i.d||t.d&&!t.d[0]?S(new n(t),n.precision,n.rounding):(M=!1,n.modulo==9?(e=Y(t,i.abs(),0,3,1),e.s*=i.s):e=Y(t,i,0,n.modulo,1),e=e.times(i),M=!0,t.minus(e))};h.naturalExponential=h.exp=function(){return rn(this)};h.naturalLogarithm=h.ln=function(){return Ye(this)};h.negated=h.neg=function(){var i=new this.constructor(this);return i.s=-i.s,S(i)};h.plus=h.add=function(i){var e,t,n,r,o,s,a,u,c,l,m=this,d=m.constructor;if(i=new d(i),!m.d||!i.d)return!m.s||!i.s?i=new d(NaN):m.d||(i=new d(i.d||m.s===i.s?m:NaN)),i;if(m.s!=i.s)return i.s=-i.s,m.minus(i);if(c=m.d,l=i.d,a=d.precision,u=d.rounding,!c[0]||!l[0])return l[0]||(i=new d(m)),M?S(i,a,u):i;if(o=Ae(m.e/R),n=Ae(i.e/R),c=c.slice(),r=o-n,r){for(r<0?(t=c,r=-r,s=l.length):(t=l,n=o,s=c.length),o=Math.ceil(a/R),s=o>s?o+1:s+1,r>s&&(r=s,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for(s=c.length,r=l.length,s-r<0&&(r=s,t=l,l=c,c=t),e=0;r;)e=(c[--r]=c[r]+l[r]+e)/Fe|0,c[r]%=Fe;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=Ot(c,n),M?S(i,a,u):i};h.precision=h.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Je+i);return t.d?(e=Vn(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};h.round=function(){var i=this,e=i.constructor;return S(new e(i),i.e+1,e.rounding)};h.sine=h.sin=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+Math.max(t.e,t.sd())+R,n.rounding=1,t=Xi(n,Hn(n,t)),n.precision=i,n.rounding=e,S(Ge>2?t.neg():t,i,e,!0)):new n(NaN)};h.squareRoot=h.sqrt=function(){var i,e,t,n,r,o,s=this,a=s.d,u=s.e,c=s.s,l=s.constructor;if(c!==1||!a||!a[0])return new l(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(M=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=we(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=Ae((u+1)/2)-(u<0||u%2),c==1/0?e="5e"+u:(e=c.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),n=new l(e)):n=new l(c.toString()),t=(u=l.precision)+3;;)if(o=n,n=o.plus(Y(s,o,t+2,1)).times(.5),we(o.d).slice(0,t)===(e=we(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(S(o,u+1,0),o.times(o).eq(s))){n=o;break}t+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(S(n,u+1,1),i=!n.times(n).eq(s));break}return M=!0,S(n,u,l.rounding,i)};h.tangent=h.tan=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+10,n.rounding=1,t=t.sin(),t.s=1,t=Y(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,S(Ge==2||Ge==4?t.neg():t,i,e,!0)):new n(NaN)};h.times=h.mul=function(i){var e,t,n,r,o,s,a,u,c,l=this,m=l.constructor,d=l.d,f=(i=new m(i)).d;if(i.s*=l.s,!d||!d[0]||!f||!f[0])return new m(!i.s||d&&!d[0]&&!f||f&&!f[0]&&!d?NaN:!d||!f?i.s/0:i.s*0);for(t=Ae(l.e/R)+Ae(i.e/R),u=d.length,c=f.length,u<c&&(o=d,d=f,f=o,s=u,u=c,c=s),o=[],s=u+c,n=s;n--;)o.push(0);for(n=c;--n>=0;){for(e=0,r=u+n;r>n;)a=o[r]+f[n]*d[r-n-1]+e,o[r--]=a%Fe|0,e=a/Fe|0;o[r]=(o[r]+e)%Fe|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),i.d=o,i.e=Ot(o,t),M?S(i,m.precision,m.rounding):i};h.toBinary=function(i,e){return sn(this,2,i,e)};h.toDecimalPlaces=h.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(Ke(i,0,$e),e===void 0?e=n.rounding:Ke(e,0,8),S(t,i+t.e+1,e))};h.toExponential=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=_e(n,!0):(Ke(i,0,$e),e===void 0?e=r.rounding:Ke(e,0,8),n=S(new r(n),i+1,e),t=_e(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};h.toFixed=function(i,e){var t,n,r=this,o=r.constructor;return i===void 0?t=_e(r):(Ke(i,0,$e),e===void 0?e=o.rounding:Ke(e,0,8),n=S(new o(r),i+r.e+1,e),t=_e(n,!1,i+n.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};h.toFraction=function(i){var e,t,n,r,o,s,a,u,c,l,m,d,f=this,b=f.d,p=f.constructor;if(!b)return new p(f);if(c=t=new p(1),n=u=new p(0),e=new p(n),o=e.e=Vn(b)-f.e-1,s=o%R,e.d[0]=fe(10,s<0?R+s:s),i==null)i=o>0?e:c;else{if(a=new p(i),!a.isInt()||a.lt(c))throw Error(Je+a);i=a.gt(e)?o>0?e:c:a}for(M=!1,a=new p(we(b)),l=p.precision,p.precision=o=b.length*R*2;m=Y(a,e,0,1,1),r=t.plus(m.times(n)),r.cmp(i)!=1;)t=n,n=r,r=c,c=u.plus(m.times(r)),u=r,r=e,e=a.minus(m.times(r)),a=r;return r=Y(i.minus(t),n,0,1,1),u=u.plus(r.times(c)),t=t.plus(r.times(n)),u.s=c.s=f.s,d=Y(c,n,o,1).minus(f).abs().cmp(Y(u,t,o,1).minus(f).abs())<1?[c,n]:[u,t],p.precision=l,M=!0,d};h.toHexadecimal=h.toHex=function(i,e){return sn(this,16,i,e)};h.toNearest=function(i,e){var t=this,n=t.constructor;if(t=new n(t),i==null){if(!t.d)return t;i=new n(1),e=n.rounding}else{if(i=new n(i),e===void 0?e=n.rounding:Ke(e,0,8),!t.d)return i.s?t:i;if(!i.d)return i.s&&(i.s=t.s),i}return i.d[0]?(M=!1,t=Y(t,i,0,e,1).times(i),M=!0,S(t)):(i.s=t.s,t=i),t};h.toNumber=function(){return+this};h.toOctal=function(i,e){return sn(this,8,i,e)};h.toPower=h.pow=function(i){var e,t,n,r,o,s,a=this,u=a.constructor,c=+(i=new u(i));if(!a.d||!i.d||!a.d[0]||!i.d[0])return new u(fe(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,o=u.rounding,i.eq(1))return S(a,n,o);if(e=Ae(i.e/R),e>=i.d.length-1&&(t=c<0?-c:c)<=qi)return r=Gn(u,a,t,n),i.s<0?new u(1).div(r):S(r,n,o);if(s=a.s,s<0){if(e<i.d.length-1)return new u(NaN);if((i.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=fe(+a,c),e=t==0||!isFinite(t)?Ae(c*(Math.log("0."+we(a.d))/Math.LN10+a.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?s/0:0):(M=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),r=rn(i.times(Ye(a,n+t)),n),r.d&&(r=S(r,n+5,1),bt(r.d,n,o)&&(e=n+10,r=S(rn(i.times(Ye(a,e+t)),e),e+5,1),+we(r.d).slice(n+1,n+15)+1==1e14&&(r=S(r,n+1,0)))),r.s=s,M=!0,u.rounding=o,S(r,n,o))};h.toPrecision=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=_e(n,n.e<=r.toExpNeg||n.e>=r.toExpPos):(Ke(i,1,$e),e===void 0?e=r.rounding:Ke(e,0,8),n=S(new r(n),i,e),t=_e(n,i<=n.e||n.e<=r.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};h.toSignificantDigits=h.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(Ke(i,1,$e),e===void 0?e=n.rounding:Ke(e,0,8)),S(new n(t),i,e)};h.toString=function(){var i=this,e=i.constructor,t=_e(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};h.truncated=h.trunc=function(){return S(new this.constructor(this),this.e+1,1)};h.valueOf=h.toJSON=function(){var i=this,e=i.constructor,t=_e(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function we(i){var e,t,n,r=i.length-1,o="",s=i[0];if(r>0){for(o+=s,e=1;e<r;e++)n=i[e]+"",t=R-n.length,t&&(o+=Qe(t)),o+=n;s=i[e],n=s+"",t=R-n.length,t&&(o+=Qe(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Ke(i,e,t){if(i!==~~i||i<e||i>t)throw Error(Je+i)}function bt(i,e,t,n){var r,o,s,a;for(o=i[0];o>=10;o/=10)--e;return--e<0?(e+=R,r=0):(r=Math.ceil((e+1)/R),e%=R),o=fe(10,R-e),a=i[r]%o|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==o||t>3&&a+1==o/2)&&(i[r+1]/o/100|0)==fe(10,e-2)-1||(a==o/2||a==0)&&(i[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=(n||t<4)&&a==9999||!n&&t>3&&a==4999):s=((n||t<4)&&a+1==o||!n&&t>3&&a+1==o/2)&&(i[r+1]/o/1e3|0)==fe(10,e-3)-1,s}function Lt(i,e,t){for(var n,r=[0],o,s=0,a=i.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=en.indexOf(i.charAt(s++)),n=0;n<r.length;n++)r[n]>t-1&&(r[n+1]===void 0&&(r[n+1]=0),r[n+1]+=r[n]/t|0,r[n]%=t)}return r.reverse()}function Gi(i,e){var t,n,r;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),r=(1/Ft(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),i.precision+=t,e=dt(i,1,e.times(r),new i(1));for(var o=t;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return i.precision-=t,e}var Y=function(){function i(n,r,o){var s,a=0,u=n.length;for(n=n.slice();u--;)s=n[u]*r+a,n[u]=s%o|0,a=s/o|0;return a&&n.unshift(a),n}function e(n,r,o,s){var a,u;if(o!=s)u=o>s?1:-1;else for(a=u=0;a<o;a++)if(n[a]!=r[a]){u=n[a]>r[a]?1:-1;break}return u}function t(n,r,o,s){for(var a=0;o--;)n[o]-=a,a=n[o]<r[o]?1:0,n[o]=a*s+n[o]-r[o];for(;!n[0]&&n.length>1;)n.shift()}return function(n,r,o,s,a,u){var c,l,m,d,f,b,p,y,g,A,w,T,N,k,K,L,O,G,E,ce,J=n.constructor,be=n.s==r.s?1:-1,oe=n.d,Z=r.d;if(!oe||!oe[0]||!Z||!Z[0])return new J(!n.s||!r.s||(oe?Z&&oe[0]==Z[0]:!Z)?NaN:oe&&oe[0]==0||!Z?be*0:be/0);for(u?(f=1,l=n.e-r.e):(u=Fe,f=R,l=Ae(n.e/f)-Ae(r.e/f)),E=Z.length,O=oe.length,g=new J(be),A=g.d=[],m=0;Z[m]==(oe[m]||0);m++);if(Z[m]>(oe[m]||0)&&l--,o==null?(k=o=J.precision,s=J.rounding):a?k=o+(n.e-r.e)+1:k=o,k<0)A.push(1),b=!0;else{if(k=k/f+2|0,m=0,E==1){for(d=0,Z=Z[0],k++;(m<O||d)&&k--;m++)K=d*u+(oe[m]||0),A[m]=K/Z|0,d=K%Z|0;b=d||m<O}else{for(d=u/(Z[0]+1)|0,d>1&&(Z=i(Z,d,u),oe=i(oe,d,u),E=Z.length,O=oe.length),L=E,w=oe.slice(0,E),T=w.length;T<E;)w[T++]=0;ce=Z.slice(),ce.unshift(0),G=Z[0],Z[1]>=u/2&&++G;do d=0,c=e(Z,w,E,T),c<0?(N=w[0],E!=T&&(N=N*u+(w[1]||0)),d=N/G|0,d>1?(d>=u&&(d=u-1),p=i(Z,d,u),y=p.length,T=w.length,c=e(p,w,y,T),c==1&&(d--,t(p,E<y?ce:Z,y,u))):(d==0&&(c=d=1),p=Z.slice()),y=p.length,y<T&&p.unshift(0),t(w,p,T,u),c==-1&&(T=w.length,c=e(Z,w,E,T),c<1&&(d++,t(w,E<T?ce:Z,T,u))),T=w.length):c===0&&(d++,w=[0]),A[m++]=d,c&&w[0]?w[T++]=oe[L]||0:(w=[oe[L]],T=1);while((L++<O||w[0]!==void 0)&&k--);b=w[0]!==void 0}A[0]||A.shift()}if(f==1)g.e=l,Fn=b;else{for(m=1,d=A[0];d>=10;d/=10)m++;g.e=m+l*f-1,S(g,a?o+g.e+1:o,s,b)}return g}}();function S(i,e,t,n){var r,o,s,a,u,c,l,m,d,f=i.constructor;e:if(e!=null){if(m=i.d,!m)return i;for(r=1,a=m[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=R,s=e,l=m[d=0],u=l/fe(10,r-s-1)%10|0;else if(d=Math.ceil((o+1)/R),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=u=0,r=1,o%=R,s=o-R+1}else break e;else{for(l=a=m[d],r=1;a>=10;a/=10)r++;o%=R,s=o-R+r,u=s<0?0:l/fe(10,r-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%fe(10,r-s-1)),c=t<4?(u||n)&&(t==0||t==(i.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(o>0?s>0?l/fe(10,r-s):0:m[d-1])%10&1||t==(i.s<0?8:7)),e<1||!m[0])return m.length=0,c?(e-=i.e+1,m[0]=fe(10,(R-e%R)%R),i.e=-e||0):m[0]=i.e=0,i;if(o==0?(m.length=d,a=1,d--):(m.length=d+1,a=fe(10,R-o),m[d]=s>0?(l/fe(10,r-s)%fe(10,s)|0)*a:0),c)for(;;)if(d==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&&(i.e++,m[0]==Fe&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=Fe)break;m[d--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return M&&(i.e>f.maxE?(i.d=null,i.e=NaN):i.e<f.minE&&(i.e=0,i.d=[0])),i}function _e(i,e,t){if(!i.isFinite())return Xn(i);var n,r=i.e,o=we(i.d),s=o.length;return e?(t&&(n=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+Qe(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i.e<0?"e":"e+")+i.e):r<0?(o="0."+Qe(-r-1)+o,t&&(n=t-s)>0&&(o+=Qe(n))):r>=s?(o+=Qe(r+1-s),t&&(n=t-r-1)>0&&(o=o+"."+Qe(n))):((n=r+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),t&&(n=t-s)>0&&(r+1===s&&(o+="."),o+=Qe(n))),o}function Ot(i,e){var t=i[0];for(e*=R;t>=10;t/=10)e++;return e}function Et(i,e,t){if(e>Vi)throw M=!0,t&&(i.precision=t),Error(Wn);return S(new i(Rt),e,1,!0)}function Oe(i,e,t){if(e>nn)throw Error(Wn);return S(new i(Mt),e,t,!0)}function Vn(i){var e=i.length-1,t=e*R+1;if(e=i[e],e){for(;e%10==0;e/=10)t--;for(e=i[0];e>=10;e/=10)t++}return t}function Qe(i){for(var e="";i--;)e+="0";return e}function Gn(i,e,t,n){var r,o=new i(1),s=Math.ceil(n/R+4);for(M=!1;;){if(t%2&&(o=o.times(e),vn(o.d,s)&&(r=!0)),t=Ae(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),vn(e.d,s)}return M=!0,o}function En(i){return i.d[i.d.length-1]&1}function Un(i,e,t){for(var n,r=new i(e[0]),o=0;++o<e.length;)if(n=new i(e[o]),n.s)r[t](n)&&(r=n);else{r=n;break}return r}function rn(i,e){var t,n,r,o,s,a,u,c=0,l=0,m=0,d=i.constructor,f=d.rounding,b=d.precision;if(!i.d||!i.d[0]||i.e>17)return new d(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:0/0);for(e==null?(M=!1,u=b):u=e,a=new d(.03125);i.e>-2;)i=i.times(a),m+=5;for(n=Math.log(fe(2,m))/Math.LN10*2+5|0,u+=n,t=o=s=new d(1),d.precision=u;;){if(o=S(o.times(i),u,1),t=t.times(++l),a=s.plus(Y(o,t,u,1)),we(a.d).slice(0,u)===we(s.d).slice(0,u)){for(r=m;r--;)s=S(s.times(s),u,1);if(e==null)if(c<3&&bt(s.d,u-n,f,c))d.precision=u+=10,t=o=a=new d(1),l=0,c++;else return S(s,d.precision=b,f,M=!0);else return d.precision=b,s}s=a}}function Ye(i,e){var t,n,r,o,s,a,u,c,l,m,d,f=1,b=10,p=i,y=p.d,g=p.constructor,A=g.rounding,w=g.precision;if(p.s<0||!y||!y[0]||!p.e&&y[0]==1&&y.length==1)return new g(y&&!y[0]?-1/0:p.s!=1?NaN:y?0:p);if(e==null?(M=!1,l=w):l=e,g.precision=l+=b,t=we(y),n=t.charAt(0),Math.abs(o=p.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)p=p.times(i),t=we(p.d),n=t.charAt(0),f++;o=p.e,n>1?(p=new g("0."+t),o++):p=new g(n+"."+t.slice(1))}else return c=Et(g,l+2,w).times(o+""),p=Ye(new g(n+"."+t.slice(1)),l-b).plus(c),g.precision=w,e==null?S(p,w,A,M=!0):p;for(m=p,u=s=p=Y(p.minus(1),p.plus(1),l,1),d=S(p.times(p),l,1),r=3;;){if(s=S(s.times(d),l,1),c=u.plus(Y(s,new g(r),l,1)),we(c.d).slice(0,l)===we(u.d).slice(0,l))if(u=u.times(2),o!==0&&(u=u.plus(Et(g,l+2,w).times(o+""))),u=Y(u,new g(f),l,1),e==null)if(bt(u.d,l-b,A,a))g.precision=l+=b,c=s=p=Y(m.minus(1),m.plus(1),l,1),d=S(p.times(p),l,1),r=a=1;else return S(u,g.precision=w,A,M=!0);else return g.precision=w,u;u=c,r+=2}}function Xn(i){return String(i.s*i.s/0)}function on(i,e){var t,n,r;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(n,r),e){if(r-=n,i.e=t=t-n-1,i.d=[],n=(t+1)%R,t<0&&(n+=R),n<r){for(n&&i.d.push(+e.slice(0,n)),r-=R;n<r;)i.d.push(+e.slice(n,n+=R));e=e.slice(n),n=R-e.length}else n-=r;for(;n--;)e+="0";i.d.push(+e),M&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function Ui(i,e){var t,n,r,o,s,a,u,c,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),qn.test(e))return on(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(Di.test(e))t=16,e=e.toLowerCase();else if(Wi.test(e))t=2;else if(_i.test(e))t=8;else throw Error(Je+e);for(o=e.search(/p/i),o>0?(u=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,n=i.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=Gn(n,new n(t),o,o*2)),c=Lt(e,t,Fe),l=c.length-1,o=l;c[o]===0;--o)c.pop();return o<0?new n(i.s*0):(i.e=Ot(c,l),i.d=c,M=!1,s&&(i=Y(i,r,a*4)),u&&(i=i.times(Math.abs(u)<54?fe(2,u):gt.pow(2,u))),M=!0,i)}function Xi(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:dt(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Ft(5,t)),e=dt(i,2,e,e);for(var r,o=new i(5),s=new i(16),a=new i(20);t--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function dt(i,e,t,n,r){var o,s,a,u,c=1,l=i.precision,m=Math.ceil(l/R);for(M=!1,u=t.times(t),a=new i(n);;){if(s=Y(a.times(u),new i(e++*e++),l,1),a=r?n.plus(s):n.minus(s),n=Y(s.times(u),new i(e++*e++),l,1),s=a.plus(n),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=n,n=s,s=o,c++}return M=!0,s.d.length=m+1,s}function Ft(i,e){for(var t=i;--e;)t*=i;return t}function Hn(i,e){var t,n=e.s<0,r=Oe(i,i.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return Ge=n?4:1,e;if(t=e.divToInt(r),t.isZero())Ge=n?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return Ge=En(t)?n?2:3:n?4:1,e;Ge=En(t)?n?1:4:n?3:2}return e.minus(r).abs()}function sn(i,e,t,n){var r,o,s,a,u,c,l,m,d,f=i.constructor,b=t!==void 0;if(b?(Ke(t,1,$e),n===void 0?n=f.rounding:Ke(n,0,8)):(t=f.precision,n=f.rounding),!i.isFinite())l=Xn(i);else{for(l=_e(i),s=l.indexOf("."),b?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(l=l.replace(".",""),d=new f(1),d.e=l.length-s,d.d=Lt(_e(d),10,r),d.e=d.d.length),m=Lt(l,10,r),o=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=b?"0p+0":"0";else{if(s<0?o--:(i=new f(i),i.d=m,i.e=o,i=Y(i,d,t,n,0,r),m=i.d,o=i.e,c=Fn),s=m[t],a=r/2,c=c||m[t+1]!==void 0,c=n<4?(s!==void 0||c)&&(n===0||n===(i.s<0?3:2)):s>a||s===a&&(n===4||c||n===6&&m[t-1]&1||n===(i.s<0?8:7)),m.length=t,c)for(;++m[--t]>r-1;)m[t]=0,t||(++o,m.unshift(1));for(u=m.length;!m[u-1];--u);for(s=0,l="";s<u;s++)l+=en.charAt(m[s]);if(b){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)l+="0";for(m=Lt(l,r,e),u=m.length;!m[u-1];--u);for(s=1,l="1.";s<u;s++)l+=en.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>u)for(o-=u;o--;)l+="0";else o<u&&(l=l.slice(0,o)+"."+l.slice(o))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return i.s<0?"-"+l:l}function vn(i,e){if(i.length>e)return i.length=e,!0}function Hi(i){return new this(i).abs()}function zi(i){return new this(i).acos()}function Zi(i){return new this(i).acosh()}function ji(i,e){return new this(i).plus(e)}function Qi(i){return new this(i).asin()}function Yi(i){return new this(i).asinh()}function Ji(i){return new this(i).atan()}function $i(i){return new this(i).atanh()}function er(i,e){i=new this(i),e=new this(e);var t,n=this.precision,r=this.rounding,o=n+4;return!i.s||!e.s?t=new this(NaN):!i.d&&!e.d?(t=Oe(this,o,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?Oe(this,n,r):new this(0),t.s=i.s):!i.d||e.isZero()?(t=Oe(this,o,1).times(.5),t.s=i.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(Y(i,e,o,1)),e=Oe(this,o,1),this.precision=n,this.rounding=r,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(Y(i,e,o,1)),t}function tr(i){return new this(i).cbrt()}function nr(i){return S(i=new this(i),i.e+1,2)}function ir(i,e,t){return new this(i).clamp(e,t)}function rr(i){if(!i||typeof i!="object")throw Error(vt+"Object expected");var e,t,n,r=i.defaults===!0,o=["precision",1,$e,"rounding",0,8,"toExpNeg",-mt,0,"toExpPos",0,mt,"maxE",0,mt,"minE",-mt,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],r&&(this[t]=tn[t]),(n=i[t])!==void 0)if(Ae(n)===n&&n>=o[e+1]&&n<=o[e+2])this[t]=n;else throw Error(Je+t+": "+n);if(t="crypto",r&&(this[t]=tn[t]),(n=i[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Dn);else this[t]=!1;else throw Error(Je+t+": "+n);return this}function or(i){return new this(i).cos()}function sr(i){return new this(i).cosh()}function zn(i){var e,t,n;function r(o){var s,a,u,c=this;if(!(c instanceof r))return new r(o);if(c.constructor=r,On(o)){c.s=o.s,M?!o.d||o.e>r.maxE?(c.e=NaN,c.d=null):o.e<r.minE?(c.e=0,c.d=[0]):(c.e=o.e,c.d=o.d.slice()):(c.e=o.e,c.d=o.d?o.d.slice():o.d);return}if(u=typeof o,u==="number"){if(o===0){c.s=1/o<0?-1:1,c.e=0,c.d=[0];return}if(o<0?(o=-o,c.s=-1):c.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;M?s>r.maxE?(c.e=NaN,c.d=null):s<r.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[o]):(c.e=s,c.d=[o]);return}else if(o*0!==0){o||(c.s=NaN),c.e=NaN,c.d=null;return}return on(c,o.toString())}else if(u!=="string")throw Error(Je+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),c.s=-1):(a===43&&(o=o.slice(1)),c.s=1),qn.test(o)?on(c,o):Ui(c,o)}if(r.prototype=h,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=rr,r.clone=zn,r.isDecimal=On,r.abs=Hi,r.acos=zi,r.acosh=Zi,r.add=ji,r.asin=Qi,r.asinh=Yi,r.atan=Ji,r.atanh=$i,r.atan2=er,r.cbrt=tr,r.ceil=nr,r.clamp=ir,r.cos=or,r.cosh=sr,r.div=ar,r.exp=ur,r.floor=cr,r.hypot=lr,r.ln=mr,r.log=dr,r.log10=pr,r.log2=fr,r.max=br,r.min=gr,r.mod=yr,r.mul=hr,r.pow=wr,r.random=kr,r.round=Pr,r.sign=Ar,r.sin=Tr,r.sinh=xr,r.sqrt=Br,r.sub=Sr,r.sum=Ir,r.tan=Nr,r.tanh=Kr,r.trunc=Cr,i===void 0&&(i={}),i&&i.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)i.hasOwnProperty(t=n[e++])||(i[t]=this[t]);return r.config(i),r}function ar(i,e){return new this(i).div(e)}function ur(i){return new this(i).exp()}function cr(i){return S(i=new this(i),i.e+1,3)}function lr(){var i,e,t=new this(0);for(M=!1,i=0;i<arguments.length;)if(e=new this(arguments[i++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return M=!0,new this(1/0);t=e}return M=!0,t.sqrt()}function On(i){return i instanceof gt||i&&i.toStringTag===_n||!1}function mr(i){return new this(i).ln()}function dr(i,e){return new this(i).log(e)}function fr(i){return new this(i).log(2)}function pr(i){return new this(i).log(10)}function br(){return Un(this,arguments,"lt")}function gr(){return Un(this,arguments,"gt")}function yr(i,e){return new this(i).mod(e)}function hr(i,e){return new this(i).mul(e)}function wr(i,e){return new this(i).pow(e)}function kr(i){var e,t,n,r,o=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Ke(i,1,$e),n=Math.ceil(i/R),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));o<n;)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(n*=4);o<n;)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=n/4}else throw Error(Dn);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],i%=R,n&&i&&(r=fe(10,R-i),a[o]=(n/r|0)*r);a[o]===0;o--)a.pop();if(o<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=R)a.shift();for(n=1,r=a[0];r>=10;r/=10)n++;n<R&&(t-=R-n)}return s.e=t,s.d=a,s}function Pr(i){return S(i=new this(i),i.e+1,this.rounding)}function Ar(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Tr(i){return new this(i).sin()}function xr(i){return new this(i).sinh()}function Br(i){return new this(i).sqrt()}function Sr(i,e){return new this(i).sub(e)}function Ir(){var i=0,e=arguments,t=new this(e[i]);for(M=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return M=!0,S(t,this.precision,this.rounding)}function Nr(i){return new this(i).tan()}function Kr(i){return new this(i).tanh()}function Cr(i){return S(i=new this(i),i.e+1,1)}h[Symbol.for("nodejs.util.inspect.custom")]=h.toString;h[Symbol.toStringTag]="Decimal";var gt=h.constructor=zn(tn);Rt=new gt(Rt);Mt=new gt(Mt);var B=gt;import Wr from"big.js";import _t from"bn.js";import Lr from"toformat";var Rr=Lr,yt=Rr;import Dt from"big.js";import Er from"bn.js";import vr from"decimal.js-light";import ht from"bn.js";var Zn=9007199254740991;function ge(i){let e=Be("Raydium_parseBigNumberish");if(i instanceof ht)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new ht(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=Zn||i<=-Zn)&&e.logWithError(`BigNumberish number overflow: ${i}`),new ht(String(i))):typeof i=="bigint"?new ht(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new ht(0))}var Wt=Be("module/fraction"),an=yt(Dt),wt=yt(vr),Or={[0]:wt.ROUND_DOWN,[1]:wt.ROUND_HALF_UP,[2]:wt.ROUND_UP},Fr={[0]:Dt.roundDown,[1]:Dt.roundHalfUp,[2]:Dt.roundUp},X=class{constructor(e,t=new Er(1)){this.numerator=ge(e),this.denominator=ge(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new X(this.denominator,this.numerator)}add(e){let t=e instanceof X?e:new X(ge(e));return this.denominator.eq(t.denominator)?new X(this.numerator.add(t.numerator),this.denominator):new X(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof X?e:new X(ge(e));return this.denominator.eq(t.denominator)?new X(this.numerator.sub(t.numerator),this.denominator):new X(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof X?e:new X(ge(e));return new X(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof X?e:new X(ge(e));return new X(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||Wt.logWithError(`${e} is not an integer.`),e<=0&&Wt.logWithError(`${e} is not positive.`),wt.set({precision:e+1,rounding:Or[n]});let r=new wt(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||Wt.logWithError(`${e} is not an integer.`),e<0&&Wt.logWithError(`${e} is negative.`),an.DP=e,an.RM=Fr[n]||1,new an(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var Dr=Be("Raydium_amount"),jn=yt(Wr);function _r(i,e){let t="0",n="0";if(i.includes(".")){let r=i.split(".");r.length===2?([t,n]=r,n=n.padEnd(e,"0")):Dr.logWithError(`invalid number string, num: ${i}`)}else t=i;return[t,n.slice(0,e)||n]}var Te=class extends X{constructor(t,n,r=!0,o){let s=new _t(0),a=un.pow(new _t(t.decimals));if(r)s=ge(n);else{let u=new _t(0),c=new _t(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=_r(n.toString(),t.decimals);u=ge(l),c=ge(m)}u=u.mul(a),s=u.add(c)}super(s,a);this.logger=Be(o||"TokenAmount"),this.token=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.token.equals(t.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(t.raw)}lt(t){return this.token.equals(t.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(t.raw)}add(t){return this.token.equals(t.token)||this.logger.logWithError("add token not equals"),new Te(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new Te(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,n,r=0){return super.toSignificant(t,n,r)}toFixed(t=this.token.decimals,n,r=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,r)}toExact(t={groupSeparator:""}){return jn.DP=this.token.decimals,new jn(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};import{PublicKey as qr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Qn}from"@solana/spl-token";var Yn={chainId:101,address:qr.default.toBase58(),programId:Qn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},rt={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Qn.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 dn}from"@solana/web3.js";import{PublicKey as ne,SystemProgram as Jn,SYSVAR_RENT_PUBKEY as Vr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Gr}from"@solana/spl-token";function cn({pubkey:i,isSigner:e=!1,isWritable:t=!0}){return{pubkey:i,isWritable:t,isSigner:e}}var ys=[cn({pubkey:Gr,isWritable:!1}),cn({pubkey:Jn.programId,isWritable:!1}),cn({pubkey:Vr,isWritable:!1})];function ln({publicKey:i,transformSol:e}){let t=$n(i.toString());if(t instanceof ne)return e&&t.equals(kt)?$t:t;if(e&&t.toString()===kt.toBase58())return $t;if(typeof t=="string"){if(t===ne.default.toBase58())return ne.default;try{return new ne(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function $n(i){try{return new ne(i)}catch{return i}}var qt=new ne("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),mn=new ne("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),et=new ne("SysvarRent111111111111111111111111111111111"),hs=new ne("SysvarC1ock11111111111111111111111111111111"),ot=new ne("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),ws=new ne("Sysvar1nstructions1111111111111111111111111"),ks=Jn.programId,Ps=new ne("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),As=new ne("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Ts=new ne("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),xs=new ne("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Bs=new ne("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ss=new ne("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Is=new ne("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ns=new ne("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Ks=new ne("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Cs=new ne("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Ls=new ne("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),$t=new ne("So11111111111111111111111111111111111111112"),kt=ne.default;function Ct(i){return ln({publicKey:i,transformSol:!0})}var fn=class{constructor({mint:e,decimals:t,symbol:n,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===kt.toBase58()||e instanceof dn&&kt.equals(e)){this.decimals=rt.decimals,this.symbol=rt.symbol,this.name=rt.name,this.mint=new dn(rt.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=n||e.toString().substring(0,6),this.name=r||e.toString().substring(0,6),this.mint=o?dn.default:ln({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Ue=fn;Ue.WSOL=new fn(se($({},rt),{mint:rt.address}));var pn=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},Vt=pn;Vt.SOL=new pn(Yn);import Ur from"bn.js";var ei=new X(new Ur(100)),tt=class extends X{toSignificant(e=5,t,n){return this.mul(ei).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(ei).toFixed(e,t,n)}};var Xr=Be("Raydium_price"),We=class extends X{constructor(t){let{baseToken:n,quoteToken:r,numerator:o,denominator:s}=t;super(o,s);this.baseToken=n,this.quoteToken=r,this.scalar=new X(bn(n.decimals),bn(r.decimals))}get raw(){return new X(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new We({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&Xr.logWithError("mul token not equals");let n=super.mul(t);return new We({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(t=this.quoteToken.decimals,n,r){return this.adjusted.toSignificant(t,n,r)}toFixed(t=this.quoteToken.decimals,n,r){return this.adjusted.toFixed(t,n,r)}};import{PublicKey as ca}from"@solana/web3.js";import ma from"bn.js";var Hr=new Xe(0),Ka=new Xe(1),Ca=new Xe(2),La=new Xe(3),Ra=new Xe(5),un=new Xe(10),Ma=new Xe(100),Ea=new Xe(1e3),va=new Xe(1e4);function bn(i){return un.pow(ge(i))}function Yt(i,e=1,t=[]){let n=[...i];if(e<=0)return t;for(;n.length;)t.push(n.splice(0,e));return t}import{PublicKey as Zr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as jr}from"@solana/spl-token";import{ComputeBudgetProgram as Ga,Keypair as Ha,PublicKey as zr,Transaction as Za,TransactionMessage as Qa,VersionedTransaction as Ya}from"@solana/web3.js";var ye={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 tu}from"@solana/spl-token";var nu=Be("Raydium_txUtil");function Se(i,e){let[t,n]=zr.findProgramAddressSync(i,e);return{publicKey:t,nonce:n}}function me(i,e,t){return Se([i.toBuffer(),(t!=null?t:jr).toBuffer(),e.toBuffer()],new Zr("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))}import{PublicKey as C}from"@solana/web3.js";var cu=new C("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),lu=new C("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),mu=new C("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),du=new C("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),fu=new C("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),pu=new C("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),bu=new C("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),gu=new C("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),yu=new C("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),hu=new C("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),wu=new C("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),ku=new C("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Pu=new C("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),Au=new C("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Tu=new C("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),xu=new C("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),Bu=new C("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Su=new C("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Iu=new C("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Nu=new C("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),Ku=new C("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Cu=new C("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),Lu=new C("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),Ru=new C("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Mu=new C("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),Eu=new C("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),vu=new C("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),Ou=new C("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),Fu=new C("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var Wu={OPEN_BOOK_PROGRAM:new C("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new C("Ray1111111111111111111111111111111111111111"),AMM_V4:new C("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new C("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new C("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new C("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new C("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new C("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new C("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new C("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new C("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new C("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:C.default,Router:new C("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new C("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new C("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new C("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new C("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new C("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new C("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new C("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new C("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new C("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new C("Ray1111111111111111111111111111111111111111")};import De from"bn.js";var Pt=1e4;function le(i,e,t,n){if(e===void 0)return{amount:i,fee:void 0,expirationTime:void 0};let r=se($({},e),{olderTransferFee:{epoch:BigInt(e.olderTransferFee.epoch),maximumFee:BigInt(e.olderTransferFee.maximumFee),transferFeeBasisPoints:e.olderTransferFee.transferFeeBasisPoints},newerTransferFee:{epoch:BigInt(e.newerTransferFee.epoch),maximumFee:BigInt(e.newerTransferFee.maximumFee),transferFeeBasisPoints:e.newerTransferFee.transferFeeBasisPoints}}),o=t.epoch<r.newerTransferFee.epoch?r.olderTransferFee:r.newerTransferFee,s=new De(o.maximumFee.toString()),a=