keep-starknet-strange / satoru

Synthetics platform for Starknet, inspired by GMX v2 design.
https://book.satoru.run/
MIT License
110 stars 73 forks source link

feat: implement the functions in the OracleUtils library pooh #511

Closed Cevedale closed 11 months ago

Cevedale commented 12 months ago

Issue Description: Implement several functions in the OracleUtils library to enhance its functionality and provide associated unit tests.

Function 1: validate_block_number_within_range

/// Validates whether a block number is within the specified range.
/// # Arguments
/// * `min_oracle_block_numbers` - The minimum oracle block numbers allowed.
/// * `max_oracle_block_numbers` - The maximum oracle block numbers allowed.
/// * `block_number` - The block number to compare.
fn validate_block_number_within_range(
    min_oracle_block_numbers: Array<u128>,
    max_oracle_block_numbers: Array<u128>,
    block_number: u128,
) {
    // Implement the logic to validate the block number here
}

/// Unit Test
#[test]
fn test_validate_block_number_within_range() {
    let min_oracle_block_numbers = [1, 2, 3];
    let max_oracle_block_numbers = [10, 20, 30];
    let block_number = 15;

    assert!(validate_block_number_within_range(min_oracle_block_numbers, max_oracle_block_numbers, block_number));
}

Function 2: is_block_number_within_range

/// Validates whether a block number is within the specified range.
/// # Arguments
/// * `min_oracle_block_numbers` - The minimum oracle block numbers allowed.
/// * `max_oracle_block_numbers` - The maximum oracle block numbers allowed.
/// * `block_number` - The block number to compare.
/// # Returns
/// True if block_number is in range, false otherwise.
fn is_block_number_within_range(
    min_oracle_block_numbers: Array<u128>,
    max_oracle_block_numbers: Array<u128>,
    block_number: u128,
) -> bool {
    // Implement the logic to check if the block number is within the range
    // Return true if it is, false otherwise
}

Function 3: get_uncompacted_price

/// Get the uncompacted price at the specified index.
/// # Arguments
/// * `compacted_prices` - The compacted prices.
/// * `index` - The index to get the decimal at.
/// # Returns
/// The price at the specified index.
fn get_uncompacted_price(compacted_prices: Array<u128>, index: u128) -> u128 {
    // Implement the logic to retrieve the uncompacted price
}

Function 4: get_uncompacted_decimal

/// Get the uncompacted decimal at the specified index.
/// # Arguments
/// * `compacted_decimals` - The compacted decimals.
/// * `index` - The index to get the decimal at.
/// # Returns
/// The decimal at the specified index.
fn get_uncompacted_decimal(compacted_decimals: Array<u128>, index: u128) -> u128 {
    // Implement the logic to retrieve the uncompacted decimal
}
akhercha commented 12 months ago

Hey, can I take this?

Cevedale commented 12 months ago

Hey, can I take this?

Sure!

sparqet commented 12 months ago

Someone is already working on it : #290

akhercha commented 12 months ago

Ah it's fine then, I'll let him finish!

Spartanldo69 commented 11 months ago

Top 🔝

Ilpauli commented 11 months ago

Woow fantastic project😉