launchpad source realm
View source
Launchpad
Token distribution platform for early-stage projects.
Overview
Launchpad enables new projects to distribute tokens to GNS stakers with tiered lock periods and pro-rata reward distribution. For more details about the concept, check out docs.
Configuration
- Pool Tiers: 30, 90, 180 days
- Minimum Start Delay: 3 days
- Minimum Deposit Amount: 1,000,000 GNS (must be a multiple of 1,000,000)
- Auto-delegation: Staked GNS converts to xGNS
- Tier Allocation: Customizable per project
Core Features
- GNS staking for project token rewards
- Multiple tier durations with different rewards
- Automatic xGNS delegation for governance
- Pro-rata distribution based on stake size
- Conditional participation requirements
Key Functions
CreateProject
Creates new token distribution project.
DepositGns
Stakes GNS to earn project tokens.
CollectRewardByDepositId
Claims earned project tokens.
CollectDepositGns
Withdraws GNS after lock period.
TransferLeftFromProjectByAdmin
Refunds unclaimed rewards to project.
Usage
1// Create project
2projectId := CreateProject(
3 name, tokenPath, recipient, amount,
4 conditionTokens, conditionAmounts,
5 tier30Ratio, tier90Ratio, tier180Ratio,
6 startTime
7)
8
9// Stake GNS
10depositId := DepositGns(projectTierId, amount, referrer)
11
12// Collect rewards
13CollectRewardByDepositId(depositId)
14
15// Withdraw after lock period
16CollectDepositGns(depositId)
Security
- GNS locked until tier period ends
- Automatic governance delegation
- Conditional requirements prevent abuse
2
const StoreKeyProjects, StoreKeyProjectTierRewardManagers, StoreKeyDepositCounter, StoreKeyDeposits, StoreKeyTotalGNSStakedAmount
1const (
2 StoreKeyProjects StoreKey = "projects" // Projects tree
3 StoreKeyProjectTierRewardManagers StoreKey = "projectTierRewardManagers" // Project tier reward managers tree
4 StoreKeyDepositCounter StoreKey = "depositCounter" // Deposit counter
5 StoreKeyDeposits StoreKey = "deposits" // Deposits tree
6 StoreKeyTotalGNSStakedAmount StoreKey = "totalGNSStakedAmount" // Total active launchpad GNS stake
7)71
func CollectDepositGns
crossing ActionCollectDepositGns collects rewards from a deposit.
func CollectEmissionReward
crossing ActionCollectEmissionReward collects accumulated launchpad emission rewards.
func CollectProtocolFee
crossing ActionCollectProtocolFee collects accumulated protocol fees from launchpad operations.
func CollectProtocolFeeReward
crossing ActionCollectProtocolFeeReward collects accumulated launchpad protocol fee rewards for the provided token path.
func CollectRewardByDepositId
crossing ActionCollectRewardByDepositId collects rewards from a deposit.
func CreateProject
crossing ActionCreateProject creates a new launchpad project with tiered allocations.
func DepositGns
crossing Action1func DepositGns(cur realm, targetProjectTierID string, depositAmount int64, referrer string) stringDepositGns deposits GNS tokens to a launchpad project tier.
func GetCurrentDepositId
ActionGetCurrentDepositId returns the current deposit counter value.
func GetDepositAmount
ActionGetDepositAmount returns the deposit amount of a deposit by its ID.
func GetDepositCount
ActionGetDepositCount returns the total number of deposits.
func GetDepositCreatedAt
ActionGetDepositCreatedAt returns the created time of a deposit by its ID.
func GetDepositCreatedHeight
ActionGetDepositCreatedHeight returns the created height of a deposit by its ID.
func GetDepositEndTime
ActionGetDepositEndTime returns the end time of a deposit by its ID.
func GetDepositProjectID
ActionGetDepositProjectID returns the project ID of a deposit by its ID.
func GetDepositProjectTierID
ActionGetDepositProjectTierID returns the project tier ID of a deposit by its ID.
func GetDepositTier
ActionGetDepositTier returns the tier of a deposit by its ID.
func GetDepositWithdrawnHeight
ActionGetDepositWithdrawnHeight returns the withdrawn height of a deposit by its ID.
func GetDepositWithdrawnTime
ActionGetDepositWithdrawnTime returns the withdrawn time of a deposit by its ID.
func GetImplementationPackagePath
ActionGetImplementationPackagePath returns the package path of the currently active implementation.
func GetProjectActiveStatus
ActionGetProjectActiveStatus returns whether a project is currently active.
func GetProjectCount
ActionGetProjectCount returns the total number of projects.
func GetProjectCreatedAt
ActionGetProjectCreatedAt returns the created time of a project by its ID.
func GetProjectCreatedHeight
ActionGetProjectCreatedHeight returns the created height of a project by its ID.
func GetProjectDepositAmount
ActionGetProjectDepositAmount returns the deposit amount of a project by its ID.
func GetProjectIDs
ActionGetProjectIDs returns a paginated list of project IDs.
func GetProjectName
ActionGetProjectName returns the name of a project by its ID.
func GetProjectTierDepositCount
ActionGetProjectTierDepositCount returns the total number of deposits for a project tier.
func GetProjectTierDepositIDs
ActionGetProjectTierDepositIDs returns a paginated list of deposit IDs for a project tier.
func GetProjectTierDistributeAmountPerSecondX128
Action1func GetProjectTierDistributeAmountPerSecondX128(projectId string, tier int64) (*u256.Uint, error)GetProjectTierDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of a project tier.
func GetProjectTierEndTime
ActionGetProjectTierEndTime returns the end time of a project tier.
func GetProjectTierRewardAccumulatedDistributeAmount
ActionGetProjectTierRewardAccumulatedDistributeAmount returns the accumulated distribute amount of a reward manager.
func GetProjectTierRewardAccumulatedRewardPerDepositX128
Action1func GetProjectTierRewardAccumulatedRewardPerDepositX128(projectTierId string) (*u256.Uint, error)GetProjectTierRewardAccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of a reward manager.
func GetProjectTierRewardAccumulatedTime
ActionGetProjectTierRewardAccumulatedTime returns the accumulated time of a reward manager.
func GetProjectTierRewardClaimableDuration
ActionGetProjectTierRewardClaimableDuration returns the reward claimable duration of a reward manager.
func GetProjectTierRewardDistributeAmountPerSecondX128
Action1func GetProjectTierRewardDistributeAmountPerSecondX128(projectTierId string) (*u256.Uint, error)GetProjectTierRewardDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of a reward manager.
func GetProjectTierRewardDistributeEndTime
ActionGetProjectTierRewardDistributeEndTime returns the distribute end time of a reward manager.
func GetProjectTierRewardDistributeStartTime
ActionGetProjectTierRewardDistributeStartTime returns the distribute start time of a reward manager.
func GetProjectTierRewardManagerCount
ActionGetProjectTierRewardManagerCount returns the total number of reward managers.
func GetProjectTierRewardTotalClaimedAmount
ActionGetProjectTierRewardTotalClaimedAmount returns the total claimed amount of a reward manager.
func GetProjectTierRewardTotalDistributeAmount
ActionGetProjectTierRewardTotalDistributeAmount returns the total distribute amount of a reward manager.
func GetProjectTierStartTime
ActionGetProjectTierStartTime returns the start time of a project tier.
func GetProjectTierTotalCollectedAmount
ActionGetProjectTierTotalCollectedAmount returns the total collected amount of a project tier.
func GetProjectTierTotalDepositAmount
ActionGetProjectTierTotalDepositAmount returns the total deposit amount of a project tier.
func GetProjectTierTotalDepositCount
ActionGetProjectTierTotalDepositCount returns the total deposit count of a project tier.
func GetProjectTierTotalDistributeAmount
ActionGetProjectTierTotalDistributeAmount returns the total distribute amount of a project tier.
func GetProjectTierTotalWithdrawAmount
ActionGetProjectTierTotalWithdrawAmount returns the total withdraw amount of a project tier.
func GetProjectTierTotalWithdrawCount
ActionGetProjectTierTotalWithdrawCount returns the total withdraw count of a project tier.
func GetProjectTiersRatios
ActionGetProjectTiersRatios returns the tiers ratios map of a project by its ID.
func GetProjectTokenPath
ActionGetProjectTokenPath returns the token path of a project by its ID.
func GetTotalGNSStakedAmount
ActionGetTotalGNSStakedAmount returns the total amount of GNS currently staked across all launchpad deposits.
func MakeProjectID
ActionMakeProjectID generates a unique project ID based on the given token path and the current block height.
The generated ID combines the `tokenPath` and the current block height in the following format: "{tokenPath}:{height}"
Parameters: - tokenPath (string): The path of the token associated with the project.
Returns: - string: A unique project ID in the format "tokenPath:height".
func MakeProjectTierID
ActionMakeProjectTierID generates a unique tier ID based on the given project ID and the tier duration.
The generated ID combines the `projectId` and the `duration` in the following format: "{projectId}:{duration}"
Parameters: - projectId (string): The unique ID of the project associated with the tier. - duration (uint64): The duration of the tier (e.g., 30, 90, 180 days).
Returns: - string: A unique tier ID in the format "projectId:duration".
func NewBPTreeN
ActionNewBPTreeN allocates a BP-tree under /r/gnoswap/launchpad's realm context (the realm that declares Project/Deposit/RewardManager). The tree's PkgID is therefore /r/gnoswap/launchpad, matching the domain values it stores, so tree.Set leaf-slot writes clear the readonly-taint gate regardless of which realm (launchpad/v1, mock, tests) calls Set. Implementations, mocks, and tests must allocate launchpad trees through here rather than calling bptree.NewBPTreeN directly in their own realm.
func RegisterInitializer
crossing Action1func RegisterInitializer(cur realm, initializer func(_ int, rlm realm, launchpadStore ILaunchpadStore) ILaunchpad)RegisterInitializer registers a new launchpad implementation version. This function is called by each version (v1, v2, etc.) during initialization to register their implementation with the proxy system.
The initializer function creates a new instance of the implementation using the provided launchpadStore interface.
Security: Only contracts within the domain path can register initializers. Each package path can only register once to prevent duplicate registrations.
func TransferLeftFromProjectByAdmin
crossing ActionTransferLeftFromProjectByAdmin transfers the remaining rewards of a project to a specified recipient.
func UpgradeImpl
crossing ActionUpgradeImpl switches the active launchpad implementation to a different version. This function allows seamless upgrades from one version to another without data migration or downtime.
Security: Only admin or governance can perform upgrades. The new implementation must have been previously registered via RegisterInitializer.
func NewCounter
ActionNewCounter creates a new Counter starting at 0.
func GetDeposit
ActionGetDeposit retrieves a deposit by its ID. Returns a cloned deposit to prevent external modification.
func NewDeposit
ActionNewDeposit returns a pointer to a new Deposit with the given values.
func NewLaunchpadStore
ActionNewLaunchpadStore creates a new launchpad store instance with the provided KV store. This function is used by the upgrade system to create storage instances for each implementation.
func GetProject
ActionGetProject retrieves a project by its ID. Returns a cloned project to prevent external modification.
func NewProject
Actionfunc GetProjectCondition
ActionGetProjectCondition retrieves a specific condition of a project. Returns a cloned condition to prevent external modification.
func NewProjectCondition
Actionfunc NewProjectConditionsWithError
Actionfunc GetProjectTier
ActionGetProjectTier retrieves a specific tier of a project. Returns a cloned tier to prevent external modification.
func NewProjectTier
ActionNewProjectTier returns a pointer to a new ProjectTier with the given values.
func GetProjectTierRewardManager
ActionGetProjectTierRewardManager retrieves a reward manager by project tier ID. Returns a cloned reward manager to prevent external modification.
func NewRewardManager
ActionNewRewardManager returns a pointer to a new RewardManager with the given values.
func GetRewardState
ActionGetRewardState retrieves a reward state by project tier ID and deposit ID. Returns a cloned reward state to prevent external modification.
func NewRewardState
ActionNewRewardState returns a pointer to a new RewardState with the given values.
13
type Counter
structCounter manages unique incrementing IDs.
type Deposit
structDeposit represents a deposit made by a user in a launchpad project.
This struct contains the necessary data and methods to manage and distribute rewards for a specific deposit.
Fields: - depositor (std.Address): The address of the depositor. - id (string): The unique identifier for the deposit. - projectID (string): The ID of the project associated with the deposit. - tier (int64): The tier of the deposit. - depositAmount (int64): The amount of the deposit. - withdrawnHeight (int64): The height at which the deposit was withdrawn. - withdrawnTime (int64): The time when the deposit was withdrawn. - createdTime (int64): The time when the deposit was created. - endTime (int64): The time when the deposit ends.
Methods on Deposit
func Clone
method on Depositfunc CreatedAt
method on Depositfunc CreatedHeight
method on Depositfunc DepositAmount
method on Depositfunc Depositor
method on Depositfunc EndTime
method on Depositfunc ID
method on Depositfunc IsDepositor
method on Depositfunc IsEnded
method on Depositfunc IsWithdrawn
method on Depositfunc ProjectID
method on Depositfunc ProjectTierID
method on Depositfunc SetCreatedAt
method on Depositfunc SetCreatedHeight
method on Depositfunc SetDepositAmount
method on Depositfunc SetDepositor
method on Depositfunc SetEndTime
method on Depositfunc SetID
method on Depositfunc SetProjectID
method on Depositfunc SetTier
method on Depositfunc SetWithdrawn
method on Depositfunc SetWithdrawnHeight
method on Depositfunc SetWithdrawnTime
method on Depositfunc Tier
method on Depositfunc WithdrawnHeight
method on Depositfunc WithdrawnTime
method on Deposittype ILaunchpad
interfacetype ILaunchpadDeposit
interfacetype ILaunchpadGetter
interface 1type ILaunchpadGetter interface {
2 GetProjectCount() int
3 GetProjectIDs(offset, count int) []string
4 GetProject(projectId string) (*Project, error)
5 GetProjectName(projectId string) (string, error)
6 GetProjectTokenPath(projectId string) (string, error)
7 GetProjectDepositAmount(projectId string) (int64, error)
8 GetProjectRecipient(projectId string) (address, error)
9 GetProjectCondition(projectId string, tokenPath string) (*ProjectCondition, error)
10 GetProjectTiersRatios(projectId string) (map[int64]int64, error)
11 GetProjectCreatedHeight(projectId string) (int64, error)
12 GetProjectCreatedAt(projectId string) (int64, error)
13
14 GetProjectTier(projectId string, tier int64) (*ProjectTier, error)
15 GetProjectTierDistributeAmountPerSecondX128(projectId string, tier int64) (*uint256.Uint, error)
16 GetProjectTierTotalDistributeAmount(projectId string, tier int64) (int64, error)
17 GetProjectTierTotalDepositAmount(projectId string, tier int64) (int64, error)
18 GetProjectTierTotalWithdrawAmount(projectId string, tier int64) (int64, error)
19 GetProjectTierTotalDepositCount(projectId string, tier int64) (int64, error)
20 GetProjectTierTotalWithdrawCount(projectId string, tier int64) (int64, error)
21 GetProjectTierTotalCollectedAmount(projectId string, tier int64) (int64, error)
22 GetProjectTierStartTime(projectId string, tier int64) (int64, error)
23 GetProjectTierEndTime(projectId string, tier int64) (int64, error)
24
25 GetDepositCount() int
26 GetCurrentDepositId() int64
27 GetProjectTierDepositCount(projectId string, tier int64) int
28 GetProjectTierDepositIDs(projectId string, tier int64, offset, count int) []string
29
30 GetDeposit(depositId string) (*Deposit, error)
31 GetDepositProjectID(depositId string) (string, error)
32 GetDepositTier(depositId string) (int64, error)
33 GetDepositProjectTierID(depositId string) (string, error)
34 GetDepositAmount(depositId string) (int64, error)
35 GetDepositWithdrawnHeight(depositId string) (int64, error)
36 GetDepositWithdrawnTime(depositId string) (int64, error)
37 GetDepositCreatedHeight(depositId string) (int64, error)
38 GetDepositCreatedAt(depositId string) (int64, error)
39 GetDepositEndTime(depositId string) (int64, error)
40 GetTotalGNSStakedAmount() int64
41
42 GetProjectTierRewardManagerCount() int
43 GetProjectTierRewardManager(projectTierId string) (*RewardManager, error)
44 GetProjectTierRewardDistributeAmountPerSecondX128(projectTierId string) (*uint256.Uint, error)
45 GetProjectTierRewardAccumulatedRewardPerDepositX128(projectTierId string) (*uint256.Uint, error)
46 GetProjectTierRewardTotalDistributeAmount(projectTierId string) (int64, error)
47 GetProjectTierRewardTotalClaimedAmount(projectTierId string) (int64, error)
48 GetProjectTierRewardDistributeStartTime(projectTierId string) (int64, error)
49 GetProjectTierRewardDistributeEndTime(projectTierId string) (int64, error)
50 GetProjectTierRewardAccumulatedDistributeAmount(projectTierId string) (int64, error)
51 GetProjectTierRewardAccumulatedTime(projectTierId string) (int64, error)
52 GetProjectTierRewardClaimableDuration(projectTierId string) (int64, error)
53
54 GetRewardState(projectTierId string, depositId string) (*RewardState, error)
55 GetProjectActiveStatus(projectId string) (bool, error)
56}type ILaunchpadProject
interface 1type ILaunchpadProject interface {
2 CreateProject(
3 _ int,
4 rlm realm,
5 name string,
6 tokenPath string,
7 recipient address,
8 depositAmount int64,
9 conditionTokens string,
10 conditionAmounts string,
11 tier30Ratio int64,
12 tier90Ratio int64,
13 tier180Ratio int64,
14 startTime int64,
15 ) string
16 TransferLeftFromProjectByAdmin(_ int, rlm realm, projectID string, recipient address) int64
17 CollectProtocolFee(_ int, rlm realm)
18 CollectEmissionReward(_ int, rlm realm)
19 CollectProtocolFeeReward(_ int, rlm realm, tokenPath string)
20}type ILaunchpadStore
interface 1type ILaunchpadStore interface {
2 HasProjectsKey() bool
3 GetProjects() *bptree.BPTree
4 SetProjects(_ int, rlm realm, projects *bptree.BPTree) error
5
6 HasProjectTierRewardManagersKey() bool
7 GetProjectTierRewardManagers() *bptree.BPTree
8 SetProjectTierRewardManagers(_ int, rlm realm, managers *bptree.BPTree) error
9
10 // DepositCounter
11 HasDepositCounterStoreKey() bool
12 GetDepositCounter() *Counter
13 SetDepositCounter(_ int, rlm realm, counter *Counter) error
14 NextDepositID() string
15
16 HasDepositsKey() bool
17 GetDeposits() *bptree.BPTree
18 SetDeposits(_ int, rlm realm, deposits *bptree.BPTree) error
19
20 HasTotalGNSStakedAmountKey() bool
21 GetTotalGNSStakedAmount() int64
22 SetTotalGNSStakedAmount(_ int, rlm realm, amount int64) error
23}type Project
struct 1type Project struct {
2 id string // 'tokenPath:createdHeight'
3 name string
4 tokenPath string
5 depositAmount int64
6 recipient address // string
7 conditions map[string]*ProjectCondition // tokenPath -> Condition
8 tiers map[int64]*ProjectTier
9 tiersRatios map[int64]int64
10 createdHeight int64
11 createdAt int64
12}Project represents a launchpad project.
This struct contains the necessary data and methods to manage and distribute rewards for a specific project.
Fields: - id (string): The unique identifier for the project, formatted as "{tokenPath}:{createdHeight}". - name (string): The name of the project. - tokenPath (string): The path of the token associated with the project. - depositAmount (int64): The total amount of tokens deposited for the project. - recipient (std.Address): The address to receive the project's rewards. - conditions (map[string]*ProjectCondition): A map of token paths to their associated conditions. - tiers (map[int64]*ProjectTier): A map of tier durations to their associated tiers. - tiersRatios (map[int64]int64): A map of tier durations to their associated ratios. - createdBlockTimeInfo (BlockTimeInfo): The block time and height information for the creation of the project.
Methods on Project
func Clone
method on Projectfunc Conditions
method on ProjectGetConditions returns the conditions map of the project.
func CreatedAt
method on ProjectGetCreatedAt returns the created time of the project.
func CreatedHeight
method on ProjectGetCreatedHeight returns the created height of the project.
func DepositAmount
method on ProjectGetDepositAmount returns the deposit amount of the project.
func GetTier
method on Projectfunc ID
method on ProjectGetID returns the ID of the project.
func IsRecipient
method on ProjectIsRecipient returns true if the project recipient is the given address.
func Name
method on ProjectGetName returns the name of the project.
func Recipient
method on ProjectGetRecipient returns the recipient address of the project.
func SetCondition
method on ProjectSetCondition sets a single condition by token path. Mutating the map inside the domain method avoids the readonly taint that arises when a caller in another realm round-trips Conditions()/SetConditions().
func SetConditions
method on ProjectSetConditions sets the conditions map of the project. The map is rebuilt so it is owned by this realm, allowing later in-domain mutations (e.g. SetCondition) without hitting the readonly taint on a foreign map.
func SetCreatedAt
method on ProjectSetCreatedAt sets the created time of the project.
func SetCreatedHeight
method on ProjectSetCreatedHeight sets the created height of the project.
func SetDepositAmount
method on ProjectSetDepositAmount sets the deposit amount of the project.
func SetID
method on ProjectSetID sets the ID of the project.
func SetName
method on ProjectSetName sets the name of the project.
func SetRecipient
method on ProjectSetRecipient sets the recipient address of the project.
func SetTier
method on Projectfunc SetTiers
method on ProjectSetTiers sets the tiers map of the project. The map is rebuilt so it is owned by this realm, allowing later in-domain mutations (e.g. SetTier) without hitting the readonly taint on a map passed in from another realm.
func SetTiersRatios
method on ProjectSetTiersRatios sets the tiers ratios map of the project.
func SetTokenPath
method on ProjectSetTokenPath sets the token path of the project.
func Tiers
method on ProjectGetTiers returns the tiers map of the project.
func TiersRatios
method on ProjectGetTiersRatios returns the tiers ratios map of the project.
func TokenPath
method on ProjectGetTokenPath returns the token path of the project.
type ProjectCondition
structProjectCondition represents a condition for a project.
This struct contains the necessary data and methods to manage and distribute rewards for a specific project.
Fields: - tokenPath (string): The path of the token associated with the project. - minimumAmount (int64): The minimum amount of the token required for the project.
Methods on ProjectCondition
func CheckBalanceCondition
method on ProjectConditionfunc Clone
method on ProjectConditionfunc IsAvailable
method on ProjectConditionfunc MinimumAmount
method on ProjectConditionfunc TokenPath
method on ProjectConditiontype ProjectTier
struct 1type ProjectTier struct {
2 distributeAmountPerSecondX128 *u256.Uint // distribute amount per second, Q128
3 id string // '{projectId}:duration' // duartion == 30, 90, 180
4 totalDistributeAmount int64
5 totalDepositAmount int64 // accumulated deposit amount
6 totalWithdrawAmount int64 // accumulated withdraw amount
7 totalDepositCount int64 // accumulated deposit count
8 totalWithdrawCount int64 // accumulated withdraw count
9 totalCollectedAmount int64 // total collected amount by user (reward)
10 startTime int64
11 endTime int64
12}ProjectTier represents a tier within a project.
This struct contains the necessary data and methods to manage and distribute rewards for a specific tier of a project.
Fields: - distributeAmountPerSecondX128 (u256.Uint): The amount of tokens to be distributed per second, represented as a Q128 fixed-point number. - startTime (int64): The time for the start of the tier. - endTime (int64): The time for the end of the tier. - id (string): The unique identifier for the tier, formatted as "{projectID}:duration". - totalDistributeAmount (int64): The total amount of tokens to be distributed for the tier. - totalDepositAmount (int64): The total amount of tokens deposited for the tier. - totalWithdrawAmount (int64): The total amount of tokens withdrawn from the tier. - totalDepositCount (int64): The total number of deposits made to the tier. - totalWithdrawCount (int64): The total number of withdrawals from the tier. - totalCollectedAmount (int64): The total amount of tokens collected as rewards for the tier.
Methods on ProjectTier
func Clone
method on ProjectTierfunc DistributeAmountPerSecondX128
method on ProjectTierDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the project tier.
func EndTime
method on ProjectTierEndTime returns the end time of the project tier.
func ID
method on ProjectTierID returns the ID of the project tier.
func IsActivated
method on ProjectTierfunc IsEnded
method on ProjectTierIsEnded returns true if the project tier has ended.
func SetDistributeAmountPerSecondX128
method on ProjectTierSetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the project tier.
func SetEndTime
method on ProjectTierSetEndTime sets the end time of the project tier.
func SetID
method on ProjectTierSetID sets the ID of the project tier.
func SetStartTime
method on ProjectTierSetStartTime sets the start time of the project tier.
func SetTotalCollectedAmount
method on ProjectTierSetTotalCollectedAmount sets the total collected amount of the project tier.
func SetTotalDepositAmount
method on ProjectTierSetTotalDepositAmount sets the total deposit amount of the project tier.
func SetTotalDepositCount
method on ProjectTierSetTotalDepositCount sets the total deposit count of the project tier.
func SetTotalDistributeAmount
method on ProjectTierSetTotalDistributeAmount sets the total distribute amount of the project tier.
func SetTotalWithdrawAmount
method on ProjectTierSetTotalWithdrawAmount sets the total withdraw amount of the project tier.
func SetTotalWithdrawCount
method on ProjectTierSetTotalWithdrawCount sets the total withdraw count of the project tier.
func StartTime
method on ProjectTierStartTime returns the start time of the project tier.
func TotalCollectedAmount
method on ProjectTierTotalCollectedAmount returns the total collected amount of the project tier.
func TotalDepositAmount
method on ProjectTierTotalDepositAmount returns the total deposit amount of the project tier.
func TotalDepositCount
method on ProjectTierTotalDepositCount returns the total deposit count of the project tier.
func TotalDistributeAmount
method on ProjectTierTotalDistributeAmount returns the total distribute amount of the project tier.
func TotalWithdrawAmount
method on ProjectTierTotalWithdrawAmount returns the total withdraw amount of the project tier.
func TotalWithdrawCount
method on ProjectTierTotalWithdrawCount returns the total withdraw count of the project tier.
type RewardManager
struct 1type RewardManager struct {
2 rewards *bptree.BPTree // depositId -> RewardState
3
4 distributeAmountPerSecondX128 *u256.Uint // distribute amount per second, Q128
5 accumulatedRewardPerDepositX128 *u256.Uint // accumulated reward per GNS stake, Q128
6
7 totalDistributeAmount int64 // total distributed amount
8 totalClaimedAmount int64 // total claimed amount
9 distributeStartTime int64 // start time of reward calculation
10 distributeEndTime int64 // end time of reward calculation
11 accumulatedDistributeAmount int64 // accumulated distribute amount
12 accumulatedTime int64 // last time when reward was calculated
13 rewardClaimableDuration int64 // duration of reward claimable
14}RewardManager manages the distribution of rewards for a project tier.
This struct contains the necessary data and methods to calculate and track rewards for deposits associated with a project tier.
Fields: - rewards (bptree.BPTree): A map of deposit IDs to their associated reward states. - distributeAmountPerSecondX128 (u256.Uint): The amount of tokens to be distributed per second, represented as a Q128 fixed-point number. - accumulatedRewardPerDepositX128 (u256.Uint): The accumulated reward per GNS stake, represented as a Q128 fixed-point number. - totalDistributeAmount (int64): The total amount of tokens to be distributed. - totalClaimedAmount (int64): The total amount of tokens claimed. - distributeStartTime (int64): The start time of the reward calculation. - distributeEndTime (int64): The end time of the reward calculation. - accumulatedDistributeAmount (int64): The accumulated amount of tokens distributed. - rewardClaimableDuration (int64): The duration of reward claimable.
Methods on RewardManager
func AccumulatedDistributeAmount
method on RewardManagerAccumulatedDistributeAmount returns the accumulated distribute amount of the reward manager.
func AccumulatedRewardPerDepositX128
method on RewardManagerAccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of the reward manager.
func AccumulatedTime
method on RewardManagerAccumulatedTime returns the accumulated time of the reward manager.
func Clone
method on RewardManagerfunc DistributeAmountPerSecondX128
method on RewardManagerDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the reward manager.
func DistributeEndTime
method on RewardManagerDistributeEndTime returns the distribute end time of the reward manager.
func DistributeStartTime
method on RewardManagerDistributeStartTime returns the distribute start time of the reward manager.
func RemoveReward
method on RewardManagerfunc RewardClaimableDuration
method on RewardManagerRewardClaimableDuration returns the reward claimable duration of the reward manager.
func Rewards
method on RewardManagerRewards returns the rewards tree of the reward manager.
func SetAccumulatedDistributeAmount
method on RewardManagerSetAccumulatedDistributeAmount sets the accumulated distribute amount of the reward manager.
func SetAccumulatedRewardPerDepositX128
method on RewardManagerSetAccumulatedRewardPerDepositX128 sets the accumulated reward per deposit (Q128) of the reward manager.
func SetAccumulatedTime
method on RewardManagerSetAccumulatedTime sets the accumulated time of the reward manager.
func SetDistributeAmountPerSecondX128
method on RewardManagerSetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the reward manager.
func SetDistributeEndTime
method on RewardManagerSetDistributeEndTime sets the distribute end time of the reward manager.
func SetDistributeStartTime
method on RewardManagerSetDistributeStartTime sets the distribute start time of the reward manager.
func SetReward
method on RewardManagerfunc SetRewardClaimableDuration
method on RewardManagerSetRewardClaimableDuration sets the reward claimable duration of the reward manager.
func SetRewards
method on RewardManagerSetRewards sets the rewards tree of the reward manager.
func SetTotalClaimedAmount
method on RewardManagerSetTotalClaimedAmount sets the total claimed amount of the reward manager.
func SetTotalDistributeAmount
method on RewardManagerSetTotalDistributeAmount sets the total distribute amount of the reward manager.
func TotalClaimedAmount
method on RewardManagerTotalClaimedAmount returns the total claimed amount of the reward manager.
func TotalDistributeAmount
method on RewardManagerTotalDistributeAmount returns the total distribute amount of the reward manager.
type RewardState
struct 1type RewardState struct {
2 priceDebtX128 *u256.Uint // price debt per GNS stake, Q128
3 claimableTime int64 // time when reward can be claimed
4
5 depositAmount int64 // amount of GNS staked
6 distributeStartTime int64 // time when launchpad started staking
7 distributeEndTime int64 // end time of reward calculation
8 accumulatedRewardAmount int64 // calculated, not collected
9 accumulatedTime int64 // last time when reward was calculated
10 claimedAmount int64 // amount of reward claimed so far
11}RewardState represents the state of a reward for a deposit. It contains the necessary data to manage and distribute rewards for a specific deposit.
Methods on RewardState
func AccumulatedRewardAmount
method on RewardStateAccumulatedRewardAmount returns the accumulated reward amount of the reward state.
func AccumulatedTime
method on RewardStateAccumulatedTime returns the accumulated time of the reward state.
func ClaimableTime
method on RewardStateClaimableTime returns the claimable time of the reward state.
func ClaimedAmount
method on RewardStateClaimedAmount returns the claimed amount of the reward state.
func Clone
method on RewardStatefunc DepositAmount
method on RewardStateDepositAmount returns the deposit amount of the reward state.
func DistributeEndTime
method on RewardStateDistributeEndTime returns the distribute end time of the reward state.
func DistributeStartTime
method on RewardStateDistributeStartTime returns the distribute start time of the reward state.
func PriceDebtX128
method on RewardStatePriceDebtX128 returns the price debt (Q128) of the reward state.
func SetAccumulatedRewardAmount
method on RewardStateSetAccumulatedRewardAmount sets the accumulated reward amount of the reward state.
func SetAccumulatedTime
method on RewardStateSetAccumulatedTime sets the accumulated time of the reward state.
func SetClaimableTime
method on RewardStateSetClaimableTime sets the claimable time of the reward state.
func SetClaimedAmount
method on RewardStateSetClaimedAmount sets the claimed amount of the reward state.
func SetDepositAmount
method on RewardStateSetDepositAmount sets the deposit amount of the reward state.
func SetDistributeEndTime
method on RewardStateSetDistributeEndTime sets the distribute end time of the reward state.
func SetDistributeStartTime
method on RewardStateSetDistributeStartTime sets the distribute start time of the reward state.
func SetPriceDebtX128
method on RewardStateSetPriceDebtX128 sets the price debt (Q128) of the reward state.