interlay / interbtc-api

interBTC TypeScript SDK
https://app.interlay.io/
Apache License 2.0
25 stars 21 forks source link

Feat: Query locked DOT, VDOT balances #732

Closed bvotteler closed 5 months ago

bvotteler commented 6 months ago

A script to gather locked balances for vaults and lending protocol via reserved amounts in tokens.account.

Usage: From project root

npx tsx ./scripts/locked-dot-vdot.ts [options]

Options:

$ npx tsx ./scripts/locked-dot-vdot.ts --help
Options:
      --help          Show help                                        [boolean]
      --version       Show version number                              [boolean]
  -b, --block-hash    Block hash at which to query, defaults to latest block.
                      Must be prefixed with '0x' and have a length of 66.
                                                                        [string]
  -o, --output-file   Which file to write json results to, defaults to
                      'output-{blockhash}.json'                         [string]
  -p, --print-only    Do not write results to file, only log to console,
                      defaults to false.              [boolean] [default: false]

To run specifically for the last block on March 31, 2024 (UTC)

The blockhash is 0xb541ad774ba9e8d35d9551a3b6580e813990cd17abe1d8dcc1bde3a0d6f43348

From the project's root, run it with the hash:

npx tsx ./scripts/locked-dot-vdot.ts --b 0xb541ad774ba9e8d35d9551a3b6580e813990cd17abe1d8dcc1bde3a0d6f43348

The output file (output-<hash>.json) will have entries as follows:

  "wd7svyXhyKPao4yxmQNYaUq24W6LfWNLYtGuWqNXmEiGzCRCo": {
    "DOT": "251157228793"
  },
  "wdCwNZeeibBLnGbAXtNMbYX1C77mJMn67bLhYJtcbeBobGnLw": {
    "VDOT": "11185015028811"
  },
  "wd9Dd4BVQP57Mth44TG6BWcU9HiakoppsSnZRCCc8ttmJe2Un": {
    "DOT": "20000000000000",
    "VDOT": "20000000000000"
  },
bvotteler commented 6 months ago

Sample output (updated):

{
// ...
  "wd7svyXhyKPao4yxmQNYaUq24W6LfWNLYtGuWqNXmEiGzCRCo": {
    "DOT": "251157228793"
  },
  "wdCwNZeeibBLnGbAXtNMbYX1C77mJMn67bLhYJtcbeBobGnLw": {
    "VDOT": "11185015028811"
  },
  "wd9Dd4BVQP57Mth44TG6BWcU9HiakoppsSnZRCCc8ttmJe2Un": {
    "DOT": "20000000000000",
    "VDOT": "20000000000000"
  },
// ...
}
bvotteler commented 5 months ago

Attaching full output from running for blockhash 0xb541ad774ba9e8d35d9551a3b6580e813990cd17abe1d8dcc1bde3a0d6f43348: output-0xb541ad774ba9e8d35d9551a3b6580e813990cd17abe1d8dcc1bde3a0d6f43348.json

More detailed data, with separated reserved (eg. vault collateral) amounts from amounts locked in lending can be found here: raw-output-0xb541ad774ba9e8d35d9551a3b6580e813990cd17abe1d8dcc1bde3a0d6f43348.json