* Interest Ratio Formula: ( a / Log10(b + N) ) * * ==> ratio = a / Log10 (b+N) */
| 122 | * ==> ratio = a / Log10 (b+N) |
| 123 | */ |
| 124 | uint64_t ComputeCDPInterest(const uint64_t total_owed_scoins, const int32_t beginHeight, const uint32_t endHeight, |
| 125 | uint64_t A, uint64_t B) { |
| 126 | |
| 127 | int32_t blockInterval = endHeight - beginHeight; |
| 128 | int32_t loanedDays = std::max<int32_t>(1, ceil((double)blockInterval / SysCfg().GetOneDayBlocks(endHeight))); |
| 129 | |
| 130 | uint64_t N = total_owed_scoins; |
| 131 | double annualInterestRate = 0.1 * A / log10(1.0 + B * N / (double)COIN); |
| 132 | uint64_t interest = (uint64_t)(((double)N / 365) * loanedDays * annualInterestRate); |
| 133 | |
| 134 | LogPrint(BCLog::CDP, "beginHeight=%d, endHeight=%d, loanedDays=%d, A=%llu, B=%llu, N=" |
| 135 | "%llu, annualInterestRate=%f, interest=%llu\n", |
| 136 | beginHeight, endHeight, loanedDays, A, B, N, annualInterestRate, interest); |
| 137 | |
| 138 | return interest; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Interest Ratio Formula: ( a / Log10(b + N) ) |
no test coverage detected