Socket
Socket
Sign inDemoInstall

@uniswap/v2-sdk

Package Overview
Dependencies
Maintainers
13
Versions
36
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.0.1 to 4.1.0

4

dist/v2-sdk.cjs.development.js

@@ -371,3 +371,3 @@ 'use strict';

if (calculateFotFees === void 0) {
calculateFotFees = false;
calculateFotFees = true;
}

@@ -452,3 +452,3 @@

if (calculateFotFees === void 0) {
calculateFotFees = false;
calculateFotFees = true;
}

@@ -455,0 +455,0 @@

@@ -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=e(require("tiny-invariant")),u=require("@ethersproject/solidity"),o=require("@ethersproject/address"),i=require("@ethersproject/bignumber"),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,n=e.tokenB,i=r.sortsBefore(n)?[r,n]:[n,r];return o.getCreate2Address(t,u.keccak256(["bytes"],[u.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){return F({factoryAddress:s[e.chainId],tokenA:e,tokenB:t})};var u=e.prototype;return u.involvesToken=function(e){return e.equals(this.token0)||e.equals(this.token1)},u.priceOf=function(e){return this.involvesToken(e)||n(!1),e.equals(this.token0)?this.token0Price:this.token1Price},u.reserveOf=function(e){return this.involvesToken(e)||n(!1),e.equals(this.token0)?this.reserve0:this.reserve1},u.getOutputAmount=function(u,o){if(void 0===o&&(o=!1),this.involvesToken(u.currency)||n(!1),r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p))throw new C;var i=this.reserveOf(u.currency),s=this.reserveOf(u.currency.equals(this.token0)?this.token1:this.token0),a=o?this.derivePercentAfterSellFees(u):y,c=a.greaterThan(y)?t.CurrencyAmount.fromRawAmount(u.currency,a.multiply(u).quotient):u,l=r.multiply(c.quotient,m),f=r.multiply(l,s.quotient),h=r.add(r.multiply(i.quotient,d),l),v=t.CurrencyAmount.fromRawAmount(u.currency.equals(this.token0)?this.token1:this.token0,r.divide(f,h));if(r.equal(v.quotient,p))throw new B;var A=o?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(i.add(c),s.subtract(T))]},u.getInputAmount=function(u,o){void 0===o&&(o=!1),this.involvesToken(u.currency)||n(!1);var i=o?this.derivePercentAfterBuyFees(u):y,s=i.greaterThan(y)?t.CurrencyAmount.fromRawAmount(u.currency,r.add(u.divide(i).quotient,l)):u;if(r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p)||r.greaterThanOrEqual(u.quotient,this.reserveOf(u.currency).quotient)||r.greaterThanOrEqual(s.quotient,this.reserveOf(u.currency).quotient))throw new C;var a=this.reserveOf(u.currency),c=this.reserveOf(u.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(u.currency.equals(this.token0)?this.token1:this.token0,r.add(r.divide(f,h),l)),A=o?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(u))]},u.getLiquidityMinted=function(e,u,o){e.currency.equals(this.liquidityToken)||n(!1);var i,s=u.currency.sortsBefore(o.currency)?[u,o]:[o,u];if(s[0].currency.equals(this.token0)&&s[1].currency.equals(this.token1)||n(!1),r.equal(e.quotient,p))i=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);i=r.lessThanOrEqual(a,l)?a:l}if(!r.greaterThan(i,p))throw new B;return t.CurrencyAmount.fromRawAmount(this.liquidityToken,i)},u.getLiquidityValue=function(e,u,o,i,s){var a;if(void 0===i&&(i=!1),this.involvesToken(e)||n(!1),u.currency.equals(this.liquidityToken)||n(!1),o.currency.equals(this.liquidityToken)||n(!1),r.lessThanOrEqual(o.quotient,u.quotient)||n(!1),i){s||n(!1);var c=r.BigInt(s);if(r.equal(c,p))a=u;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(u.quotient,r.subtract(l,m)),h=r.add(r.multiply(l,f),m),y=r.divide(d,h);a=u.add(t.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else a=u}}else a=u;return t.CurrencyAmount.fromRawAmount(e,r.divide(r.multiply(o.quotient,this.reserveOf(e).quotient),a.quotient))},u.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(i.BigNumber.from(0))?v.subtract(new t.Percent(r.BigInt(n)).divide(h)):y},u.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(i.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||n(!1);var u=e[0].chainId;e.every((function(e){return e.chainId===u}))||n(!1);var o=t.wrapped;e[0].involvesToken(o)||n(!1),void 0===r||e[e.length-1].involvesToken(r.wrapped)||n(!1);for(var i,s=[o],a=O(e.entries());!(i=a()).done;){var c=i.value,p=c[1],l=s[c[0]];l.equals(p.token0)||l.equals(p.token1)||n(!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)||n(!1),e.outputAmount.currency.equals(t.outputAmount.currency)||n(!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,u){this.route=e,this.tradeType=u;var o=new Array(e.path.length);if(u===t.TradeType.EXACT_INPUT){r.currency.equals(e.input)||n(!1),o[0]=r.wrapped;for(var i=0;i<e.path.length-1;i++){var s=e.pairs[i].getOutputAmount(o[i]);o[i+1]=s[0]}this.inputAmount=t.CurrencyAmount.fromFractionalAmount(e.input,r.numerator,r.denominator),this.outputAmount=t.CurrencyAmount.fromFractionalAmount(e.output,o[o.length-1].numerator,o[o.length-1].denominator)}else{r.currency.equals(e.output)||n(!1),o[o.length-1]=r.wrapped;for(var a=e.path.length-1;a>0;a--){var c=e.pairs[a-1].getInputAmount(o[a]);o[a-1]=c[0]}this.inputAmount=t.CurrencyAmount.fromFractionalAmount(e.input,o[0].numerator,o[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)&&n(!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)&&n(!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,u,o,i,s,a,c){var l=void 0===i?{}:i,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||n(!1),h>0||n(!1),u===a||s.length>0||n(!1);for(var y=a.wrapped,v=o.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]),u.currency,o),u,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,u,o,{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,u,o,i,s,a,c){var l=void 0===i?{}:i,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=o),void 0===c&&(c=[]),r.length>0||n(!1),h>0||n(!1),o===a||s.length>0||n(!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.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),u,o.currency),o,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,u,o,{maxNumResults:m,maxHops:h-1},[T].concat(s),q,c)}}}return c},e}();function N(e){return"0x"+e.quotient.toString(16)}var D=function(){function e(){}return e.swapCallParameters=function(e,r){var u=e.inputAmount.currency.isNative,o=e.outputAmount.currency.isNative;u&&o&&n(!1),!("ttl"in r)||r.ttl>0||n(!1);var i,s,a,c=t.validateAndParseAddress(r.recipient),p=N(e.maximumAmountIn(r.allowedSlippage)),l=N(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:u?(i=d?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,f,c,m],a=p):o?(i=d?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,f,c,m],a="0x0"):(i=d?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,f,c,m],a="0x0");break;case t.TradeType.EXACT_OUTPUT:d&&n(!1),u?(i="swapETHForExactTokens",s=[l,f,c,m],a=p):o?(i="swapTokensForExactETH",s=[l,p,f,c,m],a="0x0"):(i="swapTokensForExactTokens",s=[l,p,f,c,m],a="0x0")}return{methodName:i,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=D,exports.Trade=U,exports.computePairAddress=F,exports.inputOutputComparator=S,exports.tradeComparator=j;
"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=e(require("tiny-invariant")),u=require("@ethersproject/solidity"),o=require("@ethersproject/address"),i=require("@ethersproject/bignumber"),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,n=e.tokenB,i=r.sortsBefore(n)?[r,n]:[n,r];return o.getCreate2Address(t,u.keccak256(["bytes"],[u.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){return F({factoryAddress:s[e.chainId],tokenA:e,tokenB:t})};var u=e.prototype;return u.involvesToken=function(e){return e.equals(this.token0)||e.equals(this.token1)},u.priceOf=function(e){return this.involvesToken(e)||n(!1),e.equals(this.token0)?this.token0Price:this.token1Price},u.reserveOf=function(e){return this.involvesToken(e)||n(!1),e.equals(this.token0)?this.reserve0:this.reserve1},u.getOutputAmount=function(u,o){if(void 0===o&&(o=!0),this.involvesToken(u.currency)||n(!1),r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p))throw new C;var i=this.reserveOf(u.currency),s=this.reserveOf(u.currency.equals(this.token0)?this.token1:this.token0),a=o?this.derivePercentAfterSellFees(u):y,c=a.greaterThan(y)?t.CurrencyAmount.fromRawAmount(u.currency,a.multiply(u).quotient):u,l=r.multiply(c.quotient,m),f=r.multiply(l,s.quotient),h=r.add(r.multiply(i.quotient,d),l),v=t.CurrencyAmount.fromRawAmount(u.currency.equals(this.token0)?this.token1:this.token0,r.divide(f,h));if(r.equal(v.quotient,p))throw new B;var A=o?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(i.add(c),s.subtract(T))]},u.getInputAmount=function(u,o){void 0===o&&(o=!0),this.involvesToken(u.currency)||n(!1);var i=o?this.derivePercentAfterBuyFees(u):y,s=i.greaterThan(y)?t.CurrencyAmount.fromRawAmount(u.currency,r.add(u.divide(i).quotient,l)):u;if(r.equal(this.reserve0.quotient,p)||r.equal(this.reserve1.quotient,p)||r.greaterThanOrEqual(u.quotient,this.reserveOf(u.currency).quotient)||r.greaterThanOrEqual(s.quotient,this.reserveOf(u.currency).quotient))throw new C;var a=this.reserveOf(u.currency),c=this.reserveOf(u.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(u.currency.equals(this.token0)?this.token1:this.token0,r.add(r.divide(f,h),l)),A=o?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(u))]},u.getLiquidityMinted=function(e,u,o){e.currency.equals(this.liquidityToken)||n(!1);var i,s=u.currency.sortsBefore(o.currency)?[u,o]:[o,u];if(s[0].currency.equals(this.token0)&&s[1].currency.equals(this.token1)||n(!1),r.equal(e.quotient,p))i=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);i=r.lessThanOrEqual(a,l)?a:l}if(!r.greaterThan(i,p))throw new B;return t.CurrencyAmount.fromRawAmount(this.liquidityToken,i)},u.getLiquidityValue=function(e,u,o,i,s){var a;if(void 0===i&&(i=!1),this.involvesToken(e)||n(!1),u.currency.equals(this.liquidityToken)||n(!1),o.currency.equals(this.liquidityToken)||n(!1),r.lessThanOrEqual(o.quotient,u.quotient)||n(!1),i){s||n(!1);var c=r.BigInt(s);if(r.equal(c,p))a=u;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(u.quotient,r.subtract(l,m)),h=r.add(r.multiply(l,f),m),y=r.divide(d,h);a=u.add(t.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else a=u}}else a=u;return t.CurrencyAmount.fromRawAmount(e,r.divide(r.multiply(o.quotient,this.reserveOf(e).quotient),a.quotient))},u.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(i.BigNumber.from(0))?v.subtract(new t.Percent(r.BigInt(n)).divide(h)):y},u.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(i.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||n(!1);var u=e[0].chainId;e.every((function(e){return e.chainId===u}))||n(!1);var o=t.wrapped;e[0].involvesToken(o)||n(!1),void 0===r||e[e.length-1].involvesToken(r.wrapped)||n(!1);for(var i,s=[o],a=O(e.entries());!(i=a()).done;){var c=i.value,p=c[1],l=s[c[0]];l.equals(p.token0)||l.equals(p.token1)||n(!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)||n(!1),e.outputAmount.currency.equals(t.outputAmount.currency)||n(!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,u){this.route=e,this.tradeType=u;var o=new Array(e.path.length);if(u===t.TradeType.EXACT_INPUT){r.currency.equals(e.input)||n(!1),o[0]=r.wrapped;for(var i=0;i<e.path.length-1;i++){var s=e.pairs[i].getOutputAmount(o[i]);o[i+1]=s[0]}this.inputAmount=t.CurrencyAmount.fromFractionalAmount(e.input,r.numerator,r.denominator),this.outputAmount=t.CurrencyAmount.fromFractionalAmount(e.output,o[o.length-1].numerator,o[o.length-1].denominator)}else{r.currency.equals(e.output)||n(!1),o[o.length-1]=r.wrapped;for(var a=e.path.length-1;a>0;a--){var c=e.pairs[a-1].getInputAmount(o[a]);o[a-1]=c[0]}this.inputAmount=t.CurrencyAmount.fromFractionalAmount(e.input,o[0].numerator,o[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)&&n(!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)&&n(!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,u,o,i,s,a,c){var l=void 0===i?{}:i,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||n(!1),h>0||n(!1),u===a||s.length>0||n(!1);for(var y=a.wrapped,v=o.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]),u.currency,o),u,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,u,o,{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,u,o,i,s,a,c){var l=void 0===i?{}:i,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=o),void 0===c&&(c=[]),r.length>0||n(!1),h>0||n(!1),o===a||s.length>0||n(!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.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),u,o.currency),o,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,u,o,{maxNumResults:m,maxHops:h-1},[T].concat(s),q,c)}}}return c},e}();function N(e){return"0x"+e.quotient.toString(16)}var D=function(){function e(){}return e.swapCallParameters=function(e,r){var u=e.inputAmount.currency.isNative,o=e.outputAmount.currency.isNative;u&&o&&n(!1),!("ttl"in r)||r.ttl>0||n(!1);var i,s,a,c=t.validateAndParseAddress(r.recipient),p=N(e.maximumAmountIn(r.allowedSlippage)),l=N(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:u?(i=d?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,f,c,m],a=p):o?(i=d?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,f,c,m],a="0x0"):(i=d?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,f,c,m],a="0x0");break;case t.TradeType.EXACT_OUTPUT:d&&n(!1),u?(i="swapETHForExactTokens",s=[l,f,c,m],a=p):o?(i="swapTokensForExactETH",s=[l,p,f,c,m],a="0x0"):(i="swapTokensForExactTokens",s=[l,p,f,c,m],a="0x0")}return{methodName:i,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=D,exports.Trade=U,exports.computePairAddress=F,exports.inputOutputComparator=S,exports.tradeComparator=j;
//# sourceMappingURL=v2-sdk.cjs.production.min.js.map

@@ -365,3 +365,3 @@ import { Percent, CurrencyAmount, sqrt, Token, Price, TradeType, Fraction, computePriceImpact, sortedInsert, validateAndParseAddress } from '@uniswap/sdk-core';

if (calculateFotFees === void 0) {
calculateFotFees = false;
calculateFotFees = true;
}

@@ -446,3 +446,3 @@

if (calculateFotFees === void 0) {
calculateFotFees = false;
calculateFotFees = true;
}

@@ -449,0 +449,0 @@

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

@@ -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

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