fix(program): bind fund_escrow to the invoice mint; tolerate vault surplus - #3
Merged
Merged
Conversation
…rplus fund_escrow never checked usdc_mint against invoice.usdc_mint. The vault constraint derives the ATA from whichever mint is passed, so a client could fund with a token they minted themselves and flip the invoice to Funded. The freelancer sees a funded escrow, but settle can never pay: its vault for the real mint is empty. settle required vault.amount == total. Anyone can transfer into the vault ATA, before or after funding, so a single base unit made settle fail forever with no refund path. It now requires >= total and still pays exactly total. Adds InvalidMint at the end of the error enum so existing codes keep their numbers, and two bankrun regression tests.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two escrow bugs:
usdc_mintwas never checked againstinvoice.usdc_mint, and the vault constraint derives the ATA from whatever mint is passed. A client could fund with a self-minted token and flip the invoice toFunded, whilesettlecould never pay because the real-mint vault is empty. Nowaddress = invoice.usdc_mint(newInvalidMinterror, appended so existing codes keep their numbers).vault.amount == totalfailed forever once anyone sent tokens straight to the vault ATA. Now>=, still paying exactlytotal.Two bankrun regression tests added. The devnet deployment still runs the old program until it is redeployed.