@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 56.1 kB
JavaScript
var Yt=Object.defineProperty,Xt=Object.defineProperties;var Qt=Object.getOwnPropertyDescriptors;var mt=Object.getOwnPropertySymbols;var zt=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var pt=(e,t,n)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ue=(e,t)=>{for(var n in t||(t={}))zt.call(t,n)&&pt(e,n,t[n]);if(mt)for(var n of mt(t))$t.call(t,n)&&pt(e,n,t[n]);return e},fe=(e,t)=>Xt(e,Qt(t));import{TOKEN_PROGRAM_ID as he,ASSOCIATED_TOKEN_PROGRAM_ID as xr}from"@solana/spl-token";import{PublicKey as N,TransactionInstruction as ee,SystemProgram as Gt,SYSVAR_RENT_PUBKEY as kr}from"@solana/web3.js";import V from"bn.js";var de=9e15,ie=1e9,Ue="0123456789abcdef",Ae="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ie="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ve={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-de,maxE:de,crypto:!1},bt,Q,P=!0,We="[DecimalError] ",re=We+"Invalid argument: ",ht=We+"Precision limit exceeded",yt=We+"crypto unavailable",wt="[object Decimal]",M=Math.floor,D=Math.pow,Jt=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,en=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,tn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Pt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,G=1e7,y=7,nn=9007199254740991,rn=Ae.length-1,Ke=Ie.length-1,d={toStringTag:wt};d.absoluteValue=d.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),h(e)};d.ceil=function(){return h(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(re+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,u=(e=new i.constructor(e)).d,c=i.s,a=e.s;if(!s||!u)return!c||!a?NaN:c!==a?c:s===u?0:!s^c<0?1:-1;if(!s[0]||!u[0])return s[0]?c:u[0]?-a:0;if(c!==a)return c;if(i.e!==e.e)return i.e>e.e^c<0?1:-1;for(r=s.length,o=u.length,t=0,n=r<o?r:o;t<n;++t)if(s[t]!==u[t])return s[t]>u[t]^c<0?1:-1;return r===o?0:r>o^c<0?1:-1};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())+y,r.rounding=1,n=on(r,Lt(r,n)),r.precision=e,r.rounding=t,h(Q==2||Q==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,u,c,a,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(P=!1,i=l.s*D(l.s*l,1/3),!i||Math.abs(i)==1/0?(n=R(l.d),e=l.e,(i=(e-n.length+1)%3)&&(n+=i==1||i==-2?"0":"00"),i=D(n,1/3),e=M((e+1)/3)-(e%3==(e<0?-1:2)),i==1/0?n="5e"+e:(n=i.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),r=new m(n),r.s=l.s):r=new m(i.toString()),s=(e=m.precision)+3;;)if(u=r,c=u.times(u).times(u),a=c.plus(l),r=L(a.plus(l).times(u),a.plus(c),s+2,1),R(u.d).slice(0,s)===(n=R(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!o&&n=="4999"){if(!o&&(h(u,e+1,0),u.times(u).times(u).eq(l))){r=u;break}s+=4,o=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(h(r,e+1,1),t=!r.times(r).times(r).eq(l));break}return P=!0,h(r,e,m.rounding,t)};d.decimalPlaces=d.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-M(this.e/y))*y,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n};d.dividedBy=d.div=function(e){return L(this,new this.constructor(e))};d.dividedToIntegerBy=d.divToInt=function(e){var t=this,n=t.constructor;return h(L(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 h(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,u=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return u;n=s.precision,r=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,o=i.d.length,o<32?(e=Math.ceil(o/3),t=(1/De(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),i=ge(s,1,i.times(t),new s(1),!0);for(var c,a=e,l=new s(8);a--;)c=i.times(i),i=u.minus(c.times(l.minus(c.times(l))));return h(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=ge(i,2,o,o,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,o=o.times(1/De(5,e)),o=ge(i,2,o,o,!0);for(var s,u=new i(5),c=new i(16),a=new i(20);e--;)s=o.times(o),o=o.times(u.plus(s.times(c.times(s).plus(a))))}return i.precision=t,i.rounding=n,h(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,L(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)};d.inverseCosine=d.acos=function(){var e,t=this,n=t.constructor,r=t.abs().cmp(1),o=n.precision,i=n.rounding;return r!==-1?r===0?t.isNeg()?H(n,o,i):new n(0):new n(NaN):t.isZero()?H(n,o+4,i).times(.5):(n.precision=o+6,n.rounding=1,t=t.asin(),e=H(n,o+4,i).times(.5),n.precision=o,n.rounding=i,e.minus(t))};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,P=!1,n=n.times(n).minus(1).sqrt().plus(n),P=!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,P=!1,n=n.times(n).plus(1).sqrt().plus(n),P=!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?h(new i(o),e,t,!0):(i.precision=n=r-o.e,o=L(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=H(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,u,c,a=this,l=a.constructor,m=l.precision,f=l.rounding;if(a.isFinite()){if(a.isZero())return new l(a);if(a.abs().eq(1)&&m+4<=Ke)return s=H(l,m+4,f).times(.25),s.s=a.s,s}else{if(!a.s)return new l(NaN);if(m+4<=Ke)return s=H(l,m+4,f).times(.5),s.s=a.s,s}for(l.precision=u=m+10,l.rounding=1,n=Math.min(28,u/y+2|0),e=n;e;--e)a=a.div(a.times(a).plus(1).sqrt().plus(1));for(P=!1,t=Math.ceil(u/y),r=1,c=a.times(a),s=new l(a),o=a;e!==-1;)if(o=o.times(c),i=s.minus(o.div(r+=2)),o=o.times(c),s=i.plus(o.div(r+=2)),s.d[t]!==void 0)for(e=t;s.d[e]===i.d[e]&&e--;);return n&&(s=s.times(2<<n-1)),P=!0,h(s,l.precision=m,l.rounding=f,!0)};d.isFinite=function(){return!!this.d};d.isInteger=d.isInt=function(){return!!this.d&&M(this.e/y)>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,u,c,a=this,l=a.constructor,m=l.precision,f=l.rounding,b=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(n=a.d,a.s<0||!n||!n[0]||a.eq(1))return new l(n&&!n[0]?-1/0:a.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(o=n[0];o%10===0;)o/=10;i=o!==1}if(P=!1,u=m+b,s=ne(a,u),r=t?Ee(l,u+10):ne(e,u),c=L(s,r,u,1),we(c.d,o=m,f))do if(u+=10,s=ne(a,u),r=t?Ee(l,u+10):ne(e,u),c=L(s,r,u,1),!i){+R(c.d).slice(o+1,o+15)+1==1e14&&(c=h(c,m+1,0));break}while(we(c.d,o+=10,f));return P=!0,h(c,m,f)};d.minus=d.sub=function(e){var t,n,r,o,i,s,u,c,a,l,m,f,b=this,x=b.constructor;if(e=new x(e),!b.d||!e.d)return!b.s||!e.s?e=new x(NaN):b.d?e.s=-e.s:e=new x(e.d||b.s!==e.s?b:NaN),e;if(b.s!=e.s)return e.s=-e.s,b.plus(e);if(a=b.d,f=e.d,u=x.precision,c=x.rounding,!a[0]||!f[0]){if(f[0])e.s=-e.s;else if(a[0])e=new x(b);else return new x(c===3?-0:0);return P?h(e,u,c):e}if(n=M(e.e/y),l=M(b.e/y),a=a.slice(),i=l-n,i){for(m=i<0,m?(t=a,i=-i,s=f.length):(t=f,n=l,s=a.length),r=Math.max(Math.ceil(u/y),s)+2,i>r&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for(r=a.length,s=f.length,m=r<s,m&&(s=r),r=0;r<s;r++)if(a[r]!=f[r]){m=a[r]<f[r];break}i=0}for(m&&(t=a,a=f,f=t,e.s=-e.s),s=a.length,r=f.length-s;r>0;--r)a[s++]=0;for(r=f.length;r>i;){if(a[--r]<f[r]){for(o=r;o&&a[--o]===0;)a[o]=G-1;--a[o],a[r]+=G}a[r]-=f[r]}for(;a[--s]===0;)a.pop();for(;a[0]===0;a.shift())--n;return a[0]?(e.d=a,e.e=ve(a,n),P?h(e,u,c):e):new x(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]?h(new r(n),r.precision,r.rounding):(P=!1,r.modulo==9?(t=L(n,e.abs(),0,3,1),t.s*=e.s):t=L(n,e,0,r.modulo,1),t=t.times(e),P=!0,n.minus(t))};d.naturalExponential=d.exp=function(){return Ze(this)};d.naturalLogarithm=d.ln=function(){return ne(this)};d.negated=d.neg=function(){var e=new this.constructor(this);return e.s=-e.s,h(e)};d.plus=d.add=function(e){var t,n,r,o,i,s,u,c,a,l,m=this,f=m.constructor;if(e=new f(e),!m.d||!e.d)return!m.s||!e.s?e=new f(NaN):m.d||(e=new f(e.d||m.s===e.s?m:NaN)),e;if(m.s!=e.s)return e.s=-e.s,m.minus(e);if(a=m.d,l=e.d,u=f.precision,c=f.rounding,!a[0]||!l[0])return l[0]||(e=new f(m)),P?h(e,u,c):e;if(i=M(m.e/y),r=M(e.e/y),a=a.slice(),o=i-r,o){for(o<0?(n=a,o=-o,s=l.length):(n=l,r=i,s=a.length),i=Math.ceil(u/y),s=i>s?i+1:s+1,o>s&&(o=s,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(s=a.length,o=l.length,s-o<0&&(o=s,n=l,l=a,a=n),t=0;o;)t=(a[--o]=a[o]+l[o]+t)/G|0,a[o]%=G;for(t&&(a.unshift(t),++r),s=a.length;a[--s]==0;)a.pop();return e.d=a,e.e=ve(a,r),P?h(e,u,c):e};d.precision=d.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(re+e);return n.d?(t=xt(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t};d.round=function(){var e=this,t=e.constructor;return h(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())+y,r.rounding=1,n=un(r,Lt(r,n)),r.precision=e,r.rounding=t,h(Q>2?n.neg():n,e,t,!0)):new r(NaN)};d.squareRoot=d.sqrt=function(){var e,t,n,r,o,i,s=this,u=s.d,c=s.e,a=s.s,l=s.constructor;if(a!==1||!u||!u[0])return new l(!a||a<0&&(!u||u[0])?NaN:u?s:1/0);for(P=!1,a=Math.sqrt(+s),a==0||a==1/0?(t=R(u),(t.length+c)%2==0&&(t+="0"),a=Math.sqrt(t),c=M((c+1)/2)-(c<0||c%2),a==1/0?t="5e"+c:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),r=new l(t)):r=new l(a.toString()),n=(c=l.precision)+3;;)if(i=r,r=i.plus(L(s,i,n+2,1)).times(.5),R(i.d).slice(0,n)===(t=R(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!o&&t=="4999"){if(!o&&(h(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")&&(h(r,c+1,1),e=!r.times(r).eq(s));break}return P=!0,h(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=L(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,h(Q==2||Q==4?n.neg():n,e,t,!0)):new r(NaN)};d.times=d.mul=function(e){var t,n,r,o,i,s,u,c,a,l=this,m=l.constructor,f=l.d,b=(e=new m(e)).d;if(e.s*=l.s,!f||!f[0]||!b||!b[0])return new m(!e.s||f&&!f[0]&&!b||b&&!b[0]&&!f?NaN:!f||!b?e.s/0:e.s*0);for(n=M(l.e/y)+M(e.e/y),c=f.length,a=b.length,c<a&&(i=f,f=b,b=i,s=c,c=a,a=s),i=[],s=c+a,r=s;r--;)i.push(0);for(r=a;--r>=0;){for(t=0,o=c+r;o>r;)u=i[o]+b[r]*f[o-r-1]+t,i[o--]=u%G|0,t=u/G|0;i[o]=(i[o]+t)%G|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=ve(i,n),P?h(e,m.precision,m.rounding):e};d.toBinary=function(e,t){return He(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:(U(e,0,ie),t===void 0?t=r.rounding:U(t,0,8),h(n,e+n.e+1,t))};d.toExponential=function(e,t){var n,r=this,o=r.constructor;return e===void 0?n=X(r,!0):(U(e,0,ie),t===void 0?t=o.rounding:U(t,0,8),r=h(new o(r),e+1,t),n=X(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=X(o):(U(e,0,ie),t===void 0?t=i.rounding:U(t,0,8),r=h(new i(o),e+o.e+1,t),n=X(r,!1,e+r.e+1)),o.isNeg()&&!o.isZero()?"-"+n:n};d.toFraction=function(e){var t,n,r,o,i,s,u,c,a,l,m,f,b=this,x=b.d,w=b.constructor;if(!x)return new w(b);if(a=n=new w(1),r=c=new w(0),t=new w(r),i=t.e=xt(x)-b.e-1,s=i%y,t.d[0]=D(10,s<0?y+s:s),e==null)e=i>0?t:a;else{if(u=new w(e),!u.isInt()||u.lt(a))throw Error(re+u);e=u.gt(t)?i>0?t:a:u}for(P=!1,u=new w(R(x)),l=w.precision,w.precision=i=x.length*y*2;m=L(u,t,0,1,1),o=n.plus(m.times(r)),o.cmp(e)!=1;)n=r,r=o,o=a,a=c.plus(m.times(o)),c=o,o=t,t=u.minus(m.times(o)),u=o;return o=L(e.minus(n),r,0,1,1),c=c.plus(o.times(a)),n=n.plus(o.times(r)),c.s=a.s=b.s,f=L(a,r,i,1).minus(b).abs().cmp(L(c,n,i,1).minus(b).abs())<1?[a,r]:[c,n],w.precision=l,P=!0,f};d.toHexadecimal=d.toHex=function(e,t){return He(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:U(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]?(P=!1,n=L(n,e,0,t,1).times(e),P=!0,h(n)):(e.s=n.s,n=e),n};d.toNumber=function(){return+this};d.toOctal=function(e,t){return He(this,8,e,t)};d.toPower=d.pow=function(e){var t,n,r,o,i,s,u=this,c=u.constructor,a=+(e=new c(e));if(!u.d||!e.d||!u.d[0]||!e.d[0])return new c(D(+u,a));if(u=new c(u),u.eq(1))return u;if(r=c.precision,i=c.rounding,e.eq(1))return h(u,r,i);if(t=M(e.e/y),t>=e.d.length-1&&(n=a<0?-a:a)<=nn)return o=kt(c,u,n,r),e.s<0?new c(1).div(o):h(o,r,i);if(s=u.s,s<0){if(t<e.d.length-1)return new c(NaN);if((e.d[t]&1)==0&&(s=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=s,u}return n=D(+u,a),t=n==0||!isFinite(n)?M(a*(Math.log("0."+R(u.d))/Math.LN10+u.e+1)):new c(n+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(P=!1,c.rounding=u.s=1,n=Math.min(12,(t+"").length),o=Ze(e.times(ne(u,r+n)),r),o.d&&(o=h(o,r+5,1),we(o.d,r,i)&&(t=r+10,o=h(Ze(e.times(ne(u,t+n)),t),t+5,1),+R(o.d).slice(r+1,r+15)+1==1e14&&(o=h(o,r+1,0)))),o.s=s,P=!0,c.rounding=i,h(o,r,i))};d.toPrecision=function(e,t){var n,r=this,o=r.constructor;return e===void 0?n=X(r,r.e<=o.toExpNeg||r.e>=o.toExpPos):(U(e,1,ie),t===void 0?t=o.rounding:U(t,0,8),r=h(new o(r),e,t),n=X(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):(U(e,1,ie),t===void 0?t=r.rounding:U(t,0,8)),h(new r(n),e,t)};d.toString=function(){var e=this,t=e.constructor,n=X(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n};d.truncated=d.trunc=function(){return h(new this.constructor(this),this.e+1,1)};d.valueOf=d.toJSON=function(){var e=this,t=e.constructor,n=X(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function R(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=y-r.length,n&&(i+=te(n)),i+=r;s=e[t],r=s+"",n=y-r.length,n&&(i+=te(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return i+s}function U(e,t,n){if(e!==~~e||e<t||e>n)throw Error(re+e)}function we(e,t,n,r){var o,i,s,u;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=y,o=0):(o=Math.ceil((t+1)/y),t%=y),i=D(10,y-t),u=e[o]%i|0,r==null?t<3?(t==0?u=u/100|0:t==1&&(u=u/10|0),s=n<4&&u==99999||n>3&&u==49999||u==5e4||u==0):s=(n<4&&u+1==i||n>3&&u+1==i/2)&&(e[o+1]/i/100|0)==D(10,t-2)-1||(u==i/2||u==0)&&(e[o+1]/i/100|0)==0:t<4?(t==0?u=u/1e3|0:t==1?u=u/100|0:t==2&&(u=u/10|0),s=(r||n<4)&&u==9999||!r&&n>3&&u==4999):s=((r||n<4)&&u+1==i||!r&&n>3&&u+1==i/2)&&(e[o+1]/i/1e3|0)==D(10,t-3)-1,s}function Be(e,t,n){for(var r,o=[0],i,s=0,u=e.length;s<u;){for(i=o.length;i--;)o[i]*=t;for(o[0]+=Ue.indexOf(e.charAt(s++)),r=0;r<o.length;r++)o[r]>n-1&&(o[r+1]===void 0&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function on(e,t){var n,r,o;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),o=(1/De(4,n)).toString()):(n=16,o="2.3283064365386962890625e-10"),e.precision+=n,t=ge(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 L=function(){function e(r,o,i){var s,u=0,c=r.length;for(r=r.slice();c--;)s=r[c]*o+u,r[c]=s%i|0,u=s/i|0;return u&&r.unshift(u),r}function t(r,o,i,s){var u,c;if(i!=s)c=i>s?1:-1;else for(u=c=0;u<i;u++)if(r[u]!=o[u]){c=r[u]>o[u]?1:-1;break}return c}function n(r,o,i,s){for(var u=0;i--;)r[i]-=u,u=r[i]<o[i]?1:0,r[i]=u*s+r[i]-o[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,o,i,s,u,c){var a,l,m,f,b,x,w,O,B,K,S,C,me,Z,ye,oe,se,pe,j,Le,Te=r.constructor,Fe=r.s==o.s?1:-1,q=r.d,T=o.d;if(!q||!q[0]||!T||!T[0])return new Te(!r.s||!o.s||(q?T&&q[0]==T[0]:!T)?NaN:q&&q[0]==0||!T?Fe*0:Fe/0);for(c?(b=1,l=r.e-o.e):(c=G,b=y,l=M(r.e/b)-M(o.e/b)),j=T.length,se=q.length,B=new Te(Fe),K=B.d=[],m=0;T[m]==(q[m]||0);m++);if(T[m]>(q[m]||0)&&l--,i==null?(Z=i=Te.precision,s=Te.rounding):u?Z=i+(r.e-o.e)+1:Z=i,Z<0)K.push(1),x=!0;else{if(Z=Z/b+2|0,m=0,j==1){for(f=0,T=T[0],Z++;(m<se||f)&&Z--;m++)ye=f*c+(q[m]||0),K[m]=ye/T|0,f=ye%T|0;x=f||m<se}else{for(f=c/(T[0]+1)|0,f>1&&(T=e(T,f,c),q=e(q,f,c),j=T.length,se=q.length),oe=j,S=q.slice(0,j),C=S.length;C<j;)S[C++]=0;Le=T.slice(),Le.unshift(0),pe=T[0],T[1]>=c/2&&++pe;do f=0,a=t(T,S,j,C),a<0?(me=S[0],j!=C&&(me=me*c+(S[1]||0)),f=me/pe|0,f>1?(f>=c&&(f=c-1),w=e(T,f,c),O=w.length,C=S.length,a=t(w,S,O,C),a==1&&(f--,n(w,j<O?Le:T,O,c))):(f==0&&(a=f=1),w=T.slice()),O=w.length,O<C&&w.unshift(0),n(S,w,C,c),a==-1&&(C=S.length,a=t(T,S,j,C),a<1&&(f++,n(S,j<C?Le:T,C,c))),C=S.length):a===0&&(f++,S=[0]),K[m++]=f,a&&S[0]?S[C++]=q[oe]||0:(S=[q[oe]],C=1);while((oe++<se||S[0]!==void 0)&&Z--);x=S[0]!==void 0}K[0]||K.shift()}if(b==1)B.e=l,bt=x;else{for(m=1,f=K[0];f>=10;f/=10)m++;B.e=m+l*b-1,h(B,u?i+B.e+1:i,s,x)}return B}}();function h(e,t,n,r){var o,i,s,u,c,a,l,m,f,b=e.constructor;e:if(t!=null){if(m=e.d,!m)return e;for(o=1,u=m[0];u>=10;u/=10)o++;if(i=t-o,i<0)i+=y,s=t,l=m[f=0],c=l/D(10,o-s-1)%10|0;else if(f=Math.ceil((i+1)/y),u=m.length,f>=u)if(r){for(;u++<=f;)m.push(0);l=c=0,o=1,i%=y,s=i-y+1}else break e;else{for(l=u=m[f],o=1;u>=10;u/=10)o++;i%=y,s=i-y+o,c=s<0?0:l/D(10,o-s-1)%10|0}if(r=r||t<0||m[f+1]!==void 0||(s<0?l:l%D(10,o-s-1)),a=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(i>0?s>0?l/D(10,o-s):0:m[f-1])%10&1||n==(e.s<0?8:7)),t<1||!m[0])return m.length=0,a?(t-=e.e+1,m[0]=D(10,(y-t%y)%y),e.e=-t||0):m[0]=e.e=0,e;if(i==0?(m.length=f,u=1,f--):(m.length=f+1,u=D(10,y-i),m[f]=s>0?(l/D(10,o-s)%D(10,s)|0)*u:0),a)for(;;)if(f==0){for(i=1,s=m[0];s>=10;s/=10)i++;for(s=m[0]+=u,u=1;s>=10;s/=10)u++;i!=u&&(e.e++,m[0]==G&&(m[0]=1));break}else{if(m[f]+=u,m[f]!=G)break;m[f--]=0,u=1}for(i=m.length;m[--i]===0;)m.pop()}return P&&(e.e>b.maxE?(e.d=null,e.e=NaN):e.e<b.minE&&(e.e=0,e.d=[0])),e}function X(e,t,n){if(!e.isFinite())return Nt(e);var r,o=e.e,i=R(e.d),s=i.length;return t?(n&&(r=n-s)>0?i=i.charAt(0)+"."+i.slice(1)+te(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):o<0?(i="0."+te(-o-1)+i,n&&(r=n-s)>0&&(i+=te(r))):o>=s?(i+=te(o+1-s),n&&(r=n-o-1)>0&&(i=i+"."+te(r))):((r=o+1)<s&&(i=i.slice(0,r)+"."+i.slice(r)),n&&(r=n-s)>0&&(o+1===s&&(i+="."),i+=te(r))),i}function ve(e,t){var n=e[0];for(t*=y;n>=10;n/=10)t++;return t}function Ee(e,t,n){if(t>rn)throw P=!0,n&&(e.precision=n),Error(ht);return h(new e(Ae),t,1,!0)}function H(e,t,n){if(t>Ke)throw Error(ht);return h(new e(Ie),t,n,!0)}function xt(e){var t=e.length-1,n=t*y+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 te(e){for(var t="";e--;)t+="0";return t}function kt(e,t,n,r){var o,i=new e(1),s=Math.ceil(r/y+4);for(P=!1;;){if(n%2&&(i=i.times(t),dt(i.d,s)&&(o=!0)),n=M(n/2),n===0){n=i.d.length-1,o&&i.d[n]===0&&++i.d[n];break}t=t.times(t),dt(t.d,s)}return P=!0,i}function ft(e){return e.d[e.d.length-1]&1}function St(e,t,n){for(var r,o=new e(t[0]),i=0;++i<t.length;)if(r=new e(t[i]),r.s)o[n](r)&&(o=r);else{o=r;break}return o}function Ze(e,t){var n,r,o,i,s,u,c,a=0,l=0,m=0,f=e.constructor,b=f.rounding,x=f.precision;if(!e.d||!e.d[0]||e.e>17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(P=!1,c=x):c=t,u=new f(.03125);e.e>-2;)e=e.times(u),m+=5;for(r=Math.log(D(2,m))/Math.LN10*2+5|0,c+=r,n=i=s=new f(1),f.precision=c;;){if(i=h(i.times(e),c,1),n=n.times(++l),u=s.plus(L(i,n,c,1)),R(u.d).slice(0,c)===R(s.d).slice(0,c)){for(o=m;o--;)s=h(s.times(s),c,1);if(t==null)if(a<3&&we(s.d,c-r,b,a))f.precision=c+=10,n=i=u=new f(1),l=0,a++;else return h(s,f.precision=x,b,P=!0);else return f.precision=x,s}s=u}}function ne(e,t){var n,r,o,i,s,u,c,a,l,m,f,b=1,x=10,w=e,O=w.d,B=w.constructor,K=B.rounding,S=B.precision;if(w.s<0||!O||!O[0]||!w.e&&O[0]==1&&O.length==1)return new B(O&&!O[0]?-1/0:w.s!=1?NaN:O?0:w);if(t==null?(P=!1,l=S):l=t,B.precision=l+=x,n=R(O),r=n.charAt(0),Math.abs(i=w.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)w=w.times(e),n=R(w.d),r=n.charAt(0),b++;i=w.e,r>1?(w=new B("0."+n),i++):w=new B(r+"."+n.slice(1))}else return a=Ee(B,l+2,S).times(i+""),w=ne(new B(r+"."+n.slice(1)),l-x).plus(a),B.precision=S,t==null?h(w,S,K,P=!0):w;for(m=w,c=s=w=L(w.minus(1),w.plus(1),l,1),f=h(w.times(w),l,1),o=3;;){if(s=h(s.times(f),l,1),a=c.plus(L(s,new B(o),l,1)),R(a.d).slice(0,l)===R(c.d).slice(0,l))if(c=c.times(2),i!==0&&(c=c.plus(Ee(B,l+2,S).times(i+""))),c=L(c,new B(b),l,1),t==null)if(we(c.d,l-x,K,u))B.precision=l+=x,a=s=w=L(m.minus(1),m.plus(1),l,1),f=h(w.times(w),l,1),o=u=1;else return h(c,B.precision=S,K,P=!0);else return B.precision=S,c;c=a,o+=2}}function Nt(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)%y,n<0&&(r+=y),r<o){for(r&&e.d.push(+t.slice(0,r)),o-=y;r<o;)e.d.push(+t.slice(r,r+=y));t=t.slice(r),r=y-t.length}else r-=o;for(;r--;)t+="0";e.d.push(+t),P&&(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 sn(e,t){var n,r,o,i,s,u,c,a,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Pt.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(en.test(t))n=16,t=t.toLowerCase();else if(Jt.test(t))n=2;else if(tn.test(t))n=8;else throw Error(re+t);for(i=t.search(/p/i),i>0?(c=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),s=i>=0,r=e.constructor,s&&(t=t.replace(".",""),u=t.length,i=u-i,o=kt(r,new r(n),i,i*2)),a=Be(t,n,G),l=a.length-1,i=l;a[i]===0;--i)a.pop();return i<0?new r(e.s*0):(e.e=ve(a,l),e.d=a,P=!1,s&&(e=L(e,o,u*4)),c&&(e=e.times(Math.abs(c)<54?D(2,c):Ce.pow(2,c))),P=!0,e)}function un(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:ge(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/De(5,n)),t=ge(e,2,t,t);for(var o,i=new e(5),s=new e(16),u=new e(20);n--;)o=t.times(t),t=t.times(i.plus(o.times(s.times(o).minus(u))));return t}function ge(e,t,n,r,o){var i,s,u,c,a=1,l=e.precision,m=Math.ceil(l/y);for(P=!1,c=n.times(n),u=new e(r);;){if(s=L(u.times(c),new e(t++*t++),l,1),u=o?r.plus(s):r.minus(s),r=L(s.times(c),new e(t++*t++),l,1),s=u.plus(r),s.d[m]!==void 0){for(i=m;s.d[i]===u.d[i]&&i--;);if(i==-1)break}i=u,u=r,r=s,s=i,a++}return P=!0,s.d.length=m+1,s}function De(e,t){for(var n=e;--t;)n*=e;return n}function Lt(e,t){var n,r=t.s<0,o=H(e,e.precision,1),i=o.times(.5);if(t=t.abs(),t.lte(i))return Q=r?4:1,t;if(n=t.divToInt(o),n.isZero())Q=r?3:2;else{if(t=t.minus(n.times(o)),t.lte(i))return Q=ft(n)?r?2:3:r?4:1,t;Q=ft(n)?r?1:4:r?3:2}return t.minus(o).abs()}function He(e,t,n,r){var o,i,s,u,c,a,l,m,f,b=e.constructor,x=n!==void 0;if(x?(U(n,1,ie),r===void 0?r=b.rounding:U(r,0,8)):(n=b.precision,r=b.rounding),!e.isFinite())l=Nt(e);else{for(l=X(e),s=l.indexOf("."),x?(o=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):o=t,s>=0&&(l=l.replace(".",""),f=new b(1),f.e=l.length-s,f.d=Be(X(f),10,o),f.e=f.d.length),m=Be(l,10,o),i=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=x?"0p+0":"0";else{if(s<0?i--:(e=new b(e),e.d=m,e.e=i,e=L(e,f,n,r,0,o),m=e.d,i=e.e,a=bt),s=m[n],u=o/2,a=a||m[n+1]!==void 0,a=r<4?(s!==void 0||a)&&(r===0||r===(e.s<0?3:2)):s>u||s===u&&(r===4||a||r===6&&m[n-1]&1||r===(e.s<0?8:7)),m.length=n,a)for(;++m[--n]>o-1;)m[n]=0,n||(++i,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=Ue.charAt(m[s]);if(x){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(m=Be(l,o,t),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Ue.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)l="0"+l;l="0."+l}else if(++i>c)for(i-=c;i--;)l+="0";else i<c&&(l=l.slice(0,i)+"."+l.slice(i))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function dt(e,t){if(e.length>t)return e.length=t,!0}function an(e){return new this(e).abs()}function cn(e){return new this(e).acos()}function ln(e){return new this(e).acosh()}function mn(e,t){return new this(e).plus(t)}function pn(e){return new this(e).asin()}function fn(e){return new this(e).asinh()}function dn(e){return new this(e).atan()}function gn(e){return new this(e).atanh()}function bn(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=H(this,i,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?H(this,r,o):new this(0),n.s=e.s):!e.d||t.isZero()?(n=H(this,i,1).times(.5),n.s=e.s):t.s<0?(this.precision=i,this.rounding=1,n=this.atan(L(e,t,i,1)),t=H(this,i,1),this.precision=r,this.rounding=o,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(L(e,t,i,1)),n}function hn(e){return new this(e).cbrt()}function yn(e){return h(e=new this(e),e.e+1,2)}function wn(e,t,n){return new this(e).clamp(t,n)}function Pn(e){if(!e||typeof e!="object")throw Error(We+"Object expected");var t,n,r,o=e.defaults===!0,i=["precision",1,ie,"rounding",0,8,"toExpNeg",-de,0,"toExpPos",0,de,"maxE",0,de,"minE",-de,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(n=i[t],o&&(this[n]=Ve[n]),(r=e[n])!==void 0)if(M(r)===r&&r>=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(re+n+": "+r);if(n="crypto",o&&(this[n]=Ve[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(yt);else this[n]=!1;else throw Error(re+n+": "+r);return this}function xn(e){return new this(e).cos()}function kn(e){return new this(e).cosh()}function Tt(e){var t,n,r;function o(i){var s,u,c,a=this;if(!(a instanceof o))return new o(i);if(a.constructor=o,gt(i)){a.s=i.s,P?!i.d||i.e>o.maxE?(a.e=NaN,a.d=null):i.e<o.minE?(a.e=0,a.d=[0]):(a.e=i.e,a.d=i.d.slice()):(a.e=i.e,a.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){a.s=1/i<0?-1:1,a.e=0,a.d=[0];return}if(i<0?(i=-i,a.s=-1):a.s=1,i===~~i&&i<1e7){for(s=0,u=i;u>=10;u/=10)s++;P?s>o.maxE?(a.e=NaN,a.d=null):s<o.minE?(a.e=0,a.d=[0]):(a.e=s,a.d=[i]):(a.e=s,a.d=[i]);return}else if(i*0!==0){i||(a.s=NaN),a.e=NaN,a.d=null;return}return je(a,i.toString())}else if(c!=="string")throw Error(re+i);return(u=i.charCodeAt(0))===45?(i=i.slice(1),a.s=-1):(u===43&&(i=i.slice(1)),a.s=1),Pt.test(i)?je(a,i):sn(a,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=Pn,o.clone=Tt,o.isDecimal=gt,o.abs=an,o.acos=cn,o.acosh=ln,o.add=mn,o.asin=pn,o.asinh=fn,o.atan=dn,o.atanh=gn,o.atan2=bn,o.cbrt=hn,o.ceil=yn,o.clamp=wn,o.cos=xn,o.cosh=kn,o.div=Sn,o.exp=Nn,o.floor=Ln,o.hypot=Tn,o.ln=Bn,o.log=An,o.log10=En,o.log2=In,o.max=Wn,o.min=vn,o.mod=Dn,o.mul=Cn,o.pow=On,o.random=Rn,o.round=_n,o.sign=qn,o.sin=Mn,o.sinh=Fn,o.sqrt=Un,o.sub=Vn,o.sum=Kn,o.tan=Zn,o.tanh=jn,o.trunc=Hn,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 Sn(e,t){return new this(e).div(t)}function Nn(e){return new this(e).exp()}function Ln(e){return h(e=new this(e),e.e+1,3)}function Tn(){var e,t,n=new this(0);for(P=!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 P=!0,new this(1/0);n=t}return P=!0,n.sqrt()}function gt(e){return e instanceof Ce||e&&e.toStringTag===wt||!1}function Bn(e){return new this(e).ln()}function An(e,t){return new this(e).log(t)}function In(e){return new this(e).log(2)}function En(e){return new this(e).log(10)}function Wn(){return St(this,arguments,"lt")}function vn(){return St(this,arguments,"gt")}function Dn(e,t){return new this(e).mod(t)}function Cn(e,t){return new this(e).mul(t)}function On(e,t){return new this(e).pow(t)}function Rn(e){var t,n,r,o,i=0,s=new this(1),u=[];if(e===void 0?e=this.precision:U(e,1,ie),r=Math.ceil(e/y),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));i<r;)o=t[i],o>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:u[i++]=o%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);i<r;)o=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(t,i):(u.push(o%1e7),i+=4);i=r/4}else throw Error(yt);else for(;i<r;)u[i++]=Math.random()*1e7|0;for(r=u[--i],e%=y,r&&e&&(o=D(10,y-e),u[i]=(r/o|0)*o);u[i]===0;i--)u.pop();if(i<0)n=0,u=[0];else{for(n=-1;u[0]===0;n-=y)u.shift();for(r=1,o=u[0];o>=10;o/=10)r++;r<y&&(n-=y-r)}return s.e=n,s.d=u,s}function _n(e){return h(e=new this(e),e.e+1,this.rounding)}function qn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Mn(e){return new this(e).sin()}function Fn(e){return new this(e).sinh()}function Un(e){return new this(e).sqrt()}function Vn(e,t){return new this(e).sub(t)}function Kn(){var e=0,t=arguments,n=new this(t[e]);for(P=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return P=!0,h(n,this.precision,this.rounding)}function Zn(e){return new this(e).tan()}function jn(e){return new this(e).tanh()}function Hn(e){return h(e=new this(e),e.e+1,1)}d[Symbol.for("nodejs.util.inspect.custom")]=d.toString;d[Symbol.toStringTag]="Decimal";var Ce=d.constructor=Tt(Ve);Ae=new Ce(Ae);Ie=new Ce(Ie);import{PublicKey as Ye}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Gn}from"@solana/spl-token";import{PublicKey as A,SystemProgram as At,SYSVAR_RENT_PUBKEY as Yn}from"@solana/web3.js";function p({pubkey:e,isSigner:t=!1,isWritable:n=!0}){return{pubkey:e,isWritable:n,isSigner:t}}var Er=[p({pubkey:Gn,isWritable:!1}),p({pubkey:At.programId,isWritable:!1}),p({pubkey:Yn,isWritable:!1})];function It({publicKey:e,transformSol:t}){let n=Ge(e.toString());if(n instanceof A)return t&&n.equals(Pe)?Bt:n;if(t&&n.toString()===Pe.toBase58())return Bt;if(typeof n=="string"){if(n===A.default.toBase58())return A.default;try{return new A(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Ge(e){try{return new A(e)}catch{return e}}var Wr=new A("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),vr=new A("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Et=new A("SysvarRent111111111111111111111111111111111"),Dr=new A("SysvarC1ock11111111111111111111111111111111"),Cr=new A("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Or=new A("Sysvar1nstructions1111111111111111111111111"),Rr=At.programId,_r=new A("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),qr=new A("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Mr=new A("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Fr=new A("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Ur=new A("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Vr=new A("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Kr=new A("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Zr=new A("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),jr=new A("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Hr=new A("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Gr=new A("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),Bt=new A("So11111111111111111111111111111111111111112"),Pe=A.default;import{PublicKey as Xn}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Wt}from"@solana/spl-token";var vt={chainId:101,address:Xn.default.toBase58(),programId:Wt.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},ae={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Wt.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var Xe=class{constructor({mint:t,decimals:n,symbol:r,name:o,skipMint:i=!1,isToken2022:s=!1}){if(t===Pe.toBase58()||t instanceof Ye&&Pe.equals(t)){this.decimals=ae.decimals,this.symbol=ae.symbol,this.name=ae.name,this.mint=new Ye(ae.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?Ye.default:It({publicKey:t}),this.isToken2022=s}equals(t){return this===t?!0:this.mint.equals(t.mint)}},ce=Xe;ce.WSOL=new Xe(fe(ue({},ae),{mint:ae.address}));import{get as Dt,set as Qn}from"lodash";var Qe=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}},Ct={},zn={};function Y(e){let t=Dt(Ct,e);if(!t){let n=Dt(zn,e);t=new Qe({name:e,logLevel:n}),Qn(Ct,e,t)}return t}import Re from"big.js";import er from"bn.js";import tr from"decimal.js-light";import $n from"toformat";var Jn=$n,xe=Jn;var Oe=Y("module/fraction"),ze=xe(Re),ke=xe(tr),nr={[0]:ke.ROUND_DOWN,[1]:ke.ROUND_HALF_UP,[2]:ke.ROUND_UP},rr={[0]:Re.roundDown,[1]:Re.roundHalfUp,[2]:Re.roundUp},k=class{constructor(t,n=new er(1)){this.numerator=E(t),this.denominator=E(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(E(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(E(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(E(t));return new k(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(t){let n=t instanceof k?t:new k(E(t));return new k(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(t,n={groupSeparator:""},r=1){Number.isInteger(t)||Oe.logWithError(`${t} is not an integer.`),t<=0&&Oe.logWithError(`${t} is not positive.`),ke.set({precision:t+1,rounding:nr[r]});let o=new ke(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)||Oe.logWithError(`${t} is not an integer.`),t<0&&Oe.logWithError(`${t} is negative.`),ze.DP=t,ze.RM=rr[r]||1,new ze(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)}isZero(){return this.numerator.isZero()}};var or=Y("Raydium_price"),z=class extends k{constructor(n){let{baseToken:r,quoteToken:o,numerator:i,denominator:s}=n;super(i,s);this.baseToken=r,this.quoteToken=o,this.scalar=new k($e(r.decimals),$e(o.decimals))}get raw(){return new k(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new z({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(n){this.quoteToken!==n.baseToken&&or.logWithError("mul token not equals");let r=super.mul(n);return new z({baseToken:this.baseToken,quoteToken:n.quoteToken,denominator:r.denominator,numerator:r.numerator})}toSignificant(n=this.quoteToken.decimals,r,o){return this.adjusted.toSignificant(n,r,o)}toFixed(n=this.quoteToken.decimals,r,o){return this.adjusted.toFixed(n,r,o)}};var Je=class{constructor({decimals:t,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=t,this.symbol=n,this.name=r}equals(t){return this===t}},_e=Je;_e.SOL=new Je(vt);import sr from"big.js";import qe from"bn.js";var ur=Y("Raydium_amount"),Ot=xe(sr);function ar(e,t){let n="0",r="0";if(e.includes(".")){let o=e.split(".");o.length===2?([n,r]=o,r=r.padEnd(t,"0")):ur.logWithError(`invalid number string, num: ${e}`)}else n=e;return[n,r.slice(0,t)||r]}var $=class extends k{constructor(n,r,o=!0,i){let s=new qe(0),u=et.pow(new qe(n.decimals));if(o)s=E(r);else{let c=new qe(0),a=new qe(0);if(typeof r=="string"||typeof r=="number"||typeof r=="bigint"){let[l,m]=ar(r.toString(),n.decimals);c=E(l),a=E(m)}c=c.mul(u),s=c.add(a)}super(s,u);this.logger=Y(i||"TokenAmount"),this.token=n}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(n){return this.token.equals(n.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(n.raw)}lt(n){return this.token.equals(n.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(n.raw)}add(n){return this.token.equals(n.token)||this.logger.logWithError("add token not equals"),new $(this.token,this.raw.add(n.raw))}subtract(n){return this.token.equals(n.token)||this.logger.logWithError("sub token not equals"),new $(this.token,this.raw.sub(n.raw))}toSignificant(n=this.token.decimals,r,o=0){return super.toSignificant(n,r,o)}toFixed(n=this.token.decimals,r,o=0){return n>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(n,r,o)}toExact(n={groupSeparator:""}){return Ot.DP=this.token.decimals,new Ot(this.numerator.toString()).div(this.denominator.toString()).toFormat(n)}};import cr from"bn.js";var Rt=new k(new cr(100)),be=class extends k{toSignificant(t=5,n,r){return this.mul(Rt).toSignificant(t,n,r)}toFixed(t=2,n,r){return this.mul(Rt).toFixed(t,n,r)}};import{PublicKey as lr}from"@solana/web3.js";import mr from"bn.js";function _t(e){return typeof e=="object"&&e!==null&&![ce,$,lr,k,mr,z,be].some(t=>typeof t=="object"&&e instanceof t)}function le(e){return typeof e=="string"?Ge(e):Array.isArray(e)?e.map(t=>le(t)):_t(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,le(n)])):e}var tt=new V(0),Mt=new V(1),ho=new V(2),yo=new V(3),wo=new V(5),et=new V(10),Po=new V(100),xo=new V(1e3),ko=new V(1e4),qt=9007199254740991;function E(e){let t=Y("Raydium_parseBigNumberish");if(e instanceof V)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new V(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=qt||e<=-qt)&&t.logWithError(`BigNumberish number overflow: ${e}`),new V(String(e))):typeof e=="bigint"?new V(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new V(0))}function $e(e){return et.pow(E(e))}var Ft={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",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",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"};import{PublicKey as hr}from"@solana/web3.js";import Zt,{isBN as jt}from"bn.js";import{bits as To,BitStructure as Bo,blob as pr,Blob as Ao,cstr as Io,f32 as Eo,f32be as Wo,f64 as vo,f64be as Do,greedy as Co,Layout as fr,ns64 as Oo,ns64be as Ro,nu64 as _o,nu64be as qo,offset as Mo,s16 as Fo,s16be as Uo,s24 as Vo,s24be as Ko,s32 as Zo,s32be as jo,s40 as Ho,s40be as Go,s48 as Yo,s48be as Xo,s8 as Qo,seq as dr,struct as zo,Structure as gr,u16 as $o,u16be as Jo,u24 as es,u24be as ts,u32 as ns,u32be as rs,u40 as is,u40be as os,u48 as ss,u48be as us,u8 as as,UInt as br,union as cs,Union as ls,unionLayoutDiscriminator as ms,utf8 as ps}from"@solana/buffer-layout";var nt=fr,Ut=gr;var Vt=br;var Kt=dr;var rt=pr;var Me=class extends nt{constructor(n,r,o){super(n,o);this.blob=rt(n),this.signed=r}decode(n,r=0){let o=new Zt(this.blob.decode(n,r),10,"le");return this.signed?o.fromTwos(this.span*8).clone():o}encode(n,r,o=0){return typeof n=="number"&&(n=new Zt(n)),this.signed&&(n=n.toTwos(this.span*8)),this.blob.encode(n.toArrayLike(Buffer,"le",this.span),r,o)}};function F(e){return new Vt(1,e)}function g(e){return new Me(8,!1,e)}function J(e){return new Me(16,!1,e)}var it=class extends nt{constructor(n,r,o,i){super(n.span,i);this.layout=n,this.decoder=r,this.encoder=o}decode(n,r){return this.decoder(this.layout.decode(n,r))}encode(n,r,o){return this.layout.encode(this.encoder(n),r,o)}getSpan(n,r){return this.layout.getSpan(n,r)}};function I(e){return new it(rt(32),t=>new hr(t),t=>t.toBuffer(),e)}var ot=class extends Ut{decode(t,n){return super.decode(t,n)}};function _(e,t,n){return new ot(e,t,n)}function Se(e,t,n){let r,o=typeof t=="number"?t:jt(t)?t.toNumber():new Proxy(t,{get(i,s){if(!r){let u=Reflect.get(i,"count");r=jt(u)?u.toNumber():u,Reflect.set(i,"count",r)}return Reflect.get(i,s)},set(i,s,u){return s==="count"&&(r=u),Reflect.set(i,s,u)}});return Kt(e,o,n)}var st=_([F("instruction"),g("amountIn"),g("minAmountOut")]),ut=_([F("instruction"),g("maxAmountIn"),g("amountOut")]),Ws=_([F("instruction"),F("nonce")]),at=_([F("instruction"),F("nonce"),g("startTime")]),vs=_([g("status"),g("nonce"),g("maxOrder"),g("depth"),g("baseDecimal"),g("quoteDecimal"),g("state"),g("resetFlag"),g("minSize"),g("volMaxCutRatio"),g("amountWaveRatio"),g("baseLotSize"),g("quoteLotSize"),g("minPriceMultiplier"),g("maxPriceMultiplier"),g("systemDecimalValue"),g("minSeparateNumerator"),g("minSeparateDenominator"),g("tradeFeeNumerator"),g("tradeFeeDenominator"),g("pnlNumerator"),g("pnlDenominator"),g("swapFeeNumerator"),g("swapFeeDenominator"),g("baseNeedTakePnl"),g("quoteNeedTakePnl"),g("quoteTotalPnl"),g("baseTotalPnl"),g("poolOpenTime"),g("punishPcAmount"),g("punishCoinAmount"),g("orderbookToInitTime"),J("swapBaseInAmount"),J("swapQuoteOutAmount"),g("swapBase2QuoteFee"),J("swapQuoteInAmount"),J("swapBaseOutAmount"),g("swapQuote2BaseFee"),I("baseVault"),I("quoteVault"),I("baseMint"),I("quoteMint"),I("lpMint"),I("openOrders"),I("marketId"),I("marketProgramId"),I("targetOrders"),I("withdrawQueue"),I("lpVault"),I("owner"),g("lpReserve"),Se(g(),3,"padding")]),Ds=_([g("accountType"),g("status"),g("nonce"),g("maxOrder"),g("depth"),g("baseDecimal"),g("quoteDecimal"),g("state"),g("resetFlag"),g("minSize"),g("volMaxCutRatio"),g("amountWaveRatio"),g("baseLotSize"),g("quoteLotSize"),g("minPriceMultiplier"),g("maxPriceMultiplier"),g("systemDecimalsValue"),g("abortTradeFactor"),g("priceTickMultiplier"),g("priceTick"),g("minSeparateNumerator"),g("minSeparateDenominator"),g("tradeFeeNumerator"),g("tradeFeeDenominator"),g("pnlNumerator"),g("pnlDenominator"),g("swapFeeNumerator"),g("swapFeeDenominator"),g("baseNeedTakePnl"),g("quoteNeedTakePnl"),g("quoteTotalPnl"),g("baseTotalPnl"),g("poolOpenTime"),g("punishPcAmount"),g("punishCoinAmount"),g("orderbookToInitTime"),J("swapBaseInAmount"),J("swapQuoteOutAmount"),J("swapQuoteInAmount"),J("swapBaseOutAmount"),g("swapQuote2BaseFee"),g("swapBase2QuoteFee"),I("baseVault"),I("quoteVault"),I("baseMint"),I("quoteMint"),I("lpMint"),I("modelDataAccount"),I("openOrders"),I("marketId"),I("marketProgramId"),I("targetOrders"),I("owner"),Se(g(),64,"padding")]),ct=_([F("instruction"),g("baseAmountIn"),g("quoteAmountIn"),g("fixedSide")]),lt=_([F("instruction"),g("amountIn")]);var Cs=_([g("fee")]);import{PublicKey as yr}from"@solana/web3.js";var Ne=new yr("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),wr=5e4,Pr=_([g("x"),g("y"),g("price")]),Ms=_([g("accountType"),g("status"),g("multiplier"),g("validDataCount"),Se(Pr,wr,"DataElement")]);var Ht=Y("Raydium_liquidity_instruction");function zs(e){let{poolInfo:t,poolKeys:n,userKeys:r,baseAmountIn:o,quoteAmountIn:i,fixedSide:s}=e,u=Buffer.alloc(ct.span);ct.encode({instruction:3,baseAmountIn:E(o),quoteAmountIn:E(i),fixedSide:s==="base"?tt:Mt},u);let c=[p({pubkey:he,isWritable:!1}),p({pubkey:new N(t.id)}),p({pubkey:new N(n.authority),isWritable:!1}),p({pubkey:new N(n.openOrders),isWritable:!1}),p({pubkey:new N(n.targetOrders)}),p({pubkey:new N(t.lpMint.address)}),p({pubkey:new N(n.vault.A)}),p({pubkey:new N(n.vault.B)})];return t.pooltype.includes("StablePool")&&c.push(p({pubkey:Ne})),c.push(p({pubkey:new N(t.marketId),isWritable:!1}),p({pubkey:r.baseTokenAccount}),p({pubkey:r.quoteTokenAccount}),p({pubkey:r.lpTokenAccount}),p({pubkey:r.owner,isWritable:!1,isSigner:!0}),p({pubkey:new N(n.marketEventQueue),isWritable:!1})),new ee({programId:new N(t.programId),keys:c,data:u})}function $s(e){let{poolInfo:t,poolKeys:n,userKeys:r,amountIn:o}=e,i=le(n),s=4;if(t.pooltype.includes("StablePool")&&(s=5),s===4||s===5){let u=Buffer.alloc(lt.span);lt.encode({instruction:4,amountIn:E(o)},u);let c=[p({pubkey:he,isWritable:!1}),p({pubkey:i.id}),p({pubkey:i.authority,isWritable:!1}),p({pubkey:i.openOrders}),p({pubkey:i.targetOrders}),p({pubkey:i.mintLp.address}),p({pubkey:i.vault.A}),p({pubkey:i.vault.B})];return s===5?c.push(p({pubkey:Ne})):(c.push(p({pubkey:i.id})),c.push(p({pubkey:i.id}))),c.push(p({pubkey:i.marketProgramId,isWritable:!1}),p({pubkey:i.marketId}),p({pubkey:i.marketBaseVault}),p({pubkey:i.marke