MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / CdpToJson

Method CdpToJson

src/rpc/core/rpccommons.cpp:854–866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

852}
853
854Object RPC_PARAM::CdpToJson(const CUserCDP &cdp, uint32_t tipHeight) {
855
856 uint64_t bcoinMedianPrice = GetPriceByCdp(*pCdMan->pPriceFeedCache, cdp);
857 uint64_t interest = ComputeCDPInterest(*pCdMan->pSysParamCache, cdp, tipHeight);
858
859 int32_t blockInterval = tipHeight >= cdp.block_height ? tipHeight - cdp.block_height : 0;
860 int32_t interestDays = std::max<int32_t>(1, ceil((double)blockInterval / SysCfg().GetOneDayBlocks(tipHeight)));
861
862 auto obj = cdp.ToJson(bcoinMedianPrice);
863 obj.push_back(Pair("interest_due", interest));
864 obj.push_back(Pair("interest_days", interestDays));
865 return obj;
866}

Callers

nothing calls this directly

Calls 5

PairClass · 0.85
GetOneDayBlocksMethod · 0.80
push_backMethod · 0.80
ComputeCDPInterestFunction · 0.70
ToJsonMethod · 0.45

Tested by

no test coverage detected