0

here is the code:

await SWAP_CONTRACT.events.Swap({})
    .on('data', async function(event){
        console.log(event)
        await changeListenPair();
    })
    .on('changed', async function(event) {
        console.log(event);
    })
    .on('error', console.error);

when the swap occurs, I see the data, namely I am interested in this: amount1Out: '1991810163029119182', -> 1.99181 (human)

{
...
  returnValues: Result {
    '0': '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
    '1': '1000000',
    '2': '0',
    '3': '0',
    '4': '1991810163029119182',
    '5': '0x50732ed7e73Eb365a8A128D05eF6b07f30031103',
    sender: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
    amount0In: '1000000',
    amount1In: '0',
    amount0Out: '0',
    amount1Out: '1991810163029119182',
    to: '0x50732ed7e73Eb365a8A128D05eF6b07f30031103'
  },
  event: 'Swap',
  signature: '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822',
  raw: {
    data: '0x00000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ba454ca4b5d10ce',
    topics: [
      '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822',
      '0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d',
      '0x00000000000000000000000050732ed7e73eb365a8a128d05ef6b07f30031103'
    ]
  }
}

But this is the old meaning. How can I get a new value after a successful transaction?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.