@@ -17,7 +17,7 @@ import {MathUtils} from 'src/libraries/math/MathUtils.sol';
1717import {Constants} from 'src/libraries/helpers/Constants.sol ' ;
1818
1919import {IHubBase, IHub} from 'src/interfaces/IHub.sol ' ;
20- import {IAssetInterestRateStrategy } from 'src/interfaces/IAssetInterestRateStrategy .sol ' ;
20+ import {IBasicInterestRateStrategy } from 'src/interfaces/IBasicInterestRateStrategy .sol ' ;
2121
2222contract Hub is IHub , AccessManaged {
2323 using EnumerableSet for EnumerableSet.AddressSet;
@@ -59,8 +59,8 @@ contract Hub is IHub, AccessManaged {
5959 require (decimals <= Constants.MAX_ALLOWED_ASSET_DECIMALS, InvalidAssetDecimals ());
6060
6161 uint256 assetId = _assetCount++ ;
62- IAssetInterestRateStrategy (irStrategy).setInterestRateData (assetId, data);
63- uint256 drawnRate = IAssetInterestRateStrategy (irStrategy).calculateInterestRate ({
62+ IBasicInterestRateStrategy (irStrategy).setInterestRateData (assetId, data);
63+ uint256 drawnRate = IBasicInterestRateStrategy (irStrategy).calculateInterestRate ({
6464 assetId: assetId,
6565 liquidity: 0 ,
6666 drawn: 0 ,
@@ -171,7 +171,7 @@ contract Hub is IHub, AccessManaged {
171171 function setInterestRateData (uint256 assetId , bytes calldata data ) external restricted {
172172 DataTypes.Asset storage asset = _assets[assetId];
173173 asset.accrue (assetId, _spokes[assetId][asset.feeReceiver]);
174- IAssetInterestRateStrategy (asset.irStrategy).setInterestRateData (assetId, data);
174+ IBasicInterestRateStrategy (asset.irStrategy).setInterestRateData (assetId, data);
175175 asset.updateDrawnRate (assetId);
176176 }
177177
@@ -276,7 +276,7 @@ contract Hub is IHub, AccessManaged {
276276 return drawnShares;
277277 }
278278
279- /// @inheritdoc IHub
279+ /// @inheritdoc IHubBase
280280 function reportDeficit (
281281 uint256 assetId ,
282282 uint256 drawnAmount ,
@@ -326,7 +326,7 @@ contract Hub is IHub, AccessManaged {
326326 return shares;
327327 }
328328
329- /// @inheritdoc IHub
329+ /// @inheritdoc IHubBase
330330 function refreshPremium (uint256 assetId , DataTypes.PremiumDelta calldata premiumDelta ) external {
331331 DataTypes.Asset storage asset = _assets[assetId];
332332 DataTypes.SpokeData storage spoke = _spokes[assetId][msg .sender ];
@@ -342,7 +342,7 @@ contract Hub is IHub, AccessManaged {
342342 emit RefreshPremium (assetId, msg .sender , premiumDelta);
343343 }
344344
345- /// @inheritdoc IHub
345+ /// @inheritdoc IHubBase
346346 function payFee (uint256 assetId , uint256 shares ) external {
347347 DataTypes.SpokeData storage sender = _spokes[assetId][msg .sender ];
348348 address feeReceiver = _assets[assetId].feeReceiver;
@@ -413,6 +413,12 @@ contract Hub is IHub, AccessManaged {
413413 return _assets[assetId];
414414 }
415415
416+ /// @inheritdoc IHubBase
417+ function getAssetUnderlyingAndDecimals (uint256 assetId ) external view returns (address , uint8 ) {
418+ DataTypes.Asset storage asset = _assets[assetId];
419+ return (asset.underlying, asset.decimals);
420+ }
421+
416422 /// @inheritdoc IHub
417423 function getSpokeCount (uint256 assetId ) external view returns (uint256 ) {
418424 return _assetToSpokes[assetId].length ();
@@ -441,50 +447,46 @@ contract Hub is IHub, AccessManaged {
441447 uint256 assetId ,
442448 address spoke
443449 ) external view returns (DataTypes.SpokeConfig memory ) {
444- return
445- DataTypes.SpokeConfig ({
446- active: _spokes[assetId][spoke].active,
447- addCap: _spokes[assetId][spoke].addCap,
448- drawCap: _spokes[assetId][spoke].drawCap
449- });
450+ DataTypes.SpokeData storage spoke = _spokes[assetId][spoke];
451+ return DataTypes.SpokeConfig (spoke.active, spoke.addCap, spoke.drawCap);
450452 }
451453
452- /// @inheritdoc IHub
454+ /// @inheritdoc IHubBase
453455 function previewAddByAssets (uint256 assetId , uint256 assets ) public view returns (uint256 ) {
454456 return _assets[assetId].toAddedSharesDown (assets);
455457 }
456458
457- /// @inheritdoc IHub
459+ /// @inheritdoc IHubBase
458460 function previewAddByShares (uint256 assetId , uint256 shares ) public view returns (uint256 ) {
459461 return _assets[assetId].toAddedAssetsUp (shares);
460462 }
461463
462- /// @inheritdoc IHub
464+ /// @inheritdoc IHubBase
463465 function previewRemoveByAssets (uint256 assetId , uint256 assets ) public view returns (uint256 ) {
464466 return _assets[assetId].toAddedSharesUp (assets);
465467 }
466468
467- /// @inheritdoc IHub
469+ /// @inheritdoc IHubBase
468470 function previewRemoveByShares (uint256 assetId , uint256 shares ) public view returns (uint256 ) {
469471 return _assets[assetId].toAddedAssetsDown (shares);
470472 }
471473
472- /// @inheritdoc IHub
474+ /// @inheritdoc IHubBase
473475 function previewDrawByAssets (uint256 assetId , uint256 assets ) public view returns (uint256 ) {
474476 return _assets[assetId].toDrawnSharesUp (assets);
475477 }
476478
477- /// @inheritdoc IHub
479+ /// @inheritdoc IHubBase
478480 function previewDrawByShares (uint256 assetId , uint256 shares ) external view returns (uint256 ) {
479481 return _assets[assetId].toDrawnAssetsDown (shares);
480482 }
481483
482- /// @inheritdoc IHub
484+ /// @inheritdoc IHubBase
483485 function previewRestoreByAssets (uint256 assetId , uint256 assets ) public view returns (uint256 ) {
484486 return _assets[assetId].toDrawnSharesDown (assets);
485487 }
486488
487- /// @inheritdoc IHub
489+ /// @inheritdoc IHubBase
488490 function previewRestoreByShares (uint256 assetId , uint256 shares ) public view returns (uint256 ) {
489491 return _assets[assetId].toDrawnAssetsUp (shares);
490492 }
@@ -514,45 +516,78 @@ contract Hub is IHub, AccessManaged {
514516 return _assets[assetId].getDrawnIndex ();
515517 }
516518
519+ /// @inheritdoc IHubBase
517520 function getAssetOwed (uint256 assetId ) external view returns (uint256 , uint256 ) {
518521 DataTypes.Asset storage asset = _assets[assetId];
519522 return (asset.drawn (), asset.premium ());
520523 }
521524
525+ /// @inheritdoc IHubBase
522526 function getAssetTotalOwed (uint256 assetId ) external view returns (uint256 ) {
523527 return _assets[assetId].totalOwed ();
524528 }
525529
530+ /// @inheritdoc IHubBase
531+ function getAssetDrawnShares (uint256 assetId ) external view returns (uint256 ) {
532+ return _assets[assetId].drawnShares;
533+ }
534+
535+ /// @inheritdoc IHubBase
536+ function getAssetPremiumData (uint256 assetId ) external view returns (uint256 , uint256 , uint256 ) {
537+ DataTypes.Asset storage asset = _assets[assetId];
538+ return (asset.premiumShares, asset.premiumOffset, asset.realizedPremium);
539+ }
540+
541+ /// @inheritdoc IHubBase
526542 function getSpokeOwed (uint256 assetId , address spoke ) external view returns (uint256 , uint256 ) {
527543 DataTypes.SpokeData storage spokeData = _spokes[assetId][spoke];
528544 return (_getSpokeDrawn (spokeData, assetId), _getSpokePremium (spokeData, assetId));
529545 }
530546
547+ /// @inheritdoc IHubBase
531548 function getSpokeTotalOwed (uint256 assetId , address spoke ) external view returns (uint256 ) {
532549 DataTypes.SpokeData storage spokeData = _spokes[assetId][spoke];
533550 return _getSpokeDrawn (spokeData, assetId) + _getSpokePremium (spokeData, assetId);
534551 }
535552
553+ /// @inheritdoc IHubBase
554+ function getSpokeDrawnShares (uint256 assetId , address spoke ) external view returns (uint256 ) {
555+ return _spokes[assetId][spoke].drawnShares;
556+ }
557+
558+ /// @inheritdoc IHubBase
559+ function getSpokePremiumData (
560+ uint256 assetId ,
561+ address spoke
562+ ) external view returns (uint256 , uint256 , uint256 ) {
563+ DataTypes.SpokeData storage spokeData = _spokes[assetId][spoke];
564+ return (spokeData.premiumShares, spokeData.premiumOffset, spokeData.realizedPremium);
565+ }
566+
536567 function getAssetDrawnRate (uint256 assetId ) external view returns (uint256 ) {
537568 return _assets[assetId].drawnRate;
538569 }
539570
540- function getTotalAddedAssets (uint256 assetId ) external view returns (uint256 ) {
571+ /// @inheritdoc IHubBase
572+ function getAssetAddedAmount (uint256 assetId ) external view returns (uint256 ) {
541573 return _assets[assetId].totalAddedAssets ();
542574 }
543575
544- function getTotalAddedShares (uint256 assetId ) external view returns (uint256 ) {
576+ /// @inheritdoc IHubBase
577+ function getAssetAddedShares (uint256 assetId ) external view returns (uint256 ) {
545578 return _assets[assetId].totalAddedShares ();
546579 }
547580
548- function getSpokeAddedAmount (uint256 assetId , address spoke ) external view returns (uint256 ) {
581+ /// @inheritdoc IHubBase
582+ function getSpokeAddedAssets (uint256 assetId , address spoke ) external view returns (uint256 ) {
549583 DataTypes.Asset storage asset = _assets[assetId];
550584 uint256 unrealizedFeeShares;
551585 if (spoke == asset.feeReceiver) unrealizedFeeShares = asset.unrealizedFeeShares ();
552586 return
553587 previewRemoveByShares (assetId, _spokes[assetId][spoke].addedShares + unrealizedFeeShares);
554588 }
555589
590+ /// @inheritdoc IHubBase
556591 function getSpokeAddedShares (uint256 assetId , address spoke ) external view returns (uint256 ) {
557592 DataTypes.Asset storage asset = _assets[assetId];
558593 if (spoke == asset.feeReceiver) {
@@ -575,12 +610,13 @@ contract Hub is IHub, AccessManaged {
575610 }
576611
577612 function getAssetConfig (uint256 assetId ) external view returns (DataTypes.AssetConfig memory ) {
613+ DataTypes.Asset storage asset = _assets[assetId];
578614 return
579615 DataTypes.AssetConfig ({
580- feeReceiver: _assets[assetId] .feeReceiver,
581- liquidityFee: _assets[assetId] .liquidityFee,
582- irStrategy: _assets[assetId] .irStrategy,
583- reinvestmentController: _assets[assetId] .reinvestmentController
616+ feeReceiver: asset .feeReceiver,
617+ liquidityFee: asset .liquidityFee,
618+ irStrategy: asset .irStrategy,
619+ reinvestmentController: asset .reinvestmentController
584620 });
585621 }
586622
@@ -589,9 +625,10 @@ contract Hub is IHub, AccessManaged {
589625 address spoke ,
590626 DataTypes.SpokeConfig memory config
591627 ) internal {
592- _spokes[assetId][spoke].active = config.active;
593- _spokes[assetId][spoke].addCap = config.addCap;
594- _spokes[assetId][spoke].drawCap = config.drawCap;
628+ DataTypes.SpokeData storage spokeData = _spokes[assetId][spoke];
629+ spokeData.active = config.active;
630+ spokeData.addCap = config.addCap;
631+ spokeData.drawCap = config.drawCap;
595632 emit SpokeConfigUpdate (assetId, spoke, config);
596633 }
597634
0 commit comments