Skip to content

Commit c7aa970

Browse files
committed
refactor: use camelCase for pricing storage variables
refactor: use camelCase for pricing storage variables
1 parent 2e18fc5 commit c7aa970

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

service_contracts/src/FilecoinWarmStorageService.sol

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ contract FilecoinWarmStorageService is
268268
PlannedUpgrade private nextUpgrade;
269269

270270
// Pricing rates (mutable for future adjustments)
271-
uint256 private STORAGE_PRICE_PER_TIB_PER_MONTH;
272-
uint256 private CACHE_MISS_PRICE_PER_TIB_PER_MONTH;
273-
uint256 private CDN_PRICE_PER_TIB_PER_MONTH;
271+
uint256 private storagePricePerTibPerMonth;
272+
uint256 private cacheMissPricePerTibPerMonth;
273+
uint256 private cdnPricePerTibPerMonth;
274274

275275
event UpgradeAnnounced(PlannedUpgrade plannedUpgrade);
276276

@@ -379,9 +379,9 @@ contract FilecoinWarmStorageService is
379379
serviceCommissionBps = 0; // 0%
380380

381381
// Initialize pricing rates based on token decimals
382-
STORAGE_PRICE_PER_TIB_PER_MONTH = (5 * 10 ** TOKEN_DECIMALS) / 2; // 2.5 USDFC
383-
CACHE_MISS_PRICE_PER_TIB_PER_MONTH = (1 * 10 ** TOKEN_DECIMALS) / 2; // 0.5 USDFC
384-
CDN_PRICE_PER_TIB_PER_MONTH = (1 * 10 ** TOKEN_DECIMALS) / 2; // 0.5 USDFC
382+
storagePricePerTibPerMonth = (5 * 10 ** TOKEN_DECIMALS) / 2; // 2.5 USDFC
383+
cacheMissPricePerTibPerMonth = (1 * 10 ** TOKEN_DECIMALS) / 2; // 0.5 USDFC
384+
cdnPricePerTibPerMonth = (1 * 10 ** TOKEN_DECIMALS) / 2; // 0.5 USDFC
385385
}
386386

387387
function announcePlannedUpgrade(PlannedUpgrade calldata plannedUpgrade) external onlyOwner {
@@ -480,17 +480,17 @@ contract FilecoinWarmStorageService is
480480
require(newStoragePrice > 0 || newCacheMissPrice > 0 || newCdnPrice > 0, "At least one price must be non-zero");
481481

482482
if (newStoragePrice > 0) {
483-
STORAGE_PRICE_PER_TIB_PER_MONTH = newStoragePrice;
483+
storagePricePerTibPerMonth = newStoragePrice;
484484
}
485485
if (newCacheMissPrice > 0) {
486-
CACHE_MISS_PRICE_PER_TIB_PER_MONTH = newCacheMissPrice;
486+
cacheMissPricePerTibPerMonth = newCacheMissPrice;
487487
}
488488
if (newCdnPrice > 0) {
489-
CDN_PRICE_PER_TIB_PER_MONTH = newCdnPrice;
489+
cdnPricePerTibPerMonth = newCdnPrice;
490490
}
491491

492492
emit PricingUpdated(
493-
STORAGE_PRICE_PER_TIB_PER_MONTH, CACHE_MISS_PRICE_PER_TIB_PER_MONTH, CDN_PRICE_PER_TIB_PER_MONTH
493+
storagePricePerTibPerMonth, cacheMissPricePerTibPerMonth, cdnPricePerTibPerMonth
494494
);
495495
}
496496

@@ -1230,9 +1230,9 @@ contract FilecoinWarmStorageService is
12301230
view
12311231
returns (uint256 storageRate, uint256 cacheMissRate, uint256 cdnRate)
12321232
{
1233-
storageRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, STORAGE_PRICE_PER_TIB_PER_MONTH);
1234-
cacheMissRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, CACHE_MISS_PRICE_PER_TIB_PER_MONTH);
1235-
cdnRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, CDN_PRICE_PER_TIB_PER_MONTH);
1233+
storageRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, storagePricePerTibPerMonth);
1234+
cacheMissRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, cacheMissPricePerTibPerMonth);
1235+
cdnRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, cdnPricePerTibPerMonth);
12361236
}
12371237

