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: Update treasury assets #101

Open
ethedev opened this issue Jun 12, 2022 · 0 comments
Open

API: Update treasury assets #101

ethedev opened this issue Jun 12, 2022 · 0 comments

Comments

@ethedev
Copy link
Member

ethedev commented Jun 12, 2022

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant