-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a86cb36
commit 49aad14
Showing
8 changed files
with
115 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from discord.ext import tasks | ||
|
||
from .settings import BOT_TICKER_INTERVAL_MINUTES | ||
from .data import LiquidityPoolEpoch | ||
from .helpers import LOGGER, amount_to_k_string | ||
from .ticker import TickerBot | ||
|
||
|
||
class IncentivesBot(TickerBot): | ||
def __init__(self, *args, protocol_name: str, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.protocol_name = protocol_name | ||
|
||
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}") | ||
|
||
@tasks.loop(seconds=BOT_TICKER_INTERVAL_MINUTES * 60) | ||
async def ticker(self): | ||
try: | ||
lpes = await LiquidityPoolEpoch.fetch_latest() | ||
fees = sum(map(lambda lpe: lpe.total_fees, lpes)) | ||
bribes = sum(map(lambda lpe: lpe.total_bribes, lpes)) | ||
|
||
await self.update_nick_for_all_servers( | ||
f"Rewards: {amount_to_k_string(fees + bribes)}" | ||
) | ||
await self.update_presence( | ||
f"{amount_to_k_string(fees)} fees and {amount_to_k_string(bribes)} incentives" | ||
) | ||
except Exception as ex: | ||
LOGGER.error(f"Ticker failed with {ex}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters