-
Notifications
You must be signed in to change notification settings - Fork 159
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
Error with token amount calculation #45
Comments
这个 tokens 指的是 代币的数量,而不是 sol 的数量,因为有滑点的原因,所以,你购买的时候需要传入你想要支付的最大 sol 和 你想要得到的 代币 |
@YaminZheng I am not looking to buy a pre determined number of tokens. I am looking to buy whatever the amount of tokens is possible for a pre determined number of SOL (say 0.1 SOL). |
对,你可以看库里的。getBuyInstructions 方法,他的第四个参数就是 token 数量,第五个参数就是你愿意花费的 sol 的数量,如果你想要花费 0.1 sol ,那 第四个参数就是 0.1sol 通过 getBuyPrice 计算出来的 token 数量 |
@YaminZheng I did do the same for the transaction below. But the buy amount was way less. |
您好 @YaminZheng,如果您能告诉我,将非常有帮助。有什么方法可以计算 SOL 可以以给定数量购买的代币的估计数量? |
tokenAmount = getBuyPrice(solAmount) |
When using jup to purchase pump, you can use sol as the standard. Previously, pump seemed to be standard on tokens. Now there is a tab on the website that allows you to use sol or token as the standard. |
So I was trying to buy tokens worth 0.001 SOL.
But instead the calculation you provided bought tokens 0.000000034 SOL.
https://solscan.io/tx/2w62deyJ3uGhZerxSr1XrGJPFWjvLpkzW9cYHuBFPbmB6Dnp7yG14xMtf1vAX1F3sUs1TnhsBE5Rh1ZQ2ZBoGyYb
This is the transaction. I have no idea what is wrong with my calculations.
The text was updated successfully, but these errors were encountered: