Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): add hackathon content in devhub #558

Merged
merged 8 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion automations/anchor_feeds.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
{
"feed_name": "WIF/USD",
"feed_id": "0x015749462f55534400000000000000000000000000",
"decimals": 5,
"decimals": 6,
"base_asset": "dogwifhat",
"category": "Crypto",
"risk": 3
Expand Down Expand Up @@ -406,5 +406,61 @@
"base_asset": "Official Trump",
"category": "Crypto",
"risk": 4
},
{
"feed_name": "USDX/USD",
"feed_id": "0x01555344582f555344000000000000000000000000",
"decimals": 5,
"base_asset": "Hex Trust USD",
"category": "Crypto",
"risk": 0
},
{
"feed_name": "JOULE/USD",
"feed_id": "0x014a4f554c452f5553440000000000000000000000",
"decimals": 7,
"base_asset": "Joule",
"category": "Crypto",
"risk": 4
},
{
"feed_name": "HBAR/USD",
"feed_id": "0x01484241522f555344000000000000000000000000",
"decimals": 6,
"base_asset": "Hedera",
"category": "Crypto",
"risk": 3
},
{
"feed_name": "PENGU/USD",
"feed_id": "0x0150454e47552f5553440000000000000000000000",
"decimals": 7,
"base_asset": "Pudgy Penguins",
"category": "Crypto",
"risk": 3
},
{
"feed_name": "HYPE/USD",
"feed_id": "0x01485950452f555344000000000000000000000000",
"decimals": 5,
"base_asset": "Hyperliquid",
"category": "Crypto",
"risk": 3
},
{
"feed_name": "APT/USD",
"feed_id": "0x014150542f55534400000000000000000000000000",
"decimals": 5,
"base_asset": "Aptos",
"category": "Crypto",
"risk": 2
},
{
"feed_name": "PAXG/USD",
"feed_id": "0x01504158472f555344000000000000000000000000",
"decimals": 3,
"base_asset": "PAX Gold",
"category": "Crypto",
"risk": 1
}
]
9 changes: 8 additions & 1 deletion automations/anchor_risk.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@
{ "name": "RENDER/USD", "index": 47, "decimals": 5, "volatility": 1 },
{ "name": "NOT/USD", "index": 48, "decimals": 7, "volatility": 2},
{ "name": "RUNE/USD", "index": 49, "decimals": 5, "volatility": 2 },
{ "name": "TRUMP/USD", "index": 50, "decimals": 5, "volatility": 4 }
{ "name": "TRUMP/USD", "index": 50, "decimals": 5, "volatility": 4 },
{ "name": "USDX/USD", "index": 51, "decimals": 5, "volatility": 0 },
{ "name": "JOULE/USD", "index": 52, "decimals": 5, "volatility": 4 },
{ "name": "HBAR/USD", "index": 53, "decimals": 5, "volatility": 3 },
{ "name": "PENGU/USD", "index": 54, "decimals": 6, "volatility": 3 },
{ "name": "HYPE/USD", "index": 55, "decimals": 5, "volatility": 3 },
{ "name": "APT/USD", "index": 56, "decimals": 5, "volatility": 2 },
{ "name": "PAXG/USD", "index": 57, "decimals": 3, "volatility": 1 }
]
65 changes: 64 additions & 1 deletion automations/block_latency_feeds.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
"feed_name": "WIF/USD",
"feed_index": 32,
"feed_id": "0x015749462f55534400000000000000000000000000",
"decimals": 5,
"decimals": 6,
"base_asset": "dogwifhat",
"category": "Crypto",
"risk": 3
Expand Down Expand Up @@ -457,5 +457,68 @@
"base_asset": "Official Trump",
"category": "Crypto",
"risk": 4
},
{
"feed_name": "USDX/USD",
"feed_index": 51,
"feed_id": "0x01555344582f555344000000000000000000000000",
"decimals": 5,
"base_asset": "Hex Trust USD",
"category": "Crypto",
"risk": 0
},
{
"feed_name": "JOULE/USD",
"feed_index": 52,
"feed_id": "0x014a4f554c452f5553440000000000000000000000",
"decimals": 7,
"base_asset": "Joule",
"category": "Crypto",
"risk": 4
},
{
"feed_name": "HBAR/USD",
"feed_index": 53,
"feed_id": "0x01484241522f555344000000000000000000000000",
"decimals": 6,
"base_asset": "Hedera",
"category": "Crypto",
"risk": 3
},
{
"feed_name": "PENGU/USD",
"feed_index": 54,
"feed_id": "0x0150454e47552f5553440000000000000000000000",
"decimals": 7,
"base_asset": "Pudgy Penguins",
"category": "Crypto",
"risk": 3
},
{
"feed_name": "HYPE/USD",
"feed_index": 55,
"feed_id": "0x01485950452f555344000000000000000000000000",
"decimals": 5,
"base_asset": "Hyperliquid",
"category": "Crypto",
"risk": 3
},
{
"feed_name": "APT/USD",
"feed_index": 56,
"feed_id": "0x014150542f55534400000000000000000000000000",
"decimals": 5,
"base_asset": "Aptos",
"category": "Crypto",
"risk": 2
},
{
"feed_name": "PAXG/USD",
"feed_index": 57,
"feed_id": "0x01504158472f555344000000000000000000000000",
"decimals": 3,
"base_asset": "PAX Gold",
"category": "Crypto",
"risk": 1
}
]
9 changes: 8 additions & 1 deletion automations/block_latency_risk.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@
{ "name": "RENDER/USD", "index": 47, "decimals": 5, "volatility": 1 },
{ "name": "NOT/USD", "index": 48, "decimals": 7, "volatility": 2},
{ "name": "RUNE/USD", "index": 49, "decimals": 5, "volatility": 2 },
{ "name": "TRUMP/USD", "index": 50, "decimals": 5, "volatility": 4 }
{ "name": "TRUMP/USD", "index": 50, "decimals": 5, "volatility": 4 },
{ "name": "USDX/USD", "index": 51, "decimals": 5, "volatility": 0 },
{ "name": "JOULE/USD", "index": 51, "decimals": 5, "volatility": 4 },
{ "name": "HBAR/USD", "index": 53, "decimals": 5, "volatility": 3 },
{ "name": "PENGU/USD", "index": 54, "decimals": 6, "volatility": 3 },
{ "name": "HYPE/USD", "index": 55, "decimals": 5, "volatility": 3 },
{ "name": "APT/USD", "index": 56, "decimals": 5, "volatility": 2 },
{ "name": "PAXG/USD", "index": 57, "decimals": 3, "volatility": 1 }
]
32 changes: 25 additions & 7 deletions automations/feed_table_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import sys
import time
from pathlib import Path

