Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uniswap/sdk-core

Package Overview
Dependencies
Maintainers
7
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/sdk-core - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

17

dist/constants.d.ts

@@ -1,2 +0,3 @@

export declare type BigintIsh = bigint | string;
import JSBI from 'jsbi';
export declare type BigintIsh = JSBI | string | number;
export declare enum ChainId {

@@ -18,8 +19,8 @@ MAINNET = 1,

}
export declare const ZERO: bigint;
export declare const ONE: bigint;
export declare const TWO: bigint;
export declare const THREE: bigint;
export declare const TEN: bigint;
export declare const ONE_HUNDRED: bigint;
export declare const MaxUint256: bigint;
export declare const ZERO: JSBI;
export declare const ONE: JSBI;
export declare const TWO: JSBI;
export declare const THREE: JSBI;
export declare const TEN: JSBI;
export declare const ONE_HUNDRED: JSBI;
export declare const MaxUint256: JSBI;

@@ -0,1 +1,2 @@

import JSBI from 'jsbi';
import { Currency } from '../currency';

@@ -12,3 +13,3 @@ import { BigintIsh, Rounding } from '../../constants';

protected constructor(currency: Currency, amount: BigintIsh);
get raw(): bigint;
get raw(): JSBI;
add(other: CurrencyAmount): CurrencyAmount;

@@ -15,0 +16,0 @@ subtract(other: CurrencyAmount): CurrencyAmount;

@@ -0,7 +1,8 @@

