Search Apps Documentation Source Content File Folder Download Copy Actions Download

types.gno

4.68 Kb ยท 144 lines
  1package staker
  2
  3import (
  4	"gno.land/p/gnoswap/uint256"
  5	"gno.land/p/nt/avl"
  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
 17type IGovStakerDelegation interface {
 18	// Main delegation operations
 19	Delegate(to address, amount int64, referrer string) int64
 20	Undelegate(from address, amount int64) int64
 21	Redelegate(delegatee, newDelegatee address, amount int64) int64
 22	CollectUndelegatedGns() int64
 23}
 24
 25// Reward management interface
 26type IGovStakerReward interface {
 27	// Reward collection
 28	CollectReward()
 29	CollectRewardFromLaunchPad(to address)
 30	SetAmountByProjectWallet(addr address, amount int64, add bool)
 31}
 32
 33// Getter interface for read operations
 34type IGovStakerGetter interface {
 35	// Store data getters
 36	GetUnDelegationLockupPeriod() int64
 37	GetEmissionRewardBalance() int64
 38
 39	// Delegation getters
 40	GetTotalxGnsSupply() int64
 41	GetTotalDelegated() int64
 42	GetTotalLockedAmount() int64
 43	GetLockedAmount() int64
 44	GetDelegationCount() int
 45	GetDelegationIDs(offset, count int) []int64
 46	ExistsDelegation(delegationID int64) bool
 47	GetDelegation(delegationID int64) (*Delegation, error)
 48	GetDelegatorDelegateeCount(delegator address) int
 49	GetDelegatorDelegateeAddresses(delegator address, offset, count int) []address
 50	GetUserDelegationCount(delegator address, delegatee address) int
 51	GetUserDelegationIDs(delegator address, delegatee address) []int64
 52	HasDelegationSnapshotsKey() bool
 53	GetTotalDelegationAmountAtSnapshot(snapshotTime int64) (int64, bool)
 54	GetUserDelegationAmountAtSnapshot(userAddr address, snapshotTime int64) (int64, bool)
 55
 56	// Reward getters
 57	GetClaimableRewardByAddress(addr address) (int64, map[string]int64, error)
 58	GetClaimableRewardByLaunchpad(addr address) (int64, map[string]int64, error)
 59	GetClaimableRewardByRewardID(rewardID string) (int64, map[string]int64, error)
 60
 61	// Launchpad getters
 62	GetLaunchpadProjectDeposit(projectAddr string) (int64, bool)
 63
 64	// Withdraw getters
 65	GetDelegationWithdrawCount(delegationID int64) int
 66	GetDelegationWithdraws(delegationID int64, offset, count int) ([]*DelegationWithdraw, error)
 67	GetCollectableWithdrawAmount(delegationID int64) int64
 68
 69	// Protocol fee reward getters
 70	GetProtocolFeeAccumulatedX128PerStake(tokenPath string) *uint256.Uint
 71	GetProtocolFeeAmount(tokenPath string) int64
 72	GetProtocolFeeAccumulatedTimestamp() int64
 73
 74	// Emission reward getters
 75	GetEmissionAccumulatedX128PerStake() *uint256.Uint
 76	GetEmissionDistributedAmount() int64
 77	GetEmissionAccumulatedTimestamp() int64
 78}
 79
 80// Admin interface for administrative functions
 81type IGovStakerAdmin interface {
 82	CleanStakerDelegationSnapshotByAdmin(snapshotTime int64)
 83	SetUnDelegationLockupPeriodByAdmin(period int64)
 84}
 85
 86type IGovStakerStore interface {
 87	// Basic configuration
 88	HasUnDelegationLockupPeriodStoreKey() bool
 89	GetUnDelegationLockupPeriod() int64
 90	SetUnDelegationLockupPeriod(period int64) error
 91
 92	HasEmissionRewardBalanceStoreKey() bool
 93	GetEmissionRewardBalance() int64
 94	SetEmissionRewardBalance(balance int64) error
 95
 96	HasTotalDelegatedAmountStoreKey() bool
 97	GetTotalDelegatedAmount() int64
 98	SetTotalDelegatedAmount(amount int64) error
 99
100	HasTotalLockedAmountStoreKey() bool
101	GetTotalLockedAmount() int64
102	SetTotalLockedAmount(amount int64) error
103
104	// Delegation management
105	HasDelegation(id int64) bool
106	GetDelegation(id int64) (*Delegation, bool)
107	SetDelegation(id int64, delegation *Delegation) error
108	RemoveDelegation(id int64) error
109
110	HasDelegationsStoreKey() bool
111	SetDelegations(delegations *avl.Tree) error
112	GetAllDelegations() *avl.Tree
113
114	HasDelegationCounterStoreKey() bool
115	GetDelegationCounter() *Counter
116	SetDelegationCounter(counter *Counter) error
117
118	// Total delegation history (timestamp -> int64)
119	HasTotalDelegationHistoryStoreKey() bool
120	GetTotalDelegationHistory() *UintTree
121	SetTotalDelegationHistory(history *UintTree) error
122
123	// User delegation history (address -> *UintTree[timestamp -> int64])
124	HasUserDelegationHistoryStoreKey() bool
125	GetUserDelegationHistory() *avl.Tree
126	SetUserDelegationHistory(history *avl.Tree) error
127
128	// Manager states
129	HasEmissionRewardManagerStoreKey() bool
130	GetEmissionRewardManager() *EmissionRewardManager
131	SetEmissionRewardManager(manager *EmissionRewardManager) error
132
133	HasProtocolFeeRewardManagerStoreKey() bool
134	GetProtocolFeeRewardManager() *ProtocolFeeRewardManager
135	SetProtocolFeeRewardManager(manager *ProtocolFeeRewardManager) error
136
137	HasDelegationManagerStoreKey() bool
138	GetDelegationManager() *DelegationManager
139	SetDelegationManager(manager *DelegationManager) error
140
141	HasLaunchpadProjectDepositsStoreKey() bool
142	GetLaunchpadProjectDeposits() *LaunchpadProjectDeposits
143	SetLaunchpadProjectDeposits(deposits *LaunchpadProjectDeposits) error
144}