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

types.gno

5.77 Kb · 152 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	CollectEmissionReward(_ int, rlm realm)
 36	CollectProtocolFeeReward(_ int, rlm realm, tokenPath string)
 37	CollectRewardFromLaunchPad(_ int, rlm realm, to address)
 38	CollectEmissionRewardFromLaunchPad(_ int, rlm realm, to address)
 39	CollectProtocolFeeRewardFromLaunchPad(_ int, rlm realm, to address, tokenPath string)
 40	SetAmountByProjectWallet(_ int, rlm realm, addr address, amount int64, add bool)
 41}
 42
 43// Getter interface for read operations
 44type IGovStakerGetter interface {
 45	// Store data getters
 46	GetUnDelegationLockupPeriod() int64
 47
 48	// Delegation getters
 49	GetTotalxGnsSupply() int64
 50	GetTotalDelegated() int64
 51	GetTotalLockedAmount() int64
 52	GetDelegationCount() int
 53	GetDelegationIDs(offset, count int) []int64
 54	ExistsDelegation(delegationID int64) bool
 55	GetDelegation(delegationID int64) (*Delegation, error)
 56	GetDelegatorDelegateeCount(delegator address) int
 57	GetDelegatorDelegateeAddresses(delegator address, offset, count int) []address
 58	GetUserDelegationCount(delegator address, delegatee address) int
 59	GetUserDelegationIDs(delegator address, delegatee address) []int64
 60	HasDelegationSnapshotsKey() bool
 61	GetTotalDelegationAmountAtSnapshot(snapshotTime int64) (int64, bool)
 62	GetUserDelegationAmountAtSnapshot(userAddr address, snapshotTime int64) (int64, bool)
 63
 64	// Reward getters
 65	GetClaimableRewardByAddress(addr address) (int64, map[string]int64, error)
 66	GetClaimableRewardByLaunchpad(addr address) (int64, map[string]int64, error)
 67	GetClaimableRewardByRewardID(rewardID string) (int64, map[string]int64, error)
 68
 69	// Launchpad getters
 70	GetLaunchpadProjectDeposit(projectAddr string) (int64, bool)
 71
 72	// Withdraw getters
 73	GetDelegationWithdrawCount(delegationID int64) int
 74	GetDelegationWithdraws(delegationID int64, offset, count int) ([]DelegationWithdraw, error)
 75	GetCollectableWithdrawAmount(delegationID int64) int64
 76
 77	// Protocol fee reward getters
 78	GetProtocolFeeAccumulatedX128PerStake(tokenPath string) *uint256.Uint
 79	GetProtocolFeeAmount(tokenPath string) int64
 80	GetProtocolFeeAccumulatedTimestamp() int64
 81
 82	// Emission reward getters
 83	GetEmissionAccumulatedX128PerStake() *uint256.Uint
 84	GetEmissionDistributedAmount() int64
 85	GetEmissionAccumulatedTimestamp() int64
 86}
 87
 88// Admin interface for administrative functions
 89type IGovStakerAdmin interface {
 90	CleanStakerDelegationSnapshotByAdmin(_ int, rlm realm, snapshotTime int64, target address)
 91	SetUnDelegationLockupPeriodByAdmin(_ int, rlm realm, period int64)
 92}
 93
 94// IGovStakerStore mirrors the mutating-method realm-threading convention used
 95// by the public IGovStaker* interfaces above. Setters take `_ int, rlm realm`
 96// so KV-store writes execute under the proxy realm — the only address with
 97// write access to the shared store.
 98type IGovStakerStore interface {
 99	// Basic configuration
100	HasUnDelegationLockupPeriodStoreKey() bool
101	GetUnDelegationLockupPeriod() int64
102	SetUnDelegationLockupPeriod(_ int, rlm realm, period int64) error
103
104	HasTotalDelegatedAmountStoreKey() bool
105	GetTotalDelegatedAmount() int64
106	SetTotalDelegatedAmount(_ int, rlm realm, amount int64) error
107
108	HasTotalLockedAmountStoreKey() bool
109	GetTotalLockedAmount() int64
110	SetTotalLockedAmount(_ int, rlm realm, amount int64) error
111
112	// Delegation management
113	HasDelegation(id int64) bool
114	GetDelegation(id int64) (*Delegation, bool)
115	SetDelegation(_ int, rlm realm, id int64, delegation *Delegation) error
116	RemoveDelegation(_ int, rlm realm, id int64) error
117
118	HasDelegationsStoreKey() bool
119	SetDelegations(_ int, rlm realm, delegations *bptree.BPTree) error
120	GetAllDelegations() *bptree.BPTree
121
122	HasDelegationCounterStoreKey() bool
123	GetDelegationCounter() *Counter
124	SetDelegationCounter(_ int, rlm realm, counter *Counter) error
125
126	// Total delegation history (timestamp -> int64)
127	HasTotalDelegationHistoryStoreKey() bool
128	GetTotalDelegationHistory() *UintTree
129	SetTotalDelegationHistory(_ int, rlm realm, history *UintTree) error
130
131	// User delegation history (address -> *UintTree[timestamp -> int64])
132	HasUserDelegationHistoryStoreKey() bool
133	GetUserDelegationHistory() *bptree.BPTree
134	SetUserDelegationHistory(_ int, rlm realm, history *bptree.BPTree) error
135
136	// Manager states
137	HasEmissionRewardManagerStoreKey() bool
138	GetEmissionRewardManager() *EmissionRewardManager
139	SetEmissionRewardManager(_ int, rlm realm, manager *EmissionRewardManager) error
140
141	HasProtocolFeeRewardManagerStoreKey() bool
142	GetProtocolFeeRewardManager() *ProtocolFeeRewardManager
143	SetProtocolFeeRewardManager(_ int, rlm realm, manager *ProtocolFeeRewardManager) error
144
145	HasDelegationManagerStoreKey() bool
146	GetDelegationManager() *DelegationManager
147	SetDelegationManager(_ int, rlm realm, manager *DelegationManager) error
148
149	HasLaunchpadProjectDepositsStoreKey() bool
150	GetLaunchpadProjectDeposits() *LaunchpadProjectDeposits
151	SetLaunchpadProjectDeposits(_ int, rlm realm, deposits *LaunchpadProjectDeposits) error
152}