decred.org/dcrdex@v1.0.5/dex/calc/fees.go (about)

     1  // This code is available on the terms of the project LICENSE.md file,
     2  // also available online at https://blueoakcouncil.org/license/1.0.0.
     3  
     4  package calc
     5  
     6  // RequiredOrderFunds calculates the funds required for an order.
     7  func RequiredOrderFunds(swapVal, inputsSize, maxSwaps, swapSizeBase, swapSize, feeRate uint64) uint64 {
     8  	baseBytes := maxSwaps * swapSize
     9  	// SwapSize already includes one input, replace the size of the first swap
    10  	// in the chain with the given size of the actual inputs + SwapSizeBase.
    11  	firstSwapSize := inputsSize + swapSizeBase
    12  	totalBytes := baseBytes + firstSwapSize - swapSize // in this order because we are using unsigned integers
    13  	fee := totalBytes * feeRate
    14  	return swapVal + fee
    15  }