Fees calculation
Fees (namely, commission and vendor markup) are a percentage of the amount of the transaction that will be charged for the usage of the platform. The sum of the commission and vendor markup will be at around 0.1% of the amount.
The calculation for the fees associated with the transaction is managed in the function calculateCommissionsWithPrices of the MoCExchange contract.
This function deals with all the parameters needed to calculate said fees. You will need to pass these parameters in the form of the CommissionParamsStruct struct:
You must assign all the parameters to the struct before calling the function. Transaction types for every operation are explained here. You must have an instance of the MoCInrate contract in order to access every valid transaction type.
Fees will be paid in MoC in case the user has MoC token balance and allowance; otherwise they will be paid in RBTC.
You will receive a CommissionReturnStruct struct in return with all the values calculated for you:
In conclusion:
If you are minting and fees are paid in RBTC, the amount sent to the transaction has to be at least the amount in BTC desired plus the commission (amount times the commission rate) plus the markup (amount times the vendor markup). If the operation involves interests, you should add them as well.
If fees are paid in MoC, then btcSent (msg.value) == CommissionParamsStruct.amount
If you are redeeming and fees are paid in RBTC, the transaction returns the amount in RBTC discounting the previously calculated fees. If the operation involves interests, you should subtract them as well.
If fees are paid in MoC, then btcReceived == CommissionParamsStruct.amount
Last updated