Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v1 source realm

Package halt provides functionality for managing protocol halt levels and operations.

Readme View source

Halt

Emergency pause mechanism for protocol safety.

Overview

Halt system provides granular control over protocol operations for emergency response and beta safety mode. The initial halt level is NONE; an authorized caller must explicitly select another level.

Configuration

Halt Levels

  • NONE: All operations enabled (normal operation)
  • SAFE_MODE: All operations enabled except withdrawals (must be explicitly configured)
  • EMERGENCY: Only governance and withdrawal operations enabled (crisis response)
  • COMPLETE: All operations disabled (full system halt)

Controllable Operations (OpTypes)

  • pool: Pool creation and liquidity operations
  • position: Position NFT minting and management
  • protocol_fee: Fee collection and distribution
  • router: Swap routing and execution
  • staker: Liquidity staking and rewards
  • launchpad: Token distribution projects
  • governance: Proposal creation and voting
  • gov_staker: GNS staking for xGNS
  • xgns: xGNS token operations
  • community_pool: Treasury management
  • emission: GNS emission and distribution
  • withdraw: Withdrawal operations (LP, rewards, etc.)

Key Functions

SetHaltLevel

Sets system-wide halt level.

SetOperationStatus

Controls individual operation types.

IsHalted

Checks if operation is halted.

Usage

 1// Set system to safe mode explicitly when needed
 2SetHaltLevel(cross(cur), HaltLevelSafeMode)
 3
 4// Enable emergency mode
 5SetHaltLevel(cross(cur), HaltLevelEmergency)
 6
 7// Halt specific operation
 8SetOperationStatus(cross(cur), OpTypeRouter, true)
 9
10// Resume specific operation
11SetOperationStatus(cross(cur), OpTypeRouter, false)
12
13// Check before operation
14halted, err := IsHalted(OpTypeWithdraw)
15if err != nil {
16    panic(err)
17}
18if halted {
19    panic("withdrawals halted")
20}

Halt Level Behaviors

NONE (Normal Operation)

  • All contracts fully operational
  • No restrictions applied

SAFE_MODE (Explicitly Configured)

  • All operations enabled except withdrawals
  • Used when explicitly selected during initial mainnet launch or another controlled window
  • Allows trading but prevents fund extraction

EMERGENCY (Crisis Response)

  • Only governance and withdrawals enabled
  • Allows users to exit positions
  • Governance can still execute proposals

COMPLETE (Full Halt)

  • All operations disabled
  • Complete system freeze
  • Recovery requires admin/governance action
  • Governance can still propose, vote on, and execute proposals that only target the halt realm, so it can recover on its own

Security

  • Admin/governance control only
  • The system initializes at NONE; SAFE_MODE is not enabled by default
  • Granular operation control
  • Event emission for transparency
  • Emergency response capability

Overview

Package halt provides functionality for managing protocol halt levels and operations.

Constants 2

const HaltLevelNone, HaltLevelSafeMode, HaltLevelEmergency, HaltLevelComplete

1const (
2	HaltLevelNone      HaltLevel = "NONE"      // All operations enabled.
3	HaltLevelSafeMode  HaltLevel = "SAFE_MODE" // All operations enabled except withdrawals.
4	HaltLevelEmergency HaltLevel = "EMERGENCY" // Only governance and withdrawal operations enabled.
5	HaltLevelComplete  HaltLevel = "COMPLETE"  // All operations disabled.
6)
source

Halt levels define different states of system operation restriction.

