Skip to content

Commit 87d5c7b

Browse files
committed
fix(docs): new risk category for asset and naming
1 parent c13cadf commit 87d5c7b

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

automations/anchor_feeds.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"decimals": 6,
118118
"base_asset": "POL (ex-MATIC)",
119119
"category": "Crypto",
120-
"risk": 1
120+
"risk": 2
121121
},
122122
{
123123
"feed_name": "SOL/USD",
@@ -157,7 +157,7 @@
157157
"decimals": 6,
158158
"base_asset": "TRON",
159159
"category": "Crypto",
160-
"risk": 3
160+
"risk": 1
161161
},
162162
{
163163
"feed_name": "LINK/USD",
@@ -373,7 +373,7 @@
373373
"decimals": 5,
374374
"base_asset": "Artificial Superintelligence Alliance",
375375
"category": "Crypto",
376-
"risk": 2
376+
"risk": 1
377377
},
378378
{
379379
"feed_name": "RENDER/USD",
@@ -401,7 +401,7 @@
401401
},
402402
{
403403
"feed_name": "TRUMP/USD",
404-
"feed_id": "0x015452554D502F5553440000000000000000000000",
404+
"feed_id": "0x015452554d502f5553440000000000000000000000",
405405
"decimals": 5,
406406
"base_asset": "Official Trump",
407407
"category": "Crypto",

automations/anchor_risk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{ "name": "USDC/USD", "index": 16, "decimals": 5, "volatility": 0 },
1919
{ "name": "USDT/USD", "index": 17, "decimals": 5, "volatility": 0 },
2020
{ "name": "XDC/USD", "index": 18, "decimals": 7, "volatility": 2 },
21-
{ "name": "TRX/USD", "index": 19, "decimals": 6, "volatility": 3 },
21+
{ "name": "TRX/USD", "index": 19, "decimals": 6, "volatility": 1 },
2222
{ "name": "LINK/USD", "index": 20, "decimals": 5, "volatility": 1 },
2323
{ "name": "ATOM/USD", "index": 21, "decimals": 5, "volatility": 1 },
2424
{ "name": "DOT/USD", "index": 22, "decimals": 5, "volatility": 1 },

automations/block_latency_feeds.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"decimals": 6,
133133
"base_asset": "POL (ex-MATIC)",
134134
"category": "Crypto",
135-
"risk": 1
135+
"risk": 2
136136
},
137137
{
138138
"feed_name": "SOL/USD",
@@ -177,7 +177,7 @@
177177
"decimals": 6,
178178
"base_asset": "TRON",
179179
"category": "Crypto",
180-
"risk": 2
180+
"risk": 1
181181
},
182182
{
183183
"feed_name": "LINK/USD",
@@ -420,7 +420,7 @@
420420
"decimals": 5,
421421
"base_asset": "Artificial Superintelligence Alliance",
422422
"category": "Crypto",
423-
"risk": 2
423+
"risk": 1
424424
},
425425
{
426426
"feed_name": "RENDER/USD",
@@ -452,7 +452,7 @@
452452
{
453453
"feed_name": "TRUMP/USD",
454454
"feed_index": 50,
455-
"feed_id": "0x015452554D502F5553440000000000000000000000",
455+
"feed_id": "0x015452554d502f5553440000000000000000000000",
456456
"decimals": 5,
457457
"base_asset": "Official Trump",
458458
"category": "Crypto",

automations/block_latency_risk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{ "name": "USDC/USD", "index": 16, "decimals": 5, "volatility": 0 },
1919
{ "name": "USDT/USD", "index": 17, "decimals": 5, "volatility": 0 },
2020
{ "name": "XDC/USD", "index": 18, "decimals": 7, "volatility": 2 },
21-
{ "name": "TRX/USD", "index": 19, "decimals": 6, "volatility": 2 },
21+
{ "name": "TRX/USD", "index": 19, "decimals": 6, "volatility": 1 },
2222
{ "name": "LINK/USD", "index": 20, "decimals": 5, "volatility": 1 },
2323
{ "name": "ATOM/USD", "index": 21, "decimals": 5, "volatility": 1 },
2424
{ "name": "DOT/USD", "index": 22, "decimals": 5, "volatility": 1 },

automations/feed_table_generator.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
logging.basicConfig(level=logging.INFO)
2020
logger = logging.getLogger(__name__)
2121

22+
HARD_CODED_FEEDS = {
23+
"FTM/USD": {
24+
"name": "Fantom",
25+
"decimals": 6,
26+
"category": "Crypto",
27+
}
28+
}
2229

2330
def get_contract_abi(contract_address: str) -> dict:
2431
"""Get the ABI for a contract from the Chain Explorer API."""
@@ -36,14 +43,12 @@ def get_contract_abi(contract_address: str) -> dict:
3643
logger.exception("Error fetching ABI for contract")
3744
sys.exit(1)
3845

39-
4046
def get_feed_id(category: str, feed_name: str) -> str:
4147
"""Convert a feed name to its structured encoded feed ID."""
4248
hex_feed_name = feed_name.encode("utf-8").hex()
4349
padded_hex_string = (category + hex_feed_name).ljust(42, "0")
4450
return f"0x{padded_hex_string}"
4551

46-
4752
def write_data_to_file(file_path: Path, data: list[dict]) -> None:
4853
"""Write a markdown table to a file."""
4954
try:
@@ -53,7 +58,6 @@ def write_data_to_file(file_path: Path, data: list[dict]) -> None:
5358
except OSError:
5459
logger.exception("Failed to write to %s: ", file_path)
5560

56-
5761
def read_data_from_file(file_path: Path) -> list[dict]:
5862
"""Write a markdown table to a file."""
5963
try:
@@ -67,7 +71,6 @@ def read_data_from_file(file_path: Path) -> list[dict]:
6771
else:
6872
return data
6973

70-
7174
def get_coins_list(pages: list) -> list[dict]:
7275
"""Get the top 500 coins from CoinGecko."""
7376
cg = CoinGeckoAPI()
@@ -81,14 +84,12 @@ def get_coins_list(pages: list) -> list[dict]:
8184
else:
8285
return coins
8386

84-
8587
def find_coin_by_symbol(coins: list[dict], symbol: str) -> dict | None:
8688
"""Find a coin in the list by its symbol."""
8789
return next(
8890
(coin for coin in coins if coin["symbol"].lower() == symbol.lower()), None
8991
)
9092

91-
9293
def generate_feed_data(
9394
feed_names: list[str],
9495
feed_risk: list[dict[str, int]],
@@ -101,6 +102,11 @@ def generate_feed_data(
101102
for idx, (name, decimal) in enumerate(zip(feed_names, decimals, strict=True)):
102103
feed_id = get_feed_id("01", name)
103104
coin = find_coin_by_symbol(coins, name.split("/")[0])
105+
106+
# Handle hardcoded feeds
107+
if name in HARD_CODED_FEEDS:
108+
coin = HARD_CODED_FEEDS[name]
109+
104110
if not coin:
105111
logger.warning("Coin %s not found in CoinGecko data", name)
106112
continue
@@ -111,8 +117,8 @@ def generate_feed_data(
111117
"feed_index": idx,
112118
"feed_id": feed_id,
113119
"decimals": decimal,
114-
"base_asset": coin["name"],
115-
"category": "Crypto",
120+
"base_asset": coin.get("name"),
121+
"category": coin.get("category", "Crypto"),
116122
"risk": feed_risk[idx].get("volatility", -1),
117123
}
118124
else:
@@ -127,7 +133,6 @@ def generate_feed_data(
127133
data.append(feed_data)
128134
return data
129135

130-
131136
if __name__ == "__main__":
132137
logging.info("Running Feed Table automation...")
133138

0 commit comments

Comments
 (0)