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

@uniswap/v2-sdk

Package Overview
Dependencies
Maintainers
13
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 3.2.2 to 3.2.3

1

dist/entities/pair.d.ts

@@ -97,2 +97,3 @@ import { BigintIsh, Price, Token, CurrencyAmount } from '@uniswap/sdk-core';

* @param inputAmount
* @param calculateFotFees
*/

@@ -99,0 +100,0 @@ getOutputAmount(inputAmount: CurrencyAmount<Token>, calculateFotFees?: boolean): [CurrencyAmount<Token>, Pair];

5

dist/v2-sdk.cjs.development.js

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

* @param inputAmount
* @param calculateFotFees
*/

@@ -514,3 +515,3 @@ ;

_proto.derivePercentAfterSellFees = function derivePercentAfterSellFees(inputAmount) {
var sellFeeBips = inputAmount.currency.sellFeeBps;
var sellFeeBips = this.token0.wrapped.equals(inputAmount.wrapped.currency) ? this.token0.wrapped.sellFeeBps : this.token1.wrapped.sellFeeBps;

@@ -525,3 +526,3 @@ if (sellFeeBips != null && sellFeeBips.gt(bignumber.BigNumber.from(0))) {

_proto.derivePercentAfterBuyFees = function derivePercentAfterBuyFees(outputAmount) {
var buyFeeBps = outputAmount.currency.buyFeeBps;
var buyFeeBps = this.token0.wrapped.equals(outputAmount.wrapped.currency) ? this.token0.wrapped.buyFeeBps : this.token1.wrapped.buyFeeBps;

@@ -528,0 +529,0 @@ if (buyFeeBps != null && buyFeeBps.gt(bignumber.BigNumber.from(0))) {

@@ -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 e=require("@uniswap/sdk-core"),r=t(require("jsbi")),n=t(require("tiny-invariant")),u=require("@ethersproject/solidity"),o=require("@ethersproject/address"),i=require("@ethersproject/bignumber"),s="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",a=r.BigInt(1e3),c=r.BigInt(0),p=r.BigInt(1),l=r.BigInt(5),m=r.BigInt(997),f=r.BigInt(1e3),h=r.BigInt(1e4),d=new e.Percent(c),y=new e.Percent(p);function v(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 A(t,e,r){return e&&v(t.prototype,e),r&&v(t,r),t}function T(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function q(t){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function k(t,e){return(k=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 w(t,e,r){return(w=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&&k(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 w(t,arguments,q(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),k(r,t)})(t)}function I(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 O(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 P="setPrototypeOf"in Object,E=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientReservesError=!0,r.name=r.constructor.name,P&&Object.setPrototypeOf(I(r),(this instanceof e?this.constructor:void 0).prototype),r}return T(e,t),e}(b(Error)),C=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientInputAmountError=!0,r.name=r.constructor.name,P&&Object.setPrototypeOf(I(r),(this instanceof e?this.constructor:void 0).prototype),r}return T(e,t),e}(b(Error)),_=function(t){var e=t.factoryAddress,r=t.tokenA,n=t.tokenB,i=r.sortsBefore(n)?[r,n]:[n,r];return o.getCreate2Address(e,u.keccak256(["bytes"],[u.pack(["address","address"],[i[0].address,i[1].address])]),s)},B=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){return _({factoryAddress:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",tokenA:t,tokenB:e})};var u=t.prototype;return u.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},u.priceOf=function(t){return this.involvesToken(t)||n(!1),t.equals(this.token0)?this.token0Price:this.token1Price},u.reserveOf=function(t){return this.involvesToken(t)||n(!1),t.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,c)||r.equal(this.reserve1.quotient,c))throw new E;var i=this.reserveOf(u.currency),s=this.reserveOf(u.currency.equals(this.token0)?this.token1:this.token0),a=o?this.derivePercentAfterSellFees(u):d,p=a.greaterThan(d)?e.CurrencyAmount.fromRawAmount(u.currency,a.multiply(u).quotient):u,l=r.multiply(p.quotient,m),h=r.multiply(l,s.quotient),y=r.add(r.multiply(i.quotient,f),l),v=e.CurrencyAmount.fromRawAmount(u.currency.equals(this.token0)?this.token1:this.token0,r.divide(h,y));if(r.equal(v.quotient,c))throw new C;var A=o?this.derivePercentAfterBuyFees(v):d,T=A.greaterThan(d)?e.CurrencyAmount.fromRawAmount(v.currency,v.multiply(A).quotient):v;if(r.equal(T.quotient,c))throw new C;return[T,new t(i.add(p),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):d,s=i.greaterThan(d)?e.CurrencyAmount.fromRawAmount(u.currency,r.add(u.divide(i).quotient,p)):u;if(r.equal(this.reserve0.quotient,c)||r.equal(this.reserve1.quotient,c)||r.greaterThanOrEqual(u.quotient,this.reserveOf(u.currency).quotient)||r.greaterThanOrEqual(s.quotient,this.reserveOf(u.currency).quotient))throw new E;var a=this.reserveOf(u.currency),l=this.reserveOf(u.currency.equals(this.token0)?this.token1:this.token0),h=r.multiply(r.multiply(l.quotient,s.quotient),f),y=r.multiply(r.subtract(a.quotient,s.quotient),m),v=e.CurrencyAmount.fromRawAmount(u.currency.equals(this.token0)?this.token1:this.token0,r.add(r.divide(h,y),p)),A=o?this.derivePercentAfterSellFees(v):d;return[A.greaterThan(d)?e.CurrencyAmount.fromRawAmount(v.currency,r.add(v.divide(A).quotient,p)):v,new t(l.add(v),a.subtract(u))]},u.getLiquidityMinted=function(t,u,o){t.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(t.quotient,c))i=r.subtract(e.sqrt(r.multiply(s[0].quotient,s[1].quotient)),a);else{var p=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);i=r.lessThanOrEqual(p,l)?p:l}if(!r.greaterThan(i,c))throw new C;return e.CurrencyAmount.fromRawAmount(this.liquidityToken,i)},u.getLiquidityValue=function(t,u,o,i,s){var a;if(void 0===i&&(i=!1),this.involvesToken(t)||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 p=r.BigInt(s);if(r.equal(p,c))a=u;else{var m=e.sqrt(r.multiply(this.reserve0.quotient,this.reserve1.quotient)),f=e.sqrt(p);if(r.greaterThan(m,f)){var h=r.multiply(u.quotient,r.subtract(m,f)),d=r.add(r.multiply(m,l),f),y=r.divide(h,d);a=u.add(e.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else a=u}}else a=u;return e.CurrencyAmount.fromRawAmount(t,r.divide(r.multiply(o.quotient,this.reserveOf(t).quotient),a.quotient))},u.derivePercentAfterSellFees=function(t){var n=t.currency.sellFeeBps;return null!=n&&n.gt(i.BigNumber.from(0))?y.subtract(new e.Percent(r.BigInt(n)).divide(h)):d},u.derivePercentAfterBuyFees=function(t){var n=t.currency.buyFeeBps;return null!=n&&n.gt(i.BigNumber.from(0))?y.subtract(new e.Percent(r.BigInt(n)).divide(h)):d},A(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}(),F=function(){function t(t,e,r){this._midPrice=null,t.length>0||n(!1);var u=t[0].chainId;t.every((function(t){return t.chainId===u}))||n(!1);var o=e.wrapped;t[0].involvesToken(o)||n(!1),void 0===r||t[t.length-1].involvesToken(r.wrapped)||n(!1);for(var i,s=[o],a=O(t.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 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 A(t,[{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;for(var t,r=[],n=O(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 R(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||n(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||n(!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 S(t,e){var r=R(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 j=function(){function t(t,r,u){this.route=t,this.tradeType=u;var o=new Array(t.path.length);if(u===e.TradeType.EXACT_INPUT){r.currency.equals(t.input)||n(!1),o[0]=r.wrapped;for(var i=0;i<t.path.length-1;i++){var s=t.pairs[i].getOutputAmount(o[i]);o[i+1]=s[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,r.numerator,r.denominator),this.outputAmount=e.CurrencyAmount.fromFractionalAmount(t.output,o[o.length-1].numerator,o[o.length-1].denominator)}else{r.currency.equals(t.output)||n(!1),o[o.length-1]=r.wrapped;for(var a=t.path.length-1;a>0;a--){var c=t.pairs[a-1].getInputAmount(o[a]);o[a-1]=c[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,o[0].numerator,o[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(c)&&n(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return this.outputAmount;var r=new e.Fraction(p).add(t).invert().multiply(this.outputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.outputAmount.currency,r)},r.maximumAmountIn=function(t){if(t.lessThan(c)&&n(!1),this.tradeType===e.TradeType.EXACT_INPUT)return this.inputAmount;var r=new e.Fraction(p).add(t).multiply(this.inputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.inputAmount.currency,r)},t.bestTradeExactIn=function(r,u,o,i,s,a,p){var l=void 0===i?{}:i,m=l.maxNumResults,f=void 0===m?3:m,h=l.maxHops,d=void 0===h?3:h;void 0===s&&(s=[]),void 0===a&&(a=u),void 0===p&&(p=[]),r.length>0||n(!1),d>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(c)&&!T.reserve1.equalTo(c)){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(p,new t(new F([].concat(s,[T]),u.currency,o),u,e.TradeType.EXACT_INPUT),f,S);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactIn(k,u,o,{maxNumResults:f,maxHops:d-1},[].concat(s,[T]),q,p)}}}return p},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,u,o,i,s,a,p){var l=void 0===i?{}:i,m=l.maxNumResults,f=void 0===m?3:m,h=l.maxHops,d=void 0===h?3:h;void 0===s&&(s=[]),void 0===a&&(a=o),void 0===p&&(p=[]),r.length>0||n(!1),d>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(c)&&!T.reserve1.equalTo(c)){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(p,new t(new F([T].concat(s),u,o.currency),o,e.TradeType.EXACT_OUTPUT),f,S);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactOut(k,u,o,{maxNumResults:f,maxHops:d-1},[T].concat(s),q,p)}}}return p},t}();function U(t){return"0x"+t.quotient.toString(16)}var N=function(){function t(){}return t.swapCallParameters=function(t,r){var u=t.inputAmount.currency.isNative,o=t.outputAmount.currency.isNative;u&&o&&n(!1),!("ttl"in r)||r.ttl>0||n(!1);var i,s,a,c=e.validateAndParseAddress(r.recipient),p=U(t.maximumAmountIn(r.allowedSlippage)),l=U(t.minimumAmountOut(r.allowedSlippage)),m=t.route.path.map((function(t){return t.address})),f="ttl"in r?"0x"+(Math.floor((new Date).getTime()/1e3)+r.ttl).toString(16):"0x"+r.deadline.toString(16),h=Boolean(r.feeOnTransfer);switch(t.tradeType){case e.TradeType.EXACT_INPUT:u?(i=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,m,c,f],a=p):o?(i=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,m,c,f],a="0x0"):(i=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,m,c,f],a="0x0");break;case e.TradeType.EXACT_OUTPUT:h&&n(!1),u?(i="swapETHForExactTokens",s=[l,m,c,f],a=p):o?(i="swapTokensForExactETH",s=[l,p,m,c,f],a="0x0"):(i="swapTokensForExactTokens",s=[l,p,m,c,f],a="0x0")}return{methodName:i,args:s,value:a}},t}();exports.FACTORY_ADDRESS="0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",exports.INIT_CODE_HASH=s,exports.InsufficientInputAmountError=C,exports.InsufficientReservesError=E,exports.MINIMUM_LIQUIDITY=a,exports.Pair=B,exports.Route=F,exports.Router=N,exports.Trade=j,exports.computePairAddress=_,exports.inputOutputComparator=R,exports.tradeComparator=S;
"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=t(require("tiny-invariant")),u=require("@ethersproject/solidity"),o=require("@ethersproject/address"),i=require("@ethersproject/bignumber"),s="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",a=r.BigInt(1e3),c=r.BigInt(0),p=r.BigInt(1),l=r.BigInt(5),m=r.BigInt(997),f=r.BigInt(1e3),h=r.BigInt(1e4),d=new e.Percent(c),y=new e.Percent(p);function v(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 A(t,e,r){return e&&v(t.prototype,e),r&&v(t,r),t}function T(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function q(t){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function w(){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 g(t,e,r){return(g=w()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var u=new(Function.bind.apply(t,n));return r&&k(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 g(t,arguments,q(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),k(r,t)})(t)}function I(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 O(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 P="setPrototypeOf"in Object,E=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientReservesError=!0,r.name=r.constructor.name,P&&Object.setPrototypeOf(I(r),(this instanceof e?this.constructor:void 0).prototype),r}return T(e,t),e}(b(Error)),C=function(t){function e(){var r;return(r=t.call(this)||this).isInsufficientInputAmountError=!0,r.name=r.constructor.name,P&&Object.setPrototypeOf(I(r),(this instanceof e?this.constructor:void 0).prototype),r}return T(e,t),e}(b(Error)),B=function(t){var e=t.factoryAddress,r=t.tokenA,n=t.tokenB,i=r.sortsBefore(n)?[r,n]:[n,r];return o.getCreate2Address(e,u.keccak256(["bytes"],[u.pack(["address","address"],[i[0].address,i[1].address])]),s)},F=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){return B({factoryAddress:"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",tokenA:t,tokenB:e})};var u=t.prototype;return u.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},u.priceOf=function(t){return this.involvesToken(t)||n(!1),t.equals(this.token0)?this.token0Price:this.token1Price},u.reserveOf=function(t){return this.involvesToken(t)||n(!1),t.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,c)||r.equal(this.reserve1.quotient,c))throw new E;var i=this.reserveOf(u.currency),s=this.reserveOf(u.currency.equals(this.token0)?this.token1:this.token0),a=o?this.derivePercentAfterSellFees(u):d,p=a.greaterThan(d)?e.CurrencyAmount.fromRawAmount(u.currency,a.multiply(u).quotient):u,l=r.multiply(p.quotient,m),h=r.multiply(l,s.quotient),y=r.add(r.multiply(i.quotient,f),l),v=e.CurrencyAmount.fromRawAmount(u.currency.equals(this.token0)?this.token1:this.token0,r.divide(h,y));if(r.equal(v.quotient,c))throw new C;var A=o?this.derivePercentAfterBuyFees(v):d,T=A.greaterThan(d)?e.CurrencyAmount.fromRawAmount(v.currency,v.multiply(A).quotient):v;if(r.equal(T.quotient,c))throw new C;return[T,new t(i.add(p),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):d,s=i.greaterThan(d)?e.CurrencyAmount.fromRawAmount(u.currency,r.add(u.divide(i).quotient,p)):u;if(r.equal(this.reserve0.quotient,c)||r.equal(this.reserve1.quotient,c)||r.greaterThanOrEqual(u.quotient,this.reserveOf(u.currency).quotient)||r.greaterThanOrEqual(s.quotient,this.reserveOf(u.currency).quotient))throw new E;var a=this.reserveOf(u.currency),l=this.reserveOf(u.currency.equals(this.token0)?this.token1:this.token0),h=r.multiply(r.multiply(l.quotient,s.quotient),f),y=r.multiply(r.subtract(a.quotient,s.quotient),m),v=e.CurrencyAmount.fromRawAmount(u.currency.equals(this.token0)?this.token1:this.token0,r.add(r.divide(h,y),p)),A=o?this.derivePercentAfterSellFees(v):d;return[A.greaterThan(d)?e.CurrencyAmount.fromRawAmount(v.currency,r.add(v.divide(A).quotient,p)):v,new t(l.add(v),a.subtract(u))]},u.getLiquidityMinted=function(t,u,o){t.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(t.quotient,c))i=r.subtract(e.sqrt(r.multiply(s[0].quotient,s[1].quotient)),a);else{var p=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);i=r.lessThanOrEqual(p,l)?p:l}if(!r.greaterThan(i,c))throw new C;return e.CurrencyAmount.fromRawAmount(this.liquidityToken,i)},u.getLiquidityValue=function(t,u,o,i,s){var a;if(void 0===i&&(i=!1),this.involvesToken(t)||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 p=r.BigInt(s);if(r.equal(p,c))a=u;else{var m=e.sqrt(r.multiply(this.reserve0.quotient,this.reserve1.quotient)),f=e.sqrt(p);if(r.greaterThan(m,f)){var h=r.multiply(u.quotient,r.subtract(m,f)),d=r.add(r.multiply(m,l),f),y=r.divide(h,d);a=u.add(e.CurrencyAmount.fromRawAmount(this.liquidityToken,y))}else a=u}}else a=u;return e.CurrencyAmount.fromRawAmount(t,r.divide(r.multiply(o.quotient,this.reserveOf(t).quotient),a.quotient))},u.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(i.BigNumber.from(0))?y.subtract(new e.Percent(r.BigInt(n)).divide(h)):d},u.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(i.BigNumber.from(0))?y.subtract(new e.Percent(r.BigInt(n)).divide(h)):d},A(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}(),_=function(){function t(t,e,r){this._midPrice=null,t.length>0||n(!1);var u=t[0].chainId;t.every((function(t){return t.chainId===u}))||n(!1);var o=e.wrapped;t[0].involvesToken(o)||n(!1),void 0===r||t[t.length-1].involvesToken(r.wrapped)||n(!1);for(var i,s=[o],a=O(t.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 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 A(t,[{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;for(var t,r=[],n=O(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 R(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||n(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||n(!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 S(t,e){var r=R(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 j=function(){function t(t,r,u){this.route=t,this.tradeType=u;var o=new Array(t.path.length);if(u===e.TradeType.EXACT_INPUT){r.currency.equals(t.input)||n(!1),o[0]=r.wrapped;for(var i=0;i<t.path.length-1;i++){var s=t.pairs[i].getOutputAmount(o[i]);o[i+1]=s[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,r.numerator,r.denominator),this.outputAmount=e.CurrencyAmount.fromFractionalAmount(t.output,o[o.length-1].numerator,o[o.length-1].denominator)}else{r.currency.equals(t.output)||n(!1),o[o.length-1]=r.wrapped;for(var a=t.path.length-1;a>0;a--){var c=t.pairs[a-1].getInputAmount(o[a]);o[a-1]=c[0]}this.inputAmount=e.CurrencyAmount.fromFractionalAmount(t.input,o[0].numerator,o[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(c)&&n(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return this.outputAmount;var r=new e.Fraction(p).add(t).invert().multiply(this.outputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.outputAmount.currency,r)},r.maximumAmountIn=function(t){if(t.lessThan(c)&&n(!1),this.tradeType===e.TradeType.EXACT_INPUT)return this.inputAmount;var r=new e.Fraction(p).add(t).multiply(this.inputAmount.quotient).quotient;return e.CurrencyAmount.fromRawAmount(this.inputAmount.currency,r)},t.bestTradeExactIn=function(r,u,o,i,s,a,p){var l=void 0===i?{}:i,m=l.maxNumResults,f=void 0===m?3:m,h=l.maxHops,d=void 0===h?3:h;void 0===s&&(s=[]),void 0===a&&(a=u),void 0===p&&(p=[]),r.length>0||n(!1),d>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(c)&&!T.reserve1.equalTo(c)){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(p,new t(new _([].concat(s,[T]),u.currency,o),u,e.TradeType.EXACT_INPUT),f,S);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactIn(k,u,o,{maxNumResults:f,maxHops:d-1},[].concat(s,[T]),q,p)}}}return p},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,u,o,i,s,a,p){var l=void 0===i?{}:i,m=l.maxNumResults,f=void 0===m?3:m,h=l.maxHops,d=void 0===h?3:h;void 0===s&&(s=[]),void 0===a&&(a=o),void 0===p&&(p=[]),r.length>0||n(!1),d>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(c)&&!T.reserve1.equalTo(c)){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(p,new t(new _([T].concat(s),u,o.currency),o,e.TradeType.EXACT_OUTPUT),f,S);else if(d>1&&r.length>1){var k=r.slice(0,A).concat(r.slice(A+1,r.length));t.bestTradeExactOut(k,u,o,{maxNumResults:f,maxHops:d-1},[T].concat(s),q,p)}}}return p},t}();function U(t){return"0x"+t.quotient.toString(16)}var N=function(){function t(){}return t.swapCallParameters=function(t,r){var u=t.inputAmount.currency.isNative,o=t.outputAmount.currency.isNative;u&&o&&n(!1),!("ttl"in r)||r.ttl>0||n(!1);var i,s,a,c=e.validateAndParseAddress(r.recipient),p=U(t.maximumAmountIn(r.allowedSlippage)),l=U(t.minimumAmountOut(r.allowedSlippage)),m=t.route.path.map((function(t){return t.address})),f="ttl"in r?"0x"+(Math.floor((new Date).getTime()/1e3)+r.ttl).toString(16):"0x"+r.deadline.toString(16),h=Boolean(r.feeOnTransfer);switch(t.tradeType){case e.TradeType.EXACT_INPUT:u?(i=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",s=[l,m,c,f],a=p):o?(i=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",s=[p,l,m,c,f],a="0x0"):(i=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[p,l,m,c,f],a="0x0");break;case e.TradeType.EXACT_OUTPUT:h&&n(!1),u?(i="swapETHForExactTokens",s=[l,m,c,f],a=p):o?(i="swapTokensForExactETH",s=[l,p,m,c,f],a="0x0"):(i="swapTokensForExactTokens",s=[l,p,m,c,f],a="0x0")}return{methodName:i,args:s,value:a}},t}();exports.FACTORY_ADDRESS="0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",exports.INIT_CODE_HASH=s,exports.InsufficientInputAmountError=C,exports.InsufficientReservesError=E,exports.MINIMUM_LIQUIDITY=a,exports.Pair=F,exports.Route=_,exports.Router=N,exports.Trade=j,exports.computePairAddress=B,exports.inputOutputComparator=R,exports.tradeComparator=S;
//# sourceMappingURL=v2-sdk.cjs.production.min.js.map

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

* @param inputAmount
* @param calculateFotFees
*/

@@ -508,3 +509,3 @@ ;

_proto.derivePercentAfterSellFees = function derivePercentAfterSellFees(inputAmount) {
var sellFeeBips = inputAmount.currency.sellFeeBps;
var sellFeeBips = this.token0.wrapped.equals(inputAmount.wrapped.currency) ? this.token0.wrapped.sellFeeBps : this.token1.wrapped.sellFeeBps;

@@ -519,3 +520,3 @@ if (sellFeeBips != null && sellFeeBips.gt(BigNumber.from(0))) {

_proto.derivePercentAfterBuyFees = function derivePercentAfterBuyFees(outputAmount) {
var buyFeeBps = outputAmount.currency.buyFeeBps;
var buyFeeBps = this.token0.wrapped.equals(outputAmount.wrapped.currency) ? this.token0.wrapped.buyFeeBps : this.token1.wrapped.buyFeeBps;

@@ -522,0 +523,0 @@ if (buyFeeBps != null && buyFeeBps.gt(BigNumber.from(0))) {

{
"name": "@uniswap/v2-sdk",
"license": "MIT",
"version": "3.2.2",
"version": "3.2.3",
"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