* Interest Ratio Formula: ( a / Log10(b + N) ) * * ==> ratio = a / Log10 (b+N) */
| 830 | * ==> ratio = a / Log10 (b+N) |
| 831 | */ |
| 832 | static uint64_t ComputeCDPInterest(CSysParamDBCache &sysParamCache, const CUserCDP &cdp, uint32_t tipHeight) { |
| 833 | if (cdp.total_owed_scoins == 0 || cdp.block_height > tipHeight) { |
| 834 | return 0; |
| 835 | } |
| 836 | |
| 837 | const auto& coinPair = cdp.GetCoinPair(); |
| 838 | |
| 839 | list<CCdpInterestParamChange> changes; |
| 840 | if (!sysParamCache.GetCdpInterestParamChanges(coinPair, cdp.block_height, tipHeight, changes)) { |
| 841 | throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("get cdp interest param changes error! coinPiar=%s", |
| 842 | coinPair.ToString())); |
| 843 | } |
| 844 | |
| 845 | uint64_t interest = 0; |
| 846 | for (auto &change : changes) { |
| 847 | interest += ::ComputeCDPInterest(cdp.total_owed_scoins, change.begin_height, change.end_height, |
| 848 | change.param_a, change.param_b); |
| 849 | } |
| 850 | |
| 851 | return interest; |
| 852 | } |
| 853 | |
| 854 | Object RPC_PARAM::CdpToJson(const CUserCDP &cdp, uint32_t tipHeight) { |
| 855 |
no test coverage detected