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

accessor.gno

1.53 Kb · 44 lines
 1package governance
 2
 3import (
 4	"gno.land/r/gnoswap/gov/staker"
 5)
 6
 7type govStakerAccessor struct{}
 8
 9// GetTotalDelegationAmountAtSnapshot forwards an aggregate delegation-history lookup.
10//
11// Parameters:
12//   - snapshotTime: Unix timestamp at or before which to select the latest total-delegation entry.
13//
14// Returns:
15//   - int64: aggregate delegated amount at or before snapshotTime.
16//   - bool: true when a qualifying history entry exists; false otherwise.
17func (g *govStakerAccessor) GetTotalDelegationAmountAtSnapshot(snapshotTime int64) (int64, bool) {
18	return staker.GetTotalDelegationAmountAtSnapshot(snapshotTime)
19}
20
21// GetUserDelegationAmountAtSnapshot forwards a user's delegation-history lookup.
22//
23// Parameters:
24//   - userAddr: Delegator address whose historical amount is queried.
25//   - snapshotTime: Unix timestamp at or before which to select the latest user entry.
26//
27// Returns:
28//   - int64: user's delegated amount at or before snapshotTime.
29//   - bool: true when a qualifying history entry exists; false otherwise.
30func (g *govStakerAccessor) GetUserDelegationAmountAtSnapshot(userAddr address, snapshotTime int64) (int64, bool) {
31	return staker.GetUserDelegationAmountAtSnapshot(userAddr, snapshotTime)
32}
33
34// GetTotalxGnsSupply returns the total xGNS supply reported by the staker realm.
35//
36// Returns:
37//   - int64: total xGNS supply, including launchpad-held xGNS.
38func (g *govStakerAccessor) GetTotalxGnsSupply() int64 {
39	return staker.GetTotalxGnsSupply()
40}
41
42func newGovStakerAccessor() GovStakerAccessor {
43	return &govStakerAccessor{}
44}