Solved :

  1. Creat a 1st function only for Buy and a 2nd function for Sell with 'balanceOf = amountOut' before swap in Solidity
  2. Call in order from your JAVASCRIPT or Python etc ....
  • Did you try creating two transactions?
    – Ismael
    Nov 4, 2022 at 14:17
  • Ok you mean create two transaction in Javascript ? const BuyTx ? const SellTx ? Or in Solidity 1 function Buy and 1 function Sell ? make a bool (amount > 0) on sell ? Can you explain me what you mean please Ismael ?
    – forexmp45
    Nov 4, 2022 at 15:55
  • I don't understand your problem, but if you need two transaction hashes, then just create two transactions. Also unless you use something like flashbots there's no way to ensure two transactions will be in the same block.
    – Ismael
    Nov 4, 2022 at 16:53
  • Its ok i'm sorry i'm newbie in solidity and alone to learn .. ^^ Thank you
    – forexmp45
    Nov 5, 2022 at 0:28


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.