UNPKG

@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) 844 B
import{parseUnits as n,formatUnits as t}from"ethers";import o from"decimal.js";const e=o.clone();e.set({precision:100,rounding:e.ROUND_HALF_DOWN,toExpNeg:-300,toExpPos:300});const r=(n,t)=>{const o=BigInt(n),e=BigInt(t);return o<e?o:e},i=(n,t)=>{const o=BigInt(n),e=BigInt(t);return o>e?o:e},s=2n**48n,c=new e(10),u=2n**256n-1n,g=(n,t)=>{const o=n-t;return c.pow(o)},p=n=>new e(n.toString()),a=n=>BigInt(n.toFixed()),d=(n,t,o)=>t===o?n:n*t/o;function f(n,t){return new e(n).toFixed(t,e.ROUND_DOWN).replace(/(\.\d*?[1-9])0+$|\.0*$/,"$1")}function m(t,o){const e=f(t,o);return n(e,o)}function x(n,o){const r=BigInt(n),i=t(r,o);return new e(i).toFixed()}export{i as BigNumberMax,r as BigNumberMin,p as BnToDec,a as DecToBn,e as Decimal,u as MAX_UINT256,s as ONE,c as TEN,x as formatUnits,d as mulDiv,m as parseUnits,g as tenPow,f as trimDecimal};