0

So I'm having trouble finding the offset for some account keys of programs that have an IDL and would like to get some help on this. For example in this program

https://solscan.io/account/dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH#anchorProgramIDL

I would like for this account:

Account struct

To know the offset where the key "unrealizedPnlMaxImbalance" begins.

Thank you in advance, for any help given

1 Answer 1

0

It's a bit annoying, but if you want the offset, the easiest option is to just count up all the bytes to get to the field that you care about. In your case, we can count all the way unrealizedPnlMaxImbalance:

  • pubkey: 32 bytes
  • amm: this one's complicated since it's a big type called "AMM" and has many subtypes in it. You could go through by hand and count the number of bytes in all the fields, but I'm being lazy, sorry!
  • pnlPool: PoolBalance which is 16 bytes for scaledBalance, 2 for marketIndex, and 6 for padding
  • name: 32 bytes
  • insuranceClaim: 5 ints, 8 bytes each
  • unrealizedPnlMaxImbalance: made it!

I hope this will be a good first step, and apologies for my laziness for counting up the bytes in the AMM type. Best of luck!

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.