Socket
Socket
Sign inDemoInstall

@uniswap/v3-sdk

Package Overview
Dependencies
Maintainers
9
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/v3-sdk - npm Package Compare versions

Comparing version 1.0.0-alpha.27 to 1.0.0-alpha.28

69

dist/nonfungiblePositionManager.d.ts

@@ -1,2 +0,2 @@

import { BigintIsh, Percent } from '@uniswap/sdk-core';
import { BigintIsh, CurrencyAmount, Percent } from '@uniswap/sdk-core';
import { Position } from './entities/position';

@@ -6,5 +6,5 @@ import { MethodParameters } from './utils/calldata';

import { PermitOptions, SelfPermit } from './selfPermit';
interface MintOptions {
export interface MintSpecificOptions {
/**
* The account that should receive the minted NFT. Only needs to be present if tokenId is not.
* The account that should receive the minted NFT.
*/

@@ -17,5 +17,5 @@ recipient: string;

}
interface IncreaseOptions {
export interface IncreaseSpecificOptions {
/**
* If present, indicates the ID of the position to increase liquidity for. Otherwise, a new position will be created.
* Indicates the ID of the position to increase liquidity for.
*/

@@ -25,5 +25,5 @@ tokenId: BigintIsh;

/**
* Options for producing the calldata to mint a position or add to one.
* Options for producing the calldata to add liquidity.
*/
interface CommonIncreaseLiquidityOptions {
export interface CommonAddLiquidityOptions {
/**

@@ -50,2 +50,27 @@ * How much the pool price is allowed to move.

}
export declare type MintOptions = CommonAddLiquidityOptions & MintSpecificOptions;
export declare type IncreaseOptions = CommonAddLiquidityOptions & IncreaseSpecificOptions;
export declare type AddLiquidityOptions = MintOptions | IncreaseOptions;
export interface CollectOptions {
/**
* Indicates the ID of the position to collect for.
*/
tokenId: BigintIsh;
/**
* Expected value of tokensOwed0, including as-of-yet-unaccounted-for fees/liquidity value to be burned
*/
expectedCurrencyOwed0: CurrencyAmount;
/**
* Expected value of tokensOwed1, including as-of-yet-unaccounted-for fees/liquidity value to be burned
*/
expectedCurrencyOwed1: CurrencyAmount;
/**
* The account that should receive the tokens.
*/
recipient: string;
/**
* Optional override for the default position manager address.
*/
nonfungiblePositionManagerAddressOverride?: string;
}
export interface NFTPermitOptions {

@@ -55,11 +80,9 @@ v: 0 | 1 | 27 | 28;

s: string;
tokenId: BigintIsh;
deadline: BigintIsh;
spender: string;
}
export declare type IncreaseLiquidityOptions = (CommonIncreaseLiquidityOptions & MintOptions) | (CommonIncreaseLiquidityOptions & IncreaseOptions);
/**
* Options for producing the calldata to exit a position.
*/
export interface DecreaseLiquidityOptions {
export interface RemoveLiquidityOptions {
/**

@@ -70,3 +93,3 @@ * The ID of the token to exit

/**
* The percentage of position liquidity to exit. Optional--if not specified, exit the entire position
* The percentage of position liquidity to exit.
*/

@@ -79,6 +102,2 @@ liquidityPercentage: Percent;

/**
* The account that should receive the tokens.
*/
recipient: string;
/**
* When the transaction expires, in epoch seconds.

@@ -88,10 +107,13 @@ */

/**
* Whether to receive ether. If true, one of the pool tokens must be WETH, by default false
* Whether the NFT should be burned if the entire position is being exited, by default true.
*/
receiveEther?: boolean;
burnToken?: boolean;
/**
* Whether the NFT should be burned after exiting the entire position, by default true
* The optional permit of the token ID being exited, in case the exit transaction is being sent by an account that does not own the NFT
*/
burnToken?: boolean;
nonfungiblePositionManagerAddressOverride: string;
permit?: NFTPermitOptions;
/**
* Parameters to be passed on to collect
*/
collectOptions: Omit<CollectOptions, 'tokenId'>;
}

@@ -105,3 +127,5 @@ export declare abstract class NonfungiblePositionManager extends SelfPermit {

private constructor();
static increaseCallParameters(position: Position, options: IncreaseLiquidityOptions): MethodParameters;
static addCallParameters(position: Position, options: AddLiquidityOptions): MethodParameters;
private static encodeCollect;
static collectCallParameters(options: CollectOptions): MethodParameters;
/**

@@ -112,4 +136,3 @@ * Produces the calldata for completely or partially exiting a position

*/
static decreaseCallParameters(position: Position, options: DecreaseLiquidityOptions): MethodParameters;
static removeCallParameters(position: Position, options: RemoveLiquidityOptions): MethodParameters;
}
export {};
import { BigintIsh, Token } from '@uniswap/sdk-core';
import { Interface } from '@ethersproject/abi';
interface StandardPermitArguments {
export interface StandardPermitArguments {
v: 0 | 1 | 27 | 28;

@@ -10,3 +10,3 @@ r: string;

}
interface AllowedPermitArguments {
export interface AllowedPermitArguments {
v: 0 | 1 | 27 | 28;

@@ -22,4 +22,3 @@ r: string;

protected constructor();
static encodePermit(token: Token, options: PermitOptions): string;
protected static encodePermit(token: Token, options: PermitOptions): string;
}
export {};

@@ -6,6 +6,16 @@ import { Interface } from '@ethersproject/abi';

import { MethodParameters } from './utils/calldata';
export interface FeeOptions {
/**
* The percent of the output that will be taken as a fee.
*/
fee: Percent;
/**
* The recipient of the fee.
*/
recipient: string;
}
/**
* Options for producing the arguments to send call to the router.
* Options for producing the arguments to send calls to the router.
*/
export interface TradeOptions {
export interface SwapOptions {
/**

@@ -31,3 +41,10 @@ * How much the execution price is allowed to move unfavorably from the trade execution price.

sqrtPriceLimitX96?: BigintIsh;
swapRouterAddressOverride: string;
/**
* Optional information for taking a fee on output.
*/
fee?: FeeOptions;
/**
* Optional override for the default swap router address.
*/
swapRouterAddressOverride?: string;
}

@@ -49,3 +66,3 @@ /**

*/
static swapCallParameters(trade: Trade, options: TradeOptions): MethodParameters;
static swapCallParameters(trade: Trade, options: SwapOptions): MethodParameters;
}

@@ -1,2 +0,2 @@

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@uniswap/sdk-core"),n=t(require("jsbi")),r=t(require("tiny-invariant")),i=require("@ethersproject/abi"),o=require("@ethersproject/address"),a=require("@ethersproject/solidity"),u=require("@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json"),c=require("@uniswap/v3-periphery/artifacts/contracts/interfaces/ISelfPermit.sol/ISelfPermit.json"),s=require("@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json");function l(t,e,n,r,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,i)}function p(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){l(o,r,i,a,u,"next",t)}function u(t){l(o,r,i,a,u,"throw",t)}a(void 0)}))}}function d(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function f(t,e,n){return e&&d(t.prototype,e),n&&d(t,n),t}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function v(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return m(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var k,g,T,y=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),o=new I(r||[]);return i._invoke=function(t,e,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=y(a,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=s(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(t,n,o),i}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function p(){}function d(){}function f(){}var h={};h[i]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(q([])));v&&v!==e&&n.call(v,i)&&(h=v);var k=f.prototype=p.prototype=Object.create(h);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){var r;this._invoke=function(i,o){function a(){return new e((function(r,a){!function r(i,o,a,u){var c=s(t[i],t,o);if("throw"!==c.type){var l=c.arg,p=l.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(p).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function y(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,y(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,l;var i=r.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function q(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:w}}function w(){return{value:void 0,done:!0}}return d.prototype=k.constructor=f,f.constructor=d,d.displayName=u(f,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,u(t,a,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},g(T.prototype),T.prototype[o]=function(){return this},t.AsyncIterator=T,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new T(c(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(k),u(k,a,"Generator"),k[i]=function(){return this},k.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=q,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),x(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:q(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(T={exports:{}}),T.exports),A="0xc02f72e8ae5e68802e6d893d58ddfb0df89a2f4c9c2f04927db1186a29373660";(g=exports.FeeAmount||(exports.FeeAmount={}))[g.LOW=500]="LOW",g[g.MEDIUM=3e3]="MEDIUM",g[g.HIGH=1e4]="HIGH";var x=((k={})[exports.FeeAmount.LOW]=10,k[exports.FeeAmount.MEDIUM]=60,k[exports.FeeAmount.HIGH]=200,k),I=n.BigInt(-1),q=n.BigInt(0),w=n.BigInt(1),E=n.exponentiate(n.BigInt(2),n.BigInt(96)),b=n.exponentiate(E,n.BigInt(2));function R(t){var e=t.factoryAddress,n=t.tokenA,r=t.tokenB,u=t.fee,c=n.sortsBefore(r)?[n,r]:[r,n];return o.getCreate2Address(e,a.keccak256(["bytes"],[i.defaultAbiCoder.encode(["address","address","uint24"],[c[0].address,c[1].address,u])]),A)}var P=function(){function t(){}return t.addDelta=function(t,e){return n.lessThan(e,q)?n.subtract(t,n.multiply(e,I)):n.add(t,e)},t}(),S=function(){function t(){}return t.mulDivRoundingUp=function(t,e,r){var i=n.multiply(t,e),o=n.divide(i,r);return n.notEqual(n.remainder(i,r),q)&&(o=n.add(o,w)),o},t}(),N=n.subtract(n.exponentiate(n.BigInt(2),n.BigInt(160)),w);function O(t,r){var i=n.multiply(t,r);return n.bitwiseAnd(i,e.MaxUint256)}var C=function(){function t(){}return t.getAmount0Delta=function(t,e,r,i){if(n.greaterThan(t,e)){var o=[e,t];t=o[0],e=o[1]}var a=n.leftShift(r,n.BigInt(96)),u=n.subtract(e,t);return i?S.mulDivRoundingUp(S.mulDivRoundingUp(a,u,e),w,t):n.divide(n.divide(n.multiply(a,u),e),t)},t.getAmount1Delta=function(t,e,r,i){if(n.greaterThan(t,e)){var o=[e,t];t=o[0],e=o[1]}return i?S.mulDivRoundingUp(r,n.subtract(e,t),E):n.divide(n.multiply(r,n.subtract(e,t)),E)},t.getNextSqrtPriceFromInput=function(t,e,i,o){return n.greaterThan(t,q)||r(!1),n.greaterThan(e,q)||r(!1),o?this.getNextSqrtPriceFromAmount0RoundingUp(t,e,i,!0):this.getNextSqrtPriceFromAmount1RoundingDown(t,e,i,!0)},t.getNextSqrtPriceFromOutput=function(t,e,i,o){return n.greaterThan(t,q)||r(!1),n.greaterThan(e,q)||r(!1),o?this.getNextSqrtPriceFromAmount1RoundingDown(t,e,i,!1):this.getNextSqrtPriceFromAmount0RoundingUp(t,e,i,!1)},t.getNextSqrtPriceFromAmount0RoundingUp=function(t,i,o,a){if(n.equal(o,q))return t;var u=n.leftShift(i,n.BigInt(96));if(a){var c=O(o,t);if(n.equal(n.divide(c,o),t)){var s=(p=n.add(u,c),n.bitwiseAnd(p,e.MaxUint256));if(n.greaterThanOrEqual(s,u))return S.mulDivRoundingUp(u,t,s)}return S.mulDivRoundingUp(u,w,n.add(n.divide(u,t),o))}var l=O(o,t);n.equal(n.divide(l,o),t)||r(!1),n.greaterThan(u,l)||r(!1);var p,d=n.subtract(u,l);return S.mulDivRoundingUp(u,t,d)},t.getNextSqrtPriceFromAmount1RoundingDown=function(t,e,i,o){if(o){var a=n.lessThanOrEqual(i,N)?n.divide(n.leftShift(i,n.BigInt(96)),e):n.divide(n.multiply(i,E),e);return n.add(t,a)}var u=S.mulDivRoundingUp(i,E,e);return n.greaterThan(t,u)||r(!1),n.subtract(t,u)},t}(),_=n.exponentiate(n.BigInt(10),n.BigInt(6)),F=function(){function t(){}return t.computeSwapStep=function(t,e,r,i,o){var a={},u=n.greaterThanOrEqual(t,e),c=n.greaterThanOrEqual(i,q);if(c){var s=n.divide(n.multiply(i,n.subtract(_,n.BigInt(o))),_);a.amountIn=u?C.getAmount0Delta(e,t,r,!0):C.getAmount1Delta(t,e,r,!0),a.sqrtRatioNextX96=n.greaterThanOrEqual(s,a.amountIn)?e:C.getNextSqrtPriceFromInput(t,r,s,u)}else a.amountOut=u?C.getAmount1Delta(e,t,r,!1):C.getAmount0Delta(t,e,r,!1),a.sqrtRatioNextX96=n.greaterThanOrEqual(n.multiply(i,I),a.amountOut)?e:C.getNextSqrtPriceFromOutput(t,r,n.multiply(i,I),u);var l=n.equal(e,a.sqrtRatioNextX96);return u?(a.amountIn=l&&c?a.amountIn:C.getAmount0Delta(a.sqrtRatioNextX96,t,r,!0),a.amountOut=l&&!c?a.amountOut:C.getAmount1Delta(a.sqrtRatioNextX96,t,r,!1)):(a.amountIn=l&&c?a.amountIn:C.getAmount1Delta(t,a.sqrtRatioNextX96,r,!0),a.amountOut=l&&!c?a.amountOut:C.getAmount0Delta(t,a.sqrtRatioNextX96,r,!1)),!c&&n.greaterThan(a.amountOut,n.multiply(i,I))&&(a.amountOut=n.multiply(i,I)),a.feeAmount=c&&n.notEqual(a.sqrtRatioNextX96,e)?n.subtract(i,a.amountIn):S.mulDivRoundingUp(a.amountIn,n.BigInt(o),n.subtract(_,n.BigInt(o))),[a.sqrtRatioNextX96,a.amountIn,a.amountOut,a.feeAmount]},t}(),D=n.BigInt(2),X=[128,64,32,16,8,4,2,1].map((function(t){return[t,n.exponentiate(D,n.BigInt(t))]}));function B(t){n.greaterThan(t,q)||r(!1),n.lessThanOrEqual(t,e.MaxUint256)||r(!1);for(var i,o=0,a=v(X);!(i=a()).done;){var u=i.value,c=u[0];n.greaterThanOrEqual(t,u[1])&&(t=n.signedRightShift(t,n.BigInt(c)),o+=c)}return o}function L(t,e){return n.signedRightShift(n.multiply(t,n.BigInt(e)),n.BigInt(128))}var M=n.exponentiate(n.BigInt(2),n.BigInt(32)),U=function(){function t(){}return t.getSqrtRatioAtTick=function(i){i>=t.MIN_TICK&&i<=t.MAX_TICK&&Number.isInteger(i)||r(!1);var o=i<0?-1*i:i,a=n.BigInt(0!=(1&o)?"0xfffcb933bd6fad37aa2d162d1a594001":"0x100000000000000000000000000000000");return 0!=(2&o)&&(a=L(a,"0xfff97272373d413259a46990580e213a")),0!=(4&o)&&(a=L(a,"0xfff2e50f5f656932ef12357cf3c7fdcc")),0!=(8&o)&&(a=L(a,"0xffe5caca7e10e4e61c3624eaa0941cd0")),0!=(16&o)&&(a=L(a,"0xffcb9843d60f6159c9db58835c926644")),0!=(32&o)&&(a=L(a,"0xff973b41fa98c081472e6896dfb254c0")),0!=(64&o)&&(a=L(a,"0xff2ea16466c96a3843ec78b326b52861")),0!=(128&o)&&(a=L(a,"0xfe5dee046a99a2a811c461f1969c3053")),0!=(256&o)&&(a=L(a,"0xfcbe86c7900a88aedcffc83b479aa3a4")),0!=(512&o)&&(a=L(a,"0xf987a7253ac413176f2b074cf7815e54")),0!=(1024&o)&&(a=L(a,"0xf3392b0822b70005940c7a398e4b70f3")),0!=(2048&o)&&(a=L(a,"0xe7159475a2c29b7443b29c7fa6e889d9")),0!=(4096&o)&&(a=L(a,"0xd097f3bdfd2022b8845ad8f792aa5825")),0!=(8192&o)&&(a=L(a,"0xa9f746462d870fdf8a65dc1f90e061e5")),0!=(16384&o)&&(a=L(a,"0x70d869a156d2a1b890bb3df62baf32f7")),0!=(32768&o)&&(a=L(a,"0x31be135f97d08fd981231505542fcfa6")),0!=(65536&o)&&(a=L(a,"0x9aa508b5b7a84e1c677de54f3e99bc9")),0!=(131072&o)&&(a=L(a,"0x5d6af8dedb81196699c329225ee604")),0!=(262144&o)&&(a=L(a,"0x2216e584f5fa1ea926041bedfe98")),0!=(524288&o)&&(a=L(a,"0x48a170391f7dc42444e8fa2")),i>0&&(a=n.divide(e.MaxUint256,a)),n.greaterThan(n.remainder(a,M),q)?n.add(n.divide(a,M),w):n.divide(a,M)},t.getTickAtSqrtRatio=function(e){n.greaterThanOrEqual(e,t.MIN_SQRT_RATIO)&&n.lessThan(e,t.MAX_SQRT_RATIO)||r(!1);var i,o=n.leftShift(e,n.BigInt(32)),a=B(o);i=n.greaterThanOrEqual(n.BigInt(a),n.BigInt(128))?n.signedRightShift(o,n.BigInt(a-127)):n.leftShift(o,n.BigInt(127-a));for(var u=n.leftShift(n.subtract(n.BigInt(a),n.BigInt(128)),n.BigInt(64)),c=0;c<14;c++){i=n.signedRightShift(n.multiply(i,i),n.BigInt(127));var s=n.signedRightShift(i,n.BigInt(128));u=n.bitwiseOr(u,n.leftShift(s,n.BigInt(63-c))),i=n.signedRightShift(i,s)}var l=n.multiply(u,n.BigInt("255738958999603826347141")),p=n.toNumber(n.signedRightShift(n.subtract(l,n.BigInt("3402992956809132418596140100660247210")),n.BigInt(128))),d=n.toNumber(n.signedRightShift(n.add(l,n.BigInt("291339464771989622907027621153398088495")),n.BigInt(128)));return p===d?p:n.lessThanOrEqual(t.getSqrtRatioAtTick(d),e)?d:p},t}();U.MIN_TICK=-887272,U.MAX_TICK=-U.MIN_TICK,U.MIN_SQRT_RATIO=n.BigInt("4295128739"),U.MAX_SQRT_RATIO=n.BigInt("1461446703485210103287273052203988822378723970342");var H=function(){function t(){}var e=t.prototype;return e.getTick=function(){var e=p(y.mark((function e(n){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error(t.ERROR_MESSAGE);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var e=p(y.mark((function e(n,r,i){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error(t.ERROR_MESSAGE);case 1:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t}();function 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 W(t,e){return t.index-e.index}H.ERROR_MESSAGE="No tick data provider was given";var G=function(){function t(){}return t.validateList=function(t,e){e>0||r(!1),t.every((function(t){return t.index%e==0}))||r(!1),n.equal(t.reduce((function(t,e){return n.add(t,e.liquidityNet)}),q),q)||r(!1),j(t,W)||r(!1)},t.isBelowSmallest=function(t,e){return t.length>0||r(!1),e<t[0].index},t.isAtOrAboveLargest=function(t,e){return t.length>0||r(!1),e>=t[t.length-1].index},t.getTick=function(t,e){var n=t[this.binarySearch(t,e)];return n.index!==e&&r(!1),n},t.binarySearch=function(t,e){this.isBelowSmallest(t,e)&&r(!1);for(var n,i=0,o=t.length-1;;){if(t[n=Math.floor((i+o)/2)].index<=e&&(n===t.length-1||t[n+1].index>e))return n;t[n].index<e?i=n+1:o=n-1}},t.nextInitializedTick=function(e,n,i){return i?(t.isBelowSmallest(e,n)&&r(!1),t.isAtOrAboveLargest(e,n)?e[e.length-1]:e[this.binarySearch(e,n)]):(this.isAtOrAboveLargest(e,n)&&r(!1),this.isBelowSmallest(e,n)?e[0]:e[this.binarySearch(e,n)+1])},t.nextInitializedTickWithinOneWord=function(e,n,r,i){var o=Math.floor(n/i);if(r){var a=(o>>8<<8)*i;if(t.isBelowSmallest(e,n))return[a,!1];var u=t.nextInitializedTick(e,n,r).index,c=Math.max(a,u);return[c,c===u]}var s=(1+(o+1>>8)<<8)*i-1;if(this.isAtOrAboveLargest(e,n))return[s,!1];var l=this.nextInitializedTick(e,n,r).index,p=Math.min(s,l);return[p,p===l]},t}();function K(t){var e=n.BigInt(t).toString(16);return e.length%2!=0&&(e="0"+e),"0x"+e}function z(t,n){var r=t.input instanceof e.Token?t.input:t.input===e.Currency.ETHER?e.WETH9[t.chainId]:void 0;if(!r)throw new Error("Could not wrap input currency");var i=t.pools.reduce((function(t,e,n){var r=t.inputToken,i=t.path,o=t.types,a=e.token0.equals(r)?e.token1:e.token0;return 0===n?{inputToken:a,types:["address","uint24","address"],path:[r.address,e.fee,a.address]}:{inputToken:a,types:[].concat(o,["uint24","address"]),path:[].concat(i,[e.fee,a.address])}}),{inputToken:r,path:[],types:[]}),o=i.path,u=i.types;return n?a.pack(u.reverse(),o.reverse()):a.pack(u,o)}function Q(t,r){var i=n.leftShift(n.BigInt(t),n.BigInt(192)),o=n.BigInt(r),a=n.divide(i,o);return e.sqrt(a)}function Y(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}var o=n.divide(n.multiply(t,e),E);return n.divide(n.multiply(n.BigInt(r),o),n.subtract(e,t))}function $(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}return n.divide(n.multiply(n.BigInt(r),E),n.subtract(e,t))}function J(t,e,r,i,o){if(n.greaterThan(e,r)){var a=[r,e];e=a[0],r=a[1]}if(n.lessThanOrEqual(t,e))return Y(e,r,i);if(n.lessThan(t,r)){var u=Y(t,r,i),c=$(e,t,o);return n.lessThan(u,c)?u:c}return $(e,r,o)}function V(t,r,i){var o=U.getSqrtRatioAtTick(i),a=n.multiply(o,o);return t.sortsBefore(r)?new e.Price(t,r,b,a):new e.Price(t,r,a,b)}var Z=function(t){var e=t.index,i=t.liquidityGross,o=t.liquidityNet;e>=U.MIN_TICK&&e<=U.MAX_TICK||r(!1),this.index=e,this.liquidityGross=n.BigInt(i),this.liquidityNet=n.BigInt(o)},tt=function(){function t(t,e){var n=t.map((function(t){return t instanceof Z?t:new Z(t)}));G.validateList(n,e),this.ticks=n}var e=t.prototype;return e.getTick=function(){var t=p(y.mark((function t(e){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",G.getTick(this.ticks,e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var t=p(y.mark((function t(e,n,r){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",G.nextInitializedTickWithinOneWord(this.ticks,e,n,r));case 1:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),t}(),et=new H,nt=function(){function t(t,e,i,o,a,u,c){void 0===c&&(c=et),Number.isInteger(i)&&i<1e6||r(!1);var s=U.getSqrtRatioAtTick(u),l=U.getSqrtRatioAtTick(u+1);n.greaterThanOrEqual(n.BigInt(o),s)&&n.lessThanOrEqual(n.BigInt(o),l)||r(!1);var p=t.sortsBefore(e)?[t,e]:[e,t];this.token0=p[0],this.token1=p[1],this.fee=i,this.sqrtRatioX96=n.BigInt(o),this.liquidity=n.BigInt(a),this.tickCurrent=u,this.tickDataProvider=Array.isArray(c)?new tt(c,x[i]):c}t.getAddress=function(t,e,n){return R({factoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",fee:n,tokenA:t,tokenB:e})};var i=t.prototype;return i.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},i.priceOf=function(t){return this.involvesToken(t)||r(!1),t.equals(this.token0)?this.token0Price:this.token1Price},i.getOutputAmount=function(){var i=p(y.mark((function i(o){var a,u,c,s,l;return y.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return this.involvesToken(o.token)||r(!1),a=o.token.equals(this.token0),i.next=4,this.swap(a,o.raw);case 4:return c=(u=i.sent).sqrtRatioX96,s=u.liquidity,l=u.tickCurrent,i.abrupt("return",[new e.TokenAmount(a?this.token1:this.token0,n.multiply(u.amountCalculated,I)),new t(this.token0,this.token1,this.fee,c,s,l,this.tickDataProvider)]);case 11:case"end":return i.stop()}}),i,this)})));return function(t){return i.apply(this,arguments)}}(),i.getInputAmount=function(){var i=p(y.mark((function i(o){var a,u,c,s,l;return y.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return this.involvesToken(o.token)||r(!1),a=o.token.equals(this.token1),i.next=4,this.swap(a,n.multiply(o.raw,I));case 4:return c=(u=i.sent).sqrtRatioX96,s=u.liquidity,l=u.tickCurrent,i.abrupt("return",[new e.TokenAmount(a?this.token0:this.token1,u.amountCalculated),new t(this.token0,this.token1,this.fee,c,s,l,this.tickDataProvider)]);case 11:case"end":return i.stop()}}),i,this)})));return function(t){return i.apply(this,arguments)}}(),i.swap=function(){var t=p(y.mark((function t(e,i,o){var a,u,c,s,l,p;return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o||(o=e?n.add(U.MIN_SQRT_RATIO,w):n.subtract(U.MAX_SQRT_RATIO,w)),e?(n.greaterThan(o,U.MIN_SQRT_RATIO)||r(!1),n.lessThan(o,this.sqrtRatioX96)||r(!1)):(n.lessThan(o,U.MAX_SQRT_RATIO)||r(!1),n.greaterThan(o,this.sqrtRatioX96)||r(!1)),a=n.greaterThanOrEqual(i,q),u={amountSpecifiedRemaining:i,amountCalculated:q,sqrtPriceX96:this.sqrtRatioX96,tick:this.tickCurrent,liquidity:this.liquidity};case 4:if(!n.notEqual(u.amountSpecifiedRemaining,q)||u.sqrtPriceX96==o){t.next=35;break}return(c={}).sqrtPriceStartX96=u.sqrtPriceX96,t.next=9,this.tickDataProvider.nextInitializedTickWithinOneWord(u.tick,e,this.tickSpacing);case 9:if(c.tickNext=(s=t.sent)[0],c.initialized=s[1],c.tickNext<U.MIN_TICK?c.tickNext=U.MIN_TICK:c.tickNext>U.MAX_TICK&&(c.tickNext=U.MAX_TICK),c.sqrtPriceNextX96=U.getSqrtRatioAtTick(c.tickNext),l=F.computeSwapStep(u.sqrtPriceX96,(e?n.lessThan(c.sqrtPriceNextX96,o):n.greaterThan(c.sqrtPriceNextX96,o))?o:c.sqrtPriceNextX96,u.liquidity,u.amountSpecifiedRemaining,this.fee),u.sqrtPriceX96=l[0],c.amountIn=l[1],c.amountOut=l[2],c.feeAmount=l[3],a?(u.amountSpecifiedRemaining=n.subtract(u.amountSpecifiedRemaining,n.add(c.amountIn,c.feeAmount)),u.amountCalculated=n.subtract(u.amountCalculated,c.amountOut)):(u.amountSpecifiedRemaining=n.add(u.amountSpecifiedRemaining,c.amountOut),u.amountCalculated=n.add(u.amountCalculated,n.add(c.amountIn,c.feeAmount))),!n.equal(u.sqrtPriceX96,c.sqrtPriceNextX96)){t.next=32;break}if(!c.initialized){t.next=29;break}return t.t0=n,t.next=25,this.tickDataProvider.getTick(c.tickNext);case 25:t.t1=t.sent.liquidityNet,p=t.t0.BigInt.call(t.t0,t.t1),e&&(p=n.multiply(p,I)),u.liquidity=P.addDelta(u.liquidity,p);case 29:u.tick=e?c.tickNext-1:c.tickNext,t.next=33;break;case 32:u.sqrtPriceX96!=c.sqrtPriceStartX96&&(u.tick=U.getTickAtSqrtRatio(u.sqrtPriceX96));case 33:t.next=4;break;case 35:return t.abrupt("return",{amountCalculated:u.amountCalculated,sqrtRatioX96:u.sqrtPriceX96,liquidity:u.liquidity,tickCurrent:u.tick});case 36:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),f(t,[{key:"token0Price",get:function(){var t;return null!=(t=this._token0Price)?t:this._token0Price=new e.Price(this.token0,this.token1,b,n.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}},{key:"token1Price",get:function(){var t;return null!=(t=this._token1Price)?t:this._token1Price=new e.Price(this.token1,this.token0,n.multiply(this.sqrtRatioX96,this.sqrtRatioX96),b)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"tickSpacing",get:function(){return x[this.fee]}}]),t}(),rt=function(){function t(t){var e=t.pool,i=t.liquidity,o=t.tickLower,a=t.tickUpper;this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,o<a||r(!1),o>=U.MIN_TICK&&o%e.tickSpacing==0||r(!1),a<=U.MAX_TICK&&a%e.tickSpacing==0||r(!1),this.pool=e,this.tickLower=o,this.tickUpper=a,this.liquidity=n.BigInt(i)}return t.fromAmounts=function(e){var n=e.pool,r=e.tickLower,i=e.tickUpper,o=e.amount0,a=e.amount1,u=U.getSqrtRatioAtTick(r),c=U.getSqrtRatioAtTick(i);return new t({pool:n,tickLower:r,tickUpper:i,liquidity:J(n.sqrtRatioX96,u,c,o,a)})},t.fromAmount0=function(n){return t.fromAmounts({pool:n.pool,tickLower:n.tickLower,tickUpper:n.tickUpper,amount0:n.amount0,amount1:e.MaxUint256})},t.fromAmount1=function(n){return t.fromAmounts({pool:n.pool,tickLower:n.tickLower,tickUpper:n.tickUpper,amount0:e.MaxUint256,amount1:n.amount1})},f(t,[{key:"token0PriceLower",get:function(){return V(this.pool.token0,this.pool.token1,this.tickLower)}},{key:"token0PriceUpper",get:function(){return V(this.pool.token0,this.pool.token1,this.tickUpper)}},{key:"amount0",get:function(){return null===this._token0Amount&&(this._token0Amount=new e.TokenAmount(this.pool.token0,this.pool.tickCurrent<this.tickLower?C.getAmount0Delta(U.getSqrtRatioAtTick(this.tickLower),U.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):this.pool.tickCurrent<this.tickUpper?C.getAmount0Delta(this.pool.sqrtRatioX96,U.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):q)),this._token0Amount}},{key:"amount1",get:function(){return null===this._token1Amount&&(this._token1Amount=this.pool.tickCurrent<this.tickLower?new e.TokenAmount(this.pool.token0,q):new e.TokenAmount(this.pool.token1,C.getAmount1Delta(U.getSqrtRatioAtTick(this.tickLower),this.pool.tickCurrent<this.tickUpper?this.pool.sqrtRatioX96:U.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}},{key:"mintAmounts",get:function(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:C.getAmount0Delta(U.getSqrtRatioAtTick(this.tickLower),U.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:q}:this.pool.tickCurrent<this.tickUpper?{amount0:C.getAmount0Delta(this.pool.sqrtRatioX96,U.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:C.getAmount1Delta(U.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:q,amount1:C.getAmount1Delta(U.getSqrtRatioAtTick(this.tickLower),U.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}}]),t}(),it=function(){function t(t,n,i){t.length>0||r(!1);var o=t[0].chainId;t.every((function(t){return t.chainId===o}))||r(!1);var a=e.WETH9[o],u=n instanceof e.Token&&t[0].involvesToken(n),c=n===e.ETHER&&a&&t[0].involvesToken(a);u||c||r(!1);var s=void 0===i,l=i instanceof e.Token&&t[t.length-1].involvesToken(i),p=i===e.ETHER&&a&&t[t.length-1].involvesToken(a);s||l||p||r(!1);for(var d,f=[n instanceof e.Token?n:a],h=v(t.entries());!(d=h()).done;){var m=d.value,k=m[1],g=f[m[0]];g.equals(k.token0)||g.equals(k.token1)||r(!1);var T=g.equals(k.token0)?k.token1:k.token0;f.push(T)}this.pools=t,this.tokenPath=f,this.input=n,this.output=null!=i?i:f[f.length-1]}return f(t,[{key:"chainId",get:function(){return this.pools[0].chainId}}]),t}();function ot(t,n){return e.currencyEquals(t.inputAmount.currency,n.inputAmount.currency)||r(!1),e.currencyEquals(t.outputAmount.currency,n.outputAmount.currency)||r(!1),t.outputAmount.equalTo(n.outputAmount)?t.inputAmount.equalTo(n.inputAmount)?t.route.tokenPath.length-n.route.tokenPath.length:t.inputAmount.lessThan(n.inputAmount)?-1:1:t.outputAmount.lessThan(n.outputAmount)?1:-1}function at(t,n){return t instanceof e.TokenAmount?t:t.currency===e.ETHER?new e.TokenAmount(e.WETH9[n],t.raw):void r(!1)}function ut(t,n){return t instanceof e.Token?t:t===e.ETHER?e.WETH9[n]:void r(!1)}var ct=function(){function t(t){var n=t.route,i=t.inputAmount,o=t.outputAmount,a=t.tradeType;e.currencyEquals(i.currency,n.input)||r(!1),e.currencyEquals(o.currency,n.output)||r(!1),this.route=n,this.inputAmount=i,this.outputAmount=o,this.tradeType=a}t.exactIn=function(){var n=p(y.mark((function n(r,i){return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.fromRoute(r,i,e.TradeType.EXACT_INPUT));case 1:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.exactOut=function(){var n=p(y.mark((function n(r,i){return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.fromRoute(r,i,e.TradeType.EXACT_OUTPUT));case 1:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.fromRoute=function(){var n=p(y.mark((function n(i,o,a){var u,c,s,l,p,d,f;return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(u=new Array(i.tokenPath.length),a!==e.TradeType.EXACT_INPUT){n.next=17;break}e.currencyEquals(o.currency,i.input)||r(!1),u[0]=at(o,i.chainId),c=0;case 5:if(!(c<i.tokenPath.length-1)){n.next=15;break}return s=i.pools[c],n.next=9,s.getOutputAmount(u[c]);case 9:u[c+1]=n.sent[0];case 12:c++,n.next=5;break;case 15:n.next=30;break;case 17:e.currencyEquals(o.currency,i.output)||r(!1),u[u.length-1]=at(o,i.chainId),l=i.tokenPath.length-1;case 20:if(!(l>0)){n.next=30;break}return p=i.pools[l-1],n.next=24,p.getInputAmount(u[l]);case 24:u[l-1]=n.sent[0];case 27:l--,n.next=20;break;case 30:return d=a===e.TradeType.EXACT_INPUT?o:i.input===e.ETHER?e.CurrencyAmount.ether(u[0].raw):u[0],f=a===e.TradeType.EXACT_OUTPUT?o:i.output===e.ETHER?e.CurrencyAmount.ether(u[u.length-1].raw):u[u.length-1],n.abrupt("return",new t({route:i,tradeType:a,inputAmount:d,outputAmount:f}));case 33:case"end":return n.stop()}}),n)})));return function(t,e,r){return n.apply(this,arguments)}}(),t.createUncheckedTrade=function(e){return new t(e)};var n=t.prototype;return n.minimumAmountOut=function(t){if(t.lessThan(q)&&r(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return this.outputAmount;var n=new e.Fraction(w).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof e.TokenAmount?new e.TokenAmount(this.outputAmount.token,n):e.CurrencyAmount.ether(n)},n.maximumAmountIn=function(t){if(t.lessThan(q)&&r(!1),this.tradeType===e.TradeType.EXACT_INPUT)return this.inputAmount;var n=new e.Fraction(w).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof e.TokenAmount?new e.TokenAmount(this.inputAmount.token,n):e.CurrencyAmount.ether(n)},n.worstExecutionPrice=function(t){return new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).raw,this.minimumAmountOut(t).raw)},t.bestTradeExactIn=function(){var n=p(y.mark((function n(i,o,a,u,c,s,l){var p,d,f,h,m,v,k,g,T,A,x,I;return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:f=void 0===(d=(p=void 0===u?{}:u).maxNumResults)?3:d,m=void 0===(h=p.maxHops)?3:h,void 0===c&&(c=[]),void 0===s&&(s=o),void 0===l&&(l=[]),i.length>0||r(!1),m>0||r(!1),s===o||c.length>0||r(!1),void 0===(v=o instanceof e.TokenAmount?o.token.chainId:a instanceof e.Token?a.chainId:void 0)&&r(!1),k=at(o,v),g=ut(a,v),T=0;case 12:if(!(T<i.length)){n.next=48;break}if((A=i[T]).token0.equals(k.token)||A.token1.equals(k.token)){n.next=16;break}return n.abrupt("continue",45);case 16:return x=void 0,n.prev=17,n.next=21,A.getOutputAmount(k);case 21:x=n.sent[0],n.next=30;break;case 25:if(n.prev=25,n.t0=n.catch(17),!n.t0.isInsufficientInputAmountError){n.next=29;break}return n.abrupt("continue",45);case 29:throw n.t0;case 30:if(!x.token.equals(g)){n.next=41;break}return n.t1=e.sortedInsert,n.t2=l,n.next=35,t.fromRoute(new it([].concat(c,[A]),s.currency,a),s,e.TradeType.EXACT_INPUT);case 35:n.t3=n.sent,n.t4=f,n.t5=ot,(0,n.t1)(n.t2,n.t3,n.t4,n.t5),n.next=45;break;case 41:if(!(m>1&&i.length>1)){n.next=45;break}return I=i.slice(0,T).concat(i.slice(T+1,i.length)),n.next=45,t.bestTradeExactIn(I,x,a,{maxNumResults:f,maxHops:m-1},[].concat(c,[A]),s,l);case 45:T++,n.next=12;break;case 48:return n.abrupt("return",l);case 49:case"end":return n.stop()}}),n,null,[[17,25]])})));return function(t,e,r,i,o,a,u){return n.apply(this,arguments)}}(),t.bestTradeExactOut=function(){var n=p(y.mark((function n(i,o,a,u,c,s,l){var p,d,f,h,m,v,k,g,T,A,x,I;return y.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:f=void 0===(d=(p=void 0===u?{}:u).maxNumResults)?3:d,m=void 0===(h=p.maxHops)?3:h,void 0===c&&(c=[]),void 0===s&&(s=a),void 0===l&&(l=[]),i.length>0||r(!1),m>0||r(!1),s===a||c.length>0||r(!1),void 0===(v=a instanceof e.TokenAmount?a.token.chainId:o instanceof e.Token?o.chainId:void 0)&&r(!1),k=at(a,v),g=ut(o,v),T=0;case 12:if(!(T<i.length)){n.next=48;break}if((A=i[T]).token0.equals(k.token)||A.token1.equals(k.token)){n.next=16;break}return n.abrupt("continue",45);case 16:return x=void 0,n.prev=17,n.next=21,A.getInputAmount(k);case 21:x=n.sent[0],n.next=30;break;case 25:if(n.prev=25,n.t0=n.catch(17),!n.t0.isInsufficientReservesError){n.next=29;break}return n.abrupt("continue",45);case 29:throw n.t0;case 30:if(!x.token.equals(g)){n.next=41;break}return n.t1=e.sortedInsert,n.t2=l,n.next=35,t.fromRoute(new it([A].concat(c),o,s.currency),s,e.TradeType.EXACT_OUTPUT);case 35:n.t3=n.sent,n.t4=f,n.t5=ot,(0,n.t1)(n.t2,n.t3,n.t4,n.t5),n.next=45;break;case 41:if(!(m>1&&i.length>1)){n.next=45;break}return I=i.slice(0,T).concat(i.slice(T+1,i.length)),n.next=45,t.bestTradeExactOut(I,o,x,{maxNumResults:f,maxHops:m-1},[A].concat(c),s,l);case 45:T++,n.next=12;break;case 48:return n.abrupt("return",l);case 49:case"end":return n.stop()}}),n,null,[[17,25]])})));return function(t,e,r,i,o,a,u){return n.apply(this,arguments)}}(),f(t,[{key:"executionPrice",get:function(){var t;return null!=(t=this._executionPrice)?t:this._executionPrice=new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw)}}]),t}(),st=function(){function t(){}return t.encodePermit=function(e,n){return Object.keys(n).some((function(t){return"nonce"===t}))?t.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,K(n.nonce),K(n.expiry),n.v,n.r,n.s]):t.INTERFACE.encodeFunctionData("selfPermit",[e.address,K(n.amount),K(n.deadline),n.v,n.r,n.s])},t}();st.INTERFACE=new i.Interface(c.abi);var lt=K(n.subtract(n.exponentiate(n.BigInt(2),n.BigInt(128)),n.BigInt(1)));function pt(t){return Object.keys(t).some((function(t){return"recipient"===t}))}var dt=function(t){function i(){return t.call(this)||this}return h(i,t),i.increaseCallParameters=function(t,o){n.greaterThan(t.liquidity,q)||r(!1);var a=[],u=t.mintAmounts,c=u.amount0,s=u.amount1,l=new e.Fraction(w).subtract(o.slippageTolerance),p=K(l.multiply(c).quotient),d=K(l.multiply(s).quotient);if(pt(o)&&o.createPool&&a.push(i.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[t.pool.token0.address,t.pool.token1.address,t.pool.fee,K(t.pool.sqrtRatioX96)])),o.token0Permit&&a.push(i.encodePermit(t.pool.token0,o.token0Permit)),o.token1Permit&&a.push(i.encodePermit(t.pool.token1,o.token1Permit)),pt(o)){var f=e.validateAndParseAddress(o.recipient);a.push(i.INTERFACE.encodeFunctionData("mint",[{token0:t.pool.token0.address,token1:t.pool.token1.address,fee:t.pool.fee,tickLower:t.tickLower,tickUpper:t.tickUpper,amount0Desired:K(c),amount1Desired:K(s),amount0Min:p,amount1Min:d,recipient:f,deadline:K(o.deadline)}]))}else n.greaterThan(n.BigInt(o.tokenId),q)||r(!1),a.push(i.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:K(o.tokenId),amount0Desired:K(c),amount1Desired:K(s),amount0Min:p,amount1Min:d,deadline:K(o.deadline)}]));var h=K(0);if(o.useEther){var m=e.WETH9[t.pool.chainId];m&&(t.pool.token0.equals(m)||t.pool.token1.equals(m))||r(!1),h=K(t.pool.token0.equals(m)?c:s),a.push(i.INTERFACE.encodeFunctionData("refundETH"))}return 1===a.length?{calldata:a[0],value:h}:{calldata:i.INTERFACE.encodeFunctionData("multicall",[a]),value:h}},i.decreaseCallParameters=function(t,o){var a;if(n.greaterThan(t.liquidity,q)||r(!1),n.greaterThan(n.BigInt(o.tokenId),q)||r(!1),o.receiveEther){var u=e.WETH9[t.pool.chainId];u&&(t.pool.token0.equals(u)||t.pool.token1.equals(u))||r(!1)}var c=e.validateAndParseAddress(o.recipient),s=null!=(a=o.liquidityPercentage)?a:new e.Percent(1),l=s.multiply(t.liquidity).quotient,p=new e.Fraction(w).subtract(o.slippageTolerance),d=K(s.multiply(p).multiply(t.amount0.raw).quotient),f=K(s.multiply(p).multiply(t.amount1.raw).quotient),h=[];if(n.greaterThan(l,q)&&h.push(i.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:K(o.tokenId),liquidity:K(l),amount0Min:d,amount1Min:f,deadline:K(o.deadline)}])),h.push(i.INTERFACE.encodeFunctionData("collect",[{tokenId:K(o.tokenId),recipient:o.receiveEther?o.nonfungiblePositionManagerAddressOverride:c,amount0Max:lt,amount1Max:lt}])),o.receiveEther){var m=e.WETH9[t.pool.chainId],v=t.pool.token0.equals(m)?d:f;h.push(i.INTERFACE.encodeFunctionData("unwrapWETH9",[v,c]));var k=t.pool.token0.equals(m)?t.pool.token1:t.pool.token0,g=t.pool.token0.equals(m)?f:d;h.push(i.INTERFACE.encodeFunctionData("sweepToken",[k.address,g,c]))}return o.burnToken&&(s.equalTo(w)||r(!1),h.push(i.INTERFACE.encodeFunctionData("burn",[o.tokenId]))),{calldata:i.INTERFACE.encodeFunctionData("multicall",[h]),value:K(0)}},i}(st);dt.ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",dt.INTERFACE=new i.Interface(u.abi);var ft=function(t){function n(){return t.call(this)||this}return h(n,t),n.swapCallParameters=function(t,i){var o=[];i.inputTokenPermit&&o.push(n.encodePermit(t.inputAmount.currency,i.inputTokenPermit));var a=e.validateAndParseAddress(i.recipient),u=K(i.deadline),c=K(t.maximumAmountIn(i.slippageTolerance).raw),s=K(t.minimumAmountOut(i.slippageTolerance).raw),l=1===t.route.pools.length,p=e.currencyEquals(t.inputAmount.currency,e.ETHER)?c:K(0),d=e.currencyEquals(t.inputAmount.currency,e.ETHER)&&t.tradeType===e.TradeType.EXACT_OUTPUT,f=e.currencyEquals(t.outputAmount.currency,e.ETHER);if(l)if(t.tradeType===e.TradeType.EXACT_INPUT){var h={tokenIn:t.route.tokenPath[0].address,tokenOut:t.route.tokenPath[1].address,fee:t.route.pools[0].fee,recipient:f?i.swapRouterAddressOverride:a,deadline:u,amountIn:c,amountOutMinimum:s,sqrtPriceLimitX96:K(void 0===i.sqrtPriceLimitX96?0:i.sqrtPriceLimitX96)},m=n.INTERFACE.encodeFunctionData("exactInputSingle",[h]);o.push(m)}else{var v={tokenIn:t.route.tokenPath[0].address,tokenOut:t.route.tokenPath[1].address,fee:t.route.pools[0].fee,recipient:f?i.swapRouterAddressOverride:a,deadline:u,amountOut:s,amountInMaximum:c,sqrtPriceLimitX96:K(void 0===i.sqrtPriceLimitX96?0:i.sqrtPriceLimitX96)},k=n.INTERFACE.encodeFunctionData("exactOutputSingle",[v]);o.push(k)}else{void 0!==i.sqrtPriceLimitX96&&r(!1);var g=z(t.route,t.tradeType===e.TradeType.EXACT_OUTPUT);if(t.tradeType===e.TradeType.EXACT_INPUT){var T=n.INTERFACE.encodeFunctionData("exactInput",[{path:g,recipient:f?i.swapRouterAddressOverride:a,deadline:u,amountIn:c,amountOutMinimum:s}]);o.push(T)}else{var y=n.INTERFACE.encodeFunctionData("exactOutput",[{path:g,recipient:f?i.swapRouterAddressOverride:a,deadline:u,amountOut:s,amountInMaximum:c}]);o.push(y)}}return d&&o.push(n.INTERFACE.encodeFunctionData("refundETH")),f&&o.push(n.INTERFACE.encodeFunctionData("unwrapWETH9",[s,a])),1===o.length?{calldata:o[0],value:p}:{calldata:n.INTERFACE.encodeFunctionData("multicall",[o]),value:p}},n}(st);ft.ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",ft.INTERFACE=new i.Interface(s.abi),exports.FACTORY_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.FullMath=S,exports.LiquidityMath=P,exports.NONFUNGIBLE_POSITION_MANAGER_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.NoTickDataProvider=H,exports.NonfungiblePositionManager=dt,exports.POOL_INIT_CODE_HASH=A,exports.Pool=nt,exports.Position=rt,exports.Route=it,exports.SWAP_ROUTER_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.SqrtPriceMath=C,exports.SwapRouter=ft,exports.TICK_SPACINGS=x,exports.Tick=Z,exports.TickList=G,exports.TickListDataProvider=tt,exports.TickMath=U,exports.Trade=ct,exports.computePoolAddress=R,exports.encodeRouteToPath=z,exports.encodeSqrtRatioX96=Q,exports.isSorted=j,exports.maxLiquidityForAmounts=J,exports.mostSignificantBit=B,exports.nearestUsableTick=function(t,e){Number.isInteger(t)&&Number.isInteger(e)||r(!1),e>0||r(!1),t>=U.MIN_TICK&&t<=U.MAX_TICK||r(!1);var n=Math.round(t/e)*e;return n<U.MIN_TICK?n+e:n>U.MAX_TICK?n-e:n},exports.priceToClosestTick=function(t){t.baseCurrency instanceof e.Token&&t.quoteCurrency instanceof e.Token||r(!1);var n=t.baseCurrency.sortsBefore(t.quoteCurrency),i=n?Q(t.raw.numerator,t.raw.denominator):Q(t.raw.denominator,t.raw.numerator),o=U.getTickAtSqrtRatio(i),a=V(t.baseCurrency,t.quoteCurrency,o+1);return n?t.lessThan(a)||o++:t.greaterThan(a)||o++,o},exports.tickToPrice=V,exports.toHex=K,exports.tradeComparator=ot;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@uniswap/sdk-core"),n=t(require("jsbi")),r=t(require("tiny-invariant")),i=require("@ethersproject/abi"),o=require("@ethersproject/address"),a=require("@ethersproject/solidity"),u=require("@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json"),c=require("@uniswap/v3-periphery/artifacts/contracts/interfaces/ISelfPermit.sol/ISelfPermit.json"),s=require("@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json");function l(t,e,n,r,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,i)}function d(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){l(o,r,i,a,u,"next",t)}function u(t){l(o,r,i,a,u,"throw",t)}a(void 0)}))}}function p(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function f(t,e,n){return e&&p(t.prototype,e),n&&p(t,n),t}function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function m(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function k(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return v(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var g,y,T,A=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var i=Object.create((e&&e.prototype instanceof d?e:d).prototype),o=new I(r||[]);return i._invoke=function(t,e,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=T(a,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=s(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(t,n,o),i}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function d(){}function p(){}function f(){}var h={};h[i]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(w([])));v&&v!==e&&n.call(v,i)&&(h=v);var k=f.prototype=d.prototype=Object.create(h);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function y(t,e){var r;this._invoke=function(i,o){function a(){return new e((function(r,a){!function r(i,o,a,u){var c=s(t[i],t,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(d).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function T(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,T(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,l;var i=r.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function w(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=k.constructor=f,f.constructor=p,p.displayName=u(f,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,u(t,a,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},g(y.prototype),y.prototype[o]=function(){return this},t.AsyncIterator=y,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new y(c(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(k),u(k,a,"Generator"),k[i]=function(){return this},k.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=w,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),x(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:w(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(T={exports:{}}),T.exports),x="0xc02f72e8ae5e68802e6d893d58ddfb0df89a2f4c9c2f04927db1186a29373660";(y=exports.FeeAmount||(exports.FeeAmount={}))[y.LOW=500]="LOW",y[y.MEDIUM=3e3]="MEDIUM",y[y.HIGH=1e4]="HIGH";var I=((g={})[exports.FeeAmount.LOW]=10,g[exports.FeeAmount.MEDIUM]=60,g[exports.FeeAmount.HIGH]=200,g),w=n.BigInt(-1),E=n.BigInt(0),q=n.BigInt(1),R=n.exponentiate(n.BigInt(2),n.BigInt(96)),b=n.exponentiate(R,n.BigInt(2));function P(t){var e=t.factoryAddress,n=t.tokenA,r=t.tokenB,u=t.fee,c=n.sortsBefore(r)?[n,r]:[r,n];return o.getCreate2Address(e,a.keccak256(["bytes"],[i.defaultAbiCoder.encode(["address","address","uint24"],[c[0].address,c[1].address,u])]),x)}var S=function(){function t(){}return t.addDelta=function(t,e){return n.lessThan(e,E)?n.subtract(t,n.multiply(e,w)):n.add(t,e)},t}(),O=function(){function t(){}return t.mulDivRoundingUp=function(t,e,r){var i=n.multiply(t,e),o=n.divide(i,r);return n.notEqual(n.remainder(i,r),E)&&(o=n.add(o,q)),o},t}(),C=n.subtract(n.exponentiate(n.BigInt(2),n.BigInt(160)),q);function N(t,r){var i=n.multiply(t,r);return n.bitwiseAnd(i,e.MaxUint256)}var _=function(){function t(){}return t.getAmount0Delta=function(t,e,r,i){if(n.greaterThan(t,e)){var o=[e,t];t=o[0],e=o[1]}var a=n.leftShift(r,n.BigInt(96)),u=n.subtract(e,t);return i?O.mulDivRoundingUp(O.mulDivRoundingUp(a,u,e),q,t):n.divide(n.divide(n.multiply(a,u),e),t)},t.getAmount1Delta=function(t,e,r,i){if(n.greaterThan(t,e)){var o=[e,t];t=o[0],e=o[1]}return i?O.mulDivRoundingUp(r,n.subtract(e,t),R):n.divide(n.multiply(r,n.subtract(e,t)),R)},t.getNextSqrtPriceFromInput=function(t,e,i,o){return n.greaterThan(t,E)||r(!1),n.greaterThan(e,E)||r(!1),o?this.getNextSqrtPriceFromAmount0RoundingUp(t,e,i,!0):this.getNextSqrtPriceFromAmount1RoundingDown(t,e,i,!0)},t.getNextSqrtPriceFromOutput=function(t,e,i,o){return n.greaterThan(t,E)||r(!1),n.greaterThan(e,E)||r(!1),o?this.getNextSqrtPriceFromAmount1RoundingDown(t,e,i,!1):this.getNextSqrtPriceFromAmount0RoundingUp(t,e,i,!1)},t.getNextSqrtPriceFromAmount0RoundingUp=function(t,i,o,a){if(n.equal(o,E))return t;var u=n.leftShift(i,n.BigInt(96));if(a){var c=N(o,t);if(n.equal(n.divide(c,o),t)){var s=(d=n.add(u,c),n.bitwiseAnd(d,e.MaxUint256));if(n.greaterThanOrEqual(s,u))return O.mulDivRoundingUp(u,t,s)}return O.mulDivRoundingUp(u,q,n.add(n.divide(u,t),o))}var l=N(o,t);n.equal(n.divide(l,o),t)||r(!1),n.greaterThan(u,l)||r(!1);var d,p=n.subtract(u,l);return O.mulDivRoundingUp(u,t,p)},t.getNextSqrtPriceFromAmount1RoundingDown=function(t,e,i,o){if(o){var a=n.lessThanOrEqual(i,C)?n.divide(n.leftShift(i,n.BigInt(96)),e):n.divide(n.multiply(i,R),e);return n.add(t,a)}var u=O.mulDivRoundingUp(i,R,e);return n.greaterThan(t,u)||r(!1),n.subtract(t,u)},t}(),F=n.exponentiate(n.BigInt(10),n.BigInt(6)),D=function(){function t(){}return t.computeSwapStep=function(t,e,r,i,o){var a={},u=n.greaterThanOrEqual(t,e),c=n.greaterThanOrEqual(i,E);if(c){var s=n.divide(n.multiply(i,n.subtract(F,n.BigInt(o))),F);a.amountIn=u?_.getAmount0Delta(e,t,r,!0):_.getAmount1Delta(t,e,r,!0),a.sqrtRatioNextX96=n.greaterThanOrEqual(s,a.amountIn)?e:_.getNextSqrtPriceFromInput(t,r,s,u)}else a.amountOut=u?_.getAmount1Delta(e,t,r,!1):_.getAmount0Delta(t,e,r,!1),a.sqrtRatioNextX96=n.greaterThanOrEqual(n.multiply(i,w),a.amountOut)?e:_.getNextSqrtPriceFromOutput(t,r,n.multiply(i,w),u);var l=n.equal(e,a.sqrtRatioNextX96);return u?(a.amountIn=l&&c?a.amountIn:_.getAmount0Delta(a.sqrtRatioNextX96,t,r,!0),a.amountOut=l&&!c?a.amountOut:_.getAmount1Delta(a.sqrtRatioNextX96,t,r,!1)):(a.amountIn=l&&c?a.amountIn:_.getAmount1Delta(t,a.sqrtRatioNextX96,r,!0),a.amountOut=l&&!c?a.amountOut:_.getAmount0Delta(t,a.sqrtRatioNextX96,r,!1)),!c&&n.greaterThan(a.amountOut,n.multiply(i,w))&&(a.amountOut=n.multiply(i,w)),a.feeAmount=c&&n.notEqual(a.sqrtRatioNextX96,e)?n.subtract(i,a.amountIn):O.mulDivRoundingUp(a.amountIn,n.BigInt(o),n.subtract(F,n.BigInt(o))),[a.sqrtRatioNextX96,a.amountIn,a.amountOut,a.feeAmount]},t}(),X=n.BigInt(2),B=[128,64,32,16,8,4,2,1].map((function(t){return[t,n.exponentiate(X,n.BigInt(t))]}));function L(t){n.greaterThan(t,E)||r(!1),n.lessThanOrEqual(t,e.MaxUint256)||r(!1);for(var i,o=0,a=k(B);!(i=a()).done;){var u=i.value,c=u[0];n.greaterThanOrEqual(t,u[1])&&(t=n.signedRightShift(t,n.BigInt(c)),o+=c)}return o}function M(t,e){return n.signedRightShift(n.multiply(t,n.BigInt(e)),n.BigInt(128))}var U=n.exponentiate(n.BigInt(2),n.BigInt(32)),H=function(){function t(){}return t.getSqrtRatioAtTick=function(i){i>=t.MIN_TICK&&i<=t.MAX_TICK&&Number.isInteger(i)||r(!1);var o=i<0?-1*i:i,a=n.BigInt(0!=(1&o)?"0xfffcb933bd6fad37aa2d162d1a594001":"0x100000000000000000000000000000000");return 0!=(2&o)&&(a=M(a,"0xfff97272373d413259a46990580e213a")),0!=(4&o)&&(a=M(a,"0xfff2e50f5f656932ef12357cf3c7fdcc")),0!=(8&o)&&(a=M(a,"0xffe5caca7e10e4e61c3624eaa0941cd0")),0!=(16&o)&&(a=M(a,"0xffcb9843d60f6159c9db58835c926644")),0!=(32&o)&&(a=M(a,"0xff973b41fa98c081472e6896dfb254c0")),0!=(64&o)&&(a=M(a,"0xff2ea16466c96a3843ec78b326b52861")),0!=(128&o)&&(a=M(a,"0xfe5dee046a99a2a811c461f1969c3053")),0!=(256&o)&&(a=M(a,"0xfcbe86c7900a88aedcffc83b479aa3a4")),0!=(512&o)&&(a=M(a,"0xf987a7253ac413176f2b074cf7815e54")),0!=(1024&o)&&(a=M(a,"0xf3392b0822b70005940c7a398e4b70f3")),0!=(2048&o)&&(a=M(a,"0xe7159475a2c29b7443b29c7fa6e889d9")),0!=(4096&o)&&(a=M(a,"0xd097f3bdfd2022b8845ad8f792aa5825")),0!=(8192&o)&&(a=M(a,"0xa9f746462d870fdf8a65dc1f90e061e5")),0!=(16384&o)&&(a=M(a,"0x70d869a156d2a1b890bb3df62baf32f7")),0!=(32768&o)&&(a=M(a,"0x31be135f97d08fd981231505542fcfa6")),0!=(65536&o)&&(a=M(a,"0x9aa508b5b7a84e1c677de54f3e99bc9")),0!=(131072&o)&&(a=M(a,"0x5d6af8dedb81196699c329225ee604")),0!=(262144&o)&&(a=M(a,"0x2216e584f5fa1ea926041bedfe98")),0!=(524288&o)&&(a=M(a,"0x48a170391f7dc42444e8fa2")),i>0&&(a=n.divide(e.MaxUint256,a)),n.greaterThan(n.remainder(a,U),E)?n.add(n.divide(a,U),q):n.divide(a,U)},t.getTickAtSqrtRatio=function(e){n.greaterThanOrEqual(e,t.MIN_SQRT_RATIO)&&n.lessThan(e,t.MAX_SQRT_RATIO)||r(!1);var i,o=n.leftShift(e,n.BigInt(32)),a=L(o);i=n.greaterThanOrEqual(n.BigInt(a),n.BigInt(128))?n.signedRightShift(o,n.BigInt(a-127)):n.leftShift(o,n.BigInt(127-a));for(var u=n.leftShift(n.subtract(n.BigInt(a),n.BigInt(128)),n.BigInt(64)),c=0;c<14;c++){i=n.signedRightShift(n.multiply(i,i),n.BigInt(127));var s=n.signedRightShift(i,n.BigInt(128));u=n.bitwiseOr(u,n.leftShift(s,n.BigInt(63-c))),i=n.signedRightShift(i,s)}var l=n.multiply(u,n.BigInt("255738958999603826347141")),d=n.toNumber(n.signedRightShift(n.subtract(l,n.BigInt("3402992956809132418596140100660247210")),n.BigInt(128))),p=n.toNumber(n.signedRightShift(n.add(l,n.BigInt("291339464771989622907027621153398088495")),n.BigInt(128)));return d===p?d:n.lessThanOrEqual(t.getSqrtRatioAtTick(p),e)?p:d},t}();H.MIN_TICK=-887272,H.MAX_TICK=-H.MIN_TICK,H.MIN_SQRT_RATIO=n.BigInt("4295128739"),H.MAX_SQRT_RATIO=n.BigInt("1461446703485210103287273052203988822378723970342");var j=function(){function t(){}var e=t.prototype;return e.getTick=function(){var e=d(A.mark((function e(n){return A.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error(t.ERROR_MESSAGE);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var e=d(A.mark((function e(n,r,i){return A.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error(t.ERROR_MESSAGE);case 1:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t}();function W(t,e){for(var n=0;n<t.length-1;n++)if(e(t[n],t[n+1])>0)return!1;return!0}function G(t,e){return t.index-e.index}j.ERROR_MESSAGE="No tick data provider was given";var K=function(){function t(){}return t.validateList=function(t,e){e>0||r(!1),t.every((function(t){return t.index%e==0}))||r(!1),n.equal(t.reduce((function(t,e){return n.add(t,e.liquidityNet)}),E),E)||r(!1),W(t,G)||r(!1)},t.isBelowSmallest=function(t,e){return t.length>0||r(!1),e<t[0].index},t.isAtOrAboveLargest=function(t,e){return t.length>0||r(!1),e>=t[t.length-1].index},t.getTick=function(t,e){var n=t[this.binarySearch(t,e)];return n.index!==e&&r(!1),n},t.binarySearch=function(t,e){this.isBelowSmallest(t,e)&&r(!1);for(var n,i=0,o=t.length-1;;){if(t[n=Math.floor((i+o)/2)].index<=e&&(n===t.length-1||t[n+1].index>e))return n;t[n].index<e?i=n+1:o=n-1}},t.nextInitializedTick=function(e,n,i){return i?(t.isBelowSmallest(e,n)&&r(!1),t.isAtOrAboveLargest(e,n)?e[e.length-1]:e[this.binarySearch(e,n)]):(this.isAtOrAboveLargest(e,n)&&r(!1),this.isBelowSmallest(e,n)?e[0]:e[this.binarySearch(e,n)+1])},t.nextInitializedTickWithinOneWord=function(e,n,r,i){var o=Math.floor(n/i);if(r){var a=(o>>8<<8)*i;if(t.isBelowSmallest(e,n))return[a,!1];var u=t.nextInitializedTick(e,n,r).index,c=Math.max(a,u);return[c,c===u]}var s=(1+(o+1>>8)<<8)*i-1;if(this.isAtOrAboveLargest(e,n))return[s,!1];var l=this.nextInitializedTick(e,n,r).index,d=Math.min(s,l);return[d,d===l]},t}();function z(t){var e=n.BigInt(t).toString(16);return e.length%2!=0&&(e="0"+e),"0x"+e}function Q(t,n){var r=t.input instanceof e.Token?t.input:t.input===e.Currency.ETHER?e.WETH9[t.chainId]:void 0;if(!r)throw new Error("Could not wrap input currency");var i=t.pools.reduce((function(t,e,n){var r=t.inputToken,i=t.path,o=t.types,a=e.token0.equals(r)?e.token1:e.token0;return 0===n?{inputToken:a,types:["address","uint24","address"],path:[r.address,e.fee,a.address]}:{inputToken:a,types:[].concat(o,["uint24","address"]),path:[].concat(i,[e.fee,a.address])}}),{inputToken:r,path:[],types:[]}),o=i.path,u=i.types;return n?a.pack(u.reverse(),o.reverse()):a.pack(u,o)}function Y(t,r){var i=n.leftShift(n.BigInt(t),n.BigInt(192)),o=n.BigInt(r),a=n.divide(i,o);return e.sqrt(a)}function $(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}var o=n.divide(n.multiply(t,e),R);return n.divide(n.multiply(n.BigInt(r),o),n.subtract(e,t))}function J(t,e,r){if(n.greaterThan(t,e)){var i=[e,t];t=i[0],e=i[1]}return n.divide(n.multiply(n.BigInt(r),R),n.subtract(e,t))}function V(t,e,r,i,o){if(n.greaterThan(e,r)){var a=[r,e];e=a[0],r=a[1]}if(n.lessThanOrEqual(t,e))return $(e,r,i);if(n.lessThan(t,r)){var u=$(t,r,i),c=J(e,t,o);return n.lessThan(u,c)?u:c}return J(e,r,o)}function Z(t,r,i){var o=H.getSqrtRatioAtTick(i),a=n.multiply(o,o);return t.sortsBefore(r)?new e.Price(t,r,b,a):new e.Price(t,r,a,b)}var tt=function(t){var e=t.index,i=t.liquidityGross,o=t.liquidityNet;e>=H.MIN_TICK&&e<=H.MAX_TICK||r(!1),this.index=e,this.liquidityGross=n.BigInt(i),this.liquidityNet=n.BigInt(o)},et=function(){function t(t,e){var n=t.map((function(t){return t instanceof tt?t:new tt(t)}));K.validateList(n,e),this.ticks=n}var e=t.prototype;return e.getTick=function(){var t=d(A.mark((function t(e){return A.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",K.getTick(this.ticks,e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.nextInitializedTickWithinOneWord=function(){var t=d(A.mark((function t(e,n,r){return A.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",K.nextInitializedTickWithinOneWord(this.ticks,e,n,r));case 1:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),t}(),nt=new j,rt=function(){function t(t,e,i,o,a,u,c){void 0===c&&(c=nt),Number.isInteger(i)&&i<1e6||r(!1);var s=H.getSqrtRatioAtTick(u),l=H.getSqrtRatioAtTick(u+1);n.greaterThanOrEqual(n.BigInt(o),s)&&n.lessThanOrEqual(n.BigInt(o),l)||r(!1);var d=t.sortsBefore(e)?[t,e]:[e,t];this.token0=d[0],this.token1=d[1],this.fee=i,this.sqrtRatioX96=n.BigInt(o),this.liquidity=n.BigInt(a),this.tickCurrent=u,this.tickDataProvider=Array.isArray(c)?new et(c,I[i]):c}t.getAddress=function(t,e,n){return P({factoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",fee:n,tokenA:t,tokenB:e})};var i=t.prototype;return i.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},i.priceOf=function(t){return this.involvesToken(t)||r(!1),t.equals(this.token0)?this.token0Price:this.token1Price},i.getOutputAmount=function(){var i=d(A.mark((function i(o){var a,u,c,s,l;return A.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return this.involvesToken(o.token)||r(!1),a=o.token.equals(this.token0),i.next=4,this.swap(a,o.raw);case 4:return c=(u=i.sent).sqrtRatioX96,s=u.liquidity,l=u.tickCurrent,i.abrupt("return",[new e.TokenAmount(a?this.token1:this.token0,n.multiply(u.amountCalculated,w)),new t(this.token0,this.token1,this.fee,c,s,l,this.tickDataProvider)]);case 11:case"end":return i.stop()}}),i,this)})));return function(t){return i.apply(this,arguments)}}(),i.getInputAmount=function(){var i=d(A.mark((function i(o){var a,u,c,s,l;return A.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return this.involvesToken(o.token)||r(!1),a=o.token.equals(this.token1),i.next=4,this.swap(a,n.multiply(o.raw,w));case 4:return c=(u=i.sent).sqrtRatioX96,s=u.liquidity,l=u.tickCurrent,i.abrupt("return",[new e.TokenAmount(a?this.token0:this.token1,u.amountCalculated),new t(this.token0,this.token1,this.fee,c,s,l,this.tickDataProvider)]);case 11:case"end":return i.stop()}}),i,this)})));return function(t){return i.apply(this,arguments)}}(),i.swap=function(){var t=d(A.mark((function t(e,i,o){var a,u,c,s,l,d;return A.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o||(o=e?n.add(H.MIN_SQRT_RATIO,q):n.subtract(H.MAX_SQRT_RATIO,q)),e?(n.greaterThan(o,H.MIN_SQRT_RATIO)||r(!1),n.lessThan(o,this.sqrtRatioX96)||r(!1)):(n.lessThan(o,H.MAX_SQRT_RATIO)||r(!1),n.greaterThan(o,this.sqrtRatioX96)||r(!1)),a=n.greaterThanOrEqual(i,E),u={amountSpecifiedRemaining:i,amountCalculated:E,sqrtPriceX96:this.sqrtRatioX96,tick:this.tickCurrent,liquidity:this.liquidity};case 4:if(!n.notEqual(u.amountSpecifiedRemaining,E)||u.sqrtPriceX96==o){t.next=35;break}return(c={}).sqrtPriceStartX96=u.sqrtPriceX96,t.next=9,this.tickDataProvider.nextInitializedTickWithinOneWord(u.tick,e,this.tickSpacing);case 9:if(c.tickNext=(s=t.sent)[0],c.initialized=s[1],c.tickNext<H.MIN_TICK?c.tickNext=H.MIN_TICK:c.tickNext>H.MAX_TICK&&(c.tickNext=H.MAX_TICK),c.sqrtPriceNextX96=H.getSqrtRatioAtTick(c.tickNext),l=D.computeSwapStep(u.sqrtPriceX96,(e?n.lessThan(c.sqrtPriceNextX96,o):n.greaterThan(c.sqrtPriceNextX96,o))?o:c.sqrtPriceNextX96,u.liquidity,u.amountSpecifiedRemaining,this.fee),u.sqrtPriceX96=l[0],c.amountIn=l[1],c.amountOut=l[2],c.feeAmount=l[3],a?(u.amountSpecifiedRemaining=n.subtract(u.amountSpecifiedRemaining,n.add(c.amountIn,c.feeAmount)),u.amountCalculated=n.subtract(u.amountCalculated,c.amountOut)):(u.amountSpecifiedRemaining=n.add(u.amountSpecifiedRemaining,c.amountOut),u.amountCalculated=n.add(u.amountCalculated,n.add(c.amountIn,c.feeAmount))),!n.equal(u.sqrtPriceX96,c.sqrtPriceNextX96)){t.next=32;break}if(!c.initialized){t.next=29;break}return t.t0=n,t.next=25,this.tickDataProvider.getTick(c.tickNext);case 25:t.t1=t.sent.liquidityNet,d=t.t0.BigInt.call(t.t0,t.t1),e&&(d=n.multiply(d,w)),u.liquidity=S.addDelta(u.liquidity,d);case 29:u.tick=e?c.tickNext-1:c.tickNext,t.next=33;break;case 32:u.sqrtPriceX96!=c.sqrtPriceStartX96&&(u.tick=H.getTickAtSqrtRatio(u.sqrtPriceX96));case 33:t.next=4;break;case 35:return t.abrupt("return",{amountCalculated:u.amountCalculated,sqrtRatioX96:u.sqrtPriceX96,liquidity:u.liquidity,tickCurrent:u.tick});case 36:case"end":return t.stop()}}),t,this)})));return function(e,n,r){return t.apply(this,arguments)}}(),f(t,[{key:"token0Price",get:function(){var t;return null!=(t=this._token0Price)?t:this._token0Price=new e.Price(this.token0,this.token1,b,n.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}},{key:"token1Price",get:function(){var t;return null!=(t=this._token1Price)?t:this._token1Price=new e.Price(this.token1,this.token0,n.multiply(this.sqrtRatioX96,this.sqrtRatioX96),b)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"tickSpacing",get:function(){return I[this.fee]}}]),t}(),it=function(){function t(t){var e=t.pool,i=t.liquidity,o=t.tickLower,a=t.tickUpper;this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,o<a||r(!1),o>=H.MIN_TICK&&o%e.tickSpacing==0||r(!1),a<=H.MAX_TICK&&a%e.tickSpacing==0||r(!1),this.pool=e,this.tickLower=o,this.tickUpper=a,this.liquidity=n.BigInt(i)}return t.fromAmounts=function(e){var n=e.pool,r=e.tickLower,i=e.tickUpper,o=e.amount0,a=e.amount1,u=H.getSqrtRatioAtTick(r),c=H.getSqrtRatioAtTick(i);return new t({pool:n,tickLower:r,tickUpper:i,liquidity:V(n.sqrtRatioX96,u,c,o,a)})},t.fromAmount0=function(n){return t.fromAmounts({pool:n.pool,tickLower:n.tickLower,tickUpper:n.tickUpper,amount0:n.amount0,amount1:e.MaxUint256})},t.fromAmount1=function(n){return t.fromAmounts({pool:n.pool,tickLower:n.tickLower,tickUpper:n.tickUpper,amount0:e.MaxUint256,amount1:n.amount1})},f(t,[{key:"token0PriceLower",get:function(){return Z(this.pool.token0,this.pool.token1,this.tickLower)}},{key:"token0PriceUpper",get:function(){return Z(this.pool.token0,this.pool.token1,this.tickUpper)}},{key:"amount0",get:function(){return null===this._token0Amount&&(this._token0Amount=new e.TokenAmount(this.pool.token0,this.pool.tickCurrent<this.tickLower?_.getAmount0Delta(H.getSqrtRatioAtTick(this.tickLower),H.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):this.pool.tickCurrent<this.tickUpper?_.getAmount0Delta(this.pool.sqrtRatioX96,H.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1):E)),this._token0Amount}},{key:"amount1",get:function(){return null===this._token1Amount&&(this._token1Amount=this.pool.tickCurrent<this.tickLower?new e.TokenAmount(this.pool.token0,E):new e.TokenAmount(this.pool.token1,_.getAmount1Delta(H.getSqrtRatioAtTick(this.tickLower),this.pool.tickCurrent<this.tickUpper?this.pool.sqrtRatioX96:H.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}},{key:"mintAmounts",get:function(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:_.getAmount0Delta(H.getSqrtRatioAtTick(this.tickLower),H.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:E}:this.pool.tickCurrent<this.tickUpper?{amount0:_.getAmount0Delta(this.pool.sqrtRatioX96,H.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:_.getAmount1Delta(H.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:E,amount1:_.getAmount1Delta(H.getSqrtRatioAtTick(this.tickLower),H.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}}]),t}(),ot=function(){function t(t,n,i){t.length>0||r(!1);var o=t[0].chainId;t.every((function(t){return t.chainId===o}))||r(!1);var a=e.WETH9[o],u=n instanceof e.Token&&t[0].involvesToken(n),c=n===e.ETHER&&a&&t[0].involvesToken(a);u||c||r(!1);var s=void 0===i,l=i instanceof e.Token&&t[t.length-1].involvesToken(i),d=i===e.ETHER&&a&&t[t.length-1].involvesToken(a);s||l||d||r(!1);for(var p,f=[n instanceof e.Token?n:a],h=k(t.entries());!(p=h()).done;){var m=p.value,v=m[1],g=f[m[0]];g.equals(v.token0)||g.equals(v.token1)||r(!1);var y=g.equals(v.token0)?v.token1:v.token0;f.push(y)}this.pools=t,this.tokenPath=f,this.input=n,this.output=null!=i?i:f[f.length-1]}return f(t,[{key:"chainId",get:function(){return this.pools[0].chainId}}]),t}();function at(t,n){return e.currencyEquals(t.inputAmount.currency,n.inputAmount.currency)||r(!1),e.currencyEquals(t.outputAmount.currency,n.outputAmount.currency)||r(!1),t.outputAmount.equalTo(n.outputAmount)?t.inputAmount.equalTo(n.inputAmount)?t.route.tokenPath.length-n.route.tokenPath.length:t.inputAmount.lessThan(n.inputAmount)?-1:1:t.outputAmount.lessThan(n.outputAmount)?1:-1}function ut(t,n){return t instanceof e.TokenAmount?t:t.currency===e.ETHER?new e.TokenAmount(e.WETH9[n],t.raw):void r(!1)}function ct(t,n){return t instanceof e.Token?t:t===e.ETHER?e.WETH9[n]:void r(!1)}var st=function(){function t(t){var n=t.route,i=t.inputAmount,o=t.outputAmount,a=t.tradeType;e.currencyEquals(i.currency,n.input)||r(!1),e.currencyEquals(o.currency,n.output)||r(!1),this.route=n,this.inputAmount=i,this.outputAmount=o,this.tradeType=a}t.exactIn=function(){var n=d(A.mark((function n(r,i){return A.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.fromRoute(r,i,e.TradeType.EXACT_INPUT));case 1:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.exactOut=function(){var n=d(A.mark((function n(r,i){return A.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.fromRoute(r,i,e.TradeType.EXACT_OUTPUT));case 1:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}(),t.fromRoute=function(){var n=d(A.mark((function n(i,o,a){var u,c,s,l,d,p,f;return A.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(u=new Array(i.tokenPath.length),a!==e.TradeType.EXACT_INPUT){n.next=17;break}e.currencyEquals(o.currency,i.input)||r(!1),u[0]=ut(o,i.chainId),c=0;case 5:if(!(c<i.tokenPath.length-1)){n.next=15;break}return s=i.pools[c],n.next=9,s.getOutputAmount(u[c]);case 9:u[c+1]=n.sent[0];case 12:c++,n.next=5;break;case 15:n.next=30;break;case 17:e.currencyEquals(o.currency,i.output)||r(!1),u[u.length-1]=ut(o,i.chainId),l=i.tokenPath.length-1;case 20:if(!(l>0)){n.next=30;break}return d=i.pools[l-1],n.next=24,d.getInputAmount(u[l]);case 24:u[l-1]=n.sent[0];case 27:l--,n.next=20;break;case 30:return p=a===e.TradeType.EXACT_INPUT?o:i.input===e.ETHER?e.CurrencyAmount.ether(u[0].raw):u[0],f=a===e.TradeType.EXACT_OUTPUT?o:i.output===e.ETHER?e.CurrencyAmount.ether(u[u.length-1].raw):u[u.length-1],n.abrupt("return",new t({route:i,tradeType:a,inputAmount:p,outputAmount:f}));case 33:case"end":return n.stop()}}),n)})));return function(t,e,r){return n.apply(this,arguments)}}(),t.createUncheckedTrade=function(e){return new t(e)};var n=t.prototype;return n.minimumAmountOut=function(t){if(t.lessThan(E)&&r(!1),this.tradeType===e.TradeType.EXACT_OUTPUT)return this.outputAmount;var n=new e.Fraction(q).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof e.TokenAmount?new e.TokenAmount(this.outputAmount.token,n):e.CurrencyAmount.ether(n)},n.maximumAmountIn=function(t){if(t.lessThan(E)&&r(!1),this.tradeType===e.TradeType.EXACT_INPUT)return this.inputAmount;var n=new e.Fraction(q).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof e.TokenAmount?new e.TokenAmount(this.inputAmount.token,n):e.CurrencyAmount.ether(n)},n.worstExecutionPrice=function(t){return new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).raw,this.minimumAmountOut(t).raw)},t.bestTradeExactIn=function(){var n=d(A.mark((function n(i,o,a,u,c,s,l){var d,p,f,h,m,v,k,g,y,T,x,I;return A.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:f=void 0===(p=(d=void 0===u?{}:u).maxNumResults)?3:p,m=void 0===(h=d.maxHops)?3:h,void 0===c&&(c=[]),void 0===s&&(s=o),void 0===l&&(l=[]),i.length>0||r(!1),m>0||r(!1),s===o||c.length>0||r(!1),void 0===(v=o instanceof e.TokenAmount?o.token.chainId:a instanceof e.Token?a.chainId:void 0)&&r(!1),k=ut(o,v),g=ct(a,v),y=0;case 12:if(!(y<i.length)){n.next=48;break}if((T=i[y]).token0.equals(k.token)||T.token1.equals(k.token)){n.next=16;break}return n.abrupt("continue",45);case 16:return x=void 0,n.prev=17,n.next=21,T.getOutputAmount(k);case 21:x=n.sent[0],n.next=30;break;case 25:if(n.prev=25,n.t0=n.catch(17),!n.t0.isInsufficientInputAmountError){n.next=29;break}return n.abrupt("continue",45);case 29:throw n.t0;case 30:if(!x.token.equals(g)){n.next=41;break}return n.t1=e.sortedInsert,n.t2=l,n.next=35,t.fromRoute(new ot([].concat(c,[T]),s.currency,a),s,e.TradeType.EXACT_INPUT);case 35:n.t3=n.sent,n.t4=f,n.t5=at,(0,n.t1)(n.t2,n.t3,n.t4,n.t5),n.next=45;break;case 41:if(!(m>1&&i.length>1)){n.next=45;break}return I=i.slice(0,y).concat(i.slice(y+1,i.length)),n.next=45,t.bestTradeExactIn(I,x,a,{maxNumResults:f,maxHops:m-1},[].concat(c,[T]),s,l);case 45:y++,n.next=12;break;case 48:return n.abrupt("return",l);case 49:case"end":return n.stop()}}),n,null,[[17,25]])})));return function(t,e,r,i,o,a,u){return n.apply(this,arguments)}}(),t.bestTradeExactOut=function(){var n=d(A.mark((function n(i,o,a,u,c,s,l){var d,p,f,h,m,v,k,g,y,T,x,I;return A.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:f=void 0===(p=(d=void 0===u?{}:u).maxNumResults)?3:p,m=void 0===(h=d.maxHops)?3:h,void 0===c&&(c=[]),void 0===s&&(s=a),void 0===l&&(l=[]),i.length>0||r(!1),m>0||r(!1),s===a||c.length>0||r(!1),void 0===(v=a instanceof e.TokenAmount?a.token.chainId:o instanceof e.Token?o.chainId:void 0)&&r(!1),k=ut(a,v),g=ct(o,v),y=0;case 12:if(!(y<i.length)){n.next=48;break}if((T=i[y]).token0.equals(k.token)||T.token1.equals(k.token)){n.next=16;break}return n.abrupt("continue",45);case 16:return x=void 0,n.prev=17,n.next=21,T.getInputAmount(k);case 21:x=n.sent[0],n.next=30;break;case 25:if(n.prev=25,n.t0=n.catch(17),!n.t0.isInsufficientReservesError){n.next=29;break}return n.abrupt("continue",45);case 29:throw n.t0;case 30:if(!x.token.equals(g)){n.next=41;break}return n.t1=e.sortedInsert,n.t2=l,n.next=35,t.fromRoute(new ot([T].concat(c),o,s.currency),s,e.TradeType.EXACT_OUTPUT);case 35:n.t3=n.sent,n.t4=f,n.t5=at,(0,n.t1)(n.t2,n.t3,n.t4,n.t5),n.next=45;break;case 41:if(!(m>1&&i.length>1)){n.next=45;break}return I=i.slice(0,y).concat(i.slice(y+1,i.length)),n.next=45,t.bestTradeExactOut(I,o,x,{maxNumResults:f,maxHops:m-1},[T].concat(c),s,l);case 45:y++,n.next=12;break;case 48:return n.abrupt("return",l);case 49:case"end":return n.stop()}}),n,null,[[17,25]])})));return function(t,e,r,i,o,a,u){return n.apply(this,arguments)}}(),f(t,[{key:"executionPrice",get:function(){var t;return null!=(t=this._executionPrice)?t:this._executionPrice=new e.Price(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw)}}]),t}(),lt=function(){function t(){}return t.encodePermit=function(e,n){return Object.keys(n).some((function(t){return"nonce"===t}))?t.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,z(n.nonce),z(n.expiry),n.v,n.r,n.s]):t.INTERFACE.encodeFunctionData("selfPermit",[e.address,z(n.amount),z(n.deadline),n.v,n.r,n.s])},t}();lt.INTERFACE=new i.Interface(c.abi);var dt=z(n.subtract(n.exponentiate(n.BigInt(2),n.BigInt(128)),n.BigInt(1)));function pt(t){return Object.keys(t).some((function(t){return"recipient"===t}))}var ft=function(t){function i(){return t.call(this)||this}return m(i,t),i.addCallParameters=function(t,o){n.greaterThan(t.liquidity,E)||r(!1);var a=[],u=t.mintAmounts,c=u.amount0,s=u.amount1,l=new e.Fraction(q).subtract(o.slippageTolerance),d=z(l.multiply(c).quotient),p=z(l.multiply(s).quotient),f=z(o.deadline);if(pt(o)&&o.createPool&&a.push(i.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[t.pool.token0.address,t.pool.token1.address,t.pool.fee,z(t.pool.sqrtRatioX96)])),o.token0Permit&&a.push(i.encodePermit(t.pool.token0,o.token0Permit)),o.token1Permit&&a.push(i.encodePermit(t.pool.token1,o.token1Permit)),pt(o)){var h=e.validateAndParseAddress(o.recipient);a.push(i.INTERFACE.encodeFunctionData("mint",[{token0:t.pool.token0.address,token1:t.pool.token1.address,fee:t.pool.fee,tickLower:t.tickLower,tickUpper:t.tickUpper,amount0Desired:z(c),amount1Desired:z(s),amount0Min:d,amount1Min:p,recipient:h,deadline:f}]))}else a.push(i.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:z(o.tokenId),amount0Desired:z(c),amount1Desired:z(s),amount0Min:d,amount1Min:p,deadline:f}]));var m=z(0);if(o.useEther){var v=e.WETH9[t.pool.chainId];v&&(t.pool.token0.equals(v)||t.pool.token1.equals(v))||r(!1),m=z(t.pool.token0.equals(v)?c:s),a.push(i.INTERFACE.encodeFunctionData("refundETH"))}return{calldata:1===a.length?a[0]:i.INTERFACE.encodeFunctionData("multicall",[a]),value:m}},i.encodeCollect=function(t){var n,o=[],a=z(t.tokenId),u=e.currencyEquals(t.expectedCurrencyOwed0.currency,e.ETHER)||e.currencyEquals(t.expectedCurrencyOwed1.currency,e.ETHER);if(o.push(i.INTERFACE.encodeFunctionData("collect",[{tokenId:a,recipient:e.validateAndParseAddress(u?null!=(n=t.nonfungiblePositionManagerAddressOverride)?n:i.ADDRESS:t.recipient),amount0Max:dt,amount1Max:dt}])),u){var c=e.currencyEquals(t.expectedCurrencyOwed0.currency,e.ETHER)?t.expectedCurrencyOwed0.raw:t.expectedCurrencyOwed1.raw,s=e.currencyEquals(t.expectedCurrencyOwed0.currency,e.ETHER)?t.expectedCurrencyOwed1.currency:t.expectedCurrencyOwed0.currency,l=e.currencyEquals(t.expectedCurrencyOwed0.currency,e.ETHER)?t.expectedCurrencyOwed1.raw:t.expectedCurrencyOwed0.raw;o.push(i.INTERFACE.encodeFunctionData("unwrapWETH9",[z(c),e.validateAndParseAddress(t.recipient)])),o.push(i.INTERFACE.encodeFunctionData("sweepToken",[s.address,z(l),e.validateAndParseAddress(t.recipient)]))}else void 0!==t.nonfungiblePositionManagerAddressOverride&&r(!1);return o},i.collectCallParameters=function(t){var e=i.encodeCollect(t);return{calldata:1===e.length?e[0]:i.INTERFACE.encodeFunctionData("multicall",[e]),value:z(0)}},i.removeCallParameters=function(t,o){var a=[],u=z(o.deadline),c=z(o.tokenId),s=new it({pool:t.pool,liquidity:o.liquidityPercentage.multiply(t.liquidity).quotient,tickLower:t.tickLower,tickUpper:t.tickUpper});n.greaterThan(s.liquidity,E)||r(!1);var l=new e.Fraction(q).subtract(o.slippageTolerance),d=l.multiply(s.amount0.raw).quotient,p=l.multiply(s.amount1.raw).quotient;o.permit&&a.push(i.INTERFACE.encodeFunctionData("permit",[e.validateAndParseAddress(o.permit.spender),c,z(o.permit.deadline),o.permit.v,o.permit.r,o.permit.s])),a.push(i.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:c,liquidity:z(s.liquidity),amount0Min:z(d),amount1Min:z(p),deadline:u}]));var f=o.collectOptions,m=f.expectedCurrencyOwed0,v=f.expectedCurrencyOwed1,k=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(i[n]=t[n]);return i}(f,["expectedCurrencyOwed0","expectedCurrencyOwed1"]);return a.push.apply(a,i.encodeCollect(h({tokenId:o.tokenId,expectedCurrencyOwed0:m.add(e.currencyEquals(m.currency,e.ETHER)?e.CurrencyAmount.ether(d):new e.TokenAmount(m.currency,d)),expectedCurrencyOwed1:v.add(e.currencyEquals(v.currency,e.ETHER)?e.CurrencyAmount.ether(p):new e.TokenAmount(v.currency,p))},k))),o.liquidityPercentage.equalTo(q)?!1!==o.burnToken&&a.push(i.INTERFACE.encodeFunctionData("burn",[c])):!0===o.burnToken&&r(!1),{calldata:i.INTERFACE.encodeFunctionData("multicall",[a]),value:z(0)}},i}(lt);ft.ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",ft.INTERFACE=new i.Interface(u.abi);var ht=function(t){function n(){return t.call(this)||this}return m(n,t),n.swapCallParameters=function(t,i){var o=[];i.inputTokenPermit&&o.push(n.encodePermit(t.inputAmount.currency,i.inputTokenPermit));var a=i.swapRouterAddressOverride?e.validateAndParseAddress(i.swapRouterAddressOverride):n.ADDRESS,u=e.validateAndParseAddress(i.recipient),c=z(i.deadline),s=z(t.maximumAmountIn(i.slippageTolerance).raw),l=z(t.minimumAmountOut(i.slippageTolerance).raw),d=e.currencyEquals(t.inputAmount.currency,e.ETHER)?s:z(0),p=1===t.route.pools.length,f=e.currencyEquals(t.inputAmount.currency,e.ETHER)&&t.tradeType===e.TradeType.EXACT_OUTPUT,h=e.currencyEquals(t.outputAmount.currency,e.ETHER),m=h||!!i.fee;if(p)if(t.tradeType===e.TradeType.EXACT_INPUT){var v,k={tokenIn:t.route.tokenPath[0].address,tokenOut:t.route.tokenPath[1].address,fee:t.route.pools[0].fee,recipient:m?a:u,deadline:c,amountIn:s,amountOutMinimum:l,sqrtPriceLimitX96:z(null!=(v=i.sqrtPriceLimitX96)?v:0)};o.push(n.INTERFACE.encodeFunctionData("exactInputSingle",[k]))}else{var g,y={tokenIn:t.route.tokenPath[0].address,tokenOut:t.route.tokenPath[1].address,fee:t.route.pools[0].fee,recipient:m?a:u,deadline:c,amountOut:l,amountInMaximum:s,sqrtPriceLimitX96:z(null!=(g=i.sqrtPriceLimitX96)?g:0)};o.push(n.INTERFACE.encodeFunctionData("exactOutputSingle",[y]))}else{void 0!==i.sqrtPriceLimitX96&&r(!1);var T=Q(t.route,t.tradeType===e.TradeType.EXACT_OUTPUT);o.push(t.tradeType===e.TradeType.EXACT_INPUT?n.INTERFACE.encodeFunctionData("exactInput",[{path:T,recipient:m?a:u,deadline:c,amountIn:s,amountOutMinimum:l}]):n.INTERFACE.encodeFunctionData("exactOutput",[{path:T,recipient:m?a:u,deadline:c,amountOut:l,amountInMaximum:s}]))}if(f&&o.push(n.INTERFACE.encodeFunctionData("refundETH")),m)if(i.fee){var A=e.validateAndParseAddress(i.fee.recipient),x=z(i.fee.fee.multiply(1e4).quotient);o.push(h?n.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[l,u,x,A]):n.INTERFACE.encodeFunctionData("sweepTokenWithFee",[t.route.tokenPath[t.route.tokenPath.length-1].address,l,u,x,A]))}else o.push(n.INTERFACE.encodeFunctionData("unwrapWETH9",[l,u]));return{calldata:1===o.length?o[0]:n.INTERFACE.encodeFunctionData("multicall",[o]),value:d}},n}(lt);ht.ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",ht.INTERFACE=new i.Interface(s.abi),exports.FACTORY_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.FullMath=O,exports.LiquidityMath=S,exports.NONFUNGIBLE_POSITION_MANAGER_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.NoTickDataProvider=j,exports.NonfungiblePositionManager=ft,exports.POOL_INIT_CODE_HASH=x,exports.Pool=rt,exports.Position=it,exports.Route=ot,exports.SWAP_ROUTER_ADDRESS="0x1F98431c8aD98523631AE4a59f267346ea31F984",exports.SqrtPriceMath=_,exports.SwapRouter=ht,exports.TICK_SPACINGS=I,exports.Tick=tt,exports.TickList=K,exports.TickListDataProvider=et,exports.TickMath=H,exports.Trade=st,exports.computePoolAddress=P,exports.encodeRouteToPath=Q,exports.encodeSqrtRatioX96=Y,exports.isSorted=W,exports.maxLiquidityForAmounts=V,exports.mostSignificantBit=L,exports.nearestUsableTick=function(t,e){Number.isInteger(t)&&Number.isInteger(e)||r(!1),e>0||r(!1),t>=H.MIN_TICK&&t<=H.MAX_TICK||r(!1);var n=Math.round(t/e)*e;return n<H.MIN_TICK?n+e:n>H.MAX_TICK?n-e:n},exports.priceToClosestTick=function(t){t.baseCurrency instanceof e.Token&&t.quoteCurrency instanceof e.Token||r(!1);var n=t.baseCurrency.sortsBefore(t.quoteCurrency),i=n?Y(t.raw.numerator,t.raw.denominator):Y(t.raw.denominator,t.raw.numerator),o=H.getTickAtSqrtRatio(i),a=Z(t.baseCurrency,t.quoteCurrency,o+1);return n?t.lessThan(a)||o++:t.greaterThan(a)||o++,o},exports.tickToPrice=Z,exports.toHex=z,exports.tradeComparator=at;
//# sourceMappingURL=v3-sdk.cjs.production.min.js.map

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

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

@@ -10,0 +10,0 @@ "main": "dist/index.js",

@@ -13,2 +13,2 @@ # Work in progress

In-depth documentation on this SDK is available at [uniswap.org](https://uniswap.org/docs/v3/SDK/getting-started/).
In-depth documentation on this SDK is available at [uniswap.org](https://docs.uniswap.org/).

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc