Skip to content

Commit

Permalink
Merge pull request #27 from BeanstalkFarms/feat/sk/price-reverts
Browse files Browse the repository at this point in the history
Alerts for Well events to still process if they cannot be priced
  • Loading branch information
soilking authored Oct 10, 2024
2 parents 5777d84 + 1fd23da commit bac12d7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/bots/discord_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ async def on_ready(self):

logging.info(
f"Discord channels are {self._channel_report}, {self._channel_peg}, {self._channel_seasons}, "
f"{self._channel_pool}, {self._channel_beanstalk}, {self._channel_market}, {self._channel_barn_raise},
{self._chat_id_contract_migrated}"
f"{self._channel_pool}, {self._channel_beanstalk}, {self._channel_market}, "
f"{self._channel_barn_raise}, {self._chat_id_contract_migrated}"
)

# Guild IDs for all servers this bot is in.
Expand Down
24 changes: 22 additions & 2 deletions src/constants/addresses.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Arbitrum addresses
BEANSTALK_ADDR = "0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70"
### TODO: these may need to be updated
BEANSTALK_PRICE_ADDR = "0xC218F5a782b0913931DCF502FA2aA959b36Ac9E7"
FERTILIZER_ADDR = "0xFEFEFECA5375630d6950F40e564A27f6074845B5"
###
AQUIFER_ADDR = "0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521"
BEAN_ADDR = "0xBEA0005B8599265D41256905A9B3073D397812E4"
UNRIPE_ADDR = "0x1BEA054dddBca12889e07B3E076f511Bf1d27543"
Expand All @@ -25,3 +23,25 @@
USDT = "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"

NULL_ADDR = "0x0000000000000000000000000000000000000000"

# Ethereum addresses
# BEANSTALK_ADDR = "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5"
# BEANSTALK_PRICE_ADDR = "0x4BEd6cb142b7d474242d87F4796387DEB9E1E1B4"
# FERTILIZER_ADDR = "0x402c84De2Ce49aF88f5e2eF3710ff89bFED36cB6"
# AQUIFER_ADDR = "0xBA51AAAA95aeEFc1292515b36D86C51dC7877773"
# BEAN_ADDR = "0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab"
# UNRIPE_ADDR = "0x1BEA0050E63e05FBb5D8BA2f10cf5800B6224449"
# UNRIPE_LP_ADDR = "0x1BEA3CcD22F4EBd3d37d731BA31Eeca95713716D"
# BEAN_ETH_ADDR = "0xBEA0e11282e2bB5893bEcE110cF199501e872bAd"
# BEAN_WSTETH_ADDR = "0xBeA0000113B0d182f4064C86B71c315389E4715D"
# BEAN_WEETH_ADDR = "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5"
# BEAN_WBTC_ADDR = "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5"
# BEAN_USDC_ADDR = "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5"
# BEAN_USDT_ADDR = "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5"

# UNRIPE_TOKEN_PREFIX = "0x1BEA"

# WRAPPED_ETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
# WSTETH = "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"

# NULL_ADDR = "0x0000000000000000000000000000000000000000"
6 changes: 3 additions & 3 deletions src/data_access/subgraphs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def execute(client, query_str, max_tries=10):


def try_execute_with_wait(check_key, client, query_str, max_tries=2, max_wait_blocks=5):
"""Perform execute. Wait a block and try again if return data is empty. Eventually return None if no data.
"""Perform execute. Wait a 5s and try again if return data is empty. Eventually return None if no data.
Also do not raise exception on failure, log warning and proceed.
"""
Expand All @@ -75,8 +75,8 @@ def try_execute_with_wait(check_key, client, query_str, max_tries=2, max_wait_bl
pass
if result is not None: # null
break
logging.info("Data not found. Waiting a block, retrying...")
time.sleep(15)
logging.info("Data not found. Waiting 5s, retrying...")
time.sleep(5)
return result


Expand Down
7 changes: 5 additions & 2 deletions src/monitors/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ def well_event_str(event_log, bean_reporting, basin_graph_client, bean_client, w
return ""

if bdv is not None:
value = bdv * bean_client.avg_bean_price()

try:
value = bdv * bean_client.avg_bean_price()
except Exception as e:
logging.warning(f"Price contract failed to return a value. No value is assigned to this event")

if is_swapish:
if bean_reporting and erc20_info_out.symbol == "BEAN":
event_str += f"📗 {amount_out_str} {erc20_info_out.symbol} bought for {amount_in_str} {erc20_info_in.symbol} @ ${round_num(value/bean_to_float(amount_out), 4)} "
Expand Down

0 comments on commit bac12d7

Please sign in to comment.