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

Initial Contracts #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Initial Contracts #1

wants to merge 5 commits into from

Conversation

JGcarv
Copy link

@JGcarv JGcarv commented Sep 16, 2020

Hello!

I just set the truffle project and created the basic contracts for the conector.

@aalavandhan
Copy link
Member

Looks good 👍

Will leave it to @ahnaguib to give final approval.

function pushTellor() external {
(bool retrieved, uint256 value, uint256 _time) = getTellorData();

require(_time > now - medianOracle.reportExpirationTimeSec() && retrieved, "Tellor value too old");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for not relying on pushData() failing instead of checking here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that getData() relies on the time that the payload was added to the market-oracle contract, while here we check the time the data was added to the Tellor system. We could theoretically take an old Tellor value and push a report, which will be accepted on getData.

It's another layer of protection to ensure the data is fresh.


function verifyTellorReports() external {
//most recent tellor report is in dispute, so let's purge it
if(tellor.retrieveData(TellorID, tellorReport.time0) == 0 || tellor.retrieveData(TellorID,tellorReport.time1) == 0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about if one of them is valid, it pushes it after purging?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will add that to the job. After we purge a report, we'll check if we have a valid value and push it again

function reportExpirationTimeSec() external returns(uint256);
function pushReport(uint256 payload) external;
function purgeReports() external;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add new lines to all the files to keep the linters happy?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


function pushTellor() external {
(bool retrieved, uint256 value, uint256 _time) = getTellorData();
//Saving _time in a storage value to quickly verify disputes later
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey am I missing something or should the report only get pushed if retrieved is true?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrieved is true if the value count is greater than 0. TellorID 10 has months of data with a value count of over 4500, so retrieved will always be true when using the current Tellor contracts.

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

Successfully merging this pull request may close these issues.

4 participants