Search Apps Documentation Source Content File Folder Download Copy Actions Download

getters.gno

6.85 Kb · 177 lines
  1package staker
  2
  3import (
  4	u256 "gno.land/p/gnoswap/uint256"
  5)
  6
  7// GetTotalxGnsSupply returns the total supply of xGNS tokens.
  8func GetTotalxGnsSupply() int64 {
  9	return getImplementation().GetTotalxGnsSupply()
 10}
 11
 12// GetTotalDelegated returns the total amount of GNS delegated.
 13func GetTotalDelegated() int64 {
 14	return getImplementation().GetTotalDelegated()
 15}
 16
 17// GetTotalLockedAmount returns the total amount of GNS locked in undelegation.
 18func GetTotalLockedAmount() int64 {
 19	return getImplementation().GetTotalLockedAmount()
 20}
 21
 22// GetUnDelegationLockupPeriod returns the undelegation lockup period in seconds.
 23func GetUnDelegationLockupPeriod() int64 {
 24	return getImplementation().GetUnDelegationLockupPeriod()
 25}
 26
 27// GetDelegationCount returns the total number of delegations.
 28func GetDelegationCount() int {
 29	return getImplementation().GetDelegationCount()
 30}
 31
 32// GetDelegationIDs returns a paginated list of delegation IDs.
 33func GetDelegationIDs(offset, count int) []int64 {
 34	return cloneInt64Slice(getImplementation().GetDelegationIDs(offset, count))
 35}
 36
 37// ExistsDelegation checks if a delegation exists.
 38func ExistsDelegation(delegationID int64) bool {
 39	return getImplementation().ExistsDelegation(delegationID)
 40}
 41
 42// GetDelegation returns the delegation for the given ID.
 43func GetDelegation(delegationID int64) (*Delegation, error) {
 44	delegation, err := getImplementation().GetDelegation(delegationID)
 45	if err != nil {
 46		return nil, err
 47	}
 48	return delegation.Clone(), nil
 49}
 50
 51// GetDelegatorDelegateeCount returns the number of delegatees for a specific delegator.
 52func GetDelegatorDelegateeCount(delegator address) int {
 53	return getImplementation().GetDelegatorDelegateeCount(delegator)
 54}
 55
 56// GetDelegatorDelegateeAddresses returns a paginated list of delegatee addresses for a specific delegator.
 57func GetDelegatorDelegateeAddresses(delegator address, offset, count int) []address {
 58	return cloneAddressSlice(getImplementation().GetDelegatorDelegateeAddresses(delegator, offset, count))
 59}
 60
 61// GetUserDelegationCount returns the number of delegations for a specific delegator-delegatee pair.
 62func GetUserDelegationCount(delegator address, delegatee address) int {
 63	return getImplementation().GetUserDelegationCount(delegator, delegatee)
 64}
 65
 66// GetUserDelegationIDs returns a list of delegation IDs for a specific delegator-delegatee pair.
 67func GetUserDelegationIDs(delegator address, delegatee address) []int64 {
 68	return cloneInt64Slice(getImplementation().GetUserDelegationIDs(delegator, delegatee))
 69}
 70
 71// HasDelegationSnapshotsKey returns true if delegation history exists.
 72func HasDelegationSnapshotsKey() bool {
 73	return getImplementation().HasDelegationSnapshotsKey()
 74}
 75
 76// GetTotalDelegationAmountAtSnapshot returns the total delegation amount at a specific snapshot time.
 77func GetTotalDelegationAmountAtSnapshot(snapshotTime int64) (int64, bool) {
 78	return getImplementation().GetTotalDelegationAmountAtSnapshot(snapshotTime)
 79}
 80
 81// GetUserDelegationAmountAtSnapshot returns the user delegation amount at a specific snapshot time.
 82func GetUserDelegationAmountAtSnapshot(userAddr address, snapshotTime int64) (int64, bool) {
 83	return getImplementation().GetUserDelegationAmountAtSnapshot(userAddr, snapshotTime)
 84}
 85
 86// GetClaimableRewardByAddress returns claimable rewards for an address.
 87//
 88// Returns:
 89//   - int64: emission reward amount
 90//   - map[string]int64: protocol fee rewards by token path
 91func GetClaimableRewardByAddress(addr address) (int64, map[string]int64, error) {
 92	emissionReward, protocolFees, err := getImplementation().GetClaimableRewardByAddress(addr)
 93	if err != nil {
 94		return 0, nil, err
 95	}
 96	return emissionReward, cloneStringInt64Map(protocolFees), nil
 97}
 98
 99// GetClaimableRewardByLaunchpad returns claimable launchpad rewards for an address.
