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

emission package

Overview

Package emission manages GNS token emission and distribution for GnoSwap.

The emission system controls creation and distribution of new GNS tokens with a deflationary model featuring periodic halvings over 12 years.

Emission Schedule:

  • Year 1-2: 100% emission rate (225,000,000 GNS/year)
  • Year 3-4: 50% emission rate (112,500,000 GNS/year)
  • Year 5-6: 25% emission rate (56,250,000 GNS/year)
  • Year 7-8: 12.5% emission rate (28,125,000 GNS/year)
  • Year 9-12: 6.25% emission rate (14,062,500 GNS/year)

Distribution Targets (configurable via admin or governance):

  • LIQUIDITY_STAKER: Rewards for LP providers (default 75%)
  • DEVOPS: Development and operations fund (default 20%)
  • COMMUNITY_POOL: Community treasury (default 5%)
  • GOV_STAKER: GNS staking rewards (default 0%)

Key Functions:

  • MintAndDistributeGns: Mints and distributes GNS per emission schedule; returns false only when emission is halted.
  • SetDistributionStartTime: Sets or reschedules the start timestamp while it is still in the future; the timestamp is immutable once active.
  • ChangeDistributionPct: Updates distribution percentages
  • ClearDistributedToStaker/GovStaker: Resets pending distribution amounts

Functions

AccumulateDistributedInfo

func AccumulateDistributedInfo() (toStaker, toDevOps, toCommunityPool, toGovStaker int64)

AccumulateDistributedInfo returns the current pending allocation for every distribution target.

Returns:

  • toStaker: pending GNS allocation for liquidity stakers, in token base units.
  • toDevOps: accumulated GNS allocation for DevOps, in token base units.
  • toCommunityPool: accumulated GNS allocation for the community pool, in token base units.
  • toGovStaker: pending GNS allocation for governance stakers, in token base units.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.AccumulateDistributedInfo()"

Result

ChangeDistributionPct

func ChangeDistributionPct( cur realm, liquidityStakerPct int64, devOpsPct int64, communityPoolPct int64, govStakerPct int64, )

ChangeDistributionPct changes distribution percentages for emission targets.

This function redistributes how newly minted GNS tokens are allocated across protocol components. Before applying new ratios, it distributes any accumulated emissions using the current ratios, ensuring emissions are distributed according to the ratios in effect when they were generated. This prevents retroactive application of new ratios to past emissions.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • liquidityStakerPct: percentage for liquidity stakers in basis points (100 = 1%, 10000 = 100%).
  • devOpsPct: percentage for DevOps in basis points (100 = 1%, 10000 = 100%).
  • communityPoolPct: percentage for the community pool in basis points (100 = 1%, 10000 = 100%).
  • govStakerPct: percentage for governance stakers in basis points (100 = 1%, 10000 = 100%).

Requirements:

  • Percentages must sum to exactly 10000 (100%).
  • Each percentage must be between 0 and 10000 inclusive.

Example:

Example
1ChangeDistributionPct(
2  7000,  // 70% to liquidity stakers
3  2000,  // 20% to devops
4  1000,  // 10% to community pool
5  0,     // 0% to governance stakers
6)

Only callable by admin or governance.

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/emission" -func "ChangeDistributionPct" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/emission" -func "ChangeDistributionPct" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

ClearDistributedToGovStaker

func ClearDistributedToGovStaker(cur realm)

ClearDistributedToGovStaker resets the pending distribution amount for governance stakers.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.

Only callable by governance staker contract.

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/emission" -func "ClearDistributedToGovStaker" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/emission" -func "ClearDistributedToGovStaker" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

ClearDistributedToStaker

func ClearDistributedToStaker(cur realm)

ClearDistributedToStaker resets the pending distribution amount for liquidity stakers.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.

Only callable by staker contract.

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/emission" -func "ClearDistributedToStaker" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/emission" -func "ClearDistributedToStaker" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

GetAccuDistributedToCommunityPool

func GetAccuDistributedToCommunityPool() int64

GetAccuDistributedToCommunityPool returns the total historical GNS amount allocated to the community pool.

Returns:

  • amount: cumulative community-pool allocation in GNS base units; this value is not cleared.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetAccuDistributedToCommunityPool()"

Result

GetAccuDistributedToDevOps

func GetAccuDistributedToDevOps() int64

GetAccuDistributedToDevOps returns the total historical GNS amount allocated to DevOps.

Returns:

  • amount: cumulative DevOps allocation in GNS base units; this value is not cleared.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetAccuDistributedToDevOps()"

Result

GetAccuDistributedToGovStaker

