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 v1 collects and distributes protocol fees from swaps.

Readme View source

Protocol Fee

Fee collection and distribution for protocol operations.

Overview

The protocol-fee contract collects authorized fees from protocol operations and distributes them to GovStaker and DevOps according to configured percentages.

Configuration

  • Router Fee (initial/default): 0.15% of the swap amount; configured by the router, with an admin-or-governance range of 0–10%
  • Pool Creation Fee (initial/default): 100 GNS; configured by the pool and modifiable through governance
  • Withdrawal Fee (initial/default): 1% of LP fees claimed; configured by the pool and modifiable through governance
  • Unstaking Fee (initial/default): 1% of staking rewards; configured by the staker and modifiable by admin or governance
  • Distribution (default): 100% to GovStaker and 0% to DevOps

The operation-specific fees above are configured in their owning modules; they are not protocol-fee distribution percentages.

Fee Sources

  1. Swaps: The router applies its configured swap fee (0.15% initially).
  2. Pool Creation: The pool charges its configured creation fee (100 GNS initially).
  3. LP Withdrawals: The pool charges its configured withdrawal fee (1% initially).
  4. Staking Claims: The staker charges its configured unstaking fee (1% initially).

Key Functions

DistributeProtocolFee

Distributes accumulated fees to recipients.

SetDevOpsPct

Sets the DevOps funding percentage.

SetGovStakerPct

Sets the GovStaker funding percentage.

AddToProtocolFee

Adds an approved fee amount to the distribution queue.

AdvanceAccrualEpoch

Closes the accrual epoch in force and returns the new one. Called by gov/staker on every stake change, so fees are attributed to the stake distribution live when they arrived.

ConsumeAccrualBuckets

Returns and clears up to limit of the oldest pending buckets of one token, as parallel epoch and amount slices. Called by gov/staker when that token is collected.

Usage

 1// Distribute accumulated fees
 2DistributeProtocolFee(cross(cur))
 3
 4// Configure distribution
 5SetDevOpsPct(cross(cur), 2000)     // 20% to DevOps
 6SetGovStakerPct(cross(cur), 8000)  // 80% to GovStaker
 7
 8// View tokens reserved for the next distribution
 9GetReservedTokens()
10
11// View what gov/staker has not folded yet
12GetAccrualEpoch()
13GetAccrualPendingTokens()
14GetAccrualBuckets(tokenPath, 0)

Security

  • Configuration changes are restricted to admin or governance; distribution is restricted to admin or gov/staker
  • Automatic fee accumulation
  • Multi-token support
  • Transparent distribution tracking

Overview

package v1 collects and distributes protocol fees from swaps.

This contract accumulates fees generated from trading activity and distributes them to devOps and governance stakers according to configurable percentages set through governance.

Functions 2

func NewProtocolFeeV1

Action
1func NewProtocolFeeV1(protocolFeeStore protocol_fee.IProtocolFeeStore) protocol_fee.IProtocolFee
source

NewProtocolFeeV1 creates the protocol-fee v1 implementation backed by protocolFeeStore.

Parameters:

  • protocolFeeStore: Store implementation containing the protocol-fee state for this version.

Returns:

  • implementation: An IProtocolFee implementation that exposes v1 behavior through protocolFeeStore.

func NewProtocolFeeStateBy

Action
1func NewProtocolFeeStateBy(protocolFeeStore protocol_fee.IProtocolFeeStore) *protocolFeeState
source

NewProtocolFeeState creates a new instance of protocolFeeState with initialized values

Parameters:

  • protocolFeeStore: Store implementation backing the new protocol-fee state view.

Returns:

  • state: New protocolFeeState wrapper backed by protocolFeeStore.

Imports 14

Source Files 12