diff --git a/packages/screens/Rakki/RakkiScreen.tsx b/packages/screens/Rakki/RakkiScreen.tsx index 2901aba5df..46324c8db5 100644 --- a/packages/screens/Rakki/RakkiScreen.tsx +++ b/packages/screens/Rakki/RakkiScreen.tsx @@ -18,8 +18,6 @@ import { sectionLabelCStyle } from "@/screens/Rakki/styles"; import { ScreenFC } from "@/utils/navigation"; import { layout } from "@/utils/style/layout"; -// TODO: replace all placeholders text with real values - export const RakkiScreen: ScreenFC<"Rakki"> = () => { const networkId = useSelectedNetworkId(); const { height } = useMaxResolution(); @@ -65,7 +63,11 @@ export const RakkiScreen: ScreenFC<"Rakki"> = () => { networkId={networkId} style={{ marginTop: layout.spacing_x4 }} /> - + { if (!selectedWallet?.address) { throw new Error("No wallet with valid address selected"); @@ -166,11 +182,7 @@ export const BuyTicketsModal: FC<{ ]} gradientType="yellow" > - {prettyPrice( - networkId, - info.config.ticket_price.amount, - info.config.ticket_price.denom, - )} + {prettyTicketPrice} @@ -236,11 +248,7 @@ export const BuyTicketsModal: FC<{ Total price - {prettyPrice( - networkId, - totalPrice.toString(), - info.config.ticket_price.denom, - )} + {prettyTotalPrice} @@ -286,11 +294,7 @@ export const BuyTicketsModal: FC<{ }, ]} > - {prettyPrice( - networkId, - ticketDenomBalance, - info.config.ticket_price.denom, - )} + {prettyAvailableBalance} )} diff --git a/packages/screens/Rakki/components/GameBox.tsx b/packages/screens/Rakki/components/GameBox.tsx index cafd4bd61b..b1fcea7de0 100644 --- a/packages/screens/Rakki/components/GameBox.tsx +++ b/packages/screens/Rakki/components/GameBox.tsx @@ -2,6 +2,8 @@ import Long from "long"; import { FC } from "react"; import { StyleProp, View } from "react-native"; +import { rakkiNetCurrentPrizeAmount } from "./../utils"; + import { BrandText } from "@/components/BrandText"; import { Box, BoxStyle } from "@/components/boxes/Box"; import { Info } from "@/contracts-clients/rakki/Rakki.types"; @@ -23,16 +25,21 @@ export const GameBox: FC<{ const { ticketsCount: userTicketsCount } = useRakkiTicketsCountByUser( selectedWallet?.userId, ); - const totalPrizeAmount = Long.fromString(info.config.ticket_price.amount).mul( - info.current_tickets_count, - ); const userAmount = userTicketsCount ? Long.fromString(info.config.ticket_price.amount).mul(userTicketsCount) : 0; - const feePrizeAmount = totalPrizeAmount - .mul(info.config.fee_per10k) - .div(10000); - const winnerPrizeAmount = totalPrizeAmount.sub(feePrizeAmount); + + const prettyCurrentPrizeAmount = prettyPrice( + networkId, + rakkiNetCurrentPrizeAmount(info), + info.config.ticket_price.denom, + ); + const prettyUserTicketsPriceAmount = prettyPrice( + networkId, + userAmount.toString(), + info.config.ticket_price.denom, + ); + return ( Prize Pot @@ -90,11 +93,7 @@ export const GameBox: FC<{ Your tickets {userTicketsCount !== null ? ( ) : ( diff --git a/packages/screens/Rakki/components/Help.tsx b/packages/screens/Rakki/components/Help.tsx index eff27df9a2..14bc751bb2 100644 --- a/packages/screens/Rakki/components/Help.tsx +++ b/packages/screens/Rakki/components/Help.tsx @@ -1,10 +1,14 @@ import { FC } from "react"; import { StyleProp, View, ViewStyle } from "react-native"; +import { rakkiNetMaxPrizeAmount } from "../utils"; + import { BrandText } from "@/components/BrandText"; import { TertiaryBox } from "@/components/boxes/TertiaryBox"; import { GridList } from "@/components/layout/GridList"; +import { Info } from "@/contracts-clients/rakki/Rakki.types"; import { gameBoxLabelCStyle } from "@/screens/Rakki/styles"; +import { prettyPrice } from "@/utils/coins"; import { neutral33, neutral77 } from "@/utils/style/colors"; import { fontMedium10, @@ -18,12 +22,27 @@ interface HelpBoxDefinition { description: string; } -export const Help: FC<{ style?: StyleProp }> = ({ style }) => { +export const Help: FC<{ + info: Info; + networkId: string; + style?: StyleProp; +}> = ({ info, style, networkId }) => { + const prettyTicketPrice = prettyPrice( + networkId, + info.config.ticket_price.amount, + info.config.ticket_price.denom, + ); + console.log("rakkiNetMaxPrizeAmount(info)", rakkiNetMaxPrizeAmount(info)); + const prettyMaxPrize = prettyPrice( + networkId, + rakkiNetMaxPrizeAmount(info), + info.config.ticket_price.denom, + ); + const helpBoxes: HelpBoxDefinition[] = [ { title: "Buy Tickets", - description: - "Prices are $10 USDC per ticket.\nGamblers can buy multiple tickets.", + description: `Prices are ${prettyTicketPrice} per ticket.\nGamblers can buy multiple tickets.`, }, { title: "Wait for the Draw", @@ -32,15 +51,15 @@ export const Help: FC<{ style?: StyleProp }> = ({ style }) => { }, { title: "Check for Prizes", - description: - "Once the cashprize pool is reached, the winner receive the $10,000 transaction directly!", + description: `Once the cashprize pool is reached, the winner receive the ${prettyMaxPrize} transaction directly!`, }, ]; + return ( How to Play RAKKi - {`When the community lottery pool reaches the 10k USDC amount, only one will be the winner!\nSimple!`} + {`When the community lottery pool reaches the ${prettyMaxPrize} amount, only one will be the winner!\nSimple!`} @@ -51,7 +70,7 @@ export const Help: FC<{ style?: StyleProp }> = ({ style }) => { data={helpBoxes} renderItem={({ item, index }, width) => { return ( - + }> = ({ style }) => { letterSpacing: -(12 * 0.01), textAlign: "left", padding: layout.spacing_x1_5, - height: 56, }, ]} > diff --git a/packages/screens/Rakki/components/PrizeInfo.tsx b/packages/screens/Rakki/components/PrizeInfo.tsx index 97884b3a79..e9dd8042b1 100644 --- a/packages/screens/Rakki/components/PrizeInfo.tsx +++ b/packages/screens/Rakki/components/PrizeInfo.tsx @@ -1,7 +1,8 @@ -import Long from "long"; import { FC } from "react"; import { StyleProp, View, ViewStyle } from "react-native"; +import { rakkiNetMaxPrizeAmount } from "../utils"; + import { BrandText } from "@/components/BrandText"; import { GradientText } from "@/components/gradientText"; import { Info } from "@/contracts-clients/rakki/Rakki.types"; @@ -19,13 +20,12 @@ export const PrizeInfo: FC<{ networkId: string; style?: StyleProp; }> = ({ info, networkId, style }) => { - const totalPrizeAmount = Long.fromString(info.config.ticket_price.amount).mul( - info.config.max_tickets, + const prettyMaxPrizeAmount = prettyPrice( + networkId, + rakkiNetMaxPrizeAmount(info), + info.config.ticket_price.denom, ); - const feePrizeAmount = totalPrizeAmount - .mul(info.config.fee_per10k) - .div(10000); - const winnerPrizeAmount = totalPrizeAmount.sub(feePrizeAmount); + return ( - {prettyPrice( - networkId, - winnerPrizeAmount.toString(), - info.config.ticket_price.denom, - )} + {prettyMaxPrizeAmount} { + const grossTicketsPrizeAmount = Long.fromString( + info.config.ticket_price.amount, + ).mul(ticketsCount); + const feePrizeAmount = grossTicketsPrizeAmount + .mul(info.config.fee_per10k) + .div(10000); + const netPrizeAmount = grossTicketsPrizeAmount.sub(feePrizeAmount); + return netPrizeAmount.toString(); +}; + +export const rakkiNetCurrentPrizeAmount = (info: Info) => + rakkiNetPrizeAmount(info, info.current_tickets_count); +export const rakkiNetMaxPrizeAmount = (info: Info) => + rakkiNetPrizeAmount(info, info.config.max_tickets);