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

priorityLevelWithMaxLamports Improper Documentation #575

Closed
Aulteran opened this issue Jan 17, 2025 · 12 comments
Closed

priorityLevelWithMaxLamports Improper Documentation #575

Aulteran opened this issue Jan 17, 2025 · 12 comments

Comments

@Aulteran
Copy link

In docs/2-apis/11-landing-transactions.md, usage of priorityLevelWithMaxLamports is incorrect. Found it by testing in API Playground why all my swaps were failing, and realized the docs incorrectly showed how to use prioritizationFeeLamports. I'll fix this in a fork and open a PR.

@Aulteran
Copy link
Author

Aulteran commented Jan 17, 2025

Opened PR #576

@0xYankee-Raccoons
Copy link
Contributor

How were they failing? Can't land on-chain or landed on-chain with the wrong priority fees?

Found it by testing in API Playground why all my swaps were failing

@Aulteran
Copy link
Author

Aulteran commented Jan 17, 2025

All swaps failed with Error 422, showed up like this:

Error Status: 422
Error Status Text: Unprocessable Entity
Error Data: { error: 'Failed to deserialize the JSON body into the target type' }

when I removed the following from my code, it worked.

prioritizationFeeLamports: {
    priorityLevelWithMaxLamports: {
      maxLamports: config.swap.prio_fee_max_lamports,
      priorityLevel: config.swap.prio_level,
    },
}

Therefore I kept messing with it, and eventually, I learned if you want to use priorityLevelWithMaxLamports, you use it instead of prioritizationFeeLamports, and not under it.

so yeah, they didn't land on-chain bc the API couldn't accept my requests.

@0xYankee-Raccoons
Copy link
Contributor

try again? and check how you are passing in your params? the docs should be correct, you can refer to the video and see the difference with prioritizationFeeLamports: { and without
https://github.com/user-attachments/assets/3b498246-6001-433e-bc9b-cfc844573a92

@Aulteran
Copy link
Author

Well that's interesting. The following is my old JSON body, in which transactions constantly failed, and when testing on https://station.jup.ag/api-v6/post-swap i got the error { error: 'Failed to deserialize the JSON body into the target type' }

JSON.stringify({
    // quoteResponse from /quote api
    quoteResponse: quoteResponse.data,
    // user public key to be used for the swap
    userPublicKey: myWallet.publicKey.toString(),
    // auto wrap and unwrap SOL. default is true
    wrapAndUnwrapSol: true,
    //dynamicComputeUnitLimit: true, // allow dynamic compute limit instead of max 1,400,000
    dynamicSlippage: {
      // This will set an optimized slippage to ensure high success rate
      maxBps: 300, // Make sure to set a reasonable cap here to prevent MEV
    },
    prioritizationFeeLamports: {
      priorityLevelWithMaxLamports: {
        maxLamports: config.sell.prio_fee_max_lamports,
        priorityLevel: config.sell.prio_level,
      },
    },
})

upon changing the ending to the below, my transactions went through.

priorityLevelWithMaxLamports: {
    maxLamports: config.swap.prio_fee_max_lamports,
    priorityLevel: config.swap.prio_level,
},

but yeah you're right. although the second variant allows the swap quote to be serialized, my fee looks like its 99999 lamports.
Image

any idea why it's failing when the first body is used?

@0xYankee-Raccoons
Copy link
Contributor

what are you passing in for these params?

    maxLamports: config.swap.prio_fee_max_lamports,
    priorityLevel: config.swap.prio_level,

@Aulteran
Copy link
Author

prio_fee_max_lamports: '500000',
prio_level: 'medium'

@0xYankee-Raccoons
Copy link
Contributor

try hardcode the values and see if it works?

@Aulteran
Copy link
Author

still nothing.

@Aulteran
Copy link
Author

try again? and check how you are passing in your params? the docs should be correct, you can refer to the video and see the difference with prioritizationFeeLamports: { and without https://github.com/user-attachments/assets/3b498246-6001-433e-bc9b-cfc844573a92

can you try doing this on https://station.jup.ag/api-v6/post-swap?

@0xYankee-Raccoons
Copy link
Contributor

0xYankee-Raccoons commented Jan 18, 2025

don't use the api doc to test, it is a bit wonky

wait, what is this before your swap params?
> JSON.stringify({

edit: ah sorry, got confused, everything works fine when im doing it programmatically

@Aulteran
Copy link
Author

Update: I managed to fix it, and not sure which part fixed it. I hardcoded the parameters, separated the body as a JSON.stringify variable outside of the request, and after some more moving the code around it started working. Not gonna touch it anymore for fear of breaking it lol.

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

No branches or pull requests

2 participants