Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 758 Bytes

README.md

File metadata and controls

25 lines (18 loc) · 758 Bytes

Pragma Cairo SDK

The easiest way to import all dependencies needed to interact with Pragma on Starknet.

Usage

scarb add pragma_lib --git https://github.com/astraly-labs/pragma-lib

BTC/USD Spot Median Price

use pragma_lib::abi::{IPragmaABIDispatcher, IPragmaABIDispatcherTrait};
use pragma_lib::types::{AggregationMode, DataType, PragmaPricesResponse};
use starknet::ContractAddress;

const KEY: felt252 = 'BTC/USD';

fn get_asset_price_median(oracle_address: ContractAddress, asset : DataType) -> u128 { 
    let oracle_dispatcher = IOracleABIDispatcher{contract_address : oracle_address};
    let output: PragmaPricesResponse = oracle_dispatcher.get_data(asset, AggregationMode::Median(()));
    return output.price;
}