Search Apps Documentation Source Content File Folder Download Copy Actions Download

emission.gno

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