From db541cb63ba6a2e58907a32bf1565cf034f710f3 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 24 Feb 2022 01:04:24 -0600 Subject: [PATCH] Show investment in market resolve email --- .../src/email-templates/market-resolved.html | 22 +++++++++++++++++++ functions/src/emails.ts | 3 +++ functions/src/resolve-market.ts | 14 ++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/functions/src/email-templates/market-resolved.html b/functions/src/email-templates/market-resolved.html index 2a92d60f..42d4e2d8 100644 --- a/functions/src/email-templates/market-resolved.html +++ b/functions/src/email-templates/market-resolved.html @@ -437,6 +437,28 @@ margin: 0; " /> + Your investment was + M$ {{investment}}. +
+
Your payout is M$ {{payout}} userId)), Object.keys(userPayouts) ) + const investedByUser = _.mapValues( + _.groupBy(openBets, (bet) => bet.userId), + (bets) => _.sumBy(bets, (bet) => bet.amount) + ) const emailPayouts = [ ...Object.entries(userPayouts), ...nonWinners.map((userId) => [userId, 0] as const), - ] + ].map(([userId, payout]) => ({ + userId, + investment: investedByUser[userId], + payout, + })) + await Promise.all( - emailPayouts.map(([userId, payout]) => + emailPayouts.map(({ userId, investment, payout }) => sendMarketResolutionEmail( userId, + investment, payout, creator, contract,