createCrossSwapBody method

Cell createCrossSwapBody({
  1. required InternalAddress askJettonWalletAddress,
  2. required InternalAddress receiverAddress,
  3. required BigInt minAskAmount,
  4. required InternalAddress refundAddress,
  5. InternalAddress? excessesAddress,
  6. Cell? customPayload,
  7. BigInt? customPayloadForwardGasAmount,
  8. Cell? refundPayload,
  9. BigInt? refundForwardGasAmount,
  10. InternalAddress? referralAddress,
  11. BigInt? referralValue,
})

Implementation

Cell createCrossSwapBody({
  required InternalAddress askJettonWalletAddress,
  required InternalAddress receiverAddress,
  required BigInt minAskAmount,
  required InternalAddress refundAddress,
  InternalAddress? excessesAddress,
  Cell? customPayload,
  BigInt? customPayloadForwardGasAmount,
  Cell? refundPayload,
  BigInt? refundForwardGasAmount,
  InternalAddress? referralAddress,
  BigInt? referralValue,
}) {
  if (referralValue != null &&
      (referralValue < BigInt.zero || referralValue > BigInt.from(100))) {
    throw Exception("'referralValue' should be in range [0, 100] BPS");
  }

  return beginCell()
      .storeUint(DexOpCodes.CROSS_SWAP.op, 32)
      .storeAddress(askJettonWalletAddress)
      .storeAddress(refundAddress)
      .storeAddress(excessesAddress ?? refundAddress)
      .storeRef(beginCell()
          .storeCoins(minAskAmount)
          .storeAddress(receiverAddress)
          .storeCoins(customPayloadForwardGasAmount ?? BigInt.zero)
          .storeMaybeRef(customPayload)
          .storeCoins(refundForwardGasAmount ?? BigInt.zero)
          .storeMaybeRef(refundPayload)
          .storeUint(referralValue ?? BigInt.from(10), 16)
          .storeAddress(referralAddress)
          .endCell())
      .endCell();
}