jup-ag / jupiter-swap-api

The jupiter swap api binary
72 stars 20 forks source link

Jupiter SDK applying slippage internally for limit orders . #19

Closed hammersharkfish closed 1 month ago

hammersharkfish commented 4 months ago
+-----------------------------------------------------------------------------------------------------+

| Transaction Type: Buy                                                                               |
| sellAmount: 0.135241916                                                                             |
| buyAmount: 18.749259                                                                                |
| sellAddress: So11111111111111111111111111111111111111112                                            |
| buyAddress: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v                                            |
| buy price: 138.634973736                                                                            |
| Signature: 4tnsKHFNZU5Nxw3aG4D1M7SC7DkZtG5CvgB7CdzP7WL6KXsiHtTSgGWYXwbTkX39pDUugeGuEuMRiUPhA1qC6Bp3 |

+-----------------------------------------------------------------------------------------------------+

I created a limit order using jupiter SDK in solana with the above parameters .

const { tx, orderPubKey } = await limitOrder.createOrder({
  owner: walletKeyPair.publicKey,
  inAmount:  new anchor.BN(sellAmount.toString()), 
  outAmount: new anchor.BN(buyAmount.toString()),
  inputMint: new PublicKey(sellAddress),
  outputMint: new PublicKey(buyAddress),
  expiredAt: transactionExpiry, // Example: new BN(new Date().valueOf() / 1000)
  base: base.publicKey,
});

My outAmount was 18749259 USDC but what I received was 18730510 USDC which is less than my outAmount . Does jupiter SDK automatically apply a slippage internally ? If yes how do I set it to 0% . The docs are very unclear on this .

https://docs.jup.ag/docs/limit-order/limit-order-with-sdk

WildThingCrypto commented 3 months ago

0.1% fee. 18730510 / 18749259 = 0.9990000138138793.