@bancor/carbon-sdk
Version:
The SDK is a READ-ONLY tool, intended to facilitate working with Carbon contracts. It's a convenient wrapper around our matching algorithm, allowing programs and users get a ready to use transaction data that will allow them to manage strategies and fulfi
2 lines (1 loc) • 1 kB
JavaScript
;var e=require("@ethersproject/bignumber"),r=require("@ethersproject/units");const t=require("decimal.js").clone();t.set({precision:100,rounding:t.ROUND_HALF_DOWN,toExpNeg:-300,toExpPos:300});const o=new t(10),n=e.BigNumber.from(2).pow(256).sub(1);function s(e,r){return new t(e).toFixed(r,t.ROUND_DOWN).replace(/(\.\d*?[1-9])0+$|\.0*$/,"$1")}exports.BigNumberMax=(r,t)=>{const o=e.BigNumber.from(r),n=e.BigNumber.from(t);return o.gt(n)?o:n},exports.BigNumberMin=(r,t)=>{const o=e.BigNumber.from(r),n=e.BigNumber.from(t);return o.lt(n)?o:n},exports.BnToDec=e=>new t(e.toString()),exports.DecToBn=r=>e.BigNumber.from(r.toFixed()),exports.Decimal=t,exports.MAX_UINT256=n,exports.ONE=2**48,exports.TEN=o,exports.formatUnits=function(e,o){const n=r.formatUnits(e,o);return new t(n).toFixed()},exports.mulDiv=(e,r,t)=>r.eq(t)?e:e.mul(r).div(t),exports.parseUnits=function(e,t){const o=s(e,t);return r.parseUnits(o,t)},exports.tenPow=(e,r)=>{const t=e-r;return o.pow(t)},exports.trimDecimal=s;