Skip to content

Commit 8c2c906

Browse files
authored
fix: asset validation on mintFeeShares (#1070)
1 parent 6959e32 commit 8c2c906

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

snapshots/Hub.Operations.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"draw": "105931",
55
"eliminateDeficit: full": "59781",
66
"eliminateDeficit: partial": "69429",
7-
"mintFeeShares": "84007",
7+
"mintFeeShares": "86130",
88
"payFee": "72302",
99
"refreshPremium": "71999",
1010
"remove: full": "76993",

src/hub/Hub.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ contract Hub is IHub, AccessManaged {
206206

207207
/// @inheritdoc IHub
208208
function mintFeeShares(uint256 assetId) external restricted returns (uint256) {
209+
require(assetId < _assetCount, AssetNotListed());
209210
Asset storage asset = _assets[assetId];
210211
asset.accrue();
211212
uint256 feeShares = _mintFeeShares(asset, assetId);

tests/unit/Hub/Hub.MintFeeShares.t.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ contract HubMintFeeSharesTest is HubBase {
3131
Utils.mintFeeShares(hub1, daiAssetId, ADMIN);
3232
}
3333

34+
function test_mintFeeShares_revertsWith_AssetNotListed() public {
35+
uint256 invalidAssetId = hub1.getAssetCount();
36+
vm.expectRevert(IHub.AssetNotListed.selector);
37+
Utils.mintFeeShares(hub1, invalidAssetId, ADMIN);
38+
}
39+
3440
function test_mintFeeShares() public {
3541
// Create debt to build up fees on the existing treasury spoke
3642
_addAndDrawLiquidity({

0 commit comments

Comments
 (0)