diff --git a/common/calculate.ts b/common/calculate.ts index 44dc9113..47fee8c6 100644 --- a/common/calculate.ts +++ b/common/calculate.ts @@ -215,7 +215,7 @@ export function getContractBetMetrics(contract: Contract, yourBets: Bet[]) { } const profit = payout + saleValue + redeemed - totalInvested - const profitPercent = (profit / totalInvested) * 100 + const profitPercent = totalInvested === 0 ? 0 : (profit / totalInvested) * 100 const invested = isCpmm ? getCpmmInvested(yourBets) : getDpmInvested(yourBets) const hasShares = Object.values(totalShares).some( diff --git a/functions/.env.dev b/functions/.env.dev new file mode 100644 index 00000000..b5aae225 --- /dev/null +++ b/functions/.env.dev @@ -0,0 +1,3 @@ +# This sets which EnvConfig is deployed to Firebase Cloud Functions + +NEXT_PUBLIC_FIREBASE_ENV=DEV diff --git a/functions/.env b/functions/.env.prod similarity index 100% rename from functions/.env rename to functions/.env.prod diff --git a/functions/package.json b/functions/package.json index 0397c5db..cd2a9ec5 100644 --- a/functions/package.json +++ b/functions/package.json @@ -5,7 +5,7 @@ "firestore": "dev-mantic-markets.appspot.com" }, "scripts": { - "build": "yarn compile && rm -rf dist && mkdir -p dist/functions && cp -R ../common/lib dist/common && cp -R lib/src dist/functions/src && cp ../yarn.lock dist && cp package.json dist && cp .env dist", + "build": "yarn compile && rm -rf dist && mkdir -p dist/functions && cp -R ../common/lib dist/common && cp -R lib/src dist/functions/src && cp ../yarn.lock dist && cp package.json dist && cp .env.prod dist && cp .env.dev dist", "compile": "tsc -b", "watch": "tsc -w", "shell": "yarn build && firebase functions:shell", diff --git a/functions/src/update-metrics.ts b/functions/src/update-metrics.ts index fcaf9f08..1fde9cfd 100644 --- a/functions/src/update-metrics.ts +++ b/functions/src/update-metrics.ts @@ -30,7 +30,9 @@ const firestore = admin.firestore() export const scheduleUpdateMetrics = functions.pubsub .schedule('every 15 minutes') .onRun(async () => { - const response = await fetch(getFunctionUrl('updatemetrics'), { + const url = getFunctionUrl('updatemetrics') + console.log('Scheduling update metrics', url) + const response = await fetch(url, { headers: { 'Content-Type': 'application/json', },