12381238
/**
@@ -1241,7 +1241,7 @@ contract FilecoinWarmStorageService is
12411241
* @return The storage rate per epoch
12421242
*/
12431243
function _calculateStorageRate(uint256 totalBytes) internal view returns (uint256) {
1244-
return calculateStorageSizeBasedRatePerEpoch(totalBytes, STORAGE_PRICE_PER_TIB_PER_MONTH);
1244+
return calculateStorageSizeBasedRatePerEpoch(totalBytes, storagePricePerTibPerMonth);
12451245
}
12461246

12471247
/**
@@ -1251,8 +1251,8 @@ contract FilecoinWarmStorageService is
12511251
* @return cdnRate The CDN rate per epoch
12521252
*/
12531253
function _calculateCDNRates(uint256 totalBytes) internal view returns (uint256 cacheMissRate, uint256 cdnRate) {
1254-
cacheMissRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, CACHE_MISS_PRICE_PER_TIB_PER_MONTH);
1255-
cdnRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, CDN_PRICE_PER_TIB_PER_MONTH);
1254+
cacheMissRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, cacheMissPricePerTibPerMonth);
1255+
cdnRate = calculateStorageSizeBasedRatePerEpoch(totalBytes, cdnPricePerTibPerMonth);
12561256
}
12571257

12581258
/**
@@ -1346,8 +1346,8 @@ contract FilecoinWarmStorageService is
13461346
*/
13471347
function getServicePrice() external view returns (ServicePricing memory pricing) {
13481348
pricing = ServicePricing({
1349-
pricePerTiBPerMonthNoCDN: STORAGE_PRICE_PER_TIB_PER_MONTH,
1350-
pricePerTiBPerMonthWithCDN: STORAGE_PRICE_PER_TIB_PER_MONTH + CDN_PRICE_PER_TIB_PER_MONTH,
1349+
pricePerTiBPerMonthNoCDN: storagePricePerTibPerMonth,
1350+
pricePerTiBPerMonthWithCDN: storagePricePerTibPerMonth + cdnPricePerTibPerMonth,
13511351
tokenAddress: usdfcTokenAddress,
13521352
epochsPerMonth: EPOCHS_PER_MONTH
13531353
});
@@ -1364,7 +1364,7 @@ contract FilecoinWarmStorageService is
13641364
view
13651365
returns (uint256 storagePrice, uint256 cacheMissPrice, uint256 cdnPrice)
13661366
{
1367-
return (STORAGE_PRICE_PER_TIB_PER_MONTH, CACHE_MISS_PRICE_PER_TIB_PER_MONTH, CDN_PRICE_PER_TIB_PER_MONTH);
1367+
return (storagePricePerTibPerMonth, cacheMissPricePerTibPerMonth, cdnPricePerTibPerMonth);
13681368
}
13691369

13701370
/**
@@ -1373,7 +1373,7 @@ contract FilecoinWarmStorageService is
13731373
* @return spPayment SP payment (per TiB per month)
13741374
*/
13751375
function getEffectiveRates() external view returns (uint256 serviceFee, uint256 spPayment) {
1376-
uint256 total = STORAGE_PRICE_PER_TIB_PER_MONTH;
1376+
uint256 total = storagePricePerTibPerMonth;
13771377

13781378
serviceFee = (total * serviceCommissionBps) / COMMISSION_MAX_BPS;
13791379
spPayment = total - serviceFee;

service_contracts/src/lib/FilecoinWarmStorageServiceLayout.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ 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 CACHE_MISS_PRICE_PER_TIB_PER_MONTH_SLOT = bytes32(uint256(21));
30+
bytes32 constant CDN_PRICE_PER_TIB_PER_MONTH_SLOT = bytes32(uint256(22));

0 commit comments

Comments
 (0)