UNPKG

@raydium-io/raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

2 lines 1.62 kB
import t from"bn.js";import{get as g,set as L}from"lodash";var n=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 o=e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(", ");throw new Error(o)}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={},u={};function f(r){let e=g(s,r);if(!e){let o=g(u,r);e=new n({name:r,logLevel:o}),L(s,r,e)}return e}var c=(i=>(i[i.ROUND_DOWN=0]="ROUND_DOWN",i[i.ROUND_HALF_UP=1]="ROUND_HALF_UP",i[i.ROUND_UP=2]="ROUND_UP",i))(c||{}),l=9007199254740991;function v(r){let e=f("Raydium_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))}export{c as Rounding,v as parseBigNumberish}; //# sourceMappingURL=constant.mjs.map