func GetAccuDistributedToGovStaker() int64

GetAccuDistributedToGovStaker returns the total historical GNS amount allocated to governance stakers.

Returns:

  • amount: cumulative governance-staker allocation in GNS base units; this value is not cleared.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetAccuDistributedToGovStaker()"

Result

GetAccuDistributedToStaker

func GetAccuDistributedToStaker() int64

GetAccuDistributedToStaker returns the total historical GNS amount allocated to liquidity stakers.

Returns:

  • amount: cumulative liquidity-staker allocation in GNS base units; this value is not cleared.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetAccuDistributedToStaker()"

Result

GetAllDistributionBpsPct

func GetAllDistributionBpsPct() map[int]int64

GetAllDistributionBpsPct returns all distribution percentages in basis points.

Returns:

  • percentages: map of target to percentage in basis points

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetAllDistributionBpsPct()"

Result

GetDistributableAmount

func GetDistributableAmount(amount, timestamp int64) (map[int]int64, int64)

GetDistributableAmount returns distribution amounts by target and the remainder. If timestamp is outside the distribution window, it returns an empty map and the full amount as left.

Parameters:

  • amount: total amount to distribute
  • timestamp: timestamp to check distribution window

Returns:

  • distributions: map of target to distribution amount
  • remainder: undistributed amount

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetDistributableAmount(,)"

Result

GetDistributedToCommunityPool

func GetDistributedToCommunityPool() int64

GetDistributedToCommunityPool returns the GNS amount currently accumulated for the community pool.

Returns:

  • amount: accumulated community-pool allocation in GNS base units.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetDistributedToCommunityPool()"

Result

GetDistributedToDevOps

func GetDistributedToDevOps() int64

GetDistributedToDevOps returns the GNS amount currently accumulated for DevOps.

Returns:

  • amount: accumulated DevOps allocation in GNS base units.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetDistributedToDevOps()"

Result

GetDistributedToGovStaker

func GetDistributedToGovStaker() int64

GetDistributedToGovStaker returns the pending GNS amount allocated to governance stakers.

Returns:

  • amount: pending governance-staker allocation in GNS base units since the last clear.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetDistributedToGovStaker()"

Result

GetDistributedToStaker

func GetDistributedToStaker() int64

GetDistributedToStaker returns the pending GNS amount allocated to liquidity stakers.

Returns:

  • amount: pending liquidity-staker allocation in GNS base units since the last clear.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetDistributedToStaker()"

Result

GetDistributionBpsPct

func GetDistributionBpsPct(target int) (int64, error)

GetDistributionBpsPct returns the configured distribution percentage in basis points for a target.

Parameters:

  • target: distribution target constant whose configured share is queried.

Returns:

  • pct: configured target share in basis points (100 = 1%, 10000 = 100%).
  • error: nil when the target exists in the initialized map; otherwise an invalid-target error.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetDistributionBpsPct()"

Result

GetDistributionEndTimestamp

func GetDistributionEndTimestamp() int64

GetDistributionEndTimestamp returns the timestamp when emission distribution ends.

Returns:

  • timestamp: distribution end timestamp, or 0 if not started

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetDistributionEndTimestamp()"

Result

GetDistributionStartTimestamp

func GetDistributionStartTimestamp() int64

GetDistributionStartTimestamp returns the configured emission start timestamp. The value may be in the future; it is 0 when no start timestamp is configured.

Returns:

  • timestamp: configured distribution start timestamp, or 0 if unconfigured

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetDistributionStartTimestamp()"

Result

GetEmissionAmountPerSecondBy

func GetEmissionAmountPerSecondBy(timestamp, distributionPct int64) int64

GetEmissionAmountPerSecondBy returns the GNS emission rate per second for a timestamp and target share.

Parameters:

  • timestamp: Unix timestamp at which the base emission rate is queried.
  • distributionPct: target share in basis points, from 0 through 10000 inclusive.

Returns:

  • amountPerSecond: target's GNS emission rate in token base units per second, or zero outside the schedule.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetEmissionAmountPerSecondBy(,)"

Result

GetLastExecutedTimestamp

func GetLastExecutedTimestamp() int64

GetLastExecutedTimestamp returns the timestamp of the last emission distribution execution.

Returns:

  • timestamp: last execution timestamp

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetLastExecutedTimestamp()"

Result

GetLeftGNSAmount

func GetLeftGNSAmount() int64

GetLeftGNSAmount returns the amount of undistributed GNS tokens from previous distributions.

Returns:

  • amount: undistributed GNS amount

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetLeftGNSAmount()"

