TimeLocks
Defines the duration of each stage of a cross-chain swap for both source and destination chains.Stage Layout
Source Chain:Constructor
Use static factory methods (
new, fromDurations, fromBigInt) instead of calling the constructor directly.Static Properties
Default rescue delay of 604800 seconds (7 days)
Returns “uint256” - the Solidity type for time locks
Static Methods
new
Create TimeLocks with absolute delays from deployedAt.Source chain: Delay from deployedAt when finality lock ends and private withdrawal starts
Source chain: Delay from deployedAt when private withdrawal ends and public withdrawal starts
Source chain: Delay from deployedAt when public withdrawal ends and private cancellation starts
Source chain: Delay from deployedAt when private cancellation ends and public cancellation starts
Destination chain: Delay from deployedAt when finality lock ends and private withdrawal starts
Destination chain: Delay from deployedAt when private withdrawal ends and public withdrawal starts
Destination chain: Delay from deployedAt when public withdrawal ends and private cancellation starts
fromDurations
Create TimeLocks from stage durations.Duration of source chain finality lock stage
Duration of source chain private withdrawal stage
Duration of source chain public withdrawal stage
Duration of source chain private cancellation stage
Duration of destination chain finality lock stage
Duration of destination chain private withdrawal stage
Duration of destination chain public withdrawal stage
fromBigInt
Decode TimeLocks from a packed uint256 value.Packed 256-bit value containing all timelock parameters
Instance Properties
Timestamp when the escrow was deployed
Instance Methods
build
Encode TimeLocks to a packed uint256 value.setDeployedAt
Set the deployment timestamp.Unix timestamp of deployment
toSrcTimeLocks
Extract source chain time locks.Optional override for deployment timestamp (defaults to this.deployedAt)
toDstTimeLocks
Extract destination chain time locks.Optional override for deployment timestamp (defaults to this.deployedAt)
SrcTimeLocks
Source chain-specific time lock utilities for checking swap stages.Stage Enum
Static Methods
new
Instance Properties
Escrow deployment timestamp
Timestamp when private withdrawal starts
Timestamp when public withdrawal starts
Timestamp when private cancellation starts
Timestamp when public cancellation starts
Instance Methods
isFinalityLock
Check if the given time is in the finality lock stage.Unix timestamp to check (defaults to current time)
isPrivateWithdrawal
Check if the given time is in the private withdrawal stage.isPublicWithdrawal
Check if the given time is in the public withdrawal stage.isPrivateCancellation
Check if the given time is in the private cancellation stage.isPublicCancellation
Check if the given time is in the public cancellation stage.getStage
Get the current stage at a given time.Unix timestamp to check (defaults to current time)
equal
Check if this equals another SrcTimeLocks.DstTimeLocks
Destination chain-specific time lock utilities for checking swap stages.Stage Enum
Static Methods
new
Instance Properties
Escrow deployment timestamp
Timestamp when private withdrawal starts
Timestamp when public withdrawal starts
Timestamp when private cancellation starts
Instance Methods
isFinalityLock
Check if the given time is in the finality lock stage.Unix timestamp to check (defaults to current time)
isPrivateWithdrawal
Check if the given time is in the private withdrawal stage.isPublicWithdrawal
Check if the given time is in the public withdrawal stage.isPrivateCancellation
Check if the given time is in the private cancellation stage.getStage
Get the current stage at a given time.Unix timestamp to check (defaults to current time)