Price Fetch Method #1

Open
opened 2024-03-07 21:54:10 +00:00 by p1r0 · 0 comments
Owner

Create a file named fetchMarkets.ts that includes a ethers instance, the markets.ts file and its called in the main.ts file for testing.

Based on two parameters a currency input and currency units (100, USD) you get a json with all the specified output of the markets.ts and unit equivalent. IF there is not input () in the call just return the latest round of all the markets.ts based on 1 ETH as default parameter.

{
    "BTC": {
        "price": "",
        "round": "",
        "date": "",
        "decimals": ""
    },
    
    "ETH": {
        "price": "",
        "round": "",
        "date": "",
        "decimals": ""
        },
	"USD": {
        "price": 1,
        "round":"",
        "date": "",
        "decimals": ""
    }
    "CNY": {
        ...
        },
    "EUR": {
        ...
        }
    ...
}

1.Code Price Fetch Method, Example output.

The Price Fetch method (1.Code) specifies how the output should be returned fortmat, the currencies MUST BE all the currencies that are specified in the markets.ts and the requested.

  • The method MUST calculate the exact amount of BTC, ETH, EUR and all the specified in the markets.ts based on the quantity and currency provided as input.

  • The method MUST return the conversion prices from the previous calcultation and its dates in a json format.

  • The price must include all the possible decimals resolutions

Recommendations: you can use a for cycle in the markets.json or do a recursive method call with unit as parameter
Recomendations1: you can first verify and multiply input units before fetching the data.
Note: since all the oracle contracts use the same ABI we can keep it inside the method definition.

References

Create a file named `fetchMarkets.ts` that includes a ethers instance, the markets.ts file and its called in the main.ts file for testing. Based on two parameters a currency input and currency units (100, USD) you get a json with all the specified output of the markets.ts and unit equivalent. IF there is not input () in the call just return the latest round of all the markets.ts based on 1 ETH as default parameter. ```json { "BTC": { "price": "", "round": "", "date": "", "decimals": "" }, "ETH": { "price": "", "round": "", "date": "", "decimals": "" }, "USD": { "price": 1, "round":"", "date": "", "decimals": "" } "CNY": { ... }, "EUR": { ... } ... } ``` 1.Code Price Fetch Method, Example output. The Price Fetch method (1.Code) specifies how the output should be returned fortmat, the currencies MUST BE all the currencies that are specified in the markets.ts and the requested. - [ ] The method MUST calculate the exact amount of BTC, ETH, EUR and all the specified in the markets.ts based on the quantity and currency provided as input. - [ ] The method MUST return the conversion prices from the previous calcultation and its dates in a json format. - [ ] The price must include all the possible decimals resolutions > Recommendations: you can use a for cycle in the markets.json or do a recursive method call with unit as parameter > Recomendations1: you can first verify and multiply input units before fetching the data. > Note: since all the oracle contracts use the same ABI we can keep it inside the method definition. ### References - [Fetch Data](https://docs.chain.link/data-feeds/historical-data#getrounddata-return-values)
p1r0 added the
enhancement
label 2024-03-07 21:54:10 +00:00
p1r0 added this to the dmarketsDB project 2024-03-07 21:58:43 +00:00
Sign in to join this conversation.
No description provided.