Search Apps Documentation Source Content File Folder Download Copy Actions Download

emission.gno

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