@uniswap/v3-sdk
Advanced tools
Comparing version 3.6.1 to 3.6.2
export * from './entities'; | ||
export * from './utils'; | ||
export * from './constants'; | ||
export * from './multicall'; | ||
export * from './nonfungiblePositionManager'; | ||
export * from './swapRouter'; | ||
export * from './payments'; | ||
export * from './quoter'; | ||
export * from './selfPermit'; | ||
export * from './staker'; | ||
export * from './swapRouter'; |
@@ -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"),n=t(require("jsbi")),r=t(require("tiny-invariant")),i=require("@ethersproject/abi"),o=require("@ethersproject/address"),a=require("@ethersproject/solidity"),u=require("@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json"),c=require("@uniswap/v3-periphery/artifacts/contracts/interfaces/ISelfPermit.sol/ISelfPermit.json"),s=require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IMulticall.sol/IMulticall.json"),p=require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IPeripheryPaymentsWithFee.sol/IPeripheryPaymentsWithFee.json"),d=require("@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json"),l=require("@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json"),f=require("@uniswap/v3-staker/artifacts/contracts/UniswapV3Staker.sol/UniswapV3Staker.json");function h(t,e,n,r,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,i)}function m(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){h(o,r,i,a,u,"next",t)}function u(t){h(o,r,i,a,u,"throw",t)}a(void 0)}))}}function v(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 k(t,e,n){return e&&v(t.prototype,e),n&&v(t,n),t}function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}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 g(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)}var T,x,I,w=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var i=Object.create((e&&e.prototype instanceof d?e:d).prototype),o=new I(r||[]);return i._invoke=function(t,e,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=g(a,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=s(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(t,n,o),i}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var p={};function d(){}function l(){}function f(){}var h={};h[i]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(w([])));v&&v!==e&&n.call(v,i)&&(h=v);var k=f.prototype=d.prototype=Object.create(h);function y(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){var r;this._invoke=function(i,o){function a(){return new e((function(r,a){!function r(i,o,a,u){var c=s(t[i],t,o);if("throw"!==c.type){var p=c.arg,d=p.value;return d&&"object"==typeof d&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(d).then((function(t){p.value=t,a(p)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function g(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,g(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,p;var i=r.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function w(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:q}}function q(){return{value:void 0,done:!0}}return l.prototype=k.constructor=f,f.constructor=l,l.displayName=u(f,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,u(t,a,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},y(A.prototype),A.prototype[o]=function(){return this},t.AsyncIterator=A,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new A(c(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},y(k),u(k,a,"Generator"),k[i]=function(){return this},k.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=w,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),x(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:w(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(I={exports:{}}),I.exports),q="0x0000000000000000000000000000000000000000",b="0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54";(x=exports.FeeAmount||(exports.FeeAmount={}))[x.LOW=500]="LOW",x[x.MEDIUM=3e3]="MEDIUM",x[x.HIGH=1e4]="HIGH";var R=((T={})[exports.FeeAmount.LOW]=10,T[exports.FeeAmount.MEDIUM]=60,T[exports.FeeAmount.HIGH]=200,T),P=n.BigInt(-1),E=n.BigInt(0),C=n.BigInt(1),S=n.exponentiate(n.BigInt(2),n.BigInt(96)),O=n.exponentiate(S,n.BigInt(2));function N(t){var e=t.factoryAddress,n=t.tokenA,r=t.tokenB,u=t.fee,c=t.initCodeHashManualOverride,s=n.sortsBefore(r)?[n,r]:[r,n];return o.getCreate2Address(e,a.keccak256(["bytes"],[i.defaultAbiCoder.encode(["address","address","uint24"],[s[0].address,s[1].address,u])]),null!=c?c:10===n.chainId?"0x0c231002d0970d2126e7e00ce88c3b0e5ec8e48dac71478d56245c34ea2f9447":69===n.chainId?"0x1fc830513acbdb1608b8c18fd3cf4a4bee3329c69bb41d56400401c40fe02fd0":b)}var _=function(){function t(){}return t.addDelta=function(t,e){return n.lessThan(e,E)?n.subtract(t,n.multiply(e,P)):n.add(t,e)},t}(),F=function(){function t(){}return t.mulDivRoundingUp=function(t,e,r){var i=n.multiply(t,e),o=n.divide(i,r);return n.notEqual(n.remainder(i,r),E)&&(o=n.add(o,C)),o},t}(),L=n.subtract(n.exponentiate(n.BigInt(2),n.BigInt(160)),C);function U(t,r){var i=n.multiply(t,r);return n.bitwiseAnd(i,e.MaxUint256)}var M=function(){function t(){}return t.getAmount0Delta=function(t,e,r,i){if(n.greaterThan(t,e)){var o=[e,t];t=o[0],e=o[1]}var a=n.leftShift(r,n.BigInt(96)),u=n.subtract(e,t);return i?F.mulDivRoundingUp(F.mulDivRoundingUp(a,u,e),C,t):n.divide(n.divide(n.multiply(a,u),e),t)},t.getAmount1Delta=function(t,e,r,i){if(n.greaterThan(t,e)){var o=[e,t];t=o[0],e=o[1]}return i?F.mulDivRoundingUp(r,n.subtract(e,t),S):n.divide(n.multiply(r,n.subtract(e,t)),S)},t.getNextSqrtPriceFromInput=function(t,e,i,o){return n.greaterThan(t,E)||r(!1),n.greaterThan(e,E)||r(!1),o?this.getNextSqrtPriceFromAmount0RoundingUp(t,e,i,!0):this.getNextSqrtPriceFromAmount1RoundingDown(t,e,i,!0)},t.getNextSqrtPriceFromOutput=function(t,e,i,o){return n.greaterThan(t,E)||r(!1),n.greaterThan(e,E)||r(!1),o?this.getNextSqrtPriceFromAmount1RoundingDown(t,e,i,!1):this.getNextSqrtPriceFromAmount0RoundingUp(t,e,i,!1)},t.getNextSqrtPriceFromAmount0RoundingUp=function(t,i,o,a){if(n.equal(o,E))return t;var u=n.leftShift(i,n.BigInt(96));if(a){var c=U(o,t);if(n.equal(n.divide(c,o),t)){var s=(d=n.add(u,c),n.bitwiseAnd(d,e.MaxUint256));if(n.greaterThanOrEqual(s,u))return F.mulDivRoundingUp(u,t,s)}return F.mulDivRoundingUp(u,C,n.add(n.divide(u,t),o))}var p=U(o,t);n.equal(n.divide(p,o),t)||r(!1),n.greaterThan(u,p)||r(!1);var d,l=n.subtract(u,p);return F.mulDivRoundingUp(u,t,l)},t.getNextSqrtPriceFromAmount1RoundingDown=function(t,e,i,o){if(o){var a=n.lessThanOrEqual(i,L)?n.divide(n.leftShift(i,n.BigInt(96)),e):n.divide(n.multiply(i,S),e);return n.add(t,a)}var u=F.mulDivRoundingUp(i,S,e);return n.greaterThan(t,u)||r(!1),n.subtract(t,u)},t}(),X=n.exponentiate(n.BigInt(10),n.BigInt(6)),D=function(){function t(){}return t.computeSwapStep=function(t,e,r,i,o){var a={},u=n.greaterThanOrEqual(t,e),c=n.greaterThanOrEqual(i,E);if(c){var s=n.divide(n.multiply(i,n.subtract(X,n.BigInt(o))),X);a.amountIn=u?M.getAmount0Delta(e,t,r,!0):M.getAmount1Delta(t,e,r,!0),a.sqrtRatioNextX96=n.greaterThanOrEqual(s,a.amountIn)?e:M.getNextSqrtPriceFromInput(t,r,s,u)}else a.amountOut=u?M.getAmount1Delta(e,t,r,!1):M.getAmount0Delta(t,e,r,!1),a.sqrtRatioNextX96=n.greaterThanOrEqual(n.multiply(i,P),a.amountOut)?e:M.getNextSqrtPriceFromOutput(t,r,n.multiply(i,P),u);var p=n.equal(e,a.sqrtRatioNextX96);return u?(a.amountIn=p&&c?a.amountIn:M.getAmount0Delta(a.sqrtRatioNextX96,t,r,!0),a.amountOut=p&&!c?a.amountOut:M.getAmount1Delta(a.sqrtRatioNextX96,t,r,!1)):(a.amountIn=p&&c?a.amountIn:M.getAmount1Delta(t,a.sqrtRatioNextX96,r,!0),a.amountOut=p&&!c?a.amountOut:M.getAmount0Delta(t,a.sqrtRatioNextX96,r,!1)),!c&&n.greaterThan(a.amountOut,n.multiply(i,P))&&(a.amountOut=n.multiply(i,P)),a.feeAmount=c&&n.notEqual(a.sqrtRatioNextX96,e)?n.subtract(i,a.amountIn):F.mulDivRoundingUp(a.amountIn,n.BigInt(o),n.subtract(X,n.BigInt(o))),[a.sqrtRatioNextX96,a.amountIn,a.amountOut,a.feeAmount]},t}(),B=n.BigInt(2),j=[128,64,32,16,8,4,2,1].map((function(t){return[t,n.exponentiate(B,n.BigInt(t))]}));function H(t){n.greaterThan(t,E)||r(!1),n.lessThanOrEqual(t,e.MaxUint256)||r(!1);for(var i,o=0,a=g(j);!(i=a()).done;){var u=i.value,c=u[0];n.greaterThanOrEqual(t,u[1])&&(t=n.signedRightShift(t,n.BigInt(c)),o+=c)}return o}function W(t,e){return n.signedRightShift(n.multiply(t,n.BigInt(e)),n.BigInt(128))}var K=n.exponentiate(n.BigInt(2),n.BigInt(32)),G=function(){function t(){}return t.getSqrtRatioAtTick=function(i){i>=t.MIN_TICK&&i<=t.MAX_TICK&&Number.isInteger(i)||r(!1);var o=i<0?-1*i:i,a=n.BigInt(0!=(1&o)?"0xfffcb933bd6fad37aa2d162d1a594001":"0x100000000000000000000000000000000");return 0!=(2&o)&&(a=W(a,"0xfff97272373d413259a46990580e213a")),0!=(4&o)&&(a=W(a,"0xfff2e50f5f656932ef12357cf3c7fdcc")),0!=(8&o)&&(a=W(a,"0xffe5caca7e10e4e61c3624eaa0941cd0")),0!=(16&o)&&(a=W(a,"0xffcb9843d60f6159c9db58835c926644")),0!=(32&o)&&(a=W(a,"0xff973b41fa98c081472e6896dfb254c0")),0!=(64&o)&&(a=W(a,"0xff2ea16466c96a3843ec78b326b52861")),0!=(128&o)&&(a=W(a,"0xfe5dee046a99a2a811c461f1969c3053")),0!=(256&o)&&(a=W(a,"0xfcbe86c7900a88aedcffc83b479aa3a4")),0!=(512&o)&&(a=W(a,"0xf987a7253ac413176f2b074cf7815e54")),0!=(1024&o)&&(a=W(a,"0xf3392b0822b70005940c7a398e4b70f3")),0!=(2048&o)&&(a=W(a,"0xe7159475a2c29b7443b29c7fa6e889d9")),0!=(4096&o)&&(a=W(a,"0xd097f3bdfd2022b8845ad8f792aa5825")),0!=(8192&o)&&(a=W(a,"0xa9f746462d870fdf8a65dc1f90e061e5")),0!=(16384&o)&&(a=W(a,"0x70d869a156d2a1b890bb3df62baf32f7")),0!=(32768&o)&&(a=W(a,"0x31be135f97d08fd981231505542fcfa6")),0!=(65536&o)&&(a=W(a,"0x9aa508b5b7a84e1c677de54f3e99bc9")),0!=(131072&o)&&(a=W(a,"0x5d6af8dedb81196699c329225ee604")),0!=(262144&o)&&(a=W(a,"0x2216e584f5fa1ea926041bedfe98")),0!=(524288&o)&&(a=W(a,"0x48a170391f7dc42444e8fa2")),i>0&&(a=n.divide(e.MaxUint256,a)),n.greaterThan(n.remainder(a,K),E)?n.add(n.divide(a,K),C):n.divide(a,K)},t.getTickAtSqrtRatio=function(e){n.greaterThanOrEqual(e,t.MIN_SQRT_RATIO)&&n.lessThan(e,t.MAX_SQRT_RATIO)||r(!1);var i,o=n.leftShift(e,n.BigInt(32)),a=H(o);i=n.greaterThanOrEqual(n.BigInt(a),n.BigInt(128))?n.signedRightShift(o,n.BigInt(a-127)):n.leftShift(o,n.BigInt(127-a));for(var u=n.leftShift(n.subtract(n.BigInt(a),n.BigInt(128)),n.BigInt(64)),c=0;c<14;c++){i=n.signedRightShift(n.multiply(i,i),n.BigInt(127));var s=n.signedRightShift(i,n.BigInt(128));u=n.bitwiseOr(u,n.leftShift(s,n.BigInt(63-c))),i=n.signedRightShift(i,s)}var p=n.multiply(u,n.BigInt("255738958999603826347141")),d=n.toNumber(n.signedRightShift(n.subtract(p,n.BigInt("3402992956809132418596140100660247210")),n.BigInt(128))),l=n.toNumber(n.signedRightShift(n.add(p,n.BigInt("291339464771989622907027621153398088495")),n.BigInt(128)));return d===l?d:n.lessThanOrEqual(t.getSqrtRatioAtTick(l),e)?l:d},t}();G.MIN_TICK=-887272,G.MAX_TICK=-G.MIN_TICK,G.MIN_SQRT_RATIO=n.BigInt("4295128739"),G.MAX_SQRT_RATIO=n.BigInt("1461446703485210103287273052203988822378723970342");var Q=function(){function t(){}var e=t.prototype;return e.getTick=function(){var e=m(w.mark((function e(n){return w.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error(t.ERROR_MESSAGE);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var e=m(w.mark((function e(n,r,i){return w.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error(t.ERROR_MESSAGE);case 1:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t}();function z(t,e){for(var n=0;n<t.length-1;n++)if(e(t[n],t[n+1])>0)return!1;return!0}function V(t,e){return t.index-e.index}Q.ERROR_MESSAGE="No tick data provider was given";var Y=function(){function t(){}return t.validateList=function(t,e){e>0||r(!1),t.every((function(t){return t.index%e==0}))||r(!1),n.equal(t.reduce((function(t,e){return n.add(t,e.liquidityNet)}),E),E)||r(!1),z(t,V)||r(!1)},t.isBelowSmallest=function(t,e){return t.length>0||r(!1),e<t[0].index},t.isAtOrAboveLargest=function(t,e){return t.length>0||r(!1),e>=t[t.length-1].index},t.getTick=function(t,e){var n=t[this.binarySearch(t,e)];return n.index!==e&&r(!1),n},t.binarySearch=function(t,e){this.isBelowSmallest(t,e)&&r(!1);for(var n,i=0,o=t.length-1;;){if(t[n=Math.floor((i+o)/2)].index<=e&&(n===t.length-1||t[n+1].index>e))return n;t[n].index<e?i=n+1:o=n-1}},t.nextInitializedTick=function(e,n,i){return i?(t.isBelowSmallest(e,n)&&r(!1),t.isAtOrAboveLargest(e,n)?e[e.length-1]:e[this.binarySearch(e,n)]):(this.isAtOrAboveLargest(e,n)&&r(!1),this.isBelowSmallest(e,n)?e[0]:e[this.binarySearch(e,n)+1])},t.nextInitializedTickWithinOneWord=function(e,n,r,i){var o=Math.floor(n/i);if(r){var a=(o>>8<<8)*i;if(t.isBelowSmallest(e,n))return[a,!1];var u=t.nextInitializedTick(e,n,r).index,c=Math.max(a,u);return[c,c===u]}var s=(1+(o+1>>8)<<8)*i-1;if(this.isAtOrAboveLargest(e,n))return[s,!1];var p=this.nextInitializedTick(e,n,r).index,d=Math.min(s,p);return[d,d===p]},t}();function Z(t){var e=n.BigInt(t).toString(16);return e.length%2!=0&&(e="0"+e),"0x"+e}function $(t,e){var n=t.pools.reduce((function(t,e,n){var r=t.inputToken,i=t.path,o=t.types,a=e.token0.equals(r)?e.token1:e.token0;return 0===n?{inputToken:a,types:["address","uint24","address"],path:[r.address,e.fee,a.address]}:{inputToken:a,types:[].concat(o,["uint24","address"]),path:[].concat(i,[e.fee,a.address])}}),{inputToken:t.input.wrapped,path:[],types:[]}),r=n.path,i=n.types;return e?a.pack(i.reverse(),r.reverse()):a.pack(i,r)}function J(t,r){var i=n.leftShift(n.BigInt(t),n.BigInt(192)),o=n.BigInt(r),a=n.divide(i,o);return e.sqrt(a)}function tt(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}var o=n.divide(n.multiply(t,e),S);return n.divide(n.multiply(n.BigInt(r),o),n.subtract(e,t))}function et(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}var o=n.multiply(n.multiply(n.BigInt(r),t),e),a=n.multiply(S,n.subtract(e,t));return n.divide(o,a)}function nt(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}return n.divide(n.multiply(n.BigInt(r),S),n.subtract(e,t))}function rt(t,e,r,i,o,a){if(n.greaterThan(e,r)){var u=[r,e];e=u[0],r=u[1]}var c=a?et:tt;if(n.lessThanOrEqual(t,e))return c(e,r,i);if(n.lessThan(t,r)){var s=c(t,r,i),p=nt(e,t,o);return n.lessThan(s,p)?s:p}return nt(e,r,o)}function it(t,r,i){var o=G.getSqrtRatioAtTick(i),a=n.multiply(o,o);return t.sortsBefore(r)?new e.Price(t,r,O,a):new e.Price(t,r,a,O)}var ot=function(t){var e=t.index,i=t.liquidityGross,o=t.liquidityNet;e>=G.MIN_TICK&&e<=G.MAX_TICK||r(!1),this.index=e,this.liquidityGross=n.BigInt(i),this.liquidityNet=n.BigInt(o)},at=function(){function t(t,e){var n=t.map((function(t){return t instanceof ot?t:new ot(t)}));Y.validateList(n,e),this.ticks=n}var e=t.prototype;return e.getTick=function(){var t=m(w.mark((function t(e){return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Y.getTick(this.ticks,e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var t=m(w.mark((function t(e,n,r){return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Y.nextInitializedTickWithinOneWord(this.ticks,e,n,r));case 1:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),t}(),ut=new Q,ct=function(){function t(t,e,i,o,a,u,c){void 0===c&&(c=ut),Number.isInteger(i)&&i<1e6||r(!1);var s=G.getSqrtRatioAtTick(u),p=G.getSqrtRatioAtTick(u+1);n.greaterThanOrEqual(n.BigInt(o),s)&&n.lessThanOrEqual(n.BigInt(o),p)||r(!1);var d=t.sortsBefore(e)?[t,e]:[e,t];this.token0=d[0],this.token1=d[1],this.fee=i,this.sqrtRatioX96=n.BigInt(o),this.liquidity=n.BigInt(a),this.tickCurrent=u,this.tickDataProvider=Array.isArray(c)?new at(c,R[i]):c}t.getAddress=function(t,e,n,r){return N({factoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",fee:n,tokenA:t,tokenB:e,initCodeHashManualOverride:r})};var i=t.prototype;return i.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},i.priceOf=function(t){return this.involvesToken(t)||r(!1),t.equals(this.token0)?this.token0Price:this.token1Price},i.getOutputAmount=function(){var i=m(w.mark((function i(o,a){var u,c,s,p,d;return w.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return this.involvesToken(o.currency)||r(!1),u=o.currency.equals(this.token0),i.next=4,this.swap(u,o.quotient,a);case 4:return s=(c=i.sent).sqrtRatioX96,p=c.liquidity,d=c.tickCurrent,i.abrupt("return",[e.CurrencyAmount.fromRawAmount(u?this.token1:this.token0,n.multiply(c.amountCalculated,P)),new t(this.token0,this.token1,this.fee,s,p,d,this.tickDataProvider)]);case 11:case"end":return i.stop()}}),i,this)})));return function(t,e){return i.apply(this,arguments)}}(),i.getInputAmount=function(){var i=m(w.mark((function i(o,a){var u,c,s,p,d;return w.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return o.currency.isToken&&this.involvesToken(o.currency)||r(!1),u=o.currency.equals(this.token1),i.next=4,this.swap(u,n.multiply(o.quotient,P),a);case 4:return s=(c=i.sent).sqrtRatioX96,p=c.liquidity,d=c.tickCurrent,i.abrupt("return",[e.CurrencyAmount.fromRawAmount(u?this.token0:this.token1,c.amountCalculated),new t(this.token0,this.token1,this.fee,s,p,d,this.tickDataProvider)]);case 11:case"end":return i.stop()}}),i,this)})));return function(t,e){return i.apply(this,arguments)}}(),i.swap=function(){var t=m(w.mark((function t(e,i,o){var a,u,c,s,p,d;return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o||(o=e?n.add(G.MIN_SQRT_RATIO,C):n.subtract(G.MAX_SQRT_RATIO,C)),e?(n.greaterThan(o,G.MIN_SQRT_RATIO)||r(!1),n.lessThan(o,this.sqrtRatioX96)||r(!1)):(n.lessThan(o,G.MAX_SQRT_RATIO)||r(!1),n.greaterThan(o,this.sqrtRatioX96)||r(!1)),a=n.greaterThanOrEqual(i,E),u={amountSpecifiedRemaining:i,amountCalculated:E,sqrtPriceX96:this.sqrtRatioX96,tick:this.tickCurrent,liquidity:this.liquidity};case 4:if(!n.notEqual(u.amountSpecifiedRemaining,E)||u.sqrtPriceX96==o){t.next=35;break}return(c={}).sqrtPriceStartX96=u.sqrtPriceX96,t.next=9,this.tickDataProvider.nextInitializedTickWithinOneWord(u.tick,e,this.tickSpacing);case 9:if(c.tickNext=(s=t.sent)[0],c.initialized=s[1],c.tickNext<G.MIN_TICK?c.tickNext=G.MIN_TICK:c.tickNext>G.MAX_TICK&&(c.tickNext=G.MAX_TICK),c.sqrtPriceNextX96=G.getSqrtRatioAtTick(c.tickNext),p=D.computeSwapStep(u.sqrtPriceX96,(e?n.lessThan(c.sqrtPriceNextX96,o):n.greaterThan(c.sqrtPriceNextX96,o))?o:c.sqrtPriceNextX96,u.liquidity,u.amountSpecifiedRemaining,this.fee),u.sqrtPriceX96=p[0],c.amountIn=p[1],c.amountOut=p[2],c.feeAmount=p[3],a?(u.amountSpecifiedRemaining=n.subtract(u.amountSpecifiedRemaining,n.add(c.amountIn,c.feeAmount)),u.amountCalculated=n.subtract(u.amountCalculated,c.amountOut)):(u.amountSpecifiedRemaining=n.add(u.amountSpecifiedRemaining,c.amountOut),u.amountCalculated=n.add(u.amountCalculated,n.add(c.amountIn,c.feeAmount))),!n.equal(u.sqrtPriceX96,c.sqrtPriceNextX96)){t.next=32;break}if(!c.initialized){t.next=29;break}return t.t0=n,t.next=25,this.tickDataProvider.getTick(c.tickNext);case 25:t.t1=t.sent.liquidityNet,d=t.t0.BigInt.call(t.t0,t.t1),e&&(d=n.multiply(d,P)),u.liquidity=_.addDelta(u.liquidity,d);case 29:u.tick=e?c.tickNext-1:c.tickNext,t.next=33;break;case 32:u.sqrtPriceX96!=c.sqrtPriceStartX96&&(u.tick=G.getTickAtSqrtRatio(u.sqrtPriceX96));case 33:t.next=4;break;case 35:return t.abrupt("return",{amountCalculated:u.amountCalculated,sqrtRatioX96:u.sqrtPriceX96,liquidity:u.liquidity,tickCurrent:u.tick});case 36:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),k(t,[{key:"token0Price",get:function(){var t;return null!=(t=this._token0Price)?t:this._token0Price=new e.Price(this.token0,this.token1,O,n.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}},{key:"token1Price",get:function(){var t;return null!=(t=this._token1Price)?t:this._token1Price=new e.Price(this.token1,this.token0,n.multiply(this.sqrtRatioX96,this.sqrtRatioX96),O)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"tickSpacing",get:function(){return R[this.fee]}}]),t}(),st=function(){function t(t){var e=t.pool,i=t.liquidity,o=t.tickLower,a=t.tickUpper;this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,o<a||r(!1),o>=G.MIN_TICK&&o%e.tickSpacing==0||r(!1),a<=G.MAX_TICK&&a%e.tickSpacing==0||r(!1),this.pool=e,this.tickLower=o,this.tickUpper=a,this.liquidity=n.BigInt(i)}var i=t.prototype;return i.ratiosAfterSlippage=function(t){var r=this.pool.token0Price.asFraction.multiply(new e.Percent(1).subtract(t)),i=this.pool.token0Price.asFraction.multiply(t.add(1)),o=J(r.numerator,r.denominator);n.lessThanOrEqual(o,G.MIN_SQRT_RATIO)&&(o=n.add(G.MIN_SQRT_RATIO,n.BigInt(1)));var a=J(i.numerator,i.denominator);return n.greaterThanOrEqual(a,G.MAX_SQRT_RATIO)&&(a=n.subtract(G.MAX_SQRT_RATIO,n.BigInt(1))),{sqrtRatioX96Lower:o,sqrtRatioX96Upper:a}},i.mintAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new ct(this.pool.token0,this.pool.token1,this.pool.fee,i,0,G.getTickAtSqrtRatio(i)),a=new ct(this.pool.token0,this.pool.token1,this.pool.fee,r,0,G.getTickAtSqrtRatio(r)),u=t.fromAmounts(y({pool:this.pool,tickLower:this.tickLower,tickUpper:this.tickUpper},this.mintAmounts,{useFullPrecision:!1}));return{amount0:new t({pool:a,liquidity:u.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount0,amount1:new t({pool:o,liquidity:u.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount1}},i.burnAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new ct(this.pool.token0,this.pool.token1,this.pool.fee,i,0,G.getTickAtSqrtRatio(i)),a=new t({pool:new ct(this.pool.token0,this.pool.token1,this.pool.fee,r,0,G.getTickAtSqrtRatio(r)),liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,u=new t({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:a.quotient,amount1:u.quotient}},t.fromAmounts=function(e){var n=e.pool,r=e.tickLower,i=e.tickUpper,o=e.amount0,a=e.amount1,u=e.useFullPrecision,c=G.getSqrtRatioAtTick(r),s=G.getSqrtRatioAtTick(i);return new t({pool:n,tickLower:r,tickUpper:i,liquidity:rt(n.sqrtRatioX96,c,s,o,a,u)})},t.fromAmount0=function(n){return t.fromAmounts({pool:n.pool,tickLower:n.tickLower,tickUpper:n.tickUpper,amount0:n.amount0,amount1:e.MaxUint256,useFullPrecision:n.useFullPrecision})},t.fromAmount1=function(n){return t.fromAmounts({pool:n.pool,tickLower:n.tickLower,tickUpper:n.tickUpper,amount0:e.MaxUint256,amount1:n.amount1,useFullPrecision:!0})},k(t,[{key:"token0PriceLower",get:function(){return it(this.pool.token0,this.pool.token1,this.tickLower)}},{key:"token0PriceUpper",get:function(){return it(this.pool.token0,this.pool.token1,this.tickUpper)}},{key:"amount0",get:function(){return null===this._token0Amount&&(this._token0Amount=e.CurrencyAmount.fromRawAmount(this.pool.token0,this.pool.tickCurrent<this.tickLower?M.getAmount0Delta(G.getSqrtRatioAtTick(this.tickLower),G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):this.pool.tickCurrent<this.tickUpper?M.getAmount0Delta(this.pool.sqrtRatioX96,G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):E)),this._token0Amount}},{key:"amount1",get:function(){return null===this._token1Amount&&(this._token1Amount=e.CurrencyAmount.fromRawAmount(this.pool.token1,this.pool.tickCurrent<this.tickLower?E:M.getAmount1Delta(G.getSqrtRatioAtTick(this.tickLower),this.pool.tickCurrent<this.tickUpper?this.pool.sqrtRatioX96:G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}},{key:"mintAmounts",get:function(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:M.getAmount0Delta(G.getSqrtRatioAtTick(this.tickLower),G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:E}:this.pool.tickCurrent<this.tickUpper?{amount0:M.getAmount0Delta(this.pool.sqrtRatioX96,G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:M.getAmount1Delta(G.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:E,amount1:M.getAmount1Delta(G.getSqrtRatioAtTick(this.tickLower),G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}}]),t}(),pt=function(){function t(t,e,n){this._midPrice=null,t.length>0||r(!1);var i=t[0].chainId;t.every((function(t){return t.chainId===i}))||r(!1);var o=e.wrapped;t[0].involvesToken(o)||r(!1),t[t.length-1].involvesToken(n.wrapped)||r(!1);for(var a,u=[o],c=g(t.entries());!(a=c()).done;){var s=a.value,p=s[1],d=u[s[0]];d.equals(p.token0)||d.equals(p.token1)||r(!1);var l=d.equals(p.token0)?p.token1:p.token0;u.push(l)}this.pools=t,this.tokenPath=u,this.input=e,this.output=null!=n?n:u[u.length-1]}return k(t,[{key:"chainId",get:function(){return this.pools[0].chainId}},{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;var t=this.pools.slice(1).reduce((function(t,e){var n=t.price;return t.nextInput.equals(e.token0)?{nextInput:e.token1,price:n.multiply(e.token0Price)}:{nextInput:e.token0,price:n.multiply(e.token1Price)}}),this.pools[0].token0.equals(this.input.wrapped)?{nextInput:this.pools[0].token1,price:this.pools[0].token0Price}:{nextInput:this.pools[0].token0,price:this.pools[0].token1Price}).price;return this._midPrice=new e.Price(this.input,this.output,t.denominator,t.numerator)}}]),t}();function dt(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||r(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||r(!1),t.outputAmount.equalTo(e.outputAmount)?t.inputAmount.equalTo(e.inputAmount)?t.swaps.reduce((function(t,e){return t+e.route.tokenPath.length}),0)-e.swaps.reduce((function(t,e){return t+e.route.tokenPath.length}),0):t.inputAmount.lessThan(e.inputAmount)?-1:1:t.outputAmount.lessThan(e.outputAmount)?1:-1}var lt=function(){function t(t){var e=t.routes,n=t.tradeType,i=e[0].inputAmount.currency,o=e[0].outputAmount.currency;e.every((function(t){return i.wrapped.equals(t.route.input.wrapped)}))||r(!1),e.every((function(t){return o.wrapped.equals(t.route.output.wrapped)}))||r(!1);for(var a,u=e.map((function(t){return t.route.pools.length})).reduce((function(t,e){return t+e}),0),c=new Set,s=g(e);!(a=s()).done;)for(var p,d=g(a.value.route.pools);!(p=d()).done;){var l=p.value;c.add(ct.getAddress(l.token0,l.token1,l.fee))}u!=c.size&&r(!1),this.swaps=e,this.tradeType=n}t.exactIn=function(){var n=m(w.mark((function n(r,i){return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.fromRoute(r,i,e.TradeType.EXACT_INPUT));case 1:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.exactOut=function(){var n=m(w.mark((function n(r,i){return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.fromRoute(r,i,e.TradeType.EXACT_OUTPUT));case 1:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.fromRoute=function(){var n=m(w.mark((function n(i,o,a){var u,c,s,p,d,l,f;return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(u=new Array(i.tokenPath.length),a!==e.TradeType.EXACT_INPUT){n.next=19;break}o.currency.equals(i.input)||r(!1),u[0]=o.wrapped,p=0;case 5:if(!(p<i.tokenPath.length-1)){n.next=15;break}return d=i.pools[p],n.next=9,d.getOutputAmount(u[p]);case 9:u[p+1]=n.sent[0];case 12:p++,n.next=5;break;case 15:c=e.CurrencyAmount.fromFractionalAmount(i.input,o.numerator,o.denominator),s=e.CurrencyAmount.fromFractionalAmount(i.output,u[u.length-1].numerator,u[u.length-1].denominator),n.next=34;break;case 19:o.currency.equals(i.output)||r(!1),u[u.length-1]=o.wrapped,l=i.tokenPath.length-1;case 22:if(!(l>0)){n.next=32;break}return f=i.pools[l-1],n.next=26,f.getInputAmount(u[l]);case 26:u[l-1]=n.sent[0];case 29:l--,n.next=22;break;case 32:c=e.CurrencyAmount.fromFractionalAmount(i.input,u[0].numerator,u[0].denominator),s=e.CurrencyAmount.fromFractionalAmount(i.output,o.numerator,o.denominator);case 34:return n.abrupt("return",new t({routes:[{inputAmount:c,outputAmount:s,route:i}],tradeType:a}));case 35:case"end":return n.stop()}}),n)})));return function(t,e,r){return n.apply(this,arguments)}}(),t.fromRoutes=function(){var n=m(w.mark((function n(i,o){var a,u,c,s,p,d,l,f,h,m,v,k,y;return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:a=[],u=g(i);case 2:if((c=u()).done){n.next=43;break}if(p=(s=c.value).route,d=s.amount,l=new Array(p.tokenPath.length),f=void 0,h=void 0,o!==e.TradeType.EXACT_INPUT){n.next=25;break}d.currency.equals(p.input)||r(!1),f=e.CurrencyAmount.fromFractionalAmount(p.input,d.numerator,d.denominator),l[0]=e.CurrencyAmount.fromFractionalAmount(p.input.wrapped,d.numerator,d.denominator),m=0;case 12:if(!(m<p.tokenPath.length-1)){n.next=22;break}return v=p.pools[m],n.next=16,v.getOutputAmount(l[m]);case 16:l[m+1]=n.sent[0];case 19:m++,n.next=12;break;case 22:h=e.CurrencyAmount.fromFractionalAmount(p.output,l[l.length-1].numerator,l[l.length-1].denominator),n.next=40;break;case 25:d.currency.equals(p.output)||r(!1),h=e.CurrencyAmount.fromFractionalAmount(p.output,d.numerator,d.denominator),l[l.length-1]=e.CurrencyAmount.fromFractionalAmount(p.output.wrapped,d.numerator,d.denominator),k=p.tokenPath.length-1;case 29:if(!(k>0)){n.next=39;break}return y=p.pools[k-1],n.next=33,y.getInputAmount(l[k]);case 33:l[k-1]=n.sent[0];case 36:k--,n.next=29;break;case 39:f=e.CurrencyAmount.fromFractionalAmount(p.input,l[0].numerator,l[0].denominator);case 40:a.push({route:p,inputAmount:f,outputAmount:h});case 41:n.next=2;break;case 43:return n.abrupt("return",new t({routes:a,tradeType:o}));case 44:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.createUncheckedTrade=function(e){return new t(y({},e,{routes:[{inputAmount:e.inputAmount,outputAmount:e.outputAmount,route:e.route}]}))},t.createUncheckedTradeWithMultipleRoutes=function(e){return new t(e)};var n=t.prototype;return n.minimumAmountOut=function(t,n){if(void 0===n&&(n=this.outputAmount),t.lessThan(E)&&r(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return n;var i=new e.Fraction(C).add(t).invert().multiply(n.quotient).quotient;return e.CurrencyAmount.fromRawAmount(n.currency,i)},n.maximumAmountIn=function(t,n){if(void 0===n&&(n=this.inputAmount),t.lessThan(E)&&r(!1),this.tradeType===e.TradeType.EXACT_INPUT)return n;var i=new e.Fraction(C).add(t).multiply(n.quotient).quotient;return e.CurrencyAmount.fromRawAmount(n.currency,i)},n.worstExecutionPrice=function(t){return new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactIn=function(){var n=m(w.mark((function n(i,o,a,u,c,s,p){var d,l,f,h,m,v,k,y,A,g,T;return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:f=void 0===(l=(d=void 0===u?{}:u).maxNumResults)?3:l,m=void 0===(h=d.maxHops)?3:h,void 0===c&&(c=[]),void 0===s&&(s=o),void 0===p&&(p=[]),i.length>0||r(!1),m>0||r(!1),o===s||c.length>0||r(!1),v=s.wrapped,k=a.wrapped,y=0;case 10:if(!(y<i.length)){n.next=46;break}if((A=i[y]).token0.equals(v.currency)||A.token1.equals(v.currency)){n.next=14;break}return n.abrupt("continue",43);case 14:return g=void 0,n.prev=15,n.next=19,A.getOutputAmount(v);case 19:g=n.sent[0],n.next=28;break;case 23:if(n.prev=23,n.t0=n.catch(15),!n.t0.isInsufficientInputAmountError){n.next=27;break}return n.abrupt("continue",43);case 27:throw n.t0;case 28:if(!g.currency.isToken||!g.currency.equals(k)){n.next=39;break}return n.t1=e.sortedInsert,n.t2=p,n.next=33,t.fromRoute(new pt([].concat(c,[A]),o.currency,a),o,e.TradeType.EXACT_INPUT);case 33:n.t3=n.sent,n.t4=f,n.t5=dt,(0,n.t1)(n.t2,n.t3,n.t4,n.t5),n.next=43;break;case 39:if(!(m>1&&i.length>1)){n.next=43;break}return T=i.slice(0,y).concat(i.slice(y+1,i.length)),n.next=43,t.bestTradeExactIn(T,o,a,{maxNumResults:f,maxHops:m-1},[].concat(c,[A]),g,p);case 43:y++,n.next=10;break;case 46:return n.abrupt("return",p);case 47:case"end":return n.stop()}}),n,null,[[15,23]])})));return function(t,e,r,i,o,a,u){return n.apply(this,arguments)}}(),t.bestTradeExactOut=function(){var n=m(w.mark((function n(i,o,a,u,c,s,p){var d,l,f,h,m,v,k,y,A,g,T;return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:f=void 0===(l=(d=void 0===u?{}:u).maxNumResults)?3:l,m=void 0===(h=d.maxHops)?3:h,void 0===c&&(c=[]),void 0===s&&(s=a),void 0===p&&(p=[]),i.length>0||r(!1),m>0||r(!1),a===s||c.length>0||r(!1),v=s.wrapped,k=o.wrapped,y=0;case 10:if(!(y<i.length)){n.next=46;break}if((A=i[y]).token0.equals(v.currency)||A.token1.equals(v.currency)){n.next=14;break}return n.abrupt("continue",43);case 14:return g=void 0,n.prev=15,n.next=19,A.getInputAmount(v);case 19:g=n.sent[0],n.next=28;break;case 23:if(n.prev=23,n.t0=n.catch(15),!n.t0.isInsufficientReservesError){n.next=27;break}return n.abrupt("continue",43);case 27:throw n.t0;case 28:if(!g.currency.equals(k)){n.next=39;break}return n.t1=e.sortedInsert,n.t2=p,n.next=33,t.fromRoute(new pt([A].concat(c),o,a.currency),a,e.TradeType.EXACT_OUTPUT);case 33:n.t3=n.sent,n.t4=f,n.t5=dt,(0,n.t1)(n.t2,n.t3,n.t4,n.t5),n.next=43;break;case 39:if(!(m>1&&i.length>1)){n.next=43;break}return T=i.slice(0,y).concat(i.slice(y+1,i.length)),n.next=43,t.bestTradeExactOut(T,o,a,{maxNumResults:f,maxHops:m-1},[A].concat(c),g,p);case 43:y++,n.next=10;break;case 46:return n.abrupt("return",p);case 47:case"end":return n.stop()}}),n,null,[[15,23]])})));return function(t,e,r,i,o,a,u){return n.apply(this,arguments)}}(),k(t,[{key:"route",get:function(){return 1!=this.swaps.length&&r(!1),this.swaps[0].route}},{key:"inputAmount",get:function(){if(this._inputAmount)return this._inputAmount;var t=this.swaps[0].inputAmount.currency,n=this.swaps.map((function(t){return t.inputAmount})).reduce((function(t,e){return t.add(e)}),e.CurrencyAmount.fromRawAmount(t,0));return this._inputAmount=n,this._inputAmount}},{key:"outputAmount",get:function(){if(this._outputAmount)return this._outputAmount;var t=this.swaps[0].outputAmount.currency,n=this.swaps.map((function(t){return t.outputAmount})).reduce((function(t,e){return t.add(e)}),e.CurrencyAmount.fromRawAmount(t,0));return this._outputAmount=n,this._outputAmount}},{key:"executionPrice",get:function(){var t;return null!=(t=this._executionPrice)?t:this._executionPrice=new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.quotient,this.outputAmount.quotient)}},{key:"priceImpact",get:function(){if(this._priceImpact)return this._priceImpact;for(var t,n=e.CurrencyAmount.fromRawAmount(this.outputAmount.currency,0),r=g(this.swaps);!(t=r()).done;){var i=t.value;n=n.add(i.route.midPrice.quote(i.inputAmount))}var o=n.subtract(this.outputAmount).divide(n);return this._priceImpact=new e.Percent(o.numerator,o.denominator),this._priceImpact}}]),t}(),ft=function(){function t(){}return t.encodePermit=function(e,n){return"nonce"in n?t.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,Z(n.nonce),Z(n.expiry),n.v,n.r,n.s]):t.INTERFACE.encodeFunctionData("selfPermit",[e.address,Z(n.amount),Z(n.deadline),n.v,n.r,n.s])},t}();ft.INTERFACE=new i.Interface(c.abi);var ht=function(){function t(){}return t.encodeMulticall=function(e){return Array.isArray(e)||(e=[e]),1===e.length?e[0]:t.INTERFACE.encodeFunctionData("multicall",[e])},t}();ht.INTERFACE=new i.Interface(s.abi);var mt=function(){function t(){}return t.encodeFeeBips=function(t){return Z(t.multiply(1e4).quotient)},t.encodeUnwrapWETH9=function(n,r,i){if(r=e.validateAndParseAddress(r),i){var o=this.encodeFeeBips(i.fee),a=e.validateAndParseAddress(i.recipient);return t.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[Z(n),r,o,a])}return t.INTERFACE.encodeFunctionData("unwrapWETH9",[Z(n),r])},t.encodeSweepToken=function(n,r,i,o){if(i=e.validateAndParseAddress(i),o){var a=this.encodeFeeBips(o.fee),u=e.validateAndParseAddress(o.recipient);return t.INTERFACE.encodeFunctionData("sweepTokenWithFee",[n.address,Z(r),i,a,u])}return t.INTERFACE.encodeFunctionData("sweepToken",[n.address,Z(r),i])},t.encodeRefundETH=function(){return t.INTERFACE.encodeFunctionData("refundETH")},t}();mt.INTERFACE=new i.Interface(p.abi);var vt=Z(n.subtract(n.exponentiate(n.BigInt(2),n.BigInt(128)),n.BigInt(1)));function kt(t){return Object.keys(t).some((function(t){return"recipient"===t}))}var yt=function(){function t(){}return t.encodeCreate=function(e){return t.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[e.token0.address,e.token1.address,e.fee,Z(e.sqrtRatioX96)])},t.createCallParameters=function(t){return{calldata:this.encodeCreate(t),value:Z(0)}},t.addCallParameters=function(i,o){n.greaterThan(i.liquidity,E)||r(!1);var a=[],u=i.mintAmounts,c=u.amount0,s=u.amount1,p=i.mintAmountsWithSlippage(o.slippageTolerance),d=Z(p.amount0),l=Z(p.amount1),f=Z(o.deadline);if(kt(o)&&o.createPool&&a.push(this.encodeCreate(i.pool)),o.token0Permit&&a.push(ft.encodePermit(i.pool.token0,o.token0Permit)),o.token1Permit&&a.push(ft.encodePermit(i.pool.token1,o.token1Permit)),kt(o)){var h=e.validateAndParseAddress(o.recipient);a.push(t.INTERFACE.encodeFunctionData("mint",[{token0:i.pool.token0.address,token1:i.pool.token1.address,fee:i.pool.fee,tickLower:i.tickLower,tickUpper:i.tickUpper,amount0Desired:Z(c),amount1Desired:Z(s),amount0Min:d,amount1Min:l,recipient:h,deadline:f}]))}else a.push(t.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:Z(o.tokenId),amount0Desired:Z(c),amount1Desired:Z(s),amount0Min:d,amount1Min:l,deadline:f}]));var m=Z(0);if(o.useNative){var v=o.useNative.wrapped;i.pool.token0.equals(v)||i.pool.token1.equals(v)||r(!1);var k=i.pool.token0.equals(v)?c:s;n.greaterThan(k,E)&&a.push(mt.encodeRefundETH()),m=Z(k)}return{calldata:ht.encodeMulticall(a),value:m}},t.encodeCollect=function(n){var r=[],i=Z(n.tokenId),o=n.expectedCurrencyOwed0.currency.isNative||n.expectedCurrencyOwed1.currency.isNative,a=e.validateAndParseAddress(n.recipient);if(r.push(t.INTERFACE.encodeFunctionData("collect",[{tokenId:i,recipient:o?q:a,amount0Max:vt,amount1Max:vt}])),o){var u=n.expectedCurrencyOwed0.currency.isNative?n.expectedCurrencyOwed1.currency:n.expectedCurrencyOwed0.currency,c=n.expectedCurrencyOwed0.currency.isNative?n.expectedCurrencyOwed1.quotient:n.expectedCurrencyOwed0.quotient;r.push(mt.encodeUnwrapWETH9(n.expectedCurrencyOwed0.currency.isNative?n.expectedCurrencyOwed0.quotient:n.expectedCurrencyOwed1.quotient,a)),r.push(mt.encodeSweepToken(u,c,a))}return r},t.collectCallParameters=function(e){var n=t.encodeCollect(e);return{calldata:ht.encodeMulticall(n),value:Z(0)}},t.removeCallParameters=function(i,o){var a=[],u=Z(o.deadline),c=Z(o.tokenId),s=new st({pool:i.pool,liquidity:o.liquidityPercentage.multiply(i.liquidity).quotient,tickLower:i.tickLower,tickUpper:i.tickUpper});n.greaterThan(s.liquidity,E)||r(!1);var p=s.burnAmountsWithSlippage(o.slippageTolerance),d=p.amount0,l=p.amount1;o.permit&&a.push(t.INTERFACE.encodeFunctionData("permit",[e.validateAndParseAddress(o.permit.spender),c,Z(o.permit.deadline),o.permit.v,o.permit.r,o.permit.s])),a.push(t.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:c,liquidity:Z(s.liquidity),amount0Min:Z(d),amount1Min:Z(l),deadline:u}]));var f=o.collectOptions,h=f.expectedCurrencyOwed0,m=f.expectedCurrencyOwed1,v=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(i[n]=t[n]);return i}(f,["expectedCurrencyOwed0","expectedCurrencyOwed1"]);return a.push.apply(a,t.encodeCollect(y({tokenId:Z(o.tokenId),expectedCurrencyOwed0:h.add(e.CurrencyAmount.fromRawAmount(h.currency,d)),expectedCurrencyOwed1:m.add(e.CurrencyAmount.fromRawAmount(m.currency,l))},v))),o.liquidityPercentage.equalTo(C)?o.burnToken&&a.push(t.INTERFACE.encodeFunctionData("burn",[c])):!0===o.burnToken&&r(!1),{calldata:ht.encodeMulticall(a),value:Z(0)}},t.safeTransferFromParameters=function(n){var r=e.validateAndParseAddress(n.recipient),i=e.validateAndParseAddress(n.sender);return{calldata:n.data?t.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)",[i,r,Z(n.tokenId),n.data]):t.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256)",[i,r,Z(n.tokenId)]),value:Z(0)}},t}();yt.INTERFACE=new i.Interface(u.abi);var At=function(){function t(){}return t.swapCallParameters=function(n,i){Array.isArray(n)||(n=[n]);var o=n[0],a=o.inputAmount.currency.wrapped,u=o.outputAmount.currency.wrapped;n.every((function(t){return t.inputAmount.currency.wrapped.equals(a)}))||r(!1),n.every((function(t){return t.outputAmount.currency.wrapped.equals(u)}))||r(!1);var c=[],s=e.CurrencyAmount.fromRawAmount(n[0].inputAmount.currency,0),p=e.CurrencyAmount.fromRawAmount(n[0].outputAmount.currency,0),d=n.reduce((function(t,e){return t.add(e.minimumAmountOut(i.slippageTolerance))}),p),l=o.inputAmount.currency.isNative&&o.tradeType===e.TradeType.EXACT_OUTPUT,f=o.outputAmount.currency.isNative,h=f||!!i.fee,m=o.inputAmount.currency.isNative?n.reduce((function(t,e){return t.add(e.maximumAmountIn(i.slippageTolerance))}),s):s;i.inputTokenPermit&&(o.inputAmount.currency.isToken||r(!1),c.push(ft.encodePermit(o.inputAmount.currency,i.inputTokenPermit)));for(var v,k=e.validateAndParseAddress(i.recipient),y=Z(i.deadline),A=g(n);!(v=A()).done;)for(var T,x=v.value,I=g(x.swaps);!(T=I()).done;){var w=T.value,b=w.route,R=w.outputAmount,P=Z(x.maximumAmountIn(i.slippageTolerance,w.inputAmount).quotient),E=Z(x.minimumAmountOut(i.slippageTolerance,R).quotient);if(1===b.pools.length)if(x.tradeType===e.TradeType.EXACT_INPUT){var C,S={tokenIn:b.tokenPath[0].address,tokenOut:b.tokenPath[1].address,fee:b.pools[0].fee,recipient:h?q:k,deadline:y,amountIn:P,amountOutMinimum:E,sqrtPriceLimitX96:Z(null!=(C=i.sqrtPriceLimitX96)?C:0)};c.push(t.INTERFACE.encodeFunctionData("exactInputSingle",[S]))}else{var O,N={tokenIn:b.tokenPath[0].address,tokenOut:b.tokenPath[1].address,fee:b.pools[0].fee,recipient:h?q:k,deadline:y,amountOut:E,amountInMaximum:P,sqrtPriceLimitX96:Z(null!=(O=i.sqrtPriceLimitX96)?O:0)};c.push(t.INTERFACE.encodeFunctionData("exactOutputSingle",[N]))}else{void 0!==i.sqrtPriceLimitX96&&r(!1);var _=$(b,x.tradeType===e.TradeType.EXACT_OUTPUT);c.push(x.tradeType===e.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("exactInput",[{path:_,recipient:h?q:k,deadline:y,amountIn:P,amountOutMinimum:E}]):t.INTERFACE.encodeFunctionData("exactOutput",[{path:_,recipient:h?q:k,deadline:y,amountOut:E,amountInMaximum:P}]))}}return h&&c.push(i.fee?f?mt.encodeUnwrapWETH9(d.quotient,k,i.fee):mt.encodeSweepToken(o.outputAmount.currency.wrapped,d.quotient,k,i.fee):mt.encodeUnwrapWETH9(d.quotient,k)),l&&c.push(mt.encodeRefundETH()),{calldata:ht.encodeMulticall(c),value:Z(m.quotient)}},t}();At.INTERFACE=new i.Interface(d.abi);var gt=function(){function t(){}return t.quoteCallParameters=function(n,i,o,a){void 0===a&&(a={});var u,c=1===n.pools.length,s=Z(i.quotient);if(c){var p,d,l,f;u=o===e.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("quoteExactInputSingle",[n.tokenPath[0].address,n.tokenPath[1].address,n.pools[0].fee,s,Z(null!=(p=null==(d=a)?void 0:d.sqrtPriceLimitX96)?p:0)]):t.INTERFACE.encodeFunctionData("quoteExactOutputSingle",[n.tokenPath[0].address,n.tokenPath[1].address,n.pools[0].fee,s,Z(null!=(l=null==(f=a)?void 0:f.sqrtPriceLimitX96)?l:0)])}else{var h;void 0!==(null==(h=a)?void 0:h.sqrtPriceLimitX96)&&r(!1);var m=$(n,o===e.TradeType.EXACT_OUTPUT);u=t.INTERFACE.encodeFunctionData(o===e.TradeType.EXACT_INPUT?"quoteExactInput":"quoteExactOutput",[m,s])}return{calldata:u,value:Z(0)}},t}();gt.INTERFACE=new i.Interface(l.abi);var Tt=function(){function t(){}return t.encodeClaim=function(n,r){var i,o=[];o.push(t.INTERFACE.encodeFunctionData("unstakeToken",[this._encodeIncentiveKey(n),Z(r.tokenId)]));var a=e.validateAndParseAddress(r.recipient),u=null!=(i=r.amount)?i:0;return o.push(t.INTERFACE.encodeFunctionData("claimReward",[n.rewardToken.address,a,Z(u)])),o},t.collectRewards=function(e,n){e=Array.isArray(e)?e:[e];for(var r=[],i=0;i<e.length;i++){var o=e[i];(r=r.concat(this.encodeClaim(o,n))).push(t.INTERFACE.encodeFunctionData("stakeToken",[this._encodeIncentiveKey(o),Z(n.tokenId)]))}return{calldata:ht.encodeMulticall(r),value:Z(0)}},t.withdrawToken=function(n,r){var i=[];n=Array.isArray(n)?n:[n];for(var o={tokenId:r.tokenId,recipient:r.recipient,amount:r.amount},a=0;a<n.length;a++)i=i.concat(this.encodeClaim(n[a],o));var u=e.validateAndParseAddress(r.owner);return i.push(t.INTERFACE.encodeFunctionData("withdrawToken",[Z(r.tokenId),u,r.data?r.data:Z(0)])),{calldata:ht.encodeMulticall(i),value:Z(0)}},t.encodeDeposit=function(e){var n;if((e=Array.isArray(e)?e:[e]).length>1){for(var r=[],o=0;o<e.length;o++)r.push(this._encodeIncentiveKey(e[o]));n=i.defaultAbiCoder.encode([t.INCENTIVE_KEY_ABI+"[]"],[r])}else n=i.defaultAbiCoder.encode([t.INCENTIVE_KEY_ABI],[this._encodeIncentiveKey(e[0])]);return n},t._encodeIncentiveKey=function(t){var n=t.pool,r=n.token0,i=n.token1,o=n.fee,a=e.validateAndParseAddress(t.refundee);return{rewardToken:t.rewardToken.address,pool:ct.getAddress(r,i,o),startTime:Z(t.startTime),endTime:Z(t.endTime),refundee:a}},t}();Tt.INTERFACE=new i.Interface(f.abi),Tt.INCENTIVE_KEY_ABI="tuple(address rewardToken, address pool, uint256 startTime, uint256 endTime, address refundee)",exports.ADDRESS_ZERO=q,exports.FACTORY_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.FullMath=F,exports.LiquidityMath=_,exports.NoTickDataProvider=Q,exports.NonfungiblePositionManager=yt,exports.POOL_INIT_CODE_HASH=b,exports.POOL_INIT_CODE_HASH_OPTIMISM="0x0c231002d0970d2126e7e00ce88c3b0e5ec8e48dac71478d56245c34ea2f9447",exports.POOL_INIT_CODE_HASH_OPTIMISM_KOVAN="0x1fc830513acbdb1608b8c18fd3cf4a4bee3329c69bb41d56400401c40fe02fd0",exports.Pool=ct,exports.Position=st,exports.Route=pt,exports.SqrtPriceMath=M,exports.Staker=Tt,exports.SwapQuoter=gt,exports.SwapRouter=At,exports.TICK_SPACINGS=R,exports.Tick=ot,exports.TickList=Y,exports.TickListDataProvider=at,exports.TickMath=G,exports.Trade=lt,exports.computePoolAddress=N,exports.encodeRouteToPath=$,exports.encodeSqrtRatioX96=J,exports.isSorted=z,exports.maxLiquidityForAmounts=rt,exports.mostSignificantBit=H,exports.nearestUsableTick=function(t,e){Number.isInteger(t)&&Number.isInteger(e)||r(!1),e>0||r(!1),t>=G.MIN_TICK&&t<=G.MAX_TICK||r(!1);var n=Math.round(t/e)*e;return n<G.MIN_TICK?n+e:n>G.MAX_TICK?n-e:n},exports.priceToClosestTick=function(t){var e=t.baseCurrency.sortsBefore(t.quoteCurrency),n=e?J(t.numerator,t.denominator):J(t.denominator,t.numerator),r=G.getTickAtSqrtRatio(n),i=it(t.baseCurrency,t.quoteCurrency,r+1);return e?t.lessThan(i)||r++:t.greaterThan(i)||r++,r},exports.tickToPrice=it,exports.toHex=Z,exports.tradeComparator=dt; | ||
"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"),n=t(require("jsbi")),r=t(require("tiny-invariant")),i=require("@ethersproject/abi"),o=require("@ethersproject/address"),a=require("@ethersproject/solidity"),u=require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IMulticall.sol/IMulticall.json"),c=require("@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json"),s=require("@uniswap/v3-periphery/artifacts/contracts/interfaces/ISelfPermit.sol/ISelfPermit.json"),p=require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IPeripheryPaymentsWithFee.sol/IPeripheryPaymentsWithFee.json"),d=require("@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json"),l=require("@uniswap/v3-staker/artifacts/contracts/UniswapV3Staker.sol/UniswapV3Staker.json"),f=require("@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json");function h(t,e,n,r,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,i)}function m(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){h(o,r,i,a,u,"next",t)}function u(t){h(o,r,i,a,u,"throw",t)}a(void 0)}))}}function v(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 k(t,e,n){return e&&v(t.prototype,e),n&&v(t,n),t}function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}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 g(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)}var T,x,I,w=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var i=Object.create((e&&e.prototype instanceof d?e:d).prototype),o=new I(r||[]);return i._invoke=function(t,e,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=g(a,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=s(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(t,n,o),i}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var p={};function d(){}function l(){}function f(){}var h={};h[i]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(w([])));v&&v!==e&&n.call(v,i)&&(h=v);var k=f.prototype=d.prototype=Object.create(h);function y(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){var r;this._invoke=function(i,o){function a(){return new e((function(r,a){!function r(i,o,a,u){var c=s(t[i],t,o);if("throw"!==c.type){var p=c.arg,d=p.value;return d&&"object"==typeof d&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(d).then((function(t){p.value=t,a(p)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function g(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,g(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,p;var i=r.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function w(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:q}}function q(){return{value:void 0,done:!0}}return l.prototype=k.constructor=f,f.constructor=l,l.displayName=u(f,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,u(t,a,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},y(A.prototype),A.prototype[o]=function(){return this},t.AsyncIterator=A,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new A(c(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},y(k),u(k,a,"Generator"),k[i]=function(){return this},k.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=w,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),x(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:w(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(I={exports:{}}),I.exports),q="0x0000000000000000000000000000000000000000",b="0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54";(x=exports.FeeAmount||(exports.FeeAmount={}))[x.LOW=500]="LOW",x[x.MEDIUM=3e3]="MEDIUM",x[x.HIGH=1e4]="HIGH";var R=((T={})[exports.FeeAmount.LOW]=10,T[exports.FeeAmount.MEDIUM]=60,T[exports.FeeAmount.HIGH]=200,T),P=n.BigInt(-1),E=n.BigInt(0),C=n.BigInt(1),S=n.exponentiate(n.BigInt(2),n.BigInt(96)),O=n.exponentiate(S,n.BigInt(2));function N(t){var e=t.factoryAddress,n=t.tokenA,r=t.tokenB,u=t.fee,c=t.initCodeHashManualOverride,s=n.sortsBefore(r)?[n,r]:[r,n];return o.getCreate2Address(e,a.keccak256(["bytes"],[i.defaultAbiCoder.encode(["address","address","uint24"],[s[0].address,s[1].address,u])]),null!=c?c:10===n.chainId?"0x0c231002d0970d2126e7e00ce88c3b0e5ec8e48dac71478d56245c34ea2f9447":69===n.chainId?"0x1fc830513acbdb1608b8c18fd3cf4a4bee3329c69bb41d56400401c40fe02fd0":b)}var _=function(){function t(){}return t.addDelta=function(t,e){return n.lessThan(e,E)?n.subtract(t,n.multiply(e,P)):n.add(t,e)},t}(),F=function(){function t(){}return t.mulDivRoundingUp=function(t,e,r){var i=n.multiply(t,e),o=n.divide(i,r);return n.notEqual(n.remainder(i,r),E)&&(o=n.add(o,C)),o},t}(),L=n.subtract(n.exponentiate(n.BigInt(2),n.BigInt(160)),C);function U(t,r){var i=n.multiply(t,r);return n.bitwiseAnd(i,e.MaxUint256)}var M=function(){function t(){}return t.getAmount0Delta=function(t,e,r,i){if(n.greaterThan(t,e)){var o=[e,t];t=o[0],e=o[1]}var a=n.leftShift(r,n.BigInt(96)),u=n.subtract(e,t);return i?F.mulDivRoundingUp(F.mulDivRoundingUp(a,u,e),C,t):n.divide(n.divide(n.multiply(a,u),e),t)},t.getAmount1Delta=function(t,e,r,i){if(n.greaterThan(t,e)){var o=[e,t];t=o[0],e=o[1]}return i?F.mulDivRoundingUp(r,n.subtract(e,t),S):n.divide(n.multiply(r,n.subtract(e,t)),S)},t.getNextSqrtPriceFromInput=function(t,e,i,o){return n.greaterThan(t,E)||r(!1),n.greaterThan(e,E)||r(!1),o?this.getNextSqrtPriceFromAmount0RoundingUp(t,e,i,!0):this.getNextSqrtPriceFromAmount1RoundingDown(t,e,i,!0)},t.getNextSqrtPriceFromOutput=function(t,e,i,o){return n.greaterThan(t,E)||r(!1),n.greaterThan(e,E)||r(!1),o?this.getNextSqrtPriceFromAmount1RoundingDown(t,e,i,!1):this.getNextSqrtPriceFromAmount0RoundingUp(t,e,i,!1)},t.getNextSqrtPriceFromAmount0RoundingUp=function(t,i,o,a){if(n.equal(o,E))return t;var u=n.leftShift(i,n.BigInt(96));if(a){var c=U(o,t);if(n.equal(n.divide(c,o),t)){var s=(d=n.add(u,c),n.bitwiseAnd(d,e.MaxUint256));if(n.greaterThanOrEqual(s,u))return F.mulDivRoundingUp(u,t,s)}return F.mulDivRoundingUp(u,C,n.add(n.divide(u,t),o))}var p=U(o,t);n.equal(n.divide(p,o),t)||r(!1),n.greaterThan(u,p)||r(!1);var d,l=n.subtract(u,p);return F.mulDivRoundingUp(u,t,l)},t.getNextSqrtPriceFromAmount1RoundingDown=function(t,e,i,o){if(o){var a=n.lessThanOrEqual(i,L)?n.divide(n.leftShift(i,n.BigInt(96)),e):n.divide(n.multiply(i,S),e);return n.add(t,a)}var u=F.mulDivRoundingUp(i,S,e);return n.greaterThan(t,u)||r(!1),n.subtract(t,u)},t}(),X=n.exponentiate(n.BigInt(10),n.BigInt(6)),D=function(){function t(){}return t.computeSwapStep=function(t,e,r,i,o){var a={},u=n.greaterThanOrEqual(t,e),c=n.greaterThanOrEqual(i,E);if(c){var s=n.divide(n.multiply(i,n.subtract(X,n.BigInt(o))),X);a.amountIn=u?M.getAmount0Delta(e,t,r,!0):M.getAmount1Delta(t,e,r,!0),a.sqrtRatioNextX96=n.greaterThanOrEqual(s,a.amountIn)?e:M.getNextSqrtPriceFromInput(t,r,s,u)}else a.amountOut=u?M.getAmount1Delta(e,t,r,!1):M.getAmount0Delta(t,e,r,!1),a.sqrtRatioNextX96=n.greaterThanOrEqual(n.multiply(i,P),a.amountOut)?e:M.getNextSqrtPriceFromOutput(t,r,n.multiply(i,P),u);var p=n.equal(e,a.sqrtRatioNextX96);return u?(a.amountIn=p&&c?a.amountIn:M.getAmount0Delta(a.sqrtRatioNextX96,t,r,!0),a.amountOut=p&&!c?a.amountOut:M.getAmount1Delta(a.sqrtRatioNextX96,t,r,!1)):(a.amountIn=p&&c?a.amountIn:M.getAmount1Delta(t,a.sqrtRatioNextX96,r,!0),a.amountOut=p&&!c?a.amountOut:M.getAmount0Delta(t,a.sqrtRatioNextX96,r,!1)),!c&&n.greaterThan(a.amountOut,n.multiply(i,P))&&(a.amountOut=n.multiply(i,P)),a.feeAmount=c&&n.notEqual(a.sqrtRatioNextX96,e)?n.subtract(i,a.amountIn):F.mulDivRoundingUp(a.amountIn,n.BigInt(o),n.subtract(X,n.BigInt(o))),[a.sqrtRatioNextX96,a.amountIn,a.amountOut,a.feeAmount]},t}(),B=n.BigInt(2),j=[128,64,32,16,8,4,2,1].map((function(t){return[t,n.exponentiate(B,n.BigInt(t))]}));function H(t){n.greaterThan(t,E)||r(!1),n.lessThanOrEqual(t,e.MaxUint256)||r(!1);for(var i,o=0,a=g(j);!(i=a()).done;){var u=i.value,c=u[0];n.greaterThanOrEqual(t,u[1])&&(t=n.signedRightShift(t,n.BigInt(c)),o+=c)}return o}function W(t,e){return n.signedRightShift(n.multiply(t,n.BigInt(e)),n.BigInt(128))}var K=n.exponentiate(n.BigInt(2),n.BigInt(32)),G=function(){function t(){}return t.getSqrtRatioAtTick=function(i){i>=t.MIN_TICK&&i<=t.MAX_TICK&&Number.isInteger(i)||r(!1);var o=i<0?-1*i:i,a=n.BigInt(0!=(1&o)?"0xfffcb933bd6fad37aa2d162d1a594001":"0x100000000000000000000000000000000");return 0!=(2&o)&&(a=W(a,"0xfff97272373d413259a46990580e213a")),0!=(4&o)&&(a=W(a,"0xfff2e50f5f656932ef12357cf3c7fdcc")),0!=(8&o)&&(a=W(a,"0xffe5caca7e10e4e61c3624eaa0941cd0")),0!=(16&o)&&(a=W(a,"0xffcb9843d60f6159c9db58835c926644")),0!=(32&o)&&(a=W(a,"0xff973b41fa98c081472e6896dfb254c0")),0!=(64&o)&&(a=W(a,"0xff2ea16466c96a3843ec78b326b52861")),0!=(128&o)&&(a=W(a,"0xfe5dee046a99a2a811c461f1969c3053")),0!=(256&o)&&(a=W(a,"0xfcbe86c7900a88aedcffc83b479aa3a4")),0!=(512&o)&&(a=W(a,"0xf987a7253ac413176f2b074cf7815e54")),0!=(1024&o)&&(a=W(a,"0xf3392b0822b70005940c7a398e4b70f3")),0!=(2048&o)&&(a=W(a,"0xe7159475a2c29b7443b29c7fa6e889d9")),0!=(4096&o)&&(a=W(a,"0xd097f3bdfd2022b8845ad8f792aa5825")),0!=(8192&o)&&(a=W(a,"0xa9f746462d870fdf8a65dc1f90e061e5")),0!=(16384&o)&&(a=W(a,"0x70d869a156d2a1b890bb3df62baf32f7")),0!=(32768&o)&&(a=W(a,"0x31be135f97d08fd981231505542fcfa6")),0!=(65536&o)&&(a=W(a,"0x9aa508b5b7a84e1c677de54f3e99bc9")),0!=(131072&o)&&(a=W(a,"0x5d6af8dedb81196699c329225ee604")),0!=(262144&o)&&(a=W(a,"0x2216e584f5fa1ea926041bedfe98")),0!=(524288&o)&&(a=W(a,"0x48a170391f7dc42444e8fa2")),i>0&&(a=n.divide(e.MaxUint256,a)),n.greaterThan(n.remainder(a,K),E)?n.add(n.divide(a,K),C):n.divide(a,K)},t.getTickAtSqrtRatio=function(e){n.greaterThanOrEqual(e,t.MIN_SQRT_RATIO)&&n.lessThan(e,t.MAX_SQRT_RATIO)||r(!1);var i,o=n.leftShift(e,n.BigInt(32)),a=H(o);i=n.greaterThanOrEqual(n.BigInt(a),n.BigInt(128))?n.signedRightShift(o,n.BigInt(a-127)):n.leftShift(o,n.BigInt(127-a));for(var u=n.leftShift(n.subtract(n.BigInt(a),n.BigInt(128)),n.BigInt(64)),c=0;c<14;c++){i=n.signedRightShift(n.multiply(i,i),n.BigInt(127));var s=n.signedRightShift(i,n.BigInt(128));u=n.bitwiseOr(u,n.leftShift(s,n.BigInt(63-c))),i=n.signedRightShift(i,s)}var p=n.multiply(u,n.BigInt("255738958999603826347141")),d=n.toNumber(n.signedRightShift(n.subtract(p,n.BigInt("3402992956809132418596140100660247210")),n.BigInt(128))),l=n.toNumber(n.signedRightShift(n.add(p,n.BigInt("291339464771989622907027621153398088495")),n.BigInt(128)));return d===l?d:n.lessThanOrEqual(t.getSqrtRatioAtTick(l),e)?l:d},t}();G.MIN_TICK=-887272,G.MAX_TICK=-G.MIN_TICK,G.MIN_SQRT_RATIO=n.BigInt("4295128739"),G.MAX_SQRT_RATIO=n.BigInt("1461446703485210103287273052203988822378723970342");var Q=function(){function t(){}var e=t.prototype;return e.getTick=function(){var e=m(w.mark((function e(n){return w.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error(t.ERROR_MESSAGE);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var e=m(w.mark((function e(n,r,i){return w.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error(t.ERROR_MESSAGE);case 1:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t}();function z(t,e){for(var n=0;n<t.length-1;n++)if(e(t[n],t[n+1])>0)return!1;return!0}function V(t,e){return t.index-e.index}Q.ERROR_MESSAGE="No tick data provider was given";var Y=function(){function t(){}return t.validateList=function(t,e){e>0||r(!1),t.every((function(t){return t.index%e==0}))||r(!1),n.equal(t.reduce((function(t,e){return n.add(t,e.liquidityNet)}),E),E)||r(!1),z(t,V)||r(!1)},t.isBelowSmallest=function(t,e){return t.length>0||r(!1),e<t[0].index},t.isAtOrAboveLargest=function(t,e){return t.length>0||r(!1),e>=t[t.length-1].index},t.getTick=function(t,e){var n=t[this.binarySearch(t,e)];return n.index!==e&&r(!1),n},t.binarySearch=function(t,e){this.isBelowSmallest(t,e)&&r(!1);for(var n,i=0,o=t.length-1;;){if(t[n=Math.floor((i+o)/2)].index<=e&&(n===t.length-1||t[n+1].index>e))return n;t[n].index<e?i=n+1:o=n-1}},t.nextInitializedTick=function(e,n,i){return i?(t.isBelowSmallest(e,n)&&r(!1),t.isAtOrAboveLargest(e,n)?e[e.length-1]:e[this.binarySearch(e,n)]):(this.isAtOrAboveLargest(e,n)&&r(!1),this.isBelowSmallest(e,n)?e[0]:e[this.binarySearch(e,n)+1])},t.nextInitializedTickWithinOneWord=function(e,n,r,i){var o=Math.floor(n/i);if(r){var a=(o>>8<<8)*i;if(t.isBelowSmallest(e,n))return[a,!1];var u=t.nextInitializedTick(e,n,r).index,c=Math.max(a,u);return[c,c===u]}var s=(1+(o+1>>8)<<8)*i-1;if(this.isAtOrAboveLargest(e,n))return[s,!1];var p=this.nextInitializedTick(e,n,r).index,d=Math.min(s,p);return[d,d===p]},t}();function Z(t){var e=n.BigInt(t).toString(16);return e.length%2!=0&&(e="0"+e),"0x"+e}function $(t,e){var n=t.pools.reduce((function(t,e,n){var r=t.inputToken,i=t.path,o=t.types,a=e.token0.equals(r)?e.token1:e.token0;return 0===n?{inputToken:a,types:["address","uint24","address"],path:[r.address,e.fee,a.address]}:{inputToken:a,types:[].concat(o,["uint24","address"]),path:[].concat(i,[e.fee,a.address])}}),{inputToken:t.input.wrapped,path:[],types:[]}),r=n.path,i=n.types;return e?a.pack(i.reverse(),r.reverse()):a.pack(i,r)}function J(t,r){var i=n.leftShift(n.BigInt(t),n.BigInt(192)),o=n.BigInt(r),a=n.divide(i,o);return e.sqrt(a)}function tt(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}var o=n.divide(n.multiply(t,e),S);return n.divide(n.multiply(n.BigInt(r),o),n.subtract(e,t))}function et(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}var o=n.multiply(n.multiply(n.BigInt(r),t),e),a=n.multiply(S,n.subtract(e,t));return n.divide(o,a)}function nt(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}return n.divide(n.multiply(n.BigInt(r),S),n.subtract(e,t))}function rt(t,e,r,i,o,a){if(n.greaterThan(e,r)){var u=[r,e];e=u[0],r=u[1]}var c=a?et:tt;if(n.lessThanOrEqual(t,e))return c(e,r,i);if(n.lessThan(t,r)){var s=c(t,r,i),p=nt(e,t,o);return n.lessThan(s,p)?s:p}return nt(e,r,o)}function it(t,r,i){var o=G.getSqrtRatioAtTick(i),a=n.multiply(o,o);return t.sortsBefore(r)?new e.Price(t,r,O,a):new e.Price(t,r,a,O)}var ot=function(t){var e=t.index,i=t.liquidityGross,o=t.liquidityNet;e>=G.MIN_TICK&&e<=G.MAX_TICK||r(!1),this.index=e,this.liquidityGross=n.BigInt(i),this.liquidityNet=n.BigInt(o)},at=function(){function t(t,e){var n=t.map((function(t){return t instanceof ot?t:new ot(t)}));Y.validateList(n,e),this.ticks=n}var e=t.prototype;return e.getTick=function(){var t=m(w.mark((function t(e){return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Y.getTick(this.ticks,e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var t=m(w.mark((function t(e,n,r){return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Y.nextInitializedTickWithinOneWord(this.ticks,e,n,r));case 1:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),t}(),ut=new Q,ct=function(){function t(t,e,i,o,a,u,c){void 0===c&&(c=ut),Number.isInteger(i)&&i<1e6||r(!1);var s=G.getSqrtRatioAtTick(u),p=G.getSqrtRatioAtTick(u+1);n.greaterThanOrEqual(n.BigInt(o),s)&&n.lessThanOrEqual(n.BigInt(o),p)||r(!1);var d=t.sortsBefore(e)?[t,e]:[e,t];this.token0=d[0],this.token1=d[1],this.fee=i,this.sqrtRatioX96=n.BigInt(o),this.liquidity=n.BigInt(a),this.tickCurrent=u,this.tickDataProvider=Array.isArray(c)?new at(c,R[i]):c}t.getAddress=function(t,e,n,r){return N({factoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",fee:n,tokenA:t,tokenB:e,initCodeHashManualOverride:r})};var i=t.prototype;return i.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},i.priceOf=function(t){return this.involvesToken(t)||r(!1),t.equals(this.token0)?this.token0Price:this.token1Price},i.getOutputAmount=function(){var i=m(w.mark((function i(o,a){var u,c,s,p,d;return w.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return this.involvesToken(o.currency)||r(!1),u=o.currency.equals(this.token0),i.next=4,this.swap(u,o.quotient,a);case 4:return s=(c=i.sent).sqrtRatioX96,p=c.liquidity,d=c.tickCurrent,i.abrupt("return",[e.CurrencyAmount.fromRawAmount(u?this.token1:this.token0,n.multiply(c.amountCalculated,P)),new t(this.token0,this.token1,this.fee,s,p,d,this.tickDataProvider)]);case 11:case"end":return i.stop()}}),i,this)})));return function(t,e){return i.apply(this,arguments)}}(),i.getInputAmount=function(){var i=m(w.mark((function i(o,a){var u,c,s,p,d;return w.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return o.currency.isToken&&this.involvesToken(o.currency)||r(!1),u=o.currency.equals(this.token1),i.next=4,this.swap(u,n.multiply(o.quotient,P),a);case 4:return s=(c=i.sent).sqrtRatioX96,p=c.liquidity,d=c.tickCurrent,i.abrupt("return",[e.CurrencyAmount.fromRawAmount(u?this.token0:this.token1,c.amountCalculated),new t(this.token0,this.token1,this.fee,s,p,d,this.tickDataProvider)]);case 11:case"end":return i.stop()}}),i,this)})));return function(t,e){return i.apply(this,arguments)}}(),i.swap=function(){var t=m(w.mark((function t(e,i,o){var a,u,c,s,p,d;return w.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o||(o=e?n.add(G.MIN_SQRT_RATIO,C):n.subtract(G.MAX_SQRT_RATIO,C)),e?(n.greaterThan(o,G.MIN_SQRT_RATIO)||r(!1),n.lessThan(o,this.sqrtRatioX96)||r(!1)):(n.lessThan(o,G.MAX_SQRT_RATIO)||r(!1),n.greaterThan(o,this.sqrtRatioX96)||r(!1)),a=n.greaterThanOrEqual(i,E),u={amountSpecifiedRemaining:i,amountCalculated:E,sqrtPriceX96:this.sqrtRatioX96,tick:this.tickCurrent,liquidity:this.liquidity};case 4:if(!n.notEqual(u.amountSpecifiedRemaining,E)||u.sqrtPriceX96==o){t.next=35;break}return(c={}).sqrtPriceStartX96=u.sqrtPriceX96,t.next=9,this.tickDataProvider.nextInitializedTickWithinOneWord(u.tick,e,this.tickSpacing);case 9:if(c.tickNext=(s=t.sent)[0],c.initialized=s[1],c.tickNext<G.MIN_TICK?c.tickNext=G.MIN_TICK:c.tickNext>G.MAX_TICK&&(c.tickNext=G.MAX_TICK),c.sqrtPriceNextX96=G.getSqrtRatioAtTick(c.tickNext),p=D.computeSwapStep(u.sqrtPriceX96,(e?n.lessThan(c.sqrtPriceNextX96,o):n.greaterThan(c.sqrtPriceNextX96,o))?o:c.sqrtPriceNextX96,u.liquidity,u.amountSpecifiedRemaining,this.fee),u.sqrtPriceX96=p[0],c.amountIn=p[1],c.amountOut=p[2],c.feeAmount=p[3],a?(u.amountSpecifiedRemaining=n.subtract(u.amountSpecifiedRemaining,n.add(c.amountIn,c.feeAmount)),u.amountCalculated=n.subtract(u.amountCalculated,c.amountOut)):(u.amountSpecifiedRemaining=n.add(u.amountSpecifiedRemaining,c.amountOut),u.amountCalculated=n.add(u.amountCalculated,n.add(c.amountIn,c.feeAmount))),!n.equal(u.sqrtPriceX96,c.sqrtPriceNextX96)){t.next=32;break}if(!c.initialized){t.next=29;break}return t.t0=n,t.next=25,this.tickDataProvider.getTick(c.tickNext);case 25:t.t1=t.sent.liquidityNet,d=t.t0.BigInt.call(t.t0,t.t1),e&&(d=n.multiply(d,P)),u.liquidity=_.addDelta(u.liquidity,d);case 29:u.tick=e?c.tickNext-1:c.tickNext,t.next=33;break;case 32:u.sqrtPriceX96!=c.sqrtPriceStartX96&&(u.tick=G.getTickAtSqrtRatio(u.sqrtPriceX96));case 33:t.next=4;break;case 35:return t.abrupt("return",{amountCalculated:u.amountCalculated,sqrtRatioX96:u.sqrtPriceX96,liquidity:u.liquidity,tickCurrent:u.tick});case 36:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),k(t,[{key:"token0Price",get:function(){var t;return null!=(t=this._token0Price)?t:this._token0Price=new e.Price(this.token0,this.token1,O,n.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}},{key:"token1Price",get:function(){var t;return null!=(t=this._token1Price)?t:this._token1Price=new e.Price(this.token1,this.token0,n.multiply(this.sqrtRatioX96,this.sqrtRatioX96),O)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"tickSpacing",get:function(){return R[this.fee]}}]),t}(),st=function(){function t(t){var e=t.pool,i=t.liquidity,o=t.tickLower,a=t.tickUpper;this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,o<a||r(!1),o>=G.MIN_TICK&&o%e.tickSpacing==0||r(!1),a<=G.MAX_TICK&&a%e.tickSpacing==0||r(!1),this.pool=e,this.tickLower=o,this.tickUpper=a,this.liquidity=n.BigInt(i)}var i=t.prototype;return i.ratiosAfterSlippage=function(t){var r=this.pool.token0Price.asFraction.multiply(new e.Percent(1).subtract(t)),i=this.pool.token0Price.asFraction.multiply(t.add(1)),o=J(r.numerator,r.denominator);n.lessThanOrEqual(o,G.MIN_SQRT_RATIO)&&(o=n.add(G.MIN_SQRT_RATIO,n.BigInt(1)));var a=J(i.numerator,i.denominator);return n.greaterThanOrEqual(a,G.MAX_SQRT_RATIO)&&(a=n.subtract(G.MAX_SQRT_RATIO,n.BigInt(1))),{sqrtRatioX96Lower:o,sqrtRatioX96Upper:a}},i.mintAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new ct(this.pool.token0,this.pool.token1,this.pool.fee,i,0,G.getTickAtSqrtRatio(i)),a=new ct(this.pool.token0,this.pool.token1,this.pool.fee,r,0,G.getTickAtSqrtRatio(r)),u=t.fromAmounts(y({pool:this.pool,tickLower:this.tickLower,tickUpper:this.tickUpper},this.mintAmounts,{useFullPrecision:!1}));return{amount0:new t({pool:a,liquidity:u.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount0,amount1:new t({pool:o,liquidity:u.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount1}},i.burnAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new ct(this.pool.token0,this.pool.token1,this.pool.fee,i,0,G.getTickAtSqrtRatio(i)),a=new t({pool:new ct(this.pool.token0,this.pool.token1,this.pool.fee,r,0,G.getTickAtSqrtRatio(r)),liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,u=new t({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:a.quotient,amount1:u.quotient}},t.fromAmounts=function(e){var n=e.pool,r=e.tickLower,i=e.tickUpper,o=e.amount0,a=e.amount1,u=e.useFullPrecision,c=G.getSqrtRatioAtTick(r),s=G.getSqrtRatioAtTick(i);return new t({pool:n,tickLower:r,tickUpper:i,liquidity:rt(n.sqrtRatioX96,c,s,o,a,u)})},t.fromAmount0=function(n){return t.fromAmounts({pool:n.pool,tickLower:n.tickLower,tickUpper:n.tickUpper,amount0:n.amount0,amount1:e.MaxUint256,useFullPrecision:n.useFullPrecision})},t.fromAmount1=function(n){return t.fromAmounts({pool:n.pool,tickLower:n.tickLower,tickUpper:n.tickUpper,amount0:e.MaxUint256,amount1:n.amount1,useFullPrecision:!0})},k(t,[{key:"token0PriceLower",get:function(){return it(this.pool.token0,this.pool.token1,this.tickLower)}},{key:"token0PriceUpper",get:function(){return it(this.pool.token0,this.pool.token1,this.tickUpper)}},{key:"amount0",get:function(){return null===this._token0Amount&&(this._token0Amount=e.CurrencyAmount.fromRawAmount(this.pool.token0,this.pool.tickCurrent<this.tickLower?M.getAmount0Delta(G.getSqrtRatioAtTick(this.tickLower),G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):this.pool.tickCurrent<this.tickUpper?M.getAmount0Delta(this.pool.sqrtRatioX96,G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):E)),this._token0Amount}},{key:"amount1",get:function(){return null===this._token1Amount&&(this._token1Amount=e.CurrencyAmount.fromRawAmount(this.pool.token1,this.pool.tickCurrent<this.tickLower?E:M.getAmount1Delta(G.getSqrtRatioAtTick(this.tickLower),this.pool.tickCurrent<this.tickUpper?this.pool.sqrtRatioX96:G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}},{key:"mintAmounts",get:function(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:M.getAmount0Delta(G.getSqrtRatioAtTick(this.tickLower),G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:E}:this.pool.tickCurrent<this.tickUpper?{amount0:M.getAmount0Delta(this.pool.sqrtRatioX96,G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:M.getAmount1Delta(G.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:E,amount1:M.getAmount1Delta(G.getSqrtRatioAtTick(this.tickLower),G.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}}]),t}(),pt=function(){function t(t,e,n){this._midPrice=null,t.length>0||r(!1);var i=t[0].chainId;t.every((function(t){return t.chainId===i}))||r(!1);var o=e.wrapped;t[0].involvesToken(o)||r(!1),t[t.length-1].involvesToken(n.wrapped)||r(!1);for(var a,u=[o],c=g(t.entries());!(a=c()).done;){var s=a.value,p=s[1],d=u[s[0]];d.equals(p.token0)||d.equals(p.token1)||r(!1);var l=d.equals(p.token0)?p.token1:p.token0;u.push(l)}this.pools=t,this.tokenPath=u,this.input=e,this.output=null!=n?n:u[u.length-1]}return k(t,[{key:"chainId",get:function(){return this.pools[0].chainId}},{key:"midPrice",get:function(){if(null!==this._midPrice)return this._midPrice;var t=this.pools.slice(1).reduce((function(t,e){var n=t.price;return t.nextInput.equals(e.token0)?{nextInput:e.token1,price:n.multiply(e.token0Price)}:{nextInput:e.token0,price:n.multiply(e.token1Price)}}),this.pools[0].token0.equals(this.input.wrapped)?{nextInput:this.pools[0].token1,price:this.pools[0].token0Price}:{nextInput:this.pools[0].token0,price:this.pools[0].token1Price}).price;return this._midPrice=new e.Price(this.input,this.output,t.denominator,t.numerator)}}]),t}();function dt(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||r(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||r(!1),t.outputAmount.equalTo(e.outputAmount)?t.inputAmount.equalTo(e.inputAmount)?t.swaps.reduce((function(t,e){return t+e.route.tokenPath.length}),0)-e.swaps.reduce((function(t,e){return t+e.route.tokenPath.length}),0):t.inputAmount.lessThan(e.inputAmount)?-1:1:t.outputAmount.lessThan(e.outputAmount)?1:-1}var lt=function(){function t(t){var e=t.routes,n=t.tradeType,i=e[0].inputAmount.currency,o=e[0].outputAmount.currency;e.every((function(t){return i.wrapped.equals(t.route.input.wrapped)}))||r(!1),e.every((function(t){return o.wrapped.equals(t.route.output.wrapped)}))||r(!1);for(var a,u=e.map((function(t){return t.route.pools.length})).reduce((function(t,e){return t+e}),0),c=new Set,s=g(e);!(a=s()).done;)for(var p,d=g(a.value.route.pools);!(p=d()).done;){var l=p.value;c.add(ct.getAddress(l.token0,l.token1,l.fee))}u!=c.size&&r(!1),this.swaps=e,this.tradeType=n}t.exactIn=function(){var n=m(w.mark((function n(r,i){return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.fromRoute(r,i,e.TradeType.EXACT_INPUT));case 1:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.exactOut=function(){var n=m(w.mark((function n(r,i){return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.fromRoute(r,i,e.TradeType.EXACT_OUTPUT));case 1:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.fromRoute=function(){var n=m(w.mark((function n(i,o,a){var u,c,s,p,d,l,f;return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(u=new Array(i.tokenPath.length),a!==e.TradeType.EXACT_INPUT){n.next=19;break}o.currency.equals(i.input)||r(!1),u[0]=o.wrapped,p=0;case 5:if(!(p<i.tokenPath.length-1)){n.next=15;break}return d=i.pools[p],n.next=9,d.getOutputAmount(u[p]);case 9:u[p+1]=n.sent[0];case 12:p++,n.next=5;break;case 15:c=e.CurrencyAmount.fromFractionalAmount(i.input,o.numerator,o.denominator),s=e.CurrencyAmount.fromFractionalAmount(i.output,u[u.length-1].numerator,u[u.length-1].denominator),n.next=34;break;case 19:o.currency.equals(i.output)||r(!1),u[u.length-1]=o.wrapped,l=i.tokenPath.length-1;case 22:if(!(l>0)){n.next=32;break}return f=i.pools[l-1],n.next=26,f.getInputAmount(u[l]);case 26:u[l-1]=n.sent[0];case 29:l--,n.next=22;break;case 32:c=e.CurrencyAmount.fromFractionalAmount(i.input,u[0].numerator,u[0].denominator),s=e.CurrencyAmount.fromFractionalAmount(i.output,o.numerator,o.denominator);case 34:return n.abrupt("return",new t({routes:[{inputAmount:c,outputAmount:s,route:i}],tradeType:a}));case 35:case"end":return n.stop()}}),n)})));return function(t,e,r){return n.apply(this,arguments)}}(),t.fromRoutes=function(){var n=m(w.mark((function n(i,o){var a,u,c,s,p,d,l,f,h,m,v,k,y;return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:a=[],u=g(i);case 2:if((c=u()).done){n.next=43;break}if(p=(s=c.value).route,d=s.amount,l=new Array(p.tokenPath.length),f=void 0,h=void 0,o!==e.TradeType.EXACT_INPUT){n.next=25;break}d.currency.equals(p.input)||r(!1),f=e.CurrencyAmount.fromFractionalAmount(p.input,d.numerator,d.denominator),l[0]=e.CurrencyAmount.fromFractionalAmount(p.input.wrapped,d.numerator,d.denominator),m=0;case 12:if(!(m<p.tokenPath.length-1)){n.next=22;break}return v=p.pools[m],n.next=16,v.getOutputAmount(l[m]);case 16:l[m+1]=n.sent[0];case 19:m++,n.next=12;break;case 22:h=e.CurrencyAmount.fromFractionalAmount(p.output,l[l.length-1].numerator,l[l.length-1].denominator),n.next=40;break;case 25:d.currency.equals(p.output)||r(!1),h=e.CurrencyAmount.fromFractionalAmount(p.output,d.numerator,d.denominator),l[l.length-1]=e.CurrencyAmount.fromFractionalAmount(p.output.wrapped,d.numerator,d.denominator),k=p.tokenPath.length-1;case 29:if(!(k>0)){n.next=39;break}return y=p.pools[k-1],n.next=33,y.getInputAmount(l[k]);case 33:l[k-1]=n.sent[0];case 36:k--,n.next=29;break;case 39:f=e.CurrencyAmount.fromFractionalAmount(p.input,l[0].numerator,l[0].denominator);case 40:a.push({route:p,inputAmount:f,outputAmount:h});case 41:n.next=2;break;case 43:return n.abrupt("return",new t({routes:a,tradeType:o}));case 44:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.createUncheckedTrade=function(e){return new t(y({},e,{routes:[{inputAmount:e.inputAmount,outputAmount:e.outputAmount,route:e.route}]}))},t.createUncheckedTradeWithMultipleRoutes=function(e){return new t(e)};var n=t.prototype;return n.minimumAmountOut=function(t,n){if(void 0===n&&(n=this.outputAmount),t.lessThan(E)&&r(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return n;var i=new e.Fraction(C).add(t).invert().multiply(n.quotient).quotient;return e.CurrencyAmount.fromRawAmount(n.currency,i)},n.maximumAmountIn=function(t,n){if(void 0===n&&(n=this.inputAmount),t.lessThan(E)&&r(!1),this.tradeType===e.TradeType.EXACT_INPUT)return n;var i=new e.Fraction(C).add(t).multiply(n.quotient).quotient;return e.CurrencyAmount.fromRawAmount(n.currency,i)},n.worstExecutionPrice=function(t){return new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactIn=function(){var n=m(w.mark((function n(i,o,a,u,c,s,p){var d,l,f,h,m,v,k,y,A,g,T;return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:f=void 0===(l=(d=void 0===u?{}:u).maxNumResults)?3:l,m=void 0===(h=d.maxHops)?3:h,void 0===c&&(c=[]),void 0===s&&(s=o),void 0===p&&(p=[]),i.length>0||r(!1),m>0||r(!1),o===s||c.length>0||r(!1),v=s.wrapped,k=a.wrapped,y=0;case 10:if(!(y<i.length)){n.next=46;break}if((A=i[y]).token0.equals(v.currency)||A.token1.equals(v.currency)){n.next=14;break}return n.abrupt("continue",43);case 14:return g=void 0,n.prev=15,n.next=19,A.getOutputAmount(v);case 19:g=n.sent[0],n.next=28;break;case 23:if(n.prev=23,n.t0=n.catch(15),!n.t0.isInsufficientInputAmountError){n.next=27;break}return n.abrupt("continue",43);case 27:throw n.t0;case 28:if(!g.currency.isToken||!g.currency.equals(k)){n.next=39;break}return n.t1=e.sortedInsert,n.t2=p,n.next=33,t.fromRoute(new pt([].concat(c,[A]),o.currency,a),o,e.TradeType.EXACT_INPUT);case 33:n.t3=n.sent,n.t4=f,n.t5=dt,(0,n.t1)(n.t2,n.t3,n.t4,n.t5),n.next=43;break;case 39:if(!(m>1&&i.length>1)){n.next=43;break}return T=i.slice(0,y).concat(i.slice(y+1,i.length)),n.next=43,t.bestTradeExactIn(T,o,a,{maxNumResults:f,maxHops:m-1},[].concat(c,[A]),g,p);case 43:y++,n.next=10;break;case 46:return n.abrupt("return",p);case 47:case"end":return n.stop()}}),n,null,[[15,23]])})));return function(t,e,r,i,o,a,u){return n.apply(this,arguments)}}(),t.bestTradeExactOut=function(){var n=m(w.mark((function n(i,o,a,u,c,s,p){var d,l,f,h,m,v,k,y,A,g,T;return w.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:f=void 0===(l=(d=void 0===u?{}:u).maxNumResults)?3:l,m=void 0===(h=d.maxHops)?3:h,void 0===c&&(c=[]),void 0===s&&(s=a),void 0===p&&(p=[]),i.length>0||r(!1),m>0||r(!1),a===s||c.length>0||r(!1),v=s.wrapped,k=o.wrapped,y=0;case 10:if(!(y<i.length)){n.next=46;break}if((A=i[y]).token0.equals(v.currency)||A.token1.equals(v.currency)){n.next=14;break}return n.abrupt("continue",43);case 14:return g=void 0,n.prev=15,n.next=19,A.getInputAmount(v);case 19:g=n.sent[0],n.next=28;break;case 23:if(n.prev=23,n.t0=n.catch(15),!n.t0.isInsufficientReservesError){n.next=27;break}return n.abrupt("continue",43);case 27:throw n.t0;case 28:if(!g.currency.equals(k)){n.next=39;break}return n.t1=e.sortedInsert,n.t2=p,n.next=33,t.fromRoute(new pt([A].concat(c),o,a.currency),a,e.TradeType.EXACT_OUTPUT);case 33:n.t3=n.sent,n.t4=f,n.t5=dt,(0,n.t1)(n.t2,n.t3,n.t4,n.t5),n.next=43;break;case 39:if(!(m>1&&i.length>1)){n.next=43;break}return T=i.slice(0,y).concat(i.slice(y+1,i.length)),n.next=43,t.bestTradeExactOut(T,o,a,{maxNumResults:f,maxHops:m-1},[A].concat(c),g,p);case 43:y++,n.next=10;break;case 46:return n.abrupt("return",p);case 47:case"end":return n.stop()}}),n,null,[[15,23]])})));return function(t,e,r,i,o,a,u){return n.apply(this,arguments)}}(),k(t,[{key:"route",get:function(){return 1!=this.swaps.length&&r(!1),this.swaps[0].route}},{key:"inputAmount",get:function(){if(this._inputAmount)return this._inputAmount;var t=this.swaps[0].inputAmount.currency,n=this.swaps.map((function(t){return t.inputAmount})).reduce((function(t,e){return t.add(e)}),e.CurrencyAmount.fromRawAmount(t,0));return this._inputAmount=n,this._inputAmount}},{key:"outputAmount",get:function(){if(this._outputAmount)return this._outputAmount;var t=this.swaps[0].outputAmount.currency,n=this.swaps.map((function(t){return t.outputAmount})).reduce((function(t,e){return t.add(e)}),e.CurrencyAmount.fromRawAmount(t,0));return this._outputAmount=n,this._outputAmount}},{key:"executionPrice",get:function(){var t;return null!=(t=this._executionPrice)?t:this._executionPrice=new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.quotient,this.outputAmount.quotient)}},{key:"priceImpact",get:function(){if(this._priceImpact)return this._priceImpact;for(var t,n=e.CurrencyAmount.fromRawAmount(this.outputAmount.currency,0),r=g(this.swaps);!(t=r()).done;){var i=t.value;n=n.add(i.route.midPrice.quote(i.inputAmount))}var o=n.subtract(this.outputAmount).divide(n);return this._priceImpact=new e.Percent(o.numerator,o.denominator),this._priceImpact}}]),t}(),ft=function(){function t(){}return t.encodeMulticall=function(e){return Array.isArray(e)||(e=[e]),1===e.length?e[0]:t.INTERFACE.encodeFunctionData("multicall",[e])},t}();ft.INTERFACE=new i.Interface(u.abi);var ht=function(){function t(){}return t.encodePermit=function(e,n){return"nonce"in n?t.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,Z(n.nonce),Z(n.expiry),n.v,n.r,n.s]):t.INTERFACE.encodeFunctionData("selfPermit",[e.address,Z(n.amount),Z(n.deadline),n.v,n.r,n.s])},t}();ht.INTERFACE=new i.Interface(s.abi);var mt=function(){function t(){}return t.encodeFeeBips=function(t){return Z(t.multiply(1e4).quotient)},t.encodeUnwrapWETH9=function(n,r,i){if(r=e.validateAndParseAddress(r),i){var o=this.encodeFeeBips(i.fee),a=e.validateAndParseAddress(i.recipient);return t.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[Z(n),r,o,a])}return t.INTERFACE.encodeFunctionData("unwrapWETH9",[Z(n),r])},t.encodeSweepToken=function(n,r,i,o){if(i=e.validateAndParseAddress(i),o){var a=this.encodeFeeBips(o.fee),u=e.validateAndParseAddress(o.recipient);return t.INTERFACE.encodeFunctionData("sweepTokenWithFee",[n.address,Z(r),i,a,u])}return t.INTERFACE.encodeFunctionData("sweepToken",[n.address,Z(r),i])},t.encodeRefundETH=function(){return t.INTERFACE.encodeFunctionData("refundETH")},t}();mt.INTERFACE=new i.Interface(p.abi);var vt=Z(n.subtract(n.exponentiate(n.BigInt(2),n.BigInt(128)),n.BigInt(1)));function kt(t){return Object.keys(t).some((function(t){return"recipient"===t}))}var yt=function(){function t(){}return t.encodeCreate=function(e){return t.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[e.token0.address,e.token1.address,e.fee,Z(e.sqrtRatioX96)])},t.createCallParameters=function(t){return{calldata:this.encodeCreate(t),value:Z(0)}},t.addCallParameters=function(i,o){n.greaterThan(i.liquidity,E)||r(!1);var a=[],u=i.mintAmounts,c=u.amount0,s=u.amount1,p=i.mintAmountsWithSlippage(o.slippageTolerance),d=Z(p.amount0),l=Z(p.amount1),f=Z(o.deadline);if(kt(o)&&o.createPool&&a.push(this.encodeCreate(i.pool)),o.token0Permit&&a.push(ht.encodePermit(i.pool.token0,o.token0Permit)),o.token1Permit&&a.push(ht.encodePermit(i.pool.token1,o.token1Permit)),kt(o)){var h=e.validateAndParseAddress(o.recipient);a.push(t.INTERFACE.encodeFunctionData("mint",[{token0:i.pool.token0.address,token1:i.pool.token1.address,fee:i.pool.fee,tickLower:i.tickLower,tickUpper:i.tickUpper,amount0Desired:Z(c),amount1Desired:Z(s),amount0Min:d,amount1Min:l,recipient:h,deadline:f}]))}else a.push(t.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:Z(o.tokenId),amount0Desired:Z(c),amount1Desired:Z(s),amount0Min:d,amount1Min:l,deadline:f}]));var m=Z(0);if(o.useNative){var v=o.useNative.wrapped;i.pool.token0.equals(v)||i.pool.token1.equals(v)||r(!1);var k=i.pool.token0.equals(v)?c:s;n.greaterThan(k,E)&&a.push(mt.encodeRefundETH()),m=Z(k)}return{calldata:ft.encodeMulticall(a),value:m}},t.encodeCollect=function(n){var r=[],i=Z(n.tokenId),o=n.expectedCurrencyOwed0.currency.isNative||n.expectedCurrencyOwed1.currency.isNative,a=e.validateAndParseAddress(n.recipient);if(r.push(t.INTERFACE.encodeFunctionData("collect",[{tokenId:i,recipient:o?q:a,amount0Max:vt,amount1Max:vt}])),o){var u=n.expectedCurrencyOwed0.currency.isNative?n.expectedCurrencyOwed1.currency:n.expectedCurrencyOwed0.currency,c=n.expectedCurrencyOwed0.currency.isNative?n.expectedCurrencyOwed1.quotient:n.expectedCurrencyOwed0.quotient;r.push(mt.encodeUnwrapWETH9(n.expectedCurrencyOwed0.currency.isNative?n.expectedCurrencyOwed0.quotient:n.expectedCurrencyOwed1.quotient,a)),r.push(mt.encodeSweepToken(u,c,a))}return r},t.collectCallParameters=function(e){var n=t.encodeCollect(e);return{calldata:ft.encodeMulticall(n),value:Z(0)}},t.removeCallParameters=function(i,o){var a=[],u=Z(o.deadline),c=Z(o.tokenId),s=new st({pool:i.pool,liquidity:o.liquidityPercentage.multiply(i.liquidity).quotient,tickLower:i.tickLower,tickUpper:i.tickUpper});n.greaterThan(s.liquidity,E)||r(!1);var p=s.burnAmountsWithSlippage(o.slippageTolerance),d=p.amount0,l=p.amount1;o.permit&&a.push(t.INTERFACE.encodeFunctionData("permit",[e.validateAndParseAddress(o.permit.spender),c,Z(o.permit.deadline),o.permit.v,o.permit.r,o.permit.s])),a.push(t.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:c,liquidity:Z(s.liquidity),amount0Min:Z(d),amount1Min:Z(l),deadline:u}]));var f=o.collectOptions,h=f.expectedCurrencyOwed0,m=f.expectedCurrencyOwed1,v=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(i[n]=t[n]);return i}(f,["expectedCurrencyOwed0","expectedCurrencyOwed1"]);return a.push.apply(a,t.encodeCollect(y({tokenId:Z(o.tokenId),expectedCurrencyOwed0:h.add(e.CurrencyAmount.fromRawAmount(h.currency,d)),expectedCurrencyOwed1:m.add(e.CurrencyAmount.fromRawAmount(m.currency,l))},v))),o.liquidityPercentage.equalTo(C)?o.burnToken&&a.push(t.INTERFACE.encodeFunctionData("burn",[c])):!0===o.burnToken&&r(!1),{calldata:ft.encodeMulticall(a),value:Z(0)}},t.safeTransferFromParameters=function(n){var r=e.validateAndParseAddress(n.recipient),i=e.validateAndParseAddress(n.sender);return{calldata:n.data?t.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)",[i,r,Z(n.tokenId),n.data]):t.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256)",[i,r,Z(n.tokenId)]),value:Z(0)}},t}();yt.INTERFACE=new i.Interface(c.abi);var At=function(){function t(){}return t.quoteCallParameters=function(n,i,o,a){void 0===a&&(a={});var u,c=1===n.pools.length,s=Z(i.quotient);if(c){var p,d,l,f;u=o===e.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("quoteExactInputSingle",[n.tokenPath[0].address,n.tokenPath[1].address,n.pools[0].fee,s,Z(null!=(p=null==(d=a)?void 0:d.sqrtPriceLimitX96)?p:0)]):t.INTERFACE.encodeFunctionData("quoteExactOutputSingle",[n.tokenPath[0].address,n.tokenPath[1].address,n.pools[0].fee,s,Z(null!=(l=null==(f=a)?void 0:f.sqrtPriceLimitX96)?l:0)])}else{var h;void 0!==(null==(h=a)?void 0:h.sqrtPriceLimitX96)&&r(!1);var m=$(n,o===e.TradeType.EXACT_OUTPUT);u=t.INTERFACE.encodeFunctionData(o===e.TradeType.EXACT_INPUT?"quoteExactInput":"quoteExactOutput",[m,s])}return{calldata:u,value:Z(0)}},t}();At.INTERFACE=new i.Interface(d.abi);var gt=function(){function t(){}return t.encodeClaim=function(n,r){var i,o=[];o.push(t.INTERFACE.encodeFunctionData("unstakeToken",[this._encodeIncentiveKey(n),Z(r.tokenId)]));var a=e.validateAndParseAddress(r.recipient),u=null!=(i=r.amount)?i:0;return o.push(t.INTERFACE.encodeFunctionData("claimReward",[n.rewardToken.address,a,Z(u)])),o},t.collectRewards=function(e,n){e=Array.isArray(e)?e:[e];for(var r=[],i=0;i<e.length;i++){var o=e[i];(r=r.concat(this.encodeClaim(o,n))).push(t.INTERFACE.encodeFunctionData("stakeToken",[this._encodeIncentiveKey(o),Z(n.tokenId)]))}return{calldata:ft.encodeMulticall(r),value:Z(0)}},t.withdrawToken=function(n,r){var i=[];n=Array.isArray(n)?n:[n];for(var o={tokenId:r.tokenId,recipient:r.recipient,amount:r.amount},a=0;a<n.length;a++)i=i.concat(this.encodeClaim(n[a],o));var u=e.validateAndParseAddress(r.owner);return i.push(t.INTERFACE.encodeFunctionData("withdrawToken",[Z(r.tokenId),u,r.data?r.data:Z(0)])),{calldata:ft.encodeMulticall(i),value:Z(0)}},t.encodeDeposit=function(e){var n;if((e=Array.isArray(e)?e:[e]).length>1){for(var r=[],o=0;o<e.length;o++)r.push(this._encodeIncentiveKey(e[o]));n=i.defaultAbiCoder.encode([t.INCENTIVE_KEY_ABI+"[]"],[r])}else n=i.defaultAbiCoder.encode([t.INCENTIVE_KEY_ABI],[this._encodeIncentiveKey(e[0])]);return n},t._encodeIncentiveKey=function(t){var n=t.pool,r=n.token0,i=n.token1,o=n.fee,a=e.validateAndParseAddress(t.refundee);return{rewardToken:t.rewardToken.address,pool:ct.getAddress(r,i,o),startTime:Z(t.startTime),endTime:Z(t.endTime),refundee:a}},t}();gt.INTERFACE=new i.Interface(l.abi),gt.INCENTIVE_KEY_ABI="tuple(address rewardToken, address pool, uint256 startTime, uint256 endTime, address refundee)";var Tt=function(){function t(){}return t.swapCallParameters=function(n,i){Array.isArray(n)||(n=[n]);var o=n[0],a=o.inputAmount.currency.wrapped,u=o.outputAmount.currency.wrapped;n.every((function(t){return t.inputAmount.currency.wrapped.equals(a)}))||r(!1),n.every((function(t){return t.outputAmount.currency.wrapped.equals(u)}))||r(!1);var c=[],s=e.CurrencyAmount.fromRawAmount(n[0].inputAmount.currency,0),p=e.CurrencyAmount.fromRawAmount(n[0].outputAmount.currency,0),d=n.reduce((function(t,e){return t.add(e.minimumAmountOut(i.slippageTolerance))}),p),l=o.inputAmount.currency.isNative&&o.tradeType===e.TradeType.EXACT_OUTPUT,f=o.outputAmount.currency.isNative,h=f||!!i.fee,m=o.inputAmount.currency.isNative?n.reduce((function(t,e){return t.add(e.maximumAmountIn(i.slippageTolerance))}),s):s;i.inputTokenPermit&&(o.inputAmount.currency.isToken||r(!1),c.push(ht.encodePermit(o.inputAmount.currency,i.inputTokenPermit)));for(var v,k=e.validateAndParseAddress(i.recipient),y=Z(i.deadline),A=g(n);!(v=A()).done;)for(var T,x=v.value,I=g(x.swaps);!(T=I()).done;){var w=T.value,b=w.route,R=w.outputAmount,P=Z(x.maximumAmountIn(i.slippageTolerance,w.inputAmount).quotient),E=Z(x.minimumAmountOut(i.slippageTolerance,R).quotient);if(1===b.pools.length)if(x.tradeType===e.TradeType.EXACT_INPUT){var C,S={tokenIn:b.tokenPath[0].address,tokenOut:b.tokenPath[1].address,fee:b.pools[0].fee,recipient:h?q:k,deadline:y,amountIn:P,amountOutMinimum:E,sqrtPriceLimitX96:Z(null!=(C=i.sqrtPriceLimitX96)?C:0)};c.push(t.INTERFACE.encodeFunctionData("exactInputSingle",[S]))}else{var O,N={tokenIn:b.tokenPath[0].address,tokenOut:b.tokenPath[1].address,fee:b.pools[0].fee,recipient:h?q:k,deadline:y,amountOut:E,amountInMaximum:P,sqrtPriceLimitX96:Z(null!=(O=i.sqrtPriceLimitX96)?O:0)};c.push(t.INTERFACE.encodeFunctionData("exactOutputSingle",[N]))}else{void 0!==i.sqrtPriceLimitX96&&r(!1);var _=$(b,x.tradeType===e.TradeType.EXACT_OUTPUT);c.push(x.tradeType===e.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("exactInput",[{path:_,recipient:h?q:k,deadline:y,amountIn:P,amountOutMinimum:E}]):t.INTERFACE.encodeFunctionData("exactOutput",[{path:_,recipient:h?q:k,deadline:y,amountOut:E,amountInMaximum:P}]))}}return h&&c.push(i.fee?f?mt.encodeUnwrapWETH9(d.quotient,k,i.fee):mt.encodeSweepToken(o.outputAmount.currency.wrapped,d.quotient,k,i.fee):mt.encodeUnwrapWETH9(d.quotient,k)),l&&c.push(mt.encodeRefundETH()),{calldata:ft.encodeMulticall(c),value:Z(m.quotient)}},t}();Tt.INTERFACE=new i.Interface(f.abi),exports.ADDRESS_ZERO=q,exports.FACTORY_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.FullMath=F,exports.LiquidityMath=_,exports.Multicall=ft,exports.NoTickDataProvider=Q,exports.NonfungiblePositionManager=yt,exports.POOL_INIT_CODE_HASH=b,exports.POOL_INIT_CODE_HASH_OPTIMISM="0x0c231002d0970d2126e7e00ce88c3b0e5ec8e48dac71478d56245c34ea2f9447",exports.POOL_INIT_CODE_HASH_OPTIMISM_KOVAN="0x1fc830513acbdb1608b8c18fd3cf4a4bee3329c69bb41d56400401c40fe02fd0",exports.Payments=mt,exports.Pool=ct,exports.Position=st,exports.Route=pt,exports.SelfPermit=ht,exports.SqrtPriceMath=M,exports.Staker=gt,exports.SwapQuoter=At,exports.SwapRouter=Tt,exports.TICK_SPACINGS=R,exports.Tick=ot,exports.TickList=Y,exports.TickListDataProvider=at,exports.TickMath=G,exports.Trade=lt,exports.computePoolAddress=N,exports.encodeRouteToPath=$,exports.encodeSqrtRatioX96=J,exports.isSorted=z,exports.maxLiquidityForAmounts=rt,exports.mostSignificantBit=H,exports.nearestUsableTick=function(t,e){Number.isInteger(t)&&Number.isInteger(e)||r(!1),e>0||r(!1),t>=G.MIN_TICK&&t<=G.MAX_TICK||r(!1);var n=Math.round(t/e)*e;return n<G.MIN_TICK?n+e:n>G.MAX_TICK?n-e:n},exports.priceToClosestTick=function(t){var e=t.baseCurrency.sortsBefore(t.quoteCurrency),n=e?J(t.numerator,t.denominator):J(t.denominator,t.numerator),r=G.getTickAtSqrtRatio(n),i=it(t.baseCurrency,t.quoteCurrency,r+1);return e?t.lessThan(i)||r++:t.greaterThan(i)||r++,r},exports.tickToPrice=it,exports.toHex=Z,exports.tradeComparator=dt; | ||
//# sourceMappingURL=v3-sdk.cjs.production.min.js.map |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "3.6.1", | ||
"version": "3.6.2", | ||
"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 too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1143436
8200