Socket
Socket
Sign inDemoInstall

@uniswap/router-sdk

Package Overview
Dependencies
Maintainers
10
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/router-sdk - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

1

dist/index.d.ts
export * from './constants';
export * from './approveAndCall';
export * from './multicallExtended';

@@ -3,0 +4,0 @@ export * from './paymentsExtended';

141

dist/router-sdk.cjs.development.js

@@ -9,4 +9,6 @@ 'use strict';

var abi = require('@ethersproject/abi');
var invariant = _interopDefault(require('tiny-invariant'));
var IApproveAndCall_json = require('@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IApproveAndCall.sol/IApproveAndCall.json');
var v3Sdk = require('@uniswap/v3-sdk');
var IMulticallExtended_json = require('@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IMulticallExtended.sol/IMulticallExtended.json');
var v3Sdk = require('@uniswap/v3-sdk');
var sdkCore = require('@uniswap/sdk-core');

@@ -16,4 +18,2 @@ var IPeripheryPaymentsWithFeeExtended_json = require('@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IPeripheryPaymentsWithFeeExtended.sol/IPeripheryPaymentsWithFeeExtended.json');

var v2Sdk = require('@uniswap/v2-sdk');
var invariant = _interopDefault(require('tiny-invariant'));
var IApproveAndCall_json = require('@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IApproveAndCall.sol/IApproveAndCall.json');

@@ -25,2 +25,66 @@ var MSG_SENDER = '0x0000000000000000000000000000000000000001';

