Search Apps Documentation Source Content File Folder Download Copy Actions Download

gns package

Overview

Package gns implements the GNS governance and utility token for GnoSwap. GNS is a GRC20-compliant token with a deflationary emission schedule. The emission follows a 12-year schedule with halving every 2 years: - Years 1-2: 225,000,000 GNS per year (100%) - Years 3-4: 112,500,000 GNS per year (50%) - Years 5-6: 56,250,000 GNS per year (25%) - Years 7-8: 28,125,000 GNS per year (12.5%) - Years 9-12: 14,062,500 GNS per year (6.25%) Token Economics: - Maximum Supply: 1,000,000,000 GNS - Initial Mint: 100,000,000 GNS - Total Emission: 900,000,000 GNS Key Functions: - InitEmissionState: Initializes emission schedule (emission contract only) - MintGns: Mints tokens per emission schedule (emission contract only) - Burn: Burns tokens from circulation (admin only) - Transfer/TransferFrom/Approve: Standard GRC20 operations The emission state tracks accumulated and remaining amounts per halving year, ensuring precise token distribution according to the schedule.

Functions

Allowance

func Allowance(owner, spender address) int64

Allowance returns the amount of GNS that a spender is allowed to transfer from an owner.

Params

Command

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

Result

Approve

func Approve(cur realm, spender address, amount int64)

Approve allows spender to transfer GNS tokens from caller's account. Parameters: - spender: address authorized to spend - amount: maximum amount spender can transfer

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/gns" -func "Approve" -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/gns" -func "Approve" -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
  

BalanceOf

func BalanceOf(owner address) int64

BalanceOf returns the GNS balance of a specific address.

Param

Command

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

Result

CalculateMintGnsAmount

func CalculateMintGnsAmount(fromTimestamp, toTimestamp int64) int64

CalculateMintGnsAmount returns the amount of GNS that would be minted for the given timestamp range.

Params

Command

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

Result

Decimals

func Decimals() int

Decimals returns the number of decimal places for GNS token.

Command

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

Result

GetAmountPerSecondPerHalvingYear

func GetAmountPerSecondPerHalvingYear(year int64) int64

GetAmountPerSecondPerHalvingYear returns the emission rate per second for the specified halving year.

Param

Command

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

Result

GetCurrentYear

func GetCurrentYear() int64

GetCurrentYear returns the current halving year (1-12) or 0 if emission is not active.

Command

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

Result

GetEmissionAccumulatedAmountByTimestamp

func GetEmissionAccumulatedAmountByTimestamp(timestamp int64) int64

GetEmissionAccumulatedAmountByTimestamp returns the accumulated emission amount for the halving year at given timestamp. Returns 0 if timestamp is outside emission period.

Param

Command

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

Result

GetEmissionAmountPerSecondByTimestamp

func GetEmissionAmountPerSecondByTimestamp(timestamp int64) int64

GetEmissionAmountPerSecondByTimestamp returns the emission rate per second for a given timestamp. Returns 0 if timestamp is outside emission period.

Param

Command

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

Result

GetEmissionAmountPerSecondInRange

func GetEmissionAmountPerSecondInRange(fromTime, toTime int64) ([]int64, []int64)

GetEmissionAmountPerSecondInRange returns halving timestamps and emission rates for the given time range. Returns two slices: timestamps when halving periods start and corresponding emission rates per second.

Params

Command

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

Result

GetEmissionCreatedHeight

func GetEmissionCreatedHeight() int64

GetEmissionCreatedHeight returns the block height when emission schedule was created.

Command

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

Result

GetEmissionEndTimestamp

func GetEmissionEndTimestamp() int64

GetEmissionEndTimestamp returns the timestamp when emission schedule ends.

Command

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

Result

GetEmissionLeftAmountByTimestamp

func GetEmissionLeftAmountByTimestamp(timestamp int64) int64

GetEmissionLeftAmountByTimestamp returns the remaining emission amount for the halving year at given timestamp. Returns 0 if timestamp is outside emission period.

Param

Command

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

Result

GetEmissionStartTimestamp

func GetEmissionStartTimestamp() int64

GetEmissionStartTimestamp returns the timestamp when emission schedule begins.

Command

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

Result

GetHalvingAmountsPerYear

func GetHalvingAmountsPerYear(year int64) int64

GetHalvingAmountsPerYear returns the total emission amount allocated for the specified year. Returns 0 if year is outside the valid range (1-12).

Param

Command

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

Result

GetHalvingYear

func GetHalvingYear(timestamp int64) int64

GetHalvingYear returns the halving year (1-12) for a given timestamp.

Param

Command

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

Result

GetHalvingYearAccuAmount

func GetHalvingYearAccuAmount(year int64) int64

GetHalvingYearAccuAmount returns the accumulated token issuance for the specified halving year.

Param

Command

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

Result

GetHalvingYearEndTimestamp

func GetHalvingYearEndTimestamp(year int64) int64

GetHalvingYearEndTimestamp returns the end timestamp for the specified halving year.

Param

Command

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

Result

GetHalvingYearInfo

