Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: return a quote when not enough funds #418

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

guibescos
Copy link
Contributor

@guibescos guibescos commented Mar 6, 2025

  • in auction service, we let through transactions that fail with the user insufficient funds error
  • in opportunity service, we check if the user has enough funds and set tx in the response to none if they don't

Copy link

vercel bot commented Mar 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
swap-staging ⬜️ Ignored (Inspect) Visit Preview Mar 6, 2025 8:19pm

== InstructionError::Custom(ErrorCode::InsufficientUserFunds.into())
{
// This path only works as long as none of the other accepted programs use this error number, which is currently true since express relay is the only program in the whitelist that uses anchor error codes
// TODO: Also check the instruction index here so we are sure it's coming from the swap instruction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this TODO resolve the above comment? since ER doesn't make any CPIs to anything except system & token program?

Some(_) => (
let user_has_enough_balance =
if let Some(user_wallet_address) = input.quote_create.user_wallet_address {
self.check_user_token_balance(CheckUserTokenBalanceInput {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we checking here to prevent sybiling? why do we need to make an RPC call every time a quote is requested? couldn't we just avoid this check and use the error code itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems we could handle this in verification.rs and just return a third option to allow the bid to remain with a flag that this failed due to UserInsufficientFunds. then we don't have to recheck the token balance on chain?

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

Successfully merging this pull request may close these issues.

2 participants