Skip to content

Commit

Permalink
Add url and boost_link support for all projects
Browse files Browse the repository at this point in the history
  • Loading branch information
shuva10v committed Jun 17, 2024
1 parent 3ed1584 commit eb89dd2
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
5 changes: 3 additions & 2 deletions backends/redoubt/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
select * from project_{project.name_safe()}
""")
PROJECTS_NAMES.append(f"""
select '{project.name}' as project
select '{project.name}' as project, '{project.url if project.url else ""}' as url
""")
PROJECTS = ",\n".join(PROJECTS)
PROJECTS_ALIASES = "\nUNION ALL\n".join(PROJECTS_ALIASES)
Expand Down Expand Up @@ -93,7 +93,7 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
group by 1
)
select project, coalesce(tx_count, 0) as tx_count, coalesce(total_users,0 )as total_users,
coalesce(median_tx, 0) as median_tx
coalesce(median_tx, 0) as median_tx, url
from project_names
left join tx_stat using(project)
left join good_users using(project)
Expand Down Expand Up @@ -215,6 +215,7 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
name=row['project'],
metrics={}
)
results[row['project']].metrics[ProjectStat.URL] = row['url']
results[row['project']].metrics[ProjectStat.APP_ONCHAIN_TOTAL_TX] = int(row['tx_count'])
results[row['project']].metrics[ProjectStat.APP_ONCHAIN_UAW] = int(row['total_users'])
results[row['project']].metrics[ProjectStat.APP_ONCHAIN_MEDIAN_TX] = int(row['median_tx'])
Expand Down
7 changes: 4 additions & 3 deletions backends/redoubt/nfts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):

projects = []
for project in config.projects:
projects.append(f"select '{project.name}' as name, '{project.address}' as address")
projects.append(f"select '{project.name}' as name, '{project.address}' as address, '{project.url}' as url")
PROJECTS = "\nunion all\n".join(projects)

SQL = f"""
Expand All @@ -57,7 +57,7 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
group by d.collection_address
order by volume desc
)
select address, name, coalesce(volume, 0) as volume from collections
select address, name, url, coalesce(volume, 0) as volume from collections
left join top using(address)
"""
logger.info(f"Generated SQL: {SQL}")
Expand All @@ -77,7 +77,8 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
results[row['name']] = ProjectStat(
name=row['name'],
metrics={
ProjectStat.NFT_VOLUME: int(row['volume'])
ProjectStat.NFT_VOLUME: int(row['volume']),
ProjectStat.URL: row['url'] if len(row['url']) > 0 else ("https://getgems.io/collection/" + row['address'])
}
)

Expand Down
6 changes: 5 additions & 1 deletion backends/redoubt/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
for project in config.projects:
PROJECTS.append(f"""
select '{project.name}' as symbol, '{project.address}' as address, {project.decimals} as decimals,
{project.is_meme} as is_meme, {project.has_boost} as has_boost
{project.is_meme} as is_meme, {project.has_boost} as has_boost, '{project.url if project.url else ""}' as url,
'{project.boost_link if project.boost_link else ""}' as boost_link
""")
PROJECTS = "\nunion all\n".join(PROJECTS)

Expand Down Expand Up @@ -155,6 +156,7 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
tol_tokens.address,
is_meme,
has_boost,
url, boost_link,
coalesce(tvl_change, 0) as tvl_change, coalesce(start_tvl, 0) as start_tvl,
coalesce(new_holders, 0) as new_holders,
coalesce(last_tvl.tvl, 0) as last_tvl,
Expand Down Expand Up @@ -196,6 +198,8 @@ def _do_calculate(self, config: SeasonConfig, dry_run: bool = False):
results[row['symbol']].metrics[ProjectStat.TOKEN_PRICE_CHANGE_NORMED] = float(row['price_delta_normed'])
results[row['symbol']].metrics[ProjectStat.TOKEN_PRICE_CHANGE_SIMPLE] = float(row['price_delta'])
results[row['symbol']].metrics[ProjectStat.TOKEN_NEW_USERS_WITH_MIN_AMOUNT] = int(row['new_holders'])
results[row['symbol']].metrics[ProjectStat.URL] = row['url']
results[row['symbol']].metrics[ProjectStat.TOKEN_BOOST_LINK] = row['boost_link']
logger.info("Tokens query finished")

return CalculationResults(ranking=results.values(), build_time=1) # TODO build time
4 changes: 4 additions & 0 deletions models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ class Token(Project):
decimals: int # token decimals
is_meme: bool = False # meme flag
has_boost: bool = False
url: str = None # project url
boost_link: str = None


@dataclass
class App(Project):
analytics_key: str # project name in tganalytics.xy
metrics: List[Metric]
url: str = None # project url

@dataclass
class NFT(Project):
address: str # token address
url: str = None # project url


@dataclass
Expand Down
1 change: 1 addition & 0 deletions models/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ProjectStat:
TOKEN_ADDRESS = 'token_address'
TOKEN_IS_MEME = 'is_meme'
TOKEN_HAS_BOOST = 'has_boost'
TOKEN_BOOST_LINK = 'boost_link'

NFT_VOLUME = 'volume'

Expand Down
1 change: 1 addition & 0 deletions projects/apps/GetGems.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
GetGems = App(
name="GetGems",
analytics_key=None,
url='https://getgems.io/',
metrics=[
NFTMarketplace("Marketplace sales", "EQBYTuYbLf8INxFtD8tQeNk5ZLy-nAX9ahQbG_yl1qQ-GEMS"),
NFTMarketplace("Marketplace sales", "EQCjk1hh952vWaE9bRguFkAhDAL5jj3xj9p0uPWrFBq_GEMS"),
Expand Down
3 changes: 2 additions & 1 deletion projects/tokens/REDO.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
name='REDO',
address='EQBZ_cafPyDr5KUTs0aNxh0ZTDhkpEZONmLJA2SNGlLm4Cko',
decimals=9,
is_meme=True
is_meme=True,
url='https://coinmarketcap.com/currencies/resistance-dog/'
)
3 changes: 2 additions & 1 deletion projects/tokens/durev.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
address='EQB02DJ0cdUD4iQDRbBv4aYG3htePHBRK1tGeRtCnatescK0',
decimals=9,
is_meme=True,
has_boost=True
has_boost=True,
boost_link='https://app.ston.fi/pools/EQAIp9JcWs87eXXuaTaDXxzQSoN6yt4pffqxy1hXWBBmguqq'
)

0 comments on commit eb89dd2

Please sign in to comment.