@juiceswapxyz/v4-sdk 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ "use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e,n,r=t(require("tiny-invariant")),i=require("@ethersproject/solidity"),o=require("@juiceswapxyz/sdk-core"),a=require("@juiceswapxyz/v3-sdk"),u=require("ethers/lib/utils"),s=t(require("jsbi")),p=require("ethers"),c=require("@ethersproject/abi"),y=t(require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IMulticall.sol/IMulticall.json"));function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function l(t,e,n,r,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void n(t)}u.done?e(s):Promise.resolve(s).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){l(o,r,i,a,u,"next",t)}function u(t){l(o,r,i,a,u,"throw",t)}a(void 0)}))}}function h(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,I(r.key),r)}}function f(t,e,n){return e&&h(t.prototype,e),n&&h(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function T(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return d(t,e);var n={}.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)?d(t,e):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.")}function A(){return(A=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(null,arguments)}function k(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var s=Object.create((r&&r.prototype instanceof u?r:u).prototype);return v(s,"_invoke",function(n,r,i){var o,u,s,p=0,c=i||[],y=!1,d={p:0,n:0,v:t,a:l,f:l.bind(t,4),d:function(e,n){return o=e,u=0,s=t,d.n=n,a}};function l(n,r){for(u=n,s=r,e=0;!y&&p&&!i&&e<c.length;e++){var i,o=c[e],l=d.p,m=o[2];n>3?(i=m===r)&&(s=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=t):o[0]<=l&&((i=n<2&&l<o[1])?(u=0,d.v=r,d.n=o[1]):l<m&&(i=n<3||o[0]>r||r>m)&&(o[4]=n,o[5]=r,d.n=m,u=0))}if(i||n>1)return a;throw y=!0,r}return function(i,c,m){if(p>1)throw TypeError("Generator is already running");for(y&&1===c&&l(c,m),u=c,s=m;(e=u<2?t:s)||!y;){o||(u?u<3?(u>1&&(d.n=-1),l(u,s)):d.n=s:d.v=s);try{if(p=2,o){if(u||(i="next"),e=o[i]){if(!(e=e.call(o,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,u<2&&(u=0)}else 1===u&&(e=o.return)&&e.call(o),u<2&&(s=TypeError("The iterator does not provide a '"+i+"' method"),u=1);o=t}else if((e=(y=d.n<0)?s:n.call(r,d))!==a)break}catch(e){o=t,u=1,s=e}finally{p=1}}return{value:e,done:y}}}(n,i,o),!0),s}var a={};function u(){}function s(){}function p(){}e=Object.getPrototypeOf;var c=[][r]?e(e([][r]())):(v(e={},r,(function(){return this})),e),y=p.prototype=u.prototype=Object.create(c);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,v(t,i,"GeneratorFunction")),t.prototype=Object.create(y),t}return s.prototype=p,v(y,"constructor",p),v(p,"constructor",s),s.displayName="GeneratorFunction",v(p,i,"GeneratorFunction"),v(y),v(y,i,"Generator"),v(y,r,(function(){return this})),v(y,"toString",(function(){return"[object Generator]"})),(k=function(){return{w:o,m:d}})()}function v(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}(v=function(t,e,n,r){function o(e,n){v(t,e,(function(t){return this._invoke(e,n,t)}))}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))})(t,e,n,r)}function b(t,e){return(b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function I(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}function S(t,e){return!!t.isNative||!e.isNative&&t.wrapped.sortsBefore(e.wrapped)}(n=exports.HookOptions||(exports.HookOptions={})).AfterRemoveLiquidityReturnsDelta="afterRemoveLiquidityReturnsDelta",n.AfterAddLiquidityReturnsDelta="afterAddLiquidityReturnsDelta",n.AfterSwapReturnsDelta="afterSwapReturnsDelta",n.BeforeSwapReturnsDelta="beforeSwapReturnsDelta",n.AfterDonate="afterDonate",n.BeforeDonate="beforeDonate",n.AfterSwap="afterSwap",n.BeforeSwap="beforeSwap",n.AfterRemoveLiquidity="afterRemoveLiquidity",n.BeforeRemoveLiquidity="beforeRemoveLiquidity",n.AfterAddLiquidity="afterAddLiquidity",n.BeforeAddLiquidity="beforeAddLiquidity",n.AfterInitialize="afterInitialize",n.BeforeInitialize="beforeInitialize";var w,g,P,x=((e={})[exports.HookOptions.AfterRemoveLiquidityReturnsDelta]=0,e[exports.HookOptions.AfterAddLiquidityReturnsDelta]=1,e[exports.HookOptions.AfterSwapReturnsDelta]=2,e[exports.HookOptions.BeforeSwapReturnsDelta]=3,e[exports.HookOptions.AfterDonate]=4,e[exports.HookOptions.BeforeDonate]=5,e[exports.HookOptions.AfterSwap]=6,e[exports.HookOptions.BeforeSwap]=7,e[exports.HookOptions.AfterRemoveLiquidity]=8,e[exports.HookOptions.BeforeRemoveLiquidity]=9,e[exports.HookOptions.AfterAddLiquidity]=10,e[exports.HookOptions.BeforeAddLiquidity]=11,e[exports.HookOptions.AfterInitialize]=12,e[exports.HookOptions.BeforeInitialize]=13,e),q=function(){function t(){}return t.permissions=function(t){return this._checkAddress(t),{beforeInitialize:this._hasPermission(t,exports.HookOptions.BeforeInitialize),afterInitialize:this._hasPermission(t,exports.HookOptions.AfterInitialize),beforeAddLiquidity:this._hasPermission(t,exports.HookOptions.BeforeAddLiquidity),afterAddLiquidity:this._hasPermission(t,exports.HookOptions.AfterAddLiquidity),beforeRemoveLiquidity:this._hasPermission(t,exports.HookOptions.BeforeRemoveLiquidity),afterRemoveLiquidity:this._hasPermission(t,exports.HookOptions.AfterRemoveLiquidity),beforeSwap:this._hasPermission(t,exports.HookOptions.BeforeSwap),afterSwap:this._hasPermission(t,exports.HookOptions.AfterSwap),beforeDonate:this._hasPermission(t,exports.HookOptions.BeforeDonate),afterDonate:this._hasPermission(t,exports.HookOptions.AfterDonate),beforeSwapReturnsDelta:this._hasPermission(t,exports.HookOptions.BeforeSwapReturnsDelta),afterSwapReturnsDelta:this._hasPermission(t,exports.HookOptions.AfterSwapReturnsDelta),afterAddLiquidityReturnsDelta:this._hasPermission(t,exports.HookOptions.AfterAddLiquidityReturnsDelta),afterRemoveLiquidityReturnsDelta:this._hasPermission(t,exports.HookOptions.AfterRemoveLiquidityReturnsDelta)}},t.hasPermission=function(t,e){return this._checkAddress(t),this._hasPermission(t,e)},t.hasInitializePermissions=function(e){return this._checkAddress(e),this._hasPermission(e,exports.HookOptions.BeforeInitialize)||t._hasPermission(e,exports.HookOptions.AfterInitialize)},t.hasLiquidityPermissions=function(e){return this._checkAddress(e),this._hasPermission(e,exports.HookOptions.BeforeAddLiquidity)||t._hasPermission(e,exports.HookOptions.AfterAddLiquidity)||t._hasPermission(e,exports.HookOptions.BeforeRemoveLiquidity)||t._hasPermission(e,exports.HookOptions.AfterRemoveLiquidity)},t.hasSwapPermissions=function(e){return this._checkAddress(e),this._hasPermission(e,exports.HookOptions.BeforeSwap)||t._hasPermission(e,exports.HookOptions.AfterSwap)},t.hasDonatePermissions=function(e){return this._checkAddress(e),this._hasPermission(e,exports.HookOptions.BeforeDonate)||t._hasPermission(e,exports.HookOptions.AfterDonate)},t._hasPermission=function(t,e){return!!(parseInt(t,16)&1<<x[e])},t._checkAddress=function(t){u.isAddress(t)||r(!1)},t}(),_=p.constants.AddressZero,E=s.BigInt(-1),R=s.BigInt(0),O=s.BigInt(1),M=s.exponentiate(s.exponentiate(s.BigInt(2),s.BigInt(96)),s.BigInt(2)),L=p.constants.Zero;!function(t){t.INITIALIZE_POOL="initializePool",t.MODIFY_LIQUIDITIES="modifyLiquidities",t.PERMIT_BATCH="0x002a3e3a",t.ERC721PERMIT_PERMIT="0x0f5730f1"}(g||(g={})),function(t){t[t.LOWEST=100]="LOWEST",t[t.LOW=500]="LOW",t[t.MEDIUM=3e3]="MEDIUM",t[t.HIGH=1e4]="HIGH"}(P||(P={})),(w={})[P.LOWEST]=1,w[P.LOW]=10,w[P.MEDIUM]=60,w[P.HIGH]=200;var C=new a.NoTickDataProvider,D=function(){function t(e,n,i,o,p,c,y,d,l){void 0===l&&(l=C),u.isAddress(p)||r(!1),Number.isInteger(i)&&(8388608===i||i<1e6)||r(!1),8388608===i&&(Number(p)>0||r(!1));var m=a.TickMath.getSqrtRatioAtTick(d),h=a.TickMath.getSqrtRatioAtTick(d+1);s.greaterThanOrEqual(s.BigInt(c),m)&&s.lessThanOrEqual(s.BigInt(c),h)||r(!1);var f=S(e,n)?[e,n]:[n,e];this.currency0=f[0],this.currency1=f[1],this.fee=i,this.sqrtRatioX96=s.BigInt(c),this.tickSpacing=o,this.hooks=p,this.liquidity=s.BigInt(y),this.tickCurrent=d,this.tickDataProvider=Array.isArray(l)?new a.TickListDataProvider(l,o):l,this.poolKey=t.getPoolKey(this.currency0,this.currency1,this.fee,this.tickSpacing,this.hooks),this.poolId=t.getPoolId(this.currency0,this.currency1,this.fee,this.tickSpacing,this.hooks)}t.getPoolKey=function(t,e,n,i,o){u.isAddress(o)||r(!1);var a=S(t,e)?[t,e]:[e,t],s=a[0],p=a[1];return{currency0:s.isNative?_:s.wrapped.address,currency1:p.isNative?_:p.wrapped.address,fee:n,tickSpacing:i,hooks:o}},t.getPoolId=function(t,e,n,r,o){var a=S(t,e)?[t,e]:[e,t],s=a[0],p=a[1];return i.keccak256(["bytes"],[u.defaultAbiCoder.encode(["address","address","uint24","int24","address"],[s.isNative?_:s.wrapped.address,p.isNative?_:p.wrapped.address,n,r,o])])};var e=t.prototype;return e.involvesCurrency=function(t){return t.equals(this.currency0)||t.equals(this.currency1)},e.involvesToken=function(t){return this.involvesCurrency(t)},e.v4InvolvesToken=function(t){return this.involvesCurrency(t)||t.wrapped.equals(this.currency0)||t.wrapped.equals(this.currency1)||t.wrapped.equals(this.currency0.wrapped)||t.wrapped.equals(this.currency1.wrapped)},e.priceOf=function(t){return this.involvesCurrency(t)||r(!1),t.equals(this.currency0)?this.currency0Price:this.currency1Price},e.getOutputAmount=function(){var e=m(k().m((function e(n,i){var a,u,p,c,y;return k().w((function(e){for(;;)switch(e.n){case 0:return this.involvesCurrency(n.currency)||r(!1),a=n.currency.equals(this.currency0),e.n=1,this.swap(a,n.quotient,i);case 1:return p=(u=e.v).sqrtRatioX96,c=u.liquidity,y=u.tickCurrent,e.a(2,[o.CurrencyAmount.fromRawAmount(a?this.currency1:this.currency0,s.multiply(u.amountCalculated,E)),new t(this.currency0,this.currency1,this.fee,this.tickSpacing,this.hooks,p,c,y,this.tickDataProvider)])}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),e.getInputAmount=function(){var e=m(k().m((function e(n,i){var a,u,p,c,y;return k().w((function(e){for(;;)switch(e.n){case 0:return this.involvesCurrency(n.currency)||r(!1),a=n.currency.equals(this.currency1),e.n=1,this.swap(a,s.multiply(n.quotient,E),i);case 1:return p=(u=e.v).sqrtRatioX96,c=u.liquidity,y=u.tickCurrent,e.a(2,[o.CurrencyAmount.fromRawAmount(a?this.currency0:this.currency1,u.amountCalculated),new t(this.currency0,this.currency1,this.fee,this.tickSpacing,this.hooks,p,c,y,this.tickDataProvider)])}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),e.swap=function(){var t=m(k().m((function t(e,n,r){return k().w((function(t){for(;;)switch(t.n){case 0:if(this.hookImpactsSwap()){t.n=1;break}return t.a(2,a.v3Swap(s.BigInt(this.fee),this.sqrtRatioX96,this.tickCurrent,this.liquidity,this.tickSpacing,this.tickDataProvider,e,n,r));case 1:throw new Error("Unsupported hook");case 2:return t.a(2)}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),e.hookImpactsSwap=function(){return q.hasSwapPermissions(this.hooks)},f(t,[{key:"token0",get:function(){return this.currency0}},{key:"token1",get:function(){return this.currency1}},{key:"currency0Price",get:function(){var t;return null!=(t=this._currency0Price)?t:this._currency0Price=new o.Price(this.currency0,this.currency1,M,s.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}},{key:"token0Price",get:function(){return this.currency0Price}},{key:"currency1Price",get:function(){var t;return null!=(t=this._currency1Price)?t:this._currency1Price=new o.Price(this.currency1,this.currency0,s.multiply(this.sqrtRatioX96,this.sqrtRatioX96),M)}},{key:"token1Price",get:function(){return this.currency1Price}},{key:"chainId",get:function(){return this.currency0.chainId}}])}();function N(t,e){return o.CurrencyAmount.fromFractionalAmount(U(t.currency,e),t.numerator,t.denominator)}function U(t,e){if(e.involvesCurrency(t))return t;if(e.involvesCurrency(t.wrapped))return t.wrapped;if(e.currency0.wrapped.equals(t))return e.currency0;if(e.currency1.wrapped.equals(t))return e.currency1;throw new Error("Expected currency "+t.symbol+" to be either "+e.currency0.symbol+" or "+e.currency1.symbol)}var B=function(){return f((function(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),this.pathInput=U(e,t[0]),this.pathOutput=U(n,t[t.length-1]);for(var o,a=[this.pathInput],u=T(t.entries());!(o=u()).done;){var s=o.value,p=s[1],c=a[s[0]];c.equals(p.currency0)||c.equals(p.currency1)||r(!1);var y=c.equals(p.currency0)?p.currency1:p.currency0;a.push(y)}this.pools=t,this.currencyPath=a,this.input=e,this.output=null!=n?n:a[a.length-1]}),[{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.currency0)?{nextInput:e.currency1,price:n.multiply(e.currency0Price)}:{nextInput:e.currency0,price:n.multiply(e.currency1Price)}}),this.pools[0].currency0.equals(this.input)?{nextInput:this.pools[0].currency1,price:this.pools[0].currency0Price}:{nextInput:this.pools[0].currency0,price:this.pools[0].currency1Price}).price;return this._midPrice=new o.Price(this.input,this.output,t.denominator,t.numerator)}}])}();function H(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.currencyPath.length}),0)-e.swaps.reduce((function(t,e){return t+e.route.currencyPath.length}),0):t.inputAmount.lessThan(e.inputAmount)?-1:1:t.outputAmount.lessThan(e.outputAmount)?1:-1}var X=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.equals(t.route.input)}))||r(!1),e.every((function(t){return o.equals(t.route.output)}))||r(!1);for(var a,u=e.map((function(t){return t.route.pools.length})).reduce((function(t,e){return t+e}),0),s=new Set,p=T(e);!(a=p()).done;)for(var c,y=T(a.value.route.pools);!(c=y()).done;){var d=c.value;s.add(D.getPoolId(d.currency0,d.currency1,d.fee,d.tickSpacing,d.hooks))}u!==s.size&&r(!1),this.swaps=e,this.tradeType=n}t.exactIn=function(){var e=m(k().m((function e(n,r){return k().w((function(e){for(;;)switch(e.n){case 0:return e.a(2,t.fromRoute(n,r,o.TradeType.EXACT_INPUT))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.exactOut=function(){var e=m(k().m((function e(n,r){return k().w((function(e){for(;;)switch(e.n){case 0:return e.a(2,t.fromRoute(n,r,o.TradeType.EXACT_OUTPUT))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.fromRoute=function(){var e=m(k().m((function e(n,i,a){var u,s,p,c,y,d,l,m;return k().w((function(e){for(;;)switch(e.n){case 0:if(a!==o.TradeType.EXACT_INPUT){e.n=5;break}i.currency.equals(n.input)||r(!1),p=N(i,n.pools[0]),c=0;case 1:if(!(c<n.pools.length)){e.n=4;break}return y=n.pools[c],e.n=2,y.getOutputAmount(p);case 2:p=e.v[0];case 3:c++,e.n=1;break;case 4:u=o.CurrencyAmount.fromFractionalAmount(n.input,i.numerator,i.denominator),s=o.CurrencyAmount.fromFractionalAmount(n.output,p.numerator,p.denominator),e.n=10;break;case 5:i.currency.equals(n.output)||r(!1),d=N(i,n.pools[n.pools.length-1]),l=n.pools.length-1;case 6:if(!(l>=0)){e.n=9;break}return m=n.pools[l],e.n=7,m.getInputAmount(d);case 7:d=e.v[0];case 8:l--,e.n=6;break;case 9:u=o.CurrencyAmount.fromFractionalAmount(n.input,d.numerator,d.denominator),s=o.CurrencyAmount.fromFractionalAmount(n.output,i.numerator,i.denominator);case 10:return e.a(2,new t({routes:[{inputAmount:u,outputAmount:s,route:n}],tradeType:a}))}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.fromRoutes=function(){var e=m(k().m((function e(n,r){return k().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,Promise.all(n.map(function(){var e=m(k().m((function e(n){var i,o;return k().w((function(e){for(;;)switch(e.n){case 0:return i=n.amount,o=n.route,e.n=1,t.fromRoute(o,i,r);case 1:return e.a(2,e.v.swaps[0])}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 1:return e.a(2,new t({routes:e.v,tradeType:r}))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.createUncheckedTrade=function(e){return new t(A({},e,{routes:[{inputAmount:e.inputAmount,outputAmount:e.outputAmount,route:e.route}]}))},t.createUncheckedTradeWithMultipleRoutes=function(e){return new t(e)};var e=t.prototype;return e.minimumAmountOut=function(t,e){if(void 0===e&&(e=this.outputAmount),t.lessThan(R)&&r(!1),this.tradeType===o.TradeType.EXACT_OUTPUT)return e;var n=new o.Fraction(O).add(t).invert().multiply(e.quotient).quotient;return o.CurrencyAmount.fromRawAmount(e.currency,n)},e.maximumAmountIn=function(t,e){if(void 0===e&&(e=this.inputAmount),t.lessThan(R)&&r(!1),this.tradeType===o.TradeType.EXACT_INPUT)return e;var n=new o.Fraction(O).add(t).multiply(e.quotient).quotient;return o.CurrencyAmount.fromRawAmount(e.currency,n)},e.worstExecutionPrice=function(t){return new o.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactIn=function(){var e=m(k().m((function e(n,i,a,u,s,p,c){var y,d,l,m,h,f,T,A,v,b,I,S,w;return k().w((function(e){for(;;)switch(e.p=e.n){case 0:l=void 0===(d=(y=void 0===u?{}:u).maxNumResults)?3:d,h=void 0===(m=y.maxHops)?3:m,void 0===s&&(s=[]),void 0===p&&(p=i),void 0===c&&(c=[]),n.length>0||r(!1),h>0||r(!1),i===p||s.length>0||r(!1),f=p,T=0;case 1:if(!(T<n.length)){e.n=11;break}if((A=n[T]).currency0.equals(f.currency)||A.currency1.equals(f.currency)){e.n=2;break}return e.a(3,10);case 2:return v=void 0,e.p=3,e.n=4,A.getOutputAmount(f);case 4:v=e.v[0],e.n=7;break;case 5:if(e.p=5,!(I=e.v).isInsufficientInputAmountError){e.n=6;break}return e.a(3,10);case 6:throw I;case 7:if(!v.currency.equals(a)){e.n=9;break}return S=o.sortedInsert,w=c,e.n=8,t.fromRoute(new B([].concat(s,[A]),i.currency,a),i,o.TradeType.EXACT_INPUT);case 8:S(w,e.v,l,H),e.n=10;break;case 9:if(!(h>1&&n.length>1)){e.n=10;break}return b=n.slice(0,T).concat(n.slice(T+1,n.length)),e.n=10,t.bestTradeExactIn(b,i,a,{maxNumResults:l,maxHops:h-1},[].concat(s,[A]),v,c);case 10:T++,e.n=1;break;case 11:return e.a(2,c)}}),e,null,[[3,5]])})));return function(t,n,r,i,o,a,u){return e.apply(this,arguments)}}(),t.bestTradeExactOut=function(){var e=m(k().m((function e(n,i,a,u,s,p,c){var y,d,l,m,h,f,T,A,v,b,I,S,w;return k().w((function(e){for(;;)switch(e.p=e.n){case 0:l=void 0===(d=(y=void 0===u?{}:u).maxNumResults)?3:d,h=void 0===(m=y.maxHops)?3:m,void 0===s&&(s=[]),void 0===p&&(p=a),void 0===c&&(c=[]),n.length>0||r(!1),h>0||r(!1),a===p||s.length>0||r(!1),f=p,T=0;case 1:if(!(T<n.length)){e.n=11;break}if((A=n[T]).currency0.equals(f.currency)||A.currency1.equals(f.currency)){e.n=2;break}return e.a(3,10);case 2:return v=void 0,e.p=3,e.n=4,A.getInputAmount(f);case 4:v=e.v[0],e.n=7;break;case 5:if(e.p=5,!(I=e.v).isInsufficientReservesError){e.n=6;break}return e.a(3,10);case 6:throw I;case 7:if(!v.currency.equals(i)){e.n=9;break}return S=o.sortedInsert,w=c,e.n=8,t.fromRoute(new B([A].concat(s),i,a.currency),a,o.TradeType.EXACT_OUTPUT);case 8:S(w,e.v,l,H),e.n=10;break;case 9:if(!(h>1&&n.length>1)){e.n=10;break}return b=n.slice(0,T).concat(n.slice(T+1,n.length)),e.n=10,t.bestTradeExactOut(b,i,a,{maxNumResults:l,maxHops:h-1},[A].concat(s),v,c);case 10:T++,e.n=1;break;case 11:return e.a(2,c)}}),e,null,[[3,5]])})));return function(t,n,r,i,o,a,u){return e.apply(this,arguments)}}(),f(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,e=this.swaps.map((function(t){return t.inputAmount})).reduce((function(t,e){return t.add(e)}),o.CurrencyAmount.fromRawAmount(t,0));return this._inputAmount=e,this._inputAmount}},{key:"outputAmount",get:function(){if(this._outputAmount)return this._outputAmount;var t=this.swaps[0].outputAmount.currency,e=this.swaps.map((function(t){return t.outputAmount})).reduce((function(t,e){return t.add(e)}),o.CurrencyAmount.fromRawAmount(t,0));return this._outputAmount=e,this._outputAmount}},{key:"executionPrice",get:function(){var t;return null!=(t=this._executionPrice)?t:this._executionPrice=new o.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,e=o.CurrencyAmount.fromRawAmount(this.outputAmount.currency,0),n=T(this.swaps);!(t=n()).done;){var r=t.value;e=e.add(r.route.midPrice.quote(r.inputAmount))}var i=e.subtract(this.outputAmount).divide(e);return this._priceImpact=new o.Percent(i.numerator,i.denominator),this._priceImpact}}])}();function F(t,e,n){var r=a.TickMath.getSqrtRatioAtTick(n),i=s.multiply(r,r);return S(t,e)?new o.Price(t,e,M,i):new o.Price(t,e,i,M)}var W,K,z,j=function(){function t(t){var e=t.pool,n=t.liquidity,i=t.tickLower,o=t.tickUpper;this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,i<o||r(!1),i>=a.TickMath.MIN_TICK&&i%e.tickSpacing==0||r(!1),o<=a.TickMath.MAX_TICK&&o%e.tickSpacing==0||r(!1),this.pool=e,this.tickLower=i,this.tickUpper=o,this.liquidity=s.BigInt(n)}var e=t.prototype;return e.ratiosAfterSlippage=function(t){var e=this.pool.token0Price.asFraction.multiply(new o.Percent(1).subtract(t)),n=this.pool.token0Price.asFraction.multiply(t.add(1)),r=a.encodeSqrtRatioX96(e.numerator,e.denominator);s.lessThanOrEqual(r,a.TickMath.MIN_SQRT_RATIO)&&(r=s.add(a.TickMath.MIN_SQRT_RATIO,s.BigInt(1)));var i=a.encodeSqrtRatioX96(n.numerator,n.denominator);return s.greaterThanOrEqual(i,a.TickMath.MAX_SQRT_RATIO)&&(i=s.subtract(a.TickMath.MAX_SQRT_RATIO,s.BigInt(1))),{sqrtRatioX96Lower:r,sqrtRatioX96Upper:i}},e.mintAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new D(this.pool.token0,this.pool.token1,this.pool.fee,this.pool.tickSpacing,this.pool.hooks,i,0,a.TickMath.getTickAtSqrtRatio(i)),u=new t({pool:new D(this.pool.token0,this.pool.token1,this.pool.fee,this.pool.tickSpacing,this.pool.hooks,r,0,a.TickMath.getTickAtSqrtRatio(r)),liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount1;return{amount0:new t({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount0,amount1:u}},e.burnAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new D(this.pool.currency0,this.pool.currency1,this.pool.fee,this.pool.tickSpacing,this.pool.hooks,i,0,a.TickMath.getTickAtSqrtRatio(i)),u=new t({pool:new D(this.pool.currency0,this.pool.currency1,this.pool.fee,this.pool.tickSpacing,this.pool.hooks,r,0,a.TickMath.getTickAtSqrtRatio(r)),liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,s=new t({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:u.quotient,amount1:s.quotient}},e.permitBatchData=function(t,e,n,r){var i=this.mintAmountsWithSlippage(t);return{details:[{token:this.pool.currency0.wrapped.address,amount:i.amount0,expiration:r,nonce:n},{token:this.pool.currency1.wrapped.address,amount:i.amount1,expiration:r,nonce:n}],spender:e,sigDeadline:r}},t.fromAmounts=function(e){var n=e.pool,r=e.tickLower,i=e.tickUpper,o=e.amount0,u=e.amount1,s=e.useFullPrecision,p=a.TickMath.getSqrtRatioAtTick(r),c=a.TickMath.getSqrtRatioAtTick(i);return new t({pool:n,tickLower:r,tickUpper:i,liquidity:a.maxLiquidityForAmounts(n.sqrtRatioX96,p,c,o,u,s)})},t.fromAmount0=function(e){return t.fromAmounts({pool:e.pool,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0:e.amount0,amount1:o.MaxUint256,useFullPrecision:e.useFullPrecision})},t.fromAmount1=function(e){return t.fromAmounts({pool:e.pool,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0:o.MaxUint256,amount1:e.amount1,useFullPrecision:!0})},f(t,[{key:"token0PriceLower",get:function(){return F(this.pool.currency0,this.pool.currency1,this.tickLower)}},{key:"token0PriceUpper",get:function(){return F(this.pool.currency0,this.pool.currency1,this.tickUpper)}},{key:"amount0",get:function(){return this._token0Amount||(this._token0Amount=o.CurrencyAmount.fromRawAmount(this.pool.currency0,this.pool.tickCurrent<this.tickLower?a.SqrtPriceMath.getAmount0Delta(a.TickMath.getSqrtRatioAtTick(this.tickLower),a.TickMath.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):this.pool.tickCurrent<this.tickUpper?a.SqrtPriceMath.getAmount0Delta(this.pool.sqrtRatioX96,a.TickMath.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):R)),this._token0Amount}},{key:"amount1",get:function(){return this._token1Amount||(this._token1Amount=o.CurrencyAmount.fromRawAmount(this.pool.currency1,this.pool.tickCurrent<this.tickLower?R:a.SqrtPriceMath.getAmount1Delta(a.TickMath.getSqrtRatioAtTick(this.tickLower),this.pool.tickCurrent<this.tickUpper?this.pool.sqrtRatioX96:a.TickMath.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}},{key:"mintAmounts",get:function(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:a.SqrtPriceMath.getAmount0Delta(a.TickMath.getSqrtRatioAtTick(this.tickLower),a.TickMath.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:R}:this.pool.tickCurrent<this.tickUpper?{amount0:a.SqrtPriceMath.getAmount0Delta(this.pool.sqrtRatioX96,a.TickMath.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:a.SqrtPriceMath.getAmount1Delta(a.TickMath.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:R,amount1:a.SqrtPriceMath.getAmount1Delta(a.TickMath.getSqrtRatioAtTick(this.tickLower),a.TickMath.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}}])}(),V=function(t,e){var n=t.pools.map((function(t){return t}));e&&(n=n.reverse());for(var r,i=e?t.pathOutput:t.pathInput,o=[],a=T(n);!(r=a()).done;){var u=r.value,s=i.equals(u.currency0)?u.currency1:u.currency0;o.push({intermediateCurrency:s.isNative?_:s.address,fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks,hookData:"0x"}),i=s}return e?o.reverse():o};(K=exports.Actions||(exports.Actions={}))[K.INCREASE_LIQUIDITY=0]="INCREASE_LIQUIDITY",K[K.DECREASE_LIQUIDITY=1]="DECREASE_LIQUIDITY",K[K.MINT_POSITION=2]="MINT_POSITION",K[K.BURN_POSITION=3]="BURN_POSITION",K[K.SWAP_EXACT_IN_SINGLE=6]="SWAP_EXACT_IN_SINGLE",K[K.SWAP_EXACT_IN=7]="SWAP_EXACT_IN",K[K.SWAP_EXACT_OUT_SINGLE=8]="SWAP_EXACT_OUT_SINGLE",K[K.SWAP_EXACT_OUT=9]="SWAP_EXACT_OUT",K[K.SETTLE=11]="SETTLE",K[K.SETTLE_ALL=12]="SETTLE_ALL",K[K.SETTLE_PAIR=13]="SETTLE_PAIR",K[K.TAKE=14]="TAKE",K[K.TAKE_ALL=15]="TAKE_ALL",K[K.TAKE_PORTION=16]="TAKE_PORTION",K[K.TAKE_PAIR=17]="TAKE_PAIR",K[K.CLOSE_CURRENCY=18]="CLOSE_CURRENCY",K[K.SWEEP=20]="SWEEP",K[K.UNWRAP=22]="UNWRAP",(z=exports.Subparser||(exports.Subparser={}))[z.V4SwapExactInSingle=0]="V4SwapExactInSingle",z[z.V4SwapExactIn=1]="V4SwapExactIn",z[z.V4SwapExactOutSingle=2]="V4SwapExactOutSingle",z[z.V4SwapExactOut=3]="V4SwapExactOut",z[z.PoolKey=4]="PoolKey";var G=((W={})[exports.Actions.INCREASE_LIQUIDITY]=[{name:"tokenId",type:"uint256"},{name:"liquidity",type:"uint256"},{name:"amount0Max",type:"uint128"},{name:"amount1Max",type:"uint128"},{name:"hookData",type:"bytes"}],W[exports.Actions.DECREASE_LIQUIDITY]=[{name:"tokenId",type:"uint256"},{name:"liquidity",type:"uint256"},{name:"amount0Min",type:"uint128"},{name:"amount1Min",type:"uint128"},{name:"hookData",type:"bytes"}],W[exports.Actions.MINT_POSITION]=[{name:"poolKey",type:"(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",subparser:exports.Subparser.PoolKey},{name:"tickLower",type:"int24"},{name:"tickUpper",type:"int24"},{name:"liquidity",type:"uint256"},{name:"amount0Max",type:"uint128"},{name:"amount1Max",type:"uint128"},{name:"owner",type:"address"},{name:"hookData",type:"bytes"}],W[exports.Actions.BURN_POSITION]=[{name:"tokenId",type:"uint256"},{name:"amount0Min",type:"uint128"},{name:"amount1Min",type:"uint128"},{name:"hookData",type:"bytes"}],W[exports.Actions.SWAP_EXACT_IN_SINGLE]=[{name:"swap",type:"((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,bytes hookData)",subparser:exports.Subparser.V4SwapExactInSingle}],W[exports.Actions.SWAP_EXACT_IN]=[{name:"swap",type:"(address currencyIn,(address intermediateCurrency,uint256 fee,int24 tickSpacing,address hooks,bytes hookData)[] path,uint128 amountIn,uint128 amountOutMinimum)",subparser:exports.Subparser.V4SwapExactIn}],W[exports.Actions.SWAP_EXACT_OUT_SINGLE]=[{name:"swap",type:"((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 amountOut,uint128 amountInMaximum,bytes hookData)",subparser:exports.Subparser.V4SwapExactOutSingle}],W[exports.Actions.SWAP_EXACT_OUT]=[{name:"swap",type:"(address currencyOut,(address intermediateCurrency,uint256 fee,int24 tickSpacing,address hooks,bytes hookData)[] path,uint128 amountOut,uint128 amountInMaximum)",subparser:exports.Subparser.V4SwapExactOut}],W[exports.Actions.SETTLE]=[{name:"currency",type:"address"},{name:"amount",type:"uint256"},{name:"payerIsUser",type:"bool"}],W[exports.Actions.SETTLE_ALL]=[{name:"currency",type:"address"},{name:"maxAmount",type:"uint256"}],W[exports.Actions.SETTLE_PAIR]=[{name:"currency0",type:"address"},{name:"currency1",type:"address"}],W[exports.Actions.TAKE]=[{name:"currency",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],W[exports.Actions.TAKE_ALL]=[{name:"currency",type:"address"},{name:"minAmount",type:"uint256"}],W[exports.Actions.TAKE_PORTION]=[{name:"currency",type:"address"},{name:"recipient",type:"address"},{name:"bips",type:"uint256"}],W[exports.Actions.TAKE_PAIR]=[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"recipient",type:"address"}],W[exports.Actions.CLOSE_CURRENCY]=[{name:"currency",type:"address"}],W[exports.Actions.SWEEP]=[{name:"currency",type:"address"},{name:"recipient",type:"address"}],W[exports.Actions.UNWRAP]=[{name:"amount",type:"uint256"}],W),Q=function(){function t(){this.actions="0x",this.params=[]}var e=t.prototype;return e.addAction=function(t,e){var n=function(t,e){return{action:t,encodedInput:u.defaultAbiCoder.encode(G[t].map((function(t){return t.type})),e)}}(t,e);return this.params.push(n.encodedInput),this.actions=this.actions.concat(n.action.toString(16).padStart(2,"0")),this},e.addTrade=function(t,e){var n=t.tradeType===o.TradeType.EXACT_OUTPUT;n&&(e||r(!1)),1!==t.swaps.length&&r(!1);var i=n?exports.Actions.SWAP_EXACT_OUT:exports.Actions.SWAP_EXACT_IN,a=Y(t.route.pathInput),u=Y(t.route.pathOutput);return this.addAction(i,[n?{currencyOut:u,path:V(t.route,n),amountInMaximum:t.maximumAmountIn(null!=e?e:new o.Percent(0)).quotient.toString(),amountOut:t.outputAmount.quotient.toString()}:{currencyIn:a,path:V(t.route,n),amountIn:t.inputAmount.quotient.toString(),amountOutMinimum:e?t.minimumAmountOut(e).quotient.toString():0}]),this},e.addSettle=function(t,e,n){return this.addAction(exports.Actions.SETTLE,[Y(t),null!=n?n:0,e]),this},e.addTake=function(t,e,n){var r=null!=n?n:0;return this.addAction(exports.Actions.TAKE,[Y(t),e,r]),this},e.addUnwrap=function(t){return this.addAction(exports.Actions.UNWRAP,[t]),this},e.finalize=function(){return u.defaultAbiCoder.encode(["bytes","bytes[]"],[this.actions,this.params])},t}();function Y(t){return t.isNative?_:t.wrapped.address}function Z(t){return t.isNative?_:t.wrapped.address}var $=function(t){function e(){return t.apply(this,arguments)||this}var n,r;r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,b(n,r);var i=e.prototype;return i.addMint=function(t,e,n,r,i,o,a,u){void 0===u&&(u="0x");var s=[D.getPoolKey(t.currency0,t.currency1,t.fee,t.tickSpacing,t.hooks),e,n,r.toString(),i.toString(),o.toString(),a,u];this.addAction(exports.Actions.MINT_POSITION,s)},i.addIncrease=function(t,e,n,r,i){void 0===i&&(i="0x");var o=[t.toString(),e.toString(),n.toString(),r.toString(),i];this.addAction(exports.Actions.INCREASE_LIQUIDITY,o)},i.addDecrease=function(t,e,n,r,i){void 0===i&&(i="0x");var o=[t.toString(),e.toString(),n.toString(),r.toString(),i];this.addAction(exports.Actions.DECREASE_LIQUIDITY,o)},i.addBurn=function(t,e,n,r){void 0===r&&(r="0x");var i=[t.toString(),e.toString(),n.toString(),r];this.addAction(exports.Actions.BURN_POSITION,i)},i.addSettlePair=function(t,e){var n=[Z(t),Z(e)];this.addAction(exports.Actions.SETTLE_PAIR,n)},i.addTakePair=function(t,e,n){var r=[Z(t),Z(e),n];this.addAction(exports.Actions.TAKE_PAIR,r)},i.addSweep=function(t,e){var n=[Z(t),e];this.addAction(exports.Actions.SWEEP,n)},e}(Q);function J(t){var e=s.BigInt(t).toString(16);return e.length%2!=0&&(e="0"+e),"0x"+e}var tt=function(){function t(){}return t.parseCalldata=function(e){var n=p.ethers.utils.defaultAbiCoder.decode(["bytes","bytes[]"],e),r=n[1];return{actions:t.getActions(n[0]).map((function(t,e){var n=G[t],i=p.ethers.utils.defaultAbiCoder.decode(n.map((function(t){return t.type})),r[e]).map((function(t,e){switch(n[e].subparser){case exports.Subparser.V4SwapExactInSingle:return{name:n[e].name,value:(r=t,i=r[0],o=r[1],a=r[2],u=r[3],s=r[4],p=i[0],c=i[1],y=i[2],d=i[3],l=i[4],{poolKey:{currency0:p,currency1:c,fee:y,tickSpacing:d,hooks:l},zeroForOne:o,amountIn:a,amountOutMinimum:u,hookData:s})};case exports.Subparser.V4SwapExactIn:return{name:n[e].name,value:rt(t)};case exports.Subparser.V4SwapExactOutSingle:return{name:n[e].name,value:it(t)};case exports.Subparser.V4SwapExactOut:return{name:n[e].name,value:ot(t)};case exports.Subparser.PoolKey:return{name:n[e].name,value:et(t)};default:return{name:n[e].name,value:t}}var r,i,o,a,u,s,p,c,y,d,l}));return{actionName:exports.Actions[t],actionType:t,params:i}}))}},t.getActions=function(t){for(var e=[],n=2;n<t.length;n+=2){var r=t.substring(n,n+2);e.push(parseInt(r,16))}return e},t}();function et(t){var e=t[3],n=t[4];return{currency0:t[0],currency1:t[1],fee:parseInt(t[2]),tickSpacing:parseInt(e),hooks:n}}function nt(t){var e=t[2],n=t[3],r=t[4];return{intermediateCurrency:t[0],fee:parseInt(t[1]),tickSpacing:parseInt(e),hooks:n,hookData:r}}function rt(t){var e=t[0],n=t[2],r=t[3];return{path:t[1].map((function(t){return nt(t)})),currencyIn:e,amountIn:n,amountOutMinimum:r}}function it(t){var e=t[0];return{poolKey:{currency0:e.currency0,currency1:e.currency1,fee:e.fee,tickSpacing:e.tickSpacing,hooks:e.hooks},zeroForOne:t[1],amountOut:t[2],amountInMaximum:t[3],hookData:t[4]}}function ot(t){var e=t[0],n=t[2],r=t[3];return{path:t[1].map((function(t){return nt(t)})),currencyOut:e,amountOut:n,amountInMaximum:r}}var at="0x0000000000000000000000000000000000000001",ut=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.decodeMulticall=function(e){return t.INTERFACE.decodeFunctionData("multicall",e)[0]},t}();ut.INTERFACE=new c.Interface(y.abi);var st=[{type:"constructor",inputs:[{name:"_poolManager",type:"address",internalType:"contract IPoolManager"},{name:"_permit2",type:"address",internalType:"contract IAllowanceTransfer"},{name:"_unsubscribeGasLimit",type:"uint256",internalType:"uint256"},{name:"_tokenDescriptor",type:"address",internalType:"contract IPositionDescriptor"},{name:"_weth9",type:"address",internalType:"contract IWETH9"}],stateMutability:"nonpayable"},{type:"receive",stateMutability:"payable"},{type:"function",name:"DOMAIN_SEPARATOR",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"WETH9",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IWETH9"}],stateMutability:"view"},{type:"function",name:"approve",inputs:[{name:"spender",type:"address",internalType:"address"},{name:"id",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"balanceOf",inputs:[{name:"owner",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getApproved",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"getPoolAndPositionInfo",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"poolKey",type:"tuple",internalType:"struct PoolKey",components:[{name:"currency0",type:"address",internalType:"Currency"},{name:"currency1",type:"address",internalType:"Currency"},{name:"fee",type:"uint24",internalType:"uint24"},{name:"tickSpacing",type:"int24",internalType:"int24"},{name:"hooks",type:"address",internalType:"contract IHooks"}]},{name:"info",type:"uint256",internalType:"PositionInfo"}],stateMutability:"view"},{type:"function",name:"getPositionLiquidity",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"liquidity",type:"uint128",internalType:"uint128"}],stateMutability:"view"},{type:"function",name:"initializePool",inputs:[{name:"key",type:"tuple",internalType:"struct PoolKey",components:[{name:"currency0",type:"address",internalType:"Currency"},{name:"currency1",type:"address",internalType:"Currency"},{name:"fee",type:"uint24",internalType:"uint24"},{name:"tickSpacing",type:"int24",internalType:"int24"},{name:"hooks",type:"address",internalType:"contract IHooks"}]},{name:"sqrtPriceX96",type:"uint160",internalType:"uint160"}],outputs:[{name:"",type:"int24",internalType:"int24"}],stateMutability:"payable"},{type:"function",name:"isApprovedForAll",inputs:[{name:"",type:"address",internalType:"address"},{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"modifyLiquidities",inputs:[{name:"unlockData",type:"bytes",internalType:"bytes"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"payable"},{type:"function",name:"modifyLiquiditiesWithoutUnlock",inputs:[{name:"actions",type:"bytes",internalType:"bytes"},{name:"params",type:"bytes[]",internalType:"bytes[]"}],outputs:[],stateMutability:"payable"},{type:"function",name:"msgSender",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"multicall",inputs:[{name:"data",type:"bytes[]",internalType:"bytes[]"}],outputs:[{name:"results",type:"bytes[]",internalType:"bytes[]"}],stateMutability:"payable"},{type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"nextTokenId",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"nonces",inputs:[{name:"owner",type:"address",internalType:"address"},{name:"word",type:"uint256",internalType:"uint256"}],outputs:[{name:"bitmap",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"ownerOf",inputs:[{name:"id",type:"uint256",internalType:"uint256"}],outputs:[{name:"owner",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"permit",inputs:[{name:"spender",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"function",name:"permit",inputs:[{name:"owner",type:"address",internalType:"address"},{name:"permitSingle",type:"tuple",internalType:"struct IAllowanceTransfer.PermitSingle",components:[{name:"details",type:"tuple",internalType:"struct IAllowanceTransfer.PermitDetails",components:[{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint160",internalType:"uint160"},{name:"expiration",type:"uint48",internalType:"uint48"},{name:"nonce",type:"uint48",internalType:"uint48"}]},{name:"spender",type:"address",internalType:"address"},{name:"sigDeadline",type:"uint256",internalType:"uint256"}]},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[{name:"err",type:"bytes",internalType:"bytes"}],stateMutability:"payable"},{type:"function",name:"permit2",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IAllowanceTransfer"}],stateMutability:"view"},{type:"function",name:"permitBatch",inputs:[{name:"owner",type:"address",internalType:"address"},{name:"_permitBatch",type:"tuple",internalType:"struct IAllowanceTransfer.PermitBatch",components:[{name:"details",type:"tuple[]",internalType:"struct IAllowanceTransfer.PermitDetails[]",components:[{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint160",internalType:"uint160"},{name:"expiration",type:"uint48",internalType:"uint48"},{name:"nonce",type:"uint48",internalType:"uint48"}]},{name:"spender",type:"address",internalType:"address"},{name:"sigDeadline",type:"uint256",internalType:"uint256"}]},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[{name:"err",type:"bytes",internalType:"bytes"}],stateMutability:"payable"},{type:"function",name:"permitForAll",inputs:[{name:"owner",type:"address",internalType:"address"},{name:"operator",type:"address",internalType:"address"},{name:"approved",type:"bool",internalType:"bool"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"function",name:"poolKeys",inputs:[{name:"poolId",type:"bytes25",internalType:"bytes25"}],outputs:[{name:"currency0",type:"address",internalType:"Currency"},{name:"currency1",type:"address",internalType:"Currency"},{name:"fee",type:"uint24",internalType:"uint24"},{name:"tickSpacing",type:"int24",internalType:"int24"},{name:"hooks",type:"address",internalType:"contract IHooks"}],stateMutability:"view"},{type:"function",name:"poolManager",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IPoolManager"}],stateMutability:"view"},{type:"function",name:"positionInfo",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"info",type:"uint256",internalType:"PositionInfo"}],stateMutability:"view"},{type:"function",name:"revokeNonce",inputs:[{name:"nonce",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"payable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"id",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"id",type:"uint256",internalType:"uint256"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setApprovalForAll",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"approved",type:"bool",internalType:"bool"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"subscribe",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"newSubscriber",type:"address",internalType:"address"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"function",name:"subscriber",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"subscriber",type:"address",internalType:"contract ISubscriber"}],stateMutability:"view"},{type:"function",name:"supportsInterface",inputs:[{name:"interfaceId",type:"bytes4",internalType:"bytes4"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"tokenDescriptor",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IPositionDescriptor"}],stateMutability:"view"},{type:"function",name:"tokenURI",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"transferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"id",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"unlockCallback",inputs:[{name:"data",type:"bytes",internalType:"bytes"}],outputs:[{name:"",type:"bytes",internalType:"bytes"}],stateMutability:"nonpayable"},{type:"function",name:"unsubscribe",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"payable"},{type:"function",name:"unsubscribeGasLimit",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"event",name:"Approval",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"spender",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"ApprovalForAll",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"operator",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"Subscription",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"subscriber",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Transfer",inputs:[{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"Unsubscription",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"subscriber",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AlreadySubscribed",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"subscriber",type:"address",internalType:"address"}]},{type:"error",name:"BurnNotificationReverted",inputs:[{name:"subscriber",type:"address",internalType:"address"},{name:"reason",type:"bytes",internalType:"bytes"}]},{type:"error",name:"ContractLocked",inputs:[]},{type:"error",name:"DeadlinePassed",inputs:[{name:"deadline",type:"uint256",internalType:"uint256"}]},{type:"error",name:"DeltaNotNegative",inputs:[{name:"currency",type:"address",internalType:"Currency"}]},{type:"error",name:"DeltaNotPositive",inputs:[{name:"currency",type:"address",internalType:"Currency"}]},{type:"error",name:"GasLimitTooLow",inputs:[]},{type:"error",name:"InputLengthMismatch",inputs:[]},{type:"error",name:"InsufficientBalance",inputs:[]},{type:"error",name:"InvalidContractSignature",inputs:[]},{type:"error",name:"InvalidEthSender",inputs:[]},{type:"error",name:"InvalidSignature",inputs:[]},{type:"error",name:"InvalidSignatureLength",inputs:[]},{type:"error",name:"InvalidSigner",inputs:[]},{type:"error",name:"MaximumAmountExceeded",inputs:[{name:"maximumAmount",type:"uint128",internalType:"uint128"},{name:"amountRequested",type:"uint128",internalType:"uint128"}]},{type:"error",name:"MinimumAmountInsufficient",inputs:[{name:"minimumAmount",type:"uint128",internalType:"uint128"},{name:"amountReceived",type:"uint128",internalType:"uint128"}]},{type:"error",name:"ModifyLiquidityNotificationReverted",inputs:[{name:"subscriber",type:"address",internalType:"address"},{name:"reason",type:"bytes",internalType:"bytes"}]},{type:"error",name:"NoCodeSubscriber",inputs:[]},{type:"error",name:"NoSelfPermit",inputs:[]},{type:"error",name:"NonceAlreadyUsed",inputs:[]},{type:"error",name:"NotApproved",inputs:[{name:"caller",type:"address",internalType:"address"}]},{type:"error",name:"NotPoolManager",inputs:[]},{type:"error",name:"NotSubscribed",inputs:[]},{type:"error",name:"PoolManagerMustBeLocked",inputs:[]},{type:"error",name:"SignatureDeadlineExpired",inputs:[]},{type:"error",name:"SubscriptionReverted",inputs:[{name:"subscriber",type:"address",internalType:"address"},{name:"reason",type:"bytes",internalType:"bytes"}]},{type:"error",name:"TransferNotificationReverted",inputs:[{name:"subscriber",type:"address",internalType:"address"},{name:"reason",type:"bytes",internalType:"bytes"}]},{type:"error",name:"Unauthorized",inputs:[]},{type:"error",name:"UnsupportedAction",inputs:[{name:"action",type:"uint256",internalType:"uint256"}]}],pt={Permit:[{name:"spender",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};function ct(t){return Object.keys(t).some((function(t){return"recipient"===t}))}var yt=function(){function t(){}return t.createCallParameters=function(t,e){return{calldata:this.encodeInitializePool(t,e),value:J(0)}},t.addCallParameters=function(e,n){s.greaterThan(e.liquidity,R)||r(!1);var i=[],a=new $;ct(n)&&function(t){return!!t.createPool&&(void 0===t.sqrtPriceX96&&r(!1),!0)}(n)&&i.push(t.encodeInitializePool(e.pool.poolKey,n.sqrtPriceX96)),e.pool.currency0===n.useNative||!e.pool.currency0.isNative&&void 0===n.useNative||r(!1);var u=e.mintAmountsWithSlippage(n.slippageTolerance),p=J(u.amount0),c=J(u.amount1);if(n.batchPermit&&i.push(t.encodePermitBatch(n.batchPermit.owner,n.batchPermit.permitBatch,n.batchPermit.signature)),ct(n)){var y=o.validateAndParseAddress(n.recipient);a.addMint(e.pool,e.tickLower,e.tickUpper,e.liquidity,p,c,y,n.hookData)}else a.addIncrease(n.tokenId,e.liquidity,p,c,n.hookData);var d=J(0);return ct(n)&&n.migrate?n.useNative?(a.addUnwrap(L),a.addSettle(e.pool.currency0,!1),a.addSettle(e.pool.currency1,!1),a.addSweep(e.pool.currency0.wrapped,n.recipient),a.addSweep(e.pool.currency1,n.recipient)):(a.addSettle(e.pool.currency0,!1),a.addSettle(e.pool.currency1,!1),a.addSweep(e.pool.currency0,n.recipient),a.addSweep(e.pool.currency1,n.recipient)):(a.addSettlePair(e.pool.currency0,e.pool.currency1),n.useNative&&(d=J(p),a.addSweep(e.pool.currency0,at))),i.push(t.encodeModifyLiquidities(a.finalize(),n.deadline)),{calldata:ut.encodeMulticall(i),value:d}},t.removeCallParameters=function(e,n){var i=[],o=new $,a=J(n.tokenId);if(n.burnToken){n.liquidityPercentage.equalTo(O)||r(!1),n.permit&&i.push(t.encodeERC721Permit(n.permit.spender,n.permit.tokenId,n.permit.deadline,n.permit.nonce,n.permit.signature));var u=e.burnAmountsWithSlippage(n.slippageTolerance);o.addBurn(a,u.amount0,u.amount1,n.hookData)}else{var p,c=new j({pool:e.pool,liquidity:n.liquidityPercentage.multiply(e.liquidity).quotient,tickLower:e.tickLower,tickUpper:e.tickUpper});s.greaterThan(c.liquidity,R)||r(!1);var y=c.burnAmountsWithSlippage(n.slippageTolerance),d=y.amount0,l=y.amount1;o.addDecrease(a,c.liquidity.toString(),d.toString(),l.toString(),null!=(p=n.hookData)?p:"0x")}return o.addTakePair(e.pool.currency0,e.pool.currency1,at),i.push(t.encodeModifyLiquidities(o.finalize(),n.deadline)),{calldata:ut.encodeMulticall(i),value:J(0)}},t.collectCallParameters=function(e,n){var r=[],i=new $,a=J(n.tokenId),u=o.validateAndParseAddress(n.recipient);return i.addDecrease(a,"0","0","0",n.hookData),i.addTakePair(e.pool.currency0,e.pool.currency1,u),r.push(t.encodeModifyLiquidities(i.finalize(),n.deadline)),{calldata:ut.encodeMulticall(r),value:J(0)}},t.encodeInitializePool=function(e,n){return t.INTERFACE.encodeFunctionData(g.INITIALIZE_POOL,[e,n.toString()])},t.encodeModifyLiquidities=function(e,n){return t.INTERFACE.encodeFunctionData(g.MODIFY_LIQUIDITIES,[e,n])},t.encodePermitBatch=function(e,n,r){return t.INTERFACE.encodeFunctionData(g.PERMIT_BATCH,[e,n,r])},t.encodeERC721Permit=function(e,n,r,i,o){return t.INTERFACE.encodeFunctionData(g.ERC721PERMIT_PERMIT,[e,n,r,i,o])},t.getPermitData=function(t,e,n){return{domain:{name:"Uniswap V4 Positions NFT",chainId:n,verifyingContract:e},types:pt,values:t}},t}();yt.INTERFACE=new c.Interface(st),exports.DYNAMIC_FEE_FLAG=8388608,exports.Hook=q,exports.Pool=D,exports.Position=j,exports.Route=B,exports.Trade=X,exports.V4BaseActionsParser=tt,exports.V4Planner=Q,exports.V4PositionManager=yt,exports.V4PositionPlanner=$,exports.V4_BASE_ACTIONS_ABI_DEFINITION=G,exports.amountWithPathCurrency=N,exports.encodeRouteToPath=V,exports.getPathCurrency=U,exports.hookFlagIndex=x,exports.priceToClosestTick=function(t){var e=S(t.baseCurrency,t.quoteCurrency),n=e?a.encodeSqrtRatioX96(t.numerator,t.denominator):a.encodeSqrtRatioX96(t.denominator,t.numerator),r=a.TickMath.getTickAtSqrtRatio(n),i=F(t.baseCurrency,t.quoteCurrency,r+1);return e?t.lessThan(i)||r++:t.greaterThan(i)||r++,r},exports.sortsBefore=S,exports.tickToPrice=F,exports.toAddress=Z,exports.toHex=J,exports.tradeComparator=H;
2
+ //# sourceMappingURL=v4-sdk.cjs.production.min.js.map