harmonixfi / harmonix-api

0 stars 0 forks source link

Develop API for dashboard #160

Closed baonguyen1904 closed 3 months ago

baonguyen1904 commented 3 months ago

https://docs.google.com/spreadsheets/d/133zuSxHsNNvxzCF8aYe273pHSDNyZnd1xpfr1rrjCi4/edit?gid=0#gid=0

baonguyen1904 commented 3 months ago

Yield 24h, 7days, 30days calculation

To calculate total deposit in a period

  1. Find all tx in OnchainTransactionHistory table with method_id = constants.MethodID.DEPOSIT
  2. parse hex to float to get deposit amount
  3. sum all deposit amount

Yield last 24h:

now = datetime.now last_24h = now - 24h previous tvl = sum of VaultPerformanceBase.total_locked_value for each vault where datetime <= last_24h order by datetime desc current tvl = sum of latest VaultPerformanceBase.total_locked_value order by datetime desc

tvl change = current tvl - previous tvl yield 24h = tvl change - total deposit (in last 24h)