Socket
Socket
Sign inDemoInstall

@pooltogether/utilities

Package Overview
Dependencies
49
Maintainers
6
Versions
77
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.10 to 0.3.11

2

dist/data/networks.d.ts

@@ -19,2 +19,3 @@ /**

optimism: number;
'optimism-kovan': number;
avalanche: number;

@@ -33,1 +34,2 @@ fuji: number;

export declare const CELO_NETWORKS: readonly number[];
export declare const OPTIMISM_NETWORKS: readonly number[];

5

dist/utilities.cjs.development.js

@@ -490,3 +490,4 @@ 'use strict';

'matic': 137,
'optimism': 420,
'optimism': 10,
'optimism-kovan': 69,
'avalanche': 43114,

@@ -506,2 +507,3 @@ 'fuji': 43113,

var CELO_NETWORKS = /*#__PURE__*/Object.freeze([NETWORK.celo, NETWORK['celo-testnet']]);
var OPTIMISM_NETWORKS = /*#__PURE__*/Object.freeze([NETWORK.optimism, NETWORK['optimism-kovan']]);

@@ -1032,2 +1034,3 @@ /**

exports.NETWORK = NETWORK;
exports.OPTIMISM_NETWORKS = OPTIMISM_NETWORKS;
exports.POLYGON_NETWORKS = POLYGON_NETWORKS;

@@ -1034,0 +1037,0 @@ exports.addBigNumbers = addBigNumbers;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("ethers"),r=require("ethers/lib/utils"),t=require("@ethersproject/units"),n=require("@ethersproject/providers"),o=require("@ethersproject/networks"),i=require("@pooltogether/evm-chains-extended"),s=/^(\w{6})\w*(\w{4})$/;function a(e,r){void 0===r&&(r={precision:2});var t=r.precision;if(e&&"function"==typeof e.indexOf){var n=t?t+1:0;return e.substr(0,e.indexOf(".")+n)}return e}var u=function(e){return t.parseUnits(a(e,{precision:2}),2)},c=function(r,t){if(void 0===t&&(t={}),t.decimals||(t.decimals=18),null!=r){var n=r._isBigNumber?e.ethers.utils.formatUnits(r,t.decimals):r;return!t.precision&&0!==t.precision&&n&&(t.precision=l(n)),function(e,r){if(void 0===r&&(r={}),!e)return"number"==typeof e?e:"";var t=2;void 0!==r.precision&&(t=r.precision);var n="en-GB";r.currentLang&&"es"===r.currentLang&&(n="es-ES"),0===t&&(e=Math.floor(Number(e))),e.toString().match("e")&&(e=Number.parseFloat(e).toFixed(0));var o=e.toString().split(".");o[0]=o[0].replace(",","");var i="";return i=o.length>1&&t>0?a(o.join("."),{precision:t}):o[0],r.removeTrailingZeros&&(i=i.replace(/(\.0+|0+)$/,"")),Number(i).toLocaleString(n,{minimumFractionDigits:r.removeTrailingZeros?0:t})}(n,t)}},l=function(e){return(e=parseFloat(e))>1e4?0:e>=.1?2:d(e)},d=function(e,r){void 0===r&&(r={additionalDigits:2});var t=r.additionalDigits,n=String(e).split(".")[1];return"0"===n?0:n?n.match(/^0*/)[0].length+t:t},p=function(e,r){return e.mul(Math.round(100*r)).div(100)},m=function(r){return r.reduce((function(e,r){return r.add(e)}),e.ethers.constants.Zero)},f=Object.freeze({mainnet:1,homestead:1,ropsten:3,rinkeby:4,goerli:5,kovan:42,bsc:56,"poa-sokol":77,"bsc-testnet":97,poa:99,xdai:100,polygon:137,matic:137,optimism:420,avalanche:43114,fuji:43113,celo:42220,"celo-testnet":44787,mumbai:80001}),h=Object.freeze([f.mainnet,f.ropsten,f.rinkeby,f.goerli,f.kovan]),v=Object.freeze([f.polygon,f.mumbai]),x=Object.freeze([f.avalanche,f.fuji]),g=Object.freeze([f.celo,f["celo-testnet"]]),b=function(e){var r=Object.keys(f).find((function(r){return f[r]===e}));if(void 0!==r)return r},N=Object.freeze([1,3,4,5,42,137,80001,10,69,42161,421611]),y=Object.freeze([1,3,4,5,42]),U=Object.freeze([1,3,4,5,42,137,80001,10,69,42161,421611]),T={alchemy:void 0,etherscan:void 0,infura:void 0},P=function(e){var r,t=i.getChain(e);try{T.alchemy&&N.includes(e)?r=new n.AlchemyProvider(e,T.alchemy):T.infura&&U.includes(e)?r=new n.InfuraProvider(e,T.infura):T.etherscan&&y.includes(e)?r=new n.EtherscanProvider(e,T.etherscan):t&&t.rpc[0]?r=new n.JsonRpcProvider(t.rpc[0],e):console.warn("Chain id "+e+" not supported.")}catch(e){console.error(e)}return r},S=function(e,r){var t=T.alchemy||(null==r?void 0:r.alchemy),s=T.infura||(null==r?void 0:r.infura);try{var a;if(t&&N.includes(e))return n.AlchemyProvider.getUrl(o.getNetwork(e),t).url;if(s&&U.includes(e))return n.InfuraProvider.getUrl(o.getNetwork(e),"string"==typeof s?{projectId:s}:s).url;var u=i.getChain(e);return(null==u||null==(a=u.rpc)?void 0:a[0])||(console.warn("getRpcUrl | Chain id "+e+" not supported."),i.getChain(f.mainnet).rpc[0])}catch(e){return console.error(e),i.getChain(f.mainnet).rpc[0]}},w=function(){return Number((Date.now()/1e3).toFixed(0))},O=Object.freeze({}),M=Object.freeze({});exports.AVALANCHE_NETWORKS=x,exports.CELO_NETWORKS=g,exports.ETHEREUM_NETWORKS=h,exports.NETWORK=f,exports.POLYGON_NETWORKS=v,exports.addBigNumbers=m,exports.addTokenTotalUsdValue=function(e,t){var n=t[e.address];if(n){if(e.usd=n.usd||0,e.derivedETH=n.derivedETH||"0",e.amountUnformatted){var o=p(e.amountUnformatted,e.usd);e.totalValueUsd=r.formatUnits(o,e.decimals),e.totalValueUsdScaled=u(e.totalValueUsd)}}else e.usd=0,e.derivedETH="0"},exports.amountMultByUsd=p,exports.calculateAPR=function(e,r){return r.isZero()||e.isZero()?"0":t.formatUnits(e.mul(1e4).mul(365).div(r),2)},exports.calculateCreamBorrowApy=function(e,r,n,o,i,s,a){var u=Number(t.formatUnits(e,18)),c=Number(t.formatUnits(r,18)),l=Number(t.formatUnits(n,18)),d=Number(t.formatUnits(o,18)),p=Number(t.formatUnits(i,18)),m=Number(t.formatUnits(s,18)),f=a.toNumber();return Math.pow(1+u+c*Math.min(l,d)+Math.max(m*l-p,0),f)-1},exports.calculateCreamSupplyApy=function(e,r,n,o){var i=Number(t.formatUnits(r,18)),s=Number(t.formatUnits(n,18)),a=o.toNumber();return Math.pow(1+(Math.pow(1+e,1/a)-1)*(1-i)*s,a)-1},exports.calculateEstimatedCompoundPrizeWithYieldUnformatted=function(r,t,n,o,i,s){var a=s&&0!==parseFloat(s)?e.ethers.utils.parseUnits(parseFloat(s).toFixed(Number(o)),o):e.ethers.constants.Zero;return(a.isZero()?e.ethers.constants.Zero:t.mul(n).mul(Math.round(parseFloat(i))).mul(a).div(e.ethers.utils.parseUnits("1",18)).div(e.ethers.utils.parseUnits("1",o))).add(r)},exports.calculateLPTokenPrice=function(e,r,n,o,i){var s=m([p(t.parseUnits(e,18),n),p(t.parseUnits(r,18),o)]),a=t.parseUnits(i,18);return s.div(a)},exports.calculateOdds=function(r,t,n,o){if(void 0===o&&(o=1),!r||r.isZero()||!t||t.isZero()||!n||0===o)return 0;var i=Number(e.ethers.utils.formatUnits(r,n)),s=Number(e.ethers.utils.formatUnits(t,n));return 1-Math.pow((s-i)/s,o)},exports.calculateUsersOdds=function(r,t,n,o){if(!r||r.eq(e.ethers.BigNumber.from(0))||!n)return 0;var i=parseInt(o,10),s=Number(e.ethers.utils.formatUnits(r,Number(n))),a=Number(e.ethers.utils.formatUnits(t,Number(n)));return 1/(1-Math.pow((a-s)/a,i))},exports.calculatedEstimatedAccruedCompTotalValueUsdScaled=function(r,t,n){return r?t.mul(Math.round(100*parseFloat(r))).div(1e4).mul(100).div(31536e3).mul(n).div(100):e.ethers.constants.Zero},exports.chainIdToNetworkName=function(e){return 137===e?"polygon":b(e)},exports.dToM=function(e){return e?1440*e:0},exports.dToMs=function(e){return e?86400*e*1e3:0},exports.dToS=function(e){return e?86400*e:0},exports.deserializeBigNumbers=function r(t){try{return Array.isArray(t)?t.forEach(r):"object"==typeof t&&null!==t&&Object.keys(t).forEach((function(n){if(Array.isArray(t[n]))t[n].forEach(r);else if("object"==typeof t[n]&&null!==t[n]){var o;"BigNumber"===(null==(o=t[n])?void 0:o.type)?t[n]=e.ethers.BigNumber.from(t[n]):r(t[n])}})),t}catch(e){return t}},exports.displayPercentage=function(e){return(e=parseFloat(e).toFixed(2)).toString().replace(/(\.0+$)|(0+$)/,"")},exports.getChainIdByAlias=function(e){return null==f?void 0:f[e]},exports.getLootBoxKey=function(e,r){return"lootBox-"+e+"-"+r},exports.getMaxPrecision=function(e){var r;return(null==(r=String(e).split(".")[1])?void 0:r.length)||0},exports.getMinPrecision=d,exports.getNetworkNameAliasByChainId=b,exports.getNetworkNiceNameByChainId=function(e){switch(Number(e)){case f.mainnet:return"Ethereum";case f.matic:return"Polygon";case f.bsc:return"Binance Smart Chain";case f.celo:return"Celo";case f.xdai:return"xDai";default:var r=b(e);return r?r.charAt(0).toUpperCase()+r.slice(1):"--"}},exports.getPrecision=l,exports.getPrizePoolSymbol=function(e,r){return e.toUpperCase()+"-"+r.slice(0,8)},exports.getReadProvider=P,exports.getReadProviders=function(e){var r={};return e.forEach((function(e){var t=P(e);t&&(r[e]=t)})),r},exports.getRpcUrl=S,exports.getRpcUrls=function(e,r){return e.reduce((function(e,t){return e[t]=S(t,r),e}),{})},exports.getSecondsRemainingInPrizePeriod=function(e,r){var t=e.toNumber(),n=r.toNumber();return t-(w()-n)},exports.getSecondsSinceEpoch=w,exports.getTimeBreakdown=function(e){var r=Number(e),t=0;r>=31536e3&&(r-=31536e3*(t=Math.floor(r/31536e3)));var n=0;r>=86400&&(r-=86400*(n=Math.floor(r/86400)));var o=0;(n||r>=3600)&&(r-=3600*(o=Math.floor(r/3600)));var i=0;(o||r>=60)&&(r-=60*(i=Math.floor(r/60)));var s=0;return(i||r>=1)&&(s=r),{years:t,days:n,hours:o,minutes:i,seconds:s}},exports.getTokenColour=function(e,r){return void 0===r&&(r=!1),r?M[e]:O[e]},exports.initProviderApiKeys=function(e){T.alchemy=e.alchemy,T.etherscan=e.etherscan,T.infura=e.infura},exports.msToD=function(e){return e?e/1e3/86400:0},exports.msToS=function(e){return e?e/1e3:0},exports.msToSeconds=function(r){return r?e.ethers.BigNumber.from(r).div(1e3).toNumber():0},exports.numberWithCommas=c,exports.prettyNumber=function(e,r){return c(e,{decimals:r})},exports.sToD=function(e){return e?e/86400:0},exports.sToM=function(e){return e?e/60:0},exports.sToMs=function(e){return e?1e3*e:0},exports.safeParseUnits=function(e,r){try{return t.parseUnits(e,r)}catch(t){return void console.warn("could not run parseUnits on values:",e,r)}},exports.sharesAmountToUnderlyingAmount=function(e,r,t){if(!r.isZero())return e.mul(t).div(r)},exports.shorten=function(e){var r;return e.hash&&(r=s.exec(e.hash))?e.short?r[1]+"...":r[1]+"..."+r[2]:null},exports.stringWithPrecision=a,exports.subtractDates=function(e,r){var t=e.getTime()-r.getTime(),n=0;t>=864e5&&(t-=864e5*(n=t/864e5));var o=0;(n||t>=36e5)&&(t-=36e5*(o=t/36e5));var i=0;(o||t>=6e4)&&(t-=6e4*(i=t/6e4));var s=0;return(i||t>=1e3)&&(s=t/1e3),{days:n,hours:o,minutes:i,seconds:s}},exports.toNonScaledUsdString=function(e){return t.formatUnits(e,2)},exports.toScaledUsdBigNumber=u,exports.underlyingAmountToSharesAmount=function(e,r,t){if(!t.isZero())return e.mul(r).div(t)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("ethers"),r=require("ethers/lib/utils"),t=require("@ethersproject/units"),n=require("@ethersproject/providers"),o=require("@ethersproject/networks"),i=require("@pooltogether/evm-chains-extended"),s=/^(\w{6})\w*(\w{4})$/;function a(e,r){void 0===r&&(r={precision:2});var t=r.precision;if(e&&"function"==typeof e.indexOf){var n=t?t+1:0;return e.substr(0,e.indexOf(".")+n)}return e}var u=function(e){return t.parseUnits(a(e,{precision:2}),2)},c=function(r,t){if(void 0===t&&(t={}),t.decimals||(t.decimals=18),null!=r){var n=r._isBigNumber?e.ethers.utils.formatUnits(r,t.decimals):r;return!t.precision&&0!==t.precision&&n&&(t.precision=l(n)),function(e,r){if(void 0===r&&(r={}),!e)return"number"==typeof e?e:"";var t=2;void 0!==r.precision&&(t=r.precision);var n="en-GB";r.currentLang&&"es"===r.currentLang&&(n="es-ES"),0===t&&(e=Math.floor(Number(e))),e.toString().match("e")&&(e=Number.parseFloat(e).toFixed(0));var o=e.toString().split(".");o[0]=o[0].replace(",","");var i="";return i=o.length>1&&t>0?a(o.join("."),{precision:t}):o[0],r.removeTrailingZeros&&(i=i.replace(/(\.0+|0+)$/,"")),Number(i).toLocaleString(n,{minimumFractionDigits:r.removeTrailingZeros?0:t})}(n,t)}},l=function(e){return(e=parseFloat(e))>1e4?0:e>=.1?2:d(e)},d=function(e,r){void 0===r&&(r={additionalDigits:2});var t=r.additionalDigits,n=String(e).split(".")[1];return"0"===n?0:n?n.match(/^0*/)[0].length+t:t},p=function(e,r){return e.mul(Math.round(100*r)).div(100)},m=function(r){return r.reduce((function(e,r){return r.add(e)}),e.ethers.constants.Zero)},f=Object.freeze({mainnet:1,homestead:1,ropsten:3,rinkeby:4,goerli:5,kovan:42,bsc:56,"poa-sokol":77,"bsc-testnet":97,poa:99,xdai:100,polygon:137,matic:137,optimism:10,"optimism-kovan":69,avalanche:43114,fuji:43113,celo:42220,"celo-testnet":44787,mumbai:80001}),h=Object.freeze([f.mainnet,f.ropsten,f.rinkeby,f.goerli,f.kovan]),v=Object.freeze([f.polygon,f.mumbai]),x=Object.freeze([f.avalanche,f.fuji]),g=Object.freeze([f.celo,f["celo-testnet"]]),b=Object.freeze([f.optimism,f["optimism-kovan"]]),N=function(e){var r=Object.keys(f).find((function(r){return f[r]===e}));if(void 0!==r)return r},y=Object.freeze([1,3,4,5,42,137,80001,10,69,42161,421611]),U=Object.freeze([1,3,4,5,42]),T=Object.freeze([1,3,4,5,42,137,80001,10,69,42161,421611]),O={alchemy:void 0,etherscan:void 0,infura:void 0},S=function(e){var r,t=i.getChain(e);try{O.alchemy&&y.includes(e)?r=new n.AlchemyProvider(e,O.alchemy):O.infura&&T.includes(e)?r=new n.InfuraProvider(e,O.infura):O.etherscan&&U.includes(e)?r=new n.EtherscanProvider(e,O.etherscan):t&&t.rpc[0]?r=new n.JsonRpcProvider(t.rpc[0],e):console.warn("Chain id "+e+" not supported.")}catch(e){console.error(e)}return r},P=function(e,r){var t=O.alchemy||(null==r?void 0:r.alchemy),s=O.infura||(null==r?void 0:r.infura);try{var a;if(t&&y.includes(e))return n.AlchemyProvider.getUrl(o.getNetwork(e),t).url;if(s&&T.includes(e))return n.InfuraProvider.getUrl(o.getNetwork(e),"string"==typeof s?{projectId:s}:s).url;var u=i.getChain(e);return(null==u||null==(a=u.rpc)?void 0:a[0])||(console.warn("getRpcUrl | Chain id "+e+" not supported."),i.getChain(f.mainnet).rpc[0])}catch(e){return console.error(e),i.getChain(f.mainnet).rpc[0]}},M=function(){return Number((Date.now()/1e3).toFixed(0))},w=Object.freeze({}),E=Object.freeze({});exports.AVALANCHE_NETWORKS=x,exports.CELO_NETWORKS=g,exports.ETHEREUM_NETWORKS=h,exports.NETWORK=f,exports.OPTIMISM_NETWORKS=b,exports.POLYGON_NETWORKS=v,exports.addBigNumbers=m,exports.addTokenTotalUsdValue=function(e,t){var n=t[e.address];if(n){if(e.usd=n.usd||0,e.derivedETH=n.derivedETH||"0",e.amountUnformatted){var o=p(e.amountUnformatted,e.usd);e.totalValueUsd=r.formatUnits(o,e.decimals),e.totalValueUsdScaled=u(e.totalValueUsd)}}else e.usd=0,e.derivedETH="0"},exports.amountMultByUsd=p,exports.calculateAPR=function(e,r){return r.isZero()||e.isZero()?"0":t.formatUnits(e.mul(1e4).mul(365).div(r),2)},exports.calculateCreamBorrowApy=function(e,r,n,o,i,s,a){var u=Number(t.formatUnits(e,18)),c=Number(t.formatUnits(r,18)),l=Number(t.formatUnits(n,18)),d=Number(t.formatUnits(o,18)),p=Number(t.formatUnits(i,18)),m=Number(t.formatUnits(s,18)),f=a.toNumber();return Math.pow(1+u+c*Math.min(l,d)+Math.max(m*l-p,0),f)-1},exports.calculateCreamSupplyApy=function(e,r,n,o){var i=Number(t.formatUnits(r,18)),s=Number(t.formatUnits(n,18)),a=o.toNumber();return Math.pow(1+(Math.pow(1+e,1/a)-1)*(1-i)*s,a)-1},exports.calculateEstimatedCompoundPrizeWithYieldUnformatted=function(r,t,n,o,i,s){var a=s&&0!==parseFloat(s)?e.ethers.utils.parseUnits(parseFloat(s).toFixed(Number(o)),o):e.ethers.constants.Zero;return(a.isZero()?e.ethers.constants.Zero:t.mul(n).mul(Math.round(parseFloat(i))).mul(a).div(e.ethers.utils.parseUnits("1",18)).div(e.ethers.utils.parseUnits("1",o))).add(r)},exports.calculateLPTokenPrice=function(e,r,n,o,i){var s=m([p(t.parseUnits(e,18),n),p(t.parseUnits(r,18),o)]),a=t.parseUnits(i,18);return s.div(a)},exports.calculateOdds=function(r,t,n,o){if(void 0===o&&(o=1),!r||r.isZero()||!t||t.isZero()||!n||0===o)return 0;var i=Number(e.ethers.utils.formatUnits(r,n)),s=Number(e.ethers.utils.formatUnits(t,n));return 1-Math.pow((s-i)/s,o)},exports.calculateUsersOdds=function(r,t,n,o){if(!r||r.eq(e.ethers.BigNumber.from(0))||!n)return 0;var i=parseInt(o,10),s=Number(e.ethers.utils.formatUnits(r,Number(n))),a=Number(e.ethers.utils.formatUnits(t,Number(n)));return 1/(1-Math.pow((a-s)/a,i))},exports.calculatedEstimatedAccruedCompTotalValueUsdScaled=function(r,t,n){return r?t.mul(Math.round(100*parseFloat(r))).div(1e4).mul(100).div(31536e3).mul(n).div(100):e.ethers.constants.Zero},exports.chainIdToNetworkName=function(e){return 137===e?"polygon":N(e)},exports.dToM=function(e){return e?1440*e:0},exports.dToMs=function(e){return e?86400*e*1e3:0},exports.dToS=function(e){return e?86400*e:0},exports.deserializeBigNumbers=function r(t){try{return Array.isArray(t)?t.forEach(r):"object"==typeof t&&null!==t&&Object.keys(t).forEach((function(n){if(Array.isArray(t[n]))t[n].forEach(r);else if("object"==typeof t[n]&&null!==t[n]){var o;"BigNumber"===(null==(o=t[n])?void 0:o.type)?t[n]=e.ethers.BigNumber.from(t[n]):r(t[n])}})),t}catch(e){return t}},exports.displayPercentage=function(e){return(e=parseFloat(e).toFixed(2)).toString().replace(/(\.0+$)|(0+$)/,"")},exports.getChainIdByAlias=function(e){return null==f?void 0:f[e]},exports.getLootBoxKey=function(e,r){return"lootBox-"+e+"-"+r},exports.getMaxPrecision=function(e){var r;return(null==(r=String(e).split(".")[1])?void 0:r.length)||0},exports.getMinPrecision=d,exports.getNetworkNameAliasByChainId=N,exports.getNetworkNiceNameByChainId=function(e){switch(Number(e)){case f.mainnet:return"Ethereum";case f.matic:return"Polygon";case f.bsc:return"Binance Smart Chain";case f.celo:return"Celo";case f.xdai:return"xDai";default:var r=N(e);return r?r.charAt(0).toUpperCase()+r.slice(1):"--"}},exports.getPrecision=l,exports.getPrizePoolSymbol=function(e,r){return e.toUpperCase()+"-"+r.slice(0,8)},exports.getReadProvider=S,exports.getReadProviders=function(e){var r={};return e.forEach((function(e){var t=S(e);t&&(r[e]=t)})),r},exports.getRpcUrl=P,exports.getRpcUrls=function(e,r){return e.reduce((function(e,t){return e[t]=P(t,r),e}),{})},exports.getSecondsRemainingInPrizePeriod=function(e,r){var t=e.toNumber(),n=r.toNumber();return t-(M()-n)},exports.getSecondsSinceEpoch=M,exports.getTimeBreakdown=function(e){var r=Number(e),t=0;r>=31536e3&&(r-=31536e3*(t=Math.floor(r/31536e3)));var n=0;r>=86400&&(r-=86400*(n=Math.floor(r/86400)));var o=0;(n||r>=3600)&&(r-=3600*(o=Math.floor(r/3600)));var i=0;(o||r>=60)&&(r-=60*(i=Math.floor(r/60)));var s=0;return(i||r>=1)&&(s=r),{years:t,days:n,hours:o,minutes:i,seconds:s}},exports.getTokenColour=function(e,r){return void 0===r&&(r=!1),r?E[e]:w[e]},exports.initProviderApiKeys=function(e){O.alchemy=e.alchemy,O.etherscan=e.etherscan,O.infura=e.infura},exports.msToD=function(e){return e?e/1e3/86400:0},exports.msToS=function(e){return e?e/1e3:0},exports.msToSeconds=function(r){return r?e.ethers.BigNumber.from(r).div(1e3).toNumber():0},exports.numberWithCommas=c,exports.prettyNumber=function(e,r){return c(e,{decimals:r})},exports.sToD=function(e){return e?e/86400:0},exports.sToM=function(e){return e?e/60:0},exports.sToMs=function(e){return e?1e3*e:0},exports.safeParseUnits=function(e,r){try{return t.parseUnits(e,r)}catch(t){return void console.warn("could not run parseUnits on values:",e,r)}},exports.sharesAmountToUnderlyingAmount=function(e,r,t){if(!r.isZero())return e.mul(t).div(r)},exports.shorten=function(e){var r;return e.hash&&(r=s.exec(e.hash))?e.short?r[1]+"...":r[1]+"..."+r[2]:null},exports.stringWithPrecision=a,exports.subtractDates=function(e,r){var t=e.getTime()-r.getTime(),n=0;t>=864e5&&(t-=864e5*(n=t/864e5));var o=0;(n||t>=36e5)&&(t-=36e5*(o=t/36e5));var i=0;(o||t>=6e4)&&(t-=6e4*(i=t/6e4));var s=0;return(i||t>=1e3)&&(s=t/1e3),{days:n,hours:o,minutes:i,seconds:s}},exports.toNonScaledUsdString=function(e){return t.formatUnits(e,2)},exports.toScaledUsdBigNumber=u,exports.underlyingAmountToSharesAmount=function(e,r,t){if(!t.isZero())return e.mul(r).div(t)};
//# sourceMappingURL=utilities.cjs.production.min.js.map

@@ -486,3 +486,4 @@ import { ethers } from 'ethers';

'matic': 137,
'optimism': 420,
'optimism': 10,
'optimism-kovan': 69,
'avalanche': 43114,

@@ -502,2 +503,3 @@ 'fuji': 43113,

var CELO_NETWORKS = /*#__PURE__*/Object.freeze([NETWORK.celo, NETWORK['celo-testnet']]);
var OPTIMISM_NETWORKS = /*#__PURE__*/Object.freeze([NETWORK.optimism, NETWORK['optimism-kovan']]);

@@ -1024,3 +1026,3 @@ /**

export { AVALANCHE_NETWORKS, CELO_NETWORKS, ETHEREUM_NETWORKS, NETWORK, POLYGON_NETWORKS, addBigNumbers, addTokenTotalUsdValue, amountMultByUsd, calculateAPR, calculateCreamBorrowApy, calculateCreamSupplyApy, calculateEstimatedCompoundPrizeWithYieldUnformatted, calculateLPTokenPrice, calculateOdds, calculateUsersOdds, calculatedEstimatedAccruedCompTotalValueUsdScaled, chainIdToNetworkName, dToM, dToMs, dToS, deserializeBigNumbers, displayPercentage, getChainIdByAlias, getLootBoxKey, getMaxPrecision, getMinPrecision, getNetworkNameAliasByChainId, getNetworkNiceNameByChainId, getPrecision, getPrizePoolSymbol, getReadProvider, getReadProviders, getRpcUrl, getRpcUrls, getSecondsRemainingInPrizePeriod, getSecondsSinceEpoch, getTimeBreakdown, getTokenColour, initProviderApiKeys, msToD, msToS, msToSeconds, numberWithCommas, prettyNumber, sToD, sToM, sToMs, safeParseUnits, sharesAmountToUnderlyingAmount, shorten, stringWithPrecision, subtractDates, toNonScaledUsdString, toScaledUsdBigNumber, underlyingAmountToSharesAmount };
export { AVALANCHE_NETWORKS, CELO_NETWORKS, ETHEREUM_NETWORKS, NETWORK, OPTIMISM_NETWORKS, POLYGON_NETWORKS, addBigNumbers, addTokenTotalUsdValue, amountMultByUsd, calculateAPR, calculateCreamBorrowApy, calculateCreamSupplyApy, calculateEstimatedCompoundPrizeWithYieldUnformatted, calculateLPTokenPrice, calculateOdds, calculateUsersOdds, calculatedEstimatedAccruedCompTotalValueUsdScaled, chainIdToNetworkName, dToM, dToMs, dToS, deserializeBigNumbers, displayPercentage, getChainIdByAlias, getLootBoxKey, getMaxPrecision, getMinPrecision, getNetworkNameAliasByChainId, getNetworkNiceNameByChainId, getPrecision, getPrizePoolSymbol, getReadProvider, getReadProviders, getRpcUrl, getRpcUrls, getSecondsRemainingInPrizePeriod, getSecondsSinceEpoch, getTimeBreakdown, getTokenColour, initProviderApiKeys, msToD, msToS, msToSeconds, numberWithCommas, prettyNumber, sToD, sToM, sToMs, safeParseUnits, sharesAmountToUnderlyingAmount, shorten, stringWithPrecision, subtractDates, toNonScaledUsdString, toScaledUsdBigNumber, underlyingAmountToSharesAmount };
//# sourceMappingURL=utilities.esm.js.map
{
"name": "@pooltogether/utilities",
"version": "0.3.10",
"version": "0.3.11",
"description": "Shared utility functions across PoolTogether apps",

@@ -11,3 +11,5 @@ "main": "dist/index.js",

"module": "dist/utilities.esm.js",
"files": ["dist"],
"files": [
"dist"
],
"engines": {

@@ -14,0 +16,0 @@ "node": ">=10"

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc