@aryze/sdk-core
Version:
⚒️ An SDK for building applications on top of MAMAv3
3 lines (2 loc) • 14.8 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 r,e=t(require("jsbi")),n=t(require("tiny-invariant")),o=t(require("decimal.js-light")),i=t(require("big.js")),a=t(require("toformat")),u=require("@ethersproject/address");function s(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t,r,e){return r&&s(t.prototype,r),e&&s(t,e),t}function d(){return(d=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t}).apply(this,arguments)}function f(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r}(r=exports.ChainId||(exports.ChainId={}))[r.MAINNET=1]="MAINNET",r[r.GOERLI=5]="GOERLI",r[r.SEPOLIA=11155111]="SEPOLIA",r[r.OPTIMISM=10]="OPTIMISM",r[r.OPTIMISM_GOERLI=420]="OPTIMISM_GOERLI",r[r.ARBITRUM_ONE=42161]="ARBITRUM_ONE",r[r.ARBITRUM_GOERLI=421613]="ARBITRUM_GOERLI",r[r.POLYGON=137]="POLYGON",r[r.POLYGON_MUMBAI=80001]="POLYGON_MUMBAI",r[r.CELO=42220]="CELO",r[r.CELO_ALFAJORES=44787]="CELO_ALFAJORES",r[r.GNOSIS=100]="GNOSIS",r[r.MOONBEAM=1284]="MOONBEAM",r[r.BNB=56]="BNB",r[r.AVALANCHE=43114]="AVALANCHE";var p,l,h,E,m,A,x,y=[exports.ChainId.POLYGON];(p=exports.NativeCurrencyName||(exports.NativeCurrencyName={})).ETHER="ETH",p.MATIC="MATIC",p.CELO="CELO",p.GNOSIS="XDAI",p.MOONBEAM="GLMR",p.BNB="BNB",p.AVAX="AVAX";var D=[exports.ChainId.MAINNET,exports.ChainId.GOERLI];function C(t,r){return void 0===r&&(r=[]),D.concat(r).reduce((function(r,e){return r[e]=t,r}),{})}var O,S,R=C("0x153aA5089AeEC67a3de79685D7d8b49B487068Fc",[exports.ChainId.OPTIMISM,exports.ChainId.ARBITRUM_ONE,exports.ChainId.POLYGON,exports.ChainId.POLYGON_MUMBAI,exports.ChainId.SEPOLIA]),I=C("0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f"),_=C("0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"),N=((l={})[exports.ChainId.POLYGON]={v3PoolDeployerAddress:"0x2fB03F1e822fB401981e7b770EB01F8f877D835C",v3CoreFactoryAddress:"0xE7aE959bbC94BDF2E9FF28a214840aB3285d7765",multicallAddress:"0xf6B628751d5cD2F0248c0D5eB7eD5849Bade2a54",quoterAddress:"0xA2b78476E1f4994a2d9ad6ca39e2500F73b94096",v3MigratorAddress:"0xd5e7e49e47cb05ec158C46fF09D9eFf211611147",nonfungiblePositionManagerAddress:"0x1f7C66CcB8F95Fd8897c219E0c85840f0EaC01e7",tickLensAddress:"0xaeD113d326b574996547375c2332216B09c4cdaB"},l),v=d({},y.reduce((function(t,r){return t[r]=N[r].v3CoreFactoryAddress,t}),{})),T=d({},y.reduce((function(t,r){var e=N[r].v3MigratorAddress;return e&&(t[r]=e),t}),{})),F=d({},y.reduce((function(t,r){return t[r]=N[r].multicallAddress,t}),{})),g=C("0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F"),B=((h={})[exports.ChainId.MAINNET]="0xC4e172459f1E7939D522503B81AFAaC1014CE6F6",h),b=((E={})[exports.ChainId.MAINNET]="0x408ED6354d4973f66138C91495F2f2FCbd8724C3",E),P=C("0x1a9C8182C09F50C8318d769245beA52c32BE35BC"),M=((m={})[exports.ChainId.MAINNET]="0x090D4613473dEE047c3f2706764f49E0821D256e",m),L=((A={})[exports.ChainId.MAINNET]="0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8",A),U=d({},y.reduce((function(t,r){return t[r]=N[r].quoterAddress,t}),{})),w=d({},y.reduce((function(t,r){var e=N[r].nonfungiblePositionManagerAddress;return e&&(t[r]=e),t}),{})),q=d({},C("0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e")),W=((x={})[exports.ChainId.MAINNET]="0x65770b5283117639760beA3F867b69b3697a91dd",x),G=d({},y.reduce((function(t,r){var e=N[r].tickLensAddress;return e&&(t[r]=e),t}),{})),H=y.reduce((function(t,r){var e=N[r].v1MixedRouteQuoterAddress;return e&&(t[r]=e),t}),{});(O=exports.TradeType||(exports.TradeType={}))[O.EXACT_INPUT=0]="EXACT_INPUT",O[O.EXACT_OUTPUT=1]="EXACT_OUTPUT",(S=exports.Rounding||(exports.Rounding={}))[S.ROUND_DOWN=0]="ROUND_DOWN",S[S.ROUND_HALF_UP=1]="ROUND_HALF_UP",S[S.ROUND_UP=2]="ROUND_UP";var V,k,j=e.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Y=a(o),X=a(i),K=((V={})[exports.Rounding.ROUND_DOWN]=Y.ROUND_DOWN,V[exports.Rounding.ROUND_HALF_UP]=Y.ROUND_HALF_UP,V[exports.Rounding.ROUND_UP]=Y.ROUND_UP,V),Q=((k={})[exports.Rounding.ROUND_DOWN]=0,k[exports.Rounding.ROUND_HALF_UP]=1,k[exports.Rounding.ROUND_UP]=3,k),J=function(){function t(t,r){void 0===r&&(r=e.BigInt(1)),this.numerator=e.BigInt(t),this.denominator=e.BigInt(r)}t.tryParseFraction=function(r){if(r instanceof e||"number"==typeof r||"string"==typeof r)return new t(r);if("numerator"in r&&"denominator"in r)return r;throw new Error("Could not parse fraction")};var r=t.prototype;return r.invert=function(){return new t(this.denominator,this.numerator)},r.add=function(r){var n=t.tryParseFraction(r);return e.equal(this.denominator,n.denominator)?new t(e.add(this.numerator,n.numerator),this.denominator):new t(e.add(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator)),e.multiply(this.denominator,n.denominator))},r.subtract=function(r){var n=t.tryParseFraction(r);return e.equal(this.denominator,n.denominator)?new t(e.subtract(this.numerator,n.numerator),this.denominator):new t(e.subtract(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator)),e.multiply(this.denominator,n.denominator))},r.lessThan=function(r){var n=t.tryParseFraction(r);return e.lessThan(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator))},r.equalTo=function(r){var n=t.tryParseFraction(r);return e.equal(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator))},r.greaterThan=function(r){var n=t.tryParseFraction(r);return e.greaterThan(e.multiply(this.numerator,n.denominator),e.multiply(n.numerator,this.denominator))},r.multiply=function(r){var n=t.tryParseFraction(r);return new t(e.multiply(this.numerator,n.numerator),e.multiply(this.denominator,n.denominator))},r.divide=function(r){var n=t.tryParseFraction(r);return new t(e.multiply(this.numerator,n.denominator),e.multiply(this.denominator,n.numerator))},r.toSignificant=function(t,r,e){void 0===r&&(r={groupSeparator:""}),void 0===e&&(e=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||n(!1),t>0||n(!1),Y.set({precision:t+1,rounding:K[e]});var o=new Y(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return o.toFormat(o.decimalPlaces(),r)},r.toFixed=function(t,r,e){return void 0===r&&(r={groupSeparator:""}),void 0===e&&(e=exports.Rounding.ROUND_HALF_UP),Number.isInteger(t)||n(!1),t>=0||n(!1),X.DP=t,X.RM=Q[e],new X(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,r)},c(t,[{key:"quotient",get:function(){return e.divide(this.numerator,this.denominator)}},{key:"remainder",get:function(){return new t(e.remainder(this.numerator,this.denominator),this.denominator)}},{key:"asFraction",get:function(){return new t(this.numerator,this.denominator)}}]),t}(),$=a(i),z=function(t){function r(r,o,i){var a;return a=t.call(this,o,i)||this,e.lessThanOrEqual(a.quotient,j)||n(!1),a.currency=r,a.decimalScale=e.exponentiate(e.BigInt(10),e.BigInt(r.decimals)),a}f(r,t),r.fromRawAmount=function(t,e){return new r(t,e)},r.fromFractionalAmount=function(t,e,n){return new r(t,e,n)};var o=r.prototype;return o.add=function(e){this.currency.equals(e.currency)||n(!1);var o=t.prototype.add.call(this,e);return r.fromFractionalAmount(this.currency,o.numerator,o.denominator)},o.subtract=function(e){this.currency.equals(e.currency)||n(!1);var o=t.prototype.subtract.call(this,e);return r.fromFractionalAmount(this.currency,o.numerator,o.denominator)},o.multiply=function(e){var n=t.prototype.multiply.call(this,e);return r.fromFractionalAmount(this.currency,n.numerator,n.denominator)},o.divide=function(e){var n=t.prototype.divide.call(this,e);return r.fromFractionalAmount(this.currency,n.numerator,n.denominator)},o.toSignificant=function(r,e,n){return void 0===r&&(r=6),void 0===n&&(n=exports.Rounding.ROUND_DOWN),t.prototype.divide.call(this,this.decimalScale).toSignificant(r,e,n)},o.toFixed=function(r,e,o){return void 0===r&&(r=this.currency.decimals),void 0===o&&(o=exports.Rounding.ROUND_DOWN),r<=this.currency.decimals||n(!1),t.prototype.divide.call(this,this.decimalScale).toFixed(r,e,o)},o.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),$.DP=this.currency.decimals,new $(this.quotient.toString()).div(this.decimalScale.toString()).toFormat(t)},c(r,[{key:"wrapped",get:function(){return this.currency.isToken?this:r.fromFractionalAmount(this.currency.wrapped,this.numerator,this.denominator)}}]),r}(J),Z=new J(e.BigInt(100));function tt(t){return new rt(t.numerator,t.denominator)}var rt=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).isPercent=!0,r}f(r,t);var e=r.prototype;return e.add=function(r){return tt(t.prototype.add.call(this,r))},e.subtract=function(r){return tt(t.prototype.subtract.call(this,r))},e.multiply=function(r){return tt(t.prototype.multiply.call(this,r))},e.divide=function(r){return tt(t.prototype.divide.call(this,r))},e.toSignificant=function(r,e,n){return void 0===r&&(r=5),t.prototype.multiply.call(this,Z).toSignificant(r,e,n)},e.toFixed=function(r,e,n){return void 0===r&&(r=2),t.prototype.multiply.call(this,Z).toFixed(r,e,n)},r}(J),et=function(t){function r(){for(var r,n,o,i,a,u=arguments.length,s=new Array(u),c=0;c<u;c++)s[c]=arguments[c];if(4===s.length)n=s[0],o=s[1],i=s[2],a=s[3];else{var d=s[0].quoteAmount.divide(s[0].baseAmount),f=[s[0].baseAmount.currency,s[0].quoteAmount.currency,d.denominator,d.numerator];n=f[0],o=f[1],i=f[2],a=f[3]}return(r=t.call(this,a,i)||this).baseCurrency=n,r.quoteCurrency=o,r.scalar=new J(e.exponentiate(e.BigInt(10),e.BigInt(n.decimals)),e.exponentiate(e.BigInt(10),e.BigInt(o.decimals))),r}f(r,t);var o=r.prototype;return o.invert=function(){return new r(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},o.multiply=function(e){this.quoteCurrency.equals(e.baseCurrency)||n(!1);var o=t.prototype.multiply.call(this,e);return new r(this.baseCurrency,e.quoteCurrency,o.denominator,o.numerator)},o.quote=function(r){r.currency.equals(this.baseCurrency)||n(!1);var e=t.prototype.multiply.call(this,r);return z.fromFractionalAmount(this.quoteCurrency,e.numerator,e.denominator)},o.toSignificant=function(t,r,e){return void 0===t&&(t=6),this.adjustedForDecimals.toSignificant(t,r,e)},o.toFixed=function(t,r,e){return void 0===t&&(t=4),this.adjustedForDecimals.toFixed(t,r,e)},c(r,[{key:"adjustedForDecimals",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),r}(J),nt=function(t,r,e,o){Number.isSafeInteger(t)||n(!1),r>=0&&r<255&&Number.isInteger(r)||n(!1),this.chainId=t,this.decimals=r,this.symbol=e,this.name=o},ot=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).isNative=!0,r.isToken=!1,r}return f(r,t),r}(nt);function it(t){try{return u.getAddress(t)}catch(r){throw new Error(t+" is not a valid address.")}}var at,ut=/^0x[0-9a-fA-F]{40}$/,st=function(t){function r(r,e,n,o,i,a){var u;return(u=t.call(this,r,n,o,i)||this).isNative=!1,u.isToken=!0,u.address=a?function(t){if(ut.test(t))return t;throw new Error(t+" is not a valid address.")}(e):it(e),u}f(r,t);var e=r.prototype;return e.equals=function(t){return t.isToken&&this.chainId===t.chainId&&this.address.toLowerCase()===t.address.toLowerCase()},e.sortsBefore=function(t){return this.chainId!==t.chainId&&n(!1),this.address.toLowerCase()===t.address.toLowerCase()&&n(!1),this.address.toLowerCase()<t.address.toLowerCase()},c(r,[{key:"wrapped",get:function(){return this}}]),r}(nt),ct=((at={})[1]=new st(1,"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",18,"WETH","Wrapped Ether"),at[3]=new st(3,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),at[4]=new st(4,"0xc778417E063141139Fce010982780140Aa0cD5Ab",18,"WETH","Wrapped Ether"),at[5]=new st(5,"0xF63d162684f868f865216aBc045071822784c578",18,"WETH","Wrapped Ether"),at[80001]=new st(80001,"0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889",18,"WMATIC","Wrapped Matic"),at[42]=new st(42,"0xd0A1E359811322d97991E03f863a0C30C2cF029C",18,"WETH","Wrapped Ether"),at[10]=new st(10,"0x4200000000000000000000000000000000000006",18,"WETH","Wrapped Ether"),at[69]=new st(69,"0x4200000000000000000000000000000000000006",18,"WETH","Wrapped Ether"),at[42161]=new st(42161,"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",18,"WETH","Wrapped Ether"),at[421611]=new st(421611,"0xB47e6A5f8b33b3F17603C83a0535A9dcD7E32681",18,"WETH","Wrapped Ether"),at),dt=function(t){function r(r){return t.call(this,r,18,"ETH","Ether")||this}return f(r,t),r.onChain=function(t){var e;return null!=(e=this._etherCache[t])?e:this._etherCache[t]=new r(t)},r.prototype.equals=function(t){return t.isNative&&t.chainId===this.chainId},c(r,[{key:"wrapped",get:function(){var t=ct[this.chainId];return t||n(!1),t}}]),r}(ot);dt._etherCache={};var ft=e.BigInt(Number.MAX_SAFE_INTEGER),pt=e.BigInt(0),lt=e.BigInt(1),ht=e.BigInt(2);exports.ARGENT_WALLET_DETECTOR_ADDRESS=L,exports.CHAIN_TO_ADDRESSES_MAP=N,exports.CurrencyAmount=z,exports.ENS_REGISTRAR_ADDRESSES=q,exports.Ether=dt,exports.Fraction=J,exports.GOVERNANCE_ALPHA_V0_ADDRESSES=g,exports.GOVERNANCE_ALPHA_V1_ADDRESSES=B,exports.GOVERNANCE_BRAVO_ADDRESSES=b,exports.MERKLE_DISTRIBUTOR_ADDRESS=M,exports.MIXED_ROUTE_QUOTER_V1_ADDRESSES=H,exports.MULTICALL_ADDRESSES=F,exports.MaxUint256=j,exports.NONFUNGIBLE_POSITION_MANAGER_ADDRESSES=w,exports.NativeCurrency=ot,exports.Percent=rt,exports.Price=et,exports.QUOTER_ADDRESSES=U,exports.SOCKS_CONTROLLER_ADDRESSES=W,exports.SUPPORTED_CHAINS=y,exports.SWAP_ROUTER_02_ADDRESSES=function(t){return exports,"0xD5468622Eab451384273CdafE3B516e55AFf9d12"},exports.TICK_LENS_ADDRESSES=G,exports.TIMELOCK_ADDRESSES=P,exports.Token=st,exports.UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS="0x8B799381ac40b838BBA4131ffB26197C432AFe78",exports.UNI_ADDRESSES=R,exports.V2_FACTORY_ADDRESS="0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",exports.V2_FACTORY_ADDRESSES=I,exports.V2_ROUTER_ADDRESS="0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",exports.V2_ROUTER_ADDRESSES=_,exports.V3_CORE_FACTORY_ADDRESSES=v,exports.V3_MIGRATOR_ADDRESSES=T,exports.WETH9=ct,exports.computePriceImpact=function(t,r,e){var n=t.quote(r),o=n.subtract(e).divide(n);return new rt(o.numerator,o.denominator)},exports.sortedInsert=function(t,r,e,o){if(e>0||n(!1),t.length<=e||n(!1),0===t.length)return t.push(r),null;var i=t.length===e;if(i&&o(t[t.length-1],r)<=0)return r;for(var a=0,u=t.length;a<u;){var s=a+u>>>1;o(t[s],r)<=0?a=s+1:u=s}return t.splice(a,0,r),i?t.pop():null},exports.sqrt=function(t){if(e.greaterThanOrEqual(t,pt)||n(!1),e.lessThan(t,ft))return e.BigInt(Math.floor(Math.sqrt(e.toNumber(t))));var r,o;for(r=t,o=e.add(e.divide(t,ht),lt);e.lessThan(o,r);)r=o,o=e.divide(e.add(e.divide(t,o),o),ht);return r},exports.validateAndParseAddress=it;
//# sourceMappingURL=sdk-core.cjs.production.min.js.map