@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
2 lines • 85.9 kB
JavaScript
var ri=Object.defineProperty,oi=Object.defineProperties;var si=Object.getOwnPropertyDescriptors;var nn=Object.getOwnPropertySymbols;var ai=Object.prototype.hasOwnProperty,ui=Object.prototype.propertyIsEnumerable;var rn=(t,e,n)=>e in t?ri(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,D=(t,e)=>{for(var n in e||(e={}))ai.call(e,n)&&rn(t,n,e[n]);if(nn)for(var n of nn(e))ui.call(e,n)&&rn(t,n,e[n]);return t},q=(t,e)=>oi(t,si(e));import{PublicKey as Ho}from"@solana/web3.js";import{get as on,set as ci}from"lodash";var Tt=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let n=e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(", ");throw new Error(n)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},sn={},li={};function ee(t){let e=on(sn,t);if(!e){let n=on(li,t);e=new Tt({name:t,logLevel:n}),ci(sn,t,e)}return e}import{MINT_SIZE as Qo,TOKEN_PROGRAM_ID as Jo,getTransferFeeConfig as $o,unpackMint as es}from"@solana/spl-token";var ts=ee("Raydium_accountInfo_util");import ye from"bn.js";var Fe=9e15,xe=1e9,kt="0123456789abcdef",nt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",it="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ht={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Fe,maxE:Fe,crypto:!1},mn,Pe,K=!0,ot="[DecimalError] ",Be=ot+"Invalid argument: ",dn=ot+"Precision limit exceeded",pn=ot+"crypto unavailable",fn="[object Decimal]",j=Math.floor,U=Math.pow,mi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,di=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,pi=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,bn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,pe=1e7,S=7,fi=9007199254740991,bi=nt.length-1,Bt=it.length-1,f={toStringTag:fn};f.absoluteValue=f.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),k(t)};f.ceil=function(){return k(new this.constructor(this),this.e+1,2)};f.clampedTo=f.clamp=function(t,e){var n,i=this,r=i.constructor;if(t=new r(t),e=new r(e),!t.s||!e.s)return new r(NaN);if(t.gt(e))throw Error(Be+e);return n=i.cmp(t),n<0?t:i.cmp(e)>0?e:new r(i)};f.comparedTo=f.cmp=function(t){var e,n,i,r,o=this,s=o.d,a=(t=new o.constructor(t)).d,c=o.s,u=t.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(o.e!==t.e)return o.e>t.e^c<0?1:-1;for(i=s.length,r=a.length,e=0,n=i<r?i:r;e<n;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return i===r?0:i>r^c<0?1:-1};f.cosine=f.cos=function(){var t,e,n=this,i=n.constructor;return n.d?n.d[0]?(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+S,i.rounding=1,n=yi(i,An(i,n)),i.precision=t,i.rounding=e,k(Pe==2||Pe==3?n.neg():n,t,e,!0)):new i(1):new i(NaN)};f.cubeRoot=f.cbrt=function(){var t,e,n,i,r,o,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(K=!1,o=l.s*U(l.s*l,1/3),!o||Math.abs(o)==1/0?(n=z(l.d),t=l.e,(o=(t-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=U(n,1/3),t=j((t+1)/3)-(t%3==(t<0?-1:2)),o==1/0?n="5e"+t:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),i=new m(n),i.s=l.s):i=new m(o.toString()),s=(t=m.precision)+3;;)if(a=i,c=a.times(a).times(a),u=c.plus(l),i=E(u.plus(l).times(a),u.plus(c),s+2,1),z(a.d).slice(0,s)===(n=z(i.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!r&&n=="4999"){if(!r&&(k(a,t+1,0),a.times(a).times(a).eq(l))){i=a;break}s+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(k(i,t+1,1),e=!i.times(i).times(i).eq(l));break}return K=!0,k(i,t,m.rounding,e)};f.decimalPlaces=f.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-j(this.e/S))*S,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};f.dividedBy=f.div=function(t){return E(this,new this.constructor(t))};f.dividedToIntegerBy=f.divToInt=function(t){var e=this,n=e.constructor;return k(E(e,new n(t),0,1,1),n.precision,n.rounding)};f.equals=f.eq=function(t){return this.cmp(t)===0};f.floor=function(){return k(new this.constructor(this),this.e+1,3)};f.greaterThan=f.gt=function(t){return this.cmp(t)>0};f.greaterThanOrEqualTo=f.gte=function(t){var e=this.cmp(t);return e==1||e===0};f.hyperbolicCosine=f.cosh=function(){var t,e,n,i,r,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;n=s.precision,i=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(t=Math.ceil(r/3),e=(1/at(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=Me(s,1,o.times(e),new s(1),!0);for(var c,u=t,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return k(o,s.precision=n,s.rounding=i,!0)};f.hyperbolicSine=f.sinh=function(){var t,e,n,i,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,n=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,i=r.d.length,i<3)r=Me(o,2,r,r,!0);else{t=1.4*Math.sqrt(i),t=t>16?16:t|0,r=r.times(1/at(5,t)),r=Me(o,2,r,r,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);t--;)s=r.times(r),r=r.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=e,o.rounding=n,k(r,e,n,!0)};f.hyperbolicTangent=f.tanh=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+7,i.rounding=1,E(n.sinh(),n.cosh(),i.precision=t,i.rounding=e)):new i(n.s)};f.inverseCosine=f.acos=function(){var t,e=this,n=e.constructor,i=e.abs().cmp(1),r=n.precision,o=n.rounding;return i!==-1?i===0?e.isNeg()?de(n,r,o):new n(0):new n(NaN):e.isZero()?de(n,r+4,o).times(.5):(n.precision=r+6,n.rounding=1,e=e.asin(),t=de(n,r+4,o).times(.5),n.precision=r,n.rounding=o,t.minus(e))};f.inverseHyperbolicCosine=f.acosh=function(){var t,e,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(t=i.precision,e=i.rounding,i.precision=t+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,K=!1,n=n.times(n).minus(1).sqrt().plus(n),K=!0,i.precision=t,i.rounding=e,n.ln()):new i(n)};f.inverseHyperbolicSine=f.asinh=function(){var t,e,n=this,i=n.constructor;return!n.isFinite()||n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,K=!1,n=n.times(n).plus(1).sqrt().plus(n),K=!0,i.precision=t,i.rounding=e,n.ln())};f.inverseHyperbolicTangent=f.atanh=function(){var t,e,n,i,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(t=o.precision,e=o.rounding,i=r.sd(),Math.max(i,t)<2*-r.e-1?k(new o(r),t,e,!0):(o.precision=n=i-r.e,r=E(r.plus(1),new o(1).minus(r),n+t,1),o.precision=t+4,o.rounding=1,r=r.ln(),o.precision=t,o.rounding=e,r.times(.5))):new o(NaN)};f.inverseSine=f.asin=function(){var t,e,n,i,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),n=o.precision,i=o.rounding,e!==-1?e===0?(t=de(o,n+4,i).times(.5),t.s=r.s,t):new o(NaN):(o.precision=n+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=i,r.times(2)))};f.inverseTangent=f.atan=function(){var t,e,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=Bt)return s=de(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=Bt)return s=de(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,n=Math.min(28,a/S+2|0),t=n;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(K=!1,e=Math.ceil(a/S),i=1,c=u.times(u),s=new l(u),r=u;t!==-1;)if(r=r.times(c),o=s.minus(r.div(i+=2)),r=r.times(c),s=o.plus(r.div(i+=2)),s.d[e]!==void 0)for(t=e;s.d[t]===o.d[t]&&t--;);return n&&(s=s.times(2<<n-1)),K=!0,k(s,l.precision=m,l.rounding=d,!0)};f.isFinite=function(){return!!this.d};f.isInteger=f.isInt=function(){return!!this.d&&j(this.e/S)>this.d.length-2};f.isNaN=function(){return!this.s};f.isNegative=f.isNeg=function(){return this.s<0};f.isPositive=f.isPos=function(){return this.s>0};f.isZero=function(){return!!this.d&&this.d[0]===0};f.lessThan=f.lt=function(t){return this.cmp(t)<0};f.lessThanOrEqualTo=f.lte=function(t){return this.cmp(t)<1};f.logarithm=f.log=function(t){var e,n,i,r,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,b=5;if(t==null)t=new l(10),e=!0;else{if(t=new l(t),n=t.d,t.s<0||!n||!n[0]||t.eq(1))return new l(NaN);e=t.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new l(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(e)if(n.length>1)o=!0;else{for(r=n[0];r%10===0;)r/=10;o=r!==1}if(K=!1,a=m+b,s=he(u,a),i=e?rt(l,a+10):he(t,a),c=E(s,i,a,1),We(c.d,r=m,d))do if(a+=10,s=he(u,a),i=e?rt(l,a+10):he(t,a),c=E(s,i,a,1),!o){+z(c.d).slice(r+1,r+15)+1==1e14&&(c=k(c,m+1,0));break}while(We(c.d,r+=10,d));return K=!0,k(c,m,d)};f.minus=f.sub=function(t){var e,n,i,r,o,s,a,c,u,l,m,d,b=this,g=b.constructor;if(t=new g(t),!b.d||!t.d)return!b.s||!t.s?t=new g(NaN):b.d?t.s=-t.s:t=new g(t.d||b.s!==t.s?b:NaN),t;if(b.s!=t.s)return t.s=-t.s,b.plus(t);if(u=b.d,d=t.d,a=g.precision,c=g.rounding,!u[0]||!d[0]){if(d[0])t.s=-t.s;else if(u[0])t=new g(b);else return new g(c===3?-0:0);return K?k(t,a,c):t}if(n=j(t.e/S),l=j(b.e/S),u=u.slice(),o=l-n,o){for(m=o<0,m?(e=u,o=-o,s=d.length):(e=d,n=l,s=u.length),i=Math.max(Math.ceil(a/S),s)+2,o>i&&(o=i,e.length=1),e.reverse(),i=o;i--;)e.push(0);e.reverse()}else{for(i=u.length,s=d.length,m=i<s,m&&(s=i),i=0;i<s;i++)if(u[i]!=d[i]){m=u[i]<d[i];break}o=0}for(m&&(e=u,u=d,d=e,t.s=-t.s),s=u.length,i=d.length-s;i>0;--i)u[s++]=0;for(i=d.length;i>o;){if(u[--i]<d[i]){for(r=i;r&&u[--r]===0;)u[r]=pe-1;--u[r],u[i]+=pe}u[i]-=d[i]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(t.d=u,t.e=st(u,n),K?k(t,a,c):t):new g(c===3?-0:0)};f.modulo=f.mod=function(t){var e,n=this,i=n.constructor;return t=new i(t),!n.d||!t.s||t.d&&!t.d[0]?new i(NaN):!t.d||n.d&&!n.d[0]?k(new i(n),i.precision,i.rounding):(K=!1,i.modulo==9?(e=E(n,t.abs(),0,3,1),e.s*=t.s):e=E(n,t,0,i.modulo,1),e=e.times(t),K=!0,n.minus(e))};f.naturalExponential=f.exp=function(){return xt(this)};f.naturalLogarithm=f.ln=function(){return he(this)};f.negated=f.neg=function(){var t=new this.constructor(this);return t.s=-t.s,k(t)};f.plus=f.add=function(t){var e,n,i,r,o,s,a,c,u,l,m=this,d=m.constructor;if(t=new d(t),!m.d||!t.d)return!m.s||!t.s?t=new d(NaN):m.d||(t=new d(t.d||m.s===t.s?m:NaN)),t;if(m.s!=t.s)return t.s=-t.s,m.minus(t);if(u=m.d,l=t.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(t=new d(m)),K?k(t,a,c):t;if(o=j(m.e/S),i=j(t.e/S),u=u.slice(),r=o-i,r){for(r<0?(n=u,r=-r,s=l.length):(n=l,i=o,s=u.length),o=Math.ceil(a/S),s=o>s?o+1:s+1,r>s&&(r=s,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for(s=u.length,r=l.length,s-r<0&&(r=s,n=l,l=u,u=n),e=0;r;)e=(u[--r]=u[r]+l[r]+e)/pe|0,u[r]%=pe;for(e&&(u.unshift(e),++i),s=u.length;u[--s]==0;)u.pop();return t.d=u,t.e=st(u,i),K?k(t,a,c):t};f.precision=f.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Be+t);return n.d?(e=yn(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};f.round=function(){var t=this,e=t.constructor;return k(new e(t),t.e+1,e.rounding)};f.sine=f.sin=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+S,i.rounding=1,n=Pi(i,An(i,n)),i.precision=t,i.rounding=e,k(Pe>2?n.neg():n,t,e,!0)):new i(NaN)};f.squareRoot=f.sqrt=function(){var t,e,n,i,r,o,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(K=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=z(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=j((c+1)/2)-(c<0||c%2),u==1/0?e="5e"+c:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),i=new l(e)):i=new l(u.toString()),n=(c=l.precision)+3;;)if(o=i,i=o.plus(E(s,o,n+2,1)).times(.5),z(o.d).slice(0,n)===(e=z(i.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!r&&e=="4999"){if(!r&&(k(o,c+1,0),o.times(o).eq(s))){i=o;break}n+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(k(i,c+1,1),t=!i.times(i).eq(s));break}return K=!0,k(i,c,l.rounding,t)};f.tangent=f.tan=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+10,i.rounding=1,n=n.sin(),n.s=1,n=E(n,new i(1).minus(n.times(n)).sqrt(),t+10,0),i.precision=t,i.rounding=e,k(Pe==2||Pe==4?n.neg():n,t,e,!0)):new i(NaN)};f.times=f.mul=function(t){var e,n,i,r,o,s,a,c,u,l=this,m=l.constructor,d=l.d,b=(t=new m(t)).d;if(t.s*=l.s,!d||!d[0]||!b||!b[0])return new m(!t.s||d&&!d[0]&&!b||b&&!b[0]&&!d?NaN:!d||!b?t.s/0:t.s*0);for(n=j(l.e/S)+j(t.e/S),c=d.length,u=b.length,c<u&&(o=d,d=b,b=o,s=c,c=u,u=s),o=[],s=c+u,i=s;i--;)o.push(0);for(i=u;--i>=0;){for(e=0,r=c+i;r>i;)a=o[r]+b[i]*d[r-i-1]+e,o[r--]=a%pe|0,e=a/pe|0;o[r]=(o[r]+e)%pe|0}for(;!o[--s];)o.pop();return e?++n:o.shift(),t.d=o,t.e=st(o,n),K?k(t,m.precision,m.rounding):t};f.toBinary=function(t,e){return St(this,2,t,e)};f.toDecimalPlaces=f.toDP=function(t,e){var n=this,i=n.constructor;return n=new i(n),t===void 0?n:(ne(t,0,xe),e===void 0?e=i.rounding:ne(e,0,8),k(n,t+n.e+1,e))};f.toExponential=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=fe(i,!0):(ne(t,0,xe),e===void 0?e=r.rounding:ne(e,0,8),i=k(new r(i),t+1,e),n=fe(i,!0,t+1)),i.isNeg()&&!i.isZero()?"-"+n:n};f.toFixed=function(t,e){var n,i,r=this,o=r.constructor;return t===void 0?n=fe(r):(ne(t,0,xe),e===void 0?e=o.rounding:ne(e,0,8),i=k(new o(r),t+r.e+1,e),n=fe(i,!1,t+i.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toFraction=function(t){var e,n,i,r,o,s,a,c,u,l,m,d,b=this,g=b.d,y=b.constructor;if(!g)return new y(b);if(u=n=new y(1),i=c=new y(0),e=new y(i),o=e.e=yn(g)-b.e-1,s=o%S,e.d[0]=U(10,s<0?S+s:s),t==null)t=o>0?e:u;else{if(a=new y(t),!a.isInt()||a.lt(u))throw Error(Be+a);t=a.gt(e)?o>0?e:u:a}for(K=!1,a=new y(z(g)),l=y.precision,y.precision=o=g.length*S*2;m=E(a,e,0,1,1),r=n.plus(m.times(i)),r.cmp(t)!=1;)n=i,i=r,r=u,u=c.plus(m.times(r)),c=r,r=e,e=a.minus(m.times(r)),a=r;return r=E(t.minus(n),i,0,1,1),c=c.plus(r.times(u)),n=n.plus(r.times(i)),c.s=u.s=b.s,d=E(u,i,o,1).minus(b).abs().cmp(E(c,n,o,1).minus(b).abs())<1?[u,i]:[c,n],y.precision=l,K=!0,d};f.toHexadecimal=f.toHex=function(t,e){return St(this,16,t,e)};f.toNearest=function(t,e){var n=this,i=n.constructor;if(n=new i(n),t==null){if(!n.d)return n;t=new i(1),e=i.rounding}else{if(t=new i(t),e===void 0?e=i.rounding:ne(e,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(K=!1,n=E(n,t,0,e,1).times(t),K=!0,k(n)):(t.s=n.s,n=t),n};f.toNumber=function(){return+this};f.toOctal=function(t,e){return St(this,8,t,e)};f.toPower=f.pow=function(t){var e,n,i,r,o,s,a=this,c=a.constructor,u=+(t=new c(t));if(!a.d||!t.d||!a.d[0]||!t.d[0])return new c(U(+a,u));if(a=new c(a),a.eq(1))return a;if(i=c.precision,o=c.rounding,t.eq(1))return k(a,i,o);if(e=j(t.e/S),e>=t.d.length-1&&(n=u<0?-u:u)<=fi)return r=gn(c,a,n,i),t.s<0?new c(1).div(r):k(r,i,o);if(s=a.s,s<0){if(e<t.d.length-1)return new c(NaN);if((t.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=U(+a,u),e=n==0||!isFinite(n)?j(u*(Math.log("0."+z(a.d))/Math.LN10+a.e+1)):new c(n+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(K=!1,c.rounding=a.s=1,n=Math.min(12,(e+"").length),r=xt(t.times(he(a,i+n)),i),r.d&&(r=k(r,i+5,1),We(r.d,i,o)&&(e=i+10,r=k(xt(t.times(he(a,e+n)),e),e+5,1),+z(r.d).slice(i+1,i+15)+1==1e14&&(r=k(r,i+1,0)))),r.s=s,K=!0,c.rounding=o,k(r,i,o))};f.toPrecision=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=fe(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(ne(t,1,xe),e===void 0?e=r.rounding:ne(e,0,8),i=k(new r(i),t,e),n=fe(i,t<=i.e||i.e<=r.toExpNeg,t)),i.isNeg()&&!i.isZero()?"-"+n:n};f.toSignificantDigits=f.toSD=function(t,e){var n=this,i=n.constructor;return t===void 0?(t=i.precision,e=i.rounding):(ne(t,1,xe),e===void 0?e=i.rounding:ne(e,0,8)),k(new i(n),t,e)};f.toString=function(){var t=this,e=t.constructor,n=fe(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};f.truncated=f.trunc=function(){return k(new this.constructor(this),this.e+1,1)};f.valueOf=f.toJSON=function(){var t=this,e=t.constructor,n=fe(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function z(t){var e,n,i,r=t.length-1,o="",s=t[0];if(r>0){for(o+=s,e=1;e<r;e++)i=t[e]+"",n=S-i.length,n&&(o+=ke(n)),o+=i;s=t[e],i=s+"",n=S-i.length,n&&(o+=ke(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function ne(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Be+t)}function We(t,e,n,i){var r,o,s,a;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=S,r=0):(r=Math.ceil((e+1)/S),e%=S),o=U(10,S-e),a=t[r]%o|0,i==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==o||n>3&&a+1==o/2)&&(t[r+1]/o/100|0)==U(10,e-2)-1||(a==o/2||a==0)&&(t[r+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(i||n<4)&&a==9999||!i&&n>3&&a==4999):s=((i||n<4)&&a+1==o||!i&&n>3&&a+1==o/2)&&(t[r+1]/o/1e3|0)==U(10,e-3)-1,s}function tt(t,e,n){for(var i,r=[0],o,s=0,a=t.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=kt.indexOf(t.charAt(s++)),i=0;i<r.length;i++)r[i]>n-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/n|0,r[i]%=n)}return r.reverse()}function yi(t,e){var n,i,r;if(e.isZero())return e;i=e.d.length,i<32?(n=Math.ceil(i/3),r=(1/at(4,n)).toString()):(n=16,r="2.3283064365386962890625e-10"),t.precision+=n,e=Me(t,1,e.times(r),new t(1));for(var o=n;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return t.precision-=n,e}var E=function(){function t(i,r,o){var s,a=0,c=i.length;for(i=i.slice();c--;)s=i[c]*r+a,i[c]=s%o|0,a=s/o|0;return a&&i.unshift(a),i}function e(i,r,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(i[a]!=r[a]){c=i[a]>r[a]?1:-1;break}return c}function n(i,r,o,s){for(var a=0;o--;)i[o]-=a,a=i[o]<r[o]?1:0,i[o]=a*s+i[o]-r[o];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,o,s,a,c){var u,l,m,d,b,g,y,T,C,N,I,R,L,M,Y,ae,ue,ce,G,te,$e=i.constructor,At=i.s==r.s?1:-1,Z=i.d,O=r.d;if(!Z||!Z[0]||!O||!O[0])return new $e(!i.s||!r.s||(Z?O&&Z[0]==O[0]:!O)?NaN:Z&&Z[0]==0||!O?At*0:At/0);for(c?(b=1,l=i.e-r.e):(c=pe,b=S,l=j(i.e/b)-j(r.e/b)),G=O.length,ue=Z.length,C=new $e(At),N=C.d=[],m=0;O[m]==(Z[m]||0);m++);if(O[m]>(Z[m]||0)&&l--,o==null?(M=o=$e.precision,s=$e.rounding):a?M=o+(i.e-r.e)+1:M=o,M<0)N.push(1),g=!0;else{if(M=M/b+2|0,m=0,G==1){for(d=0,O=O[0],M++;(m<ue||d)&&M--;m++)Y=d*c+(Z[m]||0),N[m]=Y/O|0,d=Y%O|0;g=d||m<ue}else{for(d=c/(O[0]+1)|0,d>1&&(O=t(O,d,c),Z=t(Z,d,c),G=O.length,ue=Z.length),ae=G,I=Z.slice(0,G),R=I.length;R<G;)I[R++]=0;te=O.slice(),te.unshift(0),ce=O[0],O[1]>=c/2&&++ce;do d=0,u=e(O,I,G,R),u<0?(L=I[0],G!=R&&(L=L*c+(I[1]||0)),d=L/ce|0,d>1?(d>=c&&(d=c-1),y=t(O,d,c),T=y.length,R=I.length,u=e(y,I,T,R),u==1&&(d--,n(y,G<T?te:O,T,c))):(d==0&&(u=d=1),y=O.slice()),T=y.length,T<R&&y.unshift(0),n(I,y,R,c),u==-1&&(R=I.length,u=e(O,I,G,R),u<1&&(d++,n(I,G<R?te:O,R,c))),R=I.length):u===0&&(d++,I=[0]),N[m++]=d,u&&I[0]?I[R++]=Z[ae]||0:(I=[Z[ae]],R=1);while((ae++<ue||I[0]!==void 0)&&M--);g=I[0]!==void 0}N[0]||N.shift()}if(b==1)C.e=l,mn=g;else{for(m=1,d=N[0];d>=10;d/=10)m++;C.e=m+l*b-1,k(C,a?o+C.e+1:o,s,g)}return C}}();function k(t,e,n,i){var r,o,s,a,c,u,l,m,d,b=t.constructor;e:if(e!=null){if(m=t.d,!m)return t;for(r=1,a=m[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=S,s=e,l=m[d=0],c=l/U(10,r-s-1)%10|0;else if(d=Math.ceil((o+1)/S),a=m.length,d>=a)if(i){for(;a++<=d;)m.push(0);l=c=0,r=1,o%=S,s=o-S+1}else break e;else{for(l=a=m[d],r=1;a>=10;a/=10)r++;o%=S,s=o-S+r,c=s<0?0:l/U(10,r-s-1)%10|0}if(i=i||e<0||m[d+1]!==void 0||(s<0?l:l%U(10,r-s-1)),u=n<4?(c||i)&&(n==0||n==(t.s<0?3:2)):c>5||c==5&&(n==4||i||n==6&&(o>0?s>0?l/U(10,r-s):0:m[d-1])%10&1||n==(t.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=t.e+1,m[0]=U(10,(S-e%S)%S),t.e=-e||0):m[0]=t.e=0,t;if(o==0?(m.length=d,a=1,d--):(m.length=d+1,a=U(10,S-o),m[d]=s>0?(l/U(10,r-s)%U(10,s)|0)*a:0),u)for(;;)if(d==0){for(o=1,s=m[0];s>=10;s/=10)o++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(t.e++,m[0]==pe&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=pe)break;m[d--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return K&&(t.e>b.maxE?(t.d=null,t.e=NaN):t.e<b.minE&&(t.e=0,t.d=[0])),t}function fe(t,e,n){if(!t.isFinite())return wn(t);var i,r=t.e,o=z(t.d),s=o.length;return e?(n&&(i=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+ke(i):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):r<0?(o="0."+ke(-r-1)+o,n&&(i=n-s)>0&&(o+=ke(i))):r>=s?(o+=ke(r+1-s),n&&(i=n-r-1)>0&&(o=o+"."+ke(i))):((i=r+1)<s&&(o=o.slice(0,i)+"."+o.slice(i)),n&&(i=n-s)>0&&(r+1===s&&(o+="."),o+=ke(i))),o}function st(t,e){var n=t[0];for(e*=S;n>=10;n/=10)e++;return e}function rt(t,e,n){if(e>bi)throw K=!0,n&&(t.precision=n),Error(dn);return k(new t(nt),e,1,!0)}function de(t,e,n){if(e>Bt)throw Error(dn);return k(new t(it),e,n,!0)}function yn(t){var e=t.length-1,n=e*S+1;if(e=t[e],e){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function ke(t){for(var e="";t--;)e+="0";return e}function gn(t,e,n,i){var r,o=new t(1),s=Math.ceil(i/S+4);for(K=!1;;){if(n%2&&(o=o.times(e),cn(o.d,s)&&(r=!0)),n=j(n/2),n===0){n=o.d.length-1,r&&o.d[n]===0&&++o.d[n];break}e=e.times(e),cn(e.d,s)}return K=!0,o}function un(t){return t.d[t.d.length-1]&1}function Pn(t,e,n){for(var i,r=new t(e[0]),o=0;++o<e.length;)if(i=new t(e[o]),i.s)r[n](i)&&(r=i);else{r=i;break}return r}function xt(t,e){var n,i,r,o,s,a,c,u=0,l=0,m=0,d=t.constructor,b=d.rounding,g=d.precision;if(!t.d||!t.d[0]||t.e>17)return new d(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:0/0);for(e==null?(K=!1,c=g):c=e,a=new d(.03125);t.e>-2;)t=t.times(a),m+=5;for(i=Math.log(U(2,m))/Math.LN10*2+5|0,c+=i,n=o=s=new d(1),d.precision=c;;){if(o=k(o.times(t),c,1),n=n.times(++l),a=s.plus(E(o,n,c,1)),z(a.d).slice(0,c)===z(s.d).slice(0,c)){for(r=m;r--;)s=k(s.times(s),c,1);if(e==null)if(u<3&&We(s.d,c-i,b,u))d.precision=c+=10,n=o=a=new d(1),l=0,u++;else return k(s,d.precision=g,b,K=!0);else return d.precision=g,s}s=a}}function he(t,e){var n,i,r,o,s,a,c,u,l,m,d,b=1,g=10,y=t,T=y.d,C=y.constructor,N=C.rounding,I=C.precision;if(y.s<0||!T||!T[0]||!y.e&&T[0]==1&&T.length==1)return new C(T&&!T[0]?-1/0:y.s!=1?NaN:T?0:y);if(e==null?(K=!1,l=I):l=e,C.precision=l+=g,n=z(T),i=n.charAt(0),Math.abs(o=y.e)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)y=y.times(t),n=z(y.d),i=n.charAt(0),b++;o=y.e,i>1?(y=new C("0."+n),o++):y=new C(i+"."+n.slice(1))}else return u=rt(C,l+2,I).times(o+""),y=he(new C(i+"."+n.slice(1)),l-g).plus(u),C.precision=I,e==null?k(y,I,N,K=!0):y;for(m=y,c=s=y=E(y.minus(1),y.plus(1),l,1),d=k(y.times(y),l,1),r=3;;){if(s=k(s.times(d),l,1),u=c.plus(E(s,new C(r),l,1)),z(u.d).slice(0,l)===z(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(rt(C,l+2,I).times(o+""))),c=E(c,new C(b),l,1),e==null)if(We(c.d,l-g,N,a))C.precision=l+=g,u=s=y=E(m.minus(1),m.plus(1),l,1),d=k(y.times(y),l,1),r=a=1;else return k(c,C.precision=I,N,K=!0);else return C.precision=I,c;c=u,r+=2}}function wn(t){return String(t.s*t.s/0)}function It(t,e){var n,i,r;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(n<0&&(n=i),n+=+e.slice(i+1),e=e.substring(0,i)):n<0&&(n=e.length),i=0;e.charCodeAt(i)===48;i++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(i,r),e){if(r-=i,t.e=n=n-i-1,t.d=[],i=(n+1)%S,n<0&&(i+=S),i<r){for(i&&t.d.push(+e.slice(0,i)),r-=S;i<r;)t.d.push(+e.slice(i,i+=S));e=e.slice(i),i=S-e.length}else i-=r;for(;i--;)e+="0";t.d.push(+e),K&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function gi(t,e){var n,i,r,o,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),bn.test(e))return It(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(di.test(e))n=16,e=e.toLowerCase();else if(mi.test(e))n=2;else if(pi.test(e))n=8;else throw Error(Be+e);for(o=e.search(/p/i),o>0?(c=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,i=t.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=gn(i,new i(n),o,o*2)),u=tt(e,n,pe),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new i(t.s*0):(t.e=st(u,l),t.d=u,K=!1,s&&(t=E(t,r,a*4)),c&&(t=t.times(Math.abs(c)<54?U(2,c):Ve.pow(2,c))),K=!0,t)}function Pi(t,e){var n,i=e.d.length;if(i<3)return e.isZero()?e:Me(t,2,e,e);n=1.4*Math.sqrt(i),n=n>16?16:n|0,e=e.times(1/at(5,n)),e=Me(t,2,e,e);for(var r,o=new t(5),s=new t(16),a=new t(20);n--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function Me(t,e,n,i,r){var o,s,a,c,u=1,l=t.precision,m=Math.ceil(l/S);for(K=!1,c=n.times(n),a=new t(i);;){if(s=E(a.times(c),new t(e++*e++),l,1),a=r?i.plus(s):i.minus(s),i=E(s.times(c),new t(e++*e++),l,1),s=a.plus(i),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=i,i=s,s=o,u++}return K=!0,s.d.length=m+1,s}function at(t,e){for(var n=t;--e;)n*=t;return n}function An(t,e){var n,i=e.s<0,r=de(t,t.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return Pe=i?4:1,e;if(n=e.divToInt(r),n.isZero())Pe=i?3:2;else{if(e=e.minus(n.times(r)),e.lte(o))return Pe=un(n)?i?2:3:i?4:1,e;Pe=un(n)?i?1:4:i?3:2}return e.minus(r).abs()}function St(t,e,n,i){var r,o,s,a,c,u,l,m,d,b=t.constructor,g=n!==void 0;if(g?(ne(n,1,xe),i===void 0?i=b.rounding:ne(i,0,8)):(n=b.precision,i=b.rounding),!t.isFinite())l=wn(t);else{for(l=fe(t),s=l.indexOf("."),g?(r=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):r=e,s>=0&&(l=l.replace(".",""),d=new b(1),d.e=l.length-s,d.d=tt(fe(d),10,r),d.e=d.d.length),m=tt(l,10,r),o=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=g?"0p+0":"0";else{if(s<0?o--:(t=new b(t),t.d=m,t.e=o,t=E(t,d,n,i,0,r),m=t.d,o=t.e,u=mn),s=m[n],a=r/2,u=u||m[n+1]!==void 0,u=i<4?(s!==void 0||u)&&(i===0||i===(t.s<0?3:2)):s>a||s===a&&(i===4||u||i===6&&m[n-1]&1||i===(t.s<0?8:7)),m.length=n,u)for(;++m[--n]>r-1;)m[n]=0,n||(++o,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=kt.charAt(m[s]);if(g){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=tt(l,r,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=kt.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>c)for(o-=c;o--;)l+="0";else o<c&&(l=l.slice(0,o)+"."+l.slice(o))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return t.s<0?"-"+l:l}function cn(t,e){if(t.length>e)return t.length=e,!0}function wi(t){return new this(t).abs()}function Ai(t){return new this(t).acos()}function Ti(t){return new this(t).acosh()}function ki(t,e){return new this(t).plus(e)}function hi(t){return new this(t).asin()}function Bi(t){return new this(t).asinh()}function xi(t){return new this(t).atan()}function Ii(t){return new this(t).atanh()}function Si(t,e){t=new this(t),e=new this(e);var n,i=this.precision,r=this.rounding,o=i+4;return!t.s||!e.s?n=new this(NaN):!t.d&&!e.d?(n=de(this,o,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?de(this,i,r):new this(0),n.s=t.s):!t.d||e.isZero()?(n=de(this,o,1).times(.5),n.s=t.s):e.s<0?(this.precision=o,this.rounding=1,n=this.atan(E(t,e,o,1)),e=de(this,o,1),this.precision=i,this.rounding=r,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(E(t,e,o,1)),n}function Ci(t){return new this(t).cbrt()}function Ki(t){return k(t=new this(t),t.e+1,2)}function Ni(t,e,n){return new this(t).clamp(e,n)}function Ri(t){if(!t||typeof t!="object")throw Error(ot+"Object expected");var e,n,i,r=t.defaults===!0,o=["precision",1,xe,"rounding",0,8,"toExpNeg",-Fe,0,"toExpPos",0,Fe,"maxE",0,Fe,"minE",-Fe,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(n=o[e],r&&(this[n]=ht[n]),(i=t[n])!==void 0)if(j(i)===i&&i>=o[e+1]&&i<=o[e+2])this[n]=i;else throw Error(Be+n+": "+i);if(n="crypto",r&&(this[n]=ht[n]),(i=t[n])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(pn);else this[n]=!1;else throw Error(Be+n+": "+i);return this}function Li(t){return new this(t).cos()}function Fi(t){return new this(t).cosh()}function Tn(t){var e,n,i;function r(o){var s,a,c,u=this;if(!(u instanceof r))return new r(o);if(u.constructor=r,ln(o)){u.s=o.s,K?!o.d||o.e>r.maxE?(u.e=NaN,u.d=null):o.e<r.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(c=typeof o,c==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;K?s>r.maxE?(u.e=NaN,u.d=null):s<r.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}else if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return It(u,o.toString())}else if(c!=="string")throw Error(Be+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),bn.test(o)?It(u,o):gi(u,o)}if(r.prototype=f,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Ri,r.clone=Tn,r.isDecimal=ln,r.abs=wi,r.acos=Ai,r.acosh=Ti,r.add=ki,r.asin=hi,r.asinh=Bi,r.atan=xi,r.atanh=Ii,r.atan2=Si,r.cbrt=Ci,r.ceil=Ki,r.clamp=Ni,r.cos=Li,r.cosh=Fi,r.div=Mi,r.exp=vi,r.floor=Ei,r.hypot=Oi,r.ln=Di,r.log=Wi,r.log10=_i,r.log2=Vi,r.max=qi,r.min=Gi,r.mod=Ui,r.mul=Xi,r.pow=zi,r.random=Hi,r.round=Yi,r.sign=Zi,r.sin=ji,r.sinh=Qi,r.sqrt=Ji,r.sub=$i,r.sum=er,r.tan=tr,r.tanh=nr,r.trunc=ir,t===void 0&&(t={}),t&&t.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)t.hasOwnProperty(n=i[e++])||(t[n]=this[n]);return r.config(t),r}function Mi(t,e){return new this(t).div(e)}function vi(t){return new this(t).exp()}function Ei(t){return k(t=new this(t),t.e+1,3)}function Oi(){var t,e,n=new this(0);for(K=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)n.d&&(n=n.plus(e.times(e)));else{if(e.s)return K=!0,new this(1/0);n=e}return K=!0,n.sqrt()}function ln(t){return t instanceof Ve||t&&t.toStringTag===fn||!1}function Di(t){return new this(t).ln()}function Wi(t,e){return new this(t).log(e)}function Vi(t){return new this(t).log(2)}function _i(t){return new this(t).log(10)}function qi(){return Pn(this,arguments,"lt")}function Gi(){return Pn(this,arguments,"gt")}function Ui(t,e){return new this(t).mod(e)}function Xi(t,e){return new this(t).mul(e)}function zi(t,e){return new this(t).pow(e)}function Hi(t){var e,n,i,r,o=0,s=new this(1),a=[];if(t===void 0?t=this.precision:ne(t,1,xe),i=Math.ceil(t/S),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));o<i;)r=e[o],r>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);o<i;)r=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(r%1e7),o+=4);o=i/4}else throw Error(pn);else for(;o<i;)a[o++]=Math.random()*1e7|0;for(i=a[--o],t%=S,i&&t&&(r=U(10,S-t),a[o]=(i/r|0)*r);a[o]===0;o--)a.pop();if(o<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=S)a.shift();for(i=1,r=a[0];r>=10;r/=10)i++;i<S&&(n-=S-i)}return s.e=n,s.d=a,s}function Yi(t){return k(t=new this(t),t.e+1,this.rounding)}function Zi(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function ji(t){return new this(t).sin()}function Qi(t){return new this(t).sinh()}function Ji(t){return new this(t).sqrt()}function $i(t,e){return new this(t).sub(e)}function er(){var t=0,e=arguments,n=new this(e[t]);for(K=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return K=!0,k(n,this.precision,this.rounding)}function tr(t){return new this(t).tan()}function nr(t){return new this(t).tanh()}function ir(t){return k(t=new this(t),t.e+1,1)}f[Symbol.for("nodejs.util.inspect.custom")]=f.toString;f[Symbol.toStringTag]="Decimal";var Ve=f.constructor=Tn(ht);nt=new Ve(nt);it=new Ve(it);var F=Ve;import mr from"big.js";import As from"bn.js";import rr from"toformat";var or=rr,_e=or;import ct from"big.js";import ar from"bn.js";import ur from"decimal.js-light";import qe from"bn.js";var kn=9007199254740991;function be(t){let e=ee("Raydium_parseBigNumberish");if(t instanceof qe)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new qe(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=kn||t<=-kn)&&e.logWithError(`BigNumberish number overflow: ${t}`),new qe(String(t))):typeof t=="bigint"?new qe(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new qe(0))}var ut=ee("module/fraction"),Ct=_e(ct),Ge=_e(ur),cr={[0]:Ge.ROUND_DOWN,[1]:Ge.ROUND_HALF_UP,[2]:Ge.ROUND_UP},lr={[0]:ct.roundDown,[1]:ct.roundHalfUp,[2]:ct.roundUp},W=class{constructor(e,n=new ar(1)){this.numerator=be(e),this.denominator=be(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new W(this.denominator,this.numerator)}add(e){let n=e instanceof W?e:new W(be(e));return this.denominator.eq(n.denominator)?new W(this.numerator.add(n.numerator),this.denominator):new W(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof W?e:new W(be(e));return this.denominator.eq(n.denominator)?new W(this.numerator.sub(n.numerator),this.denominator):new W(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof W?e:new W(be(e));return new W(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof W?e:new W(be(e));return new W(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},i=1){Number.isInteger(e)||ut.logWithError(`${e} is not an integer.`),e<=0&&ut.logWithError(`${e} is not positive.`),Ge.set({precision:e+1,rounding:cr[i]});let r=new Ge(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),n)}toFixed(e,n={groupSeparator:""},i=1){return Number.isInteger(e)||ut.logWithError(`${e} is not an integer.`),e<0&&ut.logWithError(`${e} is negative.`),Ct.DP=e,Ct.RM=lr[i]||1,new Ct(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var Ks=ee("Raydium_amount"),Ns=_e(mr);import{PublicKey as pr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as hn}from"@solana/spl-token";var Kt={chainId:101,address:pr.default.toBase58(),programId:hn.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},Ie={chainId:101,address:"So11111111111111111111111111111111111111112",programId:hn.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};import{PublicKey as Rt}from"@solana/web3.js";import{PublicKey as V,SystemProgram as Bn,SYSVAR_RENT_PUBKEY as fr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as br}from"@solana/spl-token";function Nt({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var Ds=[Nt({pubkey:br,isWritable:!1}),Nt({pubkey:Bn.programId,isWritable:!1}),Nt({pubkey:fr,isWritable:!1})];function xn({publicKey:t,transformSol:e}){let n=In(t.toString());if(n instanceof V)return e&&n.equals(Ue)?et:n;if(e&&n.toString()===Ue.toBase58())return et;if(typeof n=="string"){if(n===V.default.toBase58())return V.default;try{return new V(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function In(t){try{return new V(t)}catch{return t}}var yr=new V("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),gr=new V("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),lt=new V("SysvarRent111111111111111111111111111111111"),Ws=new V("SysvarC1ock11111111111111111111111111111111"),Xe=new V("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Vs=new V("Sysvar1nstructions1111111111111111111111111"),_s=Bn.programId,qs=new V("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Gs=new V("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Us=new V("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Xs=new V("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),zs=new V("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Hs=new V("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Ys=new V("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Zs=new V("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),js=new V("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Qs=new V("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Js=new V("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),et=new V("So11111111111111111111111111111111111111112"),Ue=V.default;var Lt=class{constructor({mint:e,decimals:n,symbol:i,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===Ue.toBase58()||e instanceof Rt&&Ue.equals(e)){this.decimals=Ie.decimals,this.symbol=Ie.symbol,this.name=Ie.name,this.mint=new Rt(Ie.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=i||e.toString().substring(0,6),this.name=r||e.toString().substring(0,6),this.mint=o?Rt.default:xn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Se=Lt;Se.WSOL=new Lt(q(D({},Ie),{mint:Ie.address}));var Ft=class{constructor({decimals:e,symbol:n="UNKNOWN",name:i="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=i}equals(e){return this===e}},mt=Ft;mt.SOL=new Ft(Kt);import Pr from"bn.js";var la=new W(new Pr(100));var ya=ee("Raydium_price");var wr=new ye(0),Ua=new ye(1),Xa=new ye(2),za=new ye(3),Ha=new ye(5),dr=new ye(10),Ya=new ye(100),Za=new ye(1e3),ja=new ye(1e4);function Sn(t,e,n){return t.mul(e).add(n).sub(new ye(1)).div(n)}import{PublicKey as Au}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as ku}from"@solana/spl-token";import{ComputeBudgetProgram as ru,Keypair as au,PublicKey as Ar,Transaction as cu,TransactionMessage as mu,VersionedTransaction as du}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as yu}from"@solana/spl-token";var gu=ee("Raydium_txUtil");function ie(t,e){let[n,i]=Ar.findProgramAddressSync(t,e);return{publicKey:n,nonce:i}}import{PublicKey as h}from"@solana/web3.js";var Iu=new h("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),Su=new h("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),Cu=new h("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Ku=new h("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Nu=new h("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Ru=new h("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Lu=new h("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Fu=new h("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Mu=new h("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),vu=new h("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Tr=new h("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),kr=new h("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),hr=new h("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),Eu=new h("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Ou=new h("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),Du=new h("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),Wu=new h("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Vu=new h("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),_u=new h("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),qu=new h("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),Gu=new h("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Uu=new h("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),Xu=new h("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),zu=new h("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Hu=new h("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),Br=new h("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),Yu=new h("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),Zu=new h("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),ju=new h("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),Qu=new h("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),Ju=new h("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var $u={OPEN_BOOK_PROGRAM:new h("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new h("Ray1111111111111111111111111111111111111111"),AMM_V4:new h("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new h("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new h("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new h("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new h("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new h("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new h("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new h("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new h("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new h("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:h.default,Router:new h("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new h("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new h("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new h("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new h("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new h("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new h("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new h("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new h("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new h("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new h("Ray1111111111111111111111111111111111111111")};import Q from"bn.js";var ze=1e4;function Ot(t,e){let{div:n,mod:i}=t.divmod(e);return i.gt(new Q(0))?n.add(new Q(1)):n}function Ne(t,e){if(t.isZero())return new Q(0);let n=t.div(e);return n.isZero()?new Q(1):t.mod(e).gt(new Q(0))?n.add(new Q(1)):n}function Dt(t,e,n){if(e===void 0)return{amount:t,fee:void 0,expirationTime:void 0};let i=Math.floor(n/432e3),r=i<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,o=new Q(r.maximumFee.toString()),s=i<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*432e3-n)*400/1e3:void 0,a=Ot(t.mul(new Q(r.transferFeeBasisPoints)),new Q(ze)),c=a.gt(o)?o:a;return{amount:t,fee:c,expirationTime:s}}function Wt(t,e,n){if(e===void 0)return{amount:t,fee:void 0,expirationTime:void 0};let i=Math.floor(n/432e3),r=i<e.newerTransferFee.epoch?e.olderTransferFee:e.newerTransferFee,o=new Q(r.maximumFee.toString()),s=i<e.newerTransferFee.epoch?(Number(e.newerTransferFee.epoch)*432e3-n)*400/1e3:void 0;if(r.transferFeeBasisPoints===ze){let a=new Q(r.maximumFee.toString());return{amount:t.add(a),fee:a,expirationTime:s}}else{let a=Ot(t.mul(new Q(ze)),new Q(ze-r.transferFeeBasisPoints)),c=new Q(r.maximumFee.toString()),u=a.sub(t).gt(c)?t.add(c):a,l=Ot(u.mul(new Q(r.transferFeeBasisPoints)),new Q(ze)),m=l.gt(o)?o:l;return{amount:u,fee:m,expirationTime:s}}}import{PublicKey as oc,AddressLookupTableAccount as sc}from"@solana/web3.js";import{PublicKey as Tc,sendAndConfirmTransaction as kc,SystemProgram as xc,Transaction as Ic,TransactionMessage as Cc,VersionedTransaction as Kc}from"@solana/web3.js";import Rc from"axios";import{PublicKey as Dc}from"@solana/web3.js";import Vc from"bn.js";import xr from"bn.js";var Re=new xr(1e6);import{PublicKey as Er}from"@solana/web3.js";import Mn,{isBN as vn}from"bn.js";import{bits as dl,BitStructure as pl,blob as Ir,Blob as fl,cstr as bl,f32 as yl,f32be as gl,f64 as Pl,f64be as wl,greedy as Al,Layout as Sr,ns64 as Tl,ns64be as kl,nu64 as hl,nu64be as Bl,offset as Cr,s16 as xl,s16be as Il,s24 as Sl,s24be as Cl,s32 as Kr,s32be as Kl,s40 as Nl,s40be as Rl,s48 as Ll,s48be as Fl,s8 as Ml,seq as Nr,struct as vl,Structure as Rr,u16 as Lr,u16be as El,u24 as Ol,u24be as Dl,u32 as Fr,u32be as Wl,u40 as Vl,u40be as _l,u48 as ql,u48be as Gl,u8 as Mr,UInt as vr,union as Ul,Union as Xl,unionLayoutDiscriminator as zl,utf8 as Hl}from"@solana/buffer-layout";var Vt=Sr,Rn=Rr;var _t=vr;var Ln=Mr,we=Lr;var qt=Fr;var Ae=Kr;var Fn=Nr;var re=Ir;var Gt=Cr;var ve=class extends Vt{constructor(n,i,r){super(n,r);this.blob=re(n),this.signed=i}decode(n,i=0){let r=new Mn(this.blob.decode(n,i),10,"le");return this.signed?r.fromTwos(this.span*8).clone():r}encode(n,i,r=0){return typeof n=="number"&&(n=new Mn(n)),this.signed&&(n=n.toTwos(this.span*8)),this.blob.encode(n.toArrayLike(Buffer,"le",this.span),i,r)}};function P(t){return new _t(1,t)}function Ee(t){return new _t(4,t)}function p(t){return new ve(8,!1,t)}function _(t){return new ve(16,!1,t)}function En(t){return new ve(8,!0,t)}function On(t){return new ve(16,!0,t)}var Le=class extends Vt{constructor(n,i,r,o){super(n.span,o);this.layout=n,this.decoder=i,this.encoder=r}decode(n,i){return this.decoder(this.layout.decode(n,i))}encode(n,i,r){return this.layout.encode(this.encoder(n),i,r)}getSpan(n,i){return this.layout.getSpan(n,i)}};function B(t){return new Le(re(32),e=>new Er(e),e=>e.toBuffer(),t)}function Xt(t){return new Le(Ln(),Or,Dr,t)}function Or(t){if(t===0)return!1;if(t===1)return!0;throw new Error("Invalid bool: "+t)}function Dr(t){return t?1:0}function Dn(t,e){let n=qt("length"),i=x([n,v(t,Gt(n,-n.span),"values")]);return new Le(i,({values:r})=>r,r=>({values:r}),e)}function Wr(t){let e=qt("length"),n=x([e,re(Gt(e,-e.span),"data")]);return new Le(n,({data:i})=>i,i=>({data:i}),t)}function H(t){return new Le(Wr(),e=>e.toString("utf-8"),e=>Buffer.from(e,"utf-8"),t)}var Ut=class extends Rn{decode(e,n){return super.decode(e,n)}};function x(t,e,n){return new Ut(t,e,n)}function v(t,e,n){let i,r=typeof e=="number"?e:vn(e)?e.toNumber():new Proxy(e,{get(o,s){if(!i){let a=Reflect.get(o,"count");i=vn(a)?a.toNumber():a,Reflect.set(o,"count",i)}return Reflect.get(o,s)},set(o,s,a){return s==="count"&&(i=a),Reflect.set(o,s,a)}});return Fn(t,r,n)}import{ASSOCIATED_TOKEN_PROGRAM_ID as ft,TOKEN_2022_PROGRAM_ID as xo,TOKEN_PROGRAM_ID as je}from"@solana/spl-token";import{SystemProgram as oe,TransactionInstruction as J}from"@solana/web3.js";import Te from"bn.js";var Vr=x([p(),p("epoch"),P("curveType"),we("index"),p("migrateFee"),p("tradeFeeRate"),p("maxShareFeeRate"),p("minSupplyA"),p("maxLockRate"),p("minSellRateA"),p("minMigrateRateA"),p("minFundRaisingB"),B("mintB"),B("protocolFeeOwner"),B("migrateFeeOwner"),B("migrateToAmmWallet"),B("migrateToCpmmWallet"),v(p(),16)]),_r=x([p("totalLockedAmount"),p("cliffPeriod"),p("unlockPeriod"),p("startTime"),p("totalAllocatedShare")]),qr=x([p(),p("epoch"),P("bump"),P("status"),P("mintDecimalsA"),P("mintDecimalsB"),P("migrateType"),p("supply"),p("totalSellA"),p("virtualA"),p("virtualB"),p("realA"),p("realB"),p("totalFundRaisingB"),p("protocolFee"),p("platformFee"),p("migrateFee"),_r.replicate("vestingSchedule"),B("configId"),B("platformId"),B("mintA"),B("mintB"),B("vaultA"),B("vaultB"),B("creator"),P("mintProgramFlag"),P("cpmmCreatorFeeOn"),v(P(),62)]),om=x([p(),p("epoch"),B("poolId"),B("beneficiary"),p("claimedAmount"),p("tokenShareAmount"),v(p(),8)]),zt=x([P("migrateType"),P("migrateCpmmFeeOn"),p("supply"),p("totalSellA"),p("totalFundRaisingB"),p("totalLockedAmount"),p("cliffPeriod"),p("unlockPeriod")]),Gr=x([p("epoch"),P("index"),B("configId"),zt.replicate("bondingCurveParam"),v(p(),50)]),Ur=x([p(),p("epoch"),B("platformClaimFeeWallet"),B("platformLockNftWallet"),p("platformScale"),p("creatorScale"),p("burnScale"),p("feeRate"),v(P(),64,"name"),v(P(),256,"web"),v(P(),256,"img"),B("cpConfigId"),p("creatorFeeRate"),B("transferFeeExtensionAuth"),v(P(),180),Dn(Gr,"platformCurve")]);import{PublicKey as rf}from"@solana/web3.js";import sf from"bn.js";import{AccountLayout as lf,createAssociatedTokenAccountIdempotentInstruction as mf,TOKEN_2022_PROGRAM_ID as df,TOKEN_PROGRAM_ID as pf}from"@solana/spl-token";import{PublicKey as cm}from"@solana/web3.js";import{MintLayout as mm,TOKEN_PROGRAM_ID as pm}from"@solana/spl-token";import{Keypair as Sp,PublicKey as Cp,SystemProgram as Np,TransactionInstruction as Rp}from"@solana/web3.js";import Fp from"bn.js";import{ASSOCIATED_TOKEN_PROGRAM_ID as Ep,TOKEN_2022_PROGRAM_ID as Op,TOKEN_PROGRAM_ID as Dp}from"@solana/spl-token";import ap from"bn.js";import le from"bn.js";var Ht=new le(0),Wn=new le(1),Vn=new le(-1),ge=new le(1).shln(64),_n=new le(1).shln(128),Yt=ge.sub(Wn);var Xr=_n.subn(1),Oe=-443636,He=-Oe,Zt=new le("4295048016"),jt=new le("79226673521066979257578248091"),xm=new le("4295048017"),Im=new le("79226673521066979257578248090");var zr=new le(10).pow(new le(6));var Sm=new le("18446744073700000000");import Hd from"bn.js";function Qt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t,!1),new Uint8Array(e)}var Fm=Buffer.from("amm_config","utf8"),qn=Buffer.from("pool","utf8"),Gn=Buffer.from("pool_vault","utf8"),Mm=Buffer.from("pool_reward_vault","utf8"),vm=Buffer.from("position","utf8"),Em=Buffer.from("tick_array","utf8"),Om=Buffer.from("operation","utf8"),Dm=Buffer.from("pool_tick_array_bitmap_extension","utf8"),Wm=Buffer.from("observation","utf8");var Vm=Buffer.from("locked_position","utf8");var _m=Buffer.from("support_mint","utf8");import{PublicKey as Ad}from"@solana/web3.js";import{TOKEN_2022_PROGRAM_ID as kd}from"@solana/spl-token";import Bd from"bn.js";import Um from"bn.js";var en=14;var pt=60;var jr=x([re(8),P("bump"),we("index"),B(""),Ee("protocolFeeRate"),Ee("tradeFeeRate"),we("tickSpacing"),v(p(),8,"")]),Qr=x([Ee("blockTimestamp"),En("tickCumulative"),v(p(),4)]),ei=x([re(8),Xt("initialized"),p("recentEpoch"),we("observationIndex"),B("poolId"),v(Qr,100,"observations"),v(p(),4)]),Jr=x([P("rewardState"),p("openTime"),p("endTime"),p("lastUpdateTime"),_("emissionsPerSecondX64"),p("rewardTotalEmissioned"),p("rewardClaimed"),B("tokenMint"),B("tokenVault"),B("creator"),_("rewardGrowthGlobalX64")]),Qn=x([re(8),P("bump"),B("ammConfig"),B("creator"),B("mintA"),B("mintB"),B("vaultA"),B("vaultB"),B("observationId"),P("mintDecimalsA"),P("mintDecimalsB"),we("tickSpacing"),_("liquidity"),_("sqrtPriceX64"),Ae("tickCurrent"),Ee(),_("feeGrowthGlobalX64A"),_("feeGrowthGlobalX64B"),p("protocolFeesTokenA"),p("protocolFeesTokenB"),_("swapInAmountTokenA"),_("swapOutAmountTokenB"),_("swapInAmountTokenB"),_("swapOutAmountTokenA"),P("status"),v(P(),7,""),v(Jr,3,"rewardInfos"),v(p(),16,"tickArrayBitmap"),p("totalFeesTokenA"),p("totalFeesClaimedTokenA"),p("totalFeesTokenB"),p("totalFeesClaimedTokenB"),p("fundFeesTokenA"),p("fundFeesTokenB"),p("startTime"),v(p(),15*4-3,"padding")]),$r=x([_("growthInsideLastX64"),p("rewardAmountOwed")]),Jn=x([re(8),P("bump"),B("nftMint"),B("poolId"),Ae("tickLower"),Ae("tickUpper"),_("liquidity"),_("feeGrowthInsideLastX64A"),_("feeGrowthInsideLastX64B"),p("tokenFeesOwedA"),p("tokenFeesOwedB"),v($r,3,"rewardInfos"),v(p(),8,"")]),gp=x([re(8),P("bump"),B("poolId"),Ae("tickLowerIndex"),Ae("tickUpperIndex"),_("liquidity"),_("feeGrowthInsideLastX64A"),_("feeGrowthInsideLastX64B"),p("tokenFeesOwedA"),p("tokenFeesOwedB"),v(_(),3,"rewardGrowthInside"),v(p(),8,"")]),eo=x([Ae("tick"),On("liquidityNet"),_("liquidityGross"),_("feeGrowthOutsideX64A"),_("feeGrowthOutsideX64B"),v(_(),3,"rewardGrowthsOutsideX64"),v(Ee(),13,"")]),Hn=x([re(8),B("poolId"),Ae("startTickIndex"),v(eo,pt,"ticks"),P("initializedTickCount"),v(P(),115,"")]),to=x([re(329),v(B(),100,"whitelistMints")]),Zr=x([re(8),B("poolId"),v(v(p(),8),en,"positiveTickArrayBitmap"),v(v(p(),8),en,"negativeTickArrayBitmap")]),Pp=x([p(),P("bump"),B("owner"),B("poolId"),B("positionId"),B("nftAccount"),v(p(),8)]),no=x([re(8),P("bump"),B("lockOwner"),B("poolId"),B("positionId"),B("nftAccount"),B("lockNftMint"),p("recentEpoch"),v(p(),8)]);ei.span;var Hp=ee("Raydium_Clmm");var uo=Buffer.from("vault_auth_seed","utf8"),co=Buffer.from("global_config","utf8"),lo=Buffer.from("pool_vesting","utf8"),mo=Buffer.from("platform_config","utf8"),po=Buffer.from("platform_fee_vault_auth_seed","utf8"),fo=Buffer.from("creator_fee_vault_auth_seed","utf8");function bo(t){return ie([uo],t)}function Jf(t,e,n,i){return ie([co,e.toBuffer(),Po(n),Qt(i)],t)}function yo(t,e,n){return ie([qn,e.toBuffer(),n.toBuffer()],t)}function go(t,e,n){return ie([Gn,e.toBuffer(),n.toBuffer()],t)}function Ce(t){return ie([Buffer.from("__event_authority","utf8")],t)}function Po(t){let e=new ArrayBuffer(1);return new DataView(e).setUint8(0,t),new Uint8Array(e)}function wo(t,e){return ie([mo,e.toBuffer()],t)}function Ao(t,e,n){return ie([lo,e.toBuffer(),n.toBuffer()],t)}function To(t,e,n){return ie([e.toBuffer(),n.toBuffer()],t)}function ko(t){return ie([po],t)}function ho(t,e,n){return ie([e.toBuffer(),n.toBuffer()],t)}function Bo(t){return ie([fo],t)}var $={initialize:Buffer.from([175,175,109,31,13,152,155,237]),initializeV2:Buffer.from([67,153,175,39,218,16,38,32]),buyExactIn:Buffer.from([250,234,13,123,213,156,19,236]),buyExactOut:Buffer.from([24,211,116,40,105,3,153,56]),sellExactIn:Buffer.from([149,39,222,155,211,124,152,26]),sellExactOut:Buffer.from([95,200,71,34,8,9,11,166]),createVestingAccount:Buffer.from([129,178,2,13,217,172,230,218]),claimVestedToken:Buffer.from([49,33,104,30,189,157,79,35]),createPlatformConfig:Buffer.from([176,90,196,175,253,113,220,20]),claimPlatformFee:Buffer.from([156,39,208,135,76,237,61,72]),updatePlaformConfig:Buffer.from([195,60,76,129,146,45,67,143]),initializeWithToken2022:Buffer.from([37,190,126,222,44,154,171,17]),claimPlatformFeeFromVault:Buffer.from([117,241,198,168,248,218,80,29]),claimCreatorFee:Buffer.from([26,97,138,203,132,171,141,252]),updatePlatformCurveParam:Buffer.from([138,144,138,250,220,128,4,57]),removePlatformCurveParam:Buffer.from([27,30,62,169,93,224,24,145])};function lb(t,e,n,i,r,o,s,a,c,u,l,m,d,b,g,y,T,C,N,I){throw new Error("*** launchlab initialize has been deprecated, please use initializeV2 instead! ***")}function Io(t,e,n,i,r,o,s,a,c,u,l,m,d,b,g,y,T,C,N,I,R){let L=x([P("decimals"),H("name"),H("symbol"),H("uri")]),M=x([p("totalLockedAmount"),p("cliffPeriod"),p("unlockPeriod"),P("cpmmCreatorFeeOn")]),Y=x([P("index"),p("supply"),p("totalFundRaisingB"),P("migrateType")]),ae=x([P("index"),p("supply"),p("totalSellA"),p("totalFundRaisingB"),P("migrateType")]),ue=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!0,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!0},{pubkey:m,isSigner:!1,isWritable:!0},{pubkey:je,isSigner:!1,isWritable:!1},{pubkey:je,isSigner:!1,isWritable:!1},{pubkey:Xe,isSigner:!1,isWritable:!1},{pubkey:oe.programId,isSigner:!1,isWritable:!1},{pubkey:lt,isSigner:!1,isWritable:!1},{pubkey:Ce(t).publicKey,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!1,isWritable:!1}],ce=Buffer.alloc(Buffer.from(b,"utf-8").length+Buffer.from(g,"utf-8").length+Buffer.from(y,"utf-8").length+4*3+1),G=Buffer.alloc(M.span),te=Buffer.alloc(T.type==="ConstantCurve"?ae.span:Y.span);return L.encode({decimals:d,name:b,symbol:g,uri:y},ce),T.type==="ConstantCurve"?ae.encode(q(D({index:0},T),{migrateType:T.migrateType==="amm"?0:1}),te):T.type==="FixedCurve"?Y.encode(q(D({index:1},T),{migrateType:T.migrateType==="amm"?0:1}),te):T.type==="LinearCurve"&&Y.encode(q(D({index:2},T),{migrateType:T.migrateType==="amm"?0:1}),te),M.encode({totalLockedAmount:C,cliffPeriod:N,unlockPeriod:I,cpmmCreatorFeeOn:R},G),new J({keys:ue,programId:t,data:Buffer.from([...$.initializeV2,...ce,...te,...G])})}function So(t,e,n,i,r,o,s,a,c,u,l,m,d,b,g,y,T,C,N,I,R){let L=x([P("decimals"),H("name"),H("symbol"),H("uri")]),M=x([p("totalLockedAmount"),p("cliffPeriod"),p("unlockPeriod"),P("cpmmCreatorFeeOn"),P("transferFeeExtensionParamsOption"),x([we("transferFeeBasePoints"),p("maxinumFee")]).replicate("transferFeeExtensionParams")]),Y=x([P("index"),p("supply"),p("totalFundRaisingB"),P("migrateType")]),ae=x([P("index"),p("supply"),p("totalSellA"),p("totalFundRaisingB"),P("migrateType")]),ue=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!0,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!0},{pubkey:xo,isSigner:!1,isWritable:!1},{pubkey:je,isSigner:!1,isWritable:!1},{pubkey:oe.programId,isSigner:!1,isWritable:!1},{pubkey:Ce(t).publicKey,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!1,isWritable:!1}],ce=Buffer.alloc(Buffer.from(d,"utf-8").length+Buffer.from(b,"utf-8").length+Buffer.from(g,"utf-8").length+4*3+1),G=Buffer.alloc(M.span),te=Buffer.alloc(y.type==="ConstantCurve"?ae.span:Y.span);return L.encode({decimals:m,name:d,symbol:b,uri:g},ce),y.type==="ConstantCurve"?ae.encode(q(D({index:0},y),{migrateType:y.migrateType==="amm"?0:1}),te):y.type==="FixedCurve"?Y.encode(q(D({index:1},y),{migrateType:y.migrateType==="amm"?0:1}),te):y.type==="LinearCurve"&&Y.encode(q(D({index:2},y),{migrateType:y.migrateType==="amm"?0:1}),te),M.encode({totalLockedAmount:T,cliffPeriod:C,unlockPeriod:N,cpmmCreatorFeeOn:I,transferFeeExtensionParamsOption:R?1:0,transferFeeExtensionParams:R!=null?R:{transferFeeBasePoints:0,maxinumFee:new Te(0)}},G),new J({keys:ue,programId:t,data:Buffer.from([...$.initializeWithToken2022,...ce,...te,...G])})}function Co(t,e,n,i,r,o,s,a,c,u,l,m,d,b,g,y,T,C,N,I){let R=x([p("amountB"),p("minAmountA"),p("shareFeeRate")]),L=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!1},{pubkey:m,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!1,isWritable:!1},{pubkey:b,isSigner:!1,isWritable:!1},{pubkey:Ce(t).publicKey,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!1,isWritable:!1}];I&&L.push({pubkey:I,isSigner:!1,isWritable:!0}),L.push({pubkey:oe.programId,isSigner:!1,isWritable:!1}),L.push({pubkey:g,isSigner:!1,isWritable:!0}),L.push({pubkey:y,isSigner:!1,isWritable:!0});let M=Buffer.alloc(R.span);return R.encode({amountB:T,minAmountA:C,shareFeeRate:N!=null?N:new Te(0)},M),new J({keys:L,programId:t,data:Buffer.from([...$.buyExactIn,...M])})}function Ko(t,e,n,i,r,o,s,a,c,u,l,m,d,b,g,y,T,C,N,I){let R=x([p("amountA"),p("maxAmountB"),p("shareFeeRate")]),L=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!1},{pubkey:m,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!1,isWritable:!1},{pubkey:b,isSigner:!1,isWritable:!1},{pubkey:Ce(t).publicKey,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!1,isWritable:!1}];I&&L.push({pubkey:I,isSigner:!1,isWritable:!0}),L.push({pubkey:oe.programId,isSigner:!1,isWritable:!1}),L.push({pubkey:g,isSigner:!1,isWritable:!0}),L.push({pubkey:y,isSigner:!1,isWritable:!0});let M=Buffer.alloc(R.span);return R.encode({amountA:T,maxAmountB:C,shareFeeRate:N!=null?N:new Te(0)},M),new J({keys:L,programId:t,data:Buffer.from([...$.buyExactOut,...M])})}function No(t,e,n,i,r,o,s,a,c,u,l,m,d,b,g,y,T,C,N,I){let R=x([p("amountA"),p("minAmountB"),p("shareFeeRate")]),L=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!1},{pubkey:m,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!1,isWritable:!1},{pubkey:b,isSigner:!1,isWritable:!1},{pubkey:Ce(t).publicKey,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!1,isWritable:!1}];I&&L.push({pubkey:I,isSigner:!1,isWritable:!0}),L.push({pubkey:oe.programId,isSigner:!1,isWritable:!1}),L.push({pubkey:g,isSigner:!1,isWritable:!0}),L.push({pubkey:y,isSigner:!1,isWritable:!0});let M=Buffer.alloc(R.span);return R.encode({amountA:T,minAmountB:C,shareFeeRate:N!=null?N:new Te(0)},M),new J({keys:L,programId:t,data:Buffer.from([...$.sellExactIn,...M])})}function Ro(t,e,n,i,r,o,s,a,c,u,l,m,d,b,g,y,T,C,N,I){let R=x([p("amountB"),p("maxAmountA"),p("shareFeeRate")]),L=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!1},{pubkey:m,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!1,isWritable:!1},{pubkey:b,isSigner:!1,isWritable:!1},{pubkey:Ce(t).publicKey,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!1,isWritable:!1}];I&&L.push({pubkey:I,isSigner:!1,isWritable:!0}),L.push({pubkey:oe.programId,isSigner:!1,isWritable:!1}),L.push({pubkey:g,isSigner:!1,isWritable:!0}),L.push({pubkey:y,isSigner:!1,isWritable:!0});let M=Buffer.alloc(R.span);return R.encode({amountB:T,maxAmountA:C,shareFeeRate:N!=null?N:new Te(0)},M),new J({keys:L,programId:t,data:Buffer.from([...$.sellExactOut,...M])})}function Lo(t,e,n,i,r,o,s,a,c){let u=x([]),l=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:c,isSigner:!1,isWritable:!1},{pubkey:oe.programId,isSigner:!1,isWritable:!1},{pubkey:ft,isSigner:!1,isWritable:!1}],m=Buffer.alloc(u.span);return u.encode({},m),new J({keys:l,programId:t,data:Buffer.from([...$.claimVestedToken,...m])})}function Fo(t,e,n,i,r,o){let s=x([p("shareAmount")]),a=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:oe.programId,isSigner:!1,isWritable:!1}],c=Buffer.alloc(s.span);return s.encode({shareAmount:o},c),new J({keys:a,programId:t,data:Buffer.from([...$.createVestingAccount,...c])})}function Mo(t,e,n,i,r,o,s,a,c){let u=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:oe.programId,isSigner:!1,isWritable:!0},{pubkey:ft,isSigner:!1,isWritable:!0}];return new J({keys:u,programId:t,data:$.claimPlatformFee})}function vo(t,e,n,i,r,o,s,a,c,u,l,m,d){let b=x([p("platformScale"),p("creatorScale"),p("burnScale"),p("feeRate"),H("name"),H("web"),H("img"),p("creatorFeeRate")]),g=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:oe.programId,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1}],y=Buffer.alloc(8*5+Buffer.from(l,"utf-8").length+Buffer.from(m,"utf-8").length+Buffer.from(d,"utf-8").length+4*3);return b.encode({platformScale:a.platformScale,creatorScale:a.creatorScale,burnScale:a.burnScale,feeRate:c,name:l,web:m,img:d,creatorFeeRate:u},y),new J({keys:g,programId:t,data:Buffer.from([...$.createPlatformConfig,...y])})}function Eo(t,e,n,i){let r=[{pubkey:e,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!0}],o;if(i.type==="updateClaimFeeWallet"){let s=x([P("index"),B("value")]);o=Buffer.alloc(s.span),s.encode({index:0,value:i.value},o)}else if(i.type==="updateLockNftWallet"){let s=x([P("index"),B("value")]);o=Buffer.alloc(s.span),s.encode({index:1,value:i.value},o)}else if(i.type==="migrateCpLockNftScale"){let s=x([P("index"),p("platformScale"),p("creatorScale"),p("burnScale")]);o=Buffer.alloc(s.span),s.encode(D({index:2},i.value),o)}else if(i.type==="updateFeeRate"){let s=x([P("index"),p("value")]);o=Buffer.alloc(s.span),s.encode({index:3,value:i.value},o)}else if(i.type==="updateImg"||i.type==="updateName"||i.type==="updateWeb"){let s=x([P("index"),H("value")]);o=Buffer.alloc(Buffer.from(i.value,"utf-8").length+4+1*1),i.type==="updateName"?s.encode({index:4,value:i.value},o):i.type==="updateWeb"?s.encode({index:5,value:i.value},o):i.type==="updateImg"&&s.encode({index:6,value:i.value},o)}else if(i.type==="updateCpConfigId"){r.push({pubkey:i.value,isSigner:!1,isWritable:!1});let s=x([P("index")]);o=Buffer.alloc(s.span),s.encode({index:7},o)}else if(i.type==="updateAll"){r.push({pubkey:i.value.cpConfigId,isSigner:!1,isWritable:!1});let s=x([P("index"),B("platformClaimFeeWallet"),B("platformLockNftWallet"),p("platformScale"),p("creatorScale"),p("burnScale"),p("feeRate"),H("name"),H("web"),H("img"),B("transferFeeExtensionAuth"),p("creatorFeeRate")]);o=Buffer.alloc(1+32+32+8*4+4*3+Buffer.from(i.value.name,"utf-8").length+Buffer.from(i.value.web,"utf-8").length+Buffer.from(i.value.img,"utf-8").length+32+8),s.encode({index:8,platformClaimFeeWallet:i.value.platformClaimFeeWallet,platformLockNftWallet:i.value.platformLockNftWallet,platformScale:i.value.migrateCpLockNftScale.platformScale,creatorScale:i.value.migrateCpLockNftScale.creatorScale,burnScale:i.value.migrateCpLockNftScale.burnScale,feeRate:i.value.feeRate,name:i.value.name,web:i.value.web,img:i.value.img,transferFeeExtensionAuth:i.value.transferFeeExtensionAuth,creatorFeeRate:i.value.creatorFeeRate},o)}else throw Error("updateInfo params type error");return new J({keys:r,programId:t,data:Buffer.from([...$.updatePlaformConfig,...o])})}function Oo(t,e,n,i,r,o,s,a){let c=[{pubkey:n,isSigner:!0,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:oe.programId,isSigner:!1,isWritable:!1},{pubkey:ft,isSigner:!1,isWritable:!1}];return new J({keys:c,programId:t,data:$.claimPlatformFeeFromVault})}function Do(t,e,n,i,r,o,s){let a=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:oe.programId,isSigner:!1,isWritable:!1},{pubkey:ft,isSigner:!1,isWritable:!1}];return new J({keys:a,programId:t,data:$.claimCreatorFee})}var ni=255,tn=new Te("18446744073709551615");function mb(t,e,n,i,r,o){let s=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:oe.programId,isSigner:!1,isWritable:!1}],a=Buffer.alloc(1*2+8*6+P().span);return P().encode(r,a),zt.encode({migrateType:o.migrateType?o.migrateType:ni,migrateCpmmFeeOn:o.migrateCpmmFeeOn?o.migrateCpmmFeeOn:ni,supply:o.supply?o.supply:new Te(0),totalSellA:o.totalSellA?o.totalSellA:new Te(0),totalFundRaisingB:o.totalFundRaisingB?o.totalFundRaisingB:new Te(0),totalLockedAmount:o.totalLockedAmount?o.totalLockedAmount:tn,cliffPeriod:o.cliffPeriod?o.cliffPeriod:tn,unlockPeriod:o.unlockPeriod?o.unlockPeriod:tn},a,1),new J({keys:s,programId:t,data:Buffer.from([...$.updatePlatformCurveParam,...a])})}function db(t,e,n,i){let r=[{pubkey:e,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!0}],o=Buffer.alloc(P().span);return P().encode(i,o),new J({keys:r,programId:t,data:Buffer.from([...$.removePlatformCurveParam,...o,1,2])})}var ii=(n=>(n[n.OnlyTokenB=0]="OnlyTokenB",n[n.BothToken=1]="BothToken",n))(ii||{});import bt from"bn.js";var Ke=class{static getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i}){throw Error()}static getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r}){throw Error()}static getPoolPrice({poolInfo:e,decimalA:n,decimalB:i}){throw Error()}static getPoolEndPrice({supply:e,totalSell:n,totalLockedAmount:i,totalFundRaising:r,migrateFee:o,decimalA:s,decimalB:a}){throw Error()}static getPoolEndPriceReal({poolInfo:e,decimalA:n,decimalB:i}){throw Error()}static getInitParam({supply:e,totalFundRaising:n,totalSell:i,totalLockedAmount:r,migrateFee:o}){throw Error()}static buyExactIn({poolInfo:e,amount:n}){throw Error()}static buyExactOut({poolInfo:e,amount:n}){throw Error()}static sellExactIn({poolInfo:e,amount:n}){throw Error()}static sellExactOut({poolInfo:e,amount:n}){throw Error()}};var yt=class extends Ke{static getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i}){return new F(e.virtualB.toString()).div(e.virtualA.toString()).mul(10**(n-i))}static getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r}){return new F(n.toString()).div(e.toString()).mul(10**(i-r))}static getPoolPrice({poolInfo:e,decimalA:n,decimalB:i}){return new F(e.virtualB.add(e.realB).toString()).div(e.virtualA.sub(e.realA).toString()).mul(10**(n-i))}static getPoolEndPrice({supply:e,totalSell:n,totalLockedAmount:i,totalFundRaising:r,migrateFee:o,decimalA:s,decimalB:a}){return new F(r.sub(o).toString()).div(e.sub(n).sub(i).toString()).mul(10**(s-a))}static getPoolEndPriceReal({poolInfo:e,decimalA:n,decimalB:i}){let r=e.totalSellA.sub(e.realA),o=e.totalFundRaisingB.sub(e.realB);return new F(e.virtualB.add(e.realB.add(o)).toString()).div(e.virtualA.sub(e.realA.add(r)).toString()).mul(10**(n-i))}static getInitParam({supply:e,totalFundRaising:n,totalSell:i,totalLockedAmount:r,migrateFee:o}){if(e.lte(i))throw Error("supply need gt total sell");let s=e.sub(i).sub(r);if(s.lte(new bt(0)))throw Error("supplyMinusSellLocked <= 0");let a=n.sub(o);if(a.lte(new bt(0)))throw Error("tfMinusMf <= 0");let c=a.mul(i).mul(i).div(s),u=a.mul(i).div(s).sub(n),l=c.div(u),m=n.mul(n).div(u);if(l.lt(new bt(0))||m.lt(new bt(0)))throw Error("invalid input 0");return{a:l,b:m,c:i}}static buyExactIn({poolInfo:e,amount:n}){return this.getAmountOut({amountIn:n,inputReserve:e.virtualB.add(e.realB),outputReserve:e.virtualA.sub(e.realA)})}static buyExactOut({poolInfo:e,amount:n}){return this.getAmountIn({amountOut:n,inputReserve:e.virtualB.add(e.realB),outputReserve:e.virtualA.sub(e.realA)})}static sellExactIn({poolInfo:e,amount:n}){return this.getAmountOut({amountIn:n,inputReserve:e.virtualA.sub(e.realA),outputReserve:e.virtualB.add(e.realB)})}static sellExactOut({poolInfo:e,amount:n}){return this.getAmountIn({amountOut:n,inputReserve:e.virtualA.sub(e.realA),outputReserve:e.virtualB.add(e.realB)})}static getAmountOut({amountIn:e,inputReserve:n,outputReserve:i}){let r=e.mul(i),o=n.add(e);return r.div(o)}static getAmountIn({amountOut:e,inputReserve:n,outputReserve:i}){let r=n.mul(e),o=i.sub(e);return Ne(r,o)}};import me from"bn.js";import gt from"bn.js";var Pt=class extends Ke{static getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i}){return new F(e.virtualB.toString()).div(e.virtualA.toString()).mul(10**(n-i))}static getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r}){return new F(n.toString()).div(e.toString()).mul(10**(i-r))}static getPoolPrice({poolInfo:e,decimalA:n,decimalB:i}){return new F(e.virtualB.toString()).div(e.virtualA.toString()).mul(10**(n-i))}static getPoolEndPrice({supply:e,totalSell:n,totalLockedAmount:i,totalFundRaising:r,migrateFee:o,decimalA:s,decimalB:a}){return new F(r.sub(o).toString()).div(e.sub(n).sub(i).toString()).mul(10**(s-a))}static getPoolEndPriceReal({poolInfo:e,decimalA:n,decimalB:i}){let r=e.totalSellA.sub(e.realA),o=e.totalFundRaisingB.sub(e.realB);return new F(e.virtualB.add(e.realB).add(o).toString()).div(e.virtualA.sub(e.realA).add(r).toString()).mul(10**(n-i))}static getInitParam({supply:e,totalFundRaising:n,totalSell:i,totalLockedAmount:r,migrateFee:o}){let s=e.sub(r);if(s.lte(new gt(0)))throw Error("invalid input 1");let a=new gt(2).mul(n).sub(o),u=n.mul(s).div(a);if(u.lt(new gt(0))||n.lt(new gt(0)))throw Error("invalid input 0");return{a:u,b:n,c:u}}static buyExactIn({poolInfo:e,amount:n}){return this.getAmountOut({amountIn:n,initInput:e.virtualB,initOutput:e.virtualA})}static buyExactOut({poolInfo:e,amount:n}){return this.getAmountIn({amountOut:n,initInput:e.virtualB,initOutput:e.virtualA})}static sellExactIn({poolInfo:e,amount:n}){return this.getAmountOut({amountIn:n,initInput:e.virtualA,initOutput:e.virtualB})}static sellExactOut({poolInfo:e,amount:n}){return this.getAmountIn({amountOut:n,initInput:e.virtualA,initOutput:e.virtualB})}static getAmountOut({amountIn:e,initInput:n,initOutput:i}){return i.mul(e).div(n)}static getAmountIn({amountOut:e,initInput:n,initOutput:i}){let r=n.mul(e);return Ne(r,i)}};import se from"bn.js";import De from"bn.js";var Qe=class{static _multipler(e){return new F(10).pow(e)}static getPrice({priceX64:e,decimalA:n,decimalB:i}){return new F(e.toString()).div(this._Q64).mul(this._multipler(n)).div(this._multipler(i))}static getPriceX64({price:e,decimalA:n,decimalB:i}){let r=e.mul(this._multipler(i)).div(this._multipler(n));return new De(r.mul(this._Q64).toFixed(0))}};Qe._Q64=new F(new De(1).shln(64).toString());function Nb({supply:t,totalFundRaisingB:e,totalLockedAmount:n,totalSellA:i,migrateType:r,decimalsA:o}){let s=t.sub(i).sub(n),a=new De(new F(s.mul(e).toString()).sqrt().toFixed(0));if(r==="amm"){if(a.gt(new De(10).pow(new De(o))))return!0}else if(r==="cpmm"){if(a.gt(new De(100)))return!0}else throw Error("migrate type error");return!1}var wt=class extends Ke{static getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i}){return new F(0)}static getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r}){return new F(0)}static getPoolPrice({poolInfo:e,decimalA:n,decimalB:i}){return new F(e.virtualA.mul(e.realA).toString()).div(Qe._Q64).mul(10**(n-i))}static getPoolEndPrice({supply:e,totalSell:n,totalLockedAmount:i,totalFundRaising:r,migrateFee:o,decimalA:s,decimalB:a}){return new F(r.sub(o).toString()).div(e.sub(n).sub(i).toString()).mul(10**(s-a))}static getPoolEndPriceReal({poolInfo:e,decimalA:n,decimalB:i}){let r=e.totalSellA.sub(e.realA),o=e.totalFundRaisingB.sub(e.realB);return new F(e.virtualB.add(e.realB).add(o).toString()).div(e.virtualA.sub(e.realA).add(r).toString()).mul(10**(n-i))}static getInitParam({supply:e,totalFundRaising:n,totalSell:i,totalLockedAmount:r,migrateFee:o}){let s=e.sub(r);if(s.lte(new se(0)))throw Error("supplyMinusLocked need gt 0");let a=n.mul(new se(3)).sub(o),u=n.mul(new se(2)).mul(s).div(a),l=u.mul(u),m=n.mul(new se(2)).mul(ge).div(l);if(!m.gt(new se(0)))throw Error("a need gt 0");if(!Yt.gt(m))throw Error("a need lt u64 max");if(m.lt(new se(0))||u.lt(new se(0)))throw Error("invalid input 0");return{a:m,b:new se(0),c:u}}static buyExactIn({poolInfo:e,amount:n}){let i=e.realB.add(n),r=new se(2).mul(i).mul(ge).div(e.virtualA);return new se(new F(r.toString()).sqrt().toFixed(0)).sub(e.realA)}static buyExactOut({poolInfo:e,amount:n}){let i=e.realA.add(n),r=i.mul(i);return Ne(e.virtualA.mul(r),new se(2).mul(ge)).sub(e.realB)}static sellExactIn({poolInfo:e,amount:n}){let i=e.realA.sub(n),r=i.mul(i),o=Ne(e.virtualA.mul(r),new se(2).mul(ge));return e.realB.sub(o)}static sellExactOut({poolInfo:e,amount:n}){let i=e.realB.sub(n),r=new se(2).mul(i).mul(ge).div(e.virtualA),o=new se(new F(r.toString()).sqrt().toFixed(0));return e.realA.sub(o)}};var Je=class{static getPoolCurvePointByPoolInfo({curveType:e,pointCount:n,poolInfo:i}){return this.getPoolCurvePointByInit({curveType:e,pointCount:n,supply:i.supply,totalFundRaising:i.totalFundRaisingB,totalSell:i.totalSellA,totalLockedAmount:i.vestingSchedule.totalLockedAmount,migrateFee:i.migrateFee,decimalA:i.mintDecimalsA,decimalB:i.mintDecimalsB})}static getPoolCurvePointByInit({curveType:e,pointCount:n,supply:i,totalFundRaising:r,totalSell:o,totalLockedAmount:s,migrateFee:a,decimalA:c,decimalB:u}){if(n<3)throw Error("point count < 3");let l=this.getCurve(e),m=l.getInitParam({supply:i,totalFundRaising:r,totalSell:o,totalLockedAmount:s,migrateFee:a}),d=l.getPoolInitPriceByInit(q(D({},m),{decimalA:c,decimalB:u})),b=r.div(new me(n-1)),g=new me(0),y=[{price:d,totalSellSupply:0}],{a:T,b:C}=m,N=g,I=g;for(let R=1;R<n;R++){let L=R!==n-1?b:r.sub(I),M=this.buyExactIn({poolInfo:{virtualA:T,virtualB:C,realA:N,realB:I,totalFundRaisingB:r,totalSellA:o},amountB:L,protocolFeeRate:g,platformFeeRate:g,curveType:e,shareFeeRate:g,creatorFeeRate:g,transferFeeConfigA:void 0,slot:0});N=N.add(M.amountA.amount),I=I.add(M.amountB);let Y=this.getPrice({poolInfo:{virtualA:T,virtualB:C,realA:N,realB:I},decimalA:c,decimalB:u,curveType:e});y.push({price:Y,totalSellSupply:new F(N.toString()).div(10**c).toNumber()})}return y}static getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i,curveType:r}){return this.getCurve(r).getPoolInitPriceByPool({poolInfo:e,decimalA:n,decimalB:i})}static getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r,curveType:o}){return this.getCurve(o).getPoolInitPriceByInit({a:e,b:n,decimalA:i,decimalB:r})}static getPrice({poolInfo:e,curveType:n,decimalA:i,decimalB:r}){return this.getCurve(n).getPoolPrice({poolInfo:e,decimalA:i,decimalB:r})}static getEndPrice({poolInfo:e,curveType:n,decimalA:i,decimalB:r}){return this.getCurve(n).getPoolPrice({poolInfo:e,decimalA:i,decimalB:r})}static getPoolEndPriceReal({poolInfo:e,curveType:n,decimalA:i,decimalB:r}){return this.getCurve(n).getPoolEndPriceReal({poolInfo:e,decimalA:i,decimalB:r})}static checkParam({supply:e,totalFundRaising:n,totalSell:i,totalLockedAmount:r,decimals:o,config:s,migrateType:a}){if(Number(o)!==6)throw Error("decimals = 6");if(e.mul(s.maxLockRate).div(Re).lt(r))throw Error("total lock amount gte max lock amount");if(e.lt(s.minSupplyA.mul(new me(10**o))))throw Error("supply lt min supply");let u=e.mul(s.minSellRateA).div(Re);if(i.lt(u))throw Error("invalid input");if(n.lt(s.minFundRaisingB))throw Error("total fund raising lt min fund raising");let l=e.sub(i).sub(r),m=e.mul(s.minMigrateRateA).div(Re);if(l.lt(m))throw Error("migrate lt min migrate amoount");let d=e.sub(i).sub(r),b=new me(new F(d.mul(n).toString()).sqrt().toFixed(0));if(a==="amm"){let g=new me(10).pow(new me(o));if(b.lte(g))throw Error("check migrate lp error")}else if(a==="cpmm"){let g=new me(100);if(b.lte(g))throw Error("check migrate lp error")}else throw Error("migrate type error")}static buyExactIn({poolInfo:e,amountB:n,protocolFeeRate:i,platformFeeRate:r,curveType:o,shareFeeRate:s,creatorFeeRate:a,transferFeeConfigA:c,slot:u}){let l=this.totalFeeRate({protocolFeeRate:i,platformFeeRate:r,shareFeeRate:s,creatorFeeRate:a}),m=this.calculateFee({amount:n,feeRate:l}),d=n.sub(m),b=this.getCurve(o),g=b.buyExactIn({poolInfo:e,amount:d}),y=e.totalSellA.sub(e.realA),T,C,N;if(g.gt(y)){T=y;let R=b.buyExactOut({poolInfo:e,amount:T});C=this.calculatePreFee({postFeeAmount:R,feeRate:l}),N=C.sub(R)}else T=g,C=n,N=m;let I=this.splitFee({totalFee:N,protocolFeeRate:i,platformFeeRate:r,shareFeeRate:s,creatorFeeRate:a});return{amountA:Dt(T,c,u),amountB:C,splitFee:I}}static buyExactOut({poolInfo:e,amountA:n,protocolFeeRate:i,platformFeeRate:r,curveType:o,shareFeeRate:s,creatorFeeRate:a,transferFeeConfigA:c,slot:u}){let l=e.totalSellA.sub(e.realA),m=Wt(n,c,u),d=m.fee?m.amount.add(m.fee):m.amount;n.gt(l)&&(d=l);let g=this.getCurve(o).buyExactOut({poolInfo:e,amount:d}),y=this.totalFeeRate({protocolFeeRate:i,platformFeeRate:r,shareFeeRate:s,creatorFeeRate:a}),T=this.calculatePreFee({postFeeAmount:g,feeRate:y}),C=T.sub(g),N=this.splitFee({totalFee:C,protocolFeeRate:i,platformFeeRate:r,shareFeeRate:s,creatorFeeRate:a});return{amountA:m,amountB:T,splitFee:N}}static sellExactIn({poolInfo:e,amountA:n,protocolFeeRate:i,platformFeeRate:r,curveType:o,shareFeeRate:s,creatorFeeRate:a,transferFeeConfigA:c,slot:u}){let l=this.getCurve(o),m=Dt(n,c,u),d=m.fee?m.amount.sub(m.fee):m.amount,b=l.sellExactIn({poolInfo:e,amount:d}),g=this.calculateFee({amount:b,feeRate:this.totalFeeRate({protocolFeeRate:i,platformFeeRate:r,shareFeeRate:s,creatorFeeRate:a})}),y=this.splitFee({totalFee:g,protocolFeeRate:i,platformFeeRate:r,shareFeeRate:s,creatorFeeRate:a});return{amountA:m,amountB:b.sub(g),splitFee:y}}static sellExactOut({poolInfo:e,amountB:n,protocolFeeRate:i,platformFeeRate:r,curveType:o,shareFeeRate:s,creatorFeeRate:a,transferFeeConfigA:c,slot:u}){let l=this.totalFeeRate({protocolFeeRate:i,platformFeeRate:r,shareFeeRate:s,creatorFeeRate:a}),m=this.calculatePreFee({postFeeAmount:n,feeRate:l});if(e.realB.lt(m))throw Error("Insufficient liquidity");let d=m.sub(n),g=Je.getCurve(o).sellExactOut({poolInfo:e,amount:m});if(g.gt(e.realA))throw Error();let y=this.splitFee({totalFee:d,protocolFeeRate:i,platformFeeRate:r,shareFeeRate:s,creatorFeeRate:a});return{amountA:Wt(g,c,u),amountB:n,splitFee:y}}static splitFee({totalFee:e,protocolFeeRate:n,platformFeeRate:i,shareFeeRate:r,creatorFeeRate:o}){let s=this.totalFeeRate({protocolFeeRate:n,platformFeeRate:i,shareFeeRate:r,creatorFeeRate:o}),a=s.isZero()?new me(0):e.mul(i).div(s),c=s.isZero()?new me(0):e.mul(r).div(s),u=s.isZero()?new me(0):e.mul(o).div(s),l=e.sub(a).sub(c).sub(u);return{platformFee:a,shareFee:c,protocolFee:l,creatorFee:u}}static calculateFee({amount:e,feeRate:n}){return Sn(e,n,Re)}static calculatePreFee({postFeeAmount:e,feeRate:n}){if(n.isZero())return e;let i=e.mul(Re),r=Re.sub(n);return i.add(r).sub(new me(1)).div(r)}static totalFeeRate({protocolFeeRate:e,platformFeeRate:n,shareFeeRate:i,creatorFeeRate:r}){if(e.add(n).add(i).add(r).gt(new me(1e6)))throw Error("total fee rate gt 1_000_000");return e.add(n).add(i).add(r)}static getCurve(e){switch(e){case 0:return yt;case 1:return Pt;case 2:return wt}throw Error("find curve error")}};import{NATIVE_MINT as hy,TOKEN_2022_PROGRAM_ID as By,TOKEN_PROGRAM_ID as xy,createAssociatedTokenAccountIdempotentInstruction as Sy,createSyncNativeInstruction as Cy,getTransferFeeConfig as Ky,unpackMint as Ny}from"@solana/spl-token";import X from"bn.js";import{PublicKey as Wo,SystemProgram as Fy}from"@solana/web3.js";var Wy={initPriceX64:new X("515752397214619"),supply:new X(1e15),totalSellA:new X(7931e11),totalFundRaisingB:new X(85e9),totalFundRaisingBUSD:new X(125e8),totalLockedAmount:new X("0"),cliffPeriod:new X("0"),unlockPeriod:new X("0"),decimals:6,virtualA:new X("1073471847374405"),virtualB:new X("30050573465"),realA:new X(0),realB:new X(0),protocolFee:new X(0),platformId:new Wo("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),vestingSchedule:{totalLockedAmount:new X(0),cliffPeriod:new X(0),unlockPeriod:new X(0),startTime:new X(0),totalAllocatedShare:new X(0)}},Vy=new X(1e4),_y=new Set(["USDCoctVLVnvTXBEuP9s8hntucdJokbo17RwHuNXemT","USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB"]);export{uo as AUTH_SEED,zt as BondingCurveParam,co as CONFIG_SEED,fo as CREATOR_FEE_VAULT_AUTH_SEED,ii as CpmmCreatorFeeOn,Je as Curve,Ke as CurveBase,Pt as FixedPriceCurve,yt as LaunchConstantProductCurve,Vr as LaunchpadConfig,qr as LaunchpadPool,Wy as LaunchpadPoolInitParam,om as LaunchpadVesting,wt as LinearPriceCurve,Qe as MathLaunch,po as PLATFORM_FEE_VAULT_AUTH_SEED,mo as PLATFORM_SEED,lo as POOL_VESTING_SEED,Ur as PlatformConfig,Gr as PlatformCurveParam,_r as VestingSchedule,$ as anchorDataBuf,Co as buyExactInInstruction,Ko as buyExactOutInstruction,Nb as checkPoolToAmm,Do as claimCreatorFee,Mo as claimPlatformFee,Oo as claimPlatformFeeFromVault,Lo as claimVestedToken,vo as createPlatformConfig,Fo as createVestingAccount,Ce as getPdaCpiEvent,Bo as getPdaCreatorFeeVaultAuth,ho as getPdaCreatorVault,bo as getPdaLaunchpadAuth,Jf as getPdaLaunchpadConfigId,yo as getPdaLaunchpadPoolId,go as getPdaLaunchpadVaultId,ko as getPdaPlatformFeeVaultAuth,wo as getPdaPlatformId,To as getPdaPlatformVault,Ao as getPdaVestId,lb as initialize,Io as initializeV2,So as initializeWithToken2022,db as removePlatformCurveParamInstruction,No as sellExactInInstruction,Ro as sellExactOut,Po as u8ToBytes,Eo as updatePlatformConfig,mb as updatePlatformCurveParamInstruction,_y as usdMintBSet};
//# sourceMappingURL=index.mjs.map