Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Scorecards Endpoint #221

Closed
gipsh opened this issue Apr 6, 2023 · 2 comments
Closed

[API] Scorecards Endpoint #221

gipsh opened this issue Apr 6, 2023 · 2 comments
Labels
api Api component v1 v1 release
Milestone

Comments

@gipsh
Copy link
Contributor

gipsh commented Apr 6, 2023

Create the endpoint for scorecards of the dashboard to return al the statistics.

 GET /api/v1/scorecards

This endpoints returns the values to render the scorecards on the UI:

{
 
         "tvl": 212111,
         "total_volume":4091193403,
         "total_tx_count":22,
         "24h_volume": 12312312,
         "24h_tx_count":  1231,
         "24h_messages": 6010
}

This endpoint doesnt support any parameters

Lets start mocking the value we cannot implement yet and use this ticket to discuss how we calculate the values.

@gipsh gipsh added api Api component v1 v1 release labels Apr 6, 2023
@walker-16 walker-16 self-assigned this Apr 10, 2023
@gipsh
Copy link
Contributor Author

gipsh commented Apr 10, 2023

For TVL look at https://wormhole.com/stats/

@walker-16 walker-16 removed their assignment Apr 10, 2023
@agodnic agodnic self-assigned this Apr 12, 2023
agodnic added a commit that referenced this issue Apr 20, 2023
### Summary

This pull request adds the `GET /api/v1/scorecards` endpoint, which is required by the wormscan frontend.

Most of the fields that this endpoint should return are being omitted because the data is not currently available on the backend. Those fields will be added iteratively as the data becomes available.

The current format of the response is:
```json
{
  "total_tx_count": "1300200",
  "24h_tx_count": "4200"
}
```

Tracking issue: #221

## Deployment details

In order to populate the `"total_tx_count"` metric, a task is needed in influxdb:

```
$ cat total-vaa-count.flux 
option task = {
	name: "Total number of emitted VAAs",
	every: 1m
}

from(bucket: "wormhole-explorer")
  |> range(start: 2018-01-01T00:00:00Z)
  |> filter(fn: (r) => r._measurement == "vaa_count")
  |> group(columns: ["_measurement"])
  |> set(key: "_measurement", value: "total_vaa_count")
  |> count()
  |> map(fn: (r) => ({r with _time: now()}))
  |> map(fn: (r) => ({r with _field: "total_vaa_count"}))
  |> to(bucket: "wormhole-explorer", org: "xlabs")

```
@agodnic
Copy link
Contributor

agodnic commented Apr 20, 2023

Current status

  • TVL - total value locked
  • Total Volume - Historic volume in USD (calculated and summarized daily)
  • Total TX - tx count (emiteed vaa's) (blocked due to database issues - can't create tasks in influxdb)
  • 24hs volume
  • 24hs transactions
  • 24hs messages (includes all: pyth, tokenbridge, others) ([API] Add 24h messages to GET /api/v1/scorecards #252) (blocked due to database issues - need a bucket with a low retention policy)

@agodnic agodnic linked a pull request Apr 21, 2023 that will close this issue
@agodnic agodnic removed their assignment Apr 24, 2023
@agodnic agodnic self-assigned this Apr 27, 2023
@hernandiegosavio hernandiegosavio added this to the v1 milestone May 3, 2023
agodnic added a commit that referenced this issue May 4, 2023
### Summary

This pull request adds volume metrics to influxdb. Also, it adds the 24h volume metric to `GET /api/v1/scorecards`.

Tracking issues: #221, #280

### Changes:
* The `parser` service no longer generates metrics for influxdb. All metrics-related code was removed from that service, that code was moved to the analytics service instead.
* New volume metrics were added to the analytics service.
* The notional cache was modified to use token names (i.e.: ticker symbols) as keys instead of chain IDs.
* The notional cache reader was moved to the `common/client/cache` package.
* A little bit of duplicated code between the cache reader and writer was removed.
* A 24h volume metric was added to `GET /api/v1/scorecards`.
* A dictionary that stores token metadata was added under `common/domain/tokenbridge.go`. More tokens will be added to it in the near future.
@agodnic agodnic removed their assignment May 5, 2023
@agodnic agodnic closed this as completed May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Api component v1 v1 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants