interlay / interbtc-squid

Subquid GraphQL schema and indexer for the Interlay and Kintsugi networks
Apache License 2.0
4 stars 7 forks source link

Track liquidations of users in the lending protocol #103

Closed nud3l closed 1 year ago

nud3l commented 1 year ago

Required data-points:

The USD amounts are not going to be stored in squid, so can be ignored.

Designs:

image

Blocker for https://github.com/interlay/interbtc-ui/issues/869

jtfirek commented 1 year ago

Am I on the right track here @daniel-savu ? This is the event I need to track:

        LiquidatedBorrow {
            liquidator: T::AccountId,
            borrower: T::AccountId,
            liquidation_currency_id: CurrencyId<T>,
            collateral_currency_id: CurrencyId<T>,
            repay_amount: BalanceOf<T>,
            collateral_underlying_amount: BalanceOf<T>,
        },

repay_amount corresponds to: Repaid debt amount and token

collateral_underlying_amount corresponds to: Seized collateral amount and token

Do you have any thoughts on how I can get cost of liquidation and Transaction id?

daniel-savu commented 1 year ago

cost of liquidation

See this Discord discussion here and here. TLDR: collateral_underlying_amount - repay_amount

Transaction id

Good question, maybe there's a way to read that from the squid metadata of the event. You can check if the transaction id is used elsewhere in squid or the UI, or maybe ask Brendon.

nud3l commented 1 year ago

The event should have a filed "extrinsic" with an id. That is the transaction id.

jtfirek commented 1 year ago

@daniel-savu @nud3l What currencies should I account for these values?

liquidation_currency_id: CurrencyId<T>,
collateral_currency_id: CurrencyId<T>,

What token would you to see cost of liquidation represented as since it seems like I will be calculating this from collateral_underlying_amount and repay_amount?

daniel-savu commented 1 year ago

What token would you to see cost of liquidation represented as

The UI should display the cost of liquidation both in USD and the collateral_currency_id