Search Apps Documentation Source Content File Folder Download Copy Actions Download

protocol_fee package

Overview

Package protocol\_fee manages fee collection and distribution for GnoSwap protocol operations. This contract collects fees from various protocol operations (swaps, pool creation, withdrawals, staking claims) and distributes them to DevOps and Governance Stakers according to configurable percentages. Distribution Targets: - DevOps: Development and operations fund (default 0%) - GovStaker: Governance stakers / xGNS holders (default 100%) Key Functions: - DistributeProtocolFee: Distributes accumulated fees to recipients - SetDevOpsPct/SetGovStakerPct: Configure distribution percentages - AddToProtocolFee: Adds fees to the distribution queue The contract uses a version manager pattern for upgradeable implementations.

Functions

AddToProtocolFee

func AddToProtocolFee(cur realm, tokenPath string, amount int64)

AddToProtocolFee adds tokens to the protocol fee pool. Parameters: - tokenPath: path of the token - amount: amount to add

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "AddToProtocolFee" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "AddToProtocolFee" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
  

ClearAccuTransferToGovStaker

func ClearAccuTransferToGovStaker(cur realm)

ClearAccuTransferToGovStaker clears accumulated transfers to GovStaker.

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "ClearAccuTransferToGovStaker" -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "ClearAccuTransferToGovStaker" -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
  

ClearTokenListWithAmount

func ClearTokenListWithAmount(cur realm)

ClearTokenListWithAmount clears the token list with amounts.

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "ClearTokenListWithAmount" -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "ClearTokenListWithAmount" -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
  

DistributeProtocolFee

func DistributeProtocolFee(cur realm) map[string]int64

DistributeProtocolFee distributes accumulated protocol fees to DevOps and GovStaker. Returns: - map\[string]int64: amounts distributed per token

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "DistributeProtocolFee" -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "DistributeProtocolFee" -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
  

GetAccuTransferToDevOpsByTokenPath

func GetAccuTransferToDevOpsByTokenPath(tokenPath string) int64

GetAccuTransferToDevOpsByTokenPath returns accumulated DevOps transfer for a token.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetAccuTransferToDevOpsByTokenPath()"

Result

GetAccuTransferToGovStakerByTokenPath

func GetAccuTransferToGovStakerByTokenPath(tokenPath string) int64

GetAccuTransferToGovStakerByTokenPath returns accumulated GovStaker transfer for a token.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetAccuTransferToGovStakerByTokenPath()"

Result

GetAccuTransfersToDevOps

func GetAccuTransfersToDevOps() map[string]int64

GetAccuTransfersToDevOps returns accumulated transfers to DevOps.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetAccuTransfersToDevOps()"

Result

GetAccuTransfersToGovStaker

func GetAccuTransfersToGovStaker() map[string]int64

GetAccuTransfersToGovStaker returns accumulated transfers to GovStaker.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetAccuTransfersToGovStaker()"

Result

GetAmountOfToken

func GetAmountOfToken(tokenPath string) int64

GetAmountOfToken returns the amount of a specific token.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetAmountOfToken()"

Result

GetDevOpsPct

func GetDevOpsPct() int64

GetDevOpsPct returns the DevOps fee percentage.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetDevOpsPct()"

Result

GetDomainPath

func GetDomainPath() string

GetDomainPath returns the domain path of the protocol fee contract.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetDomainPath()"

Result

GetGovStakerPct

func GetGovStakerPct() int64

GetGovStakerPct returns the GovStaker fee percentage.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetGovStakerPct()"

Result

GetImplementationPackagePath

func GetImplementationPackagePath() string

GetImplementationPackagePath returns the package path of the currently active implementation.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetImplementationPackagePath()"

Result

GetTokenList

func GetTokenList() []string

GetTokenList returns the list of token paths without amounts.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetTokenList()"

Result

GetTokenListWithAmount

func GetTokenListWithAmount() map[string]int64

GetTokenListWithAmount returns the list of tokens with their amounts.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetTokenListWithAmount()"

Result

GetVersionPackagePath

func GetVersionPackagePath() string

GetVersionPackagePath returns the current implementation package path.

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.GetVersionPackagePath()"

Result

RegisterInitializer

func RegisterInitializer(cur realm, initializer func(protocolFeeStore IProtocolFeeStore) IProtocolFee)

RegisterInitializer registers a new pool implementation version. This function is called by each version (v1, v2, etc.) during initialization to register their implementation with the proxy system. The initializer function creates a new instance of the implementation using the provided protocolFeeStore interface. The stateInitializer function creates the initial state for this version. Security: Only contracts within the domain path can register initializers. Each package path can only register once to prevent duplicate registrations.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "RegisterInitializer" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "RegisterInitializer" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
  

SetDevOpsPct

func SetDevOpsPct(cur realm, pct int64)

SetDevOpsPct sets the percentage of protocol fees allocated to DevOps. Parameters: - pct: percentage (0-100)

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "SetDevOpsPct" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "SetDevOpsPct" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
  

SetGovStakerPct

func SetGovStakerPct(cur realm, pct int64)

SetGovStakerPct sets the percentage of protocol fees allocated to GovStaker. Parameters: - pct: percentage (0-100)

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "SetGovStakerPct" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "SetGovStakerPct" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
  

UpgradeImpl

func UpgradeImpl(cur realm, packagePath string)

UpgradeImpl switches the active protocol fee implementation to a different version. This function allows seamless upgrades from one version to another without data migration or downtime. Security: Only admin or governance can perform upgrades. The new implementation must have been previously registered via RegisterInitializer.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "UpgradeImpl" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/protocol_fee" -func "UpgradeImpl" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
  

NewProtocolFeeStore

func NewProtocolFeeStore(kvStore store.KVStore) IProtocolFeeStore

NewprotocolFeeStore creates a new protocol fee store instance with the provided KV store. This function is used by the upgrade system to create storage instances for each implementation.

Param

Command

gnokey query vm/qeval -remote "https://rpc.test11.testnets.gno.land" -data "gno.land/r/gnoswap/protocol_fee.NewProtocolFeeStore()"

Result