100//
101// Returns:
102//   - int64: emission reward amount
103//   - map[string]int64: protocol fee rewards by token path
104func GetClaimableRewardByLaunchpad(addr address) (int64, map[string]int64, error) {
105	emissionReward, protocolFees, err := getImplementation().GetClaimableRewardByLaunchpad(addr)
106	if err != nil {
107		return 0, nil, err
108	}
109	return emissionReward, cloneStringInt64Map(protocolFees), nil
110}
111
112// GetClaimableRewardByRewardID returns claimable reward details by reward ID.
113//
114// Returns:
115//   - int64: emission reward amount
116//   - map[string]int64: protocol fee rewards by token path
117func GetClaimableRewardByRewardID(rewardID string) (int64, map[string]int64, error) {
118	emissionReward, protocolFees, err := getImplementation().GetClaimableRewardByRewardID(rewardID)
119	if err != nil {
120		return 0, nil, err
121	}
122	return emissionReward, cloneStringInt64Map(protocolFees), nil
123}
124
125// GetLaunchpadProjectDeposit returns the deposit amount for a launchpad project.
126func GetLaunchpadProjectDeposit(projectAddr string) (int64, bool) {
127	return getImplementation().GetLaunchpadProjectDeposit(projectAddr)
128}
129
130// GetDelegationWithdrawCount returns the total number of delegation withdraws for a specific delegation.
131func GetDelegationWithdrawCount(delegationID int64) int {
132	return getImplementation().GetDelegationWithdrawCount(delegationID)
133}
134
135// GetDelegationWithdraws returns a paginated list of delegation withdraws for a specific delegation.
136func GetDelegationWithdraws(delegationID int64, offset, count int) ([]DelegationWithdraw, error) {
137	withdraws, err := getImplementation().GetDelegationWithdraws(delegationID, offset, count)
138	if err != nil {
139		return nil, err
140	}
141	return cloneDelegationWithdraws(withdraws), nil
142}
143
144// GetCollectableWithdrawAmount returns the collectable withdraw amount for a specific delegation.
145func GetCollectableWithdrawAmount(delegationID int64) int64 {
146	return getImplementation().GetCollectableWithdrawAmount(delegationID)
147}
148
149// GetProtocolFeeAccumulatedX128PerStake returns the accumulated protocol fee per stake (Q128) for a token path.
150func GetProtocolFeeAccumulatedX128PerStake(tokenPath string) *u256.Uint {
151	return getImplementation().GetProtocolFeeAccumulatedX128PerStake(tokenPath).Clone()
152}
153
154// GetProtocolFeeAmount returns the protocol fee amounts for a token path.
155func GetProtocolFeeAmount(tokenPath string) int64 {
156	return getImplementation().GetProtocolFeeAmount(tokenPath)
157}
158
159// GetProtocolFeeAccumulatedTimestamp returns the accumulated timestamp for protocol fee rewards.
160func GetProtocolFeeAccumulatedTimestamp() int64 {
161	return getImplementation().GetProtocolFeeAccumulatedTimestamp()
162}
163
164// GetEmissionAccumulatedX128PerStake returns the accumulated emission per stake (Q128).
165func GetEmissionAccumulatedX128PerStake() *u256.Uint {
166	return getImplementation().GetEmissionAccumulatedX128PerStake().Clone()
167}
168
169// GetEmissionDistributedAmount returns the total distributed emission amount.
170func GetEmissionDistributedAmount() int64 {
171	return getImplementation().GetEmissionDistributedAmount()
172}
173
174// GetEmissionAccumulatedTimestamp returns the accumulated timestamp for emission rewards.
175func GetEmissionAccumulatedTimestamp() int64 {
176	return getImplementation().GetEmissionAccumulatedTimestamp()
177}