diff --git a/src/tgbot/handlers/treasury/commands.py b/src/tgbot/handlers/treasury/commands.py index 9574ad4..8f014ec 100644 --- a/src/tgbot/handlers/treasury/commands.py +++ b/src/tgbot/handlers/treasury/commands.py @@ -9,6 +9,7 @@ get_leaderboard, get_user_balance, get_user_place_in_leaderboard, + get_token_supply, ) from src.tgbot.senders.utils import get_random_emoji @@ -94,6 +95,9 @@ async def handle_show_leaderbaord( "To see your place in the leaderboard, set your /nickname ⬅️\n\n" ) + tokens = await get_token_supply() + LEADERBOARD_TEXT += f"\n Total supply: {tokens} 🍔" + return await update.message.reply_text(LEADERBOARD_TEXT, parse_mode=ParseMode.HTML) diff --git a/src/tgbot/handlers/treasury/service.py b/src/tgbot/handlers/treasury/service.py index 8f66124..dcbddb9 100644 --- a/src/tgbot/handlers/treasury/service.py +++ b/src/tgbot/handlers/treasury/service.py @@ -32,6 +32,12 @@ async def get_leaderboard(limit=10) -> list[dict[str, Any]]: return await fetch_all(select_statement) +async def get_token_supply() -> int: + select_statement = select(func.sum(treasury_trx.c.amount)) + result = await execute(select_statement) + return result.scalar() + + async def get_user_place_in_leaderboard(user_id: int) -> int: return await fetch_one( text(