Skip to content

[Confidential Transfer Extension] Available Balance Can Be Overwritten If ConfidentialTransferInstruction::Deposit And ConfidentialTransferInstruction::ApplyPendingBalance Are Submitted In The Same Transaction #290

Open
@bonedaddy

Description

@bonedaddy

Overview

If a transaction is submitted which contains a ConfidentialTransferInstruction::Deposit instruction 1, and ConfidentialTransferInstruction::ApplyPendingBalance instruction 2, then the relationship between Available Balance and Decryptable Available Balance is corrupted, resulting in "lost" funds.

I'm not sure if the funds are truly lost, however the amount of tokens that were deposited in ConfidentialTransferInstruction::Deposit are deducted from the token account's non confidential balance, but subsequently not made available as the confidential balance.

For example if your non confidential balance is 100, and you submit tx1 which contains a ConfidentialTransferInstruction::Deposit instruction for 10 tokens, and a ConfidentialTransferInstruction::ApplyPendingBalance, once the transaction is finalized your non confidential balance will now be 90.

If you then submit tx2 which contains a ConfidentialTransferInstruction::Withdraw for 10 tokens, the transaction will fail with an error InsufficientFunds.

If however you broke tx1 into two separate transactions:

  • tx1 with ConfidentialTransferInstruction::Deposit
  • tx2 with ConfidentialTransferInstruction::ApplyPendingBalance
  • tx3 with ConfidentialTransferInstruction::Withdraw

You will succesfully be able with withdraw the 10 tokens that were deposited.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions