@@ -22,7 +22,7 @@ import { isSessionKeyMode } from '../synapse/index.js'
2222// Constants
2323export const USDFC_DECIMALS = 18
2424const MIN_FIL_FOR_GAS = ethers . parseEther ( '0.1' ) // Minimum FIL padding for gas
25- export const DEFAULT_LOCKUP_DAYS = 10 // WarmStorage requires 10 days lockup
25+ export const DEFAULT_LOCKUP_DAYS = 30 // WarmStorage requires 30 days lockup
2626
2727// Maximum allowances for trusted WarmStorage service
2828// Using MaxUint256 which MetaMask displays as "Unlimited"
@@ -381,7 +381,7 @@ export async function setServiceApprovals(
381381) : Promise < string > {
382382 const warmStorageAddress = synapse . getWarmStorageAddress ( )
383383
384- // Max lockup period is always 10 days worth of epochs for WarmStorage
384+ // Max lockup period is always 30 days worth of epochs for WarmStorage
385385 const maxLockupPeriod = BigInt ( DEFAULT_LOCKUP_DAYS ) * TIME_CONSTANTS . EPOCHS_PER_DAY
386386
387387 // Set the service approval
@@ -415,9 +415,11 @@ export async function checkAllowances(synapse: Synapse): Promise<{
415415 // Get current allowances
416416 const currentAllowances = await synapse . payments . serviceApproval ( warmStorageAddress , TOKENS . USDFC )
417417
418- // Check if we need to update (not at max)
418+ // Check if we need to update (not at max or max lockup period is not enough )
419419 const needsUpdate =
420- currentAllowances . rateAllowance < MAX_RATE_ALLOWANCE || currentAllowances . lockupAllowance < MAX_LOCKUP_ALLOWANCE
420+ currentAllowances . rateAllowance < MAX_RATE_ALLOWANCE ||
421+ currentAllowances . lockupAllowance < MAX_LOCKUP_ALLOWANCE ||
422+ currentAllowances . maxLockupPeriod < BigInt ( DEFAULT_LOCKUP_DAYS ) * TIME_CONSTANTS . EPOCHS_PER_DAY
421423
422424 return {
423425 needsUpdate,
@@ -537,9 +539,9 @@ export function calculateStorageAllowances(storageTiB: number, pricePerTiBPerEpo
537539 // Calculate rate allowance (per epoch payment)
538540 const rateAllowance = ( pricePerTiBPerEpoch * BigInt ( scaledStorage ) ) / BigInt ( scale )
539541
540- // Calculate lockup allowance (10 days worth)
541- const epochsIn10Days = BigInt ( DEFAULT_LOCKUP_DAYS ) * TIME_CONSTANTS . EPOCHS_PER_DAY
542- const lockupAllowance = rateAllowance * epochsIn10Days
542+ // Calculate lockup allowance
543+ const epochsInLockupDays = BigInt ( DEFAULT_LOCKUP_DAYS ) * TIME_CONSTANTS . EPOCHS_PER_DAY
544+ const lockupAllowance = rateAllowance * epochsInLockupDays
543545
544546 return {
545547 rateAllowance,
@@ -580,7 +582,7 @@ export function calculateActualCapacity(rateAllowance: bigint, pricePerTiBPerEpo
580582 * Calculate storage capacity from USDFC amount
581583 *
582584 * Determines how much storage can be purchased with a given USDFC amount,
583- * accounting for the 10 -day lockup period.
585+ * accounting for the 30 -day lockup period.
584586 *
585587 * @param usdfcAmount - Amount of USDFC in its smallest unit
586588 * @param pricePerTiBPerEpoch - Current pricing from storage service
@@ -589,17 +591,17 @@ export function calculateActualCapacity(rateAllowance: bigint, pricePerTiBPerEpo
589591export function calculateStorageFromUSDFC ( usdfcAmount : bigint , pricePerTiBPerEpoch : bigint ) : number {
590592 if ( pricePerTiBPerEpoch === 0n ) return 0
591593
592- // Calculate how much this covers for 10 days
593- const epochsIn10Days = BigInt ( DEFAULT_LOCKUP_DAYS ) * TIME_CONSTANTS . EPOCHS_PER_DAY
594- const ratePerEpoch = usdfcAmount / epochsIn10Days
594+ // Calculate how much this covers for lockup
595+ const epochsInLockupDays = BigInt ( DEFAULT_LOCKUP_DAYS ) * TIME_CONSTANTS . EPOCHS_PER_DAY
596+ const ratePerEpoch = usdfcAmount / epochsInLockupDays
595597
596598 return calculateActualCapacity ( ratePerEpoch , pricePerTiBPerEpoch )
597599}
598600
599601/**
600602 * Compute the additional deposit required to fund current usage for a duration.
601603 *
602- * The WarmStorage service maintains ~10 days of lockup (lockupUsed) and draws future
604+ * The WarmStorage service maintains ~30 days of lockup (lockupUsed) and draws future
603605 * lockups from the available deposit (deposited - lockupUsed). To keep the current
604606 * rails alive for N days, ensure available >= N days of spend at the current rateUsed.
605607 *
@@ -808,7 +810,7 @@ export function computeAdjustmentForExactDaysWithPiece(
808810 * treating WarmStorage as fully trusted with max allowances, i.e. not
809811 * accounting for allowance limits. If usage limits need to be accounted for
810812 * then the capacity can be capped by either deposit or allowances.
811- * This function accounts for the 10 -day lockup requirement.
813+ * This function accounts for the 30 -day lockup requirement.
812814 *
813815 * @param depositAmount - Amount deposited in USDFC
814816 * @param pricePerTiBPerEpoch - Current pricing from storage service
@@ -837,22 +839,22 @@ export function calculateDepositCapacity(
837839 }
838840
839841 // With infinite allowances, deposit is the only limiting factor
840- // Deposit needs to cover: lockup (10 days) + at least some buffer
841- const epochsIn10Days = BigInt ( DEFAULT_LOCKUP_DAYS ) * TIME_CONSTANTS . EPOCHS_PER_DAY
842+ // Deposit needs to cover: lockup (30 days) + at least some buffer
843+ const epochsInLockupDays = BigInt ( DEFAULT_LOCKUP_DAYS ) * TIME_CONSTANTS . EPOCHS_PER_DAY
842844 const epochsPerMonth = TIME_CONSTANTS . EPOCHS_PER_MONTH
843845
844846 // Maximum storage we can support with this deposit
845847 // Reserve 10% for buffer beyond the lockup
846848 // Calculate max rate per epoch we can afford with deposit
847- const maxRatePerEpoch = ( depositAmount * BUFFER_DENOMINATOR ) / ( epochsIn10Days * BUFFER_NUMERATOR )
849+ const maxRatePerEpoch = ( depositAmount * BUFFER_DENOMINATOR ) / ( epochsInLockupDays * BUFFER_NUMERATOR )
848850
849851 // Convert to storage capacity
850852 const tibPerMonth = calculateActualCapacity ( maxRatePerEpoch , pricePerTiBPerEpoch )
851853 const gibPerMonth = tibPerMonth * 1024
852854
853855 // Calculate the actual costs for this capacity
854856 const monthlyPayment = maxRatePerEpoch * epochsPerMonth
855- const requiredLockup = maxRatePerEpoch * epochsIn10Days
857+ const requiredLockup = maxRatePerEpoch * epochsInLockupDays
856858 const totalRequired = withBuffer ( requiredLockup )
857859
858860 return {
0 commit comments