1616SUSDAI_ADDR = Web3 .to_checksum_address ("0x0B2b2B2076d95dda7817e785989fE353fe955ef9" )
1717GRAPHQL_URL = "https://protocol-api.m0.org/graphql"
1818
19+
1920def main ():
2021 client = ChainManager .get_client (Chain .ARBITRUM )
2122
2223 # Common ABI
2324 from utils .abi import load_abi
25+
2426 erc20_abi = load_abi ("common-abi/ERC20.json" )
2527
2628 wm = client .get_contract (WM_TOKEN , erc20_abi )
@@ -31,7 +33,7 @@ def main():
3133 vault_shares = wm .functions .balanceOf (VAULT_ADDR ).call ()
3234 # Decimals will always be the same = 6
3335 wm_decimals = 6
34- usdai_supply_fmt = vault_shares / (10 ** wm_decimals )
36+ usdai_supply_fmt = vault_shares / (10 ** wm_decimals )
3537
3638 # 2. Get Mint Ratio via API
3739 query = """
@@ -48,7 +50,7 @@ def main():
4850 }
4951 """
5052
51- mint_ratio = 10000 # Default to 1:1 (scaled 1e4 for bps) if not found
53+ mint_ratio = 10000 # Default to 1:1 (scaled 1e4 for bps) if not found
5254
5355 try :
5456 res = requests .post (GRAPHQL_URL , json = {"query" : query }, timeout = 10 )
@@ -92,7 +94,7 @@ def main():
9294 last_ratio = int (get_last_value_for_key_from_file (cache_filename , cache_key_ratio ))
9395
9496 if last_ratio != 0 and last_ratio != mint_ratio :
95- msg = f"⚠️ *USDai Mint Ratio Changed*\n \n Old: { last_ratio / 10000 :.4f} \n New: { mint_ratio / 10000 :.4f} "
97+ msg = f"⚠️ *USDai Mint Ratio Changed*\n \n Old: { last_ratio / 10000 :.4f} \n New: { mint_ratio / 10000 :.4f} "
9698 send_telegram_message (msg , PROTOCOL )
9799
98100 # Always update ratio cache
@@ -111,10 +113,10 @@ def main():
111113
112114 write_last_value_to_file (cache_filename , cache_key_buffer , buffer )
113115
114-
115116 except Exception as e :
116117 print (f"Error: { e } " )
117118 send_telegram_message (f"⚠️ USDai monitoring failed: { e } " , PROTOCOL , False , True )
118119
120+
119121if __name__ == "__main__" :
120122 main ()
0 commit comments