1

Let's take Saturna as an example.

I want to know what was trading volume in 1 minute time buckets.

1 Answer 1

1

As far as I understand, all I need to do is observe Transfer event, e.g.

web3.eth.subscribe(
  'logs',
  {
    address: '0x1e446CbEa52BAdeB614FBe4Ab7610F737995fB44',
    topics: [
      '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
    ],
  },
  (error, data) => {
    console.log(data);
  },
);

This will give me information such as:

{
  address: '0x1e446CbEa52BAdeB614FBe4Ab7610F737995fB44',
  topics: [
    '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
    '0x0000000000000000000000002a621eb59522a895a2bc0e5b6c9341adf392892a',
    '0x000000000000000000000000ad7db2aea6e8904347be097f920174469a64774e'
  ],
  data: '0x00000000000000000000000000000000000000000000000054df3de59546157e',
  blockNumber: 7506151,
  transactionHash: '0x65ccabbed15b99ac10e4677141c1718dcc4083cba52786e4853119b45a0e2934',
  transactionIndex: 155,
  blockHash: '0xfab95d76941743259b6f4dd0019d31d078c665dbf54b7d6f419721b76b76278a',
  logIndex: 180,
  removed: false,
  id: 'log_f1c7e670'
}

which, when decoded, will tell me the amount of Saturna coins transferred:

{
  name: 'Transfer',
  values: {
    from: '0x2a621Eb59522a895A2BC0E5b6c9341aDf392892a',
    to: '0xAD7DB2Aea6E8904347BE097f920174469a64774e',
    value: '6115674875253626238'
  }
}

All I need to calculate volume from here is just to add volume to time buckets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.