DGX's fees calculation
demurrage_base
(default to 10000000) and demurrage_rate
(default to 165)last_demurrage_payment_timestamp
(in seconds), which is initialized to be the current time when A first receives any DGXscurrent_time
:
last_demurrage_payment_timestamp
:
days_elapsed = (current_time - last_demurrage_payment_timestamp) / ONE_DAY_DURATION_IN_SECONDS
demurrage_fees = days_elapsed * user_balance * demurrage_rate / demurrage_base
last_demurrage_payment_timestamp
by exactly days_elapsed
:
last_demurrage_payment_timestamp += days_elapsed * ONE_DAY_DURATION_IN_SECONDS
As such, the new last_demurrage_payment_timestamp
is not necessarily the current timestamp.
last_demurrage_payment_timestamp
is 27 hours ago, then we will deduct A's demurrage for 1 day, and update his last_demurrage_timestamp
to be 27 - 24 = 3 hours agofunction calculateDemurrage(uint256 _initial_balance, uint256 _days_elapsed)
public
view
returns (uint256 _demurrage_fees, bool _no_demurrage_fees)
_demurrage_fees
is the demurrage fees for a DGX balance of _initial_balance
over a period of _days_elapsed
days, if demurrage is turned on._no_demurrage_fees
is true if global demurrage fees is currently turned off.balanceOf
of the DGX Token contractbalanceOf
of the DGX Token contract always takes into account the demurrage fees up until the current time, as if demurrage has just been deducted.transfer_fees_base
(default to 10000) and transfer_fees_rate
(default to 13)transfer_fees = transfer_amount * transfer_fees_rate / transfer_fees_base
X
DGXs to B, A's balance will be deducted X
and B's balance will increase X - transfer_fees
. transfer_fees
will go to transfer_fee_collector
's balance.All the configurations related to the DGX token (such as the demurrage_fees_base
, demurrage_fees_rate
, transfer_fees_base
, transfer_fees_rate
,...) can be read from this contract: link to etherscan