@@ -98,20 +98,17 @@ func (k Keeper) AfterPoolBorrowed(ctx sdk.Context, poolId string, maturity int64
9898}
9999
100100// AfterPoolRepaid is the hook which is invoked after the loan is repaid
101- func (k Keeper ) AfterPoolRepaid (ctx sdk.Context , poolId string , maturity int64 , amount sdk.Coin , interest sdkmath.Int , protocolFee sdkmath.Int , actualProtocolFee sdkmath.Int , updateTotalBorrowed bool ) {
101+ func (k Keeper ) AfterPoolRepaid (ctx sdk.Context , poolId string , maturity int64 , amount sdk.Coin , interest sdkmath.Int , protocolFee sdkmath.Int , actualProtocolFee sdkmath.Int ) {
102102 pool := k .GetPool (ctx , poolId )
103103
104104 totalRepaid := amount .Amount .Add (interest ).Sub (protocolFee )
105105
106106 pool .Supply = pool .Supply .AddAmount (interest ).SubAmount (protocolFee )
107107 pool .AvailableAmount = pool .AvailableAmount .Add (totalRepaid )
108108 pool .BorrowedAmount = pool .BorrowedAmount .Sub (amount .Amount )
109+ pool .TotalBorrowed = pool .TotalBorrowed .Sub (totalRepaid )
109110 pool .ReserveAmount = pool .ReserveAmount .Add (actualProtocolFee )
110111
111- if updateTotalBorrowed {
112- pool .TotalBorrowed = pool .TotalBorrowed .Sub (totalRepaid )
113- }
114-
115112 for i , tranche := range pool .Tranches {
116113 if tranche .Maturity == maturity {
117114 pool .Tranches [i ].TotalBorrowed = pool .Tranches [i ].TotalBorrowed .Sub (totalRepaid )
@@ -124,24 +121,6 @@ func (k Keeper) AfterPoolRepaid(ctx sdk.Context, poolId string, maturity int64,
124121 k .SetPool (ctx , pool )
125122}
126123
127- // DecreaseTotalBorrowed decreases total borrowed by the given amount for the specified pool
128- func (k Keeper ) DecreaseTotalBorrowed (ctx sdk.Context , poolId string , maturity int64 , amount sdkmath.Int ) {
129- pool := k .GetPool (ctx , poolId )
130-
131- pool .TotalBorrowed = pool .TotalBorrowed .Sub (amount )
132-
133- for i , tranche := range pool .Tranches {
134- if tranche .Maturity == maturity {
135- pool .Tranches [i ].TotalBorrowed = pool .Tranches [i ].TotalBorrowed .Sub (amount )
136- break
137- }
138- }
139-
140- k .NormalizePool (ctx , pool )
141-
142- k .SetPool (ctx , pool )
143- }
144-
145124// UpdatePoolTranches updates total borrowed amount for each tranche at the beginning of each block
146125//
147126// Formula:
0 commit comments