test-raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 57.3 kB
JavaScript
var ln=Object.create;var Pe=Object.defineProperty,mn=Object.defineProperties,pn=Object.getOwnPropertyDescriptor,fn=Object.getOwnPropertyDescriptors,dn=Object.getOwnPropertyNames,bt=Object.getOwnPropertySymbols,gn=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty,bn=Object.prototype.propertyIsEnumerable;var ht=(e,t,n)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||(t={}))yt.call(t,n)&&ht(e,n,t[n]);if(bt)for(var n of bt(t))bn.call(t,n)&&ht(e,n,t[n]);return e},de=(e,t)=>mn(e,fn(t));var hn=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},wt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of dn(t))!yt.call(e,o)&&o!==n&&Pe(e,o,{get:()=>t[o],enumerable:!(r=pn(t,o))||r.enumerable});return e};var j=(e,t,n)=>(n=e!=null?ln(gn(e)):{},wt(t||!e||!e.__esModule?Pe(n,"default",{value:e,enumerable:!0}):n,e)),yn=e=>wt(Pe({},"__esModule",{value:!0}),e);var Ir={};hn(Ir,{createPoolV4InstructionV2:()=>Nr,makeAMMSwapInstruction:()=>Tr,makeAddLiquidityInstruction:()=>kr,makeInitPoolInstructionV4:()=>Br,makeSimulatePoolInfoInstruction:()=>Ar,makeSwapFixedInInstruction:()=>an,makeSwapFixedOutInstruction:()=>cn,removeLiquidityInstruction:()=>Sr,simulatePoolInfoInstruction:()=>Lr});module.exports=yn(Ir);var oe=require("@solana/spl-token"),k=require("@solana/web3.js");var U=j(require("bn.js"));var ge=9e15,ie=1e9,Ze="0123456789abcdef",De="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ce="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ye={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ge,maxE:ge,crypto:!1},St,z,x=!0,Re="[DecimalError] ",re=Re+"Invalid argument: ",Nt=Re+"Precision limit exceeded",Lt=Re+"crypto unavailable",Tt="[object Decimal]",q=Math.floor,D=Math.pow,wn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Pn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,xn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Bt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,G=1e7,y=7,kn=9007199254740991,Sn=De.length-1,He=Ce.length-1,d={toStringTag:Tt};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=Nn(r,vt(r,n)),r.precision=e,r.rounding=t,h(z==2||z==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(x=!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=q((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=B(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 x=!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-q(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 B(this,new this.constructor(e))};d.dividedToIntegerBy=d.divToInt=function(e){var t=this,n=t.constructor;return h(B(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/Me(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),i=be(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=be(i,2,o,o,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,o=o.times(1/Me(5,e)),o=be(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,B(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,x=!1,n=n.times(n).minus(1).sqrt().plus(n),x=!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,x=!1,n=n.times(n).plus(1).sqrt().plus(n),x=!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=B(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<=He)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<=He)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(x=!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)),x=!0,h(s,l.precision=m,l.rounding=f,!0)};d.isFinite=function(){return!!this.d};d.isInteger=d.isInt=function(){return!!this.d&&q(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(x=!1,u=m+b,s=ne(a,u),r=t?Oe(l,u+10):ne(e,u),c=B(s,r,u,1),xe(c.d,o=m,f))do if(u+=10,s=ne(a,u),r=t?Oe(l,u+10):ne(e,u),c=B(s,r,u,1),!i){+R(c.d).slice(o+1,o+15)+1==1e14&&(c=h(c,m+1,0));break}while(xe(c.d,o+=10,f));return x=!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,S=b.constructor;if(e=new S(e),!b.d||!e.d)return!b.s||!e.s?e=new S(NaN):b.d?e.s=-e.s:e=new S(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=S.precision,c=S.rounding,!a[0]||!f[0]){if(f[0])e.s=-e.s;else if(a[0])e=new S(b);else return new S(c===3?-0:0);return x?h(e,u,c):e}if(n=q(e.e/y),l=q(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=_e(a,n),x?h(e,u,c):e):new S(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):(x=!1,r.modulo==9?(t=B(n,e.abs(),0,3,1),t.s*=e.s):t=B(n,e,0,r.modulo,1),t=t.times(e),x=!0,n.minus(t))};d.naturalExponential=d.exp=function(){return Ge(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)),x?h(e,u,c):e;if(i=q(m.e/y),r=q(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=_e(a,r),x?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=At(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=Tn(r,vt(r,n)),r.precision=e,r.rounding=t,h(z>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(x=!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=q((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(B(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 x=!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=B(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,h(z==2||z==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=q(l.e/y)+q(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=_e(i,n),x?h(e,m.precision,m.rounding):e};d.toBinary=function(e,t){return Xe(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:(V(e,0,ie),t===void 0?t=r.rounding:V(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):(V(e,0,ie),t===void 0?t=o.rounding:V(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):(V(e,0,ie),t===void 0?t=i.rounding:V(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,S=b.d,P=b.constructor;if(!S)return new P(b);if(a=n=new P(1),r=c=new P(0),t=new P(r),i=t.e=At(S)-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 P(e),!u.isInt()||u.lt(a))throw Error(re+u);e=u.gt(t)?i>0?t:a:u}for(x=!1,u=new P(R(S)),l=P.precision,P.precision=i=S.length*y*2;m=B(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=B(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=B(a,r,i,1).minus(b).abs().cmp(B(c,n,i,1).minus(b).abs())<1?[a,r]:[c,n],P.precision=l,x=!0,f};d.toHexadecimal=d.toHex=function(e,t){return Xe(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:V(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]?(x=!1,n=B(n,e,0,t,1).times(e),x=!0,h(n)):(e.s=n.s,n=e),n};d.toNumber=function(){return+this};d.toOctal=function(e,t){return Xe(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=q(e.e/y),t>=e.d.length-1&&(n=a<0?-a:a)<=kn)return o=It(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)?q(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):(x=!1,c.rounding=u.s=1,n=Math.min(12,(t+"").length),o=Ge(e.times(ne(u,r+n)),r),o.d&&(o=h(o,r+5,1),xe(o.d,r,i)&&(t=r+10,o=h(Ge(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,x=!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):(V(e,1,ie),t===void 0?t=o.rounding:V(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):(V(e,1,ie),t===void 0?t=r.rounding:V(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 V(e,t,n){if(e!==~~e||e<t||e>n)throw Error(re+e)}function xe(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 ve(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]+=Ze.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 Nn(e,t){var n,r,o;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),o=(1/Me(4,n)).toString()):(n=16,o="2.3283064365386962890625e-10"),e.precision+=n,t=be(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 B=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,S,P,O,I,K,L,C,pe,Z,we,se,ue,fe,Y,Ee,We=r.constructor,je=r.s==o.s?1:-1,M=r.d,A=o.d;if(!M||!M[0]||!A||!A[0])return new We(!r.s||!o.s||(M?A&&M[0]==A[0]:!A)?NaN:M&&M[0]==0||!A?je*0:je/0);for(c?(b=1,l=r.e-o.e):(c=G,b=y,l=q(r.e/b)-q(o.e/b)),Y=A.length,ue=M.length,I=new We(je),K=I.d=[],m=0;A[m]==(M[m]||0);m++);if(A[m]>(M[m]||0)&&l--,i==null?(Z=i=We.precision,s=We.rounding):u?Z=i+(r.e-o.e)+1:Z=i,Z<0)K.push(1),S=!0;else{if(Z=Z/b+2|0,m=0,Y==1){for(f=0,A=A[0],Z++;(m<ue||f)&&Z--;m++)we=f*c+(M[m]||0),K[m]=we/A|0,f=we%A|0;S=f||m<ue}else{for(f=c/(A[0]+1)|0,f>1&&(A=e(A,f,c),M=e(M,f,c),Y=A.length,ue=M.length),se=Y,L=M.slice(0,Y),C=L.length;C<Y;)L[C++]=0;Ee=A.slice(),Ee.unshift(0),fe=A[0],A[1]>=c/2&&++fe;do f=0,a=t(A,L,Y,C),a<0?(pe=L[0],Y!=C&&(pe=pe*c+(L[1]||0)),f=pe/fe|0,f>1?(f>=c&&(f=c-1),P=e(A,f,c),O=P.length,C=L.length,a=t(P,L,O,C),a==1&&(f--,n(P,Y<O?Ee:A,O,c))):(f==0&&(a=f=1),P=A.slice()),O=P.length,O<C&&P.unshift(0),n(L,P,C,c),a==-1&&(C=L.length,a=t(A,L,Y,C),a<1&&(f++,n(L,Y<C?Ee:A,C,c))),C=L.length):a===0&&(f++,L=[0]),K[m++]=f,a&&L[0]?L[C++]=M[se]||0:(L=[M[se]],C=1);while((se++<ue||L[0]!==void 0)&&Z--);S=L[0]!==void 0}K[0]||K.shift()}if(b==1)I.e=l,St=S;else{for(m=1,f=K[0];f>=10;f/=10)m++;I.e=m+l*b-1,h(I,u?i+I.e+1:i,s,S)}return I}}();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 x&&(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 Wt(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 _e(e,t){var n=e[0];for(t*=y;n>=10;n/=10)t++;return t}function Oe(e,t,n){if(t>Sn)throw x=!0,n&&(e.precision=n),Error(Nt);return h(new e(De),t,1,!0)}function H(e,t,n){if(t>He)throw Error(Nt);return h(new e(Ce),t,n,!0)}function At(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 It(e,t,n,r){var o,i=new e(1),s=Math.ceil(r/y+4);for(x=!1;;){if(n%2&&(i=i.times(t),xt(i.d,s)&&(o=!0)),n=q(n/2),n===0){n=i.d.length-1,o&&i.d[n]===0&&++i.d[n];break}t=t.times(t),xt(t.d,s)}return x=!0,i}function Pt(e){return e.d[e.d.length-1]&1}function Et(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 Ge(e,t){var n,r,o,i,s,u,c,a=0,l=0,m=0,f=e.constructor,b=f.rounding,S=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?(x=!1,c=S):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(B(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&&xe(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=S,b,x=!0);else return f.precision=S,s}s=u}}function ne(e,t){var n,r,o,i,s,u,c,a,l,m,f,b=1,S=10,P=e,O=P.d,I=P.constructor,K=I.rounding,L=I.precision;if(P.s<0||!O||!O[0]||!P.e&&O[0]==1&&O.length==1)return new I(O&&!O[0]?-1/0:P.s!=1?NaN:O?0:P);if(t==null?(x=!1,l=L):l=t,I.precision=l+=S,n=R(O),r=n.charAt(0),Math.abs(i=P.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)P=P.times(e),n=R(P.d),r=n.charAt(0),b++;i=P.e,r>1?(P=new I("0."+n),i++):P=new I(r+"."+n.slice(1))}else return a=Oe(I,l+2,L).times(i+""),P=ne(new I(r+"."+n.slice(1)),l-S).plus(a),I.precision=L,t==null?h(P,L,K,x=!0):P;for(m=P,c=s=P=B(P.minus(1),P.plus(1),l,1),f=h(P.times(P),l,1),o=3;;){if(s=h(s.times(f),l,1),a=c.plus(B(s,new I(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(Oe(I,l+2,L).times(i+""))),c=B(c,new I(b),l,1),t==null)if(xe(c.d,l-S,K,u))I.precision=l+=S,a=s=P=B(m.minus(1),m.plus(1),l,1),f=h(P.times(P),l,1),o=u=1;else return h(c,I.precision=L,K,x=!0);else return I.precision=L,c;c=a,o+=2}}function Wt(e){return String(e.s*e.s/0)}function Qe(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),x&&(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 Ln(e,t){var n,r,o,i,s,u,c,a,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Bt.test(t))return Qe(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Pn.test(t))n=16,t=t.toLowerCase();else if(wn.test(t))n=2;else if(xn.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=It(r,new r(n),i,i*2)),a=ve(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=_e(a,l),e.d=a,x=!1,s&&(e=B(e,o,u*4)),c&&(e=e.times(Math.abs(c)<54?D(2,c):qe.pow(2,c))),x=!0,e)}function Tn(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:be(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/Me(5,n)),t=be(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 be(e,t,n,r,o){var i,s,u,c,a=1,l=e.precision,m=Math.ceil(l/y);for(x=!1,c=n.times(n),u=new e(r);;){if(s=B(u.times(c),new e(t++*t++),l,1),u=o?r.plus(s):r.minus(s),r=B(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 x=!0,s.d.length=m+1,s}function Me(e,t){for(var n=e;--t;)n*=e;return n}function vt(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 z=r?4:1,t;if(n=t.divToInt(o),n.isZero())z=r?3:2;else{if(t=t.minus(n.times(o)),t.lte(i))return z=Pt(n)?r?2:3:r?4:1,t;z=Pt(n)?r?1:4:r?3:2}return t.minus(o).abs()}function Xe(e,t,n,r){var o,i,s,u,c,a,l,m,f,b=e.constructor,S=n!==void 0;if(S?(V(n,1,ie),r===void 0?r=b.rounding:V(r,0,8)):(n=b.precision,r=b.rounding),!e.isFinite())l=Wt(e);else{for(l=X(e),s=l.indexOf("."),S?(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=ve(X(f),10,o),f.e=f.d.length),m=ve(l,10,o),i=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=S?"0p+0":"0";else{if(s<0?i--:(e=new b(e),e.d=m,e.e=i,e=B(e,f,n,r,0,o),m=e.d,i=e.e,a=St),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+=Ze.charAt(m[s]);if(S){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(m=ve(l,o,t),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Ze.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 xt(e,t){if(e.length>t)return e.length=t,!0}function Bn(e){return new this(e).abs()}function An(e){return new this(e).acos()}function In(e){return new this(e).acosh()}function En(e,t){return new this(e).plus(t)}function Wn(e){return new this(e).asin()}function vn(e){return new this(e).asinh()}function Dn(e){return new this(e).atan()}function Cn(e){return new this(e).atanh()}function On(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(B(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(B(e,t,i,1)),n}function Rn(e){return new this(e).cbrt()}function _n(e){return h(e=new this(e),e.e+1,2)}function Mn(e,t,n){return new this(e).clamp(t,n)}function qn(e){if(!e||typeof e!="object")throw Error(Re+"Object expected");var t,n,r,o=e.defaults===!0,i=["precision",1,ie,"rounding",0,8,"toExpNeg",-ge,0,"toExpPos",0,ge,"maxE",0,ge,"minE",-ge,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(n=i[t],o&&(this[n]=Ye[n]),(r=e[n])!==void 0)if(q(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]=Ye[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(Lt);else this[n]=!1;else throw Error(re+n+": "+r);return this}function Fn(e){return new this(e).cos()}function Un(e){return new this(e).cosh()}function Dt(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,kt(i)){a.s=i.s,x?!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++;x?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 Qe(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),Bt.test(i)?Qe(a,i):Ln(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=qn,o.clone=Dt,o.isDecimal=kt,o.abs=Bn,o.acos=An,o.acosh=In,o.add=En,o.asin=Wn,o.asinh=vn,o.atan=Dn,o.atanh=Cn,o.atan2=On,o.cbrt=Rn,o.ceil=_n,o.clamp=Mn,o.cos=Fn,o.cosh=Un,o.div=Vn,o.exp=Kn,o.floor=jn,o.hypot=Zn,o.ln=Yn,o.log=Hn,o.log10=Qn,o.log2=Gn,o.max=Xn,o.min=zn,o.mod=$n,o.mul=Jn,o.pow=er,o.random=tr,o.round=nr,o.sign=rr,o.sin=ir,o.sinh=or,o.sqrt=sr,o.sub=ur,o.sum=ar,o.tan=cr,o.tanh=lr,o.trunc=mr,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 Vn(e,t){return new this(e).div(t)}function Kn(e){return new this(e).exp()}function jn(e){return h(e=new this(e),e.e+1,3)}function Zn(){var e,t,n=new this(0);for(x=!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 x=!0,new this(1/0);n=t}return x=!0,n.sqrt()}function kt(e){return e instanceof qe||e&&e.toStringTag===Tt||!1}function Yn(e){return new this(e).ln()}function Hn(e,t){return new this(e).log(t)}function Gn(e){return new this(e).log(2)}function Qn(e){return new this(e).log(10)}function Xn(){return Et(this,arguments,"lt")}function zn(){return Et(this,arguments,"gt")}function $n(e,t){return new this(e).mod(t)}function Jn(e,t){return new this(e).mul(t)}function er(e,t){return new this(e).pow(t)}function tr(e){var t,n,r,o,i=0,s=new this(1),u=[];if(e===void 0?e=this.precision:V(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(Lt);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 nr(e){return h(e=new this(e),e.e+1,this.rounding)}function rr(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function ir(e){return new this(e).sin()}function or(e){return new this(e).sinh()}function sr(e){return new this(e).sqrt()}function ur(e,t){return new this(e).sub(t)}function ar(){var e=0,t=arguments,n=new this(t[e]);for(x=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return x=!0,h(n,this.precision,this.rounding)}function cr(e){return new this(e).tan()}function lr(e){return new this(e).tanh()}function mr(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 qe=d.constructor=Dt(Ye);De=new qe(De);Ce=new qe(Ce);var Fe=require("@solana/web3.js");var Ot=require("@solana/spl-token"),T=require("@solana/web3.js");function p({pubkey:e,isSigner:t=!1,isWritable:n=!0}){return{pubkey:e,isWritable:n,isSigner:t}}var Dr=[p({pubkey:Ot.TOKEN_PROGRAM_ID,isWritable:!1}),p({pubkey:T.SystemProgram.programId,isWritable:!1}),p({pubkey:T.SYSVAR_RENT_PUBKEY,isWritable:!1})];function Rt({publicKey:e,transformSol:t}){let n=ze(e.toString());if(n instanceof T.PublicKey)return t&&n.equals(ke)?Ct:n;if(t&&n.toString()===ke.toBase58())return Ct;if(typeof n=="string"){if(n===T.PublicKey.default.toBase58())return T.PublicKey.default;try{return new T.PublicKey(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function ze(e){try{return new T.PublicKey(e)}catch{return e}}var Cr=new T.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),_t=new T.PublicKey("SysvarRent111111111111111111111111111111111"),Or=new T.PublicKey("SysvarC1ock11111111111111111111111111111111"),Rr=new T.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),_r=new T.PublicKey("Sysvar1nstructions1111111111111111111111111"),Mr=new T.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),qr=new T.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Fr=new T.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Ur=new T.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Vr=new T.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Kr=new T.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),jr=new T.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Zr=new T.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Yr=new T.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Hr=new T.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Gr=new T.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),Ct=new T.PublicKey("So11111111111111111111111111111111111111112"),ke=T.PublicKey.default;var Mt=require("@solana/web3.js"),$e=require("@solana/spl-token"),qt={chainId:101,address:Mt.PublicKey.default.toBase58(),programId:$e.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},ce={chainId:101,address:"So11111111111111111111111111111111111111112",programId:$e.TOKEN_PROGRAM_ID.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 Je=class{constructor({mint:t,decimals:n,symbol:r,name:o,skipMint:i=!1,isToken2022:s=!1}){if(t===ke.toBase58()||t instanceof Fe.PublicKey&&ke.equals(t)){this.decimals=ce.decimals,this.symbol=ce.symbol,this.name=ce.name,this.mint=new Fe.PublicKey(ce.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?Fe.PublicKey.default:Rt({publicKey:t}),this.isToken2022=s}equals(t){return this===t?!0:this.mint.equals(t.mint)}},le=Je;le.WSOL=new Je(de(ae({},ce),{mint:ce.address}));var Se=require("lodash"),tt=j(require("dayjs")),Ut=j(require("dayjs/plugin/utc"));tt.default.extend(Ut.default);var et=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(0,tt.default)().utc().format("YYYY/MM/DD HH:mm:ss UTC")}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}},Ft={},pr={};function Q(e){let t=(0,Se.get)(Ft,e);if(!t){let n=(0,Se.get)(pr,e);t=new et({name:e,logLevel:n}),(0,Se.set)(Ft,e,t)}return t}var Le=j(require("big.js")),Kt=j(require("bn.js")),jt=j(require("decimal.js-light"));var Vt=j(require("toformat")),fr=Vt.default,Ne=fr;var Ue=Q("module/fraction"),nt=Ne(Le.default),Te=Ne(jt.default),dr={[0]:Te.ROUND_DOWN,[1]:Te.ROUND_HALF_UP,[2]:Te.ROUND_UP},gr={[0]:Le.default.roundDown,[1]:Le.default.roundHalfUp,[2]:Le.default.roundUp},N=class{constructor(t,n=new Kt.default(1)){this.numerator=W(t),this.denominator=W(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new N(this.denominator,this.numerator)}add(t){let n=t instanceof N?t:new N(W(t));return this.denominator.eq(n.denominator)?new N(this.numerator.add(n.numerator),this.denominator):new N(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(t){let n=t instanceof N?t:new N(W(t));return this.denominator.eq(n.denominator)?new N(this.numerator.sub(n.numerator),this.denominator):new N(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(t){let n=t instanceof N?t:new N(W(t));return new N(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(t){let n=t instanceof N?t:new N(W(t));return new N(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(t,n={groupSeparator:""},r=1){Number.isInteger(t)||Ue.logWithError(`${t} is not an integer.`),t<=0&&Ue.logWithError(`${t} is not positive.`),Te.set({precision:t+1,rounding:dr[r]});let o=new Te(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)||Ue.logWithError(`${t} is not an integer.`),t<0&&Ue.logWithError(`${t} is negative.`),nt.DP=t,nt.RM=gr[r]||1,new nt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)}isZero(){return this.numerator.isZero()}};var hr=Q("Raydium_price"),$=class extends N{constructor(n){let{baseToken:r,quoteToken:o,numerator:i,denominator:s}=n;super(i,s);this.baseToken=r,this.quoteToken=o,this.scalar=new N(rt(r.decimals),rt(o.decimals))}get raw(){return new N(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new $({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(n){this.quoteToken!==n.baseToken&&hr.logWithError("mul token not equals");let r=super.mul(n);return new $({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 it=class{constructor({decimals:t,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=t,this.symbol=n,this.name=r}equals(t){return this===t}},Ve=it;Ve.SOL=new it(qt);var Yt=j(require("big.js")),Be=j(require("bn.js"));var yr=Q("Raydium_amount"),Zt=Ne(Yt.default);function wr(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")):yr.logWithError(`invalid number string, num: ${e}`)}else n=e;return[n,r.slice(0,t)||r]}var J=class extends N{constructor(n,r,o=!0,i){let s=new Be.default(0),u=ot.pow(new Be.default(n.decimals));if(o)s=W(r);else{let c=new Be.default(0),a=new Be.default(0);if(typeof r=="string"||typeof r=="number"||typeof r=="bigint"){let[l,m]=wr(r.toString(),n.decimals);c=W(l),a=W(m)}c=c.mul(u),s=c.add(a)}super(s,u);this.logger=Q(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 J(this.token,this.raw.add(n.raw))}subtract(n){return this.token.equals(n.token)||this.logger.logWithError("sub token not equals"),new J(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 Zt.DP=this.token.decimals,new Zt(this.numerator.toString()).div(this.denominator.toString()).toFormat(n)}};var Gt=j(require("bn.js"));var Ht=new N(new Gt.default(100)),he=class extends N{toSignificant(t=5,n,r){return this.mul(Ht).toSignificant(t,n,r)}toFixed(t=2,n,r){return this.mul(Ht).toFixed(t,n,r)}};var Qt=require("@solana/web3.js"),Xt=j(require("bn.js"));function zt(e){return typeof e=="object"&&e!==null&&![le,J,Qt.PublicKey,N,Xt.default,$,he].some(t=>typeof t=="object"&&e instanceof t)}function me(e){return typeof e=="string"?ze(e):Array.isArray(e)?e.map(t=>me(t)):zt(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,me(n)])):e}var st=new U.default(0),Jt=new U.default(1),ro=new U.default(2),io=new U.default(3),oo=new U.default(5),ot=new U.default(10),so=new U.default(100),uo=new U.default(1e3),ao=new U.default(1e4),$t=9007199254740991;function W(e){let t=Q("Raydium_parseBigNumberish");if(e instanceof U.default)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new U.default(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=$t||e<=-$t)&&t.logWithError(`BigNumberish number overflow: ${e}`),new U.default(String(e))):typeof e=="bigint"?new U.default(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new U.default(0))}function rt(e){return ot.pow(W(e))}var en={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"};var on=require("@solana/web3.js"),ye=j(require("bn.js"));var w=require("@solana/buffer-layout"),ut=w.Layout,tn=w.Structure;var nn=w.UInt;var rn=w.seq;var at=w.blob;var Ke=class extends ut{constructor(n,r,o){super(n,o);this.blob=at(n),this.signed=r}decode(n,r=0){let o=new ye.default(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 ye.default(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 nn(1,e)}function g(e){return new Ke(8,!1,e)}function ee(e){return new Ke(16,!1,e)}var ct=class extends ut{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 E(e){return new ct(at(32),t=>new on.PublicKey(t),t=>t.toBuffer(),e)}var lt=class extends tn{decode(t,n){return super.decode(t,n)}};function _(e,t,n){return new lt(e,t,n)}function Ae(e,t,n){let r,o=typeof t=="number"?t:(0,ye.isBN)(t)?t.toNumber():new Proxy(t,{get(i,s){if(!r){let u=Reflect.get(i,"count");r=(0,ye.isBN)(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 rn(e,o,n)}var mt=_([F("instruction"),g("amountIn"),g("minAmountOut")]),pt=_([F("instruction"),g("maxAmountIn"),g("amountOut")]),Lo=_([F("instruction"),F("nonce")]),ft=_([F("instruction"),F("nonce"),g("startTime")]),To=_([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"),ee("swapBaseInAmount"),ee("swapQuoteOutAmount"),g("swapBase2QuoteFee"),ee("swapQuoteInAmount"),ee("swapBaseOutAmount"),g("swapQuote2BaseFee"),E("baseVault"),E("quoteVault"),E("baseMint"),E("quoteMint"),E("lpMint"),E("openOrders"),E("marketId"),E("marketProgramId"),E("targetOrders"),E("withdrawQueue"),E("lpVault"),E("owner"),g("lpReserve"),Ae(g(),3,"padding")]),Bo=_([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"),ee("swapBaseInAmount"),ee("swapQuoteOutAmount"),ee("swapQuoteInAmount"),ee("swapBaseOutAmount"),g("swapQuote2BaseFee"),g("swapBase2QuoteFee"),E("baseVault"),E("quoteVault"),E("baseMint"),E("quoteMint"),E("lpMint"),E("modelDataAccount"),E("openOrders"),E("marketId"),E("marketProgramId"),E("targetOrders"),E("owner"),Ae(g(),64,"padding")]),dt=_([F("instruction"),g("baseAmountIn"),g("quoteAmountIn"),g("fixedSide")]),gt=_([F("instruction"),g("amountIn")]);var Ao=_([g("fee")]);var sn=require("@solana/web3.js");var Ie=new sn.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Pr=5e4,xr=_([g("x"),g("y"),g("price")]),vo=_([g("accountType"),g("status"),g("multiplier"),g("validDataCount"),Ae(xr,Pr,"DataElement")]);var un=Q("Raydium_liquidity_instruction");function kr(e){let{poolInfo:t,poolKeys:n,userKeys:r,baseAmountIn:o,quoteAmountIn:i,fixedSide:s}=e,u=Buffer.alloc(dt.span);dt.encode({instruction:3,baseAmountIn:W(o),quoteAmountIn:W(i),fixedSide:s==="base"?st:Jt},u);let c=[p({pubkey:oe.TOKEN_PROGRAM_ID,isWritable:!1}),p({pubkey:new k.PublicKey(t.id)}),p({pubkey:new k.PublicKey(n.authority),isWritable:!1}),p({pubkey:new k.PublicKey(n.openOrders),isWritable:!1}),p({pubkey:new k.PublicKey(n.targetOrders)}),p({pubkey:new k.PublicKey(t.lpMint.address)}),p({pubkey:new k.PublicKey(n.vault.A)}),p({pubkey:new k.PublicKey(n.vault.B)})];return t.pooltype.includes("StablePool")&&c.push(p({pubkey:Ie})),c.push(p({pubkey:new k.PublicKey(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 k.PublicKey(n.marketEventQueue),isWritable:!1})),new k.TransactionInstr