Socket
Socket
Sign inDemoInstall

@uniswap/v3-sdk

Package Overview
Dependencies
Maintainers
8
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/v3-sdk - npm Package Compare versions

Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3

dist/utils/index.d.ts

1

dist/index.d.ts

@@ -5,1 +5,2 @@ export { FACTORY_ADDRESS, INIT_CODE_HASH } from './constants';

export * from './router';
export * from './utils';

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

var invariant = _interopDefault(require('tiny-invariant'));
require('decimal.js-light');

@@ -875,2 +876,113 @@ var _TICK_SPACINGS;

var TWO = /*#__PURE__*/JSBI.BigInt(2);
var POWERS_OF_2 = /*#__PURE__*/[128, 64, 32, 16, 8, 4, 2, 1].map(function (pow) {
return [pow, JSBI.exponentiate(TWO, JSBI.BigInt(pow))];
});
function mostSignificantBit(x) {
!JSBI.greaterThan(x, ZERO) ? invariant(false, 'ZERO') : void 0;
var msb = 0;
for (var _iterator = _createForOfIteratorHelperLoose(POWERS_OF_2), _step; !(_step = _iterator()).done;) {
var _step$value = _step.value,
power = _step$value[0],
min = _step$value[1];
if (JSBI.greaterThanOrEqual(x, min)) {
x = JSBI.signedRightShift(x, JSBI.BigInt(power));
msb += power;
}
}
return msb;
}
function mulShift(val, mulBy) {
return JSBI.signedRightShift(JSBI.multiply(val, JSBI.BigInt(mulBy)), JSBI.BigInt(128));
}
var Q32 = /*#__PURE__*/JSBI.exponentiate( /*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(32));
var TickMath = /*#__PURE__*/function () {
/**
* Cannot be constructed.
*/
function TickMath() {}
TickMath.getSqrtRatioAtTick = function getSqrtRatioAtTick(tick) {
var absTick = tick < 0 ? tick * -1 : tick;
!(absTick <= TickMath.MAX_TICK) ? invariant(false, 'ABS_TICK') : void 0;
var ratio = (absTick & 0x1) != 0 ? JSBI.BigInt('0xfffcb933bd6fad37aa2d162d1a594001') : JSBI.BigInt('0x100000000000000000000000000000000');
if ((absTick & 0x2) != 0) ratio = mulShift(ratio, '0xfff97272373d413259a46990580e213a');
if ((absTick & 0x4) != 0) ratio = mulShift(ratio, '0xfff2e50f5f656932ef12357cf3c7fdcc');
if ((absTick & 0x8) != 0) ratio = mulShift(ratio, '0xffe5caca7e10e4e61c3624eaa0941cd0');
if ((absTick & 0x10) != 0) ratio = mulShift(ratio, '0xffcb9843d60f6159c9db58835c926644');
if ((absTick & 0x20) != 0) ratio = mulShift(ratio, '0xff973b41fa98c081472e6896dfb254c0');
if ((absTick & 0x40) != 0) ratio = mulShift(ratio, '0xff2ea16466c96a3843ec78b326b52861');
if ((absTick & 0x80) != 0) ratio = mulShift(ratio, '0xfe5dee046a99a2a811c461f1969c3053');
if ((absTick & 0x100) != 0) ratio = mulShift(ratio, '0xfcbe86c7900a88aedcffc83b479aa3a4');
if ((absTick & 0x200) != 0) ratio = mulShift(ratio, '0xf987a7253ac413176f2b074cf7815e54');
if ((absTick & 0x400) != 0) ratio = mulShift(ratio, '0xf3392b0822b70005940c7a398e4b70f3');
if ((absTick & 0x800) != 0) ratio = mulShift(ratio, '0xe7159475a2c29b7443b29c7fa6e889d9');
if ((absTick & 0x1000) != 0) ratio = mulShift(ratio, '0xd097f3bdfd2022b8845ad8f792aa5825');
if ((absTick & 0x2000) != 0) ratio = mulShift(ratio, '0xa9f746462d870fdf8a65dc1f90e061e5');
if ((absTick & 0x4000) != 0) ratio = mulShift(ratio, '0x70d869a156d2a1b890bb3df62baf32f7');
if ((absTick & 0x8000) != 0) ratio = mulShift(ratio, '0x31be135f97d08fd981231505542fcfa6');
if ((absTick & 0x10000) != 0) ratio = mulShift(ratio, '0x9aa508b5b7a84e1c677de54f3e99bc9');
if ((absTick & 0x20000) != 0) ratio = mulShift(ratio, '0x5d6af8dedb81196699c329225ee604');
if ((absTick & 0x40000) != 0) ratio = mulShift(ratio, '0x2216e584f5fa1ea926041bedfe98');
if ((absTick & 0x80000) != 0) ratio = mulShift(ratio, '0x48a170391f7dc42444e8fa2');
if (tick > 0) ratio = JSBI.divide(sdkCore.MaxUint256, ratio); // back to Q96
return JSBI.greaterThanOrEqual(JSBI.remainder(ratio, Q32), ZERO) ? JSBI.add(JSBI.divide(ratio, Q32), ONE) : JSBI.divide(ratio, Q32);
};
TickMath.getTickAtSqrtRatio = function getTickAtSqrtRatio(sqrtRatioX96) {
!(JSBI.greaterThanOrEqual(sqrtRatioX96, TickMath.MIN_SQRT_RATIO) && JSBI.lessThan(sqrtRatioX96, TickMath.MAX_SQRT_RATIO)) ? invariant(false, 'SQRT_RATIO') : void 0;
var sqrtRatioX128 = JSBI.leftShift(sqrtRatioX96, JSBI.BigInt(32));
var msb = mostSignificantBit(sqrtRatioX128);
var r;
if (JSBI.greaterThanOrEqual(JSBI.BigInt(msb), JSBI.BigInt(128))) {
r = JSBI.signedRightShift(sqrtRatioX128, JSBI.BigInt(msb - 127));
} else {
r = JSBI.leftShift(sqrtRatioX128, JSBI.BigInt(127 - msb));
}
var log_2 = JSBI.leftShift(JSBI.subtract(JSBI.BigInt(msb), JSBI.BigInt(128)), JSBI.BigInt(64));
for (var i = 0; i < 14; i++) {
r = JSBI.signedRightShift(JSBI.multiply(r, r), JSBI.BigInt(127));
var f = JSBI.signedRightShift(r, JSBI.BigInt(128));
log_2 = JSBI.bitwiseOr(log_2, JSBI.leftShift(f, JSBI.BigInt(63 - i)));
r = JSBI.signedRightShift(r, f);
}
var log_sqrt10001 = JSBI.multiply(log_2, JSBI.BigInt('255738958999603826347141'));
var tickLow = JSBI.toNumber(JSBI.signedRightShift(JSBI.subtract(log_sqrt10001, JSBI.BigInt('3402992956809132418596140100660247210')), JSBI.BigInt(128)));
var tickHigh = JSBI.toNumber(JSBI.signedRightShift(JSBI.add(log_sqrt10001, JSBI.BigInt('291339464771989622907027621153398088495')), JSBI.BigInt(128)));
return tickLow === tickHigh ? tickLow : JSBI.lessThanOrEqual(TickMath.getSqrtRatioAtTick(tickHigh), sqrtRatioX96) ? tickHigh : tickLow;
};
return TickMath;
}();
TickMath.MIN_TICK = -887272;
TickMath.MAX_TICK = -TickMath.MIN_TICK;
TickMath.MIN_SQRT_RATIO = /*#__PURE__*/JSBI.BigInt('4295128739');
TickMath.MAX_SQRT_RATIO = /*#__PURE__*/JSBI.BigInt('1461446703485210103287273052203988822378723970342');
var SQUARED_PRICE_DENOMINATOR = /*#__PURE__*/JSBI.exponentiate( /*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(192));
/**
* Returns a price object corresponding to the input tick and the base/quote token
* Inputs must be tokens because the address order is used to interpret the price represented by the tick
* @param baseToken the base token of the price
* @param quoteToken the quote token of the price
* @param tick the tick for which to return the price
*/
function tickToPrice(baseToken, quoteToken, tick) {
var sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);
var ratioX192 = JSBI.multiply(sqrtRatioX96, sqrtRatioX96);
return baseToken.sortsBefore(quoteToken) ? new sdkCore.Price(baseToken, quoteToken, SQUARED_PRICE_DENOMINATOR, ratioX192) : new sdkCore.Price(baseToken, quoteToken, ratioX192, SQUARED_PRICE_DENOMINATOR);
}
exports.FACTORY_ADDRESS = FACTORY_ADDRESS;

@@ -883,6 +995,9 @@ exports.INIT_CODE_HASH = INIT_CODE_HASH;

exports.Router = Router;
exports.TickMath = TickMath;
exports.Trade = Trade;
exports.computePoolAddress = computePoolAddress;
exports.inputOutputComparator = inputOutputComparator;
exports.mostSignificantBit = mostSignificantBit;
exports.tickToPrice = tickToPrice;
exports.tradeComparator = tradeComparator;
//# sourceMappingURL=v3-sdk.cjs.development.js.map

2

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

@@ -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,n,r=t(require("jsbi")),o=require("@ethersproject/abi"),u=require("@ethersproject/address"),i=require("@ethersproject/solidity"),a=require("@uniswap/sdk-core"),s=t(require("tiny-invariant")),c="0x56cf930c850ce212aa057e794ef994327f2cb22ca6f87b126cc538e797b9541c",p=r.BigInt(0),f=r.BigInt(1);function l(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,e,n){return e&&l(t.prototype,e),n&&l(t,n),t}function d(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function T(t){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function m(t,e){return(m=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function v(){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 k(t,e,n){return(k=v()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&m(o,n.prototype),o}).apply(null,arguments)}function y(t){var e="function"==typeof Map?new Map:void 0;return(y=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,n)}function n(){return k(t,arguments,T(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,t)})(t)}function A(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}!function(t){t[t.LOW=500]="LOW",t[t.MEDIUM=3e3]="MEDIUM",t[t.HIGH=1e4]="HIGH"}(n||(n={})),(e={})[n.LOW]=10,e[n.MEDIUM]=60,e[n.HIGH]=200;var E="setPrototypeOf"in Object,w=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,E&&Object.setPrototypeOf(A(n),(this instanceof e?this.constructor:void 0).prototype),n}return d(e,t),e}(y(Error)),I=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,E&&Object.setPrototypeOf(A(n),(this instanceof e?this.constructor:void 0).prototype),n}return d(e,t),e}(y(Error)),x=function(t){var e=t.factoryAddress,n=t.tokenA,r=t.tokenB,a=t.fee,s=n.sortsBefore(r)?[n,r]:[r,n];return u.getCreate2Address(e,i.keccak256(["bytes"],[o.defaultAbiCoder.encode(["address","address","uint24"],[s[0].address,s[1].address,a])]),c)},b=function(){function t(t,e,n,o,u,i){Number.isInteger(n)||s(!1),Boolean(null==i?void 0:i.head)||s(!1);var a=t.token.sortsBefore(e.token)?[t,e]:[e,t];this.tokenAmounts=a,this.fee=n,this.sqrtPriceX96=r.BigInt(o),this.ticks=i,this.liquidity=r.BigInt(u)}t.getAddress=function(t,e,n){return x({factoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",fee:n,tokenA:t,tokenB:e})};var e=t.prototype;return e.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},e.priceOf=function(t){return this.involvesToken(t)||s(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||s(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(t){throw this.involvesToken(t.token)||s(!1),new Error("todo")},e.getInputAmount=function(t){throw this.involvesToken(t.token)||s(!1),new Error("todo")},e.getLiquidityMinted=function(t,e,n){throw new Error("todo")},e.getLiquidityValue=function(t,e,n,r,o){this.involvesToken(t)||s(!1),n.raw<=e.raw||s(!1),s(!1)},h(t,[{key:"token0Price",get:function(){return this.sqrtPriceX96||s(!1),new a.Price(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return this.sqrtPriceX96||s(!1),new a.Price(this.token1,this.token0,this.tokenAmounts[1].raw,this.tokenAmounts[0].raw)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"feeLevel",get:function(){return this.fee}},{key:"inRangeLiquidity",get:function(){return this.liquidity.toString()}},{key:"tickList",get:function(){return this.ticks}},{key:"token0",get:function(){return this.tokenAmounts[0].token}},{key:"token1",get:function(){return this.tokenAmounts[1].token}},{key:"reserve0",get:function(){return this.tokenAmounts[0]}},{key:"reserve1",get:function(){return this.tokenAmounts[1]}}]),t}(),O=function(){function t(t,e,n){t.length>0||s(!1);var r=t[0].chainId;t.every((function(t){return t.chainId===r}))||s(!1);var o=a.WETH9[r],u=e instanceof a.Token&&t[0].involvesToken(e),i=e===a.ETHER&&o&&t[0].involvesToken(o);u||i||s(!1);var c=void 0===n,p=n instanceof a.Token&&t[t.length-1].involvesToken(n),f=n===a.ETHER&&o&&t[t.length-1].involvesToken(o);c||p||f||s(!1);for(var l,h=[e instanceof a.Token?e:o],d=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return g(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(t,void 0):void 0}}(t))){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}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(n=t[Symbol.iterator]()).next.bind(n)}(t.entries());!(l=d()).done;){var T=l.value,m=T[1],v=h[T[0]];v.equals(m.token0)||v.equals(m.token1)||s(!1);var k=v.equals(m.token0)?m.token1:m.token0;h.push(k)}this.pools=t,this.tokenPath=h,this.input=e,this.output=null!=n?n:h[h.length-1]}return h(t,[{key:"chainId",get:function(){return this.pools[0].chainId}}]),t}();function P(t,e){return a.currencyEquals(t.inputAmount.currency,e.inputAmount.currency)||s(!1),a.currencyEquals(t.outputAmount.currency,e.outputAmount.currency)||s(!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 q(t,e){var n=P(t,e);return 0!==n?n:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.tokenPath.length-e.route.tokenPath.length}function H(t,e){return t instanceof a.TokenAmount?t:t.currency===a.ETHER?new a.TokenAmount(a.WETH9[e],t.raw):void s(!1)}function _(t,e){return t instanceof a.Token?t:t===a.ETHER?a.WETH9[e]:void s(!1)}var R=function(){function t(t,e,n){var r,o,u,i=new Array(t.tokenPath.length),c=new Array(t.pools.length);if(n===a.TradeType.EXACT_INPUT){a.currencyEquals(e.currency,t.input)||s(!1),i[0]=H(e,t.chainId);for(var p=0;p<t.tokenPath.length-1;p++){var f=t.pools[p].getOutputAmount(i[p]),l=f[1];i[p+1]=f[0],c[p]=l}}else{a.currencyEquals(e.currency,t.output)||s(!1),i[i.length-1]=H(e,t.chainId);for(var h=t.tokenPath.length-1;h>0;h--){var d=t.pools[h-1].getInputAmount(i[h]),T=d[1];i[h-1]=d[0],c[h-1]=T}}this.route=t,this.tradeType=n,this.inputAmount=n===a.TradeType.EXACT_INPUT?e:t.input===a.ETHER?a.CurrencyAmount.ether(i[0].raw):i[0],this.outputAmount=n===a.TradeType.EXACT_OUTPUT?e:t.output===a.ETHER?a.CurrencyAmount.ether(i[i.length-1].raw):i[i.length-1],this.executionPrice=new a.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.priceImpact=(r=this.outputAmount,u=(o=this.executionPrice.raw.multiply(this.inputAmount.raw)).subtract(r.raw).divide(o),new a.Percent(u.numerator,u.denominator))}t.exactIn=function(e,n){return new t(e,n,a.TradeType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,a.TradeType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(p)&&s(!1),this.tradeType===a.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new a.Fraction(f).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof a.TokenAmount?new a.TokenAmount(this.outputAmount.token,e):a.CurrencyAmount.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(p)&&s(!1),this.tradeType===a.TradeType.EXACT_INPUT)return this.inputAmount;var e=new a.Fraction(f).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof a.TokenAmount?new a.TokenAmount(this.inputAmount.token,e):a.CurrencyAmount.ether(e)},t.bestTradeExactIn=function(e,n,r,o,u,i,c){var f=void 0===o?{}:o,l=f.maxNumResults,h=void 0===l?3:l,d=f.maxHops,T=void 0===d?3:d;void 0===u&&(u=[]),void 0===i&&(i=n),void 0===c&&(c=[]),e.length>0||s(!1),T>0||s(!1),i===n||u.length>0||s(!1);var m=n instanceof a.TokenAmount?n.token.chainId:r instanceof a.Token?r.chainId:void 0;void 0===m&&s(!1);for(var v=H(n,m),k=_(r,m),y=0;y<e.length;y++){var A=e[y];if((A.token0.equals(v.token)||A.token1.equals(v.token))&&!A.reserve0.equalTo(p)&&!A.reserve1.equalTo(p)){var g=void 0;try{g=A.getOutputAmount(v)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(g.token.equals(k))a.sortedInsert(c,new t(new O([].concat(u,[A]),i.currency,r),i,a.TradeType.EXACT_INPUT),h,q);else if(T>1&&e.length>1){var E=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactIn(E,g,r,{maxNumResults:h,maxHops:T-1},[].concat(u,[A]),i,c)}}}return c},t.bestTradeExactOut=function(e,n,r,o,u,i,c){var f=void 0===o?{}:o,l=f.maxNumResults,h=void 0===l?3:l,d=f.maxHops,T=void 0===d?3:d;void 0===u&&(u=[]),void 0===i&&(i=r),void 0===c&&(c=[]),e.length>0||s(!1),T>0||s(!1),i===r||u.length>0||s(!1);var m=r instanceof a.TokenAmount?r.token.chainId:n instanceof a.Token?n.chainId:void 0;void 0===m&&s(!1);for(var v=H(r,m),k=_(n,m),y=0;y<e.length;y++){var A=e[y];if((A.token0.equals(v.token)||A.token1.equals(v.token))&&!A.reserve0.equalTo(p)&&!A.reserve1.equalTo(p)){var g=void 0;try{g=A.getInputAmount(v)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(g.token.equals(k))a.sortedInsert(c,new t(new O([A].concat(u),n,i.currency),i,a.TradeType.EXACT_OUTPUT),h,q);else if(T>1&&e.length>1){var E=e.slice(0,y).concat(e.slice(y+1,e.length));t.bestTradeExactOut(E,n,g,{maxNumResults:h,maxHops:T-1},[A].concat(u),i,c)}}}return c},t}();function C(t){return"0x"+t.raw.toString(16)}var F=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===a.ETHER,r=t.outputAmount.currency===a.ETHER;n&&r&&s(!1),!("ttl"in e)||e.ttl>0||s(!1);var o,u,i,c=a.validateAndParseAddress(e.recipient),p=C(t.maximumAmountIn(e.allowedSlippage)),f=C(t.minimumAmountOut(e.allowedSlippage)),l=t.route.tokenPath.map((function(t){return t.address})),h="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),d=Boolean(e.feeOnTransfer);switch(t.tradeType){case a.TradeType.EXACT_INPUT:n?(o=d?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",u=[f,l,c,h],i=p):r?(o=d?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",u=[p,f,l,c,h],i="0x0"):(o=d?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",u=[p,f,l,c,h],i="0x0");break;case a.TradeType.EXACT_OUTPUT:d&&s(!1),n?(o="swapETHForExactTokens",u=[f,l,c,h],i=p):r?(o="swapTokensForExactETH",u=[f,p,l,c,h],i="0x0"):(o="swapTokensForExactTokens",u=[f,p,l,c,h],i="0x0");break;default:throw new Error("invalid trade type")}return{methodName:o,args:u,value:i}},t}();exports.FACTORY_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.INIT_CODE_HASH=c,exports.InsufficientInputAmountError=I,exports.InsufficientReservesError=w,exports.Pool=b,exports.Route=O,exports.Router=F,exports.Trade=R,exports.computePoolAddress=x,exports.inputOutputComparator=P,exports.tradeComparator=q;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e,n=t(require("jsbi")),r=require("@ethersproject/abi"),o=require("@ethersproject/address"),i=require("@ethersproject/solidity"),u=require("@uniswap/sdk-core"),a=t(require("tiny-invariant"));require("decimal.js-light");var c,s="0x56cf930c850ce212aa057e794ef994327f2cb22ca6f87b126cc538e797b9541c",f=n.BigInt(0),p=n.BigInt(1);function l(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e,n){return e&&l(t.prototype,e),n&&l(t,n),t}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function T(t){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function v(t,e){return(v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function m(){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,n){return(g=m()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&v(o,n.prototype),o}).apply(null,arguments)}function k(t){var e="function"==typeof Map?new Map:void 0;return(k=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,n)}function n(){return g(t,arguments,T(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)})(t)}function y(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function I(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return A(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}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(n=t[Symbol.iterator]()).next.bind(n)}!function(t){t[t.LOW=500]="LOW",t[t.MEDIUM=3e3]="MEDIUM",t[t.HIGH=1e4]="HIGH"}(c||(c={})),(e={})[c.LOW]=10,e[c.MEDIUM]=60,e[c.HIGH]=200;var b="setPrototypeOf"in Object,x=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,b&&Object.setPrototypeOf(y(n),(this instanceof e?this.constructor:void 0).prototype),n}return h(e,t),e}(k(Error)),E=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,b&&Object.setPrototypeOf(y(n),(this instanceof e?this.constructor:void 0).prototype),n}return h(e,t),e}(k(Error)),w=function(t){var e=t.factoryAddress,n=t.tokenA,u=t.tokenB,a=t.fee,c=n.sortsBefore(u)?[n,u]:[u,n];return o.getCreate2Address(e,i.keccak256(["bytes"],[r.defaultAbiCoder.encode(["address","address","uint24"],[c[0].address,c[1].address,a])]),s)},O=function(){function t(t,e,r,o,i,u){Number.isInteger(r)||a(!1),Boolean(null==u?void 0:u.head)||a(!1);var c=t.token.sortsBefore(e.token)?[t,e]:[e,t];this.tokenAmounts=c,this.fee=r,this.sqrtPriceX96=n.BigInt(o),this.ticks=u,this.liquidity=n.BigInt(i)}t.getAddress=function(t,e,n){return w({factoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",fee:n,tokenA:t,tokenB:e})};var e=t.prototype;return e.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},e.priceOf=function(t){return this.involvesToken(t)||a(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||a(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(t){throw this.involvesToken(t.token)||a(!1),new Error("todo")},e.getInputAmount=function(t){throw this.involvesToken(t.token)||a(!1),new Error("todo")},e.getLiquidityMinted=function(t,e,n){throw new Error("todo")},e.getLiquidityValue=function(t,e,n,r,o){this.involvesToken(t)||a(!1),n.raw<=e.raw||a(!1),a(!1)},d(t,[{key:"token0Price",get:function(){return this.sqrtPriceX96||a(!1),new u.Price(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return this.sqrtPriceX96||a(!1),new u.Price(this.token1,this.token0,this.tokenAmounts[1].raw,this.tokenAmounts[0].raw)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"feeLevel",get:function(){return this.fee}},{key:"inRangeLiquidity",get:function(){return this.liquidity.toString()}},{key:"tickList",get:function(){return this.ticks}},{key:"token0",get:function(){return this.tokenAmounts[0].token}},{key:"token1",get:function(){return this.tokenAmounts[1].token}},{key:"reserve0",get:function(){return this.tokenAmounts[0]}},{key:"reserve1",get:function(){return this.tokenAmounts[1]}}]),t}(),q=function(){function t(t,e,n){t.length>0||a(!1);var r=t[0].chainId;t.every((function(t){return t.chainId===r}))||a(!1);var o=u.WETH9[r],i=e instanceof u.Token&&t[0].involvesToken(e),c=e===u.ETHER&&o&&t[0].involvesToken(o);i||c||a(!1);var s=void 0===n,f=n instanceof u.Token&&t[t.length-1].involvesToken(n),p=n===u.ETHER&&o&&t[t.length-1].involvesToken(o);s||f||p||a(!1);for(var l,d=[e instanceof u.Token?e:o],h=I(t.entries());!(l=h()).done;){var T=l.value,v=T[1],m=d[T[0]];m.equals(v.token0)||m.equals(v.token1)||a(!1);var g=m.equals(v.token0)?v.token1:v.token0;d.push(g)}this.pools=t,this.tokenPath=d,this.input=e,this.output=null!=n?n:d[d.length-1]}return d(t,[{key:"chainId",get:function(){return this.pools[0].chainId}}]),t}();function P(t,e){return u.currencyEquals(t.inputAmount.currency,e.inputAmount.currency)||a(!1),u.currencyEquals(t.outputAmount.currency,e.outputAmount.currency)||a(!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 R(t,e){var n=P(t,e);return 0!==n?n:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.tokenPath.length-e.route.tokenPath.length}function S(t,e){return t instanceof u.TokenAmount?t:t.currency===u.ETHER?new u.TokenAmount(u.WETH9[e],t.raw):void a(!1)}function B(t,e){return t instanceof u.Token?t:t===u.ETHER?u.WETH9[e]:void a(!1)}var _=function(){function t(t,e,n){var r,o,i,c=new Array(t.tokenPath.length),s=new Array(t.pools.length);if(n===u.TradeType.EXACT_INPUT){u.currencyEquals(e.currency,t.input)||a(!1),c[0]=S(e,t.chainId);for(var f=0;f<t.tokenPath.length-1;f++){var p=t.pools[f].getOutputAmount(c[f]),l=p[1];c[f+1]=p[0],s[f]=l}}else{u.currencyEquals(e.currency,t.output)||a(!1),c[c.length-1]=S(e,t.chainId);for(var d=t.tokenPath.length-1;d>0;d--){var h=t.pools[d-1].getInputAmount(c[d]),T=h[1];c[d-1]=h[0],s[d-1]=T}}this.route=t,this.tradeType=n,this.inputAmount=n===u.TradeType.EXACT_INPUT?e:t.input===u.ETHER?u.CurrencyAmount.ether(c[0].raw):c[0],this.outputAmount=n===u.TradeType.EXACT_OUTPUT?e:t.output===u.ETHER?u.CurrencyAmount.ether(c[c.length-1].raw):c[c.length-1],this.executionPrice=new u.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.priceImpact=(r=this.outputAmount,i=(o=this.executionPrice.raw.multiply(this.inputAmount.raw)).subtract(r.raw).divide(o),new u.Percent(i.numerator,i.denominator))}t.exactIn=function(e,n){return new t(e,n,u.TradeType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,u.TradeType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(f)&&a(!1),this.tradeType===u.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new u.Fraction(p).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof u.TokenAmount?new u.TokenAmount(this.outputAmount.token,e):u.CurrencyAmount.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(f)&&a(!1),this.tradeType===u.TradeType.EXACT_INPUT)return this.inputAmount;var e=new u.Fraction(p).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof u.TokenAmount?new u.TokenAmount(this.inputAmount.token,e):u.CurrencyAmount.ether(e)},t.bestTradeExactIn=function(e,n,r,o,i,c,s){var p=void 0===o?{}:o,l=p.maxNumResults,d=void 0===l?3:l,h=p.maxHops,T=void 0===h?3:h;void 0===i&&(i=[]),void 0===c&&(c=n),void 0===s&&(s=[]),e.length>0||a(!1),T>0||a(!1),c===n||i.length>0||a(!1);var v=n instanceof u.TokenAmount?n.token.chainId:r instanceof u.Token?r.chainId:void 0;void 0===v&&a(!1);for(var m=S(n,v),g=B(r,v),k=0;k<e.length;k++){var y=e[k];if((y.token0.equals(m.token)||y.token1.equals(m.token))&&!y.reserve0.equalTo(f)&&!y.reserve1.equalTo(f)){var A=void 0;try{A=y.getOutputAmount(m)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(A.token.equals(g))u.sortedInsert(s,new t(new q([].concat(i,[y]),c.currency,r),c,u.TradeType.EXACT_INPUT),d,R);else if(T>1&&e.length>1){var I=e.slice(0,k).concat(e.slice(k+1,e.length));t.bestTradeExactIn(I,A,r,{maxNumResults:d,maxHops:T-1},[].concat(i,[y]),c,s)}}}return s},t.bestTradeExactOut=function(e,n,r,o,i,c,s){var p=void 0===o?{}:o,l=p.maxNumResults,d=void 0===l?3:l,h=p.maxHops,T=void 0===h?3:h;void 0===i&&(i=[]),void 0===c&&(c=r),void 0===s&&(s=[]),e.length>0||a(!1),T>0||a(!1),c===r||i.length>0||a(!1);var v=r instanceof u.TokenAmount?r.token.chainId:n instanceof u.Token?n.chainId:void 0;void 0===v&&a(!1);for(var m=S(r,v),g=B(n,v),k=0;k<e.length;k++){var y=e[k];if((y.token0.equals(m.token)||y.token1.equals(m.token))&&!y.reserve0.equalTo(f)&&!y.reserve1.equalTo(f)){var A=void 0;try{A=y.getInputAmount(m)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(A.token.equals(g))u.sortedInsert(s,new t(new q([y].concat(i),n,c.currency),c,u.TradeType.EXACT_OUTPUT),d,R);else if(T>1&&e.length>1){var I=e.slice(0,k).concat(e.slice(k+1,e.length));t.bestTradeExactOut(I,n,A,{maxNumResults:d,maxHops:T-1},[y].concat(i),c,s)}}}return s},t}();function H(t){return"0x"+t.raw.toString(16)}var C=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===u.ETHER,r=t.outputAmount.currency===u.ETHER;n&&r&&a(!1),!("ttl"in e)||e.ttl>0||a(!1);var o,i,c,s=u.validateAndParseAddress(e.recipient),f=H(t.maximumAmountIn(e.allowedSlippage)),p=H(t.minimumAmountOut(e.allowedSlippage)),l=t.route.tokenPath.map((function(t){return t.address})),d="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),h=Boolean(e.feeOnTransfer);switch(t.tradeType){case u.TradeType.EXACT_INPUT:n?(o=h?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",i=[p,l,s,d],c=f):r?(o=h?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",i=[f,p,l,s,d],c="0x0"):(o=h?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",i=[f,p,l,s,d],c="0x0");break;case u.TradeType.EXACT_OUTPUT:h&&a(!1),n?(o="swapETHForExactTokens",i=[p,l,s,d],c=f):r?(o="swapTokensForExactETH",i=[p,f,l,s,d],c="0x0"):(o="swapTokensForExactTokens",i=[p,f,l,s,d],c="0x0");break;default:throw new Error("invalid trade type")}return{methodName:o,args:i,value:c}},t}(),M=n.BigInt(2),F=[128,64,32,16,8,4,2,1].map((function(t){return[t,n.exponentiate(M,n.BigInt(t))]}));function U(t){n.greaterThan(t,f)||a(!1);for(var e,r=0,o=I(F);!(e=o()).done;){var i=e.value,u=i[0];n.greaterThanOrEqual(t,i[1])&&(t=n.signedRightShift(t,n.BigInt(u)),r+=u)}return r}function j(t,e){return n.signedRightShift(n.multiply(t,n.BigInt(e)),n.BigInt(128))}var N=n.exponentiate(n.BigInt(2),n.BigInt(32)),X=function(){function t(){}return t.getSqrtRatioAtTick=function(e){var r=e<0?-1*e:e;r<=t.MAX_TICK||a(!1);var o=n.BigInt(0!=(1&r)?"0xfffcb933bd6fad37aa2d162d1a594001":"0x100000000000000000000000000000000");return 0!=(2&r)&&(o=j(o,"0xfff97272373d413259a46990580e213a")),0!=(4&r)&&(o=j(o,"0xfff2e50f5f656932ef12357cf3c7fdcc")),0!=(8&r)&&(o=j(o,"0xffe5caca7e10e4e61c3624eaa0941cd0")),0!=(16&r)&&(o=j(o,"0xffcb9843d60f6159c9db58835c926644")),0!=(32&r)&&(o=j(o,"0xff973b41fa98c081472e6896dfb254c0")),0!=(64&r)&&(o=j(o,"0xff2ea16466c96a3843ec78b326b52861")),0!=(128&r)&&(o=j(o,"0xfe5dee046a99a2a811c461f1969c3053")),0!=(256&r)&&(o=j(o,"0xfcbe86c7900a88aedcffc83b479aa3a4")),0!=(512&r)&&(o=j(o,"0xf987a7253ac413176f2b074cf7815e54")),0!=(1024&r)&&(o=j(o,"0xf3392b0822b70005940c7a398e4b70f3")),0!=(2048&r)&&(o=j(o,"0xe7159475a2c29b7443b29c7fa6e889d9")),0!=(4096&r)&&(o=j(o,"0xd097f3bdfd2022b8845ad8f792aa5825")),0!=(8192&r)&&(o=j(o,"0xa9f746462d870fdf8a65dc1f90e061e5")),0!=(16384&r)&&(o=j(o,"0x70d869a156d2a1b890bb3df62baf32f7")),0!=(32768&r)&&(o=j(o,"0x31be135f97d08fd981231505542fcfa6")),0!=(65536&r)&&(o=j(o,"0x9aa508b5b7a84e1c677de54f3e99bc9")),0!=(131072&r)&&(o=j(o,"0x5d6af8dedb81196699c329225ee604")),0!=(262144&r)&&(o=j(o,"0x2216e584f5fa1ea926041bedfe98")),0!=(524288&r)&&(o=j(o,"0x48a170391f7dc42444e8fa2")),e>0&&(o=n.divide(u.MaxUint256,o)),n.greaterThanOrEqual(n.remainder(o,N),f)?n.add(n.divide(o,N),p):n.divide(o,N)},t.getTickAtSqrtRatio=function(e){n.greaterThanOrEqual(e,t.MIN_SQRT_RATIO)&&n.lessThan(e,t.MAX_SQRT_RATIO)||a(!1);var r,o=n.leftShift(e,n.BigInt(32)),i=U(o);r=n.greaterThanOrEqual(n.BigInt(i),n.BigInt(128))?n.signedRightShift(o,n.BigInt(i-127)):n.leftShift(o,n.BigInt(127-i));for(var u=n.leftShift(n.subtract(n.BigInt(i),n.BigInt(128)),n.BigInt(64)),c=0;c<14;c++){r=n.signedRightShift(n.multiply(r,r),n.BigInt(127));var s=n.signedRightShift(r,n.BigInt(128));u=n.bitwiseOr(u,n.leftShift(s,n.BigInt(63-c))),r=n.signedRightShift(r,s)}var f=n.multiply(u,n.BigInt("255738958999603826347141")),p=n.toNumber(n.signedRightShift(n.subtract(f,n.BigInt("3402992956809132418596140100660247210")),n.BigInt(128))),l=n.toNumber(n.signedRightShift(n.add(f,n.BigInt("291339464771989622907027621153398088495")),n.BigInt(128)));return p===l?p:n.lessThanOrEqual(t.getSqrtRatioAtTick(l),e)?l:p},t}();X.MIN_TICK=-887272,X.MAX_TICK=-X.MIN_TICK,X.MIN_SQRT_RATIO=n.BigInt("4295128739"),X.MAX_SQRT_RATIO=n.BigInt("1461446703485210103287273052203988822378723970342");var D=n.exponentiate(n.BigInt(2),n.BigInt(192));exports.FACTORY_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.INIT_CODE_HASH=s,exports.InsufficientInputAmountError=E,exports.InsufficientReservesError=x,exports.Pool=O,exports.Route=q,exports.Router=C,exports.TickMath=X,exports.Trade=_,exports.computePoolAddress=w,exports.inputOutputComparator=P,exports.mostSignificantBit=U,exports.tickToPrice=function(t,e,r){var o=X.getSqrtRatioAtTick(r),i=n.multiply(o,o);return t.sortsBefore(e)?new u.Price(t,e,D,i):new u.Price(t,e,i,D)},exports.tradeComparator=R;
//# sourceMappingURL=v3-sdk.cjs.production.min.js.map

@@ -5,4 +5,5 @@ import JSBI from 'jsbi';

import { keccak256 } from '@ethersproject/solidity';
import { Price, Token, ETHER, WETH9, currencyEquals, TradeType, Fraction, TokenAmount, CurrencyAmount, Percent, sortedInsert, validateAndParseAddress } from '@uniswap/sdk-core';
import { Price, Token, ETHER, WETH9, currencyEquals, TradeType, Fraction, TokenAmount, CurrencyAmount, Percent, sortedInsert, validateAndParseAddress, MaxUint256 } from '@uniswap/sdk-core';
import invariant from 'tiny-invariant';
import 'decimal.js-light';

@@ -869,3 +870,114 @@ var _TICK_SPACINGS;

export { FACTORY_ADDRESS, INIT_CODE_HASH, InsufficientInputAmountError, InsufficientReservesError, Pool, Route, Router, Trade, computePoolAddress, inputOutputComparator, tradeComparator };
var TWO = /*#__PURE__*/JSBI.BigInt(2);
var POWERS_OF_2 = /*#__PURE__*/[128, 64, 32, 16, 8, 4, 2, 1].map(function (pow) {
return [pow, JSBI.exponentiate(TWO, JSBI.BigInt(pow))];
});
function mostSignificantBit(x) {
!JSBI.greaterThan(x, ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ZERO') : invariant(false) : void 0;
var msb = 0;
for (var _iterator = _createForOfIteratorHelperLoose(POWERS_OF_2), _step; !(_step = _iterator()).done;) {
var _step$value = _step.value,
power = _step$value[0],
min = _step$value[1];
if (JSBI.greaterThanOrEqual(x, min)) {
x = JSBI.signedRightShift(x, JSBI.BigInt(power));
msb += power;
}
}
return msb;
}
function mulShift(val, mulBy) {
return JSBI.signedRightShift(JSBI.multiply(val, JSBI.BigInt(mulBy)), JSBI.BigInt(128));
}
var Q32 = /*#__PURE__*/JSBI.exponentiate( /*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(32));
var TickMath = /*#__PURE__*/function () {
/**
* Cannot be constructed.
*/
function TickMath() {}
TickMath.getSqrtRatioAtTick = function getSqrtRatioAtTick(tick) {
var absTick = tick < 0 ? tick * -1 : tick;
!(absTick <= TickMath.MAX_TICK) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ABS_TICK') : invariant(false) : void 0;
var ratio = (absTick & 0x1) != 0 ? JSBI.BigInt('0xfffcb933bd6fad37aa2d162d1a594001') : JSBI.BigInt('0x100000000000000000000000000000000');
if ((absTick & 0x2) != 0) ratio = mulShift(ratio, '0xfff97272373d413259a46990580e213a');
if ((absTick & 0x4) != 0) ratio = mulShift(ratio, '0xfff2e50f5f656932ef12357cf3c7fdcc');
if ((absTick & 0x8) != 0) ratio = mulShift(ratio, '0xffe5caca7e10e4e61c3624eaa0941cd0');
if ((absTick & 0x10) != 0) ratio = mulShift(ratio, '0xffcb9843d60f6159c9db58835c926644');
if ((absTick & 0x20) != 0) ratio = mulShift(ratio, '0xff973b41fa98c081472e6896dfb254c0');
if ((absTick & 0x40) != 0) ratio = mulShift(ratio, '0xff2ea16466c96a3843ec78b326b52861');
if ((absTick & 0x80) != 0) ratio = mulShift(ratio, '0xfe5dee046a99a2a811c461f1969c3053');
if ((absTick & 0x100) != 0) ratio = mulShift(ratio, '0xfcbe86c7900a88aedcffc83b479aa3a4');
if ((absTick & 0x200) != 0) ratio = mulShift(ratio, '0xf987a7253ac413176f2b074cf7815e54');
if ((absTick & 0x400) != 0) ratio = mulShift(ratio, '0xf3392b0822b70005940c7a398e4b70f3');
if ((absTick & 0x800) != 0) ratio = mulShift(ratio, '0xe7159475a2c29b7443b29c7fa6e889d9');
if ((absTick & 0x1000) != 0) ratio = mulShift(ratio, '0xd097f3bdfd2022b8845ad8f792aa5825');
if ((absTick & 0x2000) != 0) ratio = mulShift(ratio, '0xa9f746462d870fdf8a65dc1f90e061e5');
if ((absTick & 0x4000) != 0) ratio = mulShift(ratio, '0x70d869a156d2a1b890bb3df62baf32f7');
if ((absTick & 0x8000) != 0) ratio = mulShift(ratio, '0x31be135f97d08fd981231505542fcfa6');
if ((absTick & 0x10000) != 0) ratio = mulShift(ratio, '0x9aa508b5b7a84e1c677de54f3e99bc9');
if ((absTick & 0x20000) != 0) ratio = mulShift(ratio, '0x5d6af8dedb81196699c329225ee604');
if ((absTick & 0x40000) != 0) ratio = mulShift(ratio, '0x2216e584f5fa1ea926041bedfe98');
if ((absTick & 0x80000) != 0) ratio = mulShift(ratio, '0x48a170391f7dc42444e8fa2');
if (tick > 0) ratio = JSBI.divide(MaxUint256, ratio); // back to Q96
return JSBI.greaterThanOrEqual(JSBI.remainder(ratio, Q32), ZERO) ? JSBI.add(JSBI.divide(ratio, Q32), ONE) : JSBI.divide(ratio, Q32);
};
TickMath.getTickAtSqrtRatio = function getTickAtSqrtRatio(sqrtRatioX96) {
!(JSBI.greaterThanOrEqual(sqrtRatioX96, TickMath.MIN_SQRT_RATIO) && JSBI.lessThan(sqrtRatioX96, TickMath.MAX_SQRT_RATIO)) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SQRT_RATIO') : invariant(false) : void 0;
var sqrtRatioX128 = JSBI.leftShift(sqrtRatioX96, JSBI.BigInt(32));
var msb = mostSignificantBit(sqrtRatioX128);
var r;
if (JSBI.greaterThanOrEqual(JSBI.BigInt(msb), JSBI.BigInt(128))) {
r = JSBI.signedRightShift(sqrtRatioX128, JSBI.BigInt(msb - 127));
} else {
r = JSBI.leftShift(sqrtRatioX128, JSBI.BigInt(127 - msb));
}
var log_2 = JSBI.leftShift(JSBI.subtract(JSBI.BigInt(msb), JSBI.BigInt(128)), JSBI.BigInt(64));
for (var i = 0; i < 14; i++) {
r = JSBI.signedRightShift(JSBI.multiply(r, r), JSBI.BigInt(127));
var f = JSBI.signedRightShift(r, JSBI.BigInt(128));
log_2 = JSBI.bitwiseOr(log_2, JSBI.leftShift(f, JSBI.BigInt(63 - i)));
r = JSBI.signedRightShift(r, f);
}
var log_sqrt10001 = JSBI.multiply(log_2, JSBI.BigInt('255738958999603826347141'));
var tickLow = JSBI.toNumber(JSBI.signedRightShift(JSBI.subtract(log_sqrt10001, JSBI.BigInt('3402992956809132418596140100660247210')), JSBI.BigInt(128)));
var tickHigh = JSBI.toNumber(JSBI.signedRightShift(JSBI.add(log_sqrt10001, JSBI.BigInt('291339464771989622907027621153398088495')), JSBI.BigInt(128)));
return tickLow === tickHigh ? tickLow : JSBI.lessThanOrEqual(TickMath.getSqrtRatioAtTick(tickHigh), sqrtRatioX96) ? tickHigh : tickLow;
};
return TickMath;
}();
TickMath.MIN_TICK = -887272;
TickMath.MAX_TICK = -TickMath.MIN_TICK;
TickMath.MIN_SQRT_RATIO = /*#__PURE__*/JSBI.BigInt('4295128739');
TickMath.MAX_SQRT_RATIO = /*#__PURE__*/JSBI.BigInt('1461446703485210103287273052203988822378723970342');
var SQUARED_PRICE_DENOMINATOR = /*#__PURE__*/JSBI.exponentiate( /*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(192));
/**
* Returns a price object corresponding to the input tick and the base/quote token
* Inputs must be tokens because the address order is used to interpret the price represented by the tick
* @param baseToken the base token of the price
* @param quoteToken the quote token of the price
* @param tick the tick for which to return the price
*/
function tickToPrice(baseToken, quoteToken, tick) {
var sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);
var ratioX192 = JSBI.multiply(sqrtRatioX96, sqrtRatioX96);
return baseToken.sortsBefore(quoteToken) ? new Price(baseToken, quoteToken, SQUARED_PRICE_DENOMINATOR, ratioX192) : new Price(baseToken, quoteToken, ratioX192, SQUARED_PRICE_DENOMINATOR);
}
export { FACTORY_ADDRESS, INIT_CODE_HASH, InsufficientInputAmountError, InsufficientReservesError, Pool, Route, Router, TickMath, Trade, computePoolAddress, inputOutputComparator, mostSignificantBit, tickToPrice, tradeComparator };
//# sourceMappingURL=v3-sdk.esm.js.map

@@ -7,3 +7,3 @@ {

},
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "⚒️ An SDK for building applications on top of Uniswap V3",

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