goosefx-amm-sdk
Version:
SDK for the GooseFx AMM
2 lines • 1.88 kB
JavaScript
import t from"bn.js";import{get as g,set as m}from"lodash";var i=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(o=>typeof o=="object"?JSON.stringify(o):o).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}},s={},c={};function f(r){let e=g(s,r);if(!e){let n=g(c,r);e=new i({name:r,logLevel:n}),m(s,r,e)}return e}var u=(o=>(o[o.ROUND_DOWN=0]="ROUND_DOWN",o[o.ROUND_HALF_UP=1]="ROUND_HALF_UP",o[o.ROUND_UP=2]="ROUND_UP",o))(u||{}),E=new t(0),_=new t(1),v=new t(2),a=new t(3),k=new t(5),L=new t(10),d=new t(100),y=new t(1e3),O=new t(1e4),l=9007199254740991;function N(r){let e=f("Gfx_parseBigNumberish");if(r instanceof t)return r;if(typeof r=="string"){if(r.match(/^-?[0-9]+$/))return new t(r);e.logWithError(`invalid BigNumberish string: ${r}`)}return typeof r=="number"?(r%1&&e.logWithError(`BigNumberish number underflow: ${r}`),(r>=l||r<=-l)&&e.logWithError(`BigNumberish number overflow: ${r}`),new t(String(r))):typeof r=="bigint"?new t(r.toString()):(e.error(`invalid BigNumberish value: ${r}`),new t(0))}function W(r){return L.pow(N(r))}export{d as BN_100,y as BN_1000,O as BN_10000,k as BN_FIVE,_ as BN_ONE,L as BN_TEN,a as BN_THREE,v as BN_TWO,E as BN_ZERO,u as Rounding,N as parseBigNumberish,W as tenExponential};
//# sourceMappingURL=number.mjs.map