@uniswap/sdk-core
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -423,2 +423,28 @@ 'use strict'; | ||
/** | ||
* Given a currency which can be Ether or a token, return wrapped ether for ether and the token for the token | ||
* @param currency the currency to wrap, if necessary | ||
* @param chainId the ID of the chain for wrapping | ||
*/ | ||
function wrappedCurrency(currency, chainId) { | ||
if (currency.isToken) { | ||
!(currency.chainId === chainId) ? invariant(false, 'CHAIN_ID') : void 0; | ||
return currency; | ||
} | ||
if (currency.isEther) return WETH9[chainId]; | ||
throw new Error('CURRENCY'); | ||
} | ||
/** | ||
* Given a currency amount and a chain ID, returns the equivalent representation as a wrapped token amount. | ||
* In other words, if the currency is ETHER, returns the WETH9 token amount for the given chain. Otherwise, returns | ||
* the input currency amount. | ||
*/ | ||
function wrappedCurrencyAmount(currencyAmount, chainId) { | ||
return new CurrencyAmount(wrappedCurrency(currencyAmount.currency, chainId), currencyAmount.raw); | ||
} | ||
var Big$1 = /*#__PURE__*/toFormat(_Big); | ||
@@ -585,2 +611,4 @@ | ||
exports.validateAndParseAddress = validateAndParseAddress; | ||
exports.wrappedCurrency = wrappedCurrency; | ||
exports.wrappedCurrencyAmount = wrappedCurrencyAmount; | ||
//# 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("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(n){throw new Error(t+" is not a valid address.")}}var m,y=function(t,n,r){t>=0&&t<255&&Number.isInteger(t)||o(!1),this.decimals=t,this.symbol=n,this.name=r},g=function(t){function n(n,r,e,i,o){var a;return(a=t.call(this,e,i,o)||this).isEther=!1,a.isToken=!0,a.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),v=((m={})[exports.ChainId.MAINNET]=new g(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH9","Wrapped Ether"),m[exports.ChainId.ROPSTEN]=new g(exports.ChainId.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),m[exports.ChainId.RINKEBY]=new g(exports.ChainId.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),m[exports.ChainId.GÖRLI]=new g(exports.ChainId.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH9","Wrapped Ether"),m[exports.ChainId.KOVAN]=new g(exports.ChainId.KOVAN,"0xd0A1E359811322d97991E03f863a0C30C2cF029C",18,"WETH9","Wrapped Ether"),m),I=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).isEther=!0,n.isToken=!1,n}return p(n,t),n}(y);I.ETHER=new I(18,"ETH","Ether");var x,N,E=I.ETHER,T=d(u),R=d(s),w=((x={})[exports.Rounding.ROUND_DOWN]=T.ROUND_DOWN,x[exports.Rounding.ROUND_HALF_UP]=T.ROUND_HALF_UP,x[exports.Rounding.ROUND_UP]=T.ROUND_UP,x),O=((N={})[exports.Rounding.ROUND_DOWN]=0,N[exports.Rounding.ROUND_HALF_UP]=1,N[exports.Rounding.ROUND_UP]=3,N),U=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),T.set({precision:t+1,rounding:w[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)||o(!1),t>=0||o(!1),R.DP=t,R.RM=O[r],new R(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}(),_=new U(i.BigInt(100));function C(t){return new A(t.numerator,t.denominator)}var A=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).isPercent=!0,n}p(n,t);var r=n.prototype;return r.add=function(n){return C(t.prototype.add.call(this,n))},r.subtract=function(n){return C(t.prototype.subtract.call(this,n))},r.multiply=function(n){return C(t.prototype.multiply.call(this,n))},r.divide=function(n){return C(t.prototype.divide.call(this,n))},r.toSignificant=function(t,n,r){return void 0===t&&(t=5),this.multiply(_).toSignificant(t,n,r)},r.toFixed=function(t,n,r){return void 0===t&&(t=2),this.multiply(_).toFixed(t,n,r)},n}(U),B=i.BigInt(Number.MAX_SAFE_INTEGER),D=i.BigInt(0),b=i.BigInt(1),P=i.BigInt(2);function F(t,n){return t.isToken&&n.isToken?t.equals(n):!t.isToken&&!n.isToken&&t.isEther===n.isEther}var q=d(s),S=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(E,t)};var r=n.prototype;return r.add=function(t){return F(this.currency,t.currency)||o(!1),new n(this.currency,i.add(this.raw,t.raw))},r.subtract=function(t){return F(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:""}),q.DP=this.currency.decimals,new q(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},h(n,[{key:"raw",get:function(){return this.numerator}}]),n}(U),W=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 U(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){F(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 F(n.currency,this.baseCurrency)||o(!1),new S(this.quoteCurrency,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 U(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),n}(U);exports.CurrencyAmount=S,exports.ETHER=E,exports.Ether=I,exports.Fraction=U,exports.MaxUint256=c,exports.Percent=A,exports.Price=W,exports.Token=g,exports.WETH9=v,exports.currencyEquals=F,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,D)||o(!1),i.lessThan(t,B))return i.BigInt(Math.floor(Math.sqrt(i.toNumber(t))));var n,r;for(n=t,r=i.add(i.divide(t,P),b);i.lessThan(r,n);)n=r,r=i.divide(i.add(i.divide(t,r),r),P);return n},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("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(n){throw new Error(t+" is not a valid address.")}}var m,y=function(t,n,r){t>=0&&t<255&&Number.isInteger(t)||o(!1),this.decimals=t,this.symbol=n,this.name=r},g=function(t){function n(n,r,e,i,o){var a;return(a=t.call(this,e,i,o)||this).isEther=!1,a.isToken=!0,a.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),v=((m={})[exports.ChainId.MAINNET]=new g(exports.ChainId.MAINNET,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH9","Wrapped Ether"),m[exports.ChainId.ROPSTEN]=new g(exports.ChainId.ROPSTEN,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),m[exports.ChainId.RINKEBY]=new g(exports.ChainId.RINKEBY,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH9","Wrapped Ether"),m[exports.ChainId.GÖRLI]=new g(exports.ChainId.GÖRLI,"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",18,"WETH9","Wrapped Ether"),m[exports.ChainId.KOVAN]=new g(exports.ChainId.KOVAN,"0xd0A1E359811322d97991E03f863a0C30C2cF029C",18,"WETH9","Wrapped Ether"),m),I=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).isEther=!0,n.isToken=!1,n}return p(n,t),n}(y);I.ETHER=new I(18,"ETH","Ether");var x,E,N=I.ETHER,w=d(u),R=d(s),T=((x={})[exports.Rounding.ROUND_DOWN]=w.ROUND_DOWN,x[exports.Rounding.ROUND_HALF_UP]=w.ROUND_HALF_UP,x[exports.Rounding.ROUND_UP]=w.ROUND_UP,x),O=((E={})[exports.Rounding.ROUND_DOWN]=0,E[exports.Rounding.ROUND_HALF_UP]=1,E[exports.Rounding.ROUND_UP]=3,E),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),w.set({precision:t+1,rounding:T[r]});var e=new w(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),R.DP=t,R.RM=O[r],new R(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){return new A(t.numerator,t.denominator)}var A=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).isPercent=!0,n}p(n,t);var r=n.prototype;return r.add=function(n){return _(t.prototype.add.call(this,n))},r.subtract=function(n){return _(t.prototype.subtract.call(this,n))},r.multiply=function(n){return _(t.prototype.multiply.call(this,n))},r.divide=function(n){return _(t.prototype.divide.call(this,n))},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),B=i.BigInt(Number.MAX_SAFE_INTEGER),D=i.BigInt(0),b=i.BigInt(1),P=i.BigInt(2);function F(t,n){return t.isToken&&n.isToken?t.equals(n):!t.isToken&&!n.isToken&&t.isEther===n.isEther}function q(t,n){if(t.isToken)return t.chainId!==n&&o(!1),t;if(t.isEther)return v[n];throw new Error("CURRENCY")}var S=d(s),W=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(N,t)};var r=n.prototype;return r.add=function(t){return F(this.currency,t.currency)||o(!1),new n(this.currency,i.add(this.raw,t.raw))},r.subtract=function(t){return F(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:""}),S.DP=this.currency.decimals,new S(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},h(n,[{key:"raw",get:function(){return this.numerator}}]),n}(C),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 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){F(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 F(n.currency,this.baseCurrency)||o(!1),new W(this.quoteCurrency,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.CurrencyAmount=W,exports.ETHER=N,exports.Ether=I,exports.Fraction=C,exports.MaxUint256=c,exports.Percent=A,exports.Price=H,exports.Token=g,exports.WETH9=v,exports.currencyEquals=F,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,D)||o(!1),i.lessThan(t,B))return i.BigInt(Math.floor(Math.sqrt(i.toNumber(t))));var n,r;for(n=t,r=i.add(i.divide(t,P),b);i.lessThan(r,n);)n=r,r=i.divide(i.add(i.divide(t,r),r),P);return n},exports.validateAndParseAddress=l,exports.wrappedCurrency=q,exports.wrappedCurrencyAmount=function(t,n){return new W(q(t.currency,n),t.raw)}; | ||
//# sourceMappingURL=sdk-core.cjs.production.min.js.map |
@@ -423,2 +423,28 @@ import JSBI from 'jsbi'; | ||
/** | ||
* Given a currency which can be Ether or a token, return wrapped ether for ether and the token for the token | ||
* @param currency the currency to wrap, if necessary | ||
* @param chainId the ID of the chain for wrapping | ||
*/ | ||
function wrappedCurrency(currency, chainId) { | ||
if (currency.isToken) { | ||
!(currency.chainId === chainId) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CHAIN_ID') : invariant(false) : void 0; | ||
return currency; | ||
} | ||
if (currency.isEther) return WETH9[chainId]; | ||
throw new Error('CURRENCY'); | ||
} | ||
/** | ||
* Given a currency amount and a chain ID, returns the equivalent representation as a wrapped token amount. | ||
* In other words, if the currency is ETHER, returns the WETH9 token amount for the given chain. Otherwise, returns | ||
* the input currency amount. | ||
*/ | ||
function wrappedCurrencyAmount(currencyAmount, chainId) { | ||
return new CurrencyAmount(wrappedCurrency(currencyAmount.currency, chainId), currencyAmount.raw); | ||
} | ||
var Big$1 = /*#__PURE__*/toFormat(_Big); | ||
@@ -572,3 +598,3 @@ | ||
export { ChainId, CurrencyAmount, ETHER, Ether, Fraction, MaxUint256, Percent, Price, Rounding, Token, TradeType, WETH9, currencyEquals, sortedInsert, sqrt, validateAndParseAddress }; | ||
export { ChainId, CurrencyAmount, ETHER, Ether, Fraction, MaxUint256, Percent, Price, Rounding, Token, TradeType, WETH9, currencyEquals, sortedInsert, sqrt, validateAndParseAddress, wrappedCurrency, wrappedCurrencyAmount }; | ||
//# sourceMappingURL=sdk-core.esm.js.map |
@@ -6,1 +6,3 @@ import sortedInsert from './sortedInsert'; | ||
export { currencyEquals } from './currencyEquals'; | ||
export { wrappedCurrency } from './wrappedCurrency'; | ||
export { wrappedCurrencyAmount } from './wrappedCurrencyAmount'; |
{ | ||
"name": "@uniswap/sdk-core", | ||
"license": "MIT", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"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
164068
1205
19