interlay / interbtc-squid

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

Feat: store LP per account #115

Closed bvotteler closed 1 year ago

bvotteler commented 1 year ago

Resolves #111

Added new entity:

enum LiquidityProvisionType {
    DEPOSIT,
    WITHDRAWAL
}

type AccountLiquidityProvision @entity {
    id: ID!
    height: Height!
    timestamp: DateTime! @index
    amounts: [PooledAmount!]!
    accountId: String! @index
    type: LiquidityProvisionType! @index
}

Todo before ready for review:

bvotteler commented 1 year ago

Sample query:

query MyQuery {
  accountLiquidityProvisions(limit: 10) {
    accountId
    amounts {
      amount
      amountHuman
      token {
        ... on NativeToken {
          __typename
          token
        }
        ... on ForeignAsset {
          __typename
          asset
        }
        ... on StableLpToken {
          __typename
          poolId
        }
        ... on LendToken {
          __typename
          lendTokenId
        }
      }
    }
    id
    timestamp
    type
    height {
      absolute
    }
  }
}

Gives results like these:

      {
        "accountId": "a3bYNsFrPrgRmReoJMPnXbqmyfFGLHDMYuRHGerk2cUsgR6zH",
        "amounts": [
          {
            "amount": "39804614078998",
            "amountHuman": "39.804614078998",
            "token": {
              "__typename": "NativeToken",
              "token": "KSM"
            }
          },
          {
            "amount": "4749219",
            "amountHuman": "0.04749219",
            "token": {
              "__typename": "NativeToken",
              "token": "KBTC"
            }
          }
        ],
        "id": "0002749130-f5f02",
        "timestamp": "2023-04-01T17:45:06.411000Z",
        "type": "WITHDRAWAL",
        "height": {
          "active": 2167998
        }
      },
      {
        "accountId": "a3eFe9M2HbAgrQrShEDH2CEvXACtzLhSf4JGkwuT9SQ1EV4ti",
        "amounts": [
          {
            "amount": "10000000000000",
            "amountHuman": "10",
            "token": {
              "__typename": "NativeToken",
              "token": "KSM"
            }
          },
          {
            "amount": "1192593",
            "amountHuman": "0.01192593",
            "token": {
              "__typename": "NativeToken",
              "token": "KBTC"
            }
          }
        ],
        "id": "0002749178-92eff",
        "timestamp": "2023-04-01T17:54:54.868000Z",
        "type": "DEPOSIT",
        "height": {
          "active": 2168046
        }
      },