Search Apps Documentation Source Content File Folder Download Copy Actions Download

types.gno

5.52 Kb · 148 lines
  1package staker
  2
  3import (
  4	"gno.land/p/gnoswap/uint256"
  5	bptree "gno.land/p/nt/bptree/v0"
  6)
  7
  8// Main interface that combines all sub-interfaces
  9type IGovStaker interface {
 10	IGovStakerDelegation
 11	IGovStakerReward
 12	IGovStakerGetter
 13	IGovStakerAdmin
 14}
 15
 16// Delegation operations interface
 17//
 18// Mutating methods take `_ int, rlm realm` so the realm token is threaded
 19// from the proxy entry points down to the cross-realm token transfers and
 20// store writes performed inside each implementation. The `_ int` sentinel
 21// surfaces at every call site as a literal `0`, making the realm threading
 22// visible to readers.
 23type IGovStakerDelegation interface {
 24	// Main delegation operations
 25	Delegate(_ int, rlm realm, to address, amount int64, referrer string) int64
 26	Undelegate(_ int, rlm realm, from address, amount int64) int64
 27	Redelegate(_ int, rlm realm, delegatee, newDelegatee address, amount int64) int64
 28	CollectUndelegatedGns(_ int, rlm realm) int64
 29}
 30
 31// Reward management interface
 32type IGovStakerReward interface {
 33	// Reward collection
 34	CollectReward(_ int, rlm realm)
 35	CollectRewardFromLaunchPad(_ int, rlm realm, to address)
 36	SetAmountByProjectWallet(_ int, rlm realm, addr address, amount int64, add bool)
 37}
 38
 39// Getter interface for read operations
 40type IGovStakerGetter interface {
 41	// Store data getters
 42	GetUnDelegationLockupPeriod() int64
 43
 44	// Delegation getters
 45	GetTotalxGnsSupply() int64
 46	GetTotalDelegated() int64
 47	GetTotalLockedAmount() int64
 48	GetDelegationCount() int
 49	GetDelegationIDs(offset, count int) []int64
 50	ExistsDelegation(delegationID int64) bool
 51	GetDelegation(delegationID int64) (*Delegation, error)
 52	GetDelegatorDelegateeCount(delegator address) int
 53	GetDelegatorDelegateeAddresses(delegator address, offset, count int) []address
 54	GetUserDelegationCount(delegator address, delegatee address) int
 55	GetUserDelegationIDs(delegator address, delegatee address) []int64
 56	HasDelegationSnapshotsKey() bool
 57	GetTotalDelegationAmountAtSnapshot(snapshotTime int64) (int64, bool)
 58	GetUserDelegationAmountAtSnapshot(userAddr address, snapshotTime int64) (int64, bool)
 59
 60	// Reward getters
 61	GetClaimableRewardByAddress(addr address) (int64, map[string]int64, error)
 62	GetClaimableRewardByLaunchpad(addr address) (int64, map[string]int64, error)
 63	GetClaimableRewardByRewardID(rewardID string) (int64, map[string]int64, error)
 64
 65	// Launchpad getters
 66	GetLaunchpadProjectDeposit(projectAddr string) (int64, bool)
 67
 68	// Withdraw getters
 69	GetDelegationWithdrawCount(delegationID int64) int
 70	GetDelegationWithdraws(delegationID int64, offset, count int) ([]DelegationWithdraw, error)
 71	GetCollectableWithdrawAmount(delegationID int64) int64
 72
 73	// Protocol fee reward getters
 74	GetProtocolFeeAccumulatedX128PerStake(tokenPath string) *uint256.Uint
 75	GetProtocolFeeAmount(tokenPath string) int64
 76	GetProtocolFeeAccumulatedTimestamp() int64
 77
 78	// Emission reward getters
 79	GetEmissionAccumulatedX128PerStake() *uint256.Uint
 80	GetEmissionDistributedAmount() int64
 81	GetEmissionAccumulatedTimestamp() int64
 82}
 83
 84// Admin interface for administrative functions
 85type IGovStakerAdmin interface {
 86	CleanStakerDelegationSnapshotByAdmin(_ int, rlm realm, snapshotTime int64, target address)
 87	SetUnDelegationLockupPeriodByAdmin(_ int, rlm realm, period int64)
 88}
 89
 90// IGovStakerStore mirrors the mutating-method realm-threading convention used
 91// by the public IGovStaker* interfaces above. Setters take `_ int, rlm realm`
 92// so KV-store writes execute under the proxy realm — the only address with
 93// write access to the shared store.
 94type IGovStakerStore interface {
 95	// Basic configuration
 96	HasUnDelegationLockupPeriodStoreKey() bool
 97	GetUnDelegationLockupPeriod() int64
 98	SetUnDelegationLockupPeriod(_ int, rlm realm, period int64) error
 99
100	HasTotalDelegatedAmountStoreKey() bool
101	GetTotalDelegatedAmount() int64
102	SetTotalDelegatedAmount(_ int, rlm realm, amount int64) error
103
104	HasTotalLockedAmountStoreKey() bool
105	GetTotalLockedAmount() int64
106	SetTotalLockedAmount(_ int, rlm realm, amount int64) error
107
108	// Delegation management
109	HasDelegation(id int64) bool
110	GetDelegation(id int64) (*Delegation, bool)
111	SetDelegation(_ int, rlm realm, id int64, delegation *Delegation) error
112	RemoveDelegation(_ int, rlm realm, id int64) error
113
114	HasDelegationsStoreKey() bool
115	SetDelegations(_ int, rlm realm, delegations *bptree.BPTree) error
116	GetAllDelegations() *bptree.BPTree
117
118	HasDelegationCounterStoreKey() bool
119	GetDelegationCounter() *Counter
120	SetDelegationCounter(_ int, rlm realm, counter *Counter) error
121
122	// Total delegation history (timestamp -> int64)
123	HasTotalDelegationHistoryStoreKey() bool
124	GetTotalDelegationHistory() *UintTree
125	SetTotalDelegationHistory(_ int, rlm realm, history *UintTree) error
126
127	// User delegation history (address -> *UintTree[timestamp -> int64])
128	HasUserDelegationHistoryStoreKey() bool
129	GetUserDelegationHistory() *bptree.BPTree
130	SetUserDelegationHistory(_ int, rlm realm, history *bptree.BPTree) error
131
132	// Manager states
133	HasEmissionRewardManagerStoreKey() bool
134	GetEmissionRewardManager() *EmissionRewardManager
135	SetEmissionRewardManager(_ int, rlm realm, manager *EmissionRewardManager) error
136
137	HasProtocolFeeRewardManagerStoreKey() bool
138	GetProtocolFeeRewardManager() *ProtocolFeeRewardManager
139	SetProtocolFeeRewardManager(_ int, rlm realm, manager *ProtocolFeeRewardManager) error
140
141	HasDelegationManagerStoreKey() bool
142	GetDelegationManager() *DelegationManager
143	SetDelegationManager(_ int, rlm realm, manager *DelegationManager) error
144
145	HasLaunchpadProjectDepositsStoreKey() bool
146	GetLaunchpadProjectDeposits() *LaunchpadProjectDeposits
147	SetLaunchpadProjectDeposits(_ int, rlm realm, deposits *LaunchpadProjectDeposits) error
148}