import JSBI from 'jsbi';
import { BigintIsh, Rounding } from '../../constants';
export default class Fraction {
readonly numerator: bigint;
readonly denominator: bigint;
readonly numerator: JSBI;
readonly denominator: JSBI;
constructor(numerator: BigintIsh, denominator?: BigintIsh);
get quotient(): bigint;
get quotient(): JSBI;
get remainder(): Fraction;

@@ -8,0 +9,0 @@ invert(): Fraction;

@@ -7,2 +7,3 @@ 'use strict';

var JSBI = _interopDefault(require('jsbi'));
var invariant = _interopDefault(require('tiny-invariant'));

@@ -35,9 +36,9 @@ var address = require('@ethersproject/address');

var ZERO = /*#__PURE__*/BigInt(0);
var ONE = /*#__PURE__*/BigInt(1);
var TWO = /*#__PURE__*/BigInt(2);
var THREE = /*#__PURE__*/BigInt(3);
var TEN = /*#__PURE__*/BigInt(10);
var ONE_HUNDRED = /*#__PURE__*/BigInt(100);
var MaxUint256 = /*#__PURE__*/BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
var ZERO = /*#__PURE__*/JSBI.BigInt(0);
var ONE = /*#__PURE__*/JSBI.BigInt(1);
var TWO = /*#__PURE__*/JSBI.BigInt(2);
var THREE = /*#__PURE__*/JSBI.BigInt(3);
var TEN = /*#__PURE__*/JSBI.BigInt(10);
var ONE_HUNDRED = /*#__PURE__*/JSBI.BigInt(100);
var MaxUint256 = /*#__PURE__*/JSBI.BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');

@@ -179,4 +180,4 @@ function _defineProperties(target, props) {

this.numerator = BigInt(numerator);
this.denominator = BigInt(denominator);
this.numerator = JSBI.BigInt(numerator);
this.denominator = JSBI.BigInt(denominator);
} // performs floor division

@@ -192,44 +193,44 @@

_proto.add = function add(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
if (this.denominator === otherParsed.denominator) {
return new Fraction(this.numerator + otherParsed.numerator, this.denominator);
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
return new Fraction(JSBI.add(this.numerator, otherParsed.numerator), this.denominator);
}
return new Fraction(this.numerator * otherParsed.denominator + otherParsed.numerator * this.denominator, this.denominator * otherParsed.denominator);
return new Fraction(JSBI.add(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.subtract = function subtract(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
if (this.denominator === otherParsed.denominator) {
return new Fraction(this.numerator - otherParsed.numerator, this.denominator);
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
return new Fraction(JSBI.subtract(this.numerator, otherParsed.numerator), this.denominator);
}
return new Fraction(this.numerator * otherParsed.denominator - otherParsed.numerator * this.denominator, this.denominator * otherParsed.denominator);
return new Fraction(JSBI.subtract(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.lessThan = function lessThan(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return this.numerator * otherParsed.denominator < otherParsed.numerator * this.denominator;
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return JSBI.lessThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.equalTo = function equalTo(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return this.numerator * otherParsed.denominator === otherParsed.numerator * this.denominator;
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return JSBI.equal(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.greaterThan = function greaterThan(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return this.numerator * otherParsed.denominator > otherParsed.numerator * this.denominator;
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return JSBI.greaterThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.multiply = function multiply(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return new Fraction(this.numerator * otherParsed.numerator, this.denominator * otherParsed.denominator);
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return new Fraction(JSBI.multiply(this.numerator, otherParsed.numerator), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.divide = function divide(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return new Fraction(this.numerator * otherParsed.denominator, this.denominator * otherParsed.numerator);
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return new Fraction(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(this.denominator, otherParsed.numerator));
};

@@ -279,3 +280,3 @@

get: function get() {
return this.numerator / this.denominator;
return JSBI.divide(this.numerator, this.denominator);
} // remainder after floor division

@@ -286,3 +287,3 @@

get: function get() {
return new Fraction(this.numerator % this.denominator, this.denominator);
return new Fraction(JSBI.remainder(this.numerator, this.denominator), this.denominator);
}

@@ -333,5 +334,5 @@ }]);

var parsedAmount = BigInt(amount);
var parsedAmount = JSBI.BigInt(amount);
!(parsedAmount < MaxUint256) ? invariant(false, 'AMOUNT') : void 0;
_this = _Fraction.call(this, parsedAmount, Math.pow(TEN, BigInt(currency.decimals))) || this;
_this = _Fraction.call(this, parsedAmount, JSBI.exponentiate(TEN, JSBI.BigInt(currency.decimals))) || this;
_this.currency = currency;

@@ -354,3 +355,3 @@ return _this;

!currencyEquals(this.currency, other.currency) ? invariant(false, 'TOKEN') : void 0;
return new CurrencyAmount(this.currency, this.raw + other.raw);
return new CurrencyAmount(this.currency, JSBI.add(this.raw, other.raw));
};

@@ -360,3 +361,3 @@

!currencyEquals(this.currency, other.currency) ? invariant(false, 'TOKEN') : void 0;
return new CurrencyAmount(this.currency, this.raw - other.raw);
return new CurrencyAmount(this.currency, JSBI.subtract(this.raw, other.raw));
};

@@ -426,3 +427,3 @@

!this.token.equals(other.token) ? invariant(false, 'TOKEN') : void 0;
return new TokenAmount(this.token, this.raw + other.raw);
return new TokenAmount(this.token, JSBI.add(this.raw, other.raw));
};

@@ -432,3 +433,3 @@

!this.token.equals(other.token) ? invariant(false, 'TOKEN') : void 0;
return new TokenAmount(this.token, this.raw - other.raw);
return new TokenAmount(this.token, JSBI.subtract(this.raw, other.raw));
};

@@ -449,3 +450,3 @@

_this.quoteCurrency = quoteCurrency;
_this.scalar = new Fraction(Math.pow(TEN, BigInt(baseCurrency.decimals)), Math.pow(TEN, BigInt(quoteCurrency.decimals)));
_this.scalar = new Fraction(JSBI.exponentiate(TEN, JSBI.BigInt(baseCurrency.decimals)), JSBI.exponentiate(TEN, JSBI.BigInt(quoteCurrency.decimals)));
return _this;

@@ -551,7 +552,7 @@ }

z = y;
x = y / TWO + ONE;
x = JSBI.add(JSBI.divide(y, TWO), ONE);
while (x < z) {
z = x;
x = (y / x + x) / TWO;
x = JSBI.divide(JSBI.add(JSBI.divide(y, x), x), TWO);
}

@@ -558,0 +559,0 @@ } else if (y !== ZERO) {

@@ -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("tiny-invariant")),o=require("@ethersproject/address"),a=(t(require("tiny-warning")),t(require("decimal.js-light"))),u=t(require("big.js")),s=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=BigInt(0),d=BigInt(1),f=BigInt(2),h=BigInt(3),p=BigInt(10),m=BigInt(100),l=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function g(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 y(t,n,r){return n&&g(t.prototype,n),r&&g(t,r),t}function w(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}function x(t){try{return o.getAddress(t)}catch(t){i(!1)}}var I,v=function(t,n,r){t<255||i(!1),this.decimals=t,this.symbol=n,this.name=r},N=v.ETHER=new v(18,"ETH","Ether"),R=function(t){function n(n,r,e,i,o){var a;return(a=t.call(this,e,i,o)||this).chainId=n,a.address=x(r),a}w(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&&i(!1),this.address===t.address&&i(!1),this.address.toLowerCase()<t.address.toLowerCase()},n}(v);function E(t,n){return t instanceof R&&n instanceof R?t.equals(n):!(t instanceof R||n instanceof R||t!==n)}var O,C,U=((I={})[exports.ChainId.MAINNET]=new R(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH","Wrapped Ether"),I[exports.ChainId.ROPSTEN]=new R(exports.ChainId.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),I[exports.ChainId.RINKEBY]=new R(exports.ChainId.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),I[exports.ChainId.GÖRLI]=new R(exports.ChainId.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH","Wrapped Ether"),I[exports.ChainId.KOVAN]=new R(exports.ChainId.KOVAN,"0xd0A1E359811322d97991E03f863a0C30C2cF029C",18,"WETH","Wrapped Ether"),I),T=s(a),_=s(u),A=((O={})[exports.Rounding.ROUND_DOWN]=T.ROUND_DOWN,O[exports.Rounding.ROUND_HALF_UP]=T.ROUND_HALF_UP,O[exports.Rounding.ROUND_UP]=T.ROUND_UP,O),D=((C={})[exports.Rounding.ROUND_DOWN]=0,C[exports.Rounding.ROUND_HALF_UP]=1,C[exports.Rounding.ROUND_UP]=3,C),B=function(){function t(t,n){void 0===n&&(n=d),this.numerator=BigInt(t),this.denominator=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(BigInt(n));return this.denominator===r.denominator?new t(this.numerator+r.numerator,this.denominator):new t(this.numerator*r.denominator+r.numerator*this.denominator,this.denominator*r.denominator)},n.subtract=function(n){var r=n instanceof t?n:new t(BigInt(n));return this.denominator===r.denominator?new t(this.numerator-r.numerator,this.denominator):new t(this.numerator*r.denominator-r.numerator*this.denominator,this.denominator*r.denominator)},n.lessThan=function(n){var r=n instanceof t?n:new t(BigInt(n));return this.numerator*r.denominator<r.numerator*this.denominator},n.equalTo=function(n){var r=n instanceof t?n:new t(BigInt(n));return this.numerator*r.denominator==r.numerator*this.denominator},n.greaterThan=function(n){var r=n instanceof t?n:new t(BigInt(n));return this.numerator*r.denominator>r.numerator*this.denominator},n.multiply=function(n){var r=n instanceof t?n:new t(BigInt(n));return new t(this.numerator*r.numerator,this.denominator*r.denominator)},n.divide=function(n){var r=n instanceof t?n:new t(BigInt(n));return new t(this.numerator*r.denominator,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)||i(!1),t>0||i(!1),T.set({precision:t+1,rounding:A[r]});var e=new T(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)||i(!1),t>=0||i(!1),_.DP=t,_.RM=D[r],new _(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)},y(t,[{key:"quotient",get:function(){return this.numerator/this.denominator}},{key:"remainder",get:function(){return new t(this.numerator%this.denominator,this.denominator)}}]),t}(),P=new B(m),F=function(t){function n(){return t.apply(this,arguments)||this}w(n,t);var r=n.prototype;return r.toSignificant=function(t,n,r){return void 0===t&&(t=5),this.multiply(P).toSignificant(t,n,r)},r.toFixed=function(t,n,r){return void 0===t&&(t=2),this.multiply(P).toFixed(t,n,r)},n}(B),b=s(u),q=function(t){function n(n,r){var e,o=BigInt(r);return o<l||i(!1),(e=t.call(this,o,Math.pow(p,BigInt(n.decimals)))||this).currency=n,e}w(n,t),n.ether=function(t){return new n(N,t)};var r=n.prototype;return r.add=function(t){return E(this.currency,t.currency)||i(!1),new n(this.currency,this.raw+t.raw)},r.subtract=function(t){return E(this.currency,t.currency)||i(!1),new n(this.currency,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||i(!1),t.prototype.toFixed.call(this,n,r,e)},r.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),b.DP=this.currency.decimals,new b(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},y(n,[{key:"raw",get:function(){return this.numerator}}]),n}(B),S=function(t){function n(n,r){var e;return(e=t.call(this,n,r)||this).token=n,e}w(n,t);var r=n.prototype;return r.add=function(t){return this.token.equals(t.token)||i(!1),new n(this.token,this.raw+t.raw)},r.subtract=function(t){return this.token.equals(t.token)||i(!1),new n(this.token,this.raw-t.raw)},n}(q),W=function(t){function n(n,r,e,i){var o;return(o=t.call(this,i,e)||this).baseCurrency=n,o.quoteCurrency=r,o.scalar=new B(Math.pow(p,BigInt(n.decimals)),Math.pow(p,BigInt(r.decimals))),o}w(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){E(this.quoteCurrency,r.baseCurrency)||i(!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 E(n.currency,this.baseCurrency)||i(!1),this.quoteCurrency instanceof R?new S(this.quoteCurrency,t.prototype.multiply.call(this,n.raw).quotient):q.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)},y(n,[{key:"raw",get:function(){return new B(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),n}(B);exports.Currency=v,exports.CurrencyAmount=q,exports.ETHER=N,exports.Fraction=B,exports.Percent=F,exports.Price=W,exports.Token=R,exports.TokenAmount=S,exports.WETH=U,exports.babylonianSqrt=function(t){var n,r=c;if(t>h)for(r=t,n=t/f+d;n<r;)r=n,n=(t/n+n)/f;else t!==c&&(r=d);return r},exports.currencyEquals=E,exports.sortedInsert=function(t,n,r,e){if(r>0||i(!1),t.length<=r||i(!1),0===t.length)return t.push(n),null;var o=t.length===r;if(o&&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),o?t.pop():null},exports.validateAndParseAddress=x;
"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(0),f=i.BigInt(1),h=i.BigInt(2),p=i.BigInt(3),l=i.BigInt(10),m=i.BigInt(100),y=i.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function g(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 v(t,n,r){return n&&g(t.prototype,n),r&&g(t,r),t}function x(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}function I(t){try{return a.getAddress(t)}catch(t){o(!1)}}var w,N=function(t,n,r){t<255||o(!1),this.decimals=t,this.symbol=n,this.name=r},R=N.ETHER=new N(18,"ETH","Ether"),E=function(t){function n(n,r,e,i,o){var a;return(a=t.call(this,e,i,o)||this).chainId=n,a.address=I(r),a}x(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}(N);function O(t,n){return t instanceof E&&n instanceof E?t.equals(n):!(t instanceof E||n instanceof E||t!==n)}var C,T,U=((w={})[exports.ChainId.MAINNET]=new E(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH","Wrapped Ether"),w[exports.ChainId.ROPSTEN]=new E(exports.ChainId.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),w[exports.ChainId.RINKEBY]=new E(exports.ChainId.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),w[exports.ChainId.GÖRLI]=new E(exports.ChainId.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH","Wrapped Ether"),w[exports.ChainId.KOVAN]=new E(exports.ChainId.KOVAN,"0xd0A1E359811322d97991E03f863a0C30C2cF029C",18,"WETH","Wrapped Ether"),w),_=d(u),A=d(s),D=((C={})[exports.Rounding.ROUND_DOWN]=_.ROUND_DOWN,C[exports.Rounding.ROUND_HALF_UP]=_.ROUND_HALF_UP,C[exports.Rounding.ROUND_UP]=_.ROUND_UP,C),b=((T={})[exports.Rounding.ROUND_DOWN]=0,T[exports.Rounding.ROUND_HALF_UP]=1,T[exports.Rounding.ROUND_UP]=3,T),B=function(){function t(t,n){void 0===n&&(n=f),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),_.set({precision:t+1,rounding:D[r]});var e=new _(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),A.DP=t,A.RM=b[r],new A(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,n)},v(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}(),P=new B(m),q=function(t){function n(){return t.apply(this,arguments)||this}x(n,t);var r=n.prototype;return r.toSignificant=function(t,n,r){return void 0===t&&(t=5),this.multiply(P).toSignificant(t,n,r)},r.toFixed=function(t,n,r){return void 0===t&&(t=2),this.multiply(P).toFixed(t,n,r)},n}(B),F=d(s),S=function(t){function n(n,r){var e,a=i.BigInt(r);return a<y||o(!1),(e=t.call(this,a,i.exponentiate(l,i.BigInt(n.decimals)))||this).currency=n,e}x(n,t),n.ether=function(t){return new n(R,t)};var r=n.prototype;return r.add=function(t){return O(this.currency,t.currency)||o(!1),new n(this.currency,i.add(this.raw,t.raw))},r.subtract=function(t){return O(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:""}),F.DP=this.currency.decimals,new F(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},v(n,[{key:"raw",get:function(){return this.numerator}}]),n}(B),W=function(t){function n(n,r){var e;return(e=t.call(this,n,r)||this).token=n,e}x(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}(S),H=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 B(i.exponentiate(l,i.BigInt(n.decimals)),i.exponentiate(l,i.BigInt(r.decimals))),a}x(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){O(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 O(n.currency,this.baseCurrency)||o(!1),this.quoteCurrency instanceof E?new W(this.quoteCurrency,t.prototype.multiply.call(this,n.raw).quotient):S.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)},v(n,[{key:"raw",get:function(){return new B(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),n}(B);exports.Currency=N,exports.CurrencyAmount=S,exports.ETHER=R,exports.Fraction=B,exports.Percent=q,exports.Price=H,exports.Token=E,exports.TokenAmount=W,exports.WETH=U,exports.babylonianSqrt=function(t){var n,r=c;if(t>p)for(r=t,n=i.add(i.divide(t,h),f);n<r;)r=n,n=i.divide(i.add(i.divide(t,n),n),h);else t!==c&&(r=f);return r},exports.currencyEquals=O,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=I;
//# sourceMappingURL=sdk-core.cjs.production.min.js.map

@@ -0,1 +1,2 @@

import JSBI from 'jsbi';
import invariant from 'tiny-invariant';

@@ -34,9 +35,9 @@ import { getAddress } from '@ethersproject/address';

var ZERO = /*#__PURE__*/BigInt(0);
var ONE = /*#__PURE__*/BigInt(1);
var TWO = /*#__PURE__*/BigInt(2);
var THREE = /*#__PURE__*/BigInt(3);
var TEN = /*#__PURE__*/BigInt(10);
var ONE_HUNDRED = /*#__PURE__*/BigInt(100);
var MaxUint256 = /*#__PURE__*/BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
var ZERO = /*#__PURE__*/JSBI.BigInt(0);
var ONE = /*#__PURE__*/JSBI.BigInt(1);
var TWO = /*#__PURE__*/JSBI.BigInt(2);
var THREE = /*#__PURE__*/JSBI.BigInt(3);
var TEN = /*#__PURE__*/JSBI.BigInt(10);
var ONE_HUNDRED = /*#__PURE__*/JSBI.BigInt(100);
var MaxUint256 = /*#__PURE__*/JSBI.BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');

@@ -178,4 +179,4 @@ function _defineProperties(target, props) {

this.numerator = BigInt(numerator);
this.denominator = BigInt(denominator);
this.numerator = JSBI.BigInt(numerator);
this.denominator = JSBI.BigInt(denominator);
} // performs floor division

@@ -191,44 +192,44 @@

_proto.add = function add(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
if (this.denominator === otherParsed.denominator) {
return new Fraction(this.numerator + otherParsed.numerator, this.denominator);
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
return new Fraction(JSBI.add(this.numerator, otherParsed.numerator), this.denominator);
}
return new Fraction(this.numerator * otherParsed.denominator + otherParsed.numerator * this.denominator, this.denominator * otherParsed.denominator);
return new Fraction(JSBI.add(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.subtract = function subtract(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
if (this.denominator === otherParsed.denominator) {
return new Fraction(this.numerator - otherParsed.numerator, this.denominator);
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
return new Fraction(JSBI.subtract(this.numerator, otherParsed.numerator), this.denominator);
}
return new Fraction(this.numerator * otherParsed.denominator - otherParsed.numerator * this.denominator, this.denominator * otherParsed.denominator);
return new Fraction(JSBI.subtract(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.lessThan = function lessThan(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return this.numerator * otherParsed.denominator < otherParsed.numerator * this.denominator;
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return JSBI.lessThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.equalTo = function equalTo(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return this.numerator * otherParsed.denominator === otherParsed.numerator * this.denominator;
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return JSBI.equal(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.greaterThan = function greaterThan(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return this.numerator * otherParsed.denominator > otherParsed.numerator * this.denominator;
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return JSBI.greaterThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
};
_proto.multiply = function multiply(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return new Fraction(this.numerator * otherParsed.numerator, this.denominator * otherParsed.denominator);
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return new Fraction(JSBI.multiply(this.numerator, otherParsed.numerator), JSBI.multiply(this.denominator, otherParsed.denominator));
};
_proto.divide = function divide(other) {
var otherParsed = other instanceof Fraction ? other : new Fraction(BigInt(other));
return new Fraction(this.numerator * otherParsed.denominator, this.denominator * otherParsed.numerator);
var otherParsed = other instanceof Fraction ? other : new Fraction(JSBI.BigInt(other));
return new Fraction(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(this.denominator, otherParsed.numerator));
};

@@ -278,3 +279,3 @@

get: function get() {
return this.numerator / this.denominator;
return JSBI.divide(this.numerator, this.denominator);
} // remainder after floor division

@@ -285,3 +286,3 @@

get: function get() {
return new Fraction(this.numerator % this.denominator, this.denominator);
return new Fraction(JSBI.remainder(this.numerator, this.denominator), this.denominator);
}

@@ -332,5 +333,5 @@ }]);

var parsedAmount = BigInt(amount);
var parsedAmount = JSBI.BigInt(amount);
!(parsedAmount < MaxUint256) ? process.env.NODE_ENV !== "production" ? invariant(false, 'AMOUNT') : invariant(false) : void 0;
_this = _Fraction.call(this, parsedAmount, Math.pow(TEN, BigInt(currency.decimals))) || this;
_this = _Fraction.call(this, parsedAmount, JSBI.exponentiate(TEN, JSBI.BigInt(currency.decimals))) || this;
_this.currency = currency;

@@ -353,3 +354,3 @@ return _this;

!currencyEquals(this.currency, other.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;
return new CurrencyAmount(this.currency, this.raw + other.raw);
return new CurrencyAmount(this.currency, JSBI.add(this.raw, other.raw));
};

@@ -359,3 +360,3 @@

!currencyEquals(this.currency, other.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;
return new CurrencyAmount(this.currency, this.raw - other.raw);
return new CurrencyAmount(this.currency, JSBI.subtract(this.raw, other.raw));
};

@@ -425,3 +426,3 @@

!this.token.equals(other.token) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;
return new TokenAmount(this.token, this.raw + other.raw);
return new TokenAmount(this.token, JSBI.add(this.raw, other.raw));
};

@@ -431,3 +432,3 @@

!this.token.equals(other.token) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;
return new TokenAmount(this.token, this.raw - other.raw);
return new TokenAmount(this.token, JSBI.subtract(this.raw, other.raw));
};

@@ -448,3 +449,3 @@

_this.quoteCurrency = quoteCurrency;
_this.scalar = new Fraction(Math.pow(TEN, BigInt(baseCurrency.decimals)), Math.pow(TEN, BigInt(quoteCurrency.decimals)));
_this.scalar = new Fraction(JSBI.exponentiate(TEN, JSBI.BigInt(baseCurrency.decimals)), JSBI.exponentiate(TEN, JSBI.BigInt(quoteCurrency.decimals)));
return _this;

@@ -550,7 +551,7 @@ }

z = y;
x = y / TWO + ONE;
x = JSBI.add(JSBI.divide(y, TWO), ONE);
while (x < z) {
z = x;
x = (y / x + x) / TWO;
x = JSBI.divide(JSBI.add(JSBI.divide(y, x), x), TWO);
}

@@ -557,0 +558,0 @@ } else if (y !== ZERO) {

@@ -1,1 +0,2 @@

export default function babylonianSqrt(y: bigint): bigint;
import JSBI from 'jsbi';
export default function babylonianSqrt(y: JSBI): JSBI;
{
"name": "@uniswap/sdk-core",
"license": "MIT",
"version": "1.0.2",
"version": "1.0.3",
"description": "⚒️ An SDK for building applications on top of Uniswap V3",

@@ -16,3 +16,3 @@ "main": "dist/index.js",

],
"module": "dist/sdk.esm.js",
"module": "dist/sdk-core.esm.js",
"scripts": {

@@ -28,2 +28,3 @@ "build": "tsdx build",

"decimal.js-light": "^2.5.0",
"jsbi": "^3.1.4",
"tiny-invariant": "^1.1.0",

@@ -30,0 +31,0 @@ "tiny-warning": "^1.0.3",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc