@@ -435,16 +435,7 @@ contract LM_PC_Lending_Facility_v1 is
435435 IBondingCurveBase_v1 (_dbcFmAddress).getIssuanceToken ()
436436 ).totalSupply ();
437437
438- // Get the first segment's initial price (P_floor)
439- PackedSegment[] memory segments = dbcFm.getSegments ();
440- if (segments.length == 0 ) {
441- revert
442- ILM_PC_Lending_Facility_v1
443- .Module__LM_PC_Lending_Facility_NoSegmentsConfigured ();
444- }
445-
446- // Use PackedSegmentLib to get the initial price of the first segment
447- uint pFloor = PackedSegmentLib._initialPrice (segments[0 ]);
438+ uint pFloor = _getFloorPrice ();
448439
449440 // Borrow Capacity = virtualIssuanceSupply * P_floor
450441 return virtualIssuanceSupply * pFloor / 1e18 ; // Adjust for decimals
@@ -458,11 +449,9 @@ contract LM_PC_Lending_Facility_v1 is
458449 view
459450 returns (uint )
460451 {
461- // Use the DBC FM to get the actual floor price
452+ // Use the DBC FM to get the actual floor price from the first segment
462453 // User borrowing power = locked issuance tokens * floor price
463- IFM_BC_Discrete_Redeeming_VirtualSupply_v1 dbcFm =
464- IFM_BC_Discrete_Redeeming_VirtualSupply_v1 (_dbcFmAddress);
465- uint floorPrice = dbcFm.getStaticPriceForBuying ();
454+ uint floorPrice = _getFloorPrice ();
466455 return _lockedIssuanceTokens[user_] * floorPrice / 1e18 ; // Adjust for decimals
467456 }
468457
@@ -507,11 +496,9 @@ contract LM_PC_Lending_Facility_v1 is
507496 view
508497 returns (uint )
509498 {
510- // Use the DBC FM to get the actual floor price
499+ // Use the DBC FM to get the actual floor price from the first segment
511500 // Required collateral = issuance tokens * floor price
512- IFM_BC_Discrete_Redeeming_VirtualSupply_v1 dbcFm =
513- IFM_BC_Discrete_Redeeming_VirtualSupply_v1 (_dbcFmAddress);
514- uint floorPrice = dbcFm.getStaticPriceForBuying ();
501+ uint floorPrice = _getFloorPrice ();
515502 return issuanceTokenAmount_ * floorPrice / 1e18 ; // Adjust for decimals
516503 }
517504
@@ -533,6 +520,17 @@ contract LM_PC_Lending_Facility_v1 is
533520 function _getFloorPrice () internal view returns (uint ) {
534521 IFM_BC_Discrete_Redeeming_VirtualSupply_v1 dbcFm =
535522 IFM_BC_Discrete_Redeeming_VirtualSupply_v1 (_dbcFmAddress);
536- return dbcFm.getStaticPriceForBuying ();
523+
524+ // Get the segments from the funding manager
525+ PackedSegment[] memory segments = dbcFm.getSegments ();
526+
527+ if (segments.length == 0 ) {
528+ revert
529+ ILM_PC_Lending_Facility_v1
530+ .Module__LM_PC_Lending_Facility_NoSegmentsConfigured ();
531+ }
532+
533+ // Return the initial price of the first segment (floor price)
534+ return PackedSegmentLib._initialPrice (segments[0 ]);
537535 }
538536}
0 commit comments