From 68e3f380f48ec01cf66d13f65fe89b9e26e54f6c Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 24 Jul 2020 22:11:57 +0530 Subject: [PATCH] Added debt ceiling in maker resolver --- contracts/protocols/maker.sol | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/contracts/protocols/maker.sol b/contracts/protocols/maker.sol index b699291..aad5639 100644 --- a/contracts/protocols/maker.sol +++ b/contracts/protocols/maker.sol @@ -110,6 +110,8 @@ contract Helpers is DSMath { uint borrowRate; uint price; uint liquidationRatio; + uint debtCelling; + uint totalDebt; } /** @@ -162,6 +164,13 @@ contract Helpers is DSMath { address spot = InstaMcdAddress(getMcdAddresses()).spot(); (, ratio) = SpotLike(spot).ilks(ilk); } + + function getDebtCeiling(bytes32 ilk) internal view returns (uint debtCeiling, uint totalDebt) { + address vat = InstaMcdAddress(getMcdAddresses()).vat(); + (uint totalArt,uint rate,,uint debtCeilingRad,) = VatLike(vat).ilks(ilk); + debtCeiling = debtCeilingRad / 10 ** 45; + totalDebt = rmul(totalArt, rate); + } } @@ -236,10 +245,13 @@ contract VaultResolver is Helpers { for (uint i = 0; i < name.length; i++) { bytes32 ilk = stringToBytes32(name[i]); + (uint debtCeiling, uint totalDebt) = getDebtCeiling(ilk); colInfo[i] = ColInfo( getFee(ilk), getColPrice(ilk), - getColRatio(ilk) + getColRatio(ilk), + debtCeiling, + totalDebt ); } return colInfo; @@ -265,5 +277,5 @@ contract DSRResolver is VaultResolver { contract InstaMakerResolver is DSRResolver { - string public constant name = "Maker-Resolver-v1"; + string public constant name = "Maker-Resolver-v1.1"; }