Skip to content

Commit

Permalink
show total supply
Browse files Browse the repository at this point in the history
  • Loading branch information
ohld committed Jun 9, 2024
1 parent 9a994ec commit e06010a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tgbot/handlers/treasury/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)


Expand Down
6 changes: 6 additions & 0 deletions src/tgbot/handlers/treasury/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit e06010a

Please sign in to comment.