Skip to content

Commit 79ada50

Browse files
committed
feat: integrate floor pricing with mutable pricing system
Rebased on main to incorporate floor pricing changes (commit 6cb08ce) and made MINIMUM_STORAGE_RATE_PER_MONTH mutable to enable runtime updates. Changes: - Converted minimumStorageRatePerMonth from immutable to storage variable - Added MAX_MINIMUM_STORAGE_RATE_PER_MONTH (0.24 USDFC, 4x initial 0.06) - Updated updatePricing() to accept newMinimumRate parameter - Updated PricingUpdated event to include minimumRate - Updated getCurrentPricingRates() to return both storage price and minimum rate - Added AtLeastOnePriceMustBeNonZero and PriceExceedsMaximum errors - Updated all references throughout contract to use camelCase variable names
1 parent 58df775 commit 79ada50

File tree

5 files changed

+42
-28
lines changed

5 files changed

+42
-28
lines changed

service_contracts/abi/Errors.abi.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
}
1111
]
1212
},
13+
{
14+
"type": "error",
15+
"name": "AtLeastOnePriceMustBeNonZero",
16+
"inputs": []
17+
},
1318
{
1419
"type": "error",
1520
"name": "CDNPaymentAlreadyTerminated",
@@ -715,6 +720,27 @@
715720
}
716721
]
717722
},
723+
{
724+
"type": "error",
725+
"name": "PriceExceedsMaximum",
726+
"inputs": [
727+
{
728+
"name": "priceType",
729+
"type": "string",
730+
"internalType": "string"
731+
},
732+
{
733+
"name": "maxAllowed",
734+
"type": "uint256",
735+
"internalType": "uint256"
736+
},
737+
{
738+
"name": "actual",
739+
"type": "uint256",
740+
"internalType": "uint256"
741+
}
742+
]
743+
},
718744
{
719745
"type": "error",
720746
"name": "ProofAlreadySubmitted",

service_contracts/abi/FilecoinWarmStorageService.abi.json

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,7 @@
292292
"internalType": "uint256"
293293
},
294294
{
295-
"name": "cacheMissPrice",
296-
"type": "uint256",
297-
"internalType": "uint256"
298-
},
299-
{
300-
"name": "cdnPrice",
295+
"name": "minimumRate",
301296
"type": "uint256",
302297
"internalType": "uint256"
303298
}
@@ -826,12 +821,7 @@
826821
"internalType": "uint256"
827822
},
828823
{
829-
"name": "newCacheMissPrice",
830-
"type": "uint256",
831-
"internalType": "uint256"
832-
},
833-
{
834-
"name": "newCdnPrice",
824+
"name": "newMinimumRate",
835825
"type": "uint256",
836826
"internalType": "uint256"
837827
}
@@ -1343,13 +1333,7 @@
13431333
"internalType": "uint256"
13441334
},
13451335
{
1346-
"name": "cacheMissPrice",
1347-
"type": "uint256",
1348-
"indexed": false,
1349-
"internalType": "uint256"
1350-
},
1351-
{
1352-
"name": "cdnPrice",
1336+
"name": "minimumRate",
13531337
"type": "uint256",
13541338
"indexed": false,
13551339
"internalType": "uint256"

service_contracts/src/Errors.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,13 @@ library Errors {
326326
error InsufficientMaxLockupPeriod(
327327
address payer, address operator, uint256 maxLockupPeriod, uint256 requiredLockupPeriod
328328
);
329+
330+
/// @notice At least one price parameter must be non-zero when updating pricing
331+
error AtLeastOnePriceMustBeNonZero();
332+
333+
/// @notice Price update exceeds the maximum allowed value
334+
/// @param priceType The type of price being updated (e.g., "storage", "minimumRate")
335+
/// @param maxAllowed The maximum allowed value for this price type
336+
/// @param actual The attempted value that exceeds the maximum
337+
error PriceExceedsMaximum(string priceType, uint256 maxAllowed, uint256 actual);
329338
}

service_contracts/src/FilecoinWarmStorageService.sol

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,7 @@ contract FilecoinWarmStorageService is
490490
* @param newStoragePrice New storage price per TiB per month (0 = no change, max 10 USDFC)
491491
* @param newMinimumRate New minimum monthly storage rate (0 = no change, max 0.24 USDFC)
492492
*/
493-
function updatePricing(uint256 newStoragePrice, uint256 newMinimumRate)
494-
external
495-
onlyOwner
496-
{
493+
function updatePricing(uint256 newStoragePrice, uint256 newMinimumRate) external onlyOwner {
497494
if (newStoragePrice == 0 && newMinimumRate == 0) {
498495
revert Errors.AtLeastOnePriceMustBeNonZero();
499496
}
@@ -1402,11 +1399,7 @@ contract FilecoinWarmStorageService is
14021399
* @return storagePrice Current storage price per TiB per month
14031400
* @return minimumRate Current minimum monthly storage rate
14041401
*/
1405-
function getCurrentPricingRates()
1406-
external
1407-
view
1408-
returns (uint256 storagePrice, uint256 minimumRate)
1409-
{
1402+
function getCurrentPricingRates() external view returns (uint256 storagePrice, uint256 minimumRate) {
14101403
return (storagePricePerTibPerMonth, minimumStorageRatePerMonth);
14111404
}
14121405

service_contracts/src/lib/FilecoinWarmStorageServiceLayout.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ bytes32 constant APPROVED_PROVIDER_IDS_SLOT = bytes32(uint256(16));
2525
bytes32 constant VIEW_CONTRACT_ADDRESS_SLOT = bytes32(uint256(17));
2626
bytes32 constant FIL_BEAM_CONTROLLER_ADDRESS_SLOT = bytes32(uint256(18));
2727
bytes32 constant NEXT_UPGRADE_SLOT = bytes32(uint256(19));
28+
bytes32 constant STORAGE_PRICE_PER_TIB_PER_MONTH_SLOT = bytes32(uint256(20));
29+
bytes32 constant MINIMUM_STORAGE_RATE_PER_MONTH_SLOT = bytes32(uint256(21));

0 commit comments

Comments
 (0)