-
Asked by
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It isn't a view function, view functions have the Also, you cannot see the return values of functions that are not view. So even if you pay gas and calculate spot price on-chain ( There are multiple ways you can get a quote for a swap, here are just some examples. This answer uses the Pancakeswap modules on testnet as reference.
API endpoint format is below: The logic for the math can be found here. Look at
Here's a code snippet that demonstrates swap simulation:
|
Beta Was this translation helpful? Give feedback.
-
Thanks @kshitjee it helped. |
Beta Was this translation helpful? Give feedback.
-
Hey @kshitjee just a quick question, now how can i send this transaction const txn = await aptos.transaction.build.simple({ // Now i want to encode this tx and send it over the internet so that anyone else can sign it const signedTx = aptos.transaction.sign({ // Now i want to send this signed tx so that any one else can send this please let me know as i can't find any functions for it on the sdk |
Beta Was this translation helpful? Give feedback.
It isn't a view function, view functions have the
#[view]
attribute above them.Also, you cannot see the return values of functions that are not view. So even if you pay gas and calculate spot price on-chain (
swap_utils
module), there is no way to access the return values via SDK/API/Indexer based on the design of the given Pancakeswap modules. This is because the information is not stored in a resource, nor is it emitted through an event.There are multiple ways you can get a quote for a swap, here are just some examples. This answer uses the Pancakeswap modules on testnet as reference.
Since you're using Pancakeswap, you can check out their aptos-swap-sdk. This will likely have a meth…