EOSIO / eos

An open source smart contract platform
https://developers.eos.io/manuals/eos
MIT License
11.27k stars 3.6k forks source link

How to calculate the 10% fee #6575

Closed cppfuns closed 5 years ago

cppfuns commented 5 years ago

Calculate .5% fee https://github.com/EOSIO/eos/blob/905e7c85714aee4286fa180ce946f15ceb4ce73c/contracts/eosio.system/delegate_bandwidth.cpp#L111

How to calculate the 10% fee? Is it like this? fee.amount = ( fee.amount + 9 ) / 10;

jgiszczak commented 5 years ago

Not quite.

fee.amount = ( tokens.amount + 9 ) / 10;

To complete the transaction the fee and the amount the fee is being calculated on need to be maintained separately.

Bear in mind that code performs integer coercion to the next largest integer, which for small amounts can yield a final result considerably larger than the nominal 10%.