Skip to content

Commit 422aee7

Browse files
feat: Update drawn rate in refresh premium (#716)
1 parent 92134e2 commit 422aee7

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

snapshots/Hub.Operations.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"add": "119571",
33
"draw": "112344",
4-
"refreshPremium": "84297",
4+
"refreshPremium": "100848",
55
"remove: full": "80336",
66
"remove: partial": "86836",
77
"restore: full": "114054",

snapshots/Spoke.Operations.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"borrow: first": "250505",
3-
"borrow: second action, same reserve": "213977",
4-
"liquidationCall: full": "321346",
5-
"liquidationCall: partial": "345017",
6-
"permitReserve + repay (multicall)": "273361",
2+
"borrow: first": "257756",
3+
"borrow: second action, same reserve": "221228",
4+
"liquidationCall: full": "328597",
5+
"liquidationCall: partial": "352268",
6+
"permitReserve + repay (multicall)": "280612",
77
"permitReserve + supply (multicall)": "140631",
88
"permitReserve + supply + enable collateral (multicall)": "174116",
99
"repay: full": "175218",
10-
"repay: partial": "232122",
10+
"repay: partial": "239373",
1111
"setUserPositionManagerWithSig: disable": "38977",
1212
"setUserPositionManagerWithSig: enable": "63000",
1313
"supply + enable collateral (multicall)": "152550",
@@ -17,12 +17,12 @@
1717
"supply: second action, same reserve": "102491",
1818
"updateUserDynamicConfig: 1 collateral": "53152",
1919
"updateUserDynamicConfig: 2 collaterals": "58433",
20-
"updateUserRiskPremium: 1 borrow": "123817",
21-
"updateUserRiskPremium: 2 borrows": "162132",
20+
"updateUserRiskPremium: 1 borrow": "143568",
21+
"updateUserRiskPremium: 2 borrows": "195134",
2222
"usingAsCollateral: 0 borrows, enable": "54026",
23-
"usingAsCollateral: 1 borrow, disable": "134043",
23+
"usingAsCollateral: 1 borrow, disable": "153794",
2424
"usingAsCollateral: 1 borrow, enable": "24786",
2525
"withdraw: 0 borrows, full": "135168",
2626
"withdraw: 0 borrows, partial": "137271",
27-
"withdraw: 1 borrow, partial": "240391"
27+
"withdraw: 1 borrow, partial": "254442"
2828
}

src/contracts/Hub.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ contract Hub is IHub, AccessManaged {
337337
// no premium change allowed
338338
_applyPremiumDelta(assetId, asset, spoke, premiumDelta, 0);
339339

340+
asset.updateDrawnRate(assetId);
341+
340342
emit RefreshPremium(assetId, msg.sender, premiumDelta);
341343
}
342344

tests/unit/Hub/Hub.RefreshPremium.t.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ contract HubRefreshPremiumTest is HubBase {
4343
_applyPremiumDelta(premiumDataBefore, premiumDelta)
4444
);
4545
assertLe(premiumAfter - premiumBefore, 2, 'premium should not increase by more than 2');
46+
assertBorrowRateSynced(hub1, daiAssetId, 'after refreshPremium');
4647
}
4748

4849
/// @dev offsetDelta can't be more than sharesDelta or else underflow
@@ -84,6 +85,7 @@ contract HubRefreshPremiumTest is HubBase {
8485
_applyPremiumDelta(premiumDataBefore, premiumDelta)
8586
);
8687
assertLe(premiumAfter - premiumBefore, 2, 'premium should not increase by more than 2');
88+
assertBorrowRateSynced(hub1, daiAssetId, 'after refreshPremium');
8789
}
8890
}
8991

@@ -118,6 +120,7 @@ contract HubRefreshPremiumTest is HubBase {
118120
_applyPremiumDelta(premiumDataBefore, premiumDelta)
119121
);
120122
assertLe(premiumAfter - premiumBefore, 2, 'premium should not increase by more than 2');
123+
assertBorrowRateSynced(hub1, daiAssetId, 'after refreshPremium');
121124
}
122125

123126
function test_refreshPremium_negativeDeltas_withAccrual(
@@ -180,6 +183,7 @@ contract HubRefreshPremiumTest is HubBase {
180183
_applyPremiumDelta(premiumDataBefore, premiumDelta)
181184
);
182185
assertLe(premiumAfter - premiumBefore, 2, 'premium should not increase by more than 2');
186+
assertBorrowRateSynced(hub1, daiAssetId, 'after refreshPremium');
183187
}
184188
}
185189

@@ -252,6 +256,7 @@ contract HubRefreshPremiumTest is HubBase {
252256
_applyPremiumDelta(premiumDataBefore, premiumDelta)
253257
);
254258
assertLe(premiumAfter - premiumBefore, 2, 'premium should not increase by more than 2');
259+
assertBorrowRateSynced(hub1, daiAssetId, 'after refreshPremium');
255260
}
256261
}
257262

0 commit comments

Comments
 (0)