Skip to content

Commit

Permalink
Merge branch 'main' into OPS-185-discord-pool-command
Browse files Browse the repository at this point in the history
  • Loading branch information
callmephilip committed Nov 15, 2023
2 parents f6cf1bd + 0098895 commit 645d0eb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions bots/fees.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .settings import BOT_TICKER_INTERVAL_MINUTES
from .data import LiquidityPool
from .helpers import LOGGER
from .helpers import LOGGER, amount_to_k_string
from .ticker import TickerBot


Expand All @@ -22,7 +22,7 @@ async def ticker(self):
pools = await LiquidityPool.get_pools()
fees = sum(map(lambda p: p.total_fees, pools))

await self.update_nick_for_all_servers(f"Fees: {round(fees/1000, 2)}K")
await self.update_presence(f"{len(pools)} pools")
await self.update_nick_for_all_servers(f"Fees ~${amount_to_k_string(fees)}")
await self.update_presence(f"Based on {len(pools)} pools this epoch")
except Exception as ex:
LOGGER.error(f"Ticker failed with {ex}")
5 changes: 5 additions & 0 deletions bots/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def format_percentage(value: float) -> str:
return "{:0,.2f} %".format(value)


def amount_to_m_string(amount: float) -> str:
"""Turns 2000000 to "2M" """
return f"{round(amount/1000000, 2)}M"


# logging
LOGGING_LEVEL = os.getenv("LOGGING_LEVEL", "DEBUG")
LOGGING_HANDLER = logging.StreamHandler(sys.stdout)
Expand Down
4 changes: 2 additions & 2 deletions bots/price.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def __init__(self, *args, source_token: Token, target_token: Token, **kwargs):
async def on_ready(self):
LOGGER.debug(f"Logged in as {self.user} (ID: {self.user.id})")
LOGGER.debug("------")
await self.update_presence(self.source_token.symbol)
await self.update_presence(f"Based on {self.target_token.symbol} onchain quote")

@tasks.loop(seconds=BOT_TICKER_INTERVAL_MINUTES * 60)
async def ticker(self):
try:
[source_token_price] = await Price.get_prices([self.source_token])
await self.update_nick_for_all_servers(
f"{self.target_token.symbol} {source_token_price.pretty_price}"
f"~${source_token_price.pretty_price} / {self.source_token.symbol}"
)
except Exception as ex:
LOGGER.error(f"Ticker failed with {ex}")
6 changes: 3 additions & 3 deletions bots/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, *args, protocol_name: str, **kwargs):
async def on_ready(self):
LOGGER.debug(f"Logged in as {self.user} (ID: {self.user.id})")
LOGGER.debug("------")
await self.update_presence(f"incentives for {self.protocol_name}")
await self.update_presence(f"rewards for {self.protocol_name}")

@tasks.loop(seconds=BOT_TICKER_INTERVAL_MINUTES * 60)
async def ticker(self):
Expand All @@ -24,10 +24,10 @@ async def ticker(self):
bribes = sum(map(lambda lpe: lpe.total_bribes, lpes))

await self.update_nick_for_all_servers(
f"Rewards: {amount_to_k_string(fees + bribes)}"
f"Rewards: ~${amount_to_k_string(fees + bribes)}"
)
await self.update_presence(
f"{amount_to_k_string(fees)} fees & {amount_to_k_string(bribes)} incentives"
f"~${amount_to_k_string(fees)} + ~${amount_to_k_string(bribes)} in fees & incentives for voters" # noqa
)
except Exception as ex:
LOGGER.error(f"Ticker failed with {ex}")
8 changes: 5 additions & 3 deletions bots/tvl.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from discord.ext import tasks

from .settings import BOT_TICKER_INTERVAL_MINUTES
from .data import LiquidityPool
from .helpers import LOGGER
from .data import LiquidityPool, Token
from .helpers import LOGGER, amount_to_m_string
from .ticker import TickerBot


Expand All @@ -21,6 +21,8 @@ async def ticker(self):
try:
pools = await LiquidityPool.get_pools()
tvl = await LiquidityPool.tvl(pools)
await self.update_nick_for_all_servers(f"{round(tvl/1000000, 2)}M")
tokens = await Token.get_all_listed_tokens()
await self.update_nick_for_all_servers(f"TVL ~${amount_to_m_string(tvl)}")
await self.update_presence(f"Based on {len(tokens)} listed tokens")
except Exception as ex:
LOGGER.error(f"Ticker failed with {ex}")

0 comments on commit 645d0eb

Please sign in to comment.