Ellipsis-Labs / phoenix-sdk

SDK for interacting with the Phoenix DEX.
83 stars 39 forks source link

Explicitly check for seat status when setting up instructions for the trader #152

Closed mmdhrumil closed 7 months ago

mmdhrumil commented 7 months ago

Problem: If the trader acquired a seat initially and got it evicted later, the getMakerSetupInstructionsForMarket() function call during the next trade won't return the necessary instructions to claim the seat because currently it only checks if the data at the seat account is initialized, hence fails to check if the seat status is evicted/retired

Solution: Also add an explicit check here if the seat status is evicted/retired and add the getClaimSeatIx() instructions if needed https://github.com/Ellipsis-Labs/phoenix-sdk/blob/master/typescript/phoenix-sdk/src/utils/seatManager.ts#L190

mmdhrumil commented 7 months ago

Update: Always adding seat claiming instruction instead of checking whether initialized or not should work. One sub-optimality is that we may be adding seat claiming instruction even if the seat is approved, but the instruction call will be light-weight and won't cost substantially more compute units