BananaCrystal / email-templates

This repository contains in-house email templates that serve as structure for our emails. Each template can be updated and modified to fit requirements.
MIT License
0 stars 0 forks source link

dashboard.rb #18

Open geekelo opened 1 month ago

geekelo commented 1 month ago

FILE

include AdminHelper

ActiveAdmin.register_page 'Dashboard' do
  menu priority: 1, label: "Dashboard #{Rails.env.development? ? 'DEV' : ''}"

  action_item :update_rates do
    if current_admin_user.super_admin? || current_admin_user.manager?
      link_to 'Update Rates', "#{ENV.fetch('DASHBOARD_APP_URL')}/admin/exchange_rates?q%5Boverride_eq%5D=true&commit=Filter&order=id_desc"
    end
  end

  action_item :process_payments do
    if current_admin_user.super_admin? || current_admin_user.manager?
      link_to 'Process Payments',
              "#{ENV.fetch('DASHBOARD_APP_URL')}/admin/payment_methods?q%5Bpayment_processor_eq%5D=bananacrystal"
    end
  end

  action_item :process_payouts do
    if current_admin_user.super_admin? || current_admin_user.manager?
      link_to 'Process Payouts',
              "#{ENV.fetch('DASHBOARD_APP_URL')}/admin/payouts?q%5Bpayment_method_payment_processor_eq%5D=bananacrystal&q%5Bstatus_eq%5D=processing&commit=Filter&payment_method_payment_processor=bananacrystal&order=created_at_desc"
    end
  end
  # action_item :loans_admin do
  #   link_to "Loans Admin #{Rails.env.development? ? 'DEV' : ''}", "#{ENV.fetch('LOANS_APP_URL')}/admin-login",
  #           target: '_blank', rel: 'noopener'
  # end

  action_item :www_admin do
    if current_admin_user.super_admin? || current_admin_user.manager?
      link_to 'WWW Admin', "#{ENV.fetch('WWW_APP_URL')}/admin-login", target: '_blank', rel: 'noopener'
    end
  end

  content title: proc { I18n.t('active_admin.dashboard') } do

    columns do
      column do
        panel "Total MATIC available for Gas Fees", class: (total_fees_in_wallet('MATIC') < Limit.gas_fee_threshold ? 'panel-red' : 'panel-blue').to_s do
          div do
            br
            text_node %(
              <div class="total-amount">
              #{number_to_currency(total_fees_in_wallet('MATIC'), unit: '', precision: 6)} MATIC <br/><br/>
              (#{number_to_currency(total_fees_in_wallet_usd('MATIC'), unit: '$')})<sup>*</sup>
              </div>
              <br>
              <br>
              <span style="font-size:1.25em;font-weight:normal;">Total Transaction Covered: ~ #{(total_fees_in_wallet('MATIC') / 0.1).to_i} transactions</span>
              <br>
              <br>
              <span style="font-size:1.00em;font-weight:normal;">*Gas fees are about 0.1 MATIC per transaction. When the MATIC balance is approaching a low amount, ask accountant/admin to reload wallet with MATIC</span>
              <br>
          ).html_safe
          end
        end
        div do
          br
        end
      end
      column do
        panel "Total BananaCrystal Fees Earned", class: 'panel-blue' do
          div do
            br
            #   text_node %(
            #     <div class="total-amount">
            #     <h3>Average daily fees (for
            #       #{sprintf("%0.0f", ( (Time.zone.now - Time.new(2023, 9, 1))/(3600*24) ) ) } days):
            #       <br><br>
            #       <span style="font-size:3.0em;font-weight:bold;">
            #         #{number_to_currency(total_bananacrystal_fees_usd_all_tokens/( (Time.zone.now - Time.new(2023, 9, 1)) /3600 ), unit: 'USDT ')}
            #       </span>
            #     </h3>
            #     <br><br>
            #     Total: #{number_to_currency(total_bananacrystal_fees_usd_all_tokens)} since #{distance_of_time_in_words_to_now(Time.new(2023, 9, 1), include_seconds: true)} ago<br><br><br>
            #     #{number_to_currency(total_bananacrystal_fees('USDT'), unit: 'USDT ')} #{number_to_currency(total_bananacrystal_fees('USDT'), unit: '$')}<br><br>
            #     #{number_to_currency(total_bananacrystal_fees('MATIC'), unit: 'MATIC ', precision: 8)} #{number_to_currency(total_bananacrystal_fees_usd('MATIC'), unit: '$')}  <br><br></div>).html_safe
          end
        end
        div do
          br
        end
      end
      column do
        panel "Total Commissions Earned by Partners", class: 'panel-gray' do
          div do
            br
            #   text_node %(
            #     <div class="total-amount">
            #     <h2>#{number_to_currency(total_user_commissions('USDT'), unit: 'USDT ')}</h2><br>
            #     #{number_to_currency(total_user_commissions('MATIC'), unit: 'DAI ', precision: 8)} #{number_to_currency(total_user_commissions_usd('MATIC'), unit: '$')}  <br><br></div>).html_safe
          end
          div do
            text_node %(<div class="text-muted">Total Partners: #{total_partners}</div>).html_safe
          end
        end
      end
      # column do
      #   panel "Total Fees Earned (Last 7 days/Last 30 days/In #{Time.now.utc.year})" do
      #     div do
      #       br
      #       text_node %(
      #         <div class="total-amount">
      #         #{number_to_currency(total_net_fees(7), unit: '$ ')} / 
      #         #{number_to_currency(total_net_fees(30), unit: '$ ')} /
      #         #{number_to_currency(total_net_fees(total_days_ytd), unit: '$ ')}
      #         </div>).html_safe
      #     end
      #   end
      # end
    end

    columns do
      column do
        panel "BananaCrystal Fees Balances" do
          div do
            br
            # text_node %(
            #   <div class="total-amount text-success">
            #   <h2>#{number_to_currency(total_fees_in_wallet('USDT'), unit: 'USDT ')}</h2><br> 
            #   #{number_to_currency(total_fees_in_wallet('MATIC'), unit: 'MATIC ', precision: 8)} #{number_to_currency(total_fees_in_wallet_usd('MATIC'), unit: '$')}  <br><br>
            #   </div>).html_safe
          end
        end
      end
      column do
        panel "Commissions Due" do
          div do
            br
            # text_node %(
            #   <div class="total-amount">
            #   <h2>#{number_to_currency(total_user_commissions_due('USDT'), unit: 'USDT ')}</h2><br>
            #   #{number_to_currency(total_user_commissions_due('MATIC'), unit: 'MATIC ', precision: 8)} #{number_to_currency(total_user_commissions_due_usd('MATIC'), unit: '$')}  <br><br>
            #   </div>).html_safe
          end
        end
      end
    end

    columns do
      column do
        panel "Verifications", 'data-panel': :collapsed do
          tag.ul do
            para "Started: #{Verification.active.started.count}"
            para "Pending: #{Verification.active.pending.count}"
            para "Accepted: #{Verification.active.accepted.count}"
            para "Denied: #{Verification.active.denied.count}"
            para "Repeated: #{Verification.active.repeated.count}"
            para "Active: #{Verification.active.all.count}"
            # pending_verifications(7).collect do |verification|
            #   tag.li(link_to("#{verification.user.name} #{verification.status} #{verification.created_at}",
            #                  admin_verification_path(verification)))
            # end.join.html_safe
          end
          div do
            link_to('see more', admin_verifications_path)
          end
        end
      end
    end
    columns do
      column do
        panel 'Payment Fees Earned' do
          div do
            br
            #       text_node %(
            #         <div class="total-amount">
            #         #{number_to_currency(total_payment_net_fees(7), unit: '$ ')} /
            #         #{number_to_currency(total_payment_net_fees(30), unit: '$ ')} /
            #         #{number_to_currency(total_payment_net_fees(total_days_ytd), unit: '$ ')}
            #         </div>).html_safe
          end
        end
      end
      column do
        panel 'Payout Fees Earned' do
          div do
            br
            # text_node %(
            #   <div class="total-amount">
            #   #{number_to_currency(total_payout_net_fees(7), unit: '$ ')} / 
            #   #{number_to_currency(total_payout_net_fees(30), unit: '$ ')} /
            #   #{number_to_currency(total_payout_net_fees(total_days_ytd), unit: '$ ')}
            #   </div>).html_safe
          end
        end
      end
      column do
        panel 'USDC Transfer Fees Earned' do
          div do
            br
            #       text_node %(
            #         <div class="total-amount">
            #         #{number_to_currency(total_transfer_net_fees(7),unit: '$ ')} /
            #         #{number_to_currency(total_transfer_net_fees(30), unit: '$ ')} /
            #         #{number_to_currency(total_transfer_net_fees(total_days_ytd), unit: '$ ')}
            #         </div>).html_safe
          end
        end
      end
    end

    columns do
      column do
        panel "Referrals (Last 7 days/Last 30 days/In #{Time.now.utc.year})" do
          div do
            br
            #       text_node %{
            #         <div class="total-amount">
            #         #{number_to_currency(total_referral_rewards(7),unit: '$ ')} /
            #         #{number_to_currency(total_referral_rewards_due(30), unit: '$ ')} <small>(due)</small> /
            #         #{number_to_currency(total_referral_rewards_due(total_days_ytd), unit: '$ ')}
            #         </div>}.html_safe
          end
        end
      end
    end

    columns do
      column do
        panel 'TOTAL DEPOSITS/PAYMENTS' do
          div do
            br
            #       text_node %(<div class="total-amount text-success">#{number_to_currency(total_payments,
            #                                                                               unit: '$ ')}</div>).html_safe
          end
        end
      end

      column do
        panel 'TOTAL WITHDRAWALS/PAYOUTS' do
          div do
            br
            # text_node %(<div class="total-amount text-danger">#{number_to_currency(total_payouts, unit: '$ ')}</div>).html_safe
          end
        end
      end
    end

    columns do
      # column do
      #   panel 'TOTAL USDC TRANSFERS' do
      #     div do
      #       br
      #       text_node %(<div class="total-amount">#{number_to_currency(total_transfers, unit: '$ ')}</div>).html_safe
      #     end
      #   end
      # end

      column do
        panel 'TOTAL CRYPTO TRANSFERS' do
          div do
            br
            # text_node %(<div class="total-amount">#{total_crypto_transfers}</div>).html_safe
          end
        end
      end
    end
    # columns do
    #   column do
    #     panel 'MASTER WALLET (USDC)' do
    #       columns do
    #         column do
    #           text_node %(<h2>In/Credits</h2>).html_safe
    #           div do
    #             br
    #             text_node %(
    #               <div class="total-amount">
    #                 Total Credits: #{number_to_currency(total_master_wallet_credits, unit: 'USDC ')}
    #               </div>).html_safe
    #             br
    #             br
    #             text_node %(
    #               <div class="total-amount">
    #                 Payouts Fees: #{number_to_currency(total_master_wallet_payout_fees_credit_transfers, unit: 'USDC ')}
    #                 <br><br><span class="help">Payouts fees are taken from the SubWallet, then Circle takes their fee from the MasterWallet</span>
    #               </div>).html_safe
    #             br
    #             br
    #             text_node %(
    #               <div class="total-amount">
    #                 Transfer Fees: #{number_to_currency(total_master_wallet_transfer_fees_credit_transfers, 
    #                                                     unit: 'USDC ')}
    #                 <br><br><span class="help">Transfer fees are taken from the SubWallet, Circle does not take any transfer fees</span>
    #               </div>).html_safe
    #             br
    #             br
    #             text_node %(
    #               <div class="total-amount">
    #                 Chargebacks: #{number_to_currency(total_master_wallet_chargeback_credit_transfers, unit: 'USDC ')}
    #                 <br><br><span class="help">Chargeback amount are taken from the SubWallet, Circle takes the chargeback amount and fee from the MasterWallet</span>
    #               </div>).html_safe
    #             br
    #             br
    #           end
    #         end
    #         column do
    #           text_node %(<h2>Out/Debits</h2>).html_safe
    #           div do
    #             br
    #             text_node %(
    #               <div class="total-amount">
    #                 Total Debits: #{number_to_currency(total_master_wallet_debits, unit: 'USDC ')}
    #               </div>).html_safe
    #             br
    #             br
    #             br
    #             text_node %(
    #               <div class="total-amount">
    #                 Payments to Subwallets: #{number_to_currency(total_master_wallet_payment_debit_transfers, 
    #                                                              unit: 'USDC ')}
    #                 <br><br><span class="help">Payments are received on the MasterWallet and then transferred to Subwallets</span>
    #               </div>).html_safe
    #             br
    #             br
    #             text_node %(
    #               <div class="total-amount">
    #                 Payouts to Banks: #{number_to_currency(total_master_wallet_payout_credit_transfers, unit: 'USDC ')}
    #                 <br><br><span class="help">Payouts are first transferred to the MasterWallet, then they are sent out from the MasterWallet to the Bank</span>
    #               </div>).html_safe
    #             br
    #             br
    #             text_node %(
    #               <div class="total-amount">
    #                 Chargeback Fees: #{number_to_currency(total_master_wallet_chargeback_fees_debit_transfers, 
    #                                                       unit: 'USDC ')}
    #                 <br><br><span class="help">Chargeback fees are taken from the MasterWallet</span>
    #               </div>).html_safe
    #             br
    #           end
    #         end
    #       end
    #     end
    #   end
    # end
    # end

    # columns do
    #  column do
    #   panel "TOTAL CURRENT BALANCE (USDC)" do
    #     div do
    #       br
    #       text_node %{<div class="total-amount">#{number_to_currency(total_wallet_balances, unit: "$ ") }</div>}.html_safe
    #     end
    #    end
    #  end
    #   column do
    #     panel "TOTAL AVAILABLE BALANCE (USDC)" do
    #       div do
    #         br
    #         text_node %{<div class="total-amount">#{number_to_currency(total_available_wallet_balances, unit: "$ ") }</div>}.html_safe
    #       end
    #     end
    #   end
  end
  # Define your dashboard sections here. Each block will be
  # rendered on the dashboard in the context of the view. So just
  # return the content which you would like to display.

  # The dashboard is organized in rows and columns, where each row
  # divides the space for its child columns equally.

  # To start a new row, open a new 'columns' block, and to start a
  # new column, open a new 'colum' block. That way, you can exactly
  # define the position for each content div.

  # == Simple Dashboard Column
  # Here is an example of a simple dashboard column
  #
  #   column do
  #     panel "Recent Posts" do
  #       content_tag :ul do
  #         Post.recent(5).collect do |post|
  #           content_tag(:li, link_to(post.title, admin_post_path(post)))
  #         end.join.html_safe
  #       end
  #     end
  #   end

  # == Render Partials
  # The block is rendererd within the context of the view, so you can
  # easily render a partial rather than build content in ruby.
  #
  #   column do
  #     panel "Recent Posts" do
  #       render 'recent_posts' # => this will render /app/views/admin/dashboard/_recent_posts.html.erb
  #     end
  #   end
end
geekelo commented 1 month ago

This code defines the dashboard for an ActiveAdmin interface. ActiveAdmin is a Ruby on Rails framework for creating elegant backends. This dashboard provides a customized interface for managing various aspects of an application, particularly related to financial operations such as updating rates, processing payments, and monitoring various metrics like gas fees, fees earned, verifications, and partner commissions.

Key Features and Functionality:

  1. Menu and Action Items:

    • The dashboard includes menu items for updating rates, processing payments, processing payouts, and accessing an external "WWW Admin" panel. These options are visible only to users with specific roles (super_admin or manager).
  2. Panels and Columns:

    • The dashboard is organized into columns and panels, each displaying key information. Examples include:
      • Total MATIC available for Gas Fees: Displays the current MATIC balance and the number of transactions it can cover.
      • Total BananaCrystal Fees Earned: Displays the total fees earned in BananaCrystal tokens.
      • Total Commissions Earned by Partners: Displays the total commissions earned by partners.
      • Verifications: Shows the count of different types of verifications (e.g., started, pending, accepted).
      • Payment Fees Earned, Payout Fees Earned, USDC Transfer Fees Earned: These are placeholders for displaying earnings related to payments, payouts, and USDC transfers.
  3. Dynamic Data Display:

    • The code utilizes methods like total_fees_in_wallet, total_bananacrystal_fees, and total_user_commissions to dynamically calculate and display financial data. The calculations appear to be related to cryptocurrency transactions and commissions.
  4. Conditional Rendering:

    • The dashboard adapts its display based on the environment (e.g., adding "DEV" to the label in development) and the role of the current user (e.g., showing action items only to certain roles).
  5. Styling and Alerts:

    • Some panels are styled differently based on conditions, such as changing the panel color to red when the MATIC balance is low.
  6. HTML Safe Content:

    • Several parts of the dashboard use html_safe to render raw HTML content within the panels. This allows for more complex formatting, such as displaying balance amounts with specific styles.

Commented Out Sections:

The code includes several commented-out sections that hint at additional features that might have been used previously or are planned for future use. These include displaying fees earned over different periods (last 7 days, last 30 days, year-to-date), and detailed transaction data for a "MASTER WALLET."

External Links:

Some action items include links that direct the user to external administrative tools or reports, such as a URL to update rates or manage payouts.

Overall, this dashboard is a comprehensive tool for managing and monitoring various aspects of the application, particularly in relation to cryptocurrency transactions and financial reporting.

geekelo commented 1 month ago

frozen_string_literal: true

HELPER

app/helpers/admin_helper.rb

module AdminHelper def admin_fee_user User.find_by(email: ENV.fetch('FEES_CRYPTO_WALLET_EMAIL')) end

def admin_fee_wallet admin_fee_user.default_crypto_api_wallet end

def total_fees_in_wallet(token) balances = admin_fee_wallet&.crypto_api_wallet_balances

return balances['available_balances'][token] if balances

0.00

end

def total_fees_in_wallet_usd(token) exchange_rate = if Rate.crypto_api.current_priced_rate(token, 'USDT') Rate.crypto_api.current_priced_rate(token, 'USDT')['USDT'] else 1.0 end total_fees_in_wallet(token) * exchange_rate if total_fees_in_wallet(token) end

def total_bananacrystal_fees_usd_all_tokens total_usd = 0.00 ['BTC', 'ETH', 'DAI','XLM'].each do |token| total_usd += total_bananacrystal_fees_usd(token) end total_usd + total_bananacrystal_fees('USDT') end

def total_bananacrystal_fees(token) MasterWalletCryptoTransferFee.complete.where(currency: token).sum(&:amount) end

def total_bananacrystal_fees_usd(token) exchange_rate = if Rate.current_priced_rate(token, 'USDT') Rate.current_priced_rate(token, 'USDT')['USDT'] else 1.0 end total_bananacrystal_fees(token) * exchange_rate if total_bananacrystal_fees(token) end

Partner Commissions

def total_partners User.active.partners.count end

def total_user_commissions(token) UserCommission.where(commission_currency: token).sum(&:commission_amount) end

def total_user_commissions_usd(token) exchange_rate = Rate.crypto_api.current_priced_rate(token, 'USDT')&.dig('USDT') || 1.0 total_user_commissions(token) * exchange_rate if total_user_commissions(token) end

def total_user_commissions_due(token) UserCommission.where(commission_currency: token, paid: false).sum(&:commission_amount) end

def total_user_commissions_due_usd(token) exchange_rate = Rate.crypto_api.current_priced_rate(token, 'USDT')&.dig('USDT') || 1.0 total_user_commissions_due(token) * exchange_rate if total_user_commissions_due(token) end

For states see https://developers.circle.com/docs/circle-api-resources

def total_payments Payment.active.sum { |payment| payment.external_status == 'paid' ? payment.gross_amount : 0 } end

def total_payouts Payout.active.sum { |payout| payout.external_status == 'complete' ? payout.gross_amount : 0 } end

def total_transfers Transfer.active.sum { |transfer| transfer.external_status == 'complete' ? transfer.gross_amount : 0 } end

Crypto Transfers

def total_crypto_transfers CryptoTransfer.complete.count end

def total_master_wallet_payment_debit_transfers MasterWalletTransfer.where(transfer_type: 'debit').sum do |transfer| transfer.complete? ? transfer.amount : 0 end end

def total_master_wallet_payout_credit_transfers MasterWalletPayoutTransfer.where(transfer_type: 'credit').sum do |transfer| transfer.complete? ? transfer.amount : 0 end end

def total_master_wallet_payout_fees_credit_transfers MasterWalletPayoutFeeTransfer.where(transfer_type: 'credit').sum do |transfer| transfer.complete? ? transfer.amount : 0 end end

def total_master_wallet_transfer_fees_credit_transfers MasterWalletTransferFeeTransfer.where(transfer_type: 'credit').sum do |transfer| transfer.complete? ? transfer.amount : 0 end end

def total_master_wallet_chargeback_credit_transfers MasterWalletChargebackTransfer.where(transfer_type: 'credit').sum do |transfer| transfer.complete? ? transfer.amount : 0 end end

def total_master_wallet_chargeback_fees_debit_transfers ChargebackItem.where(chargeback_type: '1st Chargeback').sum(:provider_fee) end

def total_master_wallet_credits total_master_wallet_payout_fees_credit_transfers + total_master_wallet_transfer_fees_credit_transfers end

def total_master_wallet_debits total_master_wallet_payment_debit_transfers + total_master_wallet_payout_credit_transfers + total_master_wallet_chargeback_fees_debit_transfers end

payments

def total_net_fees(days = 7) total_payment_net_fees(days) + total_payout_net_fees(days) + total_transfer_net_fees(days) end

def total_payment_net_fees(days = 7) total_payment_fees(days) - total_payment_provider_fees(days) end

def total_payment_fees(days = 7) Payment.where(status: 'processed', external_status: 'paid').where('created_at > ?', days.days.ago).sum(:fees) end

def total_payment_provider_fees(days = 7) Payment.where(status: 'processed', external_status: 'paid').where('created_at > ?', days.days.ago).sum(:provider_fees) end

payouts

def total_payout_net_fees(days = 7) total_payout_fees(days) - total_payout_provider_fees(days) end

def total_payout_fees(days = 7) Payout.where(status: 'processed', payout_type: 'payout', external_status: %w[complete failed]) .where('created_at > ?', days.days.ago).sum(:fees) end

def total_payout_provider_fees(days = 7) Payout.where(status: 'processed', payout_type: 'payout', external_status: %w[complete failed]) .where('created_at > ?', days.days.ago).sum(:provider_fees) end

transfers

def total_transfer_net_fees(days = 7) total_transfer_fees(days) end

def total_transfer_fees(days = 7) Transfer.where(status: 'processed', external_status: 'complete').where('created_at > ?', days.days.ago).sum(:fees) end

kyc verifications

def pending_verifications(days = 7) Verification.where(status: %w[pending]).where('created_at > ?', days.days.ago).order(created_at: :desc) end

referrals

def total_referral_rewards(days = 7) Referral.active.due.where('created_at > ?', days.days.ago).sum(:amount) end

def total_referral_rewards_due(days = 30) Referral.active.due.where('created_at > ?', days.days.ago).sum(:amount) end

def admin_list_users User.confirmed.order(:email).map { |u| ["#{u.email} - #{u.name}", u.id] }.compact end

def admin_list_verified_users User.confirmed.order(:email).map do |u| u.verification_accepted? ? ["#{u.email} - #{u.name}", u.id] : nil end.compact end

def admin_list_stores Store.where.not(status: 'inactive').all.map { |s| ["#{s.name} - owner: #{s.owner_name}", s.id] }.compact end

def admin_list_store_invoices(store) StoreInvoice.where(store: store).all.map do |i| ["#{i.external_id} - #{number_to_currency(i.amount)}", i.id] end.compact end

def admin_payment_payment_methods PaymentMethod.where(external_status: 'complete').includes(:user).sort_by(&:user).map do |pm| ["#{pm.user.email} - #{pm.name} (#{pm.description}) - #{pm.payment_method_type}", pm.id] end.compact end

def admin_payment_users User.all.map { |u| ["#{u.email} - #{u.name}", u.id] if u.verification_accepted? }.compact end

def admin_payment_wallets Wallet.where(wallet_type: 'bananacrystal_wallet').includes(:user).sort_by(&:user).map do |w| [w.id] end.compact end

def payment_method_tracking_ref(payment_method_id) payment_method = PaymentMethod.find(payment_method_id) if payment_method_id payment_method&.external_tracking_ref end

def total_days_ytd ((Time.zone.now - Time.zone.now.beginning_of_year) / (60 60 24)).truncate end end

geekelo commented 1 month ago

The AdminHelper module contains a set of methods that provide various administrative functionalities, primarily related to financial calculations, user management, and reports. In the context of the dashboard.rb file, this helper is likely included or extended to provide access to these methods, allowing the dashboard.rb to generate data for the admin dashboard. Here's a breakdown of how this helper might be used in dashboard.rb:

Example Usages in dashboard.rb

  1. Displaying Total Fees in Wallet (USD):

    # Assuming 'BTC' is the token being considered
    btc_fees_in_wallet_usd = total_fees_in_wallet_usd('BTC')

    This could be used to show how much of a specific cryptocurrency (e.g., BTC) the admin fee wallet holds in USD.

  2. Calculating Total Fees for All Tokens:

    total_fees_usd = total_bananacrystal_fees_usd_all_tokens

    This might be used to display the total USD value of fees across multiple cryptocurrencies.

  3. Displaying User Commissions:

    eth_commissions = total_user_commissions('ETH')
    eth_commissions_usd = total_user_commissions_usd('ETH')

    These methods could be used to show the total commissions earned in a specific cryptocurrency and its USD equivalent.

  4. Tracking Net Fees Over a Time Period:

    net_fees = total_net_fees(7) # Total net fees over the last 7 days

    This would be useful for showing recent net fees on the dashboard.

  5. Handling KYC Verifications:

    pending_kyc_verifications = pending_verifications(7)

    This might be used to list or count pending KYC verifications from the last 7 days.

  6. Managing Referral Rewards:

    rewards_due = total_referral_rewards_due(30) # Referral rewards due over the last 30 days

    This could be used to display the total referral rewards that are due.

  7. Listing Users, Stores, Payment Methods, Wallets, etc.:

    user_list = admin_list_users
    verified_user_list = admin_list_verified_users
    store_list = admin_list_stores

    These methods would be used to generate dropdowns or lists on the dashboard for admins to select users, stores, or payment methods.

Integration in dashboard.rb

Typically, the methods from AdminHelper would be invoked within controller actions or views that render the dashboard. For example:

class DashboardController < ApplicationController
  include AdminHelper

  def index
    @total_fees_usd = total_bananacrystal_fees_usd_all_tokens
    @net_fees = total_net_fees
    @pending_kyc = pending_verifications(7)
    @referral_rewards_due = total_referral_rewards_due(30)
    @user_list = admin_list_users
    @store_list = admin_list_stores
    # Other dashboard-related data...
  end
end

In this example, the AdminHelper methods are used to gather data that is then passed to the view for display on the dashboard.

Conclusion

The AdminHelper module provides a range of utility methods that are likely used within dashboard.rb to generate the data displayed on the admin dashboard, including financial metrics, user stats, and operational summaries.