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

dev: future get_decimals #100

Open
EvolveArt opened this issue Dec 22, 2023 · 1 comment
Open

dev: future get_decimals #100

EvolveArt opened this issue Dec 22, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@EvolveArt
Copy link
Contributor

Currently get_decimals takes a 3rd argument for future DataType corresponding to the expiration timestamp, this shouldn't be necessary. We can make the assumption that all expiries have the same decimals.

@EvolveArt EvolveArt added the bug Something isn't working label Dec 22, 2023
@JordyRo1
Copy link
Contributor

JordyRo1 commented Dec 23, 2023

Considering the code for the get_decimals for a Future DataType:

 fn get_decimals(self: @ContractState, data_type: DataType) -> u32 {
     ...
     DataType::FutureEntry((
                    pair_id, expiration_timestamp
                )) => {
                    let pair = self.oracle_pairs_storage.read(pair_id);
                    assert(!pair.id.is_zero(), 'No pair found');
                    let base_cur = self.oracle_currencies_storage.read(pair.base_currency_id);
                    let quote_cur = self.oracle_currencies_storage.read(pair.quote_currency_id);
                    (base_cur, quote_cur)
                },

whatever the expiration_timestamp provided, the decimals that will be retrieved will be the one associated with the pair id for the given future. While calling get_decimals, you can just provide the pair_id for the future entry and set the expiration_timestamp to 0 and it will work fine. I can eventually change the code to

 fn get_decimals(self: @ContractState, data_type: DataType) -> u32 {
     ...
     DataType::FutureEntry((
                    pair_id, _
                )) => {
                    let pair = self.oracle_pairs_storage.read(pair_id);
                    assert(!pair.id.is_zero(), 'No pair found');
                    let base_cur = self.oracle_currencies_storage.read(pair.base_currency_id);
                    let quote_cur = self.oracle_currencies_storage.read(pair.quote_currency_id);
                    (base_cur, quote_cur)
                },

in order to make the code clearer, but it will not change the input argument. We can possibly change the input argument in order to remove the DataType parameter, but we will still have to provide the pair id and the type of data (spot, future...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants