-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prettify /pool command output, fix problematic pools
- Loading branch information
1 parent
a7f222c
commit 593b882
Showing
8 changed files
with
117 additions
and
105 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
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
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 |
---|---|---|
@@ -1,91 +1,53 @@ | ||
import discord | ||
from ..data import LiquidityPool | ||
from ..helpers import format_percentage, format_currency | ||
from ..helpers import format_percentage, format_currency, make_app_url | ||
from ..settings import APP_BASE_URL | ||
|
||
|
||
class PoolStats: | ||
async def render(self, pool: LiquidityPool, tvl: float): | ||
embed = discord.Embed( | ||
title=f"{pool.symbol}", | ||
description=" | ".join( | ||
[ | ||
f"{'Stable Pool' if pool.is_stable else 'Volatile Pool'}", | ||
f"Trading fee: {format_percentage(pool.pool_fee_percentage)}", | ||
f"TVL: ~{format_currency(tvl)}", | ||
f"APR: {format_percentage(pool.apr(tvl))}", | ||
] | ||
), | ||
color=0xFFFFFF, | ||
) | ||
|
||
embed.add_field(name="", value="", inline=False) | ||
|
||
# Volume | ||
|
||
embed.add_field(name="Volume", value="", inline=False) | ||
embed.add_field( | ||
name=" ", | ||
value=format_currency(pool.volume), | ||
inline=True, | ||
) | ||
embed.add_field( | ||
name=" ", | ||
value=format_currency( | ||
pool.token0_volume, symbol=pool.token0.symbol, prefix=False | ||
), | ||
inline=True, | ||
) | ||
embed.add_field( | ||
name=" ", | ||
value=format_currency( | ||
pool.token1_volume, symbol=pool.token1.symbol, prefix=False | ||
), | ||
inline=True, | ||
) | ||
embed.add_field(name="", value="", inline=False) | ||
|
||
# Fees | ||
|
||
embed.add_field(name="Fees", value="", inline=False) | ||
embed.add_field( | ||
name=" ", | ||
value=format_currency( | ||
pool.token0_fees.amount_in_stable + pool.token1_fees.amount_in_stable | ||
), | ||
inline=True, | ||
) | ||
embed.add_field( | ||
name=" ", | ||
value=format_currency( | ||
pool.token0_fees.amount, symbol=pool.token0.symbol, prefix=False | ||
), | ||
inline=True, | ||
) | ||
embed.add_field( | ||
name=" ", | ||
value=format_currency( | ||
pool.token1_fees.amount, symbol=pool.token1.symbol, prefix=False | ||
), | ||
inline=True, | ||
) | ||
embed.add_field(name="", value="", inline=False) | ||
|
||
# Pool balance | ||
|
||
embed.add_field(name="Pool Balance", value="", inline=False) | ||
embed.add_field( | ||
name=" ", | ||
value=format_currency( | ||
pool.reserve0.amount, symbol=pool.token0.symbol, prefix=False | ||
), | ||
inline=True, | ||
async def render(self, pool: LiquidityPool, tvl: float) -> str: | ||
token0_fees = pool.token0_fees.amount_in_stable if pool.token0_fees else 0 | ||
token1_fees = pool.token1_fees.amount_in_stable if pool.token1_fees else 0 | ||
|
||
template_args = { | ||
"pool_symbol": pool.symbol, | ||
"pool_fee_percentage": format_percentage(pool.pool_fee_percentage), | ||
"apr": format_percentage(pool.apr(tvl)), | ||
"tvl": format_currency(tvl), | ||
"token0_volume": format_currency( | ||
pool.reserve0.amount if pool.reserve0 else 0, | ||
symbol=pool.token0.symbol, | ||
prefix=False, | ||
), | ||
"token1_volume": format_currency( | ||
pool.reserve1.amount if pool.reserve1 else 0, | ||
symbol=pool.token1.symbol, | ||
prefix=False, | ||
), | ||
"volume": format_currency(pool.volume), | ||
"fees": format_currency(token0_fees + token1_fees), | ||
"deposit_url": make_app_url( | ||
APP_BASE_URL, | ||
"/deposit", | ||
{ | ||
"token0": pool.token0.token_address, | ||
"token1": pool.token1.token_address, | ||
"stable": str(pool.is_stable).lower(), | ||
}, | ||
), | ||
"incentivize_url": make_app_url( | ||
APP_BASE_URL, "/incentivize", {"pool": pool.lp} | ||
), | ||
} | ||
|
||
return """ | ||
> **{pool_symbol} ● Fee {pool_fee_percentage} ● {apr} APR** | ||
> - ~{tvl} TVL | ||
> - {token0_volume} | ||
> - {token1_volume} | ||
> - ~{volume} volume this epoch | ||
> - ~{fees} fees this epoch | ||
> | ||
> [Deposit 🐖]({deposit_url}) ● [Incentivize 🙋]({incentivize_url}) | ||
""".format( | ||
**template_args | ||
) | ||
embed.add_field( | ||
name=" ", | ||
value=format_currency( | ||
pool.reserve1.amount, symbol=pool.token1.symbol, prefix=False | ||
), | ||
inline=True, | ||
) | ||
|
||
return embed |
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