@kayenfinance/v3-sdk 1.0.0-dev.2 → 1.0.0-dev.3

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.
@@ -1,2 +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,i=require("@kayenfinance/sdk-core"),o=t(require("jsbi")),u=t(require("tiny-invariant")),a=require("@ethersproject/abi"),c=require("@ethersproject/address"),s=require("@ethersproject/solidity"),d=t(require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IMulticall.sol/IMulticall.json")),p=t(require("@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json")),l=t(require("@uniswap/v3-periphery/artifacts/contracts/interfaces/ISelfPermit.sol/ISelfPermit.json")),f=t(require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IPeripheryPaymentsWithFee.sol/IPeripheryPaymentsWithFee.json")),m=t(require("@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json")),h=t(require("@uniswap/swap-router-contracts/artifacts/contracts/lens/QuoterV2.sol/QuoterV2.json")),k=t(require("@uniswap/v3-staker/artifacts/contracts/UniswapV3Staker.sol/UniswapV3Staker.json")),A=t(require("@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json"));function v(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 y(t,e,n,r,i,o,u){try{var a=t[o](u),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,i)}function T(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function u(t){y(o,r,i,u,a,"next",t)}function a(t){y(o,r,i,u,a,"throw",t)}u(void 0)}))}}function g(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,b(r.key),r)}}function I(t,e,n){return e&&g(t.prototype,e),n&&g(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function w(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 v(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)?v(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 q(){return(q=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 x(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=Object.create((r&&r.prototype instanceof a?r:a).prototype);return R(c,"_invoke",function(n,r,i){var o,a,c,s=0,d=i||[],p=!1,l={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,n){return o=e,a=0,c=t,l.n=n,u}};function f(n,r){for(a=n,c=r,e=0;!p&&s&&!i&&e<d.length;e++){var i,o=d[e],f=l.p,m=o[2];n>3?(i=m===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=f&&((i=n<2&&f<o[1])?(a=0,l.v=r,l.n=o[1]):f<m&&(i=n<3||o[0]>r||r>m)&&(o[4]=n,o[5]=r,l.n=m,a=0))}if(i||n>1)return u;throw p=!0,r}return function(i,d,m){if(s>1)throw TypeError("Generator is already running");for(p&&1===d&&f(d,m),a=d,c=m;(e=a<2?t:c)||!p;){o||(a?a<3?(a>1&&(l.n=-1),f(a,c)):l.n=c:l.v=c);try{if(s=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(p=l.n<0)?c:n.call(r,l))!==u)break}catch(e){o=t,a=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,i,o),!0),c}var u={};function a(){}function c(){}function s(){}e=Object.getPrototypeOf;var d=[][r]?e(e([][r]())):(R(e={},r,(function(){return this})),e),p=s.prototype=a.prototype=Object.create(d);function l(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,R(t,i,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,R(p,"constructor",s),R(s,"constructor",c),c.displayName="GeneratorFunction",R(s,i,"GeneratorFunction"),R(p),R(p,i,"Generator"),R(p,r,(function(){return this})),R(p,"toString",(function(){return"[object Generator]"})),(x=function(){return{w:o,m:l}})()}function R(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}(R=function(t,e,n,r){function o(e,n){R(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){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+""}var P,C=((e={})[i.ChainId.CHILIZ]="0x8E994Dbd9d91dF55A711D24B14739ab410CAC1E7",e[i.ChainId.SPICY]="0xe854832362b6f99a02b3b2c66c56ecfa1daac0df",e),E="0x0000000000000000000000000000000000000000",O="0x6a9477a7692b57ac6f70f344df5dd38824c03d1e5689b3c29fa3616d0ee19c85",S=((n={})[i.ChainId.CHILIZ]="0x6a9477a7692b57ac6f70f344df5dd38824c03d1e5689b3c29fa3616d0ee19c85",n[i.ChainId.SPICY]="0x6a9477a7692b57ac6f70f344df5dd38824c03d1e5689b3c29fa3616d0ee19c85",n);function _(t){var e;return null!=(e=S[t])?e:O}(P=exports.FeeAmount||(exports.FeeAmount={}))[P.LOWEST=100]="LOWEST",P[P.LOW_200=200]="LOW_200",P[P.LOW_300=300]="LOW_300",P[P.LOW_400=400]="LOW_400",P[P.LOW=500]="LOW",P[P.MEDIUM=3e3]="MEDIUM",P[P.HIGH=1e4]="HIGH";var N=((r={})[exports.FeeAmount.LOWEST]=1,r[exports.FeeAmount.LOW_200]=4,r[exports.FeeAmount.LOW_300]=6,r[exports.FeeAmount.LOW_400]=8,r[exports.FeeAmount.LOW]=10,r[exports.FeeAmount.MEDIUM]=60,r[exports.FeeAmount.HIGH]=200,r),F=o.BigInt(-1),X=o.BigInt(0),U=o.BigInt(1),B=o.exponentiate(o.BigInt(2),o.BigInt(96)),D=o.exponentiate(B,o.BigInt(2));function M(t){var e=t.factoryAddress,n=t.tokenA,r=t.tokenB,i=t.fee,o=t.initCodeHashManualOverride,u=t.chainId,d=n.sortsBefore(r)?[n,r]:[r,n],p=s.keccak256(["bytes"],[a.defaultAbiCoder.encode(["address","address","uint24"],[d[0].address,d[1].address,i])]),l=null!=o?o:_(u);return c.getCreate2Address(e,p,l)}var L=function(){function t(){}return t.mulDivRoundingUp=function(t,e,n){var r=o.multiply(t,e),i=o.divide(r,n);return o.notEqual(o.remainder(r,n),X)&&(i=o.add(i,U)),i},t}(),W=o.subtract(o.exponentiate(o.BigInt(2),o.BigInt(160)),U);function j(t,e){var n=o.multiply(t,e);return o.bitwiseAnd(n,i.MaxUint256)}var H=function(){function t(){}return t.getAmount0Delta=function(t,e,n,r){if(o.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}var u=o.leftShift(n,o.BigInt(96)),a=o.subtract(e,t);return r?L.mulDivRoundingUp(L.mulDivRoundingUp(u,a,e),U,t):o.divide(o.divide(o.multiply(u,a),e),t)},t.getAmount1Delta=function(t,e,n,r){if(o.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}return r?L.mulDivRoundingUp(n,o.subtract(e,t),B):o.divide(o.multiply(n,o.subtract(e,t)),B)},t.getNextSqrtPriceFromInput=function(t,e,n,r){return o.greaterThan(t,X)||u(!1),o.greaterThan(e,X)||u(!1),r?this.getNextSqrtPriceFromAmount0RoundingUp(t,e,n,!0):this.getNextSqrtPriceFromAmount1RoundingDown(t,e,n,!0)},t.getNextSqrtPriceFromOutput=function(t,e,n,r){return o.greaterThan(t,X)||u(!1),o.greaterThan(e,X)||u(!1),r?this.getNextSqrtPriceFromAmount1RoundingDown(t,e,n,!1):this.getNextSqrtPriceFromAmount0RoundingUp(t,e,n,!1)},t.getNextSqrtPriceFromAmount0RoundingUp=function(t,e,n,r){if(o.equal(n,X))return t;var a=o.leftShift(e,o.BigInt(96));if(r){var c=j(n,t);if(o.equal(o.divide(c,n),t)){var s=(p=o.add(a,c),o.bitwiseAnd(p,i.MaxUint256));if(o.greaterThanOrEqual(s,a))return L.mulDivRoundingUp(a,t,s)}return L.mulDivRoundingUp(a,U,o.add(o.divide(a,t),n))}var d=j(n,t);o.equal(o.divide(d,n),t)||u(!1),o.greaterThan(a,d)||u(!1);var p,l=o.subtract(a,d);return L.mulDivRoundingUp(a,t,l)},t.getNextSqrtPriceFromAmount1RoundingDown=function(t,e,n,r){if(r){var i=o.lessThanOrEqual(n,W)?o.divide(o.leftShift(n,o.BigInt(96)),e):o.divide(o.multiply(n,B),e);return o.add(t,i)}var a=L.mulDivRoundingUp(n,B,e);return o.greaterThan(t,a)||u(!1),o.subtract(t,a)},t}(),K=o.exponentiate(o.BigInt(10),o.BigInt(6)),G=function(){function t(){}return t.computeSwapStep=function(t,e,n,r,i){var u={};i=o.BigInt(i);var a=o.greaterThanOrEqual(t,e),c=o.greaterThanOrEqual(r,X);if(c){var s=o.divide(o.multiply(r,o.subtract(K,i)),K);u.amountIn=a?H.getAmount0Delta(e,t,n,!0):H.getAmount1Delta(t,e,n,!0),u.sqrtRatioNextX96=o.greaterThanOrEqual(s,u.amountIn)?e:H.getNextSqrtPriceFromInput(t,n,s,a)}else u.amountOut=a?H.getAmount1Delta(e,t,n,!1):H.getAmount0Delta(t,e,n,!1),u.sqrtRatioNextX96=o.greaterThanOrEqual(o.multiply(r,F),u.amountOut)?e:H.getNextSqrtPriceFromOutput(t,n,o.multiply(r,F),a);var d=o.equal(e,u.sqrtRatioNextX96);return a?(u.amountIn=d&&c?u.amountIn:H.getAmount0Delta(u.sqrtRatioNextX96,t,n,!0),u.amountOut=d&&!c?u.amountOut:H.getAmount1Delta(u.sqrtRatioNextX96,t,n,!1)):(u.amountIn=d&&c?u.amountIn:H.getAmount1Delta(t,u.sqrtRatioNextX96,n,!0),u.amountOut=d&&!c?u.amountOut:H.getAmount0Delta(t,u.sqrtRatioNextX96,n,!1)),!c&&o.greaterThan(u.amountOut,o.multiply(r,F))&&(u.amountOut=o.multiply(r,F)),u.feeAmount=c&&o.notEqual(u.sqrtRatioNextX96,e)?o.subtract(r,u.amountIn):L.mulDivRoundingUp(u.amountIn,i,o.subtract(K,i)),[u.sqrtRatioNextX96,u.amountIn,u.amountOut,u.feeAmount]},t}(),Q=function(){function t(){}return t.addDelta=function(t,e){return o.lessThan(e,X)?o.subtract(t,o.multiply(e,F)):o.add(t,e)},t}(),V=o.BigInt(2),z=[128,64,32,16,8,4,2,1].map((function(t){return[t,o.exponentiate(V,o.BigInt(t))]}));function Y(t){o.greaterThan(t,X)||u(!1),o.lessThanOrEqual(t,i.MaxUint256)||u(!1);for(var e,n=0,r=w(z);!(e=r()).done;){var a=e.value,c=a[0];o.greaterThanOrEqual(t,a[1])&&(t=o.signedRightShift(t,o.BigInt(c)),n+=c)}return n}function Z(t,e){return o.signedRightShift(o.multiply(t,o.BigInt(e)),o.BigInt(128))}var $=o.exponentiate(o.BigInt(2),o.BigInt(32)),J=function(){function t(){}return t.getSqrtRatioAtTick=function(e){e>=t.MIN_TICK&&e<=t.MAX_TICK&&Number.isInteger(e)||u(!1);var n=e<0?-1*e:e,r=o.BigInt(0!=(1&n)?"0xfffcb933bd6fad37aa2d162d1a594001":"0x100000000000000000000000000000000");return 0!=(2&n)&&(r=Z(r,"0xfff97272373d413259a46990580e213a")),0!=(4&n)&&(r=Z(r,"0xfff2e50f5f656932ef12357cf3c7fdcc")),0!=(8&n)&&(r=Z(r,"0xffe5caca7e10e4e61c3624eaa0941cd0")),0!=(16&n)&&(r=Z(r,"0xffcb9843d60f6159c9db58835c926644")),0!=(32&n)&&(r=Z(r,"0xff973b41fa98c081472e6896dfb254c0")),0!=(64&n)&&(r=Z(r,"0xff2ea16466c96a3843ec78b326b52861")),0!=(128&n)&&(r=Z(r,"0xfe5dee046a99a2a811c461f1969c3053")),0!=(256&n)&&(r=Z(r,"0xfcbe86c7900a88aedcffc83b479aa3a4")),0!=(512&n)&&(r=Z(r,"0xf987a7253ac413176f2b074cf7815e54")),0!=(1024&n)&&(r=Z(r,"0xf3392b0822b70005940c7a398e4b70f3")),0!=(2048&n)&&(r=Z(r,"0xe7159475a2c29b7443b29c7fa6e889d9")),0!=(4096&n)&&(r=Z(r,"0xd097f3bdfd2022b8845ad8f792aa5825")),0!=(8192&n)&&(r=Z(r,"0xa9f746462d870fdf8a65dc1f90e061e5")),0!=(16384&n)&&(r=Z(r,"0x70d869a156d2a1b890bb3df62baf32f7")),0!=(32768&n)&&(r=Z(r,"0x31be135f97d08fd981231505542fcfa6")),0!=(65536&n)&&(r=Z(r,"0x9aa508b5b7a84e1c677de54f3e99bc9")),0!=(131072&n)&&(r=Z(r,"0x5d6af8dedb81196699c329225ee604")),0!=(262144&n)&&(r=Z(r,"0x2216e584f5fa1ea926041bedfe98")),0!=(524288&n)&&(r=Z(r,"0x48a170391f7dc42444e8fa2")),e>0&&(r=o.divide(i.MaxUint256,r)),o.greaterThan(o.remainder(r,$),X)?o.add(o.divide(r,$),U):o.divide(r,$)},t.getTickAtSqrtRatio=function(e){o.greaterThanOrEqual(e,t.MIN_SQRT_RATIO)&&o.lessThan(e,t.MAX_SQRT_RATIO)||u(!1);var n,r=o.leftShift(e,o.BigInt(32)),i=Y(r);n=o.greaterThanOrEqual(o.BigInt(i),o.BigInt(128))?o.signedRightShift(r,o.BigInt(i-127)):o.leftShift(r,o.BigInt(127-i));for(var a=o.leftShift(o.subtract(o.BigInt(i),o.BigInt(128)),o.BigInt(64)),c=0;c<14;c++){n=o.signedRightShift(o.multiply(n,n),o.BigInt(127));var s=o.signedRightShift(n,o.BigInt(128));a=o.bitwiseOr(a,o.leftShift(s,o.BigInt(63-c))),n=o.signedRightShift(n,s)}var d=o.multiply(a,o.BigInt("255738958999603826347141")),p=o.toNumber(o.signedRightShift(o.subtract(d,o.BigInt("3402992956809132418596140100660247210")),o.BigInt(128))),l=o.toNumber(o.signedRightShift(o.add(d,o.BigInt("291339464771989622907027621153398088495")),o.BigInt(128)));return p===l?p:o.lessThanOrEqual(t.getSqrtRatioAtTick(l),e)?l:p},t}();function tt(t,e,n,r,i,o,u,a,c){return et.apply(this,arguments)}function et(){return(et=T(x().m((function t(e,n,r,i,a,c,s,d,p){var l,f,m,h,k,A,v;return x().w((function(t){for(;;)switch(t.n){case 0:p||(p=s?o.add(J.MIN_SQRT_RATIO,U):o.subtract(J.MAX_SQRT_RATIO,U)),s?(o.greaterThan(p,J.MIN_SQRT_RATIO)||u(!1),o.lessThan(p,n)||u(!1)):(o.lessThan(p,J.MAX_SQRT_RATIO)||u(!1),o.greaterThan(p,n)||u(!1)),l=o.greaterThanOrEqual(d,X),f={amountSpecifiedRemaining:d,amountCalculated:X,sqrtPriceX96:n,tick:r,liquidity:i};case 1:if(!o.notEqual(f.amountSpecifiedRemaining,X)||f.sqrtPriceX96===p){t.n=7;break}return(m={}).sqrtPriceStartX96=f.sqrtPriceX96,t.n=2,c.nextInitializedTickWithinOneWord(f.tick,s,a);case 2:if(m.tickNext=(h=t.v)[0],m.initialized=h[1],m.tickNext<J.MIN_TICK?m.tickNext=J.MIN_TICK:m.tickNext>J.MAX_TICK&&(m.tickNext=J.MAX_TICK),m.sqrtPriceNextX96=J.getSqrtRatioAtTick(m.tickNext),k=G.computeSwapStep(f.sqrtPriceX96,(s?o.lessThan(m.sqrtPriceNextX96,p):o.greaterThan(m.sqrtPriceNextX96,p))?p:m.sqrtPriceNextX96,f.liquidity,f.amountSpecifiedRemaining,e),f.sqrtPriceX96=k[0],m.amountIn=k[1],m.amountOut=k[2],m.feeAmount=k[3],l?(f.amountSpecifiedRemaining=o.subtract(f.amountSpecifiedRemaining,o.add(m.amountIn,m.feeAmount)),f.amountCalculated=o.subtract(f.amountCalculated,m.amountOut)):(f.amountSpecifiedRemaining=o.add(f.amountSpecifiedRemaining,m.amountOut),f.amountCalculated=o.add(f.amountCalculated,o.add(m.amountIn,m.feeAmount))),!o.equal(f.sqrtPriceX96,m.sqrtPriceNextX96)){t.n=5;break}if(!m.initialized){t.n=4;break}return v=o,t.n=3,c.getTick(m.tickNext);case 3:A=v.BigInt.call(v,t.v.liquidityNet),s&&(A=o.multiply(A,F)),f.liquidity=Q.addDelta(f.liquidity,A);case 4:f.tick=s?m.tickNext-1:m.tickNext,t.n=6;break;case 5:o.notEqual(f.sqrtPriceX96,m.sqrtPriceStartX96)&&(f.tick=J.getTickAtSqrtRatio(f.sqrtPriceX96));case 6:t.n=1;break;case 7:return t.a(2,{amountCalculated:f.amountCalculated,sqrtRatioX96:f.sqrtPriceX96,liquidity:f.liquidity,tickCurrent:f.tick})}}),t)})))).apply(this,arguments)}J.MIN_TICK=-887272,J.MAX_TICK=-J.MIN_TICK,J.MIN_SQRT_RATIO=o.BigInt("4295128739"),J.MAX_SQRT_RATIO=o.BigInt("1461446703485210103287273052203988822378723970342");var nt=function(){function t(){}var e=t.prototype;return e.getTick=function(){var e=T(x().m((function e(n){return x().w((function(e){for(;;)switch(e.n){case 0:throw new Error(t.ERROR_MESSAGE);case 1:return e.a(2)}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var e=T(x().m((function e(n,r,i){return x().w((function(e){for(;;)switch(e.n){case 0:throw new Error(t.ERROR_MESSAGE);case 1:return e.a(2)}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t}();function rt(t,e){for(var n=0;n<t.length-1;n++)if(e(t[n],t[n+1])>0)return!1;return!0}function it(t,e){return t.index-e.index}nt.ERROR_MESSAGE="No tick data provider was given";var ot=function(){function t(){}return t.validateList=function(t,e){e>0||u(!1),t.every((function(t){return t.index%e==0}))||u(!1),o.equal(t.reduce((function(t,e){return o.add(t,e.liquidityNet)}),X),X)||u(!1),rt(t,it)||u(!1)},t.isBelowSmallest=function(t,e){return t.length>0||u(!1),e<t[0].index},t.isAtOrAboveLargest=function(t,e){return t.length>0||u(!1),e>=t[t.length-1].index},t.getTick=function(t,e){var n=t[this.binarySearch(t,e)];return n.index!==e&&u(!1),n},t.binarySearch=function(t,e){this.isBelowSmallest(t,e)&&u(!1);for(var n,r=0,i=t.length-1;;){if(t[n=Math.floor((r+i)/2)].index<=e&&(n===t.length-1||t[n+1].index>e))return n;t[n].index<e?r=n+1:i=n-1}},t.nextInitializedTick=function(e,n,r){return r?(t.isBelowSmallest(e,n)&&u(!1),t.isAtOrAboveLargest(e,n)?e[e.length-1]:e[this.binarySearch(e,n)]):(this.isAtOrAboveLargest(e,n)&&u(!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 u=(o>>8<<8)*i;if(t.isBelowSmallest(e,n))return[u,!1];var a=t.nextInitializedTick(e,n,r).index,c=Math.max(u,a);return[c,c===a]}var s=((1+(o+1>>8)<<8)-1)*i;if(this.isAtOrAboveLargest(e,n))return[s,!1];var d=this.nextInitializedTick(e,n,r).index,p=Math.min(s,d);return[p,p===d]},t}();function ut(t){var e=o.BigInt(t).toString(16);return e.length%2!=0&&(e="0"+e),"0x"+e}function at(t,e){var n=t.pools.reduce((function(t,e,n){var r=t.inputToken,i=t.path,o=t.types,u=e.token0.equals(r)?e.token1:e.token0;return 0===n?{inputToken:u,types:["address","uint24","address"],path:[r.address,e.fee,u.address]}:{inputToken:u,types:[].concat(o,["uint24","address"]),path:[].concat(i,[e.fee,u.address])}}),{inputToken:t.input.wrapped,path:[],types:[]}),r=n.path,i=n.types;return e?s.pack(i.reverse(),r.reverse()):s.pack(i,r)}function ct(t,e){var n=o.leftShift(o.BigInt(t),o.BigInt(192)),r=o.BigInt(e),u=o.divide(n,r);return i.sqrt(u)}function st(t,e,n){if(o.greaterThan(t,e)){var r=[e,t];t=r[0],e=r[1]}var i=o.divide(o.multiply(t,e),B);return o.divide(o.multiply(o.BigInt(n),i),o.subtract(e,t))}function dt(t,e,n){if(o.greaterThan(t,e)){var r=[e,t];t=r[0],e=r[1]}var i=o.multiply(o.multiply(o.BigInt(n),t),e),u=o.multiply(B,o.subtract(e,t));return o.divide(i,u)}function pt(t,e,n){if(o.greaterThan(t,e)){var r=[e,t];t=r[0],e=r[1]}return o.divide(o.multiply(o.BigInt(n),B),o.subtract(e,t))}function lt(t,e,n,r,i,u){if(o.greaterThan(e,n)){var a=[n,e];e=a[0],n=a[1]}var c=u?dt:st;if(o.lessThanOrEqual(t,e))return c(e,n,r);if(o.lessThan(t,n)){var s=c(t,n,r),d=pt(e,t,i);return o.lessThan(s,d)?s:d}return pt(e,n,i)}var ft=o.exponentiate(o.BigInt(2),o.BigInt(128)),mt=function(){function t(){}return t.getTokensOwed=function(t,e,n,r,i){return[o.divide(o.multiply(At(r,t),n),ft),o.divide(o.multiply(At(i,e),n),ft)]},t}();function ht(t,e,n){var r=J.getSqrtRatioAtTick(n),u=o.multiply(r,r);return t.sortsBefore(e)?new i.Price(t,e,D,u):new i.Price(t,e,u,D)}var kt=o.exponentiate(o.BigInt(2),o.BigInt(256));function At(t,e){var n=o.subtract(t,e);return o.lessThan(n,X)?o.add(kt,n):n}var vt=function(){function t(){}return t.getFeeGrowthInside=function(t,e,n,r,i,o,u){var a,c,s,d;return i>=n?(a=t.feeGrowthOutside0X128,c=t.feeGrowthOutside1X128):(a=At(o,t.feeGrowthOutside0X128),c=At(u,t.feeGrowthOutside1X128)),i<r?(s=e.feeGrowthOutside0X128,d=e.feeGrowthOutside1X128):(s=At(o,e.feeGrowthOutside0X128),d=At(u,e.feeGrowthOutside1X128)),[At(At(o,a),s),At(At(u,c),d)]},t}(),yt=function(t){var e=t.index,n=t.liquidityGross,r=t.liquidityNet;e>=J.MIN_TICK&&e<=J.MAX_TICK||u(!1),this.index=e,this.liquidityGross=o.BigInt(n),this.liquidityNet=o.BigInt(r)},Tt=function(){function t(t,e){var n=t.map((function(t){return t instanceof yt?t:new yt(t)}));ot.validateList(n,e),this.ticks=n}var e=t.prototype;return e.getTick=function(){var t=T(x().m((function t(e){return x().w((function(t){for(;;)switch(t.n){case 0:return t.a(2,ot.getTick(this.ticks,e))}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var t=T(x().m((function t(e,n,r){return x().w((function(t){for(;;)switch(t.n){case 0:return t.a(2,ot.nextInitializedTickWithinOneWord(this.ticks,e,n,r))}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),t}(),gt=new nt,It=function(){function t(t,e,n,r,i,a,c){void 0===c&&(c=gt),Number.isInteger(n)&&n<1e6||u(!1);var s=J.getSqrtRatioAtTick(a),d=J.getSqrtRatioAtTick(a+1);o.greaterThanOrEqual(o.BigInt(r),s)&&o.lessThanOrEqual(o.BigInt(r),d)||u(!1);var p=t.sortsBefore(e)?[t,e]:[e,t];this.token0=p[0],this.token1=p[1],this.fee=n,this.sqrtRatioX96=o.BigInt(r),this.liquidity=o.BigInt(i),this.tickCurrent=a,this.tickDataProvider=Array.isArray(c)?new Tt(c,N[n]):c}t.getAddress=function(t,e,n,r,i){return M({factoryAddress:null!=i?i:"0x8E994Dbd9d91dF55A711D24B14739ab410CAC1E7",fee:n,tokenA:t,tokenB:e,initCodeHashManualOverride:r})};var e=t.prototype;return e.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},e.priceOf=function(t){return this.involvesToken(t)||u(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.getOutputAmount=function(){var e=T(x().m((function e(n,r){var a,c,s,d,p;return x().w((function(e){for(;;)switch(e.n){case 0:return this.involvesToken(n.currency)||u(!1),a=n.currency.equals(this.token0),e.n=1,this.swap(a,n.quotient,r);case 1:return s=(c=e.v).sqrtRatioX96,d=c.liquidity,p=c.tickCurrent,e.a(2,[i.CurrencyAmount.fromRawAmount(a?this.token1:this.token0,o.multiply(c.amountCalculated,F)),new t(this.token0,this.token1,this.fee,s,d,p,this.tickDataProvider)])}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),e.getInputAmount=function(){var e=T(x().m((function e(n,r){var a,c,s,d,p;return x().w((function(e){for(;;)switch(e.n){case 0:return n.currency.isToken&&this.involvesToken(n.currency)||u(!1),a=n.currency.equals(this.token1),e.n=1,this.swap(a,o.multiply(n.quotient,F),r);case 1:return s=(c=e.v).sqrtRatioX96,d=c.liquidity,p=c.tickCurrent,e.a(2,[i.CurrencyAmount.fromRawAmount(a?this.token0:this.token1,c.amountCalculated),new t(this.token0,this.token1,this.fee,s,d,p,this.tickDataProvider)])}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),e.swap=function(){var t=T(x().m((function t(e,n,r){return x().w((function(t){for(;;)switch(t.n){case 0:return t.a(2,tt(o.BigInt(this.fee),this.sqrtRatioX96,this.tickCurrent,this.liquidity,this.tickSpacing,this.tickDataProvider,e,n,r))}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),I(t,[{key:"token0Price",get:function(){var t;return null!=(t=this._token0Price)?t:this._token0Price=new i.Price(this.token0,this.token1,D,o.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}},{key:"token1Price",get:function(){var t;return null!=(t=this._token1Price)?t:this._token1Price=new i.Price(this.token1,this.token0,o.multiply(this.sqrtRatioX96,this.sqrtRatioX96),D)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"tickSpacing",get:function(){return N[this.fee]}}])}(),wt=function(){function t(t){var e=t.pool,n=t.liquidity,r=t.tickLower,i=t.tickUpper;this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,r<i||u(!1),r>=J.MIN_TICK&&r%e.tickSpacing==0||u(!1),i<=J.MAX_TICK&&i%e.tickSpacing==0||u(!1),this.pool=e,this.tickLower=r,this.tickUpper=i,this.liquidity=o.BigInt(n)}var e=t.prototype;return e.ratiosAfterSlippage=function(t){var e=this.pool.token0Price.asFraction.multiply(new i.Percent(1).subtract(t)),n=this.pool.token0Price.asFraction.multiply(t.add(1)),r=ct(e.numerator,e.denominator);o.lessThanOrEqual(r,J.MIN_SQRT_RATIO)&&(r=o.add(J.MIN_SQRT_RATIO,o.BigInt(1)));var u=ct(n.numerator,n.denominator);return o.greaterThanOrEqual(u,J.MAX_SQRT_RATIO)&&(u=o.subtract(J.MAX_SQRT_RATIO,o.BigInt(1))),{sqrtRatioX96Lower:r,sqrtRatioX96Upper:u}},e.mintAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new It(this.pool.token0,this.pool.token1,this.pool.fee,i,0,J.getTickAtSqrtRatio(i)),u=new It(this.pool.token0,this.pool.token1,this.pool.fee,r,0,J.getTickAtSqrtRatio(r)),a=t.fromAmounts(q({pool:this.pool,tickLower:this.tickLower,tickUpper:this.tickUpper},this.mintAmounts,{useFullPrecision:!1}));return{amount0:new t({pool:u,liquidity:a.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount0,amount1:new t({pool:o,liquidity:a.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount1}},e.burnAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new It(this.pool.token0,this.pool.token1,this.pool.fee,i,0,J.getTickAtSqrtRatio(i)),u=new t({pool:new It(this.pool.token0,this.pool.token1,this.pool.fee,r,0,J.getTickAtSqrtRatio(r)),liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,a=new t({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:u.quotient,amount1:a.quotient}},t.fromAmounts=function(e){var n=e.pool,r=e.tickLower,i=e.tickUpper,o=e.amount0,u=e.amount1,a=e.useFullPrecision,c=J.getSqrtRatioAtTick(r),s=J.getSqrtRatioAtTick(i);return new t({pool:n,tickLower:r,tickUpper:i,liquidity:lt(n.sqrtRatioX96,c,s,o,u,a)})},t.fromAmount0=function(e){return t.fromAmounts({pool:e.pool,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0:e.amount0,amount1:i.MaxUint256,useFullPrecision:e.useFullPrecision})},t.fromAmount1=function(e){return t.fromAmounts({pool:e.pool,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0:i.MaxUint256,amount1:e.amount1,useFullPrecision:!0})},I(t,[{key:"token0PriceLower",get:function(){return ht(this.pool.token0,this.pool.token1,this.tickLower)}},{key:"token0PriceUpper",get:function(){return ht(this.pool.token0,this.pool.token1,this.tickUpper)}},{key:"amount0",get:function(){return null===this._token0Amount&&(this._token0Amount=i.CurrencyAmount.fromRawAmount(this.pool.token0,this.pool.tickCurrent<this.tickLower?H.getAmount0Delta(J.getSqrtRatioAtTick(this.tickLower),J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):this.pool.tickCurrent<this.tickUpper?H.getAmount0Delta(this.pool.sqrtRatioX96,J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):X)),this._token0Amount}},{key:"amount1",get:function(){return null===this._token1Amount&&(this._token1Amount=i.CurrencyAmount.fromRawAmount(this.pool.token1,this.pool.tickCurrent<this.tickLower?X:H.getAmount1Delta(J.getSqrtRatioAtTick(this.tickLower),this.pool.tickCurrent<this.tickUpper?this.pool.sqrtRatioX96:J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}},{key:"mintAmounts",get:function(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:H.getAmount0Delta(J.getSqrtRatioAtTick(this.tickLower),J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:X}:this.pool.tickCurrent<this.tickUpper?{amount0:H.getAmount0Delta(this.pool.sqrtRatioX96,J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:H.getAmount1Delta(J.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:X,amount1:H.getAmount1Delta(J.getSqrtRatioAtTick(this.tickLower),J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}}])}(),qt=function(){return I((function(t,e,n){this._midPrice=null,t.length>0||u(!1);var r=t[0].chainId;t.every((function(t){return t.chainId===r}))||u(!1);var i=e.wrapped;t[0].involvesToken(i)||u(!1),t[t.length-1].involvesToken(n.wrapped)||u(!1);for(var o,a=[i],c=w(t.entries());!(o=c()).done;){var s=o.value,d=s[1],p=a[s[0]];p.equals(d.token0)||p.equals(d.token1)||u(!1);var l=p.equals(d.token0)?d.token1:d.token0;a.push(l)}this.pools=t,this.tokenPath=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.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 i.Price(this.input,this.output,t.denominator,t.numerator)}}])}();function xt(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||u(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||u(!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 Rt=function(){function t(t){var e=t.routes,n=t.tradeType,r=e[0].inputAmount.currency,i=e[0].outputAmount.currency;e.every((function(t){return r.wrapped.equals(t.route.input.wrapped)}))||u(!1),e.every((function(t){return i.wrapped.equals(t.route.output.wrapped)}))||u(!1);for(var o,a=e.map((function(t){return t.route.pools.length})).reduce((function(t,e){return t+e}),0),c=new Set,s=w(e);!(o=s()).done;)for(var d,p=w(o.value.route.pools);!(d=p()).done;){var l=d.value;c.add(It.getAddress(l.token0,l.token1,l.fee))}a!==c.size&&u(!1),this.swaps=e,this.tradeType=n}t.exactIn=function(){var e=T(x().m((function e(n,r){return x().w((function(e){for(;;)switch(e.n){case 0:return e.a(2,t.fromRoute(n,r,i.TradeType.EXACT_INPUT))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.exactOut=function(){var e=T(x().m((function e(n,r){return x().w((function(e){for(;;)switch(e.n){case 0:return e.a(2,t.fromRoute(n,r,i.TradeType.EXACT_OUTPUT))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.fromRoute=function(){var e=T(x().m((function e(n,r,o){var a,c,s,d,p,l,f;return x().w((function(e){for(;;)switch(e.n){case 0:if(a=new Array(n.tokenPath.length),o!==i.TradeType.EXACT_INPUT){e.n=5;break}r.currency.equals(n.input)||u(!1),a[0]=r.wrapped,d=0;case 1:if(!(d<n.tokenPath.length-1)){e.n=4;break}return p=n.pools[d],e.n=2,p.getOutputAmount(a[d]);case 2:a[d+1]=e.v[0];case 3:d++,e.n=1;break;case 4:c=i.CurrencyAmount.fromFractionalAmount(n.input,r.numerator,r.denominator),s=i.CurrencyAmount.fromFractionalAmount(n.output,a[a.length-1].numerator,a[a.length-1].denominator),e.n=10;break;case 5:r.currency.equals(n.output)||u(!1),a[a.length-1]=r.wrapped,l=n.tokenPath.length-1;case 6:if(!(l>0)){e.n=9;break}return f=n.pools[l-1],e.n=7,f.getInputAmount(a[l]);case 7:a[l-1]=e.v[0];case 8:l--,e.n=6;break;case 9:c=i.CurrencyAmount.fromFractionalAmount(n.input,a[0].numerator,a[0].denominator),s=i.CurrencyAmount.fromFractionalAmount(n.output,r.numerator,r.denominator);case 10:return e.a(2,new t({routes:[{inputAmount:c,outputAmount:s,route:n}],tradeType:o}))}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.fromRoutes=function(){var e=T(x().m((function e(n,r){var o,a,c,s,d,p,l,f,m,h,k,A,v;return x().w((function(e){for(;;)switch(e.n){case 0:o=[],a=w(n);case 1:if((c=a()).done){e.n=13;break}if(d=(s=c.value).route,p=s.amount,l=new Array(d.tokenPath.length),f=void 0,m=void 0,r!==i.TradeType.EXACT_INPUT){e.n=6;break}p.currency.equals(d.input)||u(!1),f=i.CurrencyAmount.fromFractionalAmount(d.input,p.numerator,p.denominator),l[0]=i.CurrencyAmount.fromFractionalAmount(d.input.wrapped,p.numerator,p.denominator),h=0;case 2:if(!(h<d.tokenPath.length-1)){e.n=5;break}return k=d.pools[h],e.n=3,k.getOutputAmount(l[h]);case 3:l[h+1]=e.v[0];case 4:h++,e.n=2;break;case 5:m=i.CurrencyAmount.fromFractionalAmount(d.output,l[l.length-1].numerator,l[l.length-1].denominator),e.n=11;break;case 6:p.currency.equals(d.output)||u(!1),m=i.CurrencyAmount.fromFractionalAmount(d.output,p.numerator,p.denominator),l[l.length-1]=i.CurrencyAmount.fromFractionalAmount(d.output.wrapped,p.numerator,p.denominator),A=d.tokenPath.length-1;case 7:if(!(A>0)){e.n=10;break}return v=d.pools[A-1],e.n=8,v.getInputAmount(l[A]);case 8:l[A-1]=e.v[0];case 9:A--,e.n=7;break;case 10:f=i.CurrencyAmount.fromFractionalAmount(d.input,l[0].numerator,l[0].denominator);case 11:o.push({route:d,inputAmount:f,outputAmount:m});case 12:e.n=1;break;case 13:return e.a(2,new t({routes:o,tradeType:r}))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.createUncheckedTrade=function(e){return new t(q({},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(X)&&u(!1),this.tradeType===i.TradeType.EXACT_OUTPUT)return e;var n=new i.Fraction(U).add(t).invert().multiply(e.quotient).quotient;return i.CurrencyAmount.fromRawAmount(e.currency,n)},e.maximumAmountIn=function(t,e){if(void 0===e&&(e=this.inputAmount),t.lessThan(X)&&u(!1),this.tradeType===i.TradeType.EXACT_INPUT)return e;var n=new i.Fraction(U).add(t).multiply(e.quotient).quotient;return i.CurrencyAmount.fromRawAmount(e.currency,n)},e.worstExecutionPrice=function(t){return new i.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactIn=function(){var e=T(x().m((function e(n,r,o,a,c,s,d){var p,l,f,m,h,k,A,v,y,T,g,I,w,q;return x().w((function(e){for(;;)switch(e.p=e.n){case 0:f=void 0===(l=(p=void 0===a?{}:a).maxNumResults)?3:l,h=void 0===(m=p.maxHops)?3:m,void 0===c&&(c=[]),void 0===s&&(s=r),void 0===d&&(d=[]),n.length>0||u(!1),h>0||u(!1),r===s||c.length>0||u(!1),k=s.wrapped,A=o.wrapped,v=0;case 1:if(!(v<n.length)){e.n=11;break}if((y=n[v]).token0.equals(k.currency)||y.token1.equals(k.currency)){e.n=2;break}return e.a(3,10);case 2:return T=void 0,e.p=3,e.n=4,y.getOutputAmount(k);case 4:T=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(!T.currency.isToken||!T.currency.equals(A)){e.n=9;break}return w=i.sortedInsert,q=d,e.n=8,t.fromRoute(new qt([].concat(c,[y]),r.currency,o),r,i.TradeType.EXACT_INPUT);case 8:w(q,e.v,f,xt),e.n=10;break;case 9:if(!(h>1&&n.length>1)){e.n=10;break}return g=n.slice(0,v).concat(n.slice(v+1,n.length)),e.n=10,t.bestTradeExactIn(g,r,o,{maxNumResults:f,maxHops:h-1},[].concat(c,[y]),T,d);case 10:v++,e.n=1;break;case 11:return e.a(2,d)}}),e,null,[[3,5]])})));return function(t,n,r,i,o,u,a){return e.apply(this,arguments)}}(),t.bestTradeExactOut=function(){var e=T(x().m((function e(n,r,o,a,c,s,d){var p,l,f,m,h,k,A,v,y,T,g,I,w,q;return x().w((function(e){for(;;)switch(e.p=e.n){case 0:f=void 0===(l=(p=void 0===a?{}:a).maxNumResults)?3:l,h=void 0===(m=p.maxHops)?3:m,void 0===c&&(c=[]),void 0===s&&(s=o),void 0===d&&(d=[]),n.length>0||u(!1),h>0||u(!1),o===s||c.length>0||u(!1),k=s.wrapped,A=r.wrapped,v=0;case 1:if(!(v<n.length)){e.n=11;break}if((y=n[v]).token0.equals(k.currency)||y.token1.equals(k.currency)){e.n=2;break}return e.a(3,10);case 2:return T=void 0,e.p=3,e.n=4,y.getInputAmount(k);case 4:T=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(!T.currency.equals(A)){e.n=9;break}return w=i.sortedInsert,q=d,e.n=8,t.fromRoute(new qt([y].concat(c),r,o.currency),o,i.TradeType.EXACT_OUTPUT);case 8:w(q,e.v,f,xt),e.n=10;break;case 9:if(!(h>1&&n.length>1)){e.n=10;break}return g=n.slice(0,v).concat(n.slice(v+1,n.length)),e.n=10,t.bestTradeExactOut(g,r,o,{maxNumResults:f,maxHops:h-1},[y].concat(c),T,d);case 10:v++,e.n=1;break;case 11:return e.a(2,d)}}),e,null,[[3,5]])})));return function(t,n,r,i,o,u,a){return e.apply(this,arguments)}}(),I(t,[{key:"route",get:function(){return 1!==this.swaps.length&&u(!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)}),i.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)}),i.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 i.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=i.CurrencyAmount.fromRawAmount(this.outputAmount.currency,0),n=w(this.swaps);!(t=n()).done;){var r=t.value;e=e.add(r.route.midPrice.quote(r.inputAmount))}var o=e.subtract(this.outputAmount).divide(e);return this._priceImpact=new i.Percent(o.numerator,o.denominator),this._priceImpact}}])}(),bt=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}();bt.INTERFACE=new a.Interface(d.abi);var Pt=function(){function t(){}return t.encodePermit=function(e,n){return"nonce"in n?t.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,ut(n.nonce),ut(n.expiry),n.v,n.r,n.s]):t.INTERFACE.encodeFunctionData("selfPermit",[e.address,ut(n.amount),ut(n.deadline),n.v,n.r,n.s])},t}();Pt.INTERFACE=new a.Interface(l.abi);var Ct=function(){function t(){}return t.encodeFeeBips=function(t){return ut(t.multiply(1e4).quotient)},t.encodeUnwrapWETH9=function(e,n,r){if(n=i.validateAndParseAddress(n),r){var o=this.encodeFeeBips(r.fee),u=i.validateAndParseAddress(r.recipient);return t.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[ut(e),n,o,u])}return t.INTERFACE.encodeFunctionData("unwrapWETH9",[ut(e),n])},t.encodeSweepToken=function(e,n,r,o){if(r=i.validateAndParseAddress(r),o){var u=this.encodeFeeBips(o.fee),a=i.validateAndParseAddress(o.recipient);return t.INTERFACE.encodeFunctionData("sweepTokenWithFee",[e.address,ut(n),r,u,a])}return t.INTERFACE.encodeFunctionData("sweepToken",[e.address,ut(n),r])},t.encodeRefundETH=function(){return t.INTERFACE.encodeFunctionData("refundETH")},t}();Ct.INTERFACE=new a.Interface(f.abi);var Et=["expectedCurrencyOwed0","expectedCurrencyOwed1"],Ot=ut(o.subtract(o.exponentiate(o.BigInt(2),o.BigInt(128)),o.BigInt(1)));function St(t){return Object.keys(t).some((function(t){return"recipient"===t}))}var _t=function(){function t(){}return t.encodeCreate=function(e){return t.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[e.token0.address,e.token1.address,e.fee,ut(e.sqrtRatioX96)])},t.createCallParameters=function(t){return{calldata:this.encodeCreate(t),value:ut(0)}},t.addCallParameters=function(e,n){o.greaterThan(e.liquidity,X)||u(!1);var r=[],a=e.mintAmounts,c=a.amount0,s=a.amount1,d=e.mintAmountsWithSlippage(n.slippageTolerance),p=ut(d.amount0),l=ut(d.amount1),f=ut(n.deadline);if(St(n)&&n.createPool&&r.push(this.encodeCreate(e.pool)),n.token0Permit&&r.push(Pt.encodePermit(e.pool.token0,n.token0Permit)),n.token1Permit&&r.push(Pt.encodePermit(e.pool.token1,n.token1Permit)),St(n)){var m=i.validateAndParseAddress(n.recipient);r.push(t.INTERFACE.encodeFunctionData("mint",[{token0:e.pool.token0.address,token1:e.pool.token1.address,fee:e.pool.fee,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0Desired:ut(c),amount1Desired:ut(s),amount0Min:p,amount1Min:l,recipient:m,deadline:f}]))}else r.push(t.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:ut(n.tokenId),amount0Desired:ut(c),amount1Desired:ut(s),amount0Min:p,amount1Min:l,deadline:f}]));var h=ut(0);if(n.useNative){var k=n.useNative.wrapped;e.pool.token0.equals(k)||e.pool.token1.equals(k)||u(!1);var A=e.pool.token0.equals(k)?c:s;o.greaterThan(A,X)&&r.push(Ct.encodeRefundETH()),h=ut(A)}return{calldata:bt.encodeMulticall(r),value:h}},t.encodeCollect=function(e){var n=[],r=ut(e.tokenId),o=e.expectedCurrencyOwed0.currency.isNative||e.expectedCurrencyOwed1.currency.isNative,u=i.validateAndParseAddress(e.recipient);if(n.push(t.INTERFACE.encodeFunctionData("collect",[{tokenId:r,recipient:o?E:u,amount0Max:Ot,amount1Max:Ot}])),o){var a=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.currency:e.expectedCurrencyOwed0.currency,c=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.quotient:e.expectedCurrencyOwed0.quotient;n.push(Ct.encodeUnwrapWETH9(e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed0.quotient:e.expectedCurrencyOwed1.quotient,u)),n.push(Ct.encodeSweepToken(a,c,u))}return n},t.collectCallParameters=function(e){var n=t.encodeCollect(e);return{calldata:bt.encodeMulticall(n),value:ut(0)}},t.removeCallParameters=function(e,n){var r=[],a=ut(n.deadline),c=ut(n.tokenId),s=new wt({pool:e.pool,liquidity:n.liquidityPercentage.multiply(e.liquidity).quotient,tickLower:e.tickLower,tickUpper:e.tickUpper});o.greaterThan(s.liquidity,X)||u(!1);var d=s.burnAmountsWithSlippage(n.slippageTolerance),p=d.amount0,l=d.amount1;n.permit&&r.push(t.INTERFACE.encodeFunctionData("permit",[i.validateAndParseAddress(n.permit.spender),c,ut(n.permit.deadline),n.permit.v,n.permit.r,n.permit.s])),r.push(t.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:c,liquidity:ut(s.liquidity),amount0Min:ut(p),amount1Min:ut(l),deadline:a}]));var f=n.collectOptions,m=f.expectedCurrencyOwed0,h=f.expectedCurrencyOwed1,k=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(f,Et);return r.push.apply(r,t.encodeCollect(q({tokenId:ut(n.tokenId),expectedCurrencyOwed0:m.add(i.CurrencyAmount.fromRawAmount(m.currency,p)),expectedCurrencyOwed1:h.add(i.CurrencyAmount.fromRawAmount(h.currency,l))},k))),n.liquidityPercentage.equalTo(U)?n.burnToken&&r.push(t.INTERFACE.encodeFunctionData("burn",[c])):!0===n.burnToken&&u(!1),{calldata:bt.encodeMulticall(r),value:ut(0)}},t.safeTransferFromParameters=function(e){var n=i.validateAndParseAddress(e.recipient),r=i.validateAndParseAddress(e.sender);return{calldata:e.data?t.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)",[r,n,ut(e.tokenId),e.data]):t.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256)",[r,n,ut(e.tokenId)]),value:ut(0)}},t}();_t.INTERFACE=new a.Interface(p.abi);var Nt=function(){function t(){}return t.quoteCallParameters=function(t,e,n,r){void 0===r&&(r={});var o,a=1===t.pools.length,c=ut(e.quotient),s=r.useQuoterV2?this.V2INTERFACE:this.V1INTERFACE;if(a){var d,p,l={tokenIn:t.tokenPath[0].address,tokenOut:t.tokenPath[1].address,fee:t.pools[0].fee,sqrtPriceLimitX96:ut(null!=(d=null==(p=r)?void 0:p.sqrtPriceLimitX96)?d:0)},f=q({},l,n===i.TradeType.EXACT_INPUT?{amountIn:c}:{amount:c});o=s.encodeFunctionData(n===i.TradeType.EXACT_INPUT?"quoteExactInputSingle":"quoteExactOutputSingle",r.useQuoterV2?[f]:[l.tokenIn,l.tokenOut,l.fee,c,l.sqrtPriceLimitX96])}else{var m;void 0!==(null==(m=r)?void 0:m.sqrtPriceLimitX96)&&u(!1);var h=at(t,n===i.TradeType.EXACT_OUTPUT);o=s.encodeFunctionData(n===i.TradeType.EXACT_INPUT?"quoteExactInput":"quoteExactOutput",[h,c])}return{calldata:o,value:ut(0)}},t}();Nt.V1INTERFACE=new a.Interface(m.abi),Nt.V2INTERFACE=new a.Interface(h.abi);var Ft=function(){function t(){}return t.encodeClaim=function(e,n){var r,o=[];o.push(t.INTERFACE.encodeFunctionData("unstakeToken",[this._encodeIncentiveKey(e),ut(n.tokenId)]));var u=i.validateAndParseAddress(n.recipient),a=null!=(r=n.amount)?r:0;return o.push(t.INTERFACE.encodeFunctionData("claimReward",[e.rewardToken.address,u,ut(a)])),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),ut(n.tokenId)]))}return{calldata:bt.encodeMulticall(r),value:ut(0)}},t.withdrawToken=function(e,n){var r=[];e=Array.isArray(e)?e:[e];for(var o={tokenId:n.tokenId,recipient:n.recipient,amount:n.amount},u=0;u<e.length;u++)r=r.concat(this.encodeClaim(e[u],o));var a=i.validateAndParseAddress(n.owner);return r.push(t.INTERFACE.encodeFunctionData("withdrawToken",[ut(n.tokenId),a,n.data?n.data:ut(0)])),{calldata:bt.encodeMulticall(r),value:ut(0)}},t.encodeDeposit=function(e){var n;if((e=Array.isArray(e)?e:[e]).length>1){for(var r=[],i=0;i<e.length;i++)r.push(this._encodeIncentiveKey(e[i]));n=a.defaultAbiCoder.encode([t.INCENTIVE_KEY_ABI+"[]"],[r])}else n=a.defaultAbiCoder.encode([t.INCENTIVE_KEY_ABI],[this._encodeIncentiveKey(e[0])]);return n},t._encodeIncentiveKey=function(t){var e=t.pool,n=e.token0,r=e.token1,o=e.fee,u=i.validateAndParseAddress(t.refundee);return{rewardToken:t.rewardToken.address,pool:It.getAddress(n,r,o),startTime:ut(t.startTime),endTime:ut(t.endTime),refundee:u}},t}();Ft.INTERFACE=new a.Interface(k.abi),Ft.INCENTIVE_KEY_ABI="tuple(address rewardToken, address pool, uint256 startTime, uint256 endTime, address refundee)";var Xt=function(){function t(){}return t.swapCallParameters=function(e,n){Array.isArray(e)||(e=[e]);var r=e[0],o=r.inputAmount.currency.wrapped,a=r.outputAmount.currency.wrapped;e.every((function(t){return t.inputAmount.currency.wrapped.equals(o)}))||u(!1),e.every((function(t){return t.outputAmount.currency.wrapped.equals(a)}))||u(!1);var c=[],s=i.CurrencyAmount.fromRawAmount(e[0].inputAmount.currency,0),d=i.CurrencyAmount.fromRawAmount(e[0].outputAmount.currency,0),p=e.reduce((function(t,e){return t.add(e.minimumAmountOut(n.slippageTolerance))}),d),l=r.inputAmount.currency.isNative&&r.tradeType===i.TradeType.EXACT_OUTPUT,f=r.outputAmount.currency.isNative,m=f||!!n.fee,h=r.inputAmount.currency.isNative?e.reduce((function(t,e){return t.add(e.maximumAmountIn(n.slippageTolerance))}),s):s;n.inputTokenPermit&&(r.inputAmount.currency.isToken||u(!1),c.push(Pt.encodePermit(r.inputAmount.currency,n.inputTokenPermit)));for(var k,A=i.validateAndParseAddress(n.recipient),v=ut(n.deadline),y=w(e);!(k=y()).done;)for(var T,g=k.value,I=w(g.swaps);!(T=I()).done;){var q=T.value,x=q.route,R=q.outputAmount,b=ut(g.maximumAmountIn(n.slippageTolerance,q.inputAmount).quotient),P=ut(g.minimumAmountOut(n.slippageTolerance,R).quotient);if(1===x.pools.length)if(g.tradeType===i.TradeType.EXACT_INPUT){var C,O={tokenIn:x.tokenPath[0].address,tokenOut:x.tokenPath[1].address,fee:x.pools[0].fee,recipient:m?E:A,deadline:v,amountIn:b,amountOutMinimum:P,sqrtPriceLimitX96:ut(null!=(C=n.sqrtPriceLimitX96)?C:0)};c.push(t.INTERFACE.encodeFunctionData("exactInputSingle",[O]))}else{var S,_={tokenIn:x.tokenPath[0].address,tokenOut:x.tokenPath[1].address,fee:x.pools[0].fee,recipient:m?E:A,deadline:v,amountOut:P,amountInMaximum:b,sqrtPriceLimitX96:ut(null!=(S=n.sqrtPriceLimitX96)?S:0)};c.push(t.INTERFACE.encodeFunctionData("exactOutputSingle",[_]))}else{void 0!==n.sqrtPriceLimitX96&&u(!1);var N=at(x,g.tradeType===i.TradeType.EXACT_OUTPUT);c.push(g.tradeType===i.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("exactInput",[{path:N,recipient:m?E:A,deadline:v,amountIn:b,amountOutMinimum:P}]):t.INTERFACE.encodeFunctionData("exactOutput",[{path:N,recipient:m?E:A,deadline:v,amountOut:P,amountInMaximum:b}]))}}return m&&c.push(n.fee?f?Ct.encodeUnwrapWETH9(p.quotient,A,n.fee):Ct.encodeSweepToken(r.outputAmount.currency.wrapped,p.quotient,A,n.fee):Ct.encodeUnwrapWETH9(p.quotient,A)),l&&c.push(Ct.encodeRefundETH()),{calldata:bt.encodeMulticall(c),value:ut(h.quotient)}},t}();Xt.INTERFACE=new a.Interface(A.abi),exports.ADDRESS_ZERO=E,exports.FACTORY_ADDRESS="0x8E994Dbd9d91dF55A711D24B14739ab410CAC1E7",exports.FACTORY_ADDRESS_BY_CHAIN_ID=C,exports.FullMath=L,exports.LiquidityMath=Q,exports.Multicall=bt,exports.NoTickDataProvider=nt,exports.NonfungiblePositionManager=_t,exports.POOL_INIT_CODE_HASH=O,exports.POOL_INIT_CODE_HASH_BY_CHAIN_ID=S,exports.Payments=Ct,exports.Pool=It,exports.Position=wt,exports.PositionLibrary=mt,exports.Route=qt,exports.SelfPermit=Pt,exports.SqrtPriceMath=H,exports.Staker=Ft,exports.SwapMath=G,exports.SwapQuoter=Nt,exports.SwapRouter=Xt,exports.TICK_SPACINGS=N,exports.Tick=yt,exports.TickLibrary=vt,exports.TickList=ot,exports.TickListDataProvider=Tt,exports.TickMath=J,exports.Trade=Rt,exports.computePoolAddress=M,exports.encodeRouteToPath=at,exports.encodeSqrtRatioX96=ct,exports.isSorted=rt,exports.maxLiquidityForAmounts=lt,exports.mostSignificantBit=Y,exports.nearestUsableTick=function(t,e){Number.isInteger(t)&&Number.isInteger(e)||u(!1),e>0||u(!1),t>=J.MIN_TICK&&t<=J.MAX_TICK||u(!1);var n=Math.round(t/e)*e;return n<J.MIN_TICK?n+e:n>J.MAX_TICK?n-e:n},exports.poolInitCodeHash=_,exports.priceToClosestTick=function(t){var e=t.baseCurrency.sortsBefore(t.quoteCurrency),n=e?ct(t.numerator,t.denominator):ct(t.denominator,t.numerator),r=J.getTickAtSqrtRatio(n),i=ht(t.baseCurrency,t.quoteCurrency,r+1);return e?t.lessThan(i)||r++:t.greaterThan(i)||r++,r},exports.subIn256=At,exports.tickToPrice=ht,exports.toHex=ut,exports.tradeComparator=xt,exports.v3Swap=tt;
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,i=require("@kayenfinance/sdk-core"),o=t(require("jsbi")),u=t(require("tiny-invariant")),a=require("@ethersproject/abi"),c=require("@ethersproject/address"),s=require("@ethersproject/solidity"),d=t(require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IMulticall.sol/IMulticall.json")),p=t(require("@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json")),l=t(require("@uniswap/v3-periphery/artifacts/contracts/interfaces/ISelfPermit.sol/ISelfPermit.json")),f=t(require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IPeripheryPaymentsWithFee.sol/IPeripheryPaymentsWithFee.json")),m=t(require("@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json")),h=t(require("@uniswap/swap-router-contracts/artifacts/contracts/lens/QuoterV2.sol/QuoterV2.json")),k=t(require("@uniswap/v3-staker/artifacts/contracts/UniswapV3Staker.sol/UniswapV3Staker.json")),A=t(require("@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json"));function v(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 y(t,e,n,r,i,o,u){try{var a=t[o](u),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,i)}function T(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function u(t){y(o,r,i,u,a,"next",t)}function a(t){y(o,r,i,u,a,"throw",t)}u(void 0)}))}}function g(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(r.key),r)}}function I(t,e,n){return e&&g(t.prototype,e),n&&g(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function w(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 v(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)?v(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 q(){return(q=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 x(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=Object.create((r&&r.prototype instanceof a?r:a).prototype);return b(c,"_invoke",function(n,r,i){var o,a,c,s=0,d=i||[],p=!1,l={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,n){return o=e,a=0,c=t,l.n=n,u}};function f(n,r){for(a=n,c=r,e=0;!p&&s&&!i&&e<d.length;e++){var i,o=d[e],f=l.p,m=o[2];n>3?(i=m===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=f&&((i=n<2&&f<o[1])?(a=0,l.v=r,l.n=o[1]):f<m&&(i=n<3||o[0]>r||r>m)&&(o[4]=n,o[5]=r,l.n=m,a=0))}if(i||n>1)return u;throw p=!0,r}return function(i,d,m){if(s>1)throw TypeError("Generator is already running");for(p&&1===d&&f(d,m),a=d,c=m;(e=a<2?t:c)||!p;){o||(a?a<3?(a>1&&(l.n=-1),f(a,c)):l.n=c:l.v=c);try{if(s=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(p=l.n<0)?c:n.call(r,l))!==u)break}catch(e){o=t,a=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,i,o),!0),c}var u={};function a(){}function c(){}function s(){}e=Object.getPrototypeOf;var d=[][r]?e(e([][r]())):(b(e={},r,(function(){return this})),e),p=s.prototype=a.prototype=Object.create(d);function l(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,b(t,i,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,b(p,"constructor",s),b(s,"constructor",c),c.displayName="GeneratorFunction",b(s,i,"GeneratorFunction"),b(p),b(p,i,"Generator"),b(p,r,(function(){return this})),b(p,"toString",(function(){return"[object Generator]"})),(x=function(){return{w:o,m:l}})()}function b(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}(b=function(t,e,n,r){function o(e,n){b(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 R(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+""}var C,P=((e={})[i.ChainId.CHILIZ]="0x4bC8BDF50843Cc503E196Be4A9560134d358bb3C",e[i.ChainId.SPICY]="0x9Fc08909577539c635F04ef924f65c56560c8BD3",e),E="0x0000000000000000000000000000000000000000",O="0xcb96d536c98123b475b91f2f81bd6d5877fb48561b42d7892f4725df4c8cce7e",S=((n={})[i.ChainId.CHILIZ]="0xcb96d536c98123b475b91f2f81bd6d5877fb48561b42d7892f4725df4c8cce7e",n[i.ChainId.SPICY]="0xcb96d536c98123b475b91f2f81bd6d5877fb48561b42d7892f4725df4c8cce7e",n);function _(t){var e;return null!=(e=S[t])?e:O}(C=exports.FeeAmount||(exports.FeeAmount={}))[C.LOWEST=100]="LOWEST",C[C.LOW_200=200]="LOW_200",C[C.LOW_300=300]="LOW_300",C[C.LOW_400=400]="LOW_400",C[C.LOW=500]="LOW",C[C.MEDIUM=3e3]="MEDIUM",C[C.HIGH=1e4]="HIGH";var N=((r={})[exports.FeeAmount.LOWEST]=1,r[exports.FeeAmount.LOW_200]=4,r[exports.FeeAmount.LOW_300]=6,r[exports.FeeAmount.LOW_400]=8,r[exports.FeeAmount.LOW]=10,r[exports.FeeAmount.MEDIUM]=60,r[exports.FeeAmount.HIGH]=200,r),F=o.BigInt(-1),X=o.BigInt(0),B=o.BigInt(1),U=o.exponentiate(o.BigInt(2),o.BigInt(96)),D=o.exponentiate(U,o.BigInt(2));function M(t){var e=t.factoryAddress,n=t.tokenA,r=t.tokenB,i=t.fee,o=t.initCodeHashManualOverride,u=t.chainId,d=n.sortsBefore(r)?[n,r]:[r,n],p=s.keccak256(["bytes"],[a.defaultAbiCoder.encode(["address","address","uint24"],[d[0].address,d[1].address,i])]),l=null!=o?o:_(u);return c.getCreate2Address(e,p,l)}var L=function(){function t(){}return t.mulDivRoundingUp=function(t,e,n){var r=o.multiply(t,e),i=o.divide(r,n);return o.notEqual(o.remainder(r,n),X)&&(i=o.add(i,B)),i},t}(),W=o.subtract(o.exponentiate(o.BigInt(2),o.BigInt(160)),B);function j(t,e){var n=o.multiply(t,e);return o.bitwiseAnd(n,i.MaxUint256)}var H=function(){function t(){}return t.getAmount0Delta=function(t,e,n,r){if(o.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}var u=o.leftShift(n,o.BigInt(96)),a=o.subtract(e,t);return r?L.mulDivRoundingUp(L.mulDivRoundingUp(u,a,e),B,t):o.divide(o.divide(o.multiply(u,a),e),t)},t.getAmount1Delta=function(t,e,n,r){if(o.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}return r?L.mulDivRoundingUp(n,o.subtract(e,t),U):o.divide(o.multiply(n,o.subtract(e,t)),U)},t.getNextSqrtPriceFromInput=function(t,e,n,r){return o.greaterThan(t,X)||u(!1),o.greaterThan(e,X)||u(!1),r?this.getNextSqrtPriceFromAmount0RoundingUp(t,e,n,!0):this.getNextSqrtPriceFromAmount1RoundingDown(t,e,n,!0)},t.getNextSqrtPriceFromOutput=function(t,e,n,r){return o.greaterThan(t,X)||u(!1),o.greaterThan(e,X)||u(!1),r?this.getNextSqrtPriceFromAmount1RoundingDown(t,e,n,!1):this.getNextSqrtPriceFromAmount0RoundingUp(t,e,n,!1)},t.getNextSqrtPriceFromAmount0RoundingUp=function(t,e,n,r){if(o.equal(n,X))return t;var a=o.leftShift(e,o.BigInt(96));if(r){var c=j(n,t);if(o.equal(o.divide(c,n),t)){var s=(p=o.add(a,c),o.bitwiseAnd(p,i.MaxUint256));if(o.greaterThanOrEqual(s,a))return L.mulDivRoundingUp(a,t,s)}return L.mulDivRoundingUp(a,B,o.add(o.divide(a,t),n))}var d=j(n,t);o.equal(o.divide(d,n),t)||u(!1),o.greaterThan(a,d)||u(!1);var p,l=o.subtract(a,d);return L.mulDivRoundingUp(a,t,l)},t.getNextSqrtPriceFromAmount1RoundingDown=function(t,e,n,r){if(r){var i=o.lessThanOrEqual(n,W)?o.divide(o.leftShift(n,o.BigInt(96)),e):o.divide(o.multiply(n,U),e);return o.add(t,i)}var a=L.mulDivRoundingUp(n,U,e);return o.greaterThan(t,a)||u(!1),o.subtract(t,a)},t}(),K=o.exponentiate(o.BigInt(10),o.BigInt(6)),G=function(){function t(){}return t.computeSwapStep=function(t,e,n,r,i){var u={};i=o.BigInt(i);var a=o.greaterThanOrEqual(t,e),c=o.greaterThanOrEqual(r,X);if(c){var s=o.divide(o.multiply(r,o.subtract(K,i)),K);u.amountIn=a?H.getAmount0Delta(e,t,n,!0):H.getAmount1Delta(t,e,n,!0),u.sqrtRatioNextX96=o.greaterThanOrEqual(s,u.amountIn)?e:H.getNextSqrtPriceFromInput(t,n,s,a)}else u.amountOut=a?H.getAmount1Delta(e,t,n,!1):H.getAmount0Delta(t,e,n,!1),u.sqrtRatioNextX96=o.greaterThanOrEqual(o.multiply(r,F),u.amountOut)?e:H.getNextSqrtPriceFromOutput(t,n,o.multiply(r,F),a);var d=o.equal(e,u.sqrtRatioNextX96);return a?(u.amountIn=d&&c?u.amountIn:H.getAmount0Delta(u.sqrtRatioNextX96,t,n,!0),u.amountOut=d&&!c?u.amountOut:H.getAmount1Delta(u.sqrtRatioNextX96,t,n,!1)):(u.amountIn=d&&c?u.amountIn:H.getAmount1Delta(t,u.sqrtRatioNextX96,n,!0),u.amountOut=d&&!c?u.amountOut:H.getAmount0Delta(t,u.sqrtRatioNextX96,n,!1)),!c&&o.greaterThan(u.amountOut,o.multiply(r,F))&&(u.amountOut=o.multiply(r,F)),u.feeAmount=c&&o.notEqual(u.sqrtRatioNextX96,e)?o.subtract(r,u.amountIn):L.mulDivRoundingUp(u.amountIn,i,o.subtract(K,i)),[u.sqrtRatioNextX96,u.amountIn,u.amountOut,u.feeAmount]},t}(),Q=function(){function t(){}return t.addDelta=function(t,e){return o.lessThan(e,X)?o.subtract(t,o.multiply(e,F)):o.add(t,e)},t}(),V=o.BigInt(2),z=[128,64,32,16,8,4,2,1].map((function(t){return[t,o.exponentiate(V,o.BigInt(t))]}));function Y(t){o.greaterThan(t,X)||u(!1),o.lessThanOrEqual(t,i.MaxUint256)||u(!1);for(var e,n=0,r=w(z);!(e=r()).done;){var a=e.value,c=a[0];o.greaterThanOrEqual(t,a[1])&&(t=o.signedRightShift(t,o.BigInt(c)),n+=c)}return n}function Z(t,e){return o.signedRightShift(o.multiply(t,o.BigInt(e)),o.BigInt(128))}var $=o.exponentiate(o.BigInt(2),o.BigInt(32)),J=function(){function t(){}return t.getSqrtRatioAtTick=function(e){e>=t.MIN_TICK&&e<=t.MAX_TICK&&Number.isInteger(e)||u(!1);var n=e<0?-1*e:e,r=o.BigInt(0!=(1&n)?"0xfffcb933bd6fad37aa2d162d1a594001":"0x100000000000000000000000000000000");return 0!=(2&n)&&(r=Z(r,"0xfff97272373d413259a46990580e213a")),0!=(4&n)&&(r=Z(r,"0xfff2e50f5f656932ef12357cf3c7fdcc")),0!=(8&n)&&(r=Z(r,"0xffe5caca7e10e4e61c3624eaa0941cd0")),0!=(16&n)&&(r=Z(r,"0xffcb9843d60f6159c9db58835c926644")),0!=(32&n)&&(r=Z(r,"0xff973b41fa98c081472e6896dfb254c0")),0!=(64&n)&&(r=Z(r,"0xff2ea16466c96a3843ec78b326b52861")),0!=(128&n)&&(r=Z(r,"0xfe5dee046a99a2a811c461f1969c3053")),0!=(256&n)&&(r=Z(r,"0xfcbe86c7900a88aedcffc83b479aa3a4")),0!=(512&n)&&(r=Z(r,"0xf987a7253ac413176f2b074cf7815e54")),0!=(1024&n)&&(r=Z(r,"0xf3392b0822b70005940c7a398e4b70f3")),0!=(2048&n)&&(r=Z(r,"0xe7159475a2c29b7443b29c7fa6e889d9")),0!=(4096&n)&&(r=Z(r,"0xd097f3bdfd2022b8845ad8f792aa5825")),0!=(8192&n)&&(r=Z(r,"0xa9f746462d870fdf8a65dc1f90e061e5")),0!=(16384&n)&&(r=Z(r,"0x70d869a156d2a1b890bb3df62baf32f7")),0!=(32768&n)&&(r=Z(r,"0x31be135f97d08fd981231505542fcfa6")),0!=(65536&n)&&(r=Z(r,"0x9aa508b5b7a84e1c677de54f3e99bc9")),0!=(131072&n)&&(r=Z(r,"0x5d6af8dedb81196699c329225ee604")),0!=(262144&n)&&(r=Z(r,"0x2216e584f5fa1ea926041bedfe98")),0!=(524288&n)&&(r=Z(r,"0x48a170391f7dc42444e8fa2")),e>0&&(r=o.divide(i.MaxUint256,r)),o.greaterThan(o.remainder(r,$),X)?o.add(o.divide(r,$),B):o.divide(r,$)},t.getTickAtSqrtRatio=function(e){o.greaterThanOrEqual(e,t.MIN_SQRT_RATIO)&&o.lessThan(e,t.MAX_SQRT_RATIO)||u(!1);var n,r=o.leftShift(e,o.BigInt(32)),i=Y(r);n=o.greaterThanOrEqual(o.BigInt(i),o.BigInt(128))?o.signedRightShift(r,o.BigInt(i-127)):o.leftShift(r,o.BigInt(127-i));for(var a=o.leftShift(o.subtract(o.BigInt(i),o.BigInt(128)),o.BigInt(64)),c=0;c<14;c++){n=o.signedRightShift(o.multiply(n,n),o.BigInt(127));var s=o.signedRightShift(n,o.BigInt(128));a=o.bitwiseOr(a,o.leftShift(s,o.BigInt(63-c))),n=o.signedRightShift(n,s)}var d=o.multiply(a,o.BigInt("255738958999603826347141")),p=o.toNumber(o.signedRightShift(o.subtract(d,o.BigInt("3402992956809132418596140100660247210")),o.BigInt(128))),l=o.toNumber(o.signedRightShift(o.add(d,o.BigInt("291339464771989622907027621153398088495")),o.BigInt(128)));return p===l?p:o.lessThanOrEqual(t.getSqrtRatioAtTick(l),e)?l:p},t}();function tt(t,e,n,r,i,o,u,a,c){return et.apply(this,arguments)}function et(){return(et=T(x().m((function t(e,n,r,i,a,c,s,d,p){var l,f,m,h,k,A,v;return x().w((function(t){for(;;)switch(t.n){case 0:p||(p=s?o.add(J.MIN_SQRT_RATIO,B):o.subtract(J.MAX_SQRT_RATIO,B)),s?(o.greaterThan(p,J.MIN_SQRT_RATIO)||u(!1),o.lessThan(p,n)||u(!1)):(o.lessThan(p,J.MAX_SQRT_RATIO)||u(!1),o.greaterThan(p,n)||u(!1)),l=o.greaterThanOrEqual(d,X),f={amountSpecifiedRemaining:d,amountCalculated:X,sqrtPriceX96:n,tick:r,liquidity:i};case 1:if(!o.notEqual(f.amountSpecifiedRemaining,X)||f.sqrtPriceX96===p){t.n=7;break}return(m={}).sqrtPriceStartX96=f.sqrtPriceX96,t.n=2,c.nextInitializedTickWithinOneWord(f.tick,s,a);case 2:if(m.tickNext=(h=t.v)[0],m.initialized=h[1],m.tickNext<J.MIN_TICK?m.tickNext=J.MIN_TICK:m.tickNext>J.MAX_TICK&&(m.tickNext=J.MAX_TICK),m.sqrtPriceNextX96=J.getSqrtRatioAtTick(m.tickNext),k=G.computeSwapStep(f.sqrtPriceX96,(s?o.lessThan(m.sqrtPriceNextX96,p):o.greaterThan(m.sqrtPriceNextX96,p))?p:m.sqrtPriceNextX96,f.liquidity,f.amountSpecifiedRemaining,e),f.sqrtPriceX96=k[0],m.amountIn=k[1],m.amountOut=k[2],m.feeAmount=k[3],l?(f.amountSpecifiedRemaining=o.subtract(f.amountSpecifiedRemaining,o.add(m.amountIn,m.feeAmount)),f.amountCalculated=o.subtract(f.amountCalculated,m.amountOut)):(f.amountSpecifiedRemaining=o.add(f.amountSpecifiedRemaining,m.amountOut),f.amountCalculated=o.add(f.amountCalculated,o.add(m.amountIn,m.feeAmount))),!o.equal(f.sqrtPriceX96,m.sqrtPriceNextX96)){t.n=5;break}if(!m.initialized){t.n=4;break}return v=o,t.n=3,c.getTick(m.tickNext);case 3:A=v.BigInt.call(v,t.v.liquidityNet),s&&(A=o.multiply(A,F)),f.liquidity=Q.addDelta(f.liquidity,A);case 4:f.tick=s?m.tickNext-1:m.tickNext,t.n=6;break;case 5:o.notEqual(f.sqrtPriceX96,m.sqrtPriceStartX96)&&(f.tick=J.getTickAtSqrtRatio(f.sqrtPriceX96));case 6:t.n=1;break;case 7:return t.a(2,{amountCalculated:f.amountCalculated,sqrtRatioX96:f.sqrtPriceX96,liquidity:f.liquidity,tickCurrent:f.tick})}}),t)})))).apply(this,arguments)}J.MIN_TICK=-887272,J.MAX_TICK=-J.MIN_TICK,J.MIN_SQRT_RATIO=o.BigInt("4295128739"),J.MAX_SQRT_RATIO=o.BigInt("1461446703485210103287273052203988822378723970342");var nt=function(){function t(){}var e=t.prototype;return e.getTick=function(){var e=T(x().m((function e(n){return x().w((function(e){for(;;)switch(e.n){case 0:throw new Error(t.ERROR_MESSAGE);case 1:return e.a(2)}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var e=T(x().m((function e(n,r,i){return x().w((function(e){for(;;)switch(e.n){case 0:throw new Error(t.ERROR_MESSAGE);case 1:return e.a(2)}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t}();function rt(t,e){for(var n=0;n<t.length-1;n++)if(e(t[n],t[n+1])>0)return!1;return!0}function it(t,e){return t.index-e.index}nt.ERROR_MESSAGE="No tick data provider was given";var ot=function(){function t(){}return t.validateList=function(t,e){e>0||u(!1),t.every((function(t){return t.index%e==0}))||u(!1),o.equal(t.reduce((function(t,e){return o.add(t,e.liquidityNet)}),X),X)||u(!1),rt(t,it)||u(!1)},t.isBelowSmallest=function(t,e){return t.length>0||u(!1),e<t[0].index},t.isAtOrAboveLargest=function(t,e){return t.length>0||u(!1),e>=t[t.length-1].index},t.getTick=function(t,e){var n=t[this.binarySearch(t,e)];return n.index!==e&&u(!1),n},t.binarySearch=function(t,e){this.isBelowSmallest(t,e)&&u(!1);for(var n,r=0,i=t.length-1;;){if(t[n=Math.floor((r+i)/2)].index<=e&&(n===t.length-1||t[n+1].index>e))return n;t[n].index<e?r=n+1:i=n-1}},t.nextInitializedTick=function(e,n,r){return r?(t.isBelowSmallest(e,n)&&u(!1),t.isAtOrAboveLargest(e,n)?e[e.length-1]:e[this.binarySearch(e,n)]):(this.isAtOrAboveLargest(e,n)&&u(!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 u=(o>>8<<8)*i;if(t.isBelowSmallest(e,n))return[u,!1];var a=t.nextInitializedTick(e,n,r).index,c=Math.max(u,a);return[c,c===a]}var s=((1+(o+1>>8)<<8)-1)*i;if(this.isAtOrAboveLargest(e,n))return[s,!1];var d=this.nextInitializedTick(e,n,r).index,p=Math.min(s,d);return[p,p===d]},t}();function ut(t){var e=o.BigInt(t).toString(16);return e.length%2!=0&&(e="0"+e),"0x"+e}function at(t,e){var n=t.pools.reduce((function(t,e,n){var r=t.inputToken,i=t.path,o=t.types,u=e.token0.equals(r)?e.token1:e.token0;return 0===n?{inputToken:u,types:["address","uint24","address"],path:[r.address,e.fee,u.address]}:{inputToken:u,types:[].concat(o,["uint24","address"]),path:[].concat(i,[e.fee,u.address])}}),{inputToken:t.input.wrapped,path:[],types:[]}),r=n.path,i=n.types;return e?s.pack(i.reverse(),r.reverse()):s.pack(i,r)}function ct(t,e){var n=o.leftShift(o.BigInt(t),o.BigInt(192)),r=o.BigInt(e),u=o.divide(n,r);return i.sqrt(u)}function st(t,e,n){if(o.greaterThan(t,e)){var r=[e,t];t=r[0],e=r[1]}var i=o.divide(o.multiply(t,e),U);return o.divide(o.multiply(o.BigInt(n),i),o.subtract(e,t))}function dt(t,e,n){if(o.greaterThan(t,e)){var r=[e,t];t=r[0],e=r[1]}var i=o.multiply(o.multiply(o.BigInt(n),t),e),u=o.multiply(U,o.subtract(e,t));return o.divide(i,u)}function pt(t,e,n){if(o.greaterThan(t,e)){var r=[e,t];t=r[0],e=r[1]}return o.divide(o.multiply(o.BigInt(n),U),o.subtract(e,t))}function lt(t,e,n,r,i,u){if(o.greaterThan(e,n)){var a=[n,e];e=a[0],n=a[1]}var c=u?dt:st;if(o.lessThanOrEqual(t,e))return c(e,n,r);if(o.lessThan(t,n)){var s=c(t,n,r),d=pt(e,t,i);return o.lessThan(s,d)?s:d}return pt(e,n,i)}var ft=o.exponentiate(o.BigInt(2),o.BigInt(128)),mt=function(){function t(){}return t.getTokensOwed=function(t,e,n,r,i){return[o.divide(o.multiply(At(r,t),n),ft),o.divide(o.multiply(At(i,e),n),ft)]},t}();function ht(t,e,n){var r=J.getSqrtRatioAtTick(n),u=o.multiply(r,r);return t.sortsBefore(e)?new i.Price(t,e,D,u):new i.Price(t,e,u,D)}var kt=o.exponentiate(o.BigInt(2),o.BigInt(256));function At(t,e){var n=o.subtract(t,e);return o.lessThan(n,X)?o.add(kt,n):n}var vt=function(){function t(){}return t.getFeeGrowthInside=function(t,e,n,r,i,o,u){var a,c,s,d;return i>=n?(a=t.feeGrowthOutside0X128,c=t.feeGrowthOutside1X128):(a=At(o,t.feeGrowthOutside0X128),c=At(u,t.feeGrowthOutside1X128)),i<r?(s=e.feeGrowthOutside0X128,d=e.feeGrowthOutside1X128):(s=At(o,e.feeGrowthOutside0X128),d=At(u,e.feeGrowthOutside1X128)),[At(At(o,a),s),At(At(u,c),d)]},t}(),yt=function(t){var e=t.index,n=t.liquidityGross,r=t.liquidityNet;e>=J.MIN_TICK&&e<=J.MAX_TICK||u(!1),this.index=e,this.liquidityGross=o.BigInt(n),this.liquidityNet=o.BigInt(r)},Tt=function(){function t(t,e){var n=t.map((function(t){return t instanceof yt?t:new yt(t)}));ot.validateList(n,e),this.ticks=n}var e=t.prototype;return e.getTick=function(){var t=T(x().m((function t(e){return x().w((function(t){for(;;)switch(t.n){case 0:return t.a(2,ot.getTick(this.ticks,e))}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var t=T(x().m((function t(e,n,r){return x().w((function(t){for(;;)switch(t.n){case 0:return t.a(2,ot.nextInitializedTickWithinOneWord(this.ticks,e,n,r))}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),t}(),gt=new nt,It=function(){function t(t,e,n,r,i,a,c){void 0===c&&(c=gt),Number.isInteger(n)&&n<1e6||u(!1);var s=J.getSqrtRatioAtTick(a),d=J.getSqrtRatioAtTick(a+1);o.greaterThanOrEqual(o.BigInt(r),s)&&o.lessThanOrEqual(o.BigInt(r),d)||u(!1);var p=t.sortsBefore(e)?[t,e]:[e,t];this.token0=p[0],this.token1=p[1],this.fee=n,this.sqrtRatioX96=o.BigInt(r),this.liquidity=o.BigInt(i),this.tickCurrent=a,this.tickDataProvider=Array.isArray(c)?new Tt(c,N[n]):c}t.getAddress=function(t,e,n,r,i){return M({factoryAddress:null!=i?i:"0x4bC8BDF50843Cc503E196Be4A9560134d358bb3C",fee:n,tokenA:t,tokenB:e,initCodeHashManualOverride:r})};var e=t.prototype;return e.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},e.priceOf=function(t){return this.involvesToken(t)||u(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.getOutputAmount=function(){var e=T(x().m((function e(n,r){var a,c,s,d,p;return x().w((function(e){for(;;)switch(e.n){case 0:return this.involvesToken(n.currency)||u(!1),a=n.currency.equals(this.token0),e.n=1,this.swap(a,n.quotient,r);case 1:return s=(c=e.v).sqrtRatioX96,d=c.liquidity,p=c.tickCurrent,e.a(2,[i.CurrencyAmount.fromRawAmount(a?this.token1:this.token0,o.multiply(c.amountCalculated,F)),new t(this.token0,this.token1,this.fee,s,d,p,this.tickDataProvider)])}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),e.getInputAmount=function(){var e=T(x().m((function e(n,r){var a,c,s,d,p;return x().w((function(e){for(;;)switch(e.n){case 0:return n.currency.isToken&&this.involvesToken(n.currency)||u(!1),a=n.currency.equals(this.token1),e.n=1,this.swap(a,o.multiply(n.quotient,F),r);case 1:return s=(c=e.v).sqrtRatioX96,d=c.liquidity,p=c.tickCurrent,e.a(2,[i.CurrencyAmount.fromRawAmount(a?this.token0:this.token1,c.amountCalculated),new t(this.token0,this.token1,this.fee,s,d,p,this.tickDataProvider)])}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),e.swap=function(){var t=T(x().m((function t(e,n,r){return x().w((function(t){for(;;)switch(t.n){case 0:return t.a(2,tt(o.BigInt(this.fee),this.sqrtRatioX96,this.tickCurrent,this.liquidity,this.tickSpacing,this.tickDataProvider,e,n,r))}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),I(t,[{key:"token0Price",get:function(){var t;return null!=(t=this._token0Price)?t:this._token0Price=new i.Price(this.token0,this.token1,D,o.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}},{key:"token1Price",get:function(){var t;return null!=(t=this._token1Price)?t:this._token1Price=new i.Price(this.token1,this.token0,o.multiply(this.sqrtRatioX96,this.sqrtRatioX96),D)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"tickSpacing",get:function(){return N[this.fee]}}])}(),wt=function(){function t(t){var e=t.pool,n=t.liquidity,r=t.tickLower,i=t.tickUpper;this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,r<i||u(!1),r>=J.MIN_TICK&&r%e.tickSpacing==0||u(!1),i<=J.MAX_TICK&&i%e.tickSpacing==0||u(!1),this.pool=e,this.tickLower=r,this.tickUpper=i,this.liquidity=o.BigInt(n)}var e=t.prototype;return e.ratiosAfterSlippage=function(t){var e=this.pool.token0Price.asFraction.multiply(new i.Percent(1).subtract(t)),n=this.pool.token0Price.asFraction.multiply(t.add(1)),r=ct(e.numerator,e.denominator);o.lessThanOrEqual(r,J.MIN_SQRT_RATIO)&&(r=o.add(J.MIN_SQRT_RATIO,o.BigInt(1)));var u=ct(n.numerator,n.denominator);return o.greaterThanOrEqual(u,J.MAX_SQRT_RATIO)&&(u=o.subtract(J.MAX_SQRT_RATIO,o.BigInt(1))),{sqrtRatioX96Lower:r,sqrtRatioX96Upper:u}},e.mintAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new It(this.pool.token0,this.pool.token1,this.pool.fee,i,0,J.getTickAtSqrtRatio(i)),u=new It(this.pool.token0,this.pool.token1,this.pool.fee,r,0,J.getTickAtSqrtRatio(r)),a=t.fromAmounts(q({pool:this.pool,tickLower:this.tickLower,tickUpper:this.tickUpper},this.mintAmounts,{useFullPrecision:!1}));return{amount0:new t({pool:u,liquidity:a.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount0,amount1:new t({pool:o,liquidity:a.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts.amount1}},e.burnAmountsWithSlippage=function(e){var n=this.ratiosAfterSlippage(e),r=n.sqrtRatioX96Upper,i=n.sqrtRatioX96Lower,o=new It(this.pool.token0,this.pool.token1,this.pool.fee,i,0,J.getTickAtSqrtRatio(i)),u=new t({pool:new It(this.pool.token0,this.pool.token1,this.pool.fee,r,0,J.getTickAtSqrtRatio(r)),liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,a=new t({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:u.quotient,amount1:a.quotient}},t.fromAmounts=function(e){var n=e.pool,r=e.tickLower,i=e.tickUpper,o=e.amount0,u=e.amount1,a=e.useFullPrecision,c=J.getSqrtRatioAtTick(r),s=J.getSqrtRatioAtTick(i);return new t({pool:n,tickLower:r,tickUpper:i,liquidity:lt(n.sqrtRatioX96,c,s,o,u,a)})},t.fromAmount0=function(e){return t.fromAmounts({pool:e.pool,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0:e.amount0,amount1:i.MaxUint256,useFullPrecision:e.useFullPrecision})},t.fromAmount1=function(e){return t.fromAmounts({pool:e.pool,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0:i.MaxUint256,amount1:e.amount1,useFullPrecision:!0})},I(t,[{key:"token0PriceLower",get:function(){return ht(this.pool.token0,this.pool.token1,this.tickLower)}},{key:"token0PriceUpper",get:function(){return ht(this.pool.token0,this.pool.token1,this.tickUpper)}},{key:"amount0",get:function(){return null===this._token0Amount&&(this._token0Amount=i.CurrencyAmount.fromRawAmount(this.pool.token0,this.pool.tickCurrent<this.tickLower?H.getAmount0Delta(J.getSqrtRatioAtTick(this.tickLower),J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):this.pool.tickCurrent<this.tickUpper?H.getAmount0Delta(this.pool.sqrtRatioX96,J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):X)),this._token0Amount}},{key:"amount1",get:function(){return null===this._token1Amount&&(this._token1Amount=i.CurrencyAmount.fromRawAmount(this.pool.token1,this.pool.tickCurrent<this.tickLower?X:H.getAmount1Delta(J.getSqrtRatioAtTick(this.tickLower),this.pool.tickCurrent<this.tickUpper?this.pool.sqrtRatioX96:J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}},{key:"mintAmounts",get:function(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:H.getAmount0Delta(J.getSqrtRatioAtTick(this.tickLower),J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:X}:this.pool.tickCurrent<this.tickUpper?{amount0:H.getAmount0Delta(this.pool.sqrtRatioX96,J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:H.getAmount1Delta(J.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:X,amount1:H.getAmount1Delta(J.getSqrtRatioAtTick(this.tickLower),J.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}}])}(),qt=function(){return I((function(t,e,n){this._midPrice=null,t.length>0||u(!1);var r=t[0].chainId;t.every((function(t){return t.chainId===r}))||u(!1);var i=e.wrapped;t[0].involvesToken(i)||u(!1),t[t.length-1].involvesToken(n.wrapped)||u(!1);for(var o,a=[i],c=w(t.entries());!(o=c()).done;){var s=o.value,d=s[1],p=a[s[0]];p.equals(d.token0)||p.equals(d.token1)||u(!1);var l=p.equals(d.token0)?d.token1:d.token0;a.push(l)}this.pools=t,this.tokenPath=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.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 i.Price(this.input,this.output,t.denominator,t.numerator)}}])}();function xt(t,e){return t.inputAmount.currency.equals(e.inputAmount.currency)||u(!1),t.outputAmount.currency.equals(e.outputAmount.currency)||u(!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 bt=function(){function t(t){var e=t.routes,n=t.tradeType,r=e[0].inputAmount.currency,i=e[0].outputAmount.currency;e.every((function(t){return r.wrapped.equals(t.route.input.wrapped)}))||u(!1),e.every((function(t){return i.wrapped.equals(t.route.output.wrapped)}))||u(!1);for(var o,a=e.map((function(t){return t.route.pools.length})).reduce((function(t,e){return t+e}),0),c=new Set,s=w(e);!(o=s()).done;)for(var d,p=w(o.value.route.pools);!(d=p()).done;){var l=d.value;c.add(It.getAddress(l.token0,l.token1,l.fee))}a!==c.size&&u(!1),this.swaps=e,this.tradeType=n}t.exactIn=function(){var e=T(x().m((function e(n,r){return x().w((function(e){for(;;)switch(e.n){case 0:return e.a(2,t.fromRoute(n,r,i.TradeType.EXACT_INPUT))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.exactOut=function(){var e=T(x().m((function e(n,r){return x().w((function(e){for(;;)switch(e.n){case 0:return e.a(2,t.fromRoute(n,r,i.TradeType.EXACT_OUTPUT))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.fromRoute=function(){var e=T(x().m((function e(n,r,o){var a,c,s,d,p,l,f;return x().w((function(e){for(;;)switch(e.n){case 0:if(a=new Array(n.tokenPath.length),o!==i.TradeType.EXACT_INPUT){e.n=5;break}r.currency.equals(n.input)||u(!1),a[0]=r.wrapped,d=0;case 1:if(!(d<n.tokenPath.length-1)){e.n=4;break}return p=n.pools[d],e.n=2,p.getOutputAmount(a[d]);case 2:a[d+1]=e.v[0];case 3:d++,e.n=1;break;case 4:c=i.CurrencyAmount.fromFractionalAmount(n.input,r.numerator,r.denominator),s=i.CurrencyAmount.fromFractionalAmount(n.output,a[a.length-1].numerator,a[a.length-1].denominator),e.n=10;break;case 5:r.currency.equals(n.output)||u(!1),a[a.length-1]=r.wrapped,l=n.tokenPath.length-1;case 6:if(!(l>0)){e.n=9;break}return f=n.pools[l-1],e.n=7,f.getInputAmount(a[l]);case 7:a[l-1]=e.v[0];case 8:l--,e.n=6;break;case 9:c=i.CurrencyAmount.fromFractionalAmount(n.input,a[0].numerator,a[0].denominator),s=i.CurrencyAmount.fromFractionalAmount(n.output,r.numerator,r.denominator);case 10:return e.a(2,new t({routes:[{inputAmount:c,outputAmount:s,route:n}],tradeType:o}))}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.fromRoutes=function(){var e=T(x().m((function e(n,r){var o,a,c,s,d,p,l,f,m,h,k,A,v;return x().w((function(e){for(;;)switch(e.n){case 0:o=[],a=w(n);case 1:if((c=a()).done){e.n=13;break}if(d=(s=c.value).route,p=s.amount,l=new Array(d.tokenPath.length),f=void 0,m=void 0,r!==i.TradeType.EXACT_INPUT){e.n=6;break}p.currency.equals(d.input)||u(!1),f=i.CurrencyAmount.fromFractionalAmount(d.input,p.numerator,p.denominator),l[0]=i.CurrencyAmount.fromFractionalAmount(d.input.wrapped,p.numerator,p.denominator),h=0;case 2:if(!(h<d.tokenPath.length-1)){e.n=5;break}return k=d.pools[h],e.n=3,k.getOutputAmount(l[h]);case 3:l[h+1]=e.v[0];case 4:h++,e.n=2;break;case 5:m=i.CurrencyAmount.fromFractionalAmount(d.output,l[l.length-1].numerator,l[l.length-1].denominator),e.n=11;break;case 6:p.currency.equals(d.output)||u(!1),m=i.CurrencyAmount.fromFractionalAmount(d.output,p.numerator,p.denominator),l[l.length-1]=i.CurrencyAmount.fromFractionalAmount(d.output.wrapped,p.numerator,p.denominator),A=d.tokenPath.length-1;case 7:if(!(A>0)){e.n=10;break}return v=d.pools[A-1],e.n=8,v.getInputAmount(l[A]);case 8:l[A-1]=e.v[0];case 9:A--,e.n=7;break;case 10:f=i.CurrencyAmount.fromFractionalAmount(d.input,l[0].numerator,l[0].denominator);case 11:o.push({route:d,inputAmount:f,outputAmount:m});case 12:e.n=1;break;case 13:return e.a(2,new t({routes:o,tradeType:r}))}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.createUncheckedTrade=function(e){return new t(q({},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(X)&&u(!1),this.tradeType===i.TradeType.EXACT_OUTPUT)return e;var n=new i.Fraction(B).add(t).invert().multiply(e.quotient).quotient;return i.CurrencyAmount.fromRawAmount(e.currency,n)},e.maximumAmountIn=function(t,e){if(void 0===e&&(e=this.inputAmount),t.lessThan(X)&&u(!1),this.tradeType===i.TradeType.EXACT_INPUT)return e;var n=new i.Fraction(B).add(t).multiply(e.quotient).quotient;return i.CurrencyAmount.fromRawAmount(e.currency,n)},e.worstExecutionPrice=function(t){return new i.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.bestTradeExactIn=function(){var e=T(x().m((function e(n,r,o,a,c,s,d){var p,l,f,m,h,k,A,v,y,T,g,I,w,q;return x().w((function(e){for(;;)switch(e.p=e.n){case 0:f=void 0===(l=(p=void 0===a?{}:a).maxNumResults)?3:l,h=void 0===(m=p.maxHops)?3:m,void 0===c&&(c=[]),void 0===s&&(s=r),void 0===d&&(d=[]),n.length>0||u(!1),h>0||u(!1),r===s||c.length>0||u(!1),k=s.wrapped,A=o.wrapped,v=0;case 1:if(!(v<n.length)){e.n=11;break}if((y=n[v]).token0.equals(k.currency)||y.token1.equals(k.currency)){e.n=2;break}return e.a(3,10);case 2:return T=void 0,e.p=3,e.n=4,y.getOutputAmount(k);case 4:T=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(!T.currency.isToken||!T.currency.equals(A)){e.n=9;break}return w=i.sortedInsert,q=d,e.n=8,t.fromRoute(new qt([].concat(c,[y]),r.currency,o),r,i.TradeType.EXACT_INPUT);case 8:w(q,e.v,f,xt),e.n=10;break;case 9:if(!(h>1&&n.length>1)){e.n=10;break}return g=n.slice(0,v).concat(n.slice(v+1,n.length)),e.n=10,t.bestTradeExactIn(g,r,o,{maxNumResults:f,maxHops:h-1},[].concat(c,[y]),T,d);case 10:v++,e.n=1;break;case 11:return e.a(2,d)}}),e,null,[[3,5]])})));return function(t,n,r,i,o,u,a){return e.apply(this,arguments)}}(),t.bestTradeExactOut=function(){var e=T(x().m((function e(n,r,o,a,c,s,d){var p,l,f,m,h,k,A,v,y,T,g,I,w,q;return x().w((function(e){for(;;)switch(e.p=e.n){case 0:f=void 0===(l=(p=void 0===a?{}:a).maxNumResults)?3:l,h=void 0===(m=p.maxHops)?3:m,void 0===c&&(c=[]),void 0===s&&(s=o),void 0===d&&(d=[]),n.length>0||u(!1),h>0||u(!1),o===s||c.length>0||u(!1),k=s.wrapped,A=r.wrapped,v=0;case 1:if(!(v<n.length)){e.n=11;break}if((y=n[v]).token0.equals(k.currency)||y.token1.equals(k.currency)){e.n=2;break}return e.a(3,10);case 2:return T=void 0,e.p=3,e.n=4,y.getInputAmount(k);case 4:T=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(!T.currency.equals(A)){e.n=9;break}return w=i.sortedInsert,q=d,e.n=8,t.fromRoute(new qt([y].concat(c),r,o.currency),o,i.TradeType.EXACT_OUTPUT);case 8:w(q,e.v,f,xt),e.n=10;break;case 9:if(!(h>1&&n.length>1)){e.n=10;break}return g=n.slice(0,v).concat(n.slice(v+1,n.length)),e.n=10,t.bestTradeExactOut(g,r,o,{maxNumResults:f,maxHops:h-1},[y].concat(c),T,d);case 10:v++,e.n=1;break;case 11:return e.a(2,d)}}),e,null,[[3,5]])})));return function(t,n,r,i,o,u,a){return e.apply(this,arguments)}}(),I(t,[{key:"route",get:function(){return 1!==this.swaps.length&&u(!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)}),i.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)}),i.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 i.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=i.CurrencyAmount.fromRawAmount(this.outputAmount.currency,0),n=w(this.swaps);!(t=n()).done;){var r=t.value;e=e.add(r.route.midPrice.quote(r.inputAmount))}var o=e.subtract(this.outputAmount).divide(e);return this._priceImpact=new i.Percent(o.numerator,o.denominator),this._priceImpact}}])}(),Rt=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}();Rt.INTERFACE=new a.Interface(d.abi);var Ct=function(){function t(){}return t.encodePermit=function(e,n){return"nonce"in n?t.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,ut(n.nonce),ut(n.expiry),n.v,n.r,n.s]):t.INTERFACE.encodeFunctionData("selfPermit",[e.address,ut(n.amount),ut(n.deadline),n.v,n.r,n.s])},t}();Ct.INTERFACE=new a.Interface(l.abi);var Pt=function(){function t(){}return t.encodeFeeBips=function(t){return ut(t.multiply(1e4).quotient)},t.encodeUnwrapWETH9=function(e,n,r){if(n=i.validateAndParseAddress(n),r){var o=this.encodeFeeBips(r.fee),u=i.validateAndParseAddress(r.recipient);return t.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[ut(e),n,o,u])}return t.INTERFACE.encodeFunctionData("unwrapWETH9",[ut(e),n])},t.encodeSweepToken=function(e,n,r,o){if(r=i.validateAndParseAddress(r),o){var u=this.encodeFeeBips(o.fee),a=i.validateAndParseAddress(o.recipient);return t.INTERFACE.encodeFunctionData("sweepTokenWithFee",[e.address,ut(n),r,u,a])}return t.INTERFACE.encodeFunctionData("sweepToken",[e.address,ut(n),r])},t.encodeRefundETH=function(){return t.INTERFACE.encodeFunctionData("refundETH")},t}();Pt.INTERFACE=new a.Interface(f.abi);var Et=["expectedCurrencyOwed0","expectedCurrencyOwed1"],Ot=ut(o.subtract(o.exponentiate(o.BigInt(2),o.BigInt(128)),o.BigInt(1)));function St(t){return Object.keys(t).some((function(t){return"recipient"===t}))}var _t=function(){function t(){}return t.encodeCreate=function(e){return t.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[e.token0.address,e.token1.address,e.fee,ut(e.sqrtRatioX96)])},t.createCallParameters=function(t){return{calldata:this.encodeCreate(t),value:ut(0)}},t.addCallParameters=function(e,n){o.greaterThan(e.liquidity,X)||u(!1);var r=[],a=e.mintAmounts,c=a.amount0,s=a.amount1,d=e.mintAmountsWithSlippage(n.slippageTolerance),p=ut(d.amount0),l=ut(d.amount1),f=ut(n.deadline);if(St(n)&&n.createPool&&r.push(this.encodeCreate(e.pool)),n.token0Permit&&r.push(Ct.encodePermit(e.pool.token0,n.token0Permit)),n.token1Permit&&r.push(Ct.encodePermit(e.pool.token1,n.token1Permit)),St(n)){var m=i.validateAndParseAddress(n.recipient);r.push(t.INTERFACE.encodeFunctionData("mint",[{token0:e.pool.token0.address,token1:e.pool.token1.address,fee:e.pool.fee,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0Desired:ut(c),amount1Desired:ut(s),amount0Min:p,amount1Min:l,recipient:m,deadline:f}]))}else r.push(t.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:ut(n.tokenId),amount0Desired:ut(c),amount1Desired:ut(s),amount0Min:p,amount1Min:l,deadline:f}]));var h=ut(0);if(n.useNative){var k=n.useNative.wrapped;e.pool.token0.equals(k)||e.pool.token1.equals(k)||u(!1);var A=e.pool.token0.equals(k)?c:s;o.greaterThan(A,X)&&r.push(Pt.encodeRefundETH()),h=ut(A)}return{calldata:Rt.encodeMulticall(r),value:h}},t.encodeCollect=function(e){var n=[],r=ut(e.tokenId),o=e.expectedCurrencyOwed0.currency.isNative||e.expectedCurrencyOwed1.currency.isNative,u=i.validateAndParseAddress(e.recipient);if(n.push(t.INTERFACE.encodeFunctionData("collect",[{tokenId:r,recipient:o?E:u,amount0Max:Ot,amount1Max:Ot}])),o){var a=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.currency:e.expectedCurrencyOwed0.currency,c=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.quotient:e.expectedCurrencyOwed0.quotient;n.push(Pt.encodeUnwrapWETH9(e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed0.quotient:e.expectedCurrencyOwed1.quotient,u)),n.push(Pt.encodeSweepToken(a,c,u))}return n},t.collectCallParameters=function(e){var n=t.encodeCollect(e);return{calldata:Rt.encodeMulticall(n),value:ut(0)}},t.removeCallParameters=function(e,n){var r=[],a=ut(n.deadline),c=ut(n.tokenId),s=new wt({pool:e.pool,liquidity:n.liquidityPercentage.multiply(e.liquidity).quotient,tickLower:e.tickLower,tickUpper:e.tickUpper});o.greaterThan(s.liquidity,X)||u(!1);var d=s.burnAmountsWithSlippage(n.slippageTolerance),p=d.amount0,l=d.amount1;n.permit&&r.push(t.INTERFACE.encodeFunctionData("permit",[i.validateAndParseAddress(n.permit.spender),c,ut(n.permit.deadline),n.permit.v,n.permit.r,n.permit.s])),r.push(t.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:c,liquidity:ut(s.liquidity),amount0Min:ut(p),amount1Min:ut(l),deadline:a}]));var f=n.collectOptions,m=f.expectedCurrencyOwed0,h=f.expectedCurrencyOwed1,k=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(f,Et);return r.push.apply(r,t.encodeCollect(q({tokenId:ut(n.tokenId),expectedCurrencyOwed0:m.add(i.CurrencyAmount.fromRawAmount(m.currency,p)),expectedCurrencyOwed1:h.add(i.CurrencyAmount.fromRawAmount(h.currency,l))},k))),n.liquidityPercentage.equalTo(B)?n.burnToken&&r.push(t.INTERFACE.encodeFunctionData("burn",[c])):!0===n.burnToken&&u(!1),{calldata:Rt.encodeMulticall(r),value:ut(0)}},t.safeTransferFromParameters=function(e){var n=i.validateAndParseAddress(e.recipient),r=i.validateAndParseAddress(e.sender);return{calldata:e.data?t.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)",[r,n,ut(e.tokenId),e.data]):t.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256)",[r,n,ut(e.tokenId)]),value:ut(0)}},t}();_t.INTERFACE=new a.Interface(p.abi);var Nt=function(){function t(){}return t.quoteCallParameters=function(t,e,n,r){void 0===r&&(r={});var o,a=1===t.pools.length,c=ut(e.quotient),s=r.useQuoterV2?this.V2INTERFACE:this.V1INTERFACE;if(a){var d,p,l={tokenIn:t.tokenPath[0].address,tokenOut:t.tokenPath[1].address,fee:t.pools[0].fee,sqrtPriceLimitX96:ut(null!=(d=null==(p=r)?void 0:p.sqrtPriceLimitX96)?d:0)},f=q({},l,n===i.TradeType.EXACT_INPUT?{amountIn:c}:{amount:c});o=s.encodeFunctionData(n===i.TradeType.EXACT_INPUT?"quoteExactInputSingle":"quoteExactOutputSingle",r.useQuoterV2?[f]:[l.tokenIn,l.tokenOut,l.fee,c,l.sqrtPriceLimitX96])}else{var m;void 0!==(null==(m=r)?void 0:m.sqrtPriceLimitX96)&&u(!1);var h=at(t,n===i.TradeType.EXACT_OUTPUT);o=s.encodeFunctionData(n===i.TradeType.EXACT_INPUT?"quoteExactInput":"quoteExactOutput",[h,c])}return{calldata:o,value:ut(0)}},t}();Nt.V1INTERFACE=new a.Interface(m.abi),Nt.V2INTERFACE=new a.Interface(h.abi);var Ft=function(){function t(){}return t.encodeClaim=function(e,n){var r,o=[];o.push(t.INTERFACE.encodeFunctionData("unstakeToken",[this._encodeIncentiveKey(e),ut(n.tokenId)]));var u=i.validateAndParseAddress(n.recipient),a=null!=(r=n.amount)?r:0;return o.push(t.INTERFACE.encodeFunctionData("claimReward",[e.rewardToken.address,u,ut(a)])),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),ut(n.tokenId)]))}return{calldata:Rt.encodeMulticall(r),value:ut(0)}},t.withdrawToken=function(e,n){var r=[];e=Array.isArray(e)?e:[e];for(var o={tokenId:n.tokenId,recipient:n.recipient,amount:n.amount},u=0;u<e.length;u++)r=r.concat(this.encodeClaim(e[u],o));var a=i.validateAndParseAddress(n.owner);return r.push(t.INTERFACE.encodeFunctionData("withdrawToken",[ut(n.tokenId),a,n.data?n.data:ut(0)])),{calldata:Rt.encodeMulticall(r),value:ut(0)}},t.encodeDeposit=function(e){var n;if((e=Array.isArray(e)?e:[e]).length>1){for(var r=[],i=0;i<e.length;i++)r.push(this._encodeIncentiveKey(e[i]));n=a.defaultAbiCoder.encode([t.INCENTIVE_KEY_ABI+"[]"],[r])}else n=a.defaultAbiCoder.encode([t.INCENTIVE_KEY_ABI],[this._encodeIncentiveKey(e[0])]);return n},t._encodeIncentiveKey=function(t){var e=t.pool,n=e.token0,r=e.token1,o=e.fee,u=i.validateAndParseAddress(t.refundee);return{rewardToken:t.rewardToken.address,pool:It.getAddress(n,r,o),startTime:ut(t.startTime),endTime:ut(t.endTime),refundee:u}},t}();Ft.INTERFACE=new a.Interface(k.abi),Ft.INCENTIVE_KEY_ABI="tuple(address rewardToken, address pool, uint256 startTime, uint256 endTime, address refundee)";var Xt=function(){function t(){}return t.swapCallParameters=function(e,n){Array.isArray(e)||(e=[e]);var r=e[0],o=r.inputAmount.currency.wrapped,a=r.outputAmount.currency.wrapped;e.every((function(t){return t.inputAmount.currency.wrapped.equals(o)}))||u(!1),e.every((function(t){return t.outputAmount.currency.wrapped.equals(a)}))||u(!1);var c=[],s=i.CurrencyAmount.fromRawAmount(e[0].inputAmount.currency,0),d=i.CurrencyAmount.fromRawAmount(e[0].outputAmount.currency,0),p=e.reduce((function(t,e){return t.add(e.minimumAmountOut(n.slippageTolerance))}),d),l=r.inputAmount.currency.isNative&&r.tradeType===i.TradeType.EXACT_OUTPUT,f=r.outputAmount.currency.isNative,m=f||!!n.fee,h=r.inputAmount.currency.isNative?e.reduce((function(t,e){return t.add(e.maximumAmountIn(n.slippageTolerance))}),s):s;n.inputTokenPermit&&(r.inputAmount.currency.isToken||u(!1),c.push(Ct.encodePermit(r.inputAmount.currency,n.inputTokenPermit)));for(var k,A=i.validateAndParseAddress(n.recipient),v=ut(n.deadline),y=w(e);!(k=y()).done;)for(var T,g=k.value,I=w(g.swaps);!(T=I()).done;){var q=T.value,x=q.route,b=q.outputAmount,R=ut(g.maximumAmountIn(n.slippageTolerance,q.inputAmount).quotient),C=ut(g.minimumAmountOut(n.slippageTolerance,b).quotient);if(1===x.pools.length)if(g.tradeType===i.TradeType.EXACT_INPUT){var P,O={tokenIn:x.tokenPath[0].address,tokenOut:x.tokenPath[1].address,fee:x.pools[0].fee,recipient:m?E:A,deadline:v,amountIn:R,amountOutMinimum:C,sqrtPriceLimitX96:ut(null!=(P=n.sqrtPriceLimitX96)?P:0)};c.push(t.INTERFACE.encodeFunctionData("exactInputSingle",[O]))}else{var S,_={tokenIn:x.tokenPath[0].address,tokenOut:x.tokenPath[1].address,fee:x.pools[0].fee,recipient:m?E:A,deadline:v,amountOut:C,amountInMaximum:R,sqrtPriceLimitX96:ut(null!=(S=n.sqrtPriceLimitX96)?S:0)};c.push(t.INTERFACE.encodeFunctionData("exactOutputSingle",[_]))}else{void 0!==n.sqrtPriceLimitX96&&u(!1);var N=at(x,g.tradeType===i.TradeType.EXACT_OUTPUT);c.push(g.tradeType===i.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("exactInput",[{path:N,recipient:m?E:A,deadline:v,amountIn:R,amountOutMinimum:C}]):t.INTERFACE.encodeFunctionData("exactOutput",[{path:N,recipient:m?E:A,deadline:v,amountOut:C,amountInMaximum:R}]))}}return m&&c.push(n.fee?f?Pt.encodeUnwrapWETH9(p.quotient,A,n.fee):Pt.encodeSweepToken(r.outputAmount.currency.wrapped,p.quotient,A,n.fee):Pt.encodeUnwrapWETH9(p.quotient,A)),l&&c.push(Pt.encodeRefundETH()),{calldata:Rt.encodeMulticall(c),value:ut(h.quotient)}},t}();Xt.INTERFACE=new a.Interface(A.abi),exports.ADDRESS_ZERO=E,exports.FACTORY_ADDRESS="0x4bC8BDF50843Cc503E196Be4A9560134d358bb3C",exports.FACTORY_ADDRESS_BY_CHAIN_ID=P,exports.FullMath=L,exports.LiquidityMath=Q,exports.Multicall=Rt,exports.NoTickDataProvider=nt,exports.NonfungiblePositionManager=_t,exports.POOL_INIT_CODE_HASH=O,exports.POOL_INIT_CODE_HASH_BY_CHAIN_ID=S,exports.Payments=Pt,exports.Pool=It,exports.Position=wt,exports.PositionLibrary=mt,exports.Route=qt,exports.SelfPermit=Ct,exports.SqrtPriceMath=H,exports.Staker=Ft,exports.SwapMath=G,exports.SwapQuoter=Nt,exports.SwapRouter=Xt,exports.TICK_SPACINGS=N,exports.Tick=yt,exports.TickLibrary=vt,exports.TickList=ot,exports.TickListDataProvider=Tt,exports.TickMath=J,exports.Trade=bt,exports.computePoolAddress=M,exports.encodeRouteToPath=at,exports.encodeSqrtRatioX96=ct,exports.isSorted=rt,exports.maxLiquidityForAmounts=lt,exports.mostSignificantBit=Y,exports.nearestUsableTick=function(t,e){Number.isInteger(t)&&Number.isInteger(e)||u(!1),e>0||u(!1),t>=J.MIN_TICK&&t<=J.MAX_TICK||u(!1);var n=Math.round(t/e)*e;return n<J.MIN_TICK?n+e:n>J.MAX_TICK?n-e:n},exports.poolInitCodeHash=_,exports.priceToClosestTick=function(t){var e=t.baseCurrency.sortsBefore(t.quoteCurrency),n=e?ct(t.numerator,t.denominator):ct(t.denominator,t.numerator),r=J.getTickAtSqrtRatio(n),i=ht(t.baseCurrency,t.quoteCurrency,r+1);return e?t.lessThan(i)||r++:t.greaterThan(i)||r++,r},exports.subIn256=At,exports.tickToPrice=ht,exports.toHex=ut,exports.tradeComparator=xt,exports.v3Swap=tt;
2
2
  //# sourceMappingURL=v3-sdk.cjs.production.min.js.map