Socket
Socket
Sign inDemoInstall

@pooltogether/utilities

Package Overview
Dependencies
47
Maintainers
4
Versions
77
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0 to 0.6.1

3

dist/data/networks.d.ts

@@ -37,1 +37,4 @@ /**

export declare const ARBITRUM_NETWORKS: readonly number[];
export declare const PT_RPC_PROXY: Readonly<{
[x: number]: string;
}>;

@@ -512,2 +512,4 @@ 'use strict';

var _Object$freeze;
/**

@@ -550,2 +552,3 @@ * Constant for chain ids

var ARBITRUM_NETWORKS = /*#__PURE__*/Object.freeze([NETWORK.arbitrum, NETWORK['arbitrum-goerli']]);
var PT_RPC_PROXY = /*#__PURE__*/Object.freeze((_Object$freeze = {}, _Object$freeze[NETWORK.mainnet] = 'https://ethereum-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.goerli] = 'https://goerli-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.optimism] = 'https://optimism-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK['optimism-goerli']] = 'https://optimism-goerli-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.arbitrum] = 'https://arbitrum-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK['arbitrum-goerli']] = 'https://arbitrum-goerli-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.polygon] = 'https://polygon-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.mumbai] = 'https://polygon-mumbai-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.fuji] = 'https://avalanche-fuji-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.avalanche] = 'https://avalanche-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze));

@@ -965,2 +968,3 @@ /**

exports.POLYGON_NETWORKS = POLYGON_NETWORKS;
exports.PT_RPC_PROXY = PT_RPC_PROXY;
exports.addBigNumbers = addBigNumbers;

@@ -967,0 +971,0 @@ exports.addTokenTotalUsdValue = addTokenTotalUsdValue;

2

dist/utilities.cjs.production.min.js

@@ -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"),o=/^(\w{6})\w*(\w{4})$/;function n(e,r){void 0===r&&(r={precision:2});var t=r.precision;if(e&&"function"==typeof e.indexOf){var o=t?t+1:0;return e.substr(0,e.indexOf(".")+o)}return e}var i=function(e){return t.parseUnits(n(e,{precision:2}),2)},s=function(r,t){if(void 0===t&&(t={}),t.decimals||(t.decimals=18),null!=r){var o=r._isBigNumber?e.ethers.utils.formatUnits(r,t.decimals):r;return!t.precision&&0!==t.precision&&o&&(t.precision=u(o)),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 o="en-GB";r.currentLang&&"es"===r.currentLang&&(o="es-ES"),0===t&&(e=Math.floor(Number(e))),2===t&&(e=Math.round(100*(parseFloat(e)+Number.EPSILON))/100),e.toString().match("e")&&(e=Number.parseFloat(e).toFixed(0));var i=e.toString().split(".");i[0]=i[0].replace(",","");var s="";return s=i.length>1&&t>0?n(i.join("."),{precision:t}):i[0],r.removeTrailingZeros&&(s=s.replace(/(\.0+|0+)$/,"")),Number(s).toLocaleString(o,{minimumFractionDigits:r.removeTrailingZeros?0:t})}(o,t)}},u=function(e){return(e=parseFloat(e))>1e4?0:e>=.1?2:a(e)},a=function(e,r){void 0===r&&(r={additionalDigits:2});var t=r.additionalDigits,o=String(e).split(".")[1];return"0"===o?0:o?o.match(/^0*/)[0].length+t:t},c=function(e,r){return e.mul(Math.round(100*r)).div(100)},l=function(r){return r.reduce((function(e,r){return r.add(e)}),e.ethers.constants.Zero)},m=function(e,r,o){return void 0===o&&(o=4),e.isZero()||r.isZero()?0:Number(t.formatUnits(e.mul(Math.pow(10,o)).div(r),String(o)))},p=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,mumbai:80001,optimism:10,"optimism-goerli":420,avalanche:43114,fuji:43113,celo:42220,"celo-testnet":44787,arbitrum:42161,"arbitrum-goerli":421613}),d=Object.freeze([p.mainnet,p.goerli]),f=Object.freeze([p.polygon,p.mumbai]),h=Object.freeze([p.avalanche,p.fuji]),v=Object.freeze([p.celo,p["celo-testnet"]]),b=Object.freeze([p.optimism,p["optimism-goerli"]]),x=Object.freeze([p.arbitrum,p["arbitrum-goerli"]]),g=function(e){var r=Object.keys(p).find((function(r){return p[r]===e}));if(void 0!==r)return r},N=function(){return Number((Date.now()/1e3).toFixed(0))},U=Object.freeze({}),y=Object.freeze({});exports.ARBITRUM_NETWORKS=x,exports.AVALANCHE_NETWORKS=h,exports.CELO_NETWORKS=v,exports.ETHEREUM_NETWORKS=d,exports.NETWORK=p,exports.OPTIMISM_NETWORKS=b,exports.POLYGON_NETWORKS=f,exports.addBigNumbers=l,exports.addTokenTotalUsdValue=function(e,t){var o=t[e.address];if(o){if(e.usd=o.usd||0,e.derivedETH=o.derivedETH||"0",e.amountUnformatted){var n=c(e.amountUnformatted,e.usd);e.totalValueUsd=r.formatUnits(n,e.decimals),e.totalValueUsdScaled=i(e.totalValueUsd)}}else e.usd=0,e.derivedETH="0"},exports.amountMultByUsd=c,exports.calculateApr=function(e,r,t){if(void 0===t&&(t=4),e.isZero()||r.isZero())return 0;var o=r.mul(365);return 100*m(o,e,t)},exports.calculateCreamBorrowApy=function(e,r,o,n,i,s,u){var a=Number(t.formatUnits(e,18)),c=Number(t.formatUnits(r,18)),l=Number(t.formatUnits(o,18)),m=Number(t.formatUnits(n,18)),p=Number(t.formatUnits(i,18)),d=Number(t.formatUnits(s,18)),f=u.toNumber();return Math.pow(1+a+c*Math.min(l,m)+Math.max(d*l-p,0),f)-1},exports.calculateCreamSupplyApy=function(e,r,o,n){var i=Number(t.formatUnits(r,18)),s=Number(t.formatUnits(o,18)),u=n.toNumber();return Math.pow(1+(Math.pow(1+e,1/u)-1)*(1-i)*s,u)-1},exports.calculateEstimatedCompoundPrizeWithYieldUnformatted=function(r,t,o,n,i,s){var u=s&&0!==parseFloat(s)?e.ethers.utils.parseUnits(parseFloat(s).toFixed(Number(n)),n):e.ethers.constants.Zero;return(u.isZero()?e.ethers.constants.Zero:t.mul(o).mul(Math.round(parseFloat(i))).mul(u).div(e.ethers.utils.parseUnits("1",18)).div(e.ethers.utils.parseUnits("1",n))).add(r)},exports.calculateLPTokenPrice=function(e,r,o,n,i){var s=l([c(t.parseUnits(e,18),o),c(t.parseUnits(r,18),n)]),u=t.parseUnits(i,18);return s.div(u)},exports.calculateOdds=function(r,t,o,n){if(void 0===n&&(n=1),!r||r.isZero()||!t||t.isZero()||!o||0===n)return 0;var i=Number(e.ethers.utils.formatUnits(r,o)),s=Number(e.ethers.utils.formatUnits(t,o));return 1-Math.pow((s-i)/s,n)},exports.calculatePercentageOfBigNumber=function(e,r,t){return void 0===t&&(t=4),e.mul(r*Math.pow(10,t)).div(Math.pow(10,t))},exports.calculateUsersOdds=function(r,t,o,n){if(!r||r.eq(e.ethers.BigNumber.from(0))||!o)return 0;var i=parseInt(n,10),s=Number(e.ethers.utils.formatUnits(r,Number(o))),u=Number(e.ethers.utils.formatUnits(t,Number(o)));return 1/(1-Math.pow((u-s)/u,i))},exports.calculatedEstimatedAccruedCompTotalValueUsdScaled=function(r,t,o){return r?t.mul(Math.round(100*parseFloat(r))).div(1e4).mul(100).div(31536e3).mul(o).div(100):e.ethers.constants.Zero},exports.chainIdToNetworkName=function(e){return 137===e?"polygon":g(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(o){if(Array.isArray(t[o]))t[o].forEach(r);else if("object"==typeof t[o]&&null!==t[o]){var n;"BigNumber"===(null==(n=t[o])?void 0:n.type)?t[o]=e.ethers.BigNumber.from(t[o]):r(t[o])}})),t}catch(e){return t}},exports.displayPercentage=function(e){return(e=parseFloat(e).toFixed(2)).toString().replace(/(\.0+$)|(0+$)/,"")},exports.divideBigNumbers=m,exports.getChainIdByAlias=function(e){return null==p?void 0:p[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=a,exports.getNetworkNameAliasByChainId=g,exports.getNetworkNiceNameByChainId=function(e){switch(Number(e)){case p.mainnet:return"Ethereum";case p.matic:return"Polygon";case p.bsc:return"Binance Smart Chain";case p.celo:return"Celo";case p.xdai:return"xDai";default:var r=g(e);return r?r.charAt(0).toUpperCase()+r.slice(1):"--"}},exports.getPrecision=u,exports.getPrizePoolSymbol=function(e,r){return e.toUpperCase()+"-"+r.slice(0,8)},exports.getSecondsRemainingInPrizePeriod=function(e,r){var t=e.toNumber(),o=r.toNumber();return t-(N()-o)},exports.getSecondsSinceEpoch=N,exports.getTimeBreakdown=function(e){var r=Number(e),t=0;r>=31536e3&&(r-=31536e3*(t=Math.floor(r/31536e3)));var o=0;r>=86400&&(r-=86400*(o=Math.floor(r/86400)));var n=0;(o||r>=3600)&&(r-=3600*(n=Math.floor(r/3600)));var i=0;(n||r>=60)&&(r-=60*(i=Math.floor(r/60)));var s=0;return(i||r>=1)&&(s=r),{years:t,days:o,hours:n,minutes:i,seconds:s}},exports.getTokenColour=function(e,r){return void 0===r&&(r=!1),r?y[e]:U[e]},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=s,exports.prettyNumber=function(e,r){return s(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=o.exec(e.hash))?e.short?r[1]+"...":r[1]+"..."+r[2]:null},exports.stringWithPrecision=n,exports.subtractDates=function(e,r){var t=e.getTime()-r.getTime(),o=0;t>=864e5&&(t-=864e5*(o=t/864e5));var n=0;(o||t>=36e5)&&(t-=36e5*(n=t/36e5));var i=0;(n||t>=6e4)&&(t-=6e4*(i=t/6e4));var s=0;return(i||t>=1e3)&&(s=t/1e3),{days:o,hours:n,minutes:i,seconds:s}},exports.toNonScaledUsdString=function(e){return t.formatUnits(e,2)},exports.toScaledUsdBigNumber=i,exports.underlyingAmountToSharesAmount=function(e,r,t){if(!t.isZero())return e.mul(r).div(t)},exports.unionProbabilities=function(){for(var e=arguments.length<=0?void 0:arguments[0],r=1;r<arguments.length;r++)e=e+(r<0||arguments.length<=r?void 0:arguments[r])-e*(r<0||arguments.length<=r?void 0:arguments[r]);return e};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("ethers"),r=require("ethers/lib/utils"),t=require("@ethersproject/units"),o=/^(\w{6})\w*(\w{4})$/;function i(e,r){void 0===r&&(r={precision:2});var t=r.precision;if(e&&"function"==typeof e.indexOf){var o=t?t+1:0;return e.substr(0,e.indexOf(".")+o)}return e}var n,s=function(e){return t.parseUnits(i(e,{precision:2}),2)},a=function(r,t){if(void 0===t&&(t={}),t.decimals||(t.decimals=18),null!=r){var o=r._isBigNumber?e.ethers.utils.formatUnits(r,t.decimals):r;return!t.precision&&0!==t.precision&&o&&(t.precision=u(o)),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 o="en-GB";r.currentLang&&"es"===r.currentLang&&(o="es-ES"),0===t&&(e=Math.floor(Number(e))),2===t&&(e=Math.round(100*(parseFloat(e)+Number.EPSILON))/100),e.toString().match("e")&&(e=Number.parseFloat(e).toFixed(0));var n=e.toString().split(".");n[0]=n[0].replace(",","");var s="";return s=n.length>1&&t>0?i(n.join("."),{precision:t}):n[0],r.removeTrailingZeros&&(s=s.replace(/(\.0+|0+)$/,"")),Number(s).toLocaleString(o,{minimumFractionDigits:r.removeTrailingZeros?0:t})}(o,t)}},u=function(e){return(e=parseFloat(e))>1e4?0:e>=.1?2:p(e)},p=function(e,r){void 0===r&&(r={additionalDigits:2});var t=r.additionalDigits,o=String(e).split(".")[1];return"0"===o?0:o?o.match(/^0*/)[0].length+t:t},c=function(e,r){return e.mul(Math.round(100*r)).div(100)},l=function(r){return r.reduce((function(e,r){return r.add(e)}),e.ethers.constants.Zero)},m=function(e,r,o){return void 0===o&&(o=4),e.isZero()||r.isZero()?0:Number(t.formatUnits(e.mul(Math.pow(10,o)).div(r),String(o)))},d=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,mumbai:80001,optimism:10,"optimism-goerli":420,avalanche:43114,fuji:43113,celo:42220,"celo-testnet":44787,arbitrum:42161,"arbitrum-goerli":421613}),f=Object.freeze([d.mainnet,d.goerli]),h=Object.freeze([d.polygon,d.mumbai]),v=Object.freeze([d.avalanche,d.fuji]),b=Object.freeze([d.celo,d["celo-testnet"]]),g=Object.freeze([d.optimism,d["optimism-goerli"]]),x=Object.freeze([d.arbitrum,d["arbitrum-goerli"]]),N=Object.freeze(((n={})[d.mainnet]="https://ethereum-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/",n[d.goerli]="https://goerli-web3-provider-proxy.pooltogether-api.workers.dev/",n[d.optimism]="https://optimism-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/",n[d["optimism-goerli"]]="https://optimism-goerli-web3-provider-proxy.pooltogether-api.workers.dev/",n[d.arbitrum]="https://arbitrum-web3-provider-proxy.pooltogether-api.workers.dev/",n[d["arbitrum-goerli"]]="https://arbitrum-goerli-web3-provider-proxy.pooltogether-api.workers.dev/",n[d.polygon]="https://polygon-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/",n[d.mumbai]="https://polygon-mumbai-web3-provider-proxy.pooltogether-api.workers.dev/",n[d.fuji]="https://avalanche-fuji-web3-provider-proxy.pooltogether-api.workers.dev/",n[d.avalanche]="https://avalanche-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/",n)),y=function(e){var r=Object.keys(d).find((function(r){return d[r]===e}));if(void 0!==r)return r},U=function(){return Number((Date.now()/1e3).toFixed(0))},w=Object.freeze({}),T=Object.freeze({});exports.ARBITRUM_NETWORKS=x,exports.AVALANCHE_NETWORKS=v,exports.CELO_NETWORKS=b,exports.ETHEREUM_NETWORKS=f,exports.NETWORK=d,exports.OPTIMISM_NETWORKS=g,exports.POLYGON_NETWORKS=h,exports.PT_RPC_PROXY=N,exports.addBigNumbers=l,exports.addTokenTotalUsdValue=function(e,t){var o=t[e.address];if(o){if(e.usd=o.usd||0,e.derivedETH=o.derivedETH||"0",e.amountUnformatted){var i=c(e.amountUnformatted,e.usd);e.totalValueUsd=r.formatUnits(i,e.decimals),e.totalValueUsdScaled=s(e.totalValueUsd)}}else e.usd=0,e.derivedETH="0"},exports.amountMultByUsd=c,exports.calculateApr=function(e,r,t){if(void 0===t&&(t=4),e.isZero()||r.isZero())return 0;var o=r.mul(365);return 100*m(o,e,t)},exports.calculateCreamBorrowApy=function(e,r,o,i,n,s,a){var u=Number(t.formatUnits(e,18)),p=Number(t.formatUnits(r,18)),c=Number(t.formatUnits(o,18)),l=Number(t.formatUnits(i,18)),m=Number(t.formatUnits(n,18)),d=Number(t.formatUnits(s,18)),f=a.toNumber();return Math.pow(1+u+p*Math.min(c,l)+Math.max(d*c-m,0),f)-1},exports.calculateCreamSupplyApy=function(e,r,o,i){var n=Number(t.formatUnits(r,18)),s=Number(t.formatUnits(o,18)),a=i.toNumber();return Math.pow(1+(Math.pow(1+e,1/a)-1)*(1-n)*s,a)-1},exports.calculateEstimatedCompoundPrizeWithYieldUnformatted=function(r,t,o,i,n,s){var a=s&&0!==parseFloat(s)?e.ethers.utils.parseUnits(parseFloat(s).toFixed(Number(i)),i):e.ethers.constants.Zero;return(a.isZero()?e.ethers.constants.Zero:t.mul(o).mul(Math.round(parseFloat(n))).mul(a).div(e.ethers.utils.parseUnits("1",18)).div(e.ethers.utils.parseUnits("1",i))).add(r)},exports.calculateLPTokenPrice=function(e,r,o,i,n){var s=l([c(t.parseUnits(e,18),o),c(t.parseUnits(r,18),i)]),a=t.parseUnits(n,18);return s.div(a)},exports.calculateOdds=function(r,t,o,i){if(void 0===i&&(i=1),!r||r.isZero()||!t||t.isZero()||!o||0===i)return 0;var n=Number(e.ethers.utils.formatUnits(r,o)),s=Number(e.ethers.utils.formatUnits(t,o));return 1-Math.pow((s-n)/s,i)},exports.calculatePercentageOfBigNumber=function(e,r,t){return void 0===t&&(t=4),e.mul(r*Math.pow(10,t)).div(Math.pow(10,t))},exports.calculateUsersOdds=function(r,t,o,i){if(!r||r.eq(e.ethers.BigNumber.from(0))||!o)return 0;var n=parseInt(i,10),s=Number(e.ethers.utils.formatUnits(r,Number(o))),a=Number(e.ethers.utils.formatUnits(t,Number(o)));return 1/(1-Math.pow((a-s)/a,n))},exports.calculatedEstimatedAccruedCompTotalValueUsdScaled=function(r,t,o){return r?t.mul(Math.round(100*parseFloat(r))).div(1e4).mul(100).div(31536e3).mul(o).div(100):e.ethers.constants.Zero},exports.chainIdToNetworkName=function(e){return 137===e?"polygon":y(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(o){if(Array.isArray(t[o]))t[o].forEach(r);else if("object"==typeof t[o]&&null!==t[o]){var i;"BigNumber"===(null==(i=t[o])?void 0:i.type)?t[o]=e.ethers.BigNumber.from(t[o]):r(t[o])}})),t}catch(e){return t}},exports.displayPercentage=function(e){return(e=parseFloat(e).toFixed(2)).toString().replace(/(\.0+$)|(0+$)/,"")},exports.divideBigNumbers=m,exports.getChainIdByAlias=function(e){return null==d?void 0:d[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=p,exports.getNetworkNameAliasByChainId=y,exports.getNetworkNiceNameByChainId=function(e){switch(Number(e)){case d.mainnet:return"Ethereum";case d.matic:return"Polygon";case d.bsc:return"Binance Smart Chain";case d.celo:return"Celo";case d.xdai:return"xDai";default:var r=y(e);return r?r.charAt(0).toUpperCase()+r.slice(1):"--"}},exports.getPrecision=u,exports.getPrizePoolSymbol=function(e,r){return e.toUpperCase()+"-"+r.slice(0,8)},exports.getSecondsRemainingInPrizePeriod=function(e,r){var t=e.toNumber(),o=r.toNumber();return t-(U()-o)},exports.getSecondsSinceEpoch=U,exports.getTimeBreakdown=function(e){var r=Number(e),t=0;r>=31536e3&&(r-=31536e3*(t=Math.floor(r/31536e3)));var o=0;r>=86400&&(r-=86400*(o=Math.floor(r/86400)));var i=0;(o||r>=3600)&&(r-=3600*(i=Math.floor(r/3600)));var n=0;(i||r>=60)&&(r-=60*(n=Math.floor(r/60)));var s=0;return(n||r>=1)&&(s=r),{years:t,days:o,hours:i,minutes:n,seconds:s}},exports.getTokenColour=function(e,r){return void 0===r&&(r=!1),r?T[e]:w[e]},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=a,exports.prettyNumber=function(e,r){return a(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=o.exec(e.hash))?e.short?r[1]+"...":r[1]+"..."+r[2]:null},exports.stringWithPrecision=i,exports.subtractDates=function(e,r){var t=e.getTime()-r.getTime(),o=0;t>=864e5&&(t-=864e5*(o=t/864e5));var i=0;(o||t>=36e5)&&(t-=36e5*(i=t/36e5));var n=0;(i||t>=6e4)&&(t-=6e4*(n=t/6e4));var s=0;return(n||t>=1e3)&&(s=t/1e3),{days:o,hours:i,minutes:n,seconds:s}},exports.toNonScaledUsdString=function(e){return t.formatUnits(e,2)},exports.toScaledUsdBigNumber=s,exports.underlyingAmountToSharesAmount=function(e,r,t){if(!t.isZero())return e.mul(r).div(t)},exports.unionProbabilities=function(){for(var e=arguments.length<=0?void 0:arguments[0],r=1;r<arguments.length;r++)e=e+(r<0||arguments.length<=r?void 0:arguments[r])-e*(r<0||arguments.length<=r?void 0:arguments[r]);return e};
//# sourceMappingURL=utilities.cjs.production.min.js.map

@@ -508,2 +508,4 @@ import { ethers } from 'ethers';

var _Object$freeze;
/**

@@ -546,2 +548,3 @@ * Constant for chain ids

var ARBITRUM_NETWORKS = /*#__PURE__*/Object.freeze([NETWORK.arbitrum, NETWORK['arbitrum-goerli']]);
var PT_RPC_PROXY = /*#__PURE__*/Object.freeze((_Object$freeze = {}, _Object$freeze[NETWORK.mainnet] = 'https://ethereum-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.goerli] = 'https://goerli-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.optimism] = 'https://optimism-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK['optimism-goerli']] = 'https://optimism-goerli-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.arbitrum] = 'https://arbitrum-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK['arbitrum-goerli']] = 'https://arbitrum-goerli-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.polygon] = 'https://polygon-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.mumbai] = 'https://polygon-mumbai-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.fuji] = 'https://avalanche-fuji-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze[NETWORK.avalanche] = 'https://avalanche-mainnet-web3-provider-proxy.pooltogether-api.workers.dev/', _Object$freeze));

@@ -954,3 +957,3 @@ /**

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

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

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