DjedAlliance / Djed-Solidity

Other
10 stars 5 forks source link

Added api3 oracle contract #8

Closed yogesh0509 closed 1 year ago

yogesh0509 commented 1 year ago

This is a work-in-progress pull request!!

I have added readData() function but for it to work we would also need to call setDapiName() function. Should I set it under acceptTermsOfService() function or create a different function for this task.

ceilican commented 1 year ago

Thanks for the WIP PR, @yogesh0509 !

I have added readData() function but for it to work we would also need to call setDapiName() function. Should I set it under acceptTermsOfService() function or create a different function for this task.

I am not completely sure. But:

But I am not familiarized with API3 oracles and I don't know exactly what dapiName means or how it should be configured. Therefore, I am not certain of my comments above.

What do you think?

yogesh0509 commented 1 year ago

Thanks for the WIP PR, @yogesh0509 !

I have added readData() function but for it to work we would also need to call setDapiName() function. Should I set it under acceptTermsOfService() function or create a different function for this task.

I am not completely sure. But:

  • acceptTermsOfService is about accepting the terms of service of the oracle. As far as I know, API3 oracles do not require accepting any terms of service. Therefore, our api3Oracle contract should have an acceptTermsOfService that does nothing.
  • setting the dapiName appears to be something that we need to do only once when setting up the API3 oracle reader. Therefore, I think it would be reasonable to pass the dapiName as an argument to the constructor of our api3Oracle and do any calls related to setting it up there in the body of the constructor function.

But I am not familiarized with API3 oracles and I don't know exactly what dapiName means or how it should be configured. Therefore, I am not certain of my comments above.

What do you think?

ceilican commented 1 year ago

dapiName will be different for each deployment, so we can pass it as an argument in the constructor and set it up in the there itself.

OK. Let's do it like this.

For our milkomeda testnet, the dapiName will be ADA/USD as referenced here

OK. It is unclear when API3 will deploy to the milkomeda mainnet though.

I was thinking we could consider having a deployment of Djed on Polygon using this oracle adapter to an API3 oracle on Polygon. Could you have a look on what the dapiName on Polygon would be? Would it be "MATIC/USD"? Would the adapter work on Polygon as it is? Or would it need changes?

yogesh0509 commented 1 year ago

OK. Let's do it like this.

The function setDapiName is an external function in the DapiServer.sol file which means we cannot set it up in the constructor itself. Maybe we can try calling this function in the deploy script.

yogesh0509 commented 1 year ago

I looked into the docs and I have found another way to do the same. We don't need to set up a DapiServer and can use a proxy instead to fetch data from existing dAPI. Also, we already have a dAPI deployed on polygon with the dAPI name "MATIC/USD".

I will close this pr and open a new wip PR with the changes!!