@uniswap/sdk-core
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -527,2 +527,31 @@ 'use strict'; | ||
var MAX_SAFE_INTEGER = /*#__PURE__*/JSBI.BigInt(Number.MAX_SAFE_INTEGER); | ||
var ZERO = /*#__PURE__*/JSBI.BigInt(0); | ||
var ONE = /*#__PURE__*/JSBI.BigInt(1); | ||
var TWO = /*#__PURE__*/JSBI.BigInt(2); | ||
/** | ||
* Computes floor(sqrt(value)) | ||
* @param value the value for which to compute the square root, rounded down | ||
*/ | ||
function sqrt(value) { | ||
!JSBI.greaterThanOrEqual(value, ZERO) ? invariant(false, 'NEGATIVE') : void 0; // rely on built in sqrt if possible | ||
if (JSBI.lessThan(value, MAX_SAFE_INTEGER)) { | ||
return JSBI.BigInt(Math.floor(Math.sqrt(JSBI.toNumber(value)))); | ||
} | ||
var z; | ||
var x; | ||
z = value; | ||
x = JSBI.add(JSBI.divide(value, TWO), ONE); | ||
while (JSBI.lessThan(x, z)) { | ||
z = x; | ||
x = JSBI.divide(JSBI.add(JSBI.divide(value, x), x), TWO); | ||
} | ||
return z; | ||
} | ||
exports.Currency = Currency; | ||
@@ -540,3 +569,4 @@ exports.CurrencyAmount = CurrencyAmount; | ||
exports.sortedInsert = sortedInsert; | ||
exports.sqrt = sqrt; | ||
exports.validateAndParseAddress = validateAndParseAddress; | ||
//# sourceMappingURL=sdk-core.cjs.development.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var n,r,e,i=t(require("jsbi")),o=t(require("tiny-invariant")),a=require("@ethersproject/address"),u=(t(require("tiny-warning")),t(require("decimal.js-light"))),s=t(require("big.js")),c=t(require("toformat"));(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=1]="MAINNET",n[n.ROPSTEN=3]="ROPSTEN",n[n.RINKEBY=4]="RINKEBY",n[n["GÖRLI"]=5]="GÖRLI",n[n.KOVAN=42]="KOVAN",(r=exports.TradeType||(exports.TradeType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(e=exports.Rounding||(exports.Rounding={}))[e.ROUND_DOWN=0]="ROUND_DOWN",e[e.ROUND_HALF_UP=1]="ROUND_HALF_UP",e[e.ROUND_UP=2]="ROUND_UP";var d=i.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function f(t,n){for(var r=0;r<n.length;r++){var e=n[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function h(t,n,r){return n&&f(t.prototype,n),r&&f(t,r),t}function p(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}function l(t){try{return a.getAddress(t)}catch(t){o(!1)}}var m,y=function(t,n,r){t<255||o(!1),this.decimals=t,this.symbol=n,this.name=r},g=y.ETHER=new y(18,"ETH","Ether"),x=function(t){function n(n,r,e,i,o){var a;return(a=t.call(this,e,i,o)||this).chainId=n,a.address=l(r),a}p(n,t);var r=n.prototype;return r.equals=function(t){return this===t||this.chainId===t.chainId&&this.address===t.address},r.sortsBefore=function(t){return this.chainId!==t.chainId&&o(!1),this.address===t.address&&o(!1),this.address.toLowerCase()<t.address.toLowerCase()},n}(y);function v(t,n){return t instanceof x&&n instanceof x?t.equals(n):!(t instanceof x||n instanceof x||t!==n)}var I,w,N=((m={})[exports.ChainId.MAINNET]=new x(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH9","Wrapped Ether"),m[exports.ChainId.ROPSTEN]=new x(exports.ChainId.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),m[exports.ChainId.RINKEBY]=new x(exports.ChainId.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),m[exports.ChainId.GÖRLI]=new x(exports.ChainId.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH9","Wrapped Ether"),m[exports.ChainId.KOVAN]=new x(exports.ChainId.KOVAN,"0xd0A1E359811322d97991E03f863a0C30C2cF029C",18,"WETH9","Wrapped Ether"),m),R=c(u),E=c(s),O=((I={})[exports.Rounding.ROUND_DOWN]=R.ROUND_DOWN,I[exports.Rounding.ROUND_HALF_UP]=R.ROUND_HALF_UP,I[exports.Rounding.ROUND_UP]=R.ROUND_UP,I),T=((w={})[exports.Rounding.ROUND_DOWN]=0,w[exports.Rounding.ROUND_HALF_UP]=1,w[exports.Rounding.ROUND_UP]=3,w),C=function(){function t(t,n){void 0===n&&(n=i.BigInt(1)),this.numerator=i.BigInt(t),this.denominator=i.BigInt(n)}var n=t.prototype;return n.invert=function(){return new t(this.denominator,this.numerator)},n.add=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.equal(this.denominator,r.denominator)?new t(i.add(this.numerator,r.numerator),this.denominator):new t(i.add(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator)),i.multiply(this.denominator,r.denominator))},n.subtract=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.equal(this.denominator,r.denominator)?new t(i.subtract(this.numerator,r.numerator),this.denominator):new t(i.subtract(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator)),i.multiply(this.denominator,r.denominator))},n.lessThan=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.lessThan(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator))},n.equalTo=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.equal(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator))},n.greaterThan=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.greaterThan(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator))},n.multiply=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return new t(i.multiply(this.numerator,r.numerator),i.multiply(this.denominator,r.denominator))},n.divide=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return new t(i.multiply(this.numerator,r.denominator),i.multiply(this.denominator,r.numerator))},n.toSignificant=function(t,n,r){void 0===n&&(n={groupSeparator:""}),void 0===r&&(r=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||o(!1),t>0||o(!1),R.set({precision:t+1,rounding:O[r]});var e=new R(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return e.toFormat(e.decimalPlaces(),n)},n.toFixed=function(t,n,r){return void 0===n&&(n={groupSeparator:""}),void 0===r&&(r=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||o(!1),t>=0||o(!1),E.DP=t,E.RM=T[r],new E(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)},h(t,[{key:"quotient",get:function(){return i.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(i.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),U=new C(i.BigInt(100)),_=function(t){function n(){return t.apply(this,arguments)||this}p(n,t);var r=n.prototype;return r.toSignificant=function(t,n,r){return void 0===t&&(t=5),this.multiply(U).toSignificant(t,n,r)},r.toFixed=function(t,n,r){return void 0===t&&(t=2),this.multiply(U).toFixed(t,n,r)},n}(C),A=c(s),D=function(t){function n(n,r){var e,a=i.BigInt(r);return i.lessThanOrEqual(a,d)||o(!1),(e=t.call(this,a,i.exponentiate(i.BigInt(10),i.BigInt(n.decimals)))||this).currency=n,e}p(n,t),n.ether=function(t){return new n(g,t)};var r=n.prototype;return r.add=function(t){return v(this.currency,t.currency)||o(!1),new n(this.currency,i.add(this.raw,t.raw))},r.subtract=function(t){return v(this.currency,t.currency)||o(!1),new n(this.currency,i.subtract(this.raw,t.raw))},r.toSignificant=function(n,r,e){return void 0===n&&(n=6),void 0===e&&(e=exports.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,n,r,e)},r.toFixed=function(n,r,e){return void 0===n&&(n=this.currency.decimals),void 0===e&&(e=exports.Rounding.ROUND_DOWN),n<=this.currency.decimals||o(!1),t.prototype.toFixed.call(this,n,r,e)},r.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),A.DP=this.currency.decimals,new A(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},h(n,[{key:"raw",get:function(){return this.numerator}}]),n}(C),b=function(t){function n(n,r){var e;return(e=t.call(this,n,r)||this).token=n,e}p(n,t);var r=n.prototype;return r.add=function(t){return this.token.equals(t.token)||o(!1),new n(this.token,i.add(this.raw,t.raw))},r.subtract=function(t){return this.token.equals(t.token)||o(!1),new n(this.token,i.subtract(this.raw,t.raw))},n}(D),B=function(t){function n(n,r,e,o){var a;return(a=t.call(this,o,e)||this).baseCurrency=n,a.quoteCurrency=r,a.scalar=new C(i.exponentiate(i.BigInt(10),i.BigInt(n.decimals)),i.exponentiate(i.BigInt(10),i.BigInt(r.decimals))),a}p(n,t);var r=n.prototype;return r.invert=function(){return new n(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},r.multiply=function(r){v(this.quoteCurrency,r.baseCurrency)||o(!1);var e=t.prototype.multiply.call(this,r);return new n(this.baseCurrency,r.quoteCurrency,e.denominator,e.numerator)},r.quote=function(n){return v(n.currency,this.baseCurrency)||o(!1),this.quoteCurrency instanceof x?new b(this.quoteCurrency,t.prototype.multiply.call(this,n.raw).quotient):D.ether(t.prototype.multiply.call(this,n.raw).quotient)},r.toSignificant=function(t,n,r){return void 0===t&&(t=6),this.adjusted.toSignificant(t,n,r)},r.toFixed=function(t,n,r){return void 0===t&&(t=4),this.adjusted.toFixed(t,n,r)},h(n,[{key:"raw",get:function(){return new C(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),n}(C);exports.Currency=y,exports.CurrencyAmount=D,exports.ETHER=g,exports.Fraction=C,exports.MaxUint256=d,exports.Percent=_,exports.Price=B,exports.Token=x,exports.TokenAmount=b,exports.WETH9=N,exports.currencyEquals=v,exports.sortedInsert=function(t,n,r,e){if(r>0||o(!1),t.length<=r||o(!1),0===t.length)return t.push(n),null;var i=t.length===r;if(i&&e(t[t.length-1],n)<=0)return n;for(var a=0,u=t.length;a<u;){var s=a+u>>>1;e(t[s],n)<=0?a=s+1:u=s}return t.splice(a,0,n),i?t.pop():null},exports.validateAndParseAddress=l; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var n,r,e,i=t(require("jsbi")),o=t(require("tiny-invariant")),a=require("@ethersproject/address"),u=(t(require("tiny-warning")),t(require("decimal.js-light"))),s=t(require("big.js")),d=t(require("toformat"));(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=1]="MAINNET",n[n.ROPSTEN=3]="ROPSTEN",n[n.RINKEBY=4]="RINKEBY",n[n["GÖRLI"]=5]="GÖRLI",n[n.KOVAN=42]="KOVAN",(r=exports.TradeType||(exports.TradeType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(e=exports.Rounding||(exports.Rounding={}))[e.ROUND_DOWN=0]="ROUND_DOWN",e[e.ROUND_HALF_UP=1]="ROUND_HALF_UP",e[e.ROUND_UP=2]="ROUND_UP";var c=i.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function f(t,n){for(var r=0;r<n.length;r++){var e=n[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function h(t,n,r){return n&&f(t.prototype,n),r&&f(t,r),t}function p(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}function l(t){try{return a.getAddress(t)}catch(t){o(!1)}}var m,y=function(t,n,r){t<255||o(!1),this.decimals=t,this.symbol=n,this.name=r},g=y.ETHER=new y(18,"ETH","Ether"),x=function(t){function n(n,r,e,i,o){var a;return(a=t.call(this,e,i,o)||this).chainId=n,a.address=l(r),a}p(n,t);var r=n.prototype;return r.equals=function(t){return this===t||this.chainId===t.chainId&&this.address===t.address},r.sortsBefore=function(t){return this.chainId!==t.chainId&&o(!1),this.address===t.address&&o(!1),this.address.toLowerCase()<t.address.toLowerCase()},n}(y);function I(t,n){return t instanceof x&&n instanceof x?t.equals(n):!(t instanceof x||n instanceof x||t!==n)}var v,N,w=((m={})[exports.ChainId.MAINNET]=new x(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH9","Wrapped Ether"),m[exports.ChainId.ROPSTEN]=new x(exports.ChainId.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),m[exports.ChainId.RINKEBY]=new x(exports.ChainId.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),m[exports.ChainId.GÖRLI]=new x(exports.ChainId.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH9","Wrapped Ether"),m[exports.ChainId.KOVAN]=new x(exports.ChainId.KOVAN,"0xd0A1E359811322d97991E03f863a0C30C2cF029C",18,"WETH9","Wrapped Ether"),m),R=d(u),E=d(s),T=((v={})[exports.Rounding.ROUND_DOWN]=R.ROUND_DOWN,v[exports.Rounding.ROUND_HALF_UP]=R.ROUND_HALF_UP,v[exports.Rounding.ROUND_UP]=R.ROUND_UP,v),O=((N={})[exports.Rounding.ROUND_DOWN]=0,N[exports.Rounding.ROUND_HALF_UP]=1,N[exports.Rounding.ROUND_UP]=3,N),C=function(){function t(t,n){void 0===n&&(n=i.BigInt(1)),this.numerator=i.BigInt(t),this.denominator=i.BigInt(n)}var n=t.prototype;return n.invert=function(){return new t(this.denominator,this.numerator)},n.add=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.equal(this.denominator,r.denominator)?new t(i.add(this.numerator,r.numerator),this.denominator):new t(i.add(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator)),i.multiply(this.denominator,r.denominator))},n.subtract=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.equal(this.denominator,r.denominator)?new t(i.subtract(this.numerator,r.numerator),this.denominator):new t(i.subtract(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator)),i.multiply(this.denominator,r.denominator))},n.lessThan=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.lessThan(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator))},n.equalTo=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.equal(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator))},n.greaterThan=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return i.greaterThan(i.multiply(this.numerator,r.denominator),i.multiply(r.numerator,this.denominator))},n.multiply=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return new t(i.multiply(this.numerator,r.numerator),i.multiply(this.denominator,r.denominator))},n.divide=function(n){var r=n instanceof t?n:new t(i.BigInt(n));return new t(i.multiply(this.numerator,r.denominator),i.multiply(this.denominator,r.numerator))},n.toSignificant=function(t,n,r){void 0===n&&(n={groupSeparator:""}),void 0===r&&(r=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||o(!1),t>0||o(!1),R.set({precision:t+1,rounding:T[r]});var e=new R(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return e.toFormat(e.decimalPlaces(),n)},n.toFixed=function(t,n,r){return void 0===n&&(n={groupSeparator:""}),void 0===r&&(r=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||o(!1),t>=0||o(!1),E.DP=t,E.RM=O[r],new E(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)},h(t,[{key:"quotient",get:function(){return i.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(i.remainder(this.numerator,this.denominator),this.denominator)}}]),t}(),U=new C(i.BigInt(100)),_=function(t){function n(){return t.apply(this,arguments)||this}p(n,t);var r=n.prototype;return r.toSignificant=function(t,n,r){return void 0===t&&(t=5),this.multiply(U).toSignificant(t,n,r)},r.toFixed=function(t,n,r){return void 0===t&&(t=2),this.multiply(U).toFixed(t,n,r)},n}(C),A=d(s),B=function(t){function n(n,r){var e,a=i.BigInt(r);return i.lessThanOrEqual(a,c)||o(!1),(e=t.call(this,a,i.exponentiate(i.BigInt(10),i.BigInt(n.decimals)))||this).currency=n,e}p(n,t),n.ether=function(t){return new n(g,t)};var r=n.prototype;return r.add=function(t){return I(this.currency,t.currency)||o(!1),new n(this.currency,i.add(this.raw,t.raw))},r.subtract=function(t){return I(this.currency,t.currency)||o(!1),new n(this.currency,i.subtract(this.raw,t.raw))},r.toSignificant=function(n,r,e){return void 0===n&&(n=6),void 0===e&&(e=exports.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,n,r,e)},r.toFixed=function(n,r,e){return void 0===n&&(n=this.currency.decimals),void 0===e&&(e=exports.Rounding.ROUND_DOWN),n<=this.currency.decimals||o(!1),t.prototype.toFixed.call(this,n,r,e)},r.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),A.DP=this.currency.decimals,new A(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},h(n,[{key:"raw",get:function(){return this.numerator}}]),n}(C),D=function(t){function n(n,r){var e;return(e=t.call(this,n,r)||this).token=n,e}p(n,t);var r=n.prototype;return r.add=function(t){return this.token.equals(t.token)||o(!1),new n(this.token,i.add(this.raw,t.raw))},r.subtract=function(t){return this.token.equals(t.token)||o(!1),new n(this.token,i.subtract(this.raw,t.raw))},n}(B),b=function(t){function n(n,r,e,o){var a;return(a=t.call(this,o,e)||this).baseCurrency=n,a.quoteCurrency=r,a.scalar=new C(i.exponentiate(i.BigInt(10),i.BigInt(n.decimals)),i.exponentiate(i.BigInt(10),i.BigInt(r.decimals))),a}p(n,t);var r=n.prototype;return r.invert=function(){return new n(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},r.multiply=function(r){I(this.quoteCurrency,r.baseCurrency)||o(!1);var e=t.prototype.multiply.call(this,r);return new n(this.baseCurrency,r.quoteCurrency,e.denominator,e.numerator)},r.quote=function(n){return I(n.currency,this.baseCurrency)||o(!1),this.quoteCurrency instanceof x?new D(this.quoteCurrency,t.prototype.multiply.call(this,n.raw).quotient):B.ether(t.prototype.multiply.call(this,n.raw).quotient)},r.toSignificant=function(t,n,r){return void 0===t&&(t=6),this.adjusted.toSignificant(t,n,r)},r.toFixed=function(t,n,r){return void 0===t&&(t=4),this.adjusted.toFixed(t,n,r)},h(n,[{key:"raw",get:function(){return new C(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),n}(C),q=i.BigInt(Number.MAX_SAFE_INTEGER),F=i.BigInt(0),P=i.BigInt(1),S=i.BigInt(2);exports.Currency=y,exports.CurrencyAmount=B,exports.ETHER=g,exports.Fraction=C,exports.MaxUint256=c,exports.Percent=_,exports.Price=b,exports.Token=x,exports.TokenAmount=D,exports.WETH9=w,exports.currencyEquals=I,exports.sortedInsert=function(t,n,r,e){if(r>0||o(!1),t.length<=r||o(!1),0===t.length)return t.push(n),null;var i=t.length===r;if(i&&e(t[t.length-1],n)<=0)return n;for(var a=0,u=t.length;a<u;){var s=a+u>>>1;e(t[s],n)<=0?a=s+1:u=s}return t.splice(a,0,n),i?t.pop():null},exports.sqrt=function(t){if(i.greaterThanOrEqual(t,F)||o(!1),i.lessThan(t,q))return i.BigInt(Math.floor(Math.sqrt(i.toNumber(t))));var n,r;for(n=t,r=i.add(i.divide(t,S),P);i.lessThan(r,n);)n=r,r=i.divide(i.add(i.divide(t,r),r),S);return n},exports.validateAndParseAddress=l; | ||
//# sourceMappingURL=sdk-core.cjs.production.min.js.map |
@@ -527,3 +527,32 @@ import JSBI from 'jsbi'; | ||
export { ChainId, Currency, CurrencyAmount, ETHER, Fraction, MaxUint256, Percent, Price, Rounding, Token, TokenAmount, TradeType, WETH9, currencyEquals, sortedInsert, validateAndParseAddress }; | ||
var MAX_SAFE_INTEGER = /*#__PURE__*/JSBI.BigInt(Number.MAX_SAFE_INTEGER); | ||
var ZERO = /*#__PURE__*/JSBI.BigInt(0); | ||
var ONE = /*#__PURE__*/JSBI.BigInt(1); | ||
var TWO = /*#__PURE__*/JSBI.BigInt(2); | ||
/** | ||
* Computes floor(sqrt(value)) | ||
* @param value the value for which to compute the square root, rounded down | ||
*/ | ||
function sqrt(value) { | ||
!JSBI.greaterThanOrEqual(value, ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NEGATIVE') : invariant(false) : void 0; // rely on built in sqrt if possible | ||
if (JSBI.lessThan(value, MAX_SAFE_INTEGER)) { | ||
return JSBI.BigInt(Math.floor(Math.sqrt(JSBI.toNumber(value)))); | ||
} | ||
var z; | ||
var x; | ||
z = value; | ||
x = JSBI.add(JSBI.divide(value, TWO), ONE); | ||
while (JSBI.lessThan(x, z)) { | ||
z = x; | ||
x = JSBI.divide(JSBI.add(JSBI.divide(value, x), x), TWO); | ||
} | ||
return z; | ||
} | ||
export { ChainId, Currency, CurrencyAmount, ETHER, Fraction, MaxUint256, Percent, Price, Rounding, Token, TokenAmount, TradeType, WETH9, currencyEquals, sortedInsert, sqrt, validateAndParseAddress }; | ||
//# sourceMappingURL=sdk-core.esm.js.map |
import sortedInsert from './sortedInsert'; | ||
import validateAndParseAddress from './validateAndParseAddress'; | ||
export { sortedInsert, validateAndParseAddress }; | ||
import sqrt from './sqrt'; | ||
export { sortedInsert, validateAndParseAddress, sqrt }; |
{ | ||
"name": "@uniswap/sdk-core", | ||
"license": "MIT", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "⚒️ An SDK for building applications on top of Uniswap V3", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153442
24
1102
22