From 86139dcc9123a67700b3374a1983136e641ddd1b Mon Sep 17 00:00:00 2001 From: Marcus Aurelius Date: Fri, 9 Feb 2024 15:58:47 -0600 Subject: [PATCH] Remove runway bot --- k8s/runway/deployment_set_bot.yaml | 16 ------ k8s/runway/kustomization.yaml | 13 ----- k8s/secret.properties.template | 1 - src/runway/__init__.py | 0 src/runway/main.py | 85 ------------------------------ 5 files changed, 115 deletions(-) delete mode 100644 k8s/runway/deployment_set_bot.yaml delete mode 100644 k8s/runway/kustomization.yaml delete mode 100644 src/runway/__init__.py delete mode 100644 src/runway/main.py diff --git a/k8s/runway/deployment_set_bot.yaml b/k8s/runway/deployment_set_bot.yaml deleted file mode 100644 index f9b89c3..0000000 --- a/k8s/runway/deployment_set_bot.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: bot -spec: - template: - spec: - containers: - - name: bot - args: ["src.runway.main"] - env: - - name: DISCORD_BOT_TOKEN - valueFrom: - secretKeyRef: - name: discord-bots-secret - key: DISCORD_BOT_TOKEN_RUNWAY diff --git a/k8s/runway/kustomization.yaml b/k8s/runway/kustomization.yaml deleted file mode 100644 index 35a5ad2..0000000 --- a/k8s/runway/kustomization.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - ../base - -namePrefix: runway- - -commonLabels: - bot: runway - -patchesStrategicMerge: - - deployment_set_bot.yaml diff --git a/k8s/secret.properties.template b/k8s/secret.properties.template index feae9d9..8b07b2e 100644 --- a/k8s/secret.properties.template +++ b/k8s/secret.properties.template @@ -16,7 +16,6 @@ DISCORD_BOT_TOKEN_INDEX=${DISCORD_BOT_TOKEN_INDEX} DISCORD_BOT_TOKEN_TREASURY_CARBON=${DISCORD_BOT_TOKEN_TREASURY_CARBON} DISCORD_BOT_TOKEN_TREASURY_MARKET=${DISCORD_BOT_TOKEN_TREASURY_MARKET} DISCORD_BOT_TOKEN_UBO_PRICE=${DISCORD_BOT_TOKEN_UBO_PRICE} -DISCORD_BOT_TOKEN_RUNWAY=${DISCORD_BOT_TOKEN_RUNWAY} DISCORD_BOT_TOKEN_RETIREMENT_FEE_INFO=${DISCORD_BOT_TOKEN_RETIREMENT_FEE_INFO} DISCORD_BOT_TOKEN_DAO_FEE=${DISCORD_BOT_TOKEN_DAO_FEE} DISCORD_BOT_TOKEN_DAO_BALANCE=${DISCORD_BOT_TOKEN_DAO_BALANCE} diff --git a/src/runway/__init__.py b/src/runway/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/runway/main.py b/src/runway/main.py deleted file mode 100644 index 7650b29..0000000 --- a/src/runway/main.py +++ /dev/null @@ -1,85 +0,0 @@ -import os -from discord.ext import tasks - -from subgrounds.subgrounds import Subgrounds - -from ..constants import MCO2_ADDRESS, MCO2_DECIMALS, \ - BCT_ADDRESS, BCT_DECIMALS, \ - NCT_ADDRESS, NCT_DECIMALS, NBO_ADDRESS, \ - NBO_DECIMALS, UBO_ADDRESS, UBO_DECIMALS -from ..contract_info import token_supply -from ..utils import get_discord_client, \ - get_polygon_web3, get_eth_web3, load_abi, prettify_number, \ - update_nickname, update_presence, get_last_metric - -BOT_TOKEN = os.environ["DISCORD_BOT_TOKEN"] - -# Initialize web3 -web3 = get_polygon_web3() -web3_eth = get_eth_web3() - -# Load ABI -pool_abi = load_abi('carbon_pool.json') - -# Initialized Discord client -client = get_discord_client() - -sg = Subgrounds() - - -def get_info(): - runway = get_runway() - total_carbon_supply = get_total_carbon_supply() - return runway, total_carbon_supply - - -def get_runway(): - last_metric = get_last_metric(sg) - runway = sg.query([last_metric.runwayCurrent]) - - return runway - - -def get_total_carbon_supply(): - try: - bct_supply = token_supply(web3, BCT_ADDRESS, pool_abi, BCT_DECIMALS) - mco2_supply = token_supply(web3_eth, MCO2_ADDRESS, pool_abi, MCO2_DECIMALS) - ubo_supply = token_supply(web3, UBO_ADDRESS, pool_abi, UBO_DECIMALS) - nbo_supply = token_supply(web3, NBO_ADDRESS, pool_abi, NBO_DECIMALS) - nct_supply = token_supply(web3, NCT_ADDRESS, pool_abi, NCT_DECIMALS) - - total_amount = bct_supply + mco2_supply + ubo_supply + nbo_supply + nct_supply - return total_amount - except Exception: - # Exception will occur if any of the supply values are None - return None - - -@client.event -async def on_ready(): - print('Logged in as {0.user}'.format(client)) - if not update_info.is_running(): - update_info.start() - - -@tasks.loop(seconds=300) -async def update_info(): - runway, total_carbon_supply = get_info() - - if runway is not None and total_carbon_supply is not None: - - nickname_txt = f'Runway: {round(runway)} days' - success = await update_nickname(client, nickname_txt) - if not success: - return - - presence_txt = f'On-Chain CO2: {prettify_number(total_carbon_supply)}t' - success = await update_presence( - client, - presence_txt, - type='playing' - ) - if not success: - return - -client.run(BOT_TOKEN)