func GetHalvingYearInfo(timestamp int64) (int64, int64, int64)

GetHalvingYearInfo returns the halving year, start timestamp, and end timestamp for a given timestamp. Returns (year, startTimestamp, endTimestamp). Year is 0 if outside emission period.

Param

Command

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

Result

GetHalvingYearLeftAmount

func GetHalvingYearLeftAmount(year int64) int64

GetHalvingYearLeftAmount returns the remaining token issuance for the specified halving year.

Param

Command

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

Result

GetHalvingYearMaxAmount

func GetHalvingYearMaxAmount(year int64) int64

GetHalvingYearMaxAmount returns the maximum token issuance for the specified halving year.

Param

Command

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

Result

GetHalvingYearMintAmount

func GetHalvingYearMintAmount(year int64) int64

GetHalvingYearMintAmount returns the amount of tokens minted for the specified halving year.

Param

Command

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

Result

GetHalvingYearStartTimestamp

func GetHalvingYearStartTimestamp(year int64) int64

GetHalvingYearStartTimestamp returns the start timestamp for the specified halving year.

Param

Command

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

Result

GetInitialMintAmount

func GetInitialMintAmount() int64

GetInitialMintAmount returns the initial amount of gns tokens to be minted.

Command

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

Result

GetMaxEmissionAmount

func GetMaxEmissionAmount() int64

GetMaxEmissionAmount returns the maximum amount of emission allowed.

Command

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

Result

GetMaximumSupply

func GetMaximumSupply() int64

GetMaximumSupply returns the maximum supply of gns tokens.

Command

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

Result

InitEmissionState

func InitEmissionState(cur realm, createdHeight int64, startTimestamp int64)

InitEmissionState initializes emission schedule with start timestamp. Only callable by emission contract. Sets up 12-year emission schedule with halving every 2 years. Panics if caller is not emission contract.

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/gns" -func "InitEmissionState" -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/gns" -func "InitEmissionState" -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
  

IsEmissionActive

func IsEmissionActive() bool

IsEmissionActive returns true if emission is currently active based on current time.

Command

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

Result

IsEmissionEnded

func IsEmissionEnded() bool

IsEmissionEnded returns true if emission schedule has completed.

Command

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

Result

IsEmissionInitialized

func IsEmissionInitialized() bool

IsEmissionInitialized returns true if emission schedule has been initialized.

Command

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

Result

KnownAccounts

func KnownAccounts() int

KnownAccounts returns the number of addresses that have held GNS.

Command

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

Result

LastMintedTimestamp

func LastMintedTimestamp() int64

LastMintedTimestamp returns the timestamp of the last GNS emission mint.

Command

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

Result

LeftEmissionAmount

func LeftEmissionAmount() int64

LeftEmissionAmount returns the remaining GNS tokens available for emission.

Command

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

Result

MintGns

func MintGns(cur realm, address address) int64

MintGns mints new GNS tokens according to the emission schedule. Parameters: - address: recipient address for minted tokens Returns amount minted. Only callable by emission contract. Note: Halt check is performed by the caller (emission.MintAndDistributeGns) to allow graceful handling. This function assumes caller has already verified halt status before invoking.

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/gns" -func "MintGns" -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/gns" -func "MintGns" -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
  

MintedEmissionAmount

func MintedEmissionAmount() int64

MintedEmissionAmount returns the total GNS tokens minted through emission, excluding the initial mint amount.

Command

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

Result

Name

func Name() string

Name returns the name of the GNS token.

Command

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

Result

Render

func Render(path string) string

Render returns token information for web interface.

Param

Command

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

Result

Symbol

func Symbol() string

Symbol returns the symbol of the GNS token.

Command

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

Result

TotalSupply

func TotalSupply() int64

TotalSupply returns the total supply of GNS tokens in circulation.

Command

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

Result

Transfer

func Transfer(cur realm, to address, amount int64)

Transfer transfers GNS tokens from caller to recipient. Parameters: - to: recipient address - amount: amount to transfer

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/gns" -func "Transfer" -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/gns" -func "Transfer" -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
  

TransferFrom

func TransferFrom(cur realm, from, to address, amount int64)

TransferFrom transfers GNS tokens on behalf of owner. Parameters: - from: token owner address - to: recipient address - amount: amount to transfer

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/gns" -func "TransferFrom" -args $'' -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/gns" -func "TransferFrom" -args $'' -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
  

NewEmissionState

func NewEmissionState(createdHeight int64, startTimestamp int64) *EmissionState

NewEmissionState creates a new EmissionState with specified start height and timestamp. Calculates emission end time based on 12-year schedule and initializes halving data.

Params

Command

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

Result

GetHalvingInfo

func GetHalvingInfo() *HalvingData

GetHalvingInfo returns a clone of the halving data.

Command

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

Result

NewHalvingData

func NewHalvingData(startTimestamp int64) *HalvingData

NewHalvingData creates a new HalvingData instance with emission schedule. Initializes 12 years of halving periods with timestamps, amounts, and rates based on startTimestamp.

Param

Command

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

Result