How to calculate UnitAmt?

function caculateUnitAmt(buyAmount, sellAmount, buyDecimal, sellDecimal, maxSlippage) {
  let unitAmt = new BigNumber(buyAmount)
    .dividedBy(10 ** buyDecimal)
    .dividedBy(new BigNumber(sellAmount).dividedBy(10 ** sellDecimal))
  unitAmt = unitAmt.multipliedBy((100 - maxSlippage) / 100)
  unitAmt = unitAmt.multipliedBy(1e18).toFixed(0)
  return unitAmt
}

If you still can't find something you're looking for or have any questions, ask them at our developers community on Discord or simply send an Email.

Our team is excited about assisting you to build an application using Instadapp Developer Platform. Your questions and feedback help us make a better development environment for future developers.