const OpTypePool, OpTypePosition, OpTypeProtocolFee, OpTypeRouter, OpTypeStaker, OpTypeLaunchpad, OpTypeGovernance, OpTypeGovStaker, OpTypeXGns, OpTypeCommunityPool, OpTypeEmission, OpTypeWithdraw

 1const (
 2	OpTypePool          OpType = "pool"
 3	OpTypePosition      OpType = "position"
 4	OpTypeProtocolFee   OpType = "protocol_fee"
 5	OpTypeRouter        OpType = "router"
 6	OpTypeStaker        OpType = "staker"
 7	OpTypeLaunchpad     OpType = "launchpad"
 8	OpTypeGovernance    OpType = "governance"
 9	OpTypeGovStaker     OpType = "gov_staker"
10	OpTypeXGns          OpType = "xgns"
11	OpTypeCommunityPool OpType = "community_pool"
12	OpTypeEmission      OpType = "emission"
13	OpTypeWithdraw      OpType = "withdraw"
14)
source

Operation types representing individual contracts.

Functions 32

func AssertIsNotHaltedOperation

Action
1func AssertIsNotHaltedOperation(op OpType)
source

AssertIsNotHaltedOperation panics if the specified operation type is halted. Panics with error details including operation type name.

Parameters:

  • op: valid operation type whose halt status must permit execution; invalid operation types panic with an invalid-operation error.

func GetHaltConfigJson

Action
1func GetHaltConfigJson() string
source

GetHaltConfigJson returns the halt configuration as a JSON string.

Returns:

  • json: JSON object containing each operation type's halt status

func IsHalted

Action
1func IsHalted(opTypes ...OpType) (bool, error)
source

IsHalted returns true if any of the specified operation types are halted. Returns error if any operation type is invalid.

Parameters:

  • opTypes: operation types to inspect; an empty list reports no halted operations

Returns:

  • halted: true when any requested operation is halted; on invalid input it is also true alongside the error
  • error: nil when all requested operation types are valid and inspected; an invalid-operation or state error otherwise

func IsHaltedCommunityPool

Action
1func IsHaltedCommunityPool() bool
source

IsHaltedCommunityPool returns true if community pool operations are halted.

Returns:

  • halted: true when community-pool operations are halted; false otherwise

func IsHaltedEmission

Action
1func IsHaltedEmission() bool
source

IsHaltedEmission returns true if emission operations are halted.

Returns:

  • halted: true when emission operations are halted; false otherwise

func IsHaltedGovStaker

Action
1func IsHaltedGovStaker() bool
source

IsHaltedGovStaker returns true if governance staker operations are halted.

Returns:

  • halted: true when governance-staker operations are halted; false otherwise

func IsHaltedGovernance

Action
1func IsHaltedGovernance() bool
source

IsHaltedGovernance returns true if governance operations are halted.

Returns:

  • halted: true when governance operations are halted; false otherwise

func IsHaltedLaunchpad

Action
1func IsHaltedLaunchpad() bool
source

IsHaltedLaunchpad returns true if launchpad operations are halted.

Returns:

  • halted: true when launchpad operations are halted; false otherwise

func IsHaltedPool

Action
1func IsHaltedPool() bool
source

IsHaltedPool returns true if pool operations are halted.

Returns:

  • halted: true when pool operations are halted; false otherwise

func IsHaltedPosition

Action
1func IsHaltedPosition() bool
source

IsHaltedPosition returns true if position operations are halted.

Returns:

  • halted: true when position operations are halted; false otherwise

func IsHaltedProtocolFee

Action
1func IsHaltedProtocolFee() bool
source

IsHaltedProtocolFee returns true if protocol fee operations are halted.

Returns:

  • halted: true when protocol-fee operations are halted; false otherwise

func IsHaltedRouter

Action
1func IsHaltedRouter() bool
source

IsHaltedRouter returns true if router operations are halted.

Returns:

  • halted: true when router operations are halted; false otherwise

func IsHaltedStaker

Action
1func IsHaltedStaker() bool
source

IsHaltedStaker returns true if staker operations are halted.

Returns:

  • halted: true when staker operations are halted; false otherwise

func IsHaltedWithdraw

Action
1func IsHaltedWithdraw() bool
source

IsHaltedWithdraw returns true if withdraw operations are halted.

Returns:

  • halted: true when withdrawal operations are halted; false otherwise

func IsHaltedXGns

Action
1func IsHaltedXGns() bool
source

IsHaltedXGns returns true if xGNS operations are halted.

Returns:

  • halted: true when xGNS operations are halted; false otherwise

func Render

1func Render(path string) string
source

Render returns the current halt status for every operation.

func SetHaltLevel

crossing Action
1func SetHaltLevel(cur realm, level HaltLevel)
source

SetHaltLevel sets the global halt level.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • level: halt level to apply (None, SafeMode, Emergency, or Complete).

Only callable by admin or governance.

func SetOperationStatus

crossing Action
1func SetOperationStatus(cur realm, op OpType, halted bool)
source

SetOperationStatus sets the halt status for a specific operation.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • op: operation type whose halt status is changed.
  • halted: true to block the operation, false to allow it.

Only callable by admin or governance.

func GetHaltConfig

Action
1func GetHaltConfig() HaltConfig
source

GetHaltConfig returns a copy of the current halt configuration.

Returns:

  • config: copy of the current halt status keyed by operation type

func OpTypes

Action
1func OpTypes() []OpType
source

OpTypes returns all operation types currently supported by the halt configuration.

Returns:

  • operationTypes: slice containing each defined operation type in map iteration order

Types 4

type HaltConfig

map
1type HaltConfig map[OpType]bool
source

HaltConfig stores halt state for each operation type.

Methods on HaltConfig

func Clone

method on HaltConfig
1func (c HaltConfig) Clone() HaltConfig
source

Clone creates a deep copy of the halt configuration and returns it.

Returns:

  • clone: independent map containing the same operation halt flags as the receiver.

func IsHalted

method on HaltConfig
1func (c HaltConfig) IsHalted(op OpType) bool
source

IsHalted returns true if the specified operation is halted, false otherwise. Returns false if operation type is not found in configuration.

Parameters:

  • op: operation type whose halt flag is queried.

Returns:

  • halted: configured halt flag; false when op is absent from the configuration.

type HaltLevel

ident
1type HaltLevel string
source

HaltLevel represents current system halt state.

Methods on HaltLevel

func Description

method on HaltLevel
1func (h HaltLevel) Description() string
source

Description returns a human-readable description of the halt level.

Returns:

  • description: human-readable policy description; "Unknown halt level" for an unrecognized value

func IsValid

method on HaltLevel
1func (h HaltLevel) IsValid() bool
source

IsValid returns true if the halt level is valid.

Returns:

  • valid: true for one of the defined halt levels; false otherwise

func String

method on HaltLevel
1func (h HaltLevel) String() string
source

String returns the string representation of the halt level.

Returns:

  • text: exact string value represented by the halt level

type HaltStateManager

map
1type HaltStateManager map[OpType]bool
source

Methods on HaltStateManager

func IsOperationHalted

method on HaltStateManager
1func (h HaltStateManager) IsOperationHalted(op OpType) (bool, error)
source

IsOperationHalted returns the halt state for an operation type.

Parameters:

  • op: operation type whose halt flag is queried.

Returns:

  • halted: configured halt flag for op.
  • error: nil when op exists; otherwise errOpTypeNotFound.

func ToConfig

method on HaltStateManager
1func (h HaltStateManager) ToConfig() HaltConfig
source

ToConfig converts the HaltStateManager to an independent HaltConfig copy.

Returns:

  • config: copied operation-to-halt-flag map.

type OpType

ident
1type OpType string
source

OpType represents operation types that can be controlled independently.

Methods on OpType

func IsValid

method on OpType
1func (o OpType) IsValid() bool
source

IsValid returns true if the operation type is valid.

Returns:

  • valid: true when the operation type is defined; false otherwise

func String

method on OpType
1func (o OpType) String() string
source

String returns the string representation of the operation type.

Returns:

  • text: exact string value represented by the operation type

Imports 7

Source Files 11