emission.gno
1.08 Kb · 37 lines
1package gns
2
3import (
4 "chain"
5 "time"
6
7 "gno.land/p/gnoswap/utils/v1"
8
9 "gno.land/r/gnoswap/access/v1"
10)
11
12// InitEmissionState initializes the emission schedule.
13// It creates the 12-year schedule with two-year halving periods.
14//
15// Parameters:
16// - cur: Current realm context; callers use cross(cur) when crossing into this realm.
17// - createdHeight: block height when the schedule is initialized
18// - startTimestamp: Unix timestamp when emission begins
19//
20// Only callable by the emission contract.
21func InitEmissionState(cur realm, createdHeight int64, startTimestamp int64) {
22 previousRealm := cur.Previous()
23 caller := previousRealm.Address()
24 access.AssertIsEmission(caller)
25
26 emissionState = NewEmissionState(createdHeight, startTimestamp)
27
28 chain.Emit(
29 "InitEmissionState",
30 "prevAddr", caller.String(),
31 "prevRealm", previousRealm.PkgPath(),
32 "height", utils.FormatInt(createdHeight),
33 "timestamp", utils.FormatInt(time.Now().Unix()),
34 "startTimestamp", utils.FormatInt(emissionState.getStartTimestamp()),
35 "endTimestamp", utils.FormatInt(emissionState.getEndTimestamp()),
36 )
37}