def repay(self, sct):
"""
used only after the activation of CDT contract
repay the loan, which converts SCT to DCt
:param sct: amount of SCT need to be repaid
:return: cdt
"""
# used only after the activation of CDT contract
if not self.is_cdt_active:
return
# repay rate is the same as loan rate
ether = sct * self.CDTL
# update the CDT balance
self.CDTB += ether
# convert SCT to CDT
cdt = sct
# calculate the cash price of CDT
self.CDTP = self.CDTB / (self.CDTS * self.CDT_CRR)
# log CDT contract according to switch
if self.log == self.log_cdt or self.log == self.log_dpt_cdt:
print('repay: ', sct, 'SCT', '+', ether, 'ETH', '=>', cdt, 'CDT')
return cdt
评论列表
文章目录