Close pyth accs manually [Solana - svm]

Is there a way to get all the accounts created with a specific signer that have not been closed?
How to close them manually?

Same questions apply both for addPostPriceUpdates and addUpdatePriceFee.

Since the (aprox) resulting sequence of the builder is

  • acc(s) creation Tx
  • Write Txs
  • [Consumer Ix + Close accs Ix] Tx

during our development phase, we didn’t execute many close instructions due to failures on our consumer ix, thus failing altogether and leaving the rent unclaimed.

My intention is to fetch all those accs and close them now.

Thanks for the help!

Heeey,

There are two types of accounts that get created while posting price updates:

  • encoded_vaa owned by the Wormhole Receiver program (HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ)
  • price_update_account (only created if you’re using addPostPriceUpdates instead of addUpdatePriceFeed) owned by the Pyth Receiver program (rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ)

To find them and close them you have to:

  • first find them using getProgramAccounts filtering on the write_authority
  • call the instruction to close them, which must be signed by the write_authority

For encoded_vaa, the sdk has the addClosePreviousEncodedVaasInstructions method that will do both.

For price_update_account, the sdk does not support it directly, you will need to use connection.getProgramAccounts to find the accounts (you can take inspiration from this code forencoded_vaa ) and close them manually (you take can inspiration from this code that generates the reclaim_rent instruction for price_update_account).