Result

GetStakerEmissionAmountPerSecond

func GetStakerEmissionAmountPerSecond() (int64, error)

GetStakerEmissionAmountPerSecond returns the current GNS emission rate allocated to liquidity stakers.

Returns:

  • amountPerSecond: current liquidity-staker emission rate in GNS base units per second.
  • error: nil when the liquidity-staker distribution share is available; otherwise the target lookup error.

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetStakerEmissionAmountPerSecond()"

Result

GetStakerEmissionAmountPerSecondInRange

func GetStakerEmissionAmountPerSecondInRange(start, end int64) ([]int64, []int64, error)

GetStakerEmissionAmountPerSecondInRange returns liquidity-staker emission-rate change points in a time range.

Parameters:

  • start: inclusive start Unix timestamp for the range.
  • end: inclusive end Unix timestamp for the range.

Returns:

  • timestamps: ordered timestamps in the range where the base emission rate changes.
  • amountsPerSecond: liquidity-staker GNS rates corresponding to timestamps, in token base units per second.
  • error: nil when the liquidity-staker distribution share is available; otherwise the target lookup error.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetStakerEmissionAmountPerSecondInRange(,)"

Result

GetTotalAccuDistributed

func GetTotalAccuDistributed() int64

GetTotalAccuDistributed returns the total accumulated distributed GNS amount.

Returns:

  • amount: total accumulated distributed GNS

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetTotalAccuDistributed()"

Result

GetTotalDistributed

func GetTotalDistributed() int64

GetTotalDistributed returns the total pending distributed GNS amount.

Returns:

  • amount: total pending distributed GNS

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.GetTotalDistributed()"

Result

MintAndDistributeGns

func MintAndDistributeGns(cur realm) (int64, bool)

MintAndDistributeGns mints and distributes GNS tokens according to the emission schedule.

This function is called automatically by protocol contracts during user interactions to trigger periodic GNS emission. It mints new tokens based on elapsed time since last distribution and distributes them to predefined targets (staker, devops, etc.).

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.

Returns:

  • distributedAmount: total amount of GNS distributed in this call
  • success: false only when emission is halted; true when processing completes, even if no tokens are distributed

Note: Distribution only occurs if start timestamp is set and reached. Any undistributed tokens from previous calls are carried forward.

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/emission" -func "MintAndDistributeGns" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/emission" -func "MintAndDistributeGns" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Render

func Render(path string) string

Render returns the current GNS emission and distribution state.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/emission.Render()"

Result

SetDefaultInitialPoolChecker

func SetDefaultInitialPoolChecker(cur realm, checker func(poolPath string) bool)

SetDefaultInitialPoolChecker registers the callback that verifies the canonical default initial pool exists before emission starts.

The checker receives the pool path as a parameter so emission owns the canonical path policy (DefaultInitialPoolTierPath) while pool supplies only the generic "does this pool exist" capability.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • checker: nonnil function returning true when the supplied pool path exists; it is called with DefaultInitialPoolTierPath and nil causes a panic.

Only callable by the pool contract.

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/emission" -func "SetDefaultInitialPoolChecker" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/emission" -func "SetDefaultInitialPoolChecker" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

SetDistributionStartTime

func SetDistributionStartTime(cur realm, startTimestamp int64)

SetDistributionStartTime sets the timestamp when emission distribution starts.

This function controls when GNS emission begins. Before the configured timestamp is reached, an admin or governance caller may reschedule it. Once the timestamp is reached, the start time is immutable.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • startTimestamp: positive future Unix timestamp when emission should begin.

Requirements:

  • Must be called before distribution starts.
  • Timestamp must be in the future and leave room for the 12-year schedule.

Effects:

  • Sets global distribution start time.
  • Initializes GNS emission state if not already started.
  • Emission begins automatically when timestamp is reached.

Only callable by admin or governance.

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/emission" -func "SetDistributionStartTime" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/emission" -func "SetDistributionStartTime" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

SetOnDistributionPctChangeCallback

func SetOnDistributionPctChangeCallback(cur realm, callback func(cur realm, emissionAmountPerSecond int64))

SetOnDistributionPctChangeCallback registers the optional callback invoked when distribution percentages change. A nil callback clears the registration. This allows external contracts (like staker) to update their internal caches when governance or admin changes emission rates.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • callback: nil to clear the callback, or a function receiving its callback realm context and the current staker GNS emission rate per second; a nonnil callback is invoked immediately after registration.

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/emission" -func "SetOnDistributionPctChangeCallback" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/emission" -func "SetOnDistributionPctChangeCallback" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx