Пример #1
0
    def notification_text_price_update(self, p: PriceReport, ath=False):
        title = bold('Price update') if not ath else bold(
            '🚀 A new all-time high has been achieved!')

        c_gecko_url = 'https://www.coingecko.com/en/coins/thorchain'
        c_gecko_link = link(c_gecko_url, 'RUNE')

        message = f"{title} | {c_gecko_link}\n\n"
        price = p.fair_price.real_rune_price

        pr_text = f"${price:.3f}"
        btc_price = f"₿ {p.btc_real_rune_price:.8f}"
        message += f"<b>RUNE</b> price is {code(pr_text)} ({btc_price}) now.\n"

        last_ath = p.last_ath
        if last_ath is not None and ath:
            last_ath_pr = f'{last_ath.ath_price:.2f}'
            message += f"Last ATH was ${pre(last_ath_pr)} ({format_time_ago(last_ath.ath_date)}).\n"

        time_combos = zip(('1h', '24h', '7d'),
                          (p.price_1h, p.price_24h, p.price_7d))
        for title, old_price in time_combos:
            if old_price:
                pc = calc_percent_change(old_price, price)
                message += pre(
                    f"{title.rjust(4)}:{adaptive_round_to_str(pc, True).rjust(8)} % "
                    f"{emoji_for_percent_change(pc).ljust(4).rjust(6)}") + "\n"

        fp = p.fair_price
        if fp.rank >= 1:
            message += f"Coin market cap is {bold(pretty_dollar(fp.market_cap))} (#{bold(fp.rank)})\n"

        if fp.tlv_usd >= 1:
            det_link = link(self.DET_PRICE_HELP_PAGE, 'deterministic price')
            message += (
                f"TVL of non-RUNE assets: ${pre(pretty_money(fp.tlv_usd))}\n"
                f"So {det_link} of RUNE is {code(pretty_money(fp.fair_price, prefix='$'))}\n"
                f"Speculative multiplier is {pre(x_ses(fp.fair_price, price))}\n"
            )

        return message.rstrip()
Пример #2
0
    def notification_text_price_update(self, p: PriceReport, ath=False):
        title = bold('Обновление цены') if not ath else bold(
            '🚀 Достигнуть новый исторический максимум!')

        c_gecko_url = 'https://www.coingecko.com/ru/' \
                      '%D0%9A%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D0%B2%D0%B0%D0%BB%D1%8E%D1%82%D1%8B/thorchain'
        c_gecko_link = link(c_gecko_url, 'RUNE')

        message = f"{title} | {c_gecko_link}\n\n"
        price = p.fair_price.real_rune_price

        btc_price = f"₿ {p.btc_real_rune_price:.8f}"
        pr_text = f"${price:.2f}"
        message += f"Цена <b>RUNE</b> сейчас {code(pr_text)} ({btc_price}).\n"

        last_ath = p.last_ath
        if last_ath is not None and ath:
            message += f"Последний ATH был ${last_ath.ath_price:2.f} ({format_time_ago(last_ath.ath_date)}).\n"

        time_combos = zip(('1ч.', '24ч.', '7дн.'),
                          (p.price_1h, p.price_24h, p.price_7d))
        for title, old_price in time_combos:
            if old_price:
                pc = calc_percent_change(old_price, price)
                message += pre(
                    f"{title.rjust(5)}:{adaptive_round_to_str(pc, True).rjust(8)} % "
                    f"{emoji_for_percent_change(pc).ljust(4).rjust(6)}") + "\n"

        fp = p.fair_price
        if fp.rank >= 1:
            message += f"Капитализация: {bold(pretty_dollar(fp.market_cap))} (#{bold(fp.rank)} место)\n"

        if fp.tlv_usd >= 1:
            message += (
                f"TLV (кроме RUNE): ${pre(pretty_money(fp.tlv_usd))}\n"
                f"Детерминистическая цена: {code(pretty_money(fp.fair_price, prefix='$'))}\n"
                f"Спекулятивый множитель: {pre(x_ses(fp.fair_price, price))}\n"
            )

        return message.rstrip()
Пример #3
0
    def tx_alert_text(self, tx: JobTxInfo):
        hash_str = bold(f'Hash: {tx.ident}')

        str_status = {
            tx.STATUS_ACTIVE: self.STATUS_RECEIVED,
            tx.STATUS_PENDING: self.STATUS_SENDING,
            tx.STATUS_COMPLETED: self.STATUS_COMPLETED,
        }.get(tx.status, self.STATUS_UNKNOWN)

        return (f"{hash_str}\n"
                f"\n"
                f"{bold('Direction:')} {tx.from_chain} ➔ {tx.to_chain}\n"
                f"{bold('Amount:')} {pretty_money(tx.in_tx.amount)} RUNE\n"
                f"{bold('From:')} {tx.in_tx.link}\n"
                f"{bold('To:')} {tx.out_tx.link}\n"
                f"\n"
                f"{bold(str_status)}")
Пример #4
0
    def notification_text_pool_churn(self, added_pools, removed_pools,
                                     changed_status_pools):
        message = bold('🏊 Liquidity pool churn!') + '\n\n'

        def pool_text(pool_name, status, to_status=None):
            t = link(self.pool_link(pool_name), pool_name)
            extra = '' if to_status is None else f' → {ital(to_status)}'
            return f'  • {t} ({ital(status)}{extra})'

        if added_pools:
            message += '✅ Pools added:\n' + '\n'.join(
                [pool_text(*a) for a in added_pools]) + '\n\n'
        if removed_pools:
            message += '❌ Pools removed:\n' + '\n'.join(
                [pool_text(*a) for a in removed_pools]) + '\n\n'
        if changed_status_pools:
            message += '🔄 Pools changed:\n' + '\n'.join(
                [pool_text(*a) for a in changed_status_pools]) + '\n\n'

        return message.rstrip()
Пример #5
0
    def notification_text_pool_churn(self, added_pools, removed_pools, changed_status_pools):
        message = bold('🏊 Изменения в пулах ликвидности:') + '\n\n'

        statuses = {
            'Enabled': 'включен',
            'Bootstrap': 'загружается'
        }

        def pool_text(pool_name, status, to_status=None):
            t = link(self.pool_link(pool_name), pool_name)
            extra = '' if to_status is None else f' → {ital(statuses[to_status])}'
            return f'{t} ({ital(statuses[status])}{extra})'

        if added_pools:
            message += '✅ Пулы добавлены: ' + ', '.join([pool_text(*a) for a in added_pools]) + '\n'
        if removed_pools:
            message += '❌ Пулы удалены: ' + ', '.join([pool_text(*a) for a in removed_pools]) + '\n'
        if changed_status_pools:
            message += '🔄 Пулы изменились: ' + ', '.join([pool_text(*a) for a in changed_status_pools]) + '\n'

        return message.rstrip()
Пример #6
0
 def entry_message():
     return (bold("Hello!") + f"\n\n"
             f"Commands are:\n"
             f"1. /info - get current status of the ETH bridge\n"
             f"2. /stop - unsubscribe from all pushes")