import requests
Expand All @@ -24,10 +25,19 @@
"name": "Fantom",
"decimals": 6,
"category": "Crypto",
},
"USDX/USD": {
"name": "Hex Trust USD",
"decimals": 5,
"category": "Crypto",
}
}


class FeedRiskNotFoundError(Exception):
pass


def get_contract_abi(contract_address: str) -> dict:
"""Get the ABI for a contract from the Chain Explorer API."""
params = {"module": "contract", "action": "getabi", "address": contract_address}
Expand Down Expand Up @@ -76,13 +86,15 @@ def read_data_from_file(file_path: Path) -> list[dict]:
return data


def get_coins_list(pages: list) -> list[dict]:
def get_coins_list(num_pages: int) -> list[dict]:
"""Get the top 500 coins from CoinGecko."""
cg = CoinGeckoAPI()
coins = []
logger.info("Querying %i pages on CoinGecko...", num_pages)
try:
for page in pages:
for page in range(1, num_pages + 1):
coins += cg.get_coins_markets(vs_currency="usd", per_page=250, page=page)
time.sleep(0.5)
except Exception:
logger.exception("Error fetching coins from CoinGecko")
sys.exit(1)
Expand Down Expand Up @@ -118,6 +130,12 @@ def generate_feed_data(
logger.warning("Coin %s not found in CoinGecko data", name)
continue

try:
risk = feed_risk[idx].get("volatility", -1)
except IndexError as e:
msg = f"Unable to find risk for {name}"
raise FeedRiskNotFoundError(msg) from e

if include_index:
feed_data = {
"feed_name": name,
Expand All @@ -126,16 +144,16 @@ def generate_feed_data(
"decimals": decimal,
"base_asset": coin.get("name"),
"category": coin.get("category", "Crypto"),
"risk": feed_risk[idx].get("volatility", -1),
"risk": risk,
}
else:
feed_data = {
"feed_name": name,
"feed_id": feed_id,
"decimals": decimal,
"base_asset": coin["name"],
"base_asset": coin.get("name"),
"category": "Crypto",
"risk": feed_risk[idx].get("volatility", -1),
"risk": risk,
}
data.append(feed_data)
return data
Expand Down Expand Up @@ -171,8 +189,8 @@ def generate_feed_data(
decimals = block_latency_feeds[2]
logger.debug("Found %d block-latency feeds", len(feed_names))

# Query CoinGecko for top 750 coins
coins_list = get_coins_list(pages=[1, 2, 3])
# Query CoinGecko for top N pages, where each page has 250 coins
coins_list = get_coins_list(num_pages=8)

# Write block-latency feeds to file
block_latency_risk = read_data_from_file(BLOCK_LATENCY_RISK_PATH)
Expand Down
4 changes: 2 additions & 2 deletions automations/solidity_reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@
},
{
"name": "FtsoFeedDecimals",
"address": "0x681C1Bc09b64e8e0EEa9d40E480B08Ab6c3FeCE3"
"address": "0x9391f16c2034CCe3cC139e9eE30E080EF524D4a9"
},
{
"name": "FtsoFeedPublisher",
Expand Down Expand Up @@ -832,7 +832,7 @@
},
{
"name": "FtsoFeedDecimals",
"address": "0x7Ec85276c1b9d53b9ca46A6f307FB8C68f6E7921"
"address": "0xC24bca265667CD2ABC412554FD39722cbaf78a4f"
},
{
"name": "FtsoFeedPublisher",
Expand Down
Loading
Loading