Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Use idempotent ATA creation to avoid tx race conditions #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andreisilviudragnea
Copy link

Raydium-sdk code is prone to race conditions for cases when an ATA is checked for existence, then a createAssociatedTokenAccountInstruction is added to the tx.

If two swaps detect the ATA missing and add the ATA creation instruction, only the first will succeed, while the second will fail with InvalidOwner.

Example:

This PR replaces createAssociatedTokenAccountInstruction with createAssociatedTokenAccountIdempotentInstruction, which does not fail even if the ATA already exists.

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

Successfully merging this pull request may close these issues.

1 participant