(function (ApprovalTypes) {
ApprovalTypes[ApprovalTypes["NOT_REQUIRED"] = 0] = "NOT_REQUIRED";
ApprovalTypes[ApprovalTypes["MAX"] = 1] = "MAX";
ApprovalTypes[ApprovalTypes["MAX_MINUS_ONE"] = 2] = "MAX_MINUS_ONE";
ApprovalTypes[ApprovalTypes["ZERO_THEN_MAX"] = 3] = "ZERO_THEN_MAX";
ApprovalTypes[ApprovalTypes["ZERO_THEN_MAX_MINUS_ONE"] = 4] = "ZERO_THEN_MAX_MINUS_ONE";
})(exports.ApprovalTypes || (exports.ApprovalTypes = {}));
var ApproveAndCall = /*#__PURE__*/function () {
/**
* Cannot be constructed.
*/
function ApproveAndCall() {}
ApproveAndCall.encodeApproveMax = function encodeApproveMax(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveMax', [token.address]);
};
ApproveAndCall.encodeApproveMaxMinusOne = function encodeApproveMaxMinusOne(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveMaxMinusOne', [token.address]);
};
ApproveAndCall.encodeApproveZeroThenMax = function encodeApproveZeroThenMax(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveZeroThenMax', [token.address]);
};
ApproveAndCall.encodeApproveZeroThenMaxMinusOne = function encodeApproveZeroThenMaxMinusOne(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveZeroThenMaxMinusOne', [token.address]);
};
ApproveAndCall.encodeCallPositionManager = function encodeCallPositionManager(calldatas) {
!(calldatas.length > 0) ? invariant(false, 'NULL_CALLDATA') : void 0;
if (calldatas.length == 1) {
return ApproveAndCall.INTERFACE.encodeFunctionData('callPositionManager', calldatas);
} else {
var encodedMulticall = v3Sdk.NonfungiblePositionManager.INTERFACE.encodeFunctionData('multicall', [calldatas]);
return ApproveAndCall.INTERFACE.encodeFunctionData('callPositionManager', [encodedMulticall]);
}
};
ApproveAndCall.encodeApprove = function encodeApprove(token, approvalType) {
switch (approvalType) {
case exports.ApprovalTypes.MAX:
return ApproveAndCall.encodeApproveMax(token.wrapped);
case exports.ApprovalTypes.MAX_MINUS_ONE:
return ApproveAndCall.encodeApproveMaxMinusOne(token.wrapped);
case exports.ApprovalTypes.ZERO_THEN_MAX:
return ApproveAndCall.encodeApproveZeroThenMax(token.wrapped);
case exports.ApprovalTypes.ZERO_THEN_MAX_MINUS_ONE:
return ApproveAndCall.encodeApproveZeroThenMaxMinusOne(token.wrapped);
default:
throw 'Error: invalid ApprovalType';
}
};
return ApproveAndCall;
}();
ApproveAndCall.INTERFACE = /*#__PURE__*/new abi.Interface(IApproveAndCall_json.abi);
function validateAndParseBytes32(bytes32) {

@@ -223,68 +287,2 @@ if (!bytes32.match(/^0x[0-9a-fA-F]{64}$/)) {

var ApprovalTypes;
(function (ApprovalTypes) {
ApprovalTypes[ApprovalTypes["NOT_REQUIRED"] = 0] = "NOT_REQUIRED";
ApprovalTypes[ApprovalTypes["MAX"] = 1] = "MAX";
ApprovalTypes[ApprovalTypes["MAX_MINUS_ONE"] = 2] = "MAX_MINUS_ONE";
ApprovalTypes[ApprovalTypes["ZERO_THEN_MAX"] = 3] = "ZERO_THEN_MAX";
ApprovalTypes[ApprovalTypes["ZERO_THEN_MAX_MINUS_ONE"] = 4] = "ZERO_THEN_MAX_MINUS_ONE";
})(ApprovalTypes || (ApprovalTypes = {}));
var ApproveAndCall = /*#__PURE__*/function () {
/**
* Cannot be constructed.
*/
function ApproveAndCall() {}
ApproveAndCall.encodeApproveMax = function encodeApproveMax(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveMax', [token.address]);
};
ApproveAndCall.encodeApproveMaxMinusOne = function encodeApproveMaxMinusOne(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveMaxMinusOne', [token.address]);
};
ApproveAndCall.encodeApproveZeroThenMax = function encodeApproveZeroThenMax(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveZeroThenMax', [token.address]);
};
ApproveAndCall.encodeApproveZeroThenMaxMinusOne = function encodeApproveZeroThenMaxMinusOne(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveZeroThenMaxMinusOne', [token.address]);
};
ApproveAndCall.encodeCallPositionManager = function encodeCallPositionManager(calldatas) {
!(calldatas.length > 0) ? invariant(false, 'NULL_CALLDATA') : void 0;
if (calldatas.length == 1) {
return ApproveAndCall.INTERFACE.encodeFunctionData('callPositionManager', calldatas);
} else {
var encodedMulticall = v3Sdk.NonfungiblePositionManager.INTERFACE.encodeFunctionData('multicall', [calldatas]);
return ApproveAndCall.INTERFACE.encodeFunctionData('callPositionManager', [encodedMulticall]);
}
};
ApproveAndCall.encodeApprove = function encodeApprove(token, approvalType) {
switch (approvalType) {
case ApprovalTypes.MAX:
return ApproveAndCall.encodeApproveMax(token.wrapped);
case ApprovalTypes.MAX_MINUS_ONE:
return ApproveAndCall.encodeApproveMaxMinusOne(token.wrapped);
case ApprovalTypes.ZERO_THEN_MAX:
return ApproveAndCall.encodeApproveZeroThenMax(token.wrapped);
case ApprovalTypes.ZERO_THEN_MAX_MINUS_ONE:
return ApproveAndCall.encodeApproveZeroThenMaxMinusOne(token.wrapped);
default:
throw 'Error: invalid ApprovalType';
}
};
return ApproveAndCall;
}();
ApproveAndCall.INTERFACE = /*#__PURE__*/new abi.Interface(IApproveAndCall_json.abi);
function createCommonjsModule(fn, module) {

@@ -1685,4 +1683,4 @@ return module = { exports: {} }, fn(module, module.exports), module.exports;

if (tokenInApprovalType !== ApprovalTypes.NOT_REQUIRED) calldatas.push(ApproveAndCall.encodeApprove(tokenIn, tokenInApprovalType));
if (tokenOutApprovalType !== ApprovalTypes.NOT_REQUIRED) calldatas.push(ApproveAndCall.encodeApprove(tokenOut, tokenOutApprovalType)); // encode NFTManager add liquidity
if (tokenInApprovalType !== exports.ApprovalTypes.NOT_REQUIRED) calldatas.push(ApproveAndCall.encodeApprove(tokenIn, tokenInApprovalType));
if (tokenOutApprovalType !== exports.ApprovalTypes.NOT_REQUIRED) calldatas.push(ApproveAndCall.encodeApprove(tokenOut, tokenOutApprovalType)); // encode NFTManager add liquidity

@@ -1731,2 +1729,3 @@ calldatas.push(ApproveAndCall.encodeCallPositionManager([v3Sdk.NonfungiblePositionManager.addCallParameters(position, addLiquidityOptions).calldata])); // sweep remaining tokens

exports.ADDRESS_THIS = ADDRESS_THIS;
exports.ApproveAndCall = ApproveAndCall;
exports.MSG_SENDER = MSG_SENDER;

@@ -1733,0 +1732,0 @@ exports.MulticallExtended = MulticallExtended;

@@ -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=t(require("jsbi")),n=require("@ethersproject/abi"),r=require("@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IMulticallExtended.sol/IMulticallExtended.json"),o=require("@uniswap/v3-sdk"),u=require("@uniswap/sdk-core"),a=require("@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IPeripheryPaymentsWithFeeExtended.sol/IPeripheryPaymentsWithFeeExtended.json"),i=require("@uniswap/swap-router-contracts/artifacts/contracts/interfaces/ISwapRouter02.sol/ISwapRouter02.json"),c=require("@uniswap/v2-sdk"),s=t(require("tiny-invariant")),p=require("@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IApproveAndCall.sol/IApproveAndCall.json"),d="0x0000000000000000000000000000000000000001",l="0x0000000000000000000000000000000000000002",f=e.BigInt(0),m=e.BigInt(1),h=function(){function t(){}return t.encodeMulticall=function(e,n){if(void 0===n)return o.Multicall.encodeMulticall(e);if(Array.isArray(e)||(e=[e]),"string"==typeof n&&n.startsWith("0x")){var r=function(t){if(!t.match(/^0x[0-9a-fA-F]{64}$/))throw new Error(t+" is not valid bytes32.");return t.toLowerCase()}(n);return t.INTERFACE.encodeFunctionData("multicall(bytes32,bytes[])",[r,e])}var u=o.toHex(n);return t.INTERFACE.encodeFunctionData("multicall(uint256,bytes[])",[u,e])},t}();function v(t){return o.toHex(t.multiply(1e4).quotient)}h.INTERFACE=new n.Interface(r.abi);var y,A=function(){function t(){}return t.encodeUnwrapWETH9=function(e,n,r){if("string"==typeof n)return o.Payments.encodeUnwrapWETH9(e,n,r);if(r){var a=v(r.fee),i=u.validateAndParseAddress(r.recipient);return t.INTERFACE.encodeFunctionData("unwrapWETH9WithFee(uint256,uint256,address)",[o.toHex(e),a,i])}return t.INTERFACE.encodeFunctionData("unwrapWETH9(uint256)",[o.toHex(e)])},t.encodeSweepToken=function(e,n,r,a){if("string"==typeof r)return o.Payments.encodeSweepToken(e,n,r,a);if(a){var i=v(a.fee),c=u.validateAndParseAddress(a.recipient);return t.INTERFACE.encodeFunctionData("sweepTokenWithFee(address,uint256,uint256,address)",[e.address,o.toHex(n),i,c])}return t.INTERFACE.encodeFunctionData("sweepToken(address,uint256)",[e.address,o.toHex(n)])},t.encodePull=function(e,n){return t.INTERFACE.encodeFunctionData("pull",[e.address,o.toHex(n)])},t.encodeWrapETH=function(e){return t.INTERFACE.encodeFunctionData("wrapETH",[o.toHex(e)])},t}();function w(t,e,n,r,o,u,a){try{var i=t[u](a),c=i.value}catch(t){return void n(t)}i.done?e(c):Promise.resolve(c).then(r,o)}function T(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var u=t.apply(e,n);function a(t){w(u,r,o,a,i,"next",t)}function i(t){w(u,r,o,a,i,"throw",t)}a(void 0)}))}}function E(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function g(t,e){var n="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 x(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)?x(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.")}A.INTERFACE=new n.Interface(a.abi),function(t){t[t.NOT_REQUIRED=0]="NOT_REQUIRED",t[t.MAX=1]="MAX",t[t.MAX_MINUS_ONE=2]="MAX_MINUS_ONE",t[t.ZERO_THEN_MAX=3]="ZERO_THEN_MAX",t[t.ZERO_THEN_MAX_MINUS_ONE=4]="ZERO_THEN_MAX_MINUS_ONE"}(y||(y={}));var I=function(){function t(){}return t.encodeApproveMax=function(e){return t.INTERFACE.encodeFunctionData("approveMax",[e.address])},t.encodeApproveMaxMinusOne=function(e){return t.INTERFACE.encodeFunctionData("approveMaxMinusOne",[e.address])},t.encodeApproveZeroThenMax=function(e){return t.INTERFACE.encodeFunctionData("approveZeroThenMax",[e.address])},t.encodeApproveZeroThenMaxMinusOne=function(e){return t.INTERFACE.encodeFunctionData("approveZeroThenMaxMinusOne",[e.address])},t.encodeCallPositionManager=function(e){if(e.length>0||s(!1),1==e.length)return t.INTERFACE.encodeFunctionData("callPositionManager",e);var n=o.NonfungiblePositionManager.INTERFACE.encodeFunctionData("multicall",[e]);return t.INTERFACE.encodeFunctionData("callPositionManager",[n])},t.encodeApprove=function(e,n){switch(n){case y.MAX:return t.encodeApproveMax(e.wrapped);case y.MAX_MINUS_ONE:return t.encodeApproveMaxMinusOne(e.wrapped);case y.ZERO_THEN_MAX:return t.encodeApproveZeroThenMax(e.wrapped);case y.ZERO_THEN_MAX_MINUS_ONE:return t.encodeApproveZeroThenMaxMinusOne(e.wrapped);default:throw"Error: invalid ApprovalType"}},t}();I.INTERFACE=new n.Interface(p.abi);var P,R,_=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",u=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function i(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var o=Object.create((e&&e.prototype instanceof d?e:d).prototype),u=new g(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,u){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw u;return{value:void 0,done:!0}}for(n.method=o,n.arg=u;;){var a=n.delegate;if(a){var i=T(a,n);if(i){if(i===p)continue;return i}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=s(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(t,n,u),o}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var p={};function d(){}function l(){}function f(){}var m={};i(m,o,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(I([])));v&&v!==e&&n.call(v,o)&&(m=v);var y=f.prototype=d.prototype=Object.create(m);function A(t){["next","throw","return"].forEach((function(e){i(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var r;this._invoke=function(o,u){function a(){return new e((function(r,a){!function r(o,u,a,i){var c=s(t[o],t,u);if("throw"!==c.type){var p=c.arg,d=p.value;return d&&"object"==typeof d&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,a,i)}),(function(t){r("throw",t,a,i)})):e.resolve(d).then((function(t){p.value=t,a(p)}),(function(t){return r("throw",t,a,i)}))}i(c.arg)}(o,u,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 p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,p;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(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 g(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function I(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,u=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 u.next=u}}return{next:P}}function P(){return{value:void 0,done:!0}}return l.prototype=f,i(y,"constructor",f),i(f,"constructor",l),l.displayName=i(f,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,i(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},A(w.prototype),i(w.prototype,u,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,u){void 0===u&&(u=Promise);var a=new w(c(e,n,r,o),u);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},A(y),i(y,a,"Generator"),i(y,o,(function(){return this})),i(y,"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=I,g.prototype={constructor:g,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 o=this.tryEntries.length-1;o>=0;--o){var u=this.tryEntries[o],a=u.completion;if("root"===u.tryLoc)return r("end");if(u.tryLoc<=this.prev){var i=n.call(u,"catchLoc"),c=n.call(u,"finallyLoc");if(i&&c){if(this.prev<u.catchLoc)return r(u.catchLoc,!0);if(this.prev<u.finallyLoc)return r(u.finallyLoc)}else if(i){if(this.prev<u.catchLoc)return r(u.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<u.finallyLoc)return r(u.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var u=o;break}}u&&("break"===t||"continue"===t)&&u.tryLoc<=e&&e<=u.finallyLoc&&(u=null);var a=u?u.completion:{};return a.type=t,a.arg=e,u?(this.method="next",this.next=u.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),x(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;x(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:I(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(R={exports:{}}),R.exports);(P=exports.Protocol||(exports.Protocol={})).V2="V2",P.V3="V3";var N=function(t){function e(e){var n;return(n=t.call(this,e.pairs,e.input,e.output)||this).protocol=exports.Protocol.V2,n.pools=n.pairs,n}return E(e,t),e}(c.Route),O=function(t){function e(e){var n;return(n=t.call(this,e.pools,e.input,e.output)||this).protocol=exports.Protocol.V3,n.path=e.tokenPath,n}return E(e,t),e}(o.Route),b=function(){function t(t){var e=t.v2Routes,n=t.v3Routes,r=t.tradeType;this.swaps=[],this.routes=[];for(var u,a=g(e);!(u=a()).done;){var i=u.value,p=i.inputAmount,d=i.outputAmount,l=new N(i.routev2);this.routes.push(l),this.swaps.push({route:l,inputAmount:p,outputAmount:d})}for(var f,m=g(n);!(f=m()).done;){var h=f.value,v=h.inputAmount,y=h.outputAmount,A=new O(h.routev3);this.routes.push(A),this.swaps.push({route:A,inputAmount:v,outputAmount:y})}this.tradeType=r;var w=this.swaps[0].inputAmount.currency,T=this.swaps[0].outputAmount.currency;this.swaps.every((function(t){return w.wrapped.equals(t.route.input.wrapped)}))||s(!1),this.swaps.every((function(t){return T.wrapped.equals(t.route.output.wrapped)}))||s(!1);for(var E,x=this.swaps.map((function(t){return t.route.pools.length})).reduce((function(t,e){return t+e}),0),I=new Set,P=g(this.swaps);!(E=P()).done;)for(var R,_=E.value.route,b=g(_.pools);!(R=b()).done;){var F=R.value;_.protocol==exports.Protocol.V3?I.add(o.Pool.getAddress(F.token0,F.token1,F.fee)):I.add(c.Pair.getAddress(F.token0,F.token1))}x!=I.size&&s(!1)}var e,n=t.prototype;return n.minimumAmountOut=function(t,e){if(void 0===e&&(e=this.outputAmount),t.lessThan(f)&&s(!1),this.tradeType===u.TradeType.EXACT_OUTPUT)return e;var n=new u.Fraction(m).add(t).invert().multiply(e.quotient).quotient;return u.CurrencyAmount.fromRawAmount(e.currency,n)},n.maximumAmountIn=function(t,e){if(void 0===e&&(e=this.inputAmount),t.lessThan(f)&&s(!1),this.tradeType===u.TradeType.EXACT_INPUT)return e;var n=new u.Fraction(m).add(t).multiply(e.quotient).quotient;return u.CurrencyAmount.fromRawAmount(e.currency,n)},n.worstExecutionPrice=function(t){return new u.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.fromRoutes=function(){var e=T(_.mark((function e(n,r,u){var a,i,s,p,d,l,f,m,h,v,y,A,w;return _.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(a=[],i=[],s=g(n);!(p=s()).done;)f=new c.Trade(l=(d=p.value).routev2,d.amount,u),a.push({routev2:l,inputAmount:f.inputAmount,outputAmount:f.outputAmount});m=g(r);case 4:if((h=m()).done){e.next=13;break}return y=(v=h.value).routev3,A=v.amount,e.next=8,o.Trade.fromRoute(y,A,u);case 8:i.push({routev3:y,inputAmount:(w=e.sent).inputAmount,outputAmount:w.outputAmount});case 11:e.next=4;break;case 13:return e.abrupt("return",new t({v2Routes:a,v3Routes:i,tradeType:u}));case 14:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.fromRoute=function(){var e=T(_.mark((function e(n,r,u){var a,i,s,p;return _.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n instanceof c.Route)){e.next=7;break}s=new c.Trade(n,r,u),a=[{routev2:n,inputAmount:s.inputAmount,outputAmount:s.outputAmount}],i=[],e.next=13;break;case 7:return e.next=9,o.Trade.fromRoute(n,r,u);case 9:i=[{routev3:n,inputAmount:(p=e.sent).inputAmount,outputAmount:p.outputAmount}],a=[];case 13:return e.abrupt("return",new t({v2Routes:a,v3Routes:i,tradeType:u}));case 14:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),(e=[{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)}),u.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)}),u.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 u.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=u.CurrencyAmount.fromRawAmount(this.outputAmount.currency,0),n=g(this.swaps);!(t=n()).done;){var r=t.value;e=e.add(r.route.midPrice.quote(r.inputAmount))}var o=e.subtract(this.outputAmount).divide(e);return this._priceImpact=new u.Percent(o.numerator,o.denominator),this._priceImpact}}])&&function(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)}}(t.prototype,e),t}(),F=e.BigInt(0),M=function(){function t(){}return t.encodeV2Swap=function(e,n,r,a){var i=o.toHex(e.maximumAmountIn(n.slippageTolerance).quotient),c=o.toHex(e.minimumAmountOut(n.slippageTolerance).quotient),s=e.route.path.map((function(t){return t.address})),p=r?l:void 0===n.recipient?d:u.validateAndParseAddress(n.recipient);return e.tradeType===u.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("swapExactTokensForTokens",[i,a?0:c,s,p]):t.INTERFACE.encodeFunctionData("swapTokensForExactTokens",[c,i,s,p])},t.encodeV3Swap=function(e,n,r,a){for(var i,c=[],s=g(e.swaps);!(i=s()).done;){var p=i.value,f=p.route,m=p.outputAmount,h=o.toHex(e.maximumAmountIn(n.slippageTolerance,p.inputAmount).quotient),v=o.toHex(e.minimumAmountOut(n.slippageTolerance,m).quotient),y=1===f.pools.length,A=r?l:void 0===n.recipient?d:u.validateAndParseAddress(n.recipient);if(y)c.push(e.tradeType===u.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("exactInputSingle",[{tokenIn:f.tokenPath[0].address,tokenOut:f.tokenPath[1].address,fee:f.pools[0].fee,recipient:A,amountIn:h,amountOutMinimum:a?0:v,sqrtPriceLimitX96:0}]):t.INTERFACE.encodeFunctionData("exactOutputSingle",[{tokenIn:f.tokenPath[0].address,tokenOut:f.tokenPath[1].address,fee:f.pools[0].fee,recipient:A,amountOut:v,amountInMaximum:h,sqrtPriceLimitX96:0}]));else{var w=o.encodeRouteToPath(f,e.tradeType===u.TradeType.EXACT_OUTPUT);c.push(e.tradeType===u.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("exactInput",[{path:w,recipient:A,amountIn:h,amountOutMinimum:a?0:v}]):t.INTERFACE.encodeFunctionData("exactOutput",[{path:w,recipient:A,amountOut:v,amountInMaximum:h}]))}}return c},t.encodeSwaps=function(e,n,r){if(e instanceof b){e.swaps.every((function(t){return t.route.protocol==exports.Protocol.V3||t.route.protocol==exports.Protocol.V2}))||s(!1);for(var a,i=[],p=g(e.swaps);!(a=p()).done;){var d=a.value,l=d.route,f=d.inputAmount,m=d.outputAmount;l.protocol==exports.Protocol.V2?i.push(new c.Trade(l,e.tradeType==u.TradeType.EXACT_INPUT?f:m,e.tradeType)):l.protocol==exports.Protocol.V3&&i.push(o.Trade.createUncheckedTrade({route:l,inputAmount:f,outputAmount:m,tradeType:e.tradeType}))}e=i}Array.isArray(e)||(e=[e]);var h=e.reduce((function(t,e){return t+(e instanceof o.Trade?e.swaps.length:1)}),0),v=e[0];e.every((function(t){return t.inputAmount.currency.equals(v.inputAmount.currency)}))||s(!1),e.every((function(t){return t.outputAmount.currency.equals(v.outputAmount.currency)}))||s(!1),e.every((function(t){return t.tradeType===v.tradeType}))||s(!1);var y=[],A=v.inputAmount.currency.isNative,w=v.outputAmount.currency.isNative,T=v.tradeType===u.TradeType.EXACT_INPUT&&h>2,E=w||!!n.fee||!!r||T;n.inputTokenPermit&&(v.inputAmount.currency.isToken||s(!1),y.push(o.SelfPermit.encodePermit(v.inputAmount.currency,n.inputTokenPermit)));for(var x,I=g(e);!(x=I()).done;){var P=x.value;if(P instanceof c.Trade)y.push(t.encodeV2Swap(P,n,E,T));else for(var R,_=g(t.encodeV3Swap(P,n,E,T));!(R=_()).done;)y.push(R.value)}var N=u.CurrencyAmount.fromRawAmount(v.inputAmount.currency,0),O=u.CurrencyAmount.fromRawAmount(v.outputAmount.currency,0),F=e.reduce((function(t,e){return t.add(e.minimumAmountOut(n.slippageTolerance))}),O),M=e.reduce((function(t,e){return t.add(e.maximumAmountIn(n.slippageTolerance))}),N);return{calldatas:y,sampleTrade:v,routerMustCustody:E,inputIsNative:A,outputIsNative:w,totalAmountIn:M,totalAmountOut:F}},t.swapCallParameters=function(e,n){var r=t.encodeSwaps(e,n),a=r.calldatas,i=r.sampleTrade,c=r.inputIsNative,s=r.totalAmountIn,p=r.totalAmountOut;return r.routerMustCustody&&a.push(r.outputIsNative?A.encodeUnwrapWETH9(p.quotient,n.recipient,n.fee):A.encodeSweepToken(i.outputAmount.currency.wrapped,p.quotient,n.recipient,n.fee)),c&&i.tradeType===u.TradeType.EXACT_OUTPUT&&a.push(o.Payments.encodeRefundETH()),{calldata:h.encodeMulticall(a,n.deadlineOrPreviousBlockhash),value:o.toHex(c?s.quotient:F)}},t.swapAndAddCallParameters=function(e,n,r,a,i,c){var s,p=t.encodeSwaps(e,n,!0),d=p.calldatas,l=p.inputIsNative,f=p.outputIsNative,m=p.totalAmountIn,v=p.totalAmountOut,w=p.sampleTrade.route.chainId,T=t.getPositionAmounts(r,r.pool.token0===m.currency.wrapped),E=T.positionAmountIn,x=T.positionAmountOut,g=l?u.WETH9[w]:E.currency.wrapped,P=f?u.WETH9[w]:x.currency.wrapped,R=x.subtract(v.wrapped);return R.greaterThan(u.CurrencyAmount.fromRawAmount(x.currency,0))&&d.push(f?A.encodeWrapETH(R.quotient):A.encodePull(P,R.quotient)),d.push(l?A.encodeWrapETH(E.quotient):A.encodePull(g,E.quotient)),i!==y.NOT_REQUIRED&&d.push(I.encodeApprove(g,i)),c!==y.NOT_REQUIRED&&d.push(I.encodeApprove(P,c)),d.push(I.encodeCallPositionManager([o.NonfungiblePositionManager.addCallParameters(r,a).calldata])),d.push(l?A.encodeUnwrapWETH9(F):A.encodeSweepToken(g,F)),d.push(f?A.encodeUnwrapWETH9(F):A.encodeSweepToken(P,F)),s=l?m.wrapped.add(E.wrapped).quotient:f?R.quotient:F,{calldata:h.encodeMulticall(d,n.deadlineOrPreviousBlockhash),value:s.toString()}},t.getPositionAmounts=function(t,e){var n=t.mintAmounts,r=n.amount1,o=u.CurrencyAmount.fromRawAmount(t.pool.token0,n.amount0),a=u.CurrencyAmount.fromRawAmount(t.pool.token1,r),i=e?[o,a]:[a,o];return{positionAmountIn:i[0],positionAmountOut:i[1]}},t}();M.INTERFACE=new n.Interface(i.abi),exports.ADDRESS_THIS=l,exports.MSG_SENDER=d,exports.MulticallExtended=h,exports.ONE=m,exports.PaymentsExtended=A,exports.RouteV2=N,exports.RouteV3=O,exports.SwapRouter=M,exports.Trade=b,exports.ZERO=f;
"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=t(require("jsbi")),r=require("@ethersproject/abi"),o=t(require("tiny-invariant")),u=require("@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IApproveAndCall.sol/IApproveAndCall.json"),a=require("@uniswap/v3-sdk"),i=require("@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IMulticallExtended.sol/IMulticallExtended.json"),c=require("@uniswap/sdk-core"),p=require("@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IPeripheryPaymentsWithFeeExtended.sol/IPeripheryPaymentsWithFeeExtended.json"),s=require("@uniswap/swap-router-contracts/artifacts/contracts/interfaces/ISwapRouter02.sol/ISwapRouter02.json"),d=require("@uniswap/v2-sdk"),l="0x0000000000000000000000000000000000000001",f="0x0000000000000000000000000000000000000002",m=n.BigInt(0),h=n.BigInt(1);(e=exports.ApprovalTypes||(exports.ApprovalTypes={}))[e.NOT_REQUIRED=0]="NOT_REQUIRED",e[e.MAX=1]="MAX",e[e.MAX_MINUS_ONE=2]="MAX_MINUS_ONE",e[e.ZERO_THEN_MAX=3]="ZERO_THEN_MAX",e[e.ZERO_THEN_MAX_MINUS_ONE=4]="ZERO_THEN_MAX_MINUS_ONE";var v=function(){function t(){}return t.encodeApproveMax=function(e){return t.INTERFACE.encodeFunctionData("approveMax",[e.address])},t.encodeApproveMaxMinusOne=function(e){return t.INTERFACE.encodeFunctionData("approveMaxMinusOne",[e.address])},t.encodeApproveZeroThenMax=function(e){return t.INTERFACE.encodeFunctionData("approveZeroThenMax",[e.address])},t.encodeApproveZeroThenMaxMinusOne=function(e){return t.INTERFACE.encodeFunctionData("approveZeroThenMaxMinusOne",[e.address])},t.encodeCallPositionManager=function(e){if(e.length>0||o(!1),1==e.length)return t.INTERFACE.encodeFunctionData("callPositionManager",e);var n=a.NonfungiblePositionManager.INTERFACE.encodeFunctionData("multicall",[e]);return t.INTERFACE.encodeFunctionData("callPositionManager",[n])},t.encodeApprove=function(e,n){switch(n){case exports.ApprovalTypes.MAX:return t.encodeApproveMax(e.wrapped);case exports.ApprovalTypes.MAX_MINUS_ONE:return t.encodeApproveMaxMinusOne(e.wrapped);case exports.ApprovalTypes.ZERO_THEN_MAX:return t.encodeApproveZeroThenMax(e.wrapped);case exports.ApprovalTypes.ZERO_THEN_MAX_MINUS_ONE:return t.encodeApproveZeroThenMaxMinusOne(e.wrapped);default:throw"Error: invalid ApprovalType"}},t}();v.INTERFACE=new r.Interface(u.abi);var y=function(){function t(){}return t.encodeMulticall=function(e,n){if(void 0===n)return a.Multicall.encodeMulticall(e);if(Array.isArray(e)||(e=[e]),"string"==typeof n&&n.startsWith("0x")){var r=function(t){if(!t.match(/^0x[0-9a-fA-F]{64}$/))throw new Error(t+" is not valid bytes32.");return t.toLowerCase()}(n);return t.INTERFACE.encodeFunctionData("multicall(bytes32,bytes[])",[r,e])}var o=a.toHex(n);return t.INTERFACE.encodeFunctionData("multicall(uint256,bytes[])",[o,e])},t}();function A(t){return a.toHex(t.multiply(1e4).quotient)}y.INTERFACE=new r.Interface(i.abi);var T=function(){function t(){}return t.encodeUnwrapWETH9=function(e,n,r){if("string"==typeof n)return a.Payments.encodeUnwrapWETH9(e,n,r);if(r){var o=A(r.fee),u=c.validateAndParseAddress(r.recipient);return t.INTERFACE.encodeFunctionData("unwrapWETH9WithFee(uint256,uint256,address)",[a.toHex(e),o,u])}return t.INTERFACE.encodeFunctionData("unwrapWETH9(uint256)",[a.toHex(e)])},t.encodeSweepToken=function(e,n,r,o){if("string"==typeof r)return a.Payments.encodeSweepToken(e,n,r,o);if(o){var u=A(o.fee),i=c.validateAndParseAddress(o.recipient);return t.INTERFACE.encodeFunctionData("sweepTokenWithFee(address,uint256,uint256,address)",[e.address,a.toHex(n),u,i])}return t.INTERFACE.encodeFunctionData("sweepToken(address,uint256)",[e.address,a.toHex(n)])},t.encodePull=function(e,n){return t.INTERFACE.encodeFunctionData("pull",[e.address,a.toHex(n)])},t.encodeWrapETH=function(e){return t.INTERFACE.encodeFunctionData("wrapETH",[a.toHex(e)])},t}();function w(t,e,n,r,o,u,a){try{var i=t[u](a),c=i.value}catch(t){return void n(t)}i.done?e(c):Promise.resolve(c).then(r,o)}function E(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var u=t.apply(e,n);function a(t){w(u,r,o,a,i,"next",t)}function i(t){w(u,r,o,a,i,"throw",t)}a(void 0)}))}}function x(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function g(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 I(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 g(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)?g(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.")}T.INTERFACE=new r.Interface(p.abi);var P,R,_=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",u=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function i(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var o=Object.create((e&&e.prototype instanceof d?e:d).prototype),u=new g(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,u){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw u;return{value:void 0,done:!0}}for(n.method=o,n.arg=u;;){var a=n.delegate;if(a){var i=w(a,n);if(i){if(i===s)continue;return i}}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=p(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===s)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(t,n,u),o}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var s={};function d(){}function l(){}function f(){}var m={};i(m,o,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(I([])));v&&v!==e&&n.call(v,o)&&(m=v);var y=f.prototype=d.prototype=Object.create(m);function A(t){["next","throw","return"].forEach((function(e){i(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){var r;this._invoke=function(o,u){function a(){return new e((function(r,a){!function r(o,u,a,i){var c=p(t[o],t,u);if("throw"!==c.type){var s=c.arg,d=s.value;return d&&"object"==typeof d&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,a,i)}),(function(t){r("throw",t,a,i)})):e.resolve(d).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,i)}))}i(c.arg)}(o,u,r,a)}))}return r=r?r.then(a,a):a()}}function w(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,w(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var r=p(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,s;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function E(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 g(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function I(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,u=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 u.next=u}}return{next:P}}function P(){return{value:void 0,done:!0}}return l.prototype=f,i(y,"constructor",f),i(f,"constructor",l),l.displayName=i(f,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,i(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},A(T.prototype),i(T.prototype,u,(function(){return this})),t.AsyncIterator=T,t.async=function(e,n,r,o,u){void 0===u&&(u=Promise);var a=new T(c(e,n,r,o),u);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},A(y),i(y,a,"Generator"),i(y,o,(function(){return this})),i(y,"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=I,g.prototype={constructor:g,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 o=this.tryEntries.length-1;o>=0;--o){var u=this.tryEntries[o],a=u.completion;if("root"===u.tryLoc)return r("end");if(u.tryLoc<=this.prev){var i=n.call(u,"catchLoc"),c=n.call(u,"finallyLoc");if(i&&c){if(this.prev<u.catchLoc)return r(u.catchLoc,!0);if(this.prev<u.finallyLoc)return r(u.finallyLoc)}else if(i){if(this.prev<u.catchLoc)return r(u.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<u.finallyLoc)return r(u.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var u=o;break}}u&&("break"===t||"continue"===t)&&u.tryLoc<=e&&e<=u.finallyLoc&&(u=null);var a=u?u.completion:{};return a.type=t,a.arg=e,u?(this.method="next",this.next=u.finallyLoc,s):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),s},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),s}},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 o=r.arg;x(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:I(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(R={exports:{}}),R.exports);(P=exports.Protocol||(exports.Protocol={})).V2="V2",P.V3="V3";var N=function(t){function e(e){var n;return(n=t.call(this,e.pairs,e.input,e.output)||this).protocol=exports.Protocol.V2,n.pools=n.pairs,n}return x(e,t),e}(d.Route),O=function(t){function e(e){var n;return(n=t.call(this,e.pools,e.input,e.output)||this).protocol=exports.Protocol.V3,n.path=e.tokenPath,n}return x(e,t),e}(a.Route),b=function(){function t(t){var e=t.v2Routes,n=t.v3Routes,r=t.tradeType;this.swaps=[],this.routes=[];for(var u,i=I(e);!(u=i()).done;){var c=u.value,p=c.inputAmount,s=c.outputAmount,l=new N(c.routev2);this.routes.push(l),this.swaps.push({route:l,inputAmount:p,outputAmount:s})}for(var f,m=I(n);!(f=m()).done;){var h=f.value,v=h.inputAmount,y=h.outputAmount,A=new O(h.routev3);this.routes.push(A),this.swaps.push({route:A,inputAmount:v,outputAmount:y})}this.tradeType=r;var T=this.swaps[0].inputAmount.currency,w=this.swaps[0].outputAmount.currency;this.swaps.every((function(t){return T.wrapped.equals(t.route.input.wrapped)}))||o(!1),this.swaps.every((function(t){return w.wrapped.equals(t.route.output.wrapped)}))||o(!1);for(var E,x=this.swaps.map((function(t){return t.route.pools.length})).reduce((function(t,e){return t+e}),0),g=new Set,P=I(this.swaps);!(E=P()).done;)for(var R,_=E.value.route,b=I(_.pools);!(R=b()).done;){var F=R.value;_.protocol==exports.Protocol.V3?g.add(a.Pool.getAddress(F.token0,F.token1,F.fee)):g.add(d.Pair.getAddress(F.token0,F.token1))}x!=g.size&&o(!1)}var e,n=t.prototype;return n.minimumAmountOut=function(t,e){if(void 0===e&&(e=this.outputAmount),t.lessThan(m)&&o(!1),this.tradeType===c.TradeType.EXACT_OUTPUT)return e;var n=new c.Fraction(h).add(t).invert().multiply(e.quotient).quotient;return c.CurrencyAmount.fromRawAmount(e.currency,n)},n.maximumAmountIn=function(t,e){if(void 0===e&&(e=this.inputAmount),t.lessThan(m)&&o(!1),this.tradeType===c.TradeType.EXACT_INPUT)return e;var n=new c.Fraction(h).add(t).multiply(e.quotient).quotient;return c.CurrencyAmount.fromRawAmount(e.currency,n)},n.worstExecutionPrice=function(t){return new c.Price(this.inputAmount.currency,this.outputAmount.currency,this.maximumAmountIn(t).quotient,this.minimumAmountOut(t).quotient)},t.fromRoutes=function(){var e=E(_.mark((function e(n,r,o){var u,i,c,p,s,l,f,m,h,v,y,A,T;return _.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(u=[],i=[],c=I(n);!(p=c()).done;)f=new d.Trade(l=(s=p.value).routev2,s.amount,o),u.push({routev2:l,inputAmount:f.inputAmount,outputAmount:f.outputAmount});m=I(r);case 4:if((h=m()).done){e.next=13;break}return y=(v=h.value).routev3,A=v.amount,e.next=8,a.Trade.fromRoute(y,A,o);case 8:i.push({routev3:y,inputAmount:(T=e.sent).inputAmount,outputAmount:T.outputAmount});case 11:e.next=4;break;case 13:return e.abrupt("return",new t({v2Routes:u,v3Routes:i,tradeType:o}));case 14:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.fromRoute=function(){var e=E(_.mark((function e(n,r,o){var u,i,c,p;return _.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n instanceof d.Route)){e.next=7;break}c=new d.Trade(n,r,o),u=[{routev2:n,inputAmount:c.inputAmount,outputAmount:c.outputAmount}],i=[],e.next=13;break;case 7:return e.next=9,a.Trade.fromRoute(n,r,o);case 9:i=[{routev3:n,inputAmount:(p=e.sent).inputAmount,outputAmount:p.outputAmount}],u=[];case 13:return e.abrupt("return",new t({v2Routes:u,v3Routes:i,tradeType:o}));case 14:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),(e=[{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)}),c.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)}),c.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 c.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=c.CurrencyAmount.fromRawAmount(this.outputAmount.currency,0),n=I(this.swaps);!(t=n()).done;){var r=t.value;e=e.add(r.route.midPrice.quote(r.inputAmount))}var o=e.subtract(this.outputAmount).divide(e);return this._priceImpact=new c.Percent(o.numerator,o.denominator),this._priceImpact}}])&&function(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)}}(t.prototype,e),t}(),F=n.BigInt(0),M=function(){function t(){}return t.encodeV2Swap=function(e,n,r,o){var u=a.toHex(e.maximumAmountIn(n.slippageTolerance).quotient),i=a.toHex(e.minimumAmountOut(n.slippageTolerance).quotient),p=e.route.path.map((function(t){return t.address})),s=r?f:void 0===n.recipient?l:c.validateAndParseAddress(n.recipient);return e.tradeType===c.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("swapExactTokensForTokens",[u,o?0:i,p,s]):t.INTERFACE.encodeFunctionData("swapTokensForExactTokens",[i,u,p,s])},t.encodeV3Swap=function(e,n,r,o){for(var u,i=[],p=I(e.swaps);!(u=p()).done;){var s=u.value,d=s.route,m=s.outputAmount,h=a.toHex(e.maximumAmountIn(n.slippageTolerance,s.inputAmount).quotient),v=a.toHex(e.minimumAmountOut(n.slippageTolerance,m).quotient),y=1===d.pools.length,A=r?f:void 0===n.recipient?l:c.validateAndParseAddress(n.recipient);if(y)i.push(e.tradeType===c.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("exactInputSingle",[{tokenIn:d.tokenPath[0].address,tokenOut:d.tokenPath[1].address,fee:d.pools[0].fee,recipient:A,amountIn:h,amountOutMinimum:o?0:v,sqrtPriceLimitX96:0}]):t.INTERFACE.encodeFunctionData("exactOutputSingle",[{tokenIn:d.tokenPath[0].address,tokenOut:d.tokenPath[1].address,fee:d.pools[0].fee,recipient:A,amountOut:v,amountInMaximum:h,sqrtPriceLimitX96:0}]));else{var T=a.encodeRouteToPath(d,e.tradeType===c.TradeType.EXACT_OUTPUT);i.push(e.tradeType===c.TradeType.EXACT_INPUT?t.INTERFACE.encodeFunctionData("exactInput",[{path:T,recipient:A,amountIn:h,amountOutMinimum:o?0:v}]):t.INTERFACE.encodeFunctionData("exactOutput",[{path:T,recipient:A,amountOut:v,amountInMaximum:h}]))}}return i},t.encodeSwaps=function(e,n,r){if(e instanceof b){e.swaps.every((function(t){return t.route.protocol==exports.Protocol.V3||t.route.protocol==exports.Protocol.V2}))||o(!1);for(var u,i=[],p=I(e.swaps);!(u=p()).done;){var s=u.value,l=s.route,f=s.inputAmount,m=s.outputAmount;l.protocol==exports.Protocol.V2?i.push(new d.Trade(l,e.tradeType==c.TradeType.EXACT_INPUT?f:m,e.tradeType)):l.protocol==exports.Protocol.V3&&i.push(a.Trade.createUncheckedTrade({route:l,inputAmount:f,outputAmount:m,tradeType:e.tradeType}))}e=i}Array.isArray(e)||(e=[e]);var h=e.reduce((function(t,e){return t+(e instanceof a.Trade?e.swaps.length:1)}),0),v=e[0];e.every((function(t){return t.inputAmount.currency.equals(v.inputAmount.currency)}))||o(!1),e.every((function(t){return t.outputAmount.currency.equals(v.outputAmount.currency)}))||o(!1),e.every((function(t){return t.tradeType===v.tradeType}))||o(!1);var y=[],A=v.inputAmount.currency.isNative,T=v.outputAmount.currency.isNative,w=v.tradeType===c.TradeType.EXACT_INPUT&&h>2,E=T||!!n.fee||!!r||w;n.inputTokenPermit&&(v.inputAmount.currency.isToken||o(!1),y.push(a.SelfPermit.encodePermit(v.inputAmount.currency,n.inputTokenPermit)));for(var x,g=I(e);!(x=g()).done;){var P=x.value;if(P instanceof d.Trade)y.push(t.encodeV2Swap(P,n,E,w));else for(var R,_=I(t.encodeV3Swap(P,n,E,w));!(R=_()).done;)y.push(R.value)}var N=c.CurrencyAmount.fromRawAmount(v.inputAmount.currency,0),O=c.CurrencyAmount.fromRawAmount(v.outputAmount.currency,0),F=e.reduce((function(t,e){return t.add(e.minimumAmountOut(n.slippageTolerance))}),O),M=e.reduce((function(t,e){return t.add(e.maximumAmountIn(n.slippageTolerance))}),N);return{calldatas:y,sampleTrade:v,routerMustCustody:E,inputIsNative:A,outputIsNative:T,totalAmountIn:M,totalAmountOut:F}},t.swapCallParameters=function(e,n){var r=t.encodeSwaps(e,n),o=r.calldatas,u=r.sampleTrade,i=r.inputIsNative,p=r.totalAmountIn,s=r.totalAmountOut;return r.routerMustCustody&&o.push(r.outputIsNative?T.encodeUnwrapWETH9(s.quotient,n.recipient,n.fee):T.encodeSweepToken(u.outputAmount.currency.wrapped,s.quotient,n.recipient,n.fee)),i&&u.tradeType===c.TradeType.EXACT_OUTPUT&&o.push(a.Payments.encodeRefundETH()),{calldata:y.encodeMulticall(o,n.deadlineOrPreviousBlockhash),value:a.toHex(i?p.quotient:F)}},t.swapAndAddCallParameters=function(e,n,r,o,u,i){var p,s=t.encodeSwaps(e,n,!0),d=s.calldatas,l=s.inputIsNative,f=s.outputIsNative,m=s.totalAmountIn,h=s.totalAmountOut,A=s.sampleTrade.route.chainId,w=t.getPositionAmounts(r,r.pool.token0===m.currency.wrapped),E=w.positionAmountIn,x=w.positionAmountOut,g=l?c.WETH9[A]:E.currency.wrapped,I=f?c.WETH9[A]:x.currency.wrapped,P=x.subtract(h.wrapped);return P.greaterThan(c.CurrencyAmount.fromRawAmount(x.currency,0))&&d.push(f?T.encodeWrapETH(P.quotient):T.encodePull(I,P.quotient)),d.push(l?T.encodeWrapETH(E.quotient):T.encodePull(g,E.quotient)),u!==exports.ApprovalTypes.NOT_REQUIRED&&d.push(v.encodeApprove(g,u)),i!==exports.ApprovalTypes.NOT_REQUIRED&&d.push(v.encodeApprove(I,i)),d.push(v.encodeCallPositionManager([a.NonfungiblePositionManager.addCallParameters(r,o).calldata])),d.push(l?T.encodeUnwrapWETH9(F):T.encodeSweepToken(g,F)),d.push(f?T.encodeUnwrapWETH9(F):T.encodeSweepToken(I,F)),p=l?m.wrapped.add(E.wrapped).quotient:f?P.quotient:F,{calldata:y.encodeMulticall(d,n.deadlineOrPreviousBlockhash),value:p.toString()}},t.getPositionAmounts=function(t,e){var n=t.mintAmounts,r=n.amount1,o=c.CurrencyAmount.fromRawAmount(t.pool.token0,n.amount0),u=c.CurrencyAmount.fromRawAmount(t.pool.token1,r),a=e?[o,u]:[u,o];return{positionAmountIn:a[0],positionAmountOut:a[1]}},t}();M.INTERFACE=new r.Interface(s.abi),exports.ADDRESS_THIS=f,exports.ApproveAndCall=v,exports.MSG_SENDER=l,exports.MulticallExtended=y,exports.ONE=h,exports.PaymentsExtended=T,exports.RouteV2=N,exports.RouteV3=O,exports.SwapRouter=M,exports.Trade=b,exports.ZERO=m;
//# sourceMappingURL=router-sdk.cjs.production.min.js.map
import JSBI from 'jsbi';
import { Interface } from '@ethersproject/abi';
import { abi } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IMulticallExtended.sol/IMulticallExtended.json';
import { Multicall, toHex, Payments, NonfungiblePositionManager, Route as Route$1, Pool, Trade as Trade$1, encodeRouteToPath, SelfPermit } from '@uniswap/v3-sdk';
import invariant from 'tiny-invariant';
import { abi } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IApproveAndCall.sol/IApproveAndCall.json';
import { NonfungiblePositionManager, Multicall, toHex, Payments, Route as Route$1, Pool, Trade as Trade$1, encodeRouteToPath, SelfPermit } from '@uniswap/v3-sdk';
import { abi as abi$1 } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IMulticallExtended.sol/IMulticallExtended.json';
import { validateAndParseAddress, TradeType, Fraction, CurrencyAmount, Price, Percent, WETH9 } from '@uniswap/sdk-core';
import { abi as abi$1 } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IPeripheryPaymentsWithFeeExtended.sol/IPeripheryPaymentsWithFeeExtended.json';
import { abi as abi$2 } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IPeripheryPaymentsWithFeeExtended.sol/IPeripheryPaymentsWithFeeExtended.json';
import { abi as abi$3 } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/ISwapRouter02.sol/ISwapRouter02.json';
import { Route, Pair, Trade as Trade$2 } from '@uniswap/v2-sdk';
import invariant from 'tiny-invariant';
import { abi as abi$2 } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IApproveAndCall.sol/IApproveAndCall.json';

