Skip to content

Commit 875fc8c

Browse files
authored
fix: Check reserve is listed when setting as collateral (#684)
* fix: reserve existance check when set as collateral * fix: gas snapshots
1 parent 8f9301e commit 875fc8c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

snapshots/Spoke.Operations.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"liquidationCall: partial": "384217",
66
"permitReserve + repay (multicall)": "269705",
77
"permitReserve + supply (multicall)": "140588",
8-
"permitReserve + supply + enable collateral (multicall)": "173977",
8+
"permitReserve + supply + enable collateral (multicall)": "174118",
99
"repay: full": "173610",
1010
"repay: partial": "228487",
11-
"supply + enable collateral (multicall)": "152410",
11+
"supply + enable collateral (multicall)": "152551",
1212
"supply: 0 borrows, collateral disabled": "116422",
1313
"supply: 0 borrows, collateral enabled": "119569",
1414
"supply: 1 borrow": "119558",
@@ -17,8 +17,8 @@
1717
"updateUserDynamicConfig: 2 collaterals": "58377",
1818
"updateUserRiskPremium: 1 borrow": "122190",
1919
"updateUserRiskPremium: 2 borrows": "158175",
20-
"usingAsCollateral: 0 borrows, enable": "53930",
21-
"usingAsCollateral: 1 borrow, disable": "132392",
20+
"usingAsCollateral: 0 borrows, enable": "54071",
21+
"usingAsCollateral: 1 borrow, disable": "132533",
2222
"usingAsCollateral: 1 borrow, enable": "24831",
2323
"withdraw: 0 borrows, full": "136817",
2424
"withdraw: 0 borrows, partial": "137740",

src/contracts/Spoke.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ contract Spoke is ISpoke, Multicall, AccessManaged, EIP712 {
739739
DataTypes.Reserve storage reserve,
740740
bool usingAsCollateral
741741
) internal view {
742+
require(address(reserve.hub) != address(0), ReserveNotListed());
742743
require(!reserve.paused, ReservePaused());
743744
// deactivation should be allowed
744745
require(!usingAsCollateral || !reserve.frozen, ReserveFrozen());

tests/unit/Spoke/Spoke.SetUsingAsCollateral.t.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import 'tests/unit/Spoke/SpokeBase.t.sol';
77
contract SpokeConfigTest is SpokeBase {
88
using SafeCast for uint256;
99

10+
function test_setUsingAsCollateral_revertsWith_ReserveNotListed() public {
11+
uint256 reserveCount = spoke1.getReserveCount();
12+
vm.prank(alice);
13+
vm.expectRevert(ISpoke.ReserveNotListed.selector);
14+
spoke1.setUsingAsCollateral(reserveCount, true, alice);
15+
}
16+
1017
function test_setUsingAsCollateral_revertsWith_ReserveFrozen() public {
1118
uint256 daiReserveId = _daiReserveId(spoke1);
1219

0 commit comments

Comments
 (0)