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

0.89 Kb · 31 lines
 1package gns
 2
 3import (
 4	"chain"
 5	"time"
 6
 7	"gno.land/p/gnoswap/utils"
 8
 9	"gno.land/r/gnoswap/access"
10)
11
12// InitEmissionState initializes emission schedule with start timestamp.
13// Only callable by emission contract. Sets up 12-year emission schedule
14// with halving every 2 years. Panics if caller is not emission contract.
15func InitEmissionState(cur realm, createdHeight int64, startTimestamp int64) {
16	previousRealm := cur.Previous()
17	caller := previousRealm.Address()
18	access.AssertIsEmission(caller)
19
20	emissionState = NewEmissionState(createdHeight, startTimestamp)
21
22	chain.Emit(
23		"InitEmissionState",
24		"prevAddr", caller.String(),
25		"prevRealm", previousRealm.PkgPath(),
26		"height", utils.FormatInt(createdHeight),
27		"timestamp", utils.FormatInt(time.Now().Unix()),
28		"startTimestamp", utils.FormatInt(emissionState.getStartTimestamp()),
29		"endTimestamp", utils.FormatInt(emissionState.getEndTimestamp()),
30	)
31}