@@ -17,2 +17,68 @@ var MSG_SENDER = '0x0000000000000000000000000000000000000001';

var ApprovalTypes;
(function (ApprovalTypes) {
ApprovalTypes[ApprovalTypes["NOT_REQUIRED"] = 0] = "NOT_REQUIRED";
ApprovalTypes[ApprovalTypes["MAX"] = 1] = "MAX";
ApprovalTypes[ApprovalTypes["MAX_MINUS_ONE"] = 2] = "MAX_MINUS_ONE";
ApprovalTypes[ApprovalTypes["ZERO_THEN_MAX"] = 3] = "ZERO_THEN_MAX";
ApprovalTypes[ApprovalTypes["ZERO_THEN_MAX_MINUS_ONE"] = 4] = "ZERO_THEN_MAX_MINUS_ONE";
})(ApprovalTypes || (ApprovalTypes = {}));
var ApproveAndCall = /*#__PURE__*/function () {
/**
* Cannot be constructed.
*/
function ApproveAndCall() {}
ApproveAndCall.encodeApproveMax = function encodeApproveMax(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveMax', [token.address]);
};
ApproveAndCall.encodeApproveMaxMinusOne = function encodeApproveMaxMinusOne(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveMaxMinusOne', [token.address]);
};
ApproveAndCall.encodeApproveZeroThenMax = function encodeApproveZeroThenMax(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveZeroThenMax', [token.address]);
};
ApproveAndCall.encodeApproveZeroThenMaxMinusOne = function encodeApproveZeroThenMaxMinusOne(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveZeroThenMaxMinusOne', [token.address]);
};
ApproveAndCall.encodeCallPositionManager = function encodeCallPositionManager(calldatas) {
!(calldatas.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NULL_CALLDATA') : invariant(false) : void 0;
if (calldatas.length == 1) {
return ApproveAndCall.INTERFACE.encodeFunctionData('callPositionManager', calldatas);
} else {
var encodedMulticall = NonfungiblePositionManager.INTERFACE.encodeFunctionData('multicall', [calldatas]);
return ApproveAndCall.INTERFACE.encodeFunctionData('callPositionManager', [encodedMulticall]);
}
};
ApproveAndCall.encodeApprove = function encodeApprove(token, approvalType) {
switch (approvalType) {
case ApprovalTypes.MAX:
return ApproveAndCall.encodeApproveMax(token.wrapped);
case ApprovalTypes.MAX_MINUS_ONE:
return ApproveAndCall.encodeApproveMaxMinusOne(token.wrapped);
case ApprovalTypes.ZERO_THEN_MAX:
return ApproveAndCall.encodeApproveZeroThenMax(token.wrapped);
case ApprovalTypes.ZERO_THEN_MAX_MINUS_ONE:
return ApproveAndCall.encodeApproveZeroThenMaxMinusOne(token.wrapped);
default:
throw 'Error: invalid ApprovalType';
}
};
return ApproveAndCall;
}();
ApproveAndCall.INTERFACE = /*#__PURE__*/new Interface(abi);
function validateAndParseBytes32(bytes32) {

@@ -55,3 +121,3 @@ if (!bytes32.match(/^0x[0-9a-fA-F]{64}$/)) {

}();
MulticallExtended.INTERFACE = /*#__PURE__*/new Interface(abi);
MulticallExtended.INTERFACE = /*#__PURE__*/new Interface(abi$1);

@@ -108,3 +174,3 @@ function encodeFeeBips(fee) {

}();
PaymentsExtended.INTERFACE = /*#__PURE__*/new Interface(abi$1);
PaymentsExtended.INTERFACE = /*#__PURE__*/new Interface(abi$2);

@@ -217,68 +283,2 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {

var ApprovalTypes;
(function (ApprovalTypes) {
ApprovalTypes[ApprovalTypes["NOT_REQUIRED"] = 0] = "NOT_REQUIRED";
ApprovalTypes[ApprovalTypes["MAX"] = 1] = "MAX";
ApprovalTypes[ApprovalTypes["MAX_MINUS_ONE"] = 2] = "MAX_MINUS_ONE";
ApprovalTypes[ApprovalTypes["ZERO_THEN_MAX"] = 3] = "ZERO_THEN_MAX";
ApprovalTypes[ApprovalTypes["ZERO_THEN_MAX_MINUS_ONE"] = 4] = "ZERO_THEN_MAX_MINUS_ONE";
})(ApprovalTypes || (ApprovalTypes = {}));
var ApproveAndCall = /*#__PURE__*/function () {
/**
* Cannot be constructed.
*/
function ApproveAndCall() {}
ApproveAndCall.encodeApproveMax = function encodeApproveMax(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveMax', [token.address]);
};
ApproveAndCall.encodeApproveMaxMinusOne = function encodeApproveMaxMinusOne(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveMaxMinusOne', [token.address]);
};
ApproveAndCall.encodeApproveZeroThenMax = function encodeApproveZeroThenMax(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveZeroThenMax', [token.address]);
};
ApproveAndCall.encodeApproveZeroThenMaxMinusOne = function encodeApproveZeroThenMaxMinusOne(token) {
return ApproveAndCall.INTERFACE.encodeFunctionData('approveZeroThenMaxMinusOne', [token.address]);
};
ApproveAndCall.encodeCallPositionManager = function encodeCallPositionManager(calldatas) {
!(calldatas.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NULL_CALLDATA') : invariant(false) : void 0;
if (calldatas.length == 1) {
return ApproveAndCall.INTERFACE.encodeFunctionData('callPositionManager', calldatas);
} else {
var encodedMulticall = NonfungiblePositionManager.INTERFACE.encodeFunctionData('multicall', [calldatas]);
return ApproveAndCall.INTERFACE.encodeFunctionData('callPositionManager', [encodedMulticall]);
}
};
ApproveAndCall.encodeApprove = function encodeApprove(token, approvalType) {
switch (approvalType) {
case ApprovalTypes.MAX:
return ApproveAndCall.encodeApproveMax(token.wrapped);
case ApprovalTypes.MAX_MINUS_ONE:
return ApproveAndCall.encodeApproveMaxMinusOne(token.wrapped);
case ApprovalTypes.ZERO_THEN_MAX:
return ApproveAndCall.encodeApproveZeroThenMax(token.wrapped);
case ApprovalTypes.ZERO_THEN_MAX_MINUS_ONE:
return ApproveAndCall.encodeApproveZeroThenMaxMinusOne(token.wrapped);
default:
throw 'Error: invalid ApprovalType';
}
};
return ApproveAndCall;
}();
ApproveAndCall.INTERFACE = /*#__PURE__*/new Interface(abi$2);
function createCommonjsModule(fn, module) {

@@ -1725,3 +1725,3 @@ return module = { exports: {} }, fn(module, module.exports), module.exports;

export { ADDRESS_THIS, MSG_SENDER, MulticallExtended, ONE, PaymentsExtended, Protocol, RouteV2, RouteV3, SwapRouter, Trade, ZERO };
export { ADDRESS_THIS, ApprovalTypes, ApproveAndCall, MSG_SENDER, MulticallExtended, ONE, PaymentsExtended, Protocol, RouteV2, RouteV3, SwapRouter, Trade, ZERO };
//# sourceMappingURL=router-sdk.esm.js.map
{
"name": "@uniswap/router-sdk",
"version": "1.0.1",
"version": "1.0.2",
"description": "An sdk for routing swaps using Uniswap v2 and Uniswap v3.",

@@ -5,0 +5,0 @@ "publishConfig": {

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 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