-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve test stability by optional pricing source (#490)
* feat: improve test stability by optional pricing source * add helper function to process each pool (cherry picked from commit f1efd83)
- Loading branch information
1 parent
8823a64
commit b834cc7
Showing
5 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import requests | ||
|
||
ASSET_LIST_URL = "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/osmosis-1/generated/frontend/assetlist.json" | ||
|
||
class AssetListService: | ||
# cache the asset list, key => coinMinimalDenom, value => {symbol, decimals, coingeckoId} | ||
asset_map = {} | ||
|
||
# This is a simple service that fetches the asset list from the asset list URL | ||
def get_asset_metadata(self, denom): | ||
if self.asset_map == {}: | ||
response = requests.get(ASSET_LIST_URL) | ||
if response.status_code != 200: | ||
raise Exception(f"Error fetching asset list: {response.text}") | ||
asset_list = response.json().get("assets", []) | ||
for asset in asset_list: | ||
coinMinimalDenom = asset.get("coinMinimalDenom") | ||
symbol = asset.get("symbol") | ||
decimals = asset.get("decimals") | ||
coingeckoId = asset.get("coingeckoId") | ||
self.asset_map[coinMinimalDenom] = { | ||
"symbol": symbol, | ||
"decimals": decimals, | ||
"coingeckoId": coingeckoId | ||
} | ||
return self.asset_map.get(denom, None) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters