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

halt 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.

Configuration

Halt Levels

  • NONE: All operations enabled (normal operation)
  • SAFE_MODE: All operations enabled except withdrawals (beta mainnet default)
  • 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 (beta mainnet)
 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 (Beta Mainnet)

  • All operations enabled except withdrawals
  • Used during initial mainnet launch
  • 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

Security

  • Admin/governance control only
  • Beta mainnet starts in SAFE_MODE
  • 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 31

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.

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.

func SetHaltLevel

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

SetHaltLevel sets the global halt level.

Parameters:

  • level: halt level to apply (None, SafeMode, Emergency, Complete)

Only callable by admin or governance.

func SetOperationStatus

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

SetOperationStatus sets halt status for a specific operation.

Parameters:

  • op: operation type
  • halted: true to halt, false to resume

Only callable by admin or governance.

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.

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.

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.

func IsValid

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

IsValid returns true if the halt level is valid.

func String

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

String returns the string representation of 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

func ToConfig

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

ToConfig converts the `HaltStateManager` to a HaltConfig.

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.

func String

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

String returns the string representation of the operation type.

Imports 5

Source Files 10