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 function in the `reader` contract. #428

Closed Sk8erboi84 closed 1 year ago

Sk8erboi84 commented 1 year ago

Description

Implement the get_market function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_market(data_store: IDataStoreDispatcher, key: ContractAddress) -> Market;

Implement the get_market_by_salt function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_market_by_salt(data_store: IDataStoreDispatcher, salt: felt252) -> Market;

Implement the get_deposit function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_deposit(data_store: IDataStoreDispatcher, key: felt252) -> Deposit;

Implement the get_withdrawl function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_withdrawl(data_store: IDataStoreDispatcher, key: felt252) -> Withdrawal

Implement the get_position function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_position(data_store: IDataStoreDispatcher, key: felt252) -> Position;

Implement the get_order function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_order(data_store: IDataStoreDispatcher, key: felt252) -> Order;

Implement the get_position_pnl_usd function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_position_pnl_usd(
    data_store: IDataStoreDispatcher,
    market: Market,
    prices: MarketPrices,
    position_key: felt252,
    size_delta_usd: u128
) -> (i128, i128, u128)

Implement the get_account_positions function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_account_positions(
    data_store: IDataStoreDispatcher, account: ContractAddress, start: u128, end: u128
) -> Array<Position>

Implement the get_account_position_info_list function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_account_position_info_list(
    data_store: IDataStoreDispatcher,
    referral_storage: IReferralStorageDispatcher,
    position_keys: Array<felt252>,
    prices: Array<MarketPrices>,
    ui_fee_receiver: ContractAddress
) -> Array<PositionInfo>;

Implement the get_position_info function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_position_info(
    data_store: IDataStoreDispatcher,
    referral_storage: IReferralStorageDispatcher,
    position_key: felt252,
    prices: MarketPrices,
    size_delta_usd: u128,
    ui_fee_receiver: ContractAddress,
    use_position_size_as_size_delta_usd: bool
) -> PositionInfo;

Implement the get_account_orders function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_account_orders(
    data_store: IDataStoreDispatcher, account: ContractAddress, start: u128, end: u128
) -> Array<Order>;

Implement the get_markets function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_markets(data_store: IDataStoreDispatcher, start: u128, end: u128) -> Array<Market>;

Implement the get_market_info_list function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_market_info_list(
    data_store: IDataStoreDispatcher, market_price_list: Array<MarketPrices>, start: u128, end: u128
) -> Array<MarketInfo>;

Implement the get_market_info function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_market_info(
    data_store: IDataStoreDispatcher, prices: MarketPrices, market_key: ContractAddress
) -> MarketInfo;

Implement the get_market_token_price function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_market_token_price(
    data_store: IDataStoreDispatcher,
    market: Market,
    index_token_price: Price,
    long_token_price: Price,
    short_token_price: Price,
    pnl_factor_type: felt252,
    maximize: bool
) -> (i128, MarketPoolValueInfo);

Implement the get_net_pnl function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_net_pnl(
    data_store: IDataStoreDispatcher, market: Market, index_token_price: Price, maximize: bool
) -> u128;

Implement the get_pnl function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_pnl(
    data_store: IDataStoreDispatcher,
    market: Market,
    index_token_price: Price,
    is_long: bool,
    maximize: bool
) -> u128;

Implement the get_open_interest_with_pnl function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_open_interest_with_pnl(
    data_store: IDataStoreDispatcher,
    market: Market,
    index_token_price: Price,
    is_long: bool,
    maximize: bool
) -> i128

Implement the get_pnl_to_pool_factor function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_pnl_to_pool_factor(
    data_store: IDataStoreDispatcher,
    market_address: ContractAddress,
    prices: MarketPrices,
    is_long: bool,
    maximize: bool
) -> i128

Implement the get_swap_amount_out function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_swap_amount_out(
    data_store: IDataStoreDispatcher,
    market: Market,
    prices: MarketPrices,
    token_in: ContractAddress,
    amount_in: u128,
    ui_fee_receiver: ContractAddress
) -> (u128, u128, SwapFees)

Implement the get_virtual_inventory function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_virtual_inventory(data_store: IDataStoreDispatcher, market: Market) -> VirtualInventory;

Implement the get_execution_price function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_execution_price(
    data_store: IDataStoreDispatcher,
    market_key: ContractAddress,
    index_token_price: Price,
    position_size_in_usd: u128,
    position_size_in_token: u128,
    size_delta_usd: u128, // TODO replace with i128 when it derives Store
    is_long: bool
) -> ExecutionPriceResult

Implement the get_swap_price_impact function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_swap_price_impact(
    data_store: IDataStoreDispatcher,
    market_key: ContractAddress,
    token_in: ContractAddress,
    token_out: ContractAddress,
    amount_in: u128,
    token_in_price: Price,
    token_out_price: Price
) -> (i128, i128)

Implement the get_adl_state function in the Reader contract.

File: src/reader/reader.cairo.

Function signature:

fn get_adl_state(
    data_store: IDataStoreDispatcher, market: ContractAddress, is_long: bool, prices: MarketPrices
) -> (u128, bool, i128, u128);

Acceptance criteria

Resources

tevrat-aksoy commented 1 year ago

I can take this

sparqet commented 1 year ago

Assigned !