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