interlay / interbtc-squid

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

Add vaults to squid #51

Open nud3l opened 1 year ago

nud3l commented 1 year ago

Goal

Add a vaults endpoint where we can the data available at https://app.interlay.io/dashboard/vaults

Implementation

Vaults have:

Replaces

image

jtfirek commented 1 year ago

Would you like me to add onto the existing vault object in squid or is should this be an entirely new object? https://github.com/interlay/interbtc-squid/blob/e0ed448a63df2383f805f366066ab1979b6feb95/schema.graphql#L51-L59 If adding to this existing is this what you are looking for?

type Vault @entity {
    id: ID!
    accountId: String! @index
    collateralToken: Currency!
    collateralAmount: BigInt!
    wrappedToken: Currency!
    pendingBtcAmount: BigInt!
    collateralization: String!
    statusIssuing: Bool!
    statusCollateral: Bool!
    registrationBlock: Height!
    registrationTimestamp: DateTime!
    lastActivity: Height
}
nud3l commented 1 year ago

Adding it to the existing vault object is the right approach. Thank you!

jtfirek commented 1 year ago

Sounds good!

jtfirek commented 1 year ago

@nud3l The locked collateral in the dashboard displays the collateral as DOT. Is the collateral in the multi-collateral system all converted to DOT equivalent value for displaying here?

nud3l commented 1 year ago

No, there are individual dashboards for each collateral asset. The DOT is just due to Interlay only having DOT as collateral right now. See Kintsugi as an example: https://kintsugi.interlay.io/dashboard/vaults

There's then a summary dashboard that converts all collateral assets to USD but that would be an add on and I'd consider it out of scope for this PR.

jtfirek commented 1 year ago

Ok thanks that clears up all my confusion.

jtfirek commented 1 year ago

Looks like the proposed goal does not included locked btc amount just the a pending btc amount. I feel that we need locked btc to calculation the collateratlization: collateralization = colleratalAmount (converted to btc value) / locked btc I have added this to the schema, but lmk if this is not needed/wanted.

nud3l commented 1 year ago

great catch, I forgot to add it.

jtfirek commented 1 year ago

@nud3l For the status issuing, Is this referring to status | VaultStatus | Current status of the vault (Active, Liquidated, CommittedTheft) from the iBTC spec?

nud3l commented 1 year ago

Almost:

StatusIssuing - Active or Inactive (just that part basically: https://github.com/interlay/interbtc/blob/master/crates/vault-registry/src/types.rs#L132)

StatusCollateral - AboveSecureThreshold, BelowSecureThreshold, BelowPremiumRedeemThreshold, Liquidated. The parachain just tracks if a vault is liquidated but the UI/frontend would also track if a vault is above or below certain collateral thresholds as determined by the ones here: https://docs.interlay.io/#/vault/overview?id=collateral-thresholds

jtfirek commented 1 year ago

Ok I see Active is a bool within the VaultStatus struct