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

@uniswap/v2-sdk

Package Overview
Dependencies
Maintainers
15
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/v2-sdk - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

23

dist/v2-sdk.cjs.development.js

@@ -19,24 +19,3 @@ 'use strict';

var FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
var FACTORY_ADDRESS_MAP = {
// Mainnet
1: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Ropsten
3: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Goerli
5: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Optimism
10: '0x0c3c1c532F1e39EdF36BE9Fe0bE1410313E074Bf',
// Arbitrum
42161: '0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9',
// Avalanche
43114: '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C',
// Base
8453: '0x8909dc15e40173ff4699343b6eb8132c65e18ec6',
// BNB
56: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6',
// Polygon
137: '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C',
// Celo
42220: '0x79a530c8e2fA8748B7B40dd3629C0520c2cCf03f'
};
var FACTORY_ADDRESS_MAP = sdkCore.V2_FACTORY_ADDRESSES;
var INIT_CODE_HASH = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f';

@@ -43,0 +22,0 @@ var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000); // exports for internal consumption

2

dist/v2-sdk.cjs.production.min.js

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

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@uniswap/sdk-core"),r=e(require("jsbi")),n=require("@ethersproject/address"),u=require("@ethersproject/bignumber"),o=require("@ethersproject/solidity"),i=e(require("tiny-invariant")),s={1:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",3:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",5:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",10:"0x0c3c1c532F1e39EdF36BE9Fe0bE1410313E074Bf",42161:"0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9",43114:"0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C",8453:"0x8909dc15e40173ff4699343b6eb8132c65e18ec6",56:"0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6",137:"0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C",42220:"0x79a530c8e2fA8748B7B40dd3629C0520c2cCf03f"},a="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",c=r.BigInt(1e3),p=r.BigInt(0),l=r.BigInt(1),f=r.BigInt(5),m=r.BigInt(997),d=r.BigInt(1e3),h=r.BigInt(1e4),y=new t.Percent(p),v=new t.Percent(l);function A(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function T(e,t,r){return t&&A(e.prototype,t),r&&A(e,r),e}function q(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function k(e){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function b(e,t,r){return(b=g()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var u=new(Function.bind.apply(e,n));return r&&w(u,r.prototype),u}).apply(null,arguments)}function x(e){var t="function"==typeof Map?new Map:void 0;return(x=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return b(e,arguments,k(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,e)})(e)}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function O(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return I(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}var P="setPrototypeOf"in Object,C=function(e){function t(){var r;return(r=e.call(this)||this).isInsufficientReservesError=!0,r.name=r.constructor.name,P&&Object.setPrototypeOf(E(r),(this instanceof t?this.constructor:void 0).prototype),r}return q(t,e),t}(x(Error)),B=function(e){function t(){var r;return(r=e.call(this)||this).isInsufficientInputAmountError=!0,r.name=r.constructor.name,P&&Object.setPrototypeOf(E(r),(this instanceof t?this.constructor:void 0).prototype),r}return q(t,e),t}(x(Error)),F=function(e){var t=e.factoryAddress,r=e.tokenA,u=e.tokenB,i=r.sortsBefore(u)?[r,u]:[u,r];return n.getCreate2Address(t,o.keccak256(["bytes"],[o.pack(["address","address"],[i[0].address,i[1].address])]),a)},_=function(){function e(r,n){var u=r.currency.sortsBefore(n.currency)?[r,n]:[n,r];this.liquidityToken=new t.Token(u[0].currency.chainId,e.getAddress(u[0].currency,u[1].currency),18,"UNI-V2","Uniswap V2"),this.tokenAmounts=u}e.getAddress=function(e,t){var r,n=null!=(r=s[e.chainId])?r:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";return F({factoryAddress:n,tokenA:e,tokenB:t})};var n=e.prototype;return n.involvesToken=function(e){return e.equals(this.token0)||e.equals(this.token1)},n.priceOf=function(e){return this.involvesToken(e)||i(!1),e.equals(this.token0)?this.token0Price:this.token1Price},n.reserveOf=function(e){return this.involvesToken(e)||i(!1),e.equals(this.token0)?this.reserve0:this.reserve1},n.getOutputAmount=function(n,u){if(void 0===u&&(u=!0),this.involvesToken(n.currency)||i(!1),r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p))throw new C;var o=this.reserveOf(n.currency),s=this.reserveOf(n.currency.equals(this.token0)?this.token1:this.token0),a=u?this.derivePercentAfterSellFees(n):y,c=a.greaterThan(y)?t.CurrencyAmount.fromRawAmount(n.currency,a.multiply(n).quotient):n,l=r.multiply(c.quotient,m),f=r.multiply(l,s.quotient),h=r.add(r.multiply(o.quotient,d),l),v=t.CurrencyAmount.fromRawAmount(n.currency.equals(this.token0)?this.token1:this.token0,r.divide(f,h));if(r.equal(v.quotient,p))throw new B;var A=u?this.derivePercentAfterBuyFees(v):y,T=A.greaterThan(y)?t.CurrencyAmount.fromRawAmount(v.currency,v.multiply(A).quotient):v;if(r.equal(T.quotient,p))throw new B;return[T,new e(o.add(c),s.subtract(T))]},n.getInputAmount=function(n,u){void 0===u&&(u=!0),this.involvesToken(n.currency)||i(!1);var o=u?this.derivePercentAfterBuyFees(n):y,s=o.greaterThan(y)?t.CurrencyAmount.fromRawAmount(n.currency,r.add(n.divide(o).quotient,l)):n;if(r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p)||r.greaterThanOrEqual(n.quotient,this.reserveOf(n.currency).quotient)||r.greaterThanOrEqual(s.quotient,this.reserveOf(n.currency).quotient))throw new C;var a=this.reserveOf(n.currency),c=this.reserveOf(n.currency.equals(this.token0)?this.token1:this.token0),f=r.multiply(r.multiply(c.quotient,s.quotient),d),h=r.multiply(r.subtract(a.quotient,s.quotient),m),v=t.CurrencyAmount.fromRawAmount(n.currency.equals(this.token0)?this.token1:this.token0,r.add(r.divide(f,h),l)),A=u?this.derivePercentAfterSellFees(v):y;return[A.greaterThan(y)?t.CurrencyAmount.fromRawAmount(v.currency,r.add(v.divide(A).quotient,l)):v,new e(c.add(v),a.subtract(n))]},n.getLiquidityMinted=function(e,n,u){e.currency.equals(this.liquidityToken)||i(!1);var o,s=n.currency.sortsBefore(u.currency)?[n,u]:[u,n];if(s[0].currency.equals(this.token0)&&s[1].currency.equals(this.token1)||i(!1),r.equal(e.quotient,p))o=r.subtract(t.sqrt(r.multiply(s[0].quotient,s[1].quotient)),c);else{var a=r.divide(r.multiply(s[0].quotient,e.quotient),this.reserve0.quotient),l=r.divide(r.multiply(s[1].quotient,e.quotient),this.reserve1.quotient);o=r.lessThanOrEqual(a,l)?a:l}if(!r.greaterThan(o,p))throw new B;return t.CurrencyAmount.fromRawAmount(this.liquidityToken,o)},n.getLiquidityValue=function(e,n,u,o,s){var a;if(void 0===o&&(o=!1),this.involvesToken(e)||i(!1),n.currency.equals(this.liquidityToken)||i(!1),u.currency.equals(this.liquidityToken)||i(!1),r.lessThanOrEqual(u.quotient,n.quotient)||i(!1),o){s||i(!1);var c=r.BigInt(s);if(r.equal(c,p))a=n;else{var l=t.sqrt(r.multiply(this.reserve0.quotient,this.reserve1.quotient)),m=t.sqrt(c);if(r.greaterThan(l,m)){var d=r.multiply(n.quotient,r.subtract(l,m)),h=r.add(r.multiply(l,f),m),y=r.divide(d,h);a=n.add(t.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else a=n}}else a=n;return t.CurrencyAmount.fromRawAmount(e,r.divide(r.multiply(u.quotient,this.reserveOf(e).quotient),a.quotient))},n.derivePercentAfterSellFees=function(e){var n=this.token0.wrapped.equals(e.wrapped.currency)?this.token0.wrapped.sellFeeBps:this.token1.wrapped.sellFeeBps;return null!=n&&n.gt(u.BigNumber.from(0))?v.subtract(new t.Percent(r.BigInt(n)).divide(h)):y},n.derivePercentAfterBuyFees=function(e){var n=this.token0.wrapped.equals(e.wrapped.currency)?this.token0.wrapped.buyFeeBps:this.token1.wrapped.buyFeeBps;return null!=n&&n.gt(u.BigNumber.from(0))?v.subtract(new t.Percent(r.BigInt(n)).divide(h)):y},T(e,[{key:"token0Price",get:function(){var e=this.tokenAmounts[1].divide(this.tokenAmounts[0]);return new t.Price(this.token0,this.token1,e.denominator,e.numerator)}},{key:"token1Price",get:function(){var e=this.tokenAmounts[0].divide(this.tokenAmounts[1]);return new t.Price(this.token1,this.token0,e.denominator,e.numerator)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"token0",get:function(){return this.tokenAmounts[0].currency}},{key:"token1",get:function(){return this.tokenAmounts[1].currency}},{key:"reserve0",get:function(){return this.tokenAmounts[0]}},{key:"reserve1",get:function(){return this.tokenAmounts[1]}}]),e}(),R=function(){function e(e,t,r){this._midPrice=null,e.length>0||i(!1);var n=e[0].chainId;e.every((function(e){return e.chainId===n}))||i(!1);var u=t.wrapped;e[0].involvesToken(u)||i(!1),void 0===r||e[e.length-1].involvesToken(r.wrapped)||i(!1);for(var o,s=[u],a=O(e.entries());!(o=a()).done;){var c=o.value,p=c[1],l=s[c[0]];l.equals(p.token0)||l.equals(p.token1)||i(!1);var f=l.equals(p.token0)?p.token1:p.token0;s.push(f)}this.pairs=e,this.path=s,this.input=t,this.output=r}return T(e,[{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;for(var e,r=[],n=O(this.pairs.entries());!(e=n()).done;){var u=e.value,o=u[1];r.push(this.path[u[0]].equals(o.token0)?new t.Price(o.reserve0.currency,o.reserve1.currency,o.reserve0.quotient,o.reserve1.quotient):new t.Price(o.reserve1.currency,o.reserve0.currency,o.reserve1.quotient,o.reserve0.quotient))}var i=r.slice(1).reduce((function(e,t){return e.multiply(t)}),r[0]);return this._midPrice=new t.Price(this.input,this.output,i.denominator,i.numerator)}},{key:"chainId",get:function(){return this.pairs[0].chainId}}]),e}();function S(e,t){return e.inputAmount.currency.equals(t.inputAmount.currency)||i(!1),e.outputAmount.currency.equals(t.outputAmount.currency)||i(!1),e.outputAmount.equalTo(t.outputAmount)?e.inputAmount.equalTo(t.inputAmount)?0:e.inputAmount.lessThan(t.inputAmount)?-1:1:e.outputAmount.lessThan(t.outputAmount)?1:-1}function j(e,t){var r=S(e,t);return 0!==r?r:e.priceImpact.lessThan(t.priceImpact)?-1:e.priceImpact.greaterThan(t.priceImpact)?1:e.route.path.length-t.route.path.length}var U=function(){function e(e,r,n){this.route=e,this.tradeType=n;var u=new Array(e.path.length);if(n===t.TradeType.EXACT_INPUT){r.currency.equals(e.input)||i(!1),u[0]=r.wrapped;for(var o=0;o<e.path.length-1;o++){var s=e.pairs[o].getOutputAmount(u[o]);u[o+1]=s[0]}this.inputAmount=t.CurrencyAmount.fromFractionalAmount(e.input,r.numerator,r.denominator),this.outputAmount=t.CurrencyAmount.fromFractionalAmount(e.output,u[u.length-1].numerator,u[u.length-1].denominator)}else{r.currency.equals(e.output)||i(!1),u[u.length-1]=r.wrapped;for(var a=e.path.length-1;a>0;a--){var c=e.pairs[a-1].getInputAmount(u[a]);u[a-1]=c[0]}this.inputAmount=t.CurrencyAmount.fromFractionalAmount(e.input,u[0].numerator,u[0].denominator),this.outputAmount=t.CurrencyAmount.fromFractionalAmount(e.output,r.numerator,r.denominator)}this.executionPrice=new t.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.quotient,this.outputAmount.quotient),this.priceImpact=t.computePriceImpact(e.midPrice,this.inputAmount,this.outputAmount)}e.exactIn=function(r,n){return new e(r,n,t.TradeType.EXACT_INPUT)},e.exactOut=function(r,n){return new e(r,n,t.TradeType.EXACT_OUTPUT)};var r=e.prototype;return r.minimumAmountOut=function(e){if(e.lessThan(p)&&i(!1),this.tradeType===t.TradeType.EXACT_OUTPUT)return this.outputAmount;var r=new t.Fraction(l).add(e).invert().multiply(this.outputAmount.quotient).quotient;return t.CurrencyAmount.fromRawAmount(this.outputAmount.currency,r)},r.maximumAmountIn=function(e){if(e.lessThan(p)&&i(!1),this.tradeType===t.TradeType.EXACT_INPUT)return this.inputAmount;var r=new t.Fraction(l).add(e).multiply(this.inputAmount.quotient).quotient;return t.CurrencyAmount.fromRawAmount(this.inputAmount.currency,r)},e.bestTradeExactIn=function(r,n,u,o,s,a,c){var l=void 0===o?{}:o,f=l.maxNumResults,m=void 0===f?3:f,d=l.maxHops,h=void 0===d?3:d;void 0===s&&(s=[]),void 0===a&&(a=n),void 0===c&&(c=[]),r.length>0||i(!1),h>0||i(!1),n===a||s.length>0||i(!1);for(var y=a.wrapped,v=u.wrapped,A=0;A<r.length;A++){var T=r[A];if((T.token0.equals(y.currency)||T.token1.equals(y.currency))&&!T.reserve0.equalTo(p)&&!T.reserve1.equalTo(p)){var q=void 0;try{q=T.getOutputAmount(y)[0]}catch(e){if(e.isInsufficientInputAmountError)continue;throw e}if(q.currency.equals(v))t.sortedInsert(c,new e(new R([].concat(s,[T]),n.currency,u),n,t.TradeType.EXACT_INPUT),m,j);else if(h>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));e.bestTradeExactIn(k,n,u,{maxNumResults:m,maxHops:h-1},[].concat(s,[T]),q,c)}}}return c},r.worstExecutionPrice=function(e){return new t.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(e).quotient,this.minimumAmountOut(e).quotient)},e.bestTradeExactOut=function(r,n,u,o,s,a,c){var l=void 0===o?{}:o,f=l.maxNumResults,m=void 0===f?3:f,d=l.maxHops,h=void 0===d?3:d;void 0===s&&(s=[]),void 0===a&&(a=u),void 0===c&&(c=[]),r.length>0||i(!1),h>0||i(!1),u===a||s.length>0||i(!1);for(var y=a.wrapped,v=n.wrapped,A=0;A<r.length;A++){var T=r[A];if((T.token0.equals(y.currency)||T.token1.equals(y.currency))&&!T.reserve0.equalTo(p)&&!T.reserve1.equalTo(p)){var q=void 0;try{q=T.getInputAmount(y)[0]}catch(e){if(e.isInsufficientReservesError)continue;throw e}if(q.currency.equals(v))t.sortedInsert(c,new e(new R([T].concat(s),n,u.currency),u,t.TradeType.EXACT_OUTPUT),m,j);else if(h>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));e.bestTradeExactOut(k,n,u,{maxNumResults:m,maxHops:h-1},[T].concat(s),q,c)}}}return c},e}();function D(e){return"0x"+e.quotient.toString(16)}var N=function(){function e(){}return e.swapCallParameters=function(e,r){var n=e.inputAmount.currency.isNative,u=e.outputAmount.currency.isNative;n&&u&&i(!1),!("ttl"in r)||r.ttl>0||i(!1);var o,s,a,c=t.validateAndParseAddress(r.recipient),p=D(e.maximumAmountIn(r.allowedSlippage)),l=D(e.minimumAmountOut(r.allowedSlippage)),f=e.route.path.map((function(e){return e.address})),m="ttl"in r?"0x"+(Math.floor((new Date).getTime()/1e3)+r.ttl).toString(16):"0x"+r.deadline.toString(16),d=Boolean(r.feeOnTransfer);switch(e.tradeType){case t.TradeType.EXACT_INPUT:n?(o=d?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,f,c,m],a=p):u?(o=d?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,f,c,m],a="0x0"):(o=d?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,f,c,m],a="0x0");break;case t.TradeType.EXACT_OUTPUT:d&&i(!1),n?(o="swapETHForExactTokens",s=[l,f,c,m],a=p):u?(o="swapTokensForExactETH",s=[l,p,f,c,m],a="0x0"):(o="swapTokensForExactTokens",s=[l,p,f,c,m],a="0x0")}return{methodName:o,args:s,value:a}},e}();exports.FACTORY_ADDRESS_MAP=s,exports.INIT_CODE_HASH=a,exports.InsufficientInputAmountError=B,exports.InsufficientReservesError=C,exports.MINIMUM_LIQUIDITY=c,exports.Pair=_,exports.Route=R,exports.Router=N,exports.Trade=U,exports.computePairAddress=F,exports.inputOutputComparator=S,exports.tradeComparator=j;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@uniswap/sdk-core"),r=t(require("jsbi")),n=require("@ethersproject/address"),u=require("@ethersproject/bignumber"),o=require("@ethersproject/solidity"),i=t(require("tiny-invariant")),s=e.V2_FACTORY_ADDRESSES,a="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",c=r.BigInt(1e3),p=r.BigInt(0),l=r.BigInt(1),m=r.BigInt(5),h=r.BigInt(997),f=r.BigInt(1e3),d=r.BigInt(1e4),y=new e.Percent(p),v=new e.Percent(l);function A(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function T(t,e,r){return e&&A(t.prototype,e),r&&A(t,r),t}function q(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function k(t){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function w(t,e){return(w=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function g(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function I(t,e,r){return(I=g()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var u=new(Function.bind.apply(t,n));return r&&w(u,r.prototype),u}).apply(null,arguments)}function b(t){var e="function"==typeof Map?new Map:void 0;return(b=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return I(t,arguments,k(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)})(t)}function O(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function P(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return x(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}var E="setPrototypeOf"in Object,C=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientReservesError=!0,r.name=r.constructor.name,E&&Object.setPrototypeOf(O(r),(this instanceof e?this.constructor:void 0).prototype),r}return q(e,t),e}(b(Error)),_=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientInputAmountError=!0,r.name=r.constructor.name,E&&Object.setPrototypeOf(O(r),(this instanceof e?this.constructor:void 0).prototype),r}return q(e,t),e}(b(Error)),F=function(t){var e=t.factoryAddress,r=t.tokenA,u=t.tokenB,i=r.sortsBefore(u)?[r,u]:[u,r];return n.getCreate2Address(e,o.keccak256(["bytes"],[o.pack(["address","address"],[i[0].address,i[1].address])]),a)},R=function(){function t(r,n){var u=r.currency.sortsBefore(n.currency)?[r,n]:[n,r];this.liquidityToken=new e.Token(u[0].currency.chainId,t.getAddress(u[0].currency,u[1].currency),18,"UNI-V2","Uniswap V2"),this.tokenAmounts=u}t.getAddress=function(t,e){var r,n=null!=(r=s[t.chainId])?r:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";return F({factoryAddress:n,tokenA:t,tokenB:e})};var n=t.prototype;return n.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},n.priceOf=function(t){return this.involvesToken(t)||i(!1),t.equals(this.token0)?this.token0Price:this.token1Price},n.reserveOf=function(t){return this.involvesToken(t)||i(!1),t.equals(this.token0)?this.reserve0:this.reserve1},n.getOutputAmount=function(n,u){if(void 0===u&&(u=!0),this.involvesToken(n.currency)||i(!1),r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p))throw new C;var o=this.reserveOf(n.currency),s=this.reserveOf(n.currency.equals(this.token0)?this.token1:this.token0),a=u?this.derivePercentAfterSellFees(n):y,c=a.greaterThan(y)?e.CurrencyAmount.fromRawAmount(n.currency,a.multiply(n).quotient):n,l=r.multiply(c.quotient,h),m=r.multiply(l,s.quotient),d=r.add(r.multiply(o.quotient,f),l),v=e.CurrencyAmount.fromRawAmount(n.currency.equals(this.token0)?this.token1:this.token0,r.divide(m,d));if(r.equal(v.quotient,p))throw new _;var A=u?this.derivePercentAfterBuyFees(v):y,T=A.greaterThan(y)?e.CurrencyAmount.fromRawAmount(v.currency,v.multiply(A).quotient):v;if(r.equal(T.quotient,p))throw new _;return[T,new t(o.add(c),s.subtract(T))]},n.getInputAmount=function(n,u){void 0===u&&(u=!0),this.involvesToken(n.currency)||i(!1);var o=u?this.derivePercentAfterBuyFees(n):y,s=o.greaterThan(y)?e.CurrencyAmount.fromRawAmount(n.currency,r.add(n.divide(o).quotient,l)):n;if(r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p)||r.greaterThanOrEqual(n.quotient,this.reserveOf(n.currency).quotient)||r.greaterThanOrEqual(s.quotient,this.reserveOf(n.currency).quotient))throw new C;var a=this.reserveOf(n.currency),c=this.reserveOf(n.currency.equals(this.token0)?this.token1:this.token0),m=r.multiply(r.multiply(c.quotient,s.quotient),f),d=r.multiply(r.subtract(a.quotient,s.quotient),h),v=e.CurrencyAmount.fromRawAmount(n.currency.equals(this.token0)?this.token1:this.token0,r.add(r.divide(m,d),l)),A=u?this.derivePercentAfterSellFees(v):y;return[A.greaterThan(y)?e.CurrencyAmount.fromRawAmount(v.currency,r.add(v.divide(A).quotient,l)):v,new t(c.add(v),a.subtract(n))]},n.getLiquidityMinted=function(t,n,u){t.currency.equals(this.liquidityToken)||i(!1);var o,s=n.currency.sortsBefore(u.currency)?[n,u]:[u,n];if(s[0].currency.equals(this.token0)&&s[1].currency.equals(this.token1)||i(!1),r.equal(t.quotient,p))o=r.subtract(e.sqrt(r.multiply(s[0].quotient,s[1].quotient)),c);else{var a=r.divide(r.multiply(s[0].quotient,t.quotient),this.reserve0.quotient),l=r.divide(r.multiply(s[1].quotient,t.quotient),this.reserve1.quotient);o=r.lessThanOrEqual(a,l)?a:l}if(!r.greaterThan(o,p))throw new _;return e.CurrencyAmount.fromRawAmount(this.liquidityToken,o)},n.getLiquidityValue=function(t,n,u,o,s){var a;if(void 0===o&&(o=!1),this.involvesToken(t)||i(!1),n.currency.equals(this.liquidityToken)||i(!1),u.currency.equals(this.liquidityToken)||i(!1),r.lessThanOrEqual(u.quotient,n.quotient)||i(!1),o){s||i(!1);var c=r.BigInt(s);if(r.equal(c,p))a=n;else{var l=e.sqrt(r.multiply(this.reserve0.quotient,this.reserve1.quotient)),h=e.sqrt(c);if(r.greaterThan(l,h)){var f=r.multiply(n.quotient,r.subtract(l,h)),d=r.add(r.multiply(l,m),h),y=r.divide(f,d);a=n.add(e.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else a=n}}else a=n;return e.CurrencyAmount.fromRawAmount(t,r.divide(r.multiply(u.quotient,this.reserveOf(t).quotient),a.quotient))},n.derivePercentAfterSellFees=function(t){var n=this.token0.wrapped.equals(t.wrapped.currency)?this.token0.wrapped.sellFeeBps:this.token1.wrapped.sellFeeBps;return null!=n&&n.gt(u.BigNumber.from(0))?v.subtract(new e.Percent(r.BigInt(n)).divide(d)):y},n.derivePercentAfterBuyFees=function(t){var n=this.token0.wrapped.equals(t.wrapped.currency)?this.token0.wrapped.buyFeeBps:this.token1.wrapped.buyFeeBps;return null!=n&&n.gt(u.BigNumber.from(0))?v.subtract(new e.Percent(r.BigInt(n)).divide(d)):y},T(t,[{key:"token0Price",get:function(){var t=this.tokenAmounts[1].divide(this.tokenAmounts[0]);return new e.Price(this.token0,this.token1,t.denominator,t.numerator)}},{key:"token1Price",get:function(){var t=this.tokenAmounts[0].divide(this.tokenAmounts[1]);return new e.Price(this.token1,this.token0,t.denominator,t.numerator)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"token0",get:function(){return this.tokenAmounts[0].currency}},{key:"token1",get:function(){return this.tokenAmounts[1].currency}},{key:"reserve0",get:function(){return this.tokenAmounts[0]}},{key:"reserve1",get:function(){return this.tokenAmounts[1]}}]),t}(),B=function(){function t(t,e,r){this._midPrice=null,t.length>0||i(!1);var n=t[0].chainId;t.every((function(t){return t.chainId===n}))||i(!1);var u=e.wrapped;t[0].involvesToken(u)||i(!1),void 0===r||t[t.length-1].involvesToken(r.wrapped)||i(!1);for(var o,s=[u],a=P(t.entries());!(o=a()).done;){var c=o.value,p=c[1],l=s[c[0]];l.equals(p.token0)||l.equals(p.token1)||i(!1);var m=l.equals(p.token0)?p.token1:p.token0;s.push(m)}this.pairs=t,this.path=s,this.input=e,this.output=r}return T(t,[{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;for(var t,r=[],n=P(this.pairs.entries());!(t=n()).done;){var u=t.value,o=u[1];r.push(this.path[u[0]].equals(o.token0)?new e.Price(o.reserve0.currency,o.reserve1.currency,o.reserve0.quotient,o.reserve1.quotient):new e.Price(o.reserve1.currency,o.reserve0.currency,o.reserve1.quotient,o.reserve0.quotient))}var i=r.slice(1).reduce((function(t,e){return t.multiply(e)}),r[0]);return this._midPrice=new e.Price(this.input,this.output,i.denominator,i.numerator)}},{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}();function S(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||i(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||i(!1),t.outputAmount.equalTo(e.outputAmount)?t.inputAmount.equalTo(e.inputAmount)?0:t.inputAmount.lessThan(e.inputAmount)?-1:1:t.outputAmount.lessThan(e.outputAmount)?1:-1}function j(t,e){var r=S(t,e);return 0!==r?r:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.path.length-e.route.path.length}var U=function(){function t(t,r,n){this.route=t,this.tradeType=n;var u=new Array(t.path.length);if(n===e.TradeType.EXACT_INPUT){r.currency.equals(t.input)||i(!1),u[0]=r.wrapped;for(var o=0;o<t.path.length-1;o++){var s=t.pairs[o].getOutputAmount(u[o]);u[o+1]=s[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,r.numerator,r.denominator),this.outputAmount=e.CurrencyAmount.fromFractionalAmount(t.output,u[u.length-1].numerator,u[u.length-1].denominator)}else{r.currency.equals(t.output)||i(!1),u[u.length-1]=r.wrapped;for(var a=t.path.length-1;a>0;a--){var c=t.pairs[a-1].getInputAmount(u[a]);u[a-1]=c[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,u[0].numerator,u[0].denominator),this.outputAmount=e.CurrencyAmount.fromFractionalAmount(t.output,r.numerator,r.denominator)}this.executionPrice=new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.quotient,this.outputAmount.quotient),this.priceImpact=e.computePriceImpact(t.midPrice,this.inputAmount,this.outputAmount)}t.exactIn=function(r,n){return new t(r,n,e.TradeType.EXACT_INPUT)},t.exactOut=function(r,n){return new t(r,n,e.TradeType.EXACT_OUTPUT)};var r=t.prototype;return r.minimumAmountOut=function(t){if(t.lessThan(p)&&i(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return this.outputAmount;var r=new e.Fraction(l).add(t).invert().multiply(this.outputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.outputAmount.currency,r)},r.maximumAmountIn=function(t){if(t.lessThan(p)&&i(!1),this.tradeType===e.TradeType.EXACT_INPUT)return this.inputAmount;var r=new e.Fraction(l).add(t).multiply(this.inputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.inputAmount.currency,r)},t.bestTradeExactIn=function(r,n,u,o,s,a,c){var l=void 0===o?{}:o,m=l.maxNumResults,h=void 0===m?3:m,f=l.maxHops,d=void 0===f?3:f;void 0===s&&(s=[]),void 0===a&&(a=n),void 0===c&&(c=[]),r.length>0||i(!1),d>0||i(!1),n===a||s.length>0||i(!1);for(var y=a.wrapped,v=u.wrapped,A=0;A<r.length;A++){var T=r[A];if((T.token0.equals(y.currency)||T.token1.equals(y.currency))&&!T.reserve0.equalTo(p)&&!T.reserve1.equalTo(p)){var q=void 0;try{q=T.getOutputAmount(y)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(q.currency.equals(v))e.sortedInsert(c,new t(new B([].concat(s,[T]),n.currency,u),n,e.TradeType.EXACT_INPUT),h,j);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactIn(k,n,u,{maxNumResults:h,maxHops:d-1},[].concat(s,[T]),q,c)}}}return c},r.worstExecutionPrice=function(t){return new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactOut=function(r,n,u,o,s,a,c){var l=void 0===o?{}:o,m=l.maxNumResults,h=void 0===m?3:m,f=l.maxHops,d=void 0===f?3:f;void 0===s&&(s=[]),void 0===a&&(a=u),void 0===c&&(c=[]),r.length>0||i(!1),d>0||i(!1),u===a||s.length>0||i(!1);for(var y=a.wrapped,v=n.wrapped,A=0;A<r.length;A++){var T=r[A];if((T.token0.equals(y.currency)||T.token1.equals(y.currency))&&!T.reserve0.equalTo(p)&&!T.reserve1.equalTo(p)){var q=void 0;try{q=T.getInputAmount(y)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(q.currency.equals(v))e.sortedInsert(c,new t(new B([T].concat(s),n,u.currency),u,e.TradeType.EXACT_OUTPUT),h,j);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactOut(k,n,u,{maxNumResults:h,maxHops:d-1},[T].concat(s),q,c)}}}return c},t}();function N(t){return"0x"+t.quotient.toString(16)}var H=function(){function t(){}return t.swapCallParameters=function(t,r){var n=t.inputAmount.currency.isNative,u=t.outputAmount.currency.isNative;n&&u&&i(!1),!("ttl"in r)||r.ttl>0||i(!1);var o,s,a,c=e.validateAndParseAddress(r.recipient),p=N(t.maximumAmountIn(r.allowedSlippage)),l=N(t.minimumAmountOut(r.allowedSlippage)),m=t.route.path.map((function(t){return t.address})),h="ttl"in r?"0x"+(Math.floor((new Date).getTime()/1e3)+r.ttl).toString(16):"0x"+r.deadline.toString(16),f=Boolean(r.feeOnTransfer);switch(t.tradeType){case e.TradeType.EXACT_INPUT:n?(o=f?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,m,c,h],a=p):u?(o=f?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,m,c,h],a="0x0"):(o=f?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,m,c,h],a="0x0");break;case e.TradeType.EXACT_OUTPUT:f&&i(!1),n?(o="swapETHForExactTokens",s=[l,m,c,h],a=p):u?(o="swapTokensForExactETH",s=[l,p,m,c,h],a="0x0"):(o="swapTokensForExactTokens",s=[l,p,m,c,h],a="0x0")}return{methodName:o,args:s,value:a}},t}();exports.FACTORY_ADDRESS_MAP=s,exports.INIT_CODE_HASH=a,exports.InsufficientInputAmountError=_,exports.InsufficientReservesError=C,exports.MINIMUM_LIQUIDITY=c,exports.Pair=R,exports.Route=B,exports.Router=H,exports.Trade=U,exports.computePairAddress=F,exports.inputOutputComparator=S,exports.tradeComparator=j;
//# sourceMappingURL=v2-sdk.cjs.production.min.js.map

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

import { Percent, CurrencyAmount, sqrt, Token, Price, TradeType, Fraction, computePriceImpact, sortedInsert, validateAndParseAddress } from '@uniswap/sdk-core';
import { V2_FACTORY_ADDRESSES, Percent, CurrencyAmount, sqrt, Token, Price, TradeType, Fraction, computePriceImpact, sortedInsert, validateAndParseAddress } from '@uniswap/sdk-core';
import JSBI from 'jsbi';

@@ -13,24 +13,3 @@ import { getCreate2Address } from '@ethersproject/address';

var FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
var FACTORY_ADDRESS_MAP = {
// Mainnet
1: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Ropsten
3: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Goerli
5: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
// Optimism
10: '0x0c3c1c532F1e39EdF36BE9Fe0bE1410313E074Bf',
// Arbitrum
42161: '0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9',
// Avalanche
43114: '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C',
// Base
8453: '0x8909dc15e40173ff4699343b6eb8132c65e18ec6',
// BNB
56: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6',
// Polygon
137: '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C',
// Celo
42220: '0x79a530c8e2fA8748B7B40dd3629C0520c2cCf03f'
};
var FACTORY_ADDRESS_MAP = V2_FACTORY_ADDRESSES;
var INIT_CODE_HASH = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f';

@@ -37,0 +16,0 @@ var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000); // exports for internal consumption

{
"name": "@uniswap/v2-sdk",
"license": "MIT",
"version": "4.2.0",
"version": "4.2.1",
"description": "🛠 An SDK for building applications on top of Uniswap V2",

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

"@ethersproject/solidity": "^5.0.0",
"@uniswap/sdk-core": "^4.0.7",
"@uniswap/sdk-core": "^4.1.3",
"tiny-invariant": "^1.1.0",

@@ -30,0 +30,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