UNPKG

@everestswap/sdk

Version:

🛠 An SDK for building applications on top of Everest.

3 lines (2 loc) • 34.7 kB
"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")),s=(t(require("tiny-warning")),require("@ethersproject/address")),u=require("@ethersproject/contracts"),p=require("@ethersproject/networks"),c=require("@ethersproject/providers"),d=t(require("big.js")),l=t(require("toformat")),y=t(require("decimal.js-light")),m=require("@ethersproject/solidity");!function(t){t[t.ICE_MAINNET=550]="ICE_MAINNET",t[t.ICE_SNOW=552]="ICE_SNOW",t[t.ICE_ARCTIC=553]="ICE_ARCTIC"}(exports.ChainId||(exports.ChainId={})),(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 f,h={ICE_MAINNET:{TOKEN:"0x0000000000000000000000000000000000001111",FACTORY:"0x0000000000000000000000000000000000001112",ROUTER:"0x0000000000000000000000000000000000001113",WICZ:"0x0000000000000000000000000000000000001114",CHEF:"0x0000000000000000000000000000000000001115",AIRDROP:"0x0000000000000000000000000000000000001116",MULTICALL:"0x0000000000000000000000000000000000001117"},ICE_SNOW:{TOKEN:"0x0000000000000000000000000000000000001111",FACTORY:"0x8a5B2745f4C9334ca5B91d9db8c4ba049Ad38E0F",ROUTER:"0x622032CAA208Bdd9908564CEEFB50C36Cc576c60",WICZ:"0xd92FB2844E76e455DfD0e20D46BCA2Cc77558B6e",CHEF:"0x0000000000000000000000000000000000001115",AIRDROP:"0x0000000000000000000000000000000000001116",MULTICALL:"0x3c68c784B94040d49C0b935ddfAedC36b8Dc8526"},ICE_ARCTIC:{TOKEN:"0xCf3cd1A322fA7397588a48e6bC0eB2cDe56fe783",FACTORY:"0x720E42229a3552648B2AB5C01DbEadEfEC0f7bcb",ROUTER:"0x260Ed18B4c96Ef72551F28Ca086fc99a11331f76",WICZ:"0xd92FB2844E76e455DfD0e20D46BCA2Cc77558B6e",CHEF:"0x6A21eE0519a3614161A60CD59887A9392b8b9FC1",AIRDROP:"0x6e4D6C1c10DEBD2f938B6375dC28C4158b3c47fD",MULTICALL:"0x3c68c784B94040d49C0b935ddfAedC36b8Dc8526"}},v=((e={})[exports.ChainId.ICE_MAINNET]=h.ICE_MAINNET.FACTORY,e[exports.ChainId.ICE_SNOW]=h.ICE_SNOW.FACTORY,e[exports.ChainId.ICE_ARCTIC]=h.ICE_ARCTIC.FACTORY,e),T="0xd4cc97f7f1105b7d9084d4771a71f7c9772a5b9546b3736add1f2ebe94995713",I=a.BigInt(1e3),C=a.BigInt(0),w=a.BigInt(1),b=a.BigInt(2),E=a.BigInt(3),x=a.BigInt(5),A=a.BigInt(10),k=a.BigInt(100),_=a.BigInt(997),g=a.BigInt(1e3);!function(t){t.uint8="uint8",t.uint256="uint256"}(f||(f={}));var N=((n={})[f.uint8]=a.BigInt("0xff"),n[f.uint256]=a.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n);function O(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 R(t,e,n){return e&&O(t.prototype,e),n&&O(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function M(){return(M=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 q(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,P(t,e)}function U(t){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function P(t,e){return(P=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function D(t,e,n){return(D=S()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&P(i,n.prototype),i}).apply(null,arguments)}function F(t){var e="function"==typeof Map?new Map:void 0;return(F=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 D(t,arguments,U(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),P(n,t)})(t)}function B(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function W(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 j(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 W(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)?W(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.")}var Z="setPrototypeOf"in Object,L=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientReservesError=!0,n.name=n.constructor.name,Z&&Object.setPrototypeOf(B(n),(this instanceof e?this.constructor:void 0).prototype),n}return q(e,t),e}(F(Error)),H=function(t){function e(){var n;return(n=t.call(this)||this).isInsufficientInputAmountError=!0,n.name=n.constructor.name,Z&&Object.setPrototypeOf(B(n),(this instanceof e?this.constructor:void 0).prototype),n}return q(e,t),e}(F(Error));function Y(t,e){a.greaterThanOrEqual(t,C)||o(!1),a.lessThanOrEqual(t,N[e])||o(!1)}function X(t){try{return s.getAddress(t)}catch(t){o(!1)}}function K(t){return t instanceof a?t:a.BigInt("bigint"==typeof t?t.toString():t)}function V(t){Y(t,f.uint256);var e,n=C;if(a.greaterThan(t,E))for(n=t,e=a.add(a.divide(t,b),w);a.lessThan(e,n);)n=e,e=a.divide(a.add(a.divide(t,e),e),b);else a.notEqual(t,C)&&(n=w);return n}function Q(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,s=t.length;a<s;){var u=a+s>>>1;r(t[u],e)<=0?a=u+1:s=u}return t.splice(a,0,e),i?t.pop():null}function z(t){return"0x"+t.raw.toString(16)}var J,$,G,tt,et=function(){function t(){}return t.swapCallParameters=function(t,e,n){void 0===n&&(n=exports.ChainId.ICE_MAINNET);var r=t.inputAmount.currency===xt[n],i=t.outputAmount.currency===xt[n];r&&i&&o(!1),!("ttl"in e)||e.ttl>0||o(!1);var a,s,u,p=X(e.recipient),c=z(t.maximumAmountIn(e.allowedSlippage,n)),d=z(t.minimumAmountOut(e.allowedSlippage,n)),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),m=Boolean(e.feeOnTransfer);switch(t.tradeType){case exports.TradeType.EXACT_INPUT:r?(a=m?"swapExactICZForTokensSupportingFeeOnTransferTokens":"swapExactICZForTokens",s=[d,l,p,y],u=c):i?(a=m?"swapExactTokensForICZSupportingFeeOnTransferTokens":"swapExactTokensForICZ",s=[c,d,l,p,y],u="0x0"):(a=m?"swapExactTokensForTokensSupportingFeeOnTransferTokens":"swapExactTokensForTokens",s=[c,d,l,p,y],u="0x0");break;case exports.TradeType.EXACT_OUTPUT:m&&o(!1),r?(a="swapICZForExactTokens",s=[d,l,p,y],u=c):i?(a="swapTokensForExactICZ",s=[d,c,l,p,y],u="0x0"):(a="swapTokensForExactTokens",s=[d,c,l,p,y],u="0x0")}return{methodName:a,args:s,value:u}},t}(),nt=l(y),rt=l(d),it=((J={})[exports.Rounding.ROUND_DOWN]=nt.ROUND_DOWN,J[exports.Rounding.ROUND_HALF_UP]=nt.ROUND_HALF_UP,J[exports.Rounding.ROUND_UP]=nt.ROUND_UP,J),at=(($={})[exports.Rounding.ROUND_DOWN]=0,$[exports.Rounding.ROUND_HALF_UP]=1,$[exports.Rounding.ROUND_UP]=3,$),ot=function(){function t(t,e){void 0===e&&(e=w),this.numerator=K(t),this.denominator=K(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(K(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(K(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(K(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(K(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(K(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(K(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(K(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),nt.set({precision:t+1,rounding:it[n]});var r=new nt(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),rt.DP=t,rt.RM=at[n],new rt(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)},R(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)}}]),t}(),st=l(d),ut=function(t){function e(e,n){var r,i=K(n);return Y(i,f.uint256),(r=t.call(this,i,a.exponentiate(A,a.BigInt(e.decimals)))||this).currency=e,r}q(e,t),e.ether=function(t,n){return void 0===n&&(n=exports.ChainId.ICE_MAINNET),new e(xt[n],t)};var n=e.prototype;return n.add=function(t){return kt(this.currency,t.currency)||o(!1),new e(this.currency,a.add(this.raw,t.raw))},n.subtract=function(t){return kt(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:""}),st.DP=this.currency.decimals,new st(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)},R(e,[{key:"raw",get:function(){return this.numerator}}]),e}(ot),pt=function(t){function e(e,n){var r;return(r=t.call(this,e,n)||this).token=e,r}q(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}(ut),ct=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 ot(a.exponentiate(A,a.BigInt(e.decimals)),a.exponentiate(A,a.BigInt(n.decimals))),o}q(e,t),e.fromRoute=function(t){for(var n,r=[],i=j(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){kt(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,n){return void 0===n&&(n=exports.ChainId.ICE_MAINNET),kt(e.currency,this.baseCurrency)||o(!1),this.quoteCurrency instanceof At?new pt(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient):ut.ether(t.prototype.multiply.call(this,e.raw).quotient,n)},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)},R(e,[{key:"raw",get:function(){return new ot(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(ot),dt={},lt=function(){function t(e,n,r){void 0===r&&(r=exports.ChainId.ICE_MAINNET);var i=e.token.sortsBefore(n.token)?[e,n]:[n,e];this.liquidityToken=new At(i[0].token.chainId,t.getAddress(i[0].token,i[1].token,r),18,"EVRSL","Everest Liquidity"),this.tokenAmounts=i}t.getAddress=function(t,e,n){var r,i;void 0===n&&(n=exports.ChainId.ICE_MAINNET);var a,o,u,p=t.sortsBefore(e)?[t,e]:[e,t];return void 0===(null===(r=dt)||void 0===r||null===(i=r[p[0].address])||void 0===i?void 0:i[p[1].address])&&(dt=M({},dt,((u={})[p[0].address]=M({},null===(a=dt)||void 0===a?void 0:a[p[0].address],((o={})[p[1].address]=s.getCreate2Address(v[n],m.keccak256(["bytes"],[m.pack(["address","address"],[p[0].address,p[1].address])]),T),o)),u))),dt[p[0].address][p[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,n){if(void 0===n&&(n=exports.ChainId.ICE_MAINNET),this.involvesToken(e.token)||o(!1),a.equal(this.reserve0.raw,C)||a.equal(this.reserve1.raw,C))throw new L;var r=this.reserveOf(e.token),i=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),s=a.multiply(e.raw,_),u=a.multiply(s,i.raw),p=a.add(a.multiply(r.raw,g),s),c=new pt(e.token.equals(this.token0)?this.token1:this.token0,a.divide(u,p));if(a.equal(c.raw,C))throw new H;return[c,new t(r.add(e),i.subtract(c),n)]},e.getInputAmount=function(e,n){if(void 0===n&&(n=exports.ChainId.ICE_MAINNET),this.involvesToken(e.token)||o(!1),a.equal(this.reserve0.raw,C)||a.equal(this.reserve1.raw,C)||a.greaterThanOrEqual(e.raw,this.reserveOf(e.token).raw))throw new L;var r=this.reserveOf(e.token),i=this.reserveOf(e.token.equals(this.token0)?this.token1:this.token0),s=a.multiply(a.multiply(i.raw,e.raw),g),u=a.multiply(a.subtract(r.raw,e.raw),_),p=new pt(e.token.equals(this.token0)?this.token1:this.token0,a.add(a.divide(s,u),w));return[p,new t(i.add(p),r.subtract(e),n)]},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,C))r=a.subtract(V(a.multiply(i[0].raw,i[1].raw)),I);else{var s=a.divide(a.multiply(i[0].raw,t.raw),this.reserve0.raw),u=a.divide(a.multiply(i[1].raw,t.raw),this.reserve1.raw);r=a.lessThanOrEqual(s,u)?s:u}if(!a.greaterThan(r,C))throw new H;return new pt(this.liquidityToken,r)},e.getLiquidityValue=function(t,e,n,r,i){var s;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 u=K(i);if(a.equal(u,C))s=e;else{var p=V(a.multiply(this.reserve0.raw,this.reserve1.raw)),c=V(u);if(a.greaterThan(p,c)){var d=a.multiply(e.raw,a.subtract(p,c)),l=a.add(a.multiply(p,x),c),y=a.divide(d,l);s=e.add(new pt(this.liquidityToken,y))}else s=e}}else s=e;return new pt(t,a.divide(a.multiply(n.raw,this.reserveOf(t).raw),s.raw))},R(t,[{key:"token0Price",get:function(){return new ct(this.token0,this.token1,this.tokenAmounts[0].raw,this.tokenAmounts[1].raw)}},{key:"token1Price",get:function(){return new ct(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}(),yt=[{inputs:[],payable:!1,stateMutability:"nonpayable",type:"constructor"},{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"},{constant:!0,inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"MINIMUM_LIQUIDITY",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"}],name:"burn",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getReserves",outputs:[{internalType:"uint112",name:"_reserve0",type:"uint112"},{internalType:"uint112",name:"_reserve1",type:"uint112"},{internalType:"uint32",name:"_blockTimestampLast",type:"uint32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"_token0",type:"address"},{internalType:"address",name:"_token1",type:"address"}],name:"initialize",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"kLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[{internalType:"uint256",name:"liquidity",type:"uint256"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,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:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"price0CumulativeLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"price1CumulativeLast",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"}],name:"skim",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,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:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[],name:"sync",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"token0",outputs:[{internalType:"address",name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"token1",outputs:[{internalType:"address",name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,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"}],payable:!1,stateMutability:"nonpayable",type:"function"}],mt=[{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"}],ft={},ht=function(){function t(){}return t.fetchTokenData=function(t,e,n,r,i){try{var a,o,s=function(n){return new At(t,e,n,r,i)};void 0===t&&(t=exports.ChainId.ICE_MAINNET),void 0===n&&(n=c.getDefaultProvider(p.getNetwork(t)));var d="number"==typeof(null===(a=ft)||void 0===a||null===(o=a[t])||void 0===o?void 0:o[e]);return Promise.resolve(d?s(ft[t][e]):Promise.resolve(new u.Contract(e,mt,n).decimals().then((function(n){var r,i,a;return ft=M({},ft,((a={})[t]=M({},null===(r=ft)||void 0===r?void 0:r[t],((i={})[e]=n,i)),a)),n}))).then(s))}catch(t){return Promise.reject(t)}},t.fetchPairData=function(t,e,n){try{void 0===n&&(n=c.getDefaultProvider(p.getNetwork(t.chainId))),t.chainId!==e.chainId&&o(!1);var r=lt.getAddress(t,e,t.chainId);return Promise.resolve(new u.Contract(r,yt,n).getReserves()).then((function(n){var r=n[0],i=n[1],a=t.sortsBefore(e)?[r,i]:[i,r];return new lt(new pt(t,a[0]),new pt(e,a[1]),t.chainId)}))}catch(t){return Promise.reject(t)}},t}(),vt={id:"ice_mainnet",chain_id:550,name:"ICE Network",symbol:"ICY",token_symbol:"EVRS",mainnet:!0,dex_is_live:!1,tracked_by_debank:!1,supported_by_gelato:!1,rpc_uri:"https://ice-rpc.icenetwork.io",contracts:{token:h.ICE_MAINNET.TOKEN,factory:h.ICE_MAINNET.FACTORY,router:h.ICE_MAINNET.ROUTER,wrapped_native_token:h.ICE_MAINNET.WICZ},nativeCurrency:{name:"ICY",symbol:"ICY",decimals:18},blockExplorerUrls:[]},Tt={id:"ice_snow",chain_id:552,name:"ICE Network",symbol:"ICZ",token_symbol:"EVRS",mainnet:!0,dex_is_live:!1,tracked_by_debank:!1,supported_by_gelato:!1,rpc_uri:"https://snow-rpc.icenetwork.io:9933",contracts:{token:h.ICE_MAINNET.TOKEN,factory:h.ICE_MAINNET.FACTORY,router:h.ICE_MAINNET.ROUTER,wrapped_native_token:h.ICE_MAINNET.WICZ},nativeCurrency:{name:"ICZ",symbol:"ICZ",decimals:18},blockExplorerUrls:[]},It={id:"ice_arctic",chain_id:553,name:"Arctic Testnet",symbol:"ICZ",token_symbol:"EVRS",mainnet:!1,dex_is_live:!0,tracked_by_debank:!1,supported_by_gelato:!1,rpc_uri:"https://arctic-rpc.icenetwork.io:9933",contracts:{token:h.ICE_ARCTIC.TOKEN,factory:h.ICE_ARCTIC.FACTORY,router:h.ICE_ARCTIC.ROUTER,wrapped_native_token:h.ICE_ARCTIC.WICZ},nativeCurrency:{name:"ICZ",symbol:"ICZ",decimals:18},blockExplorerUrls:["https://arctic-blockscout.icenetwork.io"]};!function(t){t[t.ARCTIC=553]="ARCTIC",t[t.SNOW=552]="SNOW",t[t.ICE=550]="ICE"}(tt||(tt={}));var Ct,wt,bt=((G={})[tt.ARCTIC]=It,G[tt.SNOW]=Tt,G[tt.ICE]=vt,G),Et=function(t,e,n){Y(a.BigInt(t),f.uint8),this.decimals=t,this.symbol=e,this.name=n},xt=Et.CURRENCY=((Ct={})[exports.ChainId.ICE_ARCTIC]=new Et(18,"ICZ","ICZ"),Ct[exports.ChainId.ICE_SNOW]=new Et(18,"ICZ","ICZ"),Ct[exports.ChainId.ICE_MAINNET]=new Et(18,"ICY","ICY"),Ct),At=function(t){function e(e,n,r,i,a){var o;return void 0===e&&(e=exports.ChainId.ICE_MAINNET),(o=t.call(this,r,i,a)||this).chainId=exports.ChainId.ICE_MAINNET,o.chainId=e,o.address=X(n),o}q(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}(Et);function kt(t,e){return t instanceof At&&e instanceof At?t.equals(e):!(t instanceof At||e instanceof At||t!==e)}var _t=((wt={})[exports.ChainId.ICE_ARCTIC]=new At(exports.ChainId.ICE_ARCTIC,h.ICE_ARCTIC.WICZ,18,"WICZ","Wrapped ICZ"),wt[exports.ChainId.ICE_SNOW]=new At(exports.ChainId.ICE_SNOW,h.ICE_SNOW.WICZ,18,"WICZ","Wrapped ICZ"),wt[exports.ChainId.ICE_MAINNET]=new At(exports.ChainId.ICE_MAINNET,h.ICE_MAINNET.WICZ,18,"WICY","Wrapped ICY"),wt),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 At&&t[0].involvesToken(e)||e===xt[t[0].chainId]&&t[0].involvesToken(_t[t[0].chainId])||o(!1),void 0===n||n instanceof At&&t[t.length-1].involvesToken(n)||n===xt[t[0].chainId]&&t[t.length-1].involvesToken(_t[t[0].chainId])||o(!1);for(var r,i=[e instanceof At?e:_t[t[0].chainId]],a=j(t.entries());!(r=a()).done;){var s=r.value,u=s[1],p=i[s[0]];p.equals(u.token0)||p.equals(u.token1)||o(!1);var c=p.equals(u.token0)?u.token1:u.token0;i.push(c)}this.pairs=t,this.path=i,this.midPrice=ct.fromRoute(this),this.input=e,this.output=null!=n?n:i[i.length-1]}return R(t,[{key:"chainId",get:function(){return this.pairs[0].chainId}}]),t}(),Nt=new ot(k),Ot=function(t){function e(){return t.apply(this,arguments)||this}q(e,t);var n=e.prototype;return n.toSignificant=function(t,e,n){return void 0===t&&(t=5),this.multiply(Nt).toSignificant(t,e,n)},n.toFixed=function(t,e,n){return void 0===t&&(t=2),this.multiply(Nt).toFixed(t,e,n)},e}(ot);function Rt(t,e){return kt(t.inputAmount.currency,e.inputAmount.currency)||o(!1),kt(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 Mt(t,e){var n=Rt(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 qt(t,e){return void 0===e&&(e=exports.ChainId.ICE_MAINNET),t instanceof pt?t:t.currency===xt[e]?new pt(_t[e],t.raw):void o(!1)}function Ut(t,e){return void 0===e&&(e=exports.ChainId.ICE_MAINNET),t instanceof At?t:t===xt[e]?_t[e]:void o(!1)}var Pt=function(){function t(t,e,n,r){void 0===r&&(r=exports.ChainId.ICE_MAINNET),this.chainId=exports.ChainId.ICE_MAINNET;var i,a,s,u=new Array(t.path.length),p=new Array(t.pairs.length);if(n===exports.TradeType.EXACT_INPUT){kt(e.currency,t.input)||o(!1),u[0]=qt(e,t.chainId);for(var c=0;c<t.path.length-1;c++){var d=t.pairs[c].getOutputAmount(u[c],r),l=d[1];u[c+1]=d[0],p[c]=l}}else{kt(e.currency,t.output)||o(!1),u[u.length-1]=qt(e,t.chainId);for(var y=t.path.length-1;y>0;y--){var m=t.pairs[y-1].getInputAmount(u[y],r),f=m[1];u[y-1]=m[0],p[y-1]=f}}this.route=t,this.tradeType=n,this.inputAmount=n===exports.TradeType.EXACT_INPUT?e:t.input===xt[r]?ut.ether(u[0].raw,r):u[0],this.outputAmount=n===exports.TradeType.EXACT_OUTPUT?e:t.output===xt[r]?ut.ether(u[u.length-1].raw,r):u[u.length-1],this.executionPrice=new ct(this.inputAmount.currency,this.outputAmount.currency,this.inputAmount.raw,this.outputAmount.raw),this.nextMidPrice=ct.fromRoute(new gt(p,t.input)),this.priceImpact=(i=this.outputAmount,s=(a=t.midPrice.raw.multiply(this.inputAmount.raw)).subtract(i.raw).divide(a),new Ot(s.numerator,s.denominator)),this.chainId=r}t.exactIn=function(e,n,r){return void 0===r&&(r=exports.ChainId.ICE_MAINNET),new t(e,n,exports.TradeType.EXACT_INPUT,r)},t.exactOut=function(e,n,r){return void 0===r&&(r=exports.ChainId.ICE_MAINNET),new t(e,n,exports.TradeType.EXACT_OUTPUT,r)};var e=t.prototype;return e.minimumAmountOut=function(t,e){if(void 0===e&&(e=exports.ChainId.ICE_MAINNET),t.lessThan(C)&&o(!1),this.tradeType===exports.TradeType.EXACT_OUTPUT)return this.outputAmount;var n=new ot(w).add(t).invert().multiply(this.outputAmount.raw).quotient;return this.outputAmount instanceof pt?new pt(this.outputAmount.token,n):ut.ether(n,e)},e.maximumAmountIn=function(t,e){if(void 0===e&&(e=exports.ChainId.ICE_MAINNET),t.lessThan(C)&&o(!1),this.tradeType===exports.TradeType.EXACT_INPUT)return this.inputAmount;var n=new ot(w).add(t).multiply(this.inputAmount.raw).quotient;return this.inputAmount instanceof pt?new pt(this.inputAmount.token,n):ut.ether(n,e)},t.bestTradeExactIn=function(e,n,r,i,a,s,u){var p=void 0===i?{}:i,c=p.maxNumResults,d=void 0===c?3:c,l=p.maxHops,y=void 0===l?3:l;void 0===a&&(a=[]),void 0===s&&(s=n),void 0===u&&(u=[]),e.length>0||o(!1),y>0||o(!1),s===n||a.length>0||o(!1);var m=n instanceof pt?n.token.chainId:r instanceof At?r.chainId:void 0;void 0===m&&o(!1);for(var f=qt(n,m),h=Ut(r,m),v=0;v<e.length;v++){var T=e[v];if((T.token0.equals(f.token)||T.token1.equals(f.token))&&!T.reserve0.equalTo(C)&&!T.reserve1.equalTo(C)){var I=void 0;try{I=T.getOutputAmount(f,m)[0]}catch(t){if(t.isInsufficientInputAmountError)continue;throw t}if(I.token.equals(h))Q(u,new t(new gt([].concat(a,[T]),s.currency,r),s,exports.TradeType.EXACT_INPUT,m),d,Mt);else if(y>1&&e.length>1){var w=e.slice(0,v).concat(e.slice(v+1,e.length));t.bestTradeExactIn(w,I,r,{maxNumResults:d,maxHops:y-1},[].concat(a,[T]),s,u)}}}return u},t.bestTradeExactOut=function(e,n,r,i,a,s,u){var p=void 0===i?{}:i,c=p.maxNumResults,d=void 0===c?3:c,l=p.maxHops,y=void 0===l?3:l;void 0===a&&(a=[]),void 0===s&&(s=r),void 0===u&&(u=[]),e.length>0||o(!1),y>0||o(!1),s===r||a.length>0||o(!1);var m=r instanceof pt?r.token.chainId:n instanceof At?n.chainId:void 0;void 0===m&&o(!1);for(var f=qt(r,m),h=Ut(n,m),v=0;v<e.length;v++){var T=e[v];if((T.token0.equals(f.token)||T.token1.equals(f.token))&&!T.reserve0.equalTo(C)&&!T.reserve1.equalTo(C)){var I=void 0;try{I=T.getInputAmount(f,m)[0]}catch(t){if(t.isInsufficientReservesError)continue;throw t}if(I.token.equals(h))Q(u,new t(new gt([T].concat(a),n,s.currency),s,exports.TradeType.EXACT_OUTPUT,m),d,Mt);else if(y>1&&e.length>1){var w=e.slice(0,v).concat(e.slice(v+1,e.length));t.bestTradeExactOut(w,n,I,{maxNumResults:d,maxHops:y-1},[T].concat(a),s,u)}}}return u},t}();exports.JSBI=a,exports.CHAINS=bt,exports.CICZ=xt,exports.Currency=Et,exports.CurrencyAmount=ut,exports.ETHEREUM_MAINNET={id:"ethereum_mainnet",chain_id:1,name:"Ethereum",symbol:"ETH",mainnet:!0,logo:"https://raw.githubusercontent.com/everestswap/sdk/master/src/images/chains/eth.png",dex_is_live:!1,tracked_by_debank:!0,supported_by_gelato:!0,rpc_uri:"https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",coingecko_id:"ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockExplorerUrls:["https://etherscan.io"]},exports.FACTORY_ADDRESS=v,exports.Fetcher=ht,exports.Fraction=ot,exports.ICE_ARCTIC=It,exports.ICE_MAINNET=vt,exports.ICE_SNOW=Tt,exports.INIT_CODE_HASH=T,exports.InsufficientInputAmountError=H,exports.InsufficientReservesError=L,exports.MINIMUM_LIQUIDITY=I,exports.Pair=lt,exports.Percent=Ot,exports.Price=ct,exports.Route=gt,exports.Router=et,exports.Token=At,exports.TokenAmount=pt,exports.Trade=Pt,exports.WICZ=_t,exports.contractAddresses=h,exports.currencyEquals=kt,exports.inputOutputComparator=Rt,exports.tradeComparator=Mt; //# sourceMappingURL=sdk.cjs.production.min.js.map