Skip to content

API: Update treasury assets #101

@ethedev

Description

@ethedev

Description

For the treasury there are multiple data collection points to account for, should be cached every day. Everything should be converted to USDC for its rate. See yam treasury assets to understand where is it located at, and be able to pull it to then save it into the database and serve it on the endpoints.

Endpoints

/treasury

  • Data should be fetched and saved on the database every 1 day at 01:00 AM UTC.
  • Should return:
    • One object.
{
  timestamp: TIMESTAMP, // time last saved when the data was collected
  values: {
    assets: {
			...
      "USDC": 400000,
      "WETH": 600000,
      "UMA": 100000,
			...
    },
    total: 1100000 // total combined assets value when the data was collected
  }
}

/treasury-history

  • Data should be fetched and saved on the database every 1 day at 01:00 AM UTC.
  • Should return:
    • Multiple objects and each is an average of 7 days data.
    • Maximum objects returned are always the past 52 objects.
{
	...
	{
	  timestamp: TIMESTAMP,
	  values: {
	    assets: {
				...
	      "USDC": 0,
	      "WETH": 0,
	      "UMA": 0,
				...
	    },
	    total: 0
	  }
	},
	{
	  timestamp: TIMESTAMP,
	  values: {
	    assets: {
				...
	      "USDC": 400,
	      "WETH": 600,
	      "UMA": 100,
				...
	    },
	    total: 1100
	  }
	},
	{
	  timestamp: TIMESTAMP,
	  values: {
	    assets: {
				...
	      "USDC": 400000,
	      "WETH": 600000,
	      "UMA": 100000,
				...
	    },
	    total: 1100000
	  }
	},
	...
}

Follow the .env.example to add or use secrets if needed.

Requirements

  • Adding call for the specified endpoints.
  • Caching the data every hour using cron to the mongo database, appending the last cached data for the /treasury endpoint calls.
  • On your PR include examples of what the endpoints are returning.
  • Use your own mongo database for testing.
  • Documenting the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions