Function: modifyRailLockup(uint256 railId, uint256 period, uint256 lockupFixed)
This function modifies a rail’s lockup configuration. If the rail is terminated, only the fixed lockup may be reduced and the period must remain unchanged. If the rail is active, the period and/or fixed lockup may be adjusted subject to account-funding and operator-allowance constraints. The function settles the payer’s account before and after.
Inputs
railId
Control: Chosen by the operator.
Constraints: Must reference an active rail (
validateRailActive(railId)
), andonlyRailOperator(railId)
must hold. Account lockup is settled before/after viasettleAccountLockupBeforeAndAfterForRail(railId, false, 0)
.Impact: Selects which
Rail
is modified and which event is emitted.
period
Control: Chosen by the operator.
Constraints: If the rail is terminated, it must equal
rail.lockupPeriod
. If the rail is active and the payer’s account is not fully settled, it must also equalrail.lockupPeriod
. When increasing the period on an active rail, it must be ≤operatorApproval.maxLockupPeriod
.Impact: Determines the dynamic component of the new lockup — may change
rail.lockupPeriod
(active rails only) and adjustpayer.lockupCurrent
and operator lockup usage accordingly.
lockupFixed
Control: Chosen by the operator.
Constraints: If the rail is terminated, it must be ≤ current
rail.lockupFixed
. If the rail is active and the payer’s account is not fully settled, it must be ≤ currentrail.lockupFixed
. Any increase requires sufficient operator lockup allowance and sufficient payer funds.Impact: Contributes to the new lockup — updates
payer.lockupCurrent
, operator lockup usage, andrail.lockupFixed
.
Branches and code coverage
Intended branches
For a terminated rail — reduce
lockupFixed
only, keepperiod
unchanged, update payer lockup and operator usage, and emitRailLockupModified
.For an active rail, payer fully settled — change
period
and/orlockupFixed
within operator limits, adjust payer lockup and operator usage, and emit event.For an active rail, payer not fully settled — only allow
lockupFixed
to decrease andperiod
to remain unchanged and emit event.Revert — terminated rail with
period
change orlockupFixed
increase.Revert — increasing
period
beyondoperatorApproval.maxLockupPeriod
.Revert — insufficient
payer.lockupCurrent
for old/new lockup requirements or postsettlement check failure.