bigshortbets / indexer

Subsquid indexer aligned with P2P Market metadata
MIT License
1 stars 4 forks source link

Recent transations based on settlement price #1

Closed Klapeyron closed 9 months ago

Klapeyron commented 10 months ago

Describe the bug Right now frontend displays recent transactions based on latest created positions on given market, which is realized by following query:

subscription SubscribePositions($marketId: String!) {
        positions(where: { market: { id_eq: $marketId } }, limit: 10, orderBy: timestamp_DESC) {
            id
            price
            timestamp
            quantity
        }
    }

The thing is, that positions once created are immediately marked to market with known oracle price, so price that is in this position does not represent creation price of the position.

Position Creation and Position M2M are two independent operations represented by separate events. Right now, for Market.PositionCreated new record is created in the database and for Market.PositionMarkedToMarket position price is updated to oracle price.

Expected behavior

Screenshots

Zrzut ekranu 2023-10-25 o 10 53 05

Additional content