Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the correct way to replay the events on v4 chain? #100

Open
miran248 opened this issue Dec 22, 2023 · 4 comments
Open

What's the correct way to replay the events on v4 chain? #100

miran248 opened this issue Dec 22, 2023 · 4 comments

Comments

@miran248
Copy link

miran248 commented Dec 22, 2023

Hey,

I'm currently exploring what's stored on the chain with a goal to do some analysis (and maybe make my own indexer later).

I've successfully established the connection with some mainnet validators and checked a few blocks so far.
It looks like all blocks contain these four messages

"/dydxprotocol.clob.MsgProposedOperations"
"/dydxprotocol.bridge.MsgAcknowledgeBridges"
"/dydxprotocol.perpetuals.MsgAddPremiumVotes"
"/dydxprotocol.prices.MsgUpdateMarketPrices"

I'm wondering, what's the correct way to decode them?
This is what i came up with so far https://github.com/miran248/dydx-v4-test/blob/a6581251eacfa488c85f564287fb1955097a0555/validator-client.ts#L6
Feels wrong, and MsgProposedOperations was not fully decoded
Screenshot 2023-12-22 at 12 36 43

Are there any other ways to replay the events?
Indexer has some functions but there i can't target a specific block height.

(didn't know where to ask this question, hence the issue)

Thanks,
Miran

EDIT: It looks like i'll have to do the mapping myself, like here https://github.com/dydxprotocol/v4-clients/blob/c94bcbf4fc91bb896ea716ccd02ace32b0cb50d0/v4-client-js/src/clients/lib/registry.ts

@yllhwa
Copy link

yllhwa commented Mar 11, 2024

Have you found a method to decode shortTermOrderPlacement?

@miran248
Copy link
Author

@yllhwa Hey, unfortunately no. I gave up shortly after.
Might revisit it at some point, once I get more familiar with cosmos-sdk in general.

@yllhwa
Copy link

yllhwa commented Mar 11, 2024

All right, I figure it out.

import { decodeTxRaw } from "@cosmjs/proto-signing";
var data = decodeTxRaw(operation.shortTermOrderPlacement);
console.log(data.body.messages);
// decode message then

what brilliant developers and detailed documentation we have.

@miran248
Copy link
Author

Tried that too but not sure if it's correct.

Have you seen this? https://github.com/dydxprotocol/v4-chain/blob/e6b269186c9800a3af973171f2290e6fa94765db/protocol/x/clob/types/operation.go

Msg here is of type MsgPlaceOrder, at a quick glance it appears to be a request type though..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants