launchpad source realm
View source
Launchpad
Token distribution platform for launching projects with time-locked GNS deposits and project-token rewards.
Overview
The launchpad supports projects with three lock tiers: 30, 90, and 180 days. Project creators configure the project-token reward allocation for each tier, and depositors receive rewards according to the selected tier.
Gnoweb
The root Render("") delegates to the active implementation and shows realm identity, halt flags, project-creation roles, stored record counts, the deposit ID counter, total staked GNS, and timing and deposit requirements. Deposit records include withdrawn deposits.
GNS amounts use six-decimal base units; project rewards use their token's base units. Rendering reads stored counts and fixed configuration without traversing projects or deposits. Unsupported paths return 404.
Configuration
- Pool Tiers: 30 days, 90 days, and 180 days
- Minimum Start Delay: 3 days from project creation
- Minimum Deposit: 1 GNS (1,000,000 base units) and integer multiples of that amount
- Reward Claim Delay: 1 day after each deposit, capped at the selected tier's end time
- Condition Delimiter: Use
*PAD*between condition expressions - Auto-Delegation: Project deposits can be reflected in governance-staker accounting
Core Features
- Project Creation: Admin or governance creates a project and its tiers
- GNS Deposits: Users deposit GNS into a selected project tier
- Time-Locked Withdrawals: A depositor can withdraw the original GNS only after the tier ends
- Project-Token Rewards: Rewards accrue over the tier duration and can be claimed after the claim delay
- Administrative Refund: Admin can transfer the remaining refundable project-token balance from an ended project to a supplied recipient; active depositor claims remain reserved
Key Functions
CreateProject
Creates a new project with token address, reward amount, tier configuration,
and optional *PAD*-separated conditions. Only admin or governance may call it.
DepositGns
Deposits GNS into a project tier. The deposit amount must meet the minimum and multiple rules.
CollectRewardByDepositId
Claims the project-token reward for a deposit. Only the deposit owner can call it, and the reward is claimable one day after deposit creation, capped by the tier end time.
CollectDepositGns
Settles any claimable project-token reward and then returns the original GNS deposit. Only the deposit owner can call it, and the current time must be strictly after the selected tier's end time.
TransferLeftFromProjectByAdmin
Transfers the remaining refundable project-token balance from an ended project to the supplied recipient. Only admin may call it; amounts reserved for active depositor claims are not transferred.
Approval Requirements
DepositGnspulls GNS from the caller into the launchpad realm, so approve the launchpad realm for at least the deposit amount before calling.CollectRewardByDepositIdandCollectDepositGnspay out to the caller and require no approval.
1// Approve the launchpad realm before depositing
2launchpadAddress := access.MustGetAddress(prabc.ROLE_LAUNCHPAD.String())
3gns.Approve(cross(cur), launchpadAddress, 10_000_000)
Usage
1// Create a project (admin or governance; start must be at least 3 days away)
2projectID := CreateProject(
3 cross(cur),
4 "Example Project",
5 "gno.land/r/demo/projecttoken",
6 recipientAddr,
7 1_000_000_000,
8 "", // no condition tokens
9 "", // no condition amounts
10 10, // 30-day tier ratio
11 20, // 90-day tier ratio
12 70, // 180-day tier ratio
13 futureStartTimestamp,
14)
15
16// Deposit GNS into a 30-day tier; referrer is optional
17depositID := DepositGns(cross(cur), projectID+":30", 10_000_000, "")
18
19// Claim after the one-day delay
20CollectRewardByDepositId(cross(cur), depositID)
21
22// After the tier has ended, settle reward and withdraw principal
23CollectDepositGns(cross(cur), depositID)
24
25// Admin refund of the remaining project-token balance
26TransferLeftFromProjectByAdmin(cross(cur), projectID, recipientAddr)
Security
- Admin or governance authorization is required for project creation
- Deposits are locked until strictly after the selected tier's end time
- Project-token rewards are claimable only by the deposit owner and only after the one-day delay
- Withdrawal settles any claimable project-token reward before returning principal
- Administrative refunds require an ended project and preserve active depositor claims
- Conditions are evaluated for each deposit when configured
- Depositor and reward recipient addresses are validated
2
const StoreKeyProjects, StoreKeyProjectRecipients, StoreKeyProjectTierRewardManagers, StoreKeyDepositCounter, StoreKeyDeposits, StoreKeyTotalGNSStakedAmount
1const (
2 StoreKeyProjects StoreKey = "projects" // Projects tree
3 StoreKeyProjectRecipients StoreKey = "projectRecipients" // Recipient membership tree
4 StoreKeyProjectTierRewardManagers StoreKey = "projectTierRewardManagers" // Project tier reward managers tree
5 StoreKeyDepositCounter StoreKey = "depositCounter" // Deposit counter
6 StoreKeyDeposits StoreKey = "deposits" // Deposits tree
7 StoreKeyTotalGNSStakedAmount StoreKey = "totalGNSStakedAmount" // Total active launchpad GNS stake
8)70
func CollectDepositGns
crossing ActionCollectDepositGns withdraws the GNS amount recorded by a deposit.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
- depositID: identifier of the deposit whose GNS is collected.
Returns:
- amount: GNS amount withdrawn from the deposit.
- err: non-nil when the deposit cannot be collected.
Halt check: reverts while the Withdraw halt scope is active.
func CollectEmissionReward
crossing ActionCollectEmissionReward collects accumulated launchpad emission rewards.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
Halt check: reverts while the Withdraw halt scope is active.
func CollectProtocolFee
crossing ActionCollectProtocolFee collects protocol-fee rewards allocated to project recipients.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
Halt check: reverts while the Withdraw halt scope is active.
func CollectProtocolFeeReward
crossing ActionCollectProtocolFeeReward collects accumulated launchpad protocol-fee rewards for a token path.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
- tokenPath: token path whose accumulated protocol-fee reward is collected.
Halt check: reverts while the Withdraw halt scope is active.
func CollectRewardByDepositId
crossing ActionCollectRewardByDepositId collects the project-token reward earned by a deposit.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
- depositID: identifier of the deposit whose reward is collected.
Returns:
- amount: project-token reward amount transferred to the depositor.
Halt check: reverts while the Withdraw halt scope is active.
func CreateProject
crossing ActionCreateProject creates a new launchpad project callable by the administrator or governance.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
- name: human-readable project name.
- tokenPath: token path whose tokens are distributed as project rewards.
- recipient: address authorized to receive project rewards and project proceeds.
- depositAmount: total reward-token amount allocated to the project.
- conditionTokens: optional `*PAD*`-separated token paths required for deposits.
- conditionAmounts: optional `*PAD*`-separated required amounts matching conditionTokens.
- tier30Ratio: reward allocation ratio for the 30-day tier.
- tier90Ratio: reward allocation ratio for the 90-day tier.
- tier180Ratio: reward allocation ratio for the 180-day tier.
- startTime: Unix timestamp at which project reward distribution starts.
Returns:
- projectId: identifier assigned to the newly created project.
Halt check: reverts while the Launchpad halt scope is active.
func DepositGns
crossing Action1func DepositGns(cur realm, targetProjectTierID string, depositAmount int64, referrer string) stringDepositGns deposits GNS into a selected launchpad project tier.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
- targetProjectTierID: project-tier identifier in `{projectID}:{tierDuration}` form.
- depositAmount: amount of GNS to stake in the selected tier.
- referrer: optional referral address associated with the deposit.
Returns:
- depositId: identifier assigned to the newly created deposit.
Halt check: reverts while the Launchpad halt scope is active.
func GetCurrentDepositId
ActionGetCurrentDepositId returns the current deposit counter value.
Returns:
- depositId: current deposit counter value; it is not incremented by this read.
func GetDepositAmount
ActionGetDepositAmount returns the deposit amount of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- amount: GNS principal deposited, in base units.
- err: non-nil when depositId does not identify a stored deposit.
func GetDepositCount
ActionGetDepositCount returns the total number of deposits.
Returns:
- count: number of deposit records currently stored.
func GetDepositCreatedAt
ActionGetDepositCreatedAt returns the created time of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- createdAt: deposit creation Unix timestamp in seconds.
- err: non-nil when depositId does not identify a stored deposit.
func GetDepositCreatedHeight
ActionGetDepositCreatedHeight returns the created height of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- height: creation block height of the deposit.
- err: non-nil when depositId does not identify a stored deposit.
func GetDepositEndTime
ActionGetDepositEndTime returns the end time of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- endTime: deposit lock/end Unix timestamp in seconds.
- err: non-nil when depositId does not identify a stored deposit.
func GetDepositProjectID
ActionGetDepositProjectID returns the project ID of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- projectId: project identifier associated with the deposit.
- err: non-nil when depositId does not identify a stored deposit.
func GetDepositProjectTierID
ActionGetDepositProjectTierID returns the project tier ID of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- projectTierId: composite project-tier identifier derived from the deposit's project and tier.
- err: non-nil when depositId does not identify a stored deposit.
func GetDepositTier
ActionGetDepositTier returns the tier of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- tier: tier duration key selected by the deposit.
- err: non-nil when depositId does not identify a stored deposit.
func GetDepositWithdrawnHeight
ActionGetDepositWithdrawnHeight returns the withdrawn height of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- height: withdrawal block height; zero when the deposit has not been withdrawn.
- err: non-nil when depositId does not identify a stored deposit.
func GetDepositWithdrawnTime
ActionGetDepositWithdrawnTime returns the withdrawn time of a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- withdrawnAt: withdrawal Unix timestamp in seconds; zero when the deposit has not been withdrawn.
- err: non-nil when depositId does not identify a stored deposit.
func GetImplementationPackagePath
ActionGetImplementationPackagePath returns the package path of the currently active implementation.
Returns:
- packagePath: package path of the active implementation
func GetProjectActiveStatus
ActionGetProjectActiveStatus returns whether a project is currently active.
Parameters:
- projectId: unique identifier of the project to inspect.
Returns:
- active: true when the project is active at the current Unix time; false when it is inactive.
- err: non-nil when projectId does not identify a stored project.
func GetProjectCreatedAt
ActionGetProjectCreatedAt returns the created time of a project by its ID.
Parameters:
- projectId: unique identifier of the launchpad project to inspect.
Returns:
- createdAt: Unix timestamp in seconds at which the project was created.
- err: non-nil when projectId does not identify a stored project.
func GetProjectCreatedHeight
ActionGetProjectCreatedHeight returns the created height of a project by its ID.
Parameters:
- projectId: unique identifier of the launchpad project to inspect.
Returns:
- height: block height at which the project was created.
- err: non-nil when projectId does not identify a stored project.
func GetProjectDepositAmount
ActionGetProjectDepositAmount returns the deposit amount of a project by its ID.
Parameters:
- projectId: unique identifier of the launchpad project to inspect.
Returns:
- amount: project-token amount initially allocated to the project, in token base units.
- err: non-nil when projectId does not identify a stored project.
func GetProjectName
ActionGetProjectName returns the name of a project by its ID.
Parameters:
- projectId: unique identifier of the launchpad project to inspect.
Returns:
- name: stored project name.
- err: non-nil when projectId does not identify a stored project.
func GetProjectTierDistributeAmountPerSecondX128
Action1func GetProjectTierDistributeAmountPerSecondX128(projectId string, tier int64) (*u256.Uint, error)GetProjectTierDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- amountPerSecondX128: project-token distribution rate per second in Q128 fixed-point units; nil when no value is available.
- err: non-nil when the project or tier cannot be found.
func GetProjectTierEndTime
ActionGetProjectTierEndTime returns the end time of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- endTime: tier end timestamp in Unix seconds.
- err: non-nil when the project or tier cannot be found.
func GetProjectTierRewardAccumulatedDistributeAmount
ActionGetProjectTierRewardAccumulatedDistributeAmount returns a legacy reward-manager field. The v1 reward paths do not maintain it, so normal reads return zero unless it was explicitly set.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- amount: legacy accumulated distribution amount in token base units; v1 accounting normally leaves it at zero unless explicitly set.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewardAccumulatedRewardPerDepositX128
Action1func GetProjectTierRewardAccumulatedRewardPerDepositX128(projectTierId string) (*u256.Uint, error)GetProjectTierRewardAccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of a reward manager.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- accumulatedRewardPerDepositX128: accumulated reward index per deposited GNS unit in Q128 fixed-point units; nil when no value is available.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewardAccumulatedTime
ActionGetProjectTierRewardAccumulatedTime returns the accumulated time of a reward manager.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- time: last reward-accumulation timestamp in Unix seconds, or zero before accumulation.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewardClaimableDuration
ActionGetProjectTierRewardClaimableDuration returns the reward claimable duration of a reward manager.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- duration: reward claimable window in seconds.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewardDistributeAmountPerSecondX128
Action1func GetProjectTierRewardDistributeAmountPerSecondX128(projectTierId string) (*u256.Uint, error)GetProjectTierRewardDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of a reward manager.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- amountPerSecondX128: reward distribution rate per second in Q128 fixed-point token units; nil when no value is available.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewardDistributeEndTime
ActionGetProjectTierRewardDistributeEndTime returns the distribute end time of a reward manager.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- endTime: reward distribution end timestamp in Unix seconds.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewardDistributeStartTime
ActionGetProjectTierRewardDistributeStartTime returns the distribute start time of a reward manager.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- startTime: reward distribution start timestamp in Unix seconds.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewardManagerCount
ActionGetProjectTierRewardManagerCount returns the total number of reward managers.
Returns:
- count: number of project-tier reward managers currently stored.
func GetProjectTierRewardTotalClaimedAmount
ActionGetProjectTierRewardTotalClaimedAmount returns the total claimed amount of a reward manager.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- amount: total reward amount claimed from the manager, in token base units.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewardTotalDistributeAmount
ActionGetProjectTierRewardTotalDistributeAmount returns the total distribute amount of a reward manager.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- amount: total reward allocation managed for the project tier, in token base units.
- err: non-nil when projectTierId does not identify a stored reward manager.
func GetProjectTierRewards
ActionGetProjectTierRewards returns a read-only view of a project tier's reward states, keyed by deposit ID. Reading an entry yields a clone, so the view cannot mutate realm state. nil is returned when the project tier does not exist.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- rewards: read-only tree of reward states keyed by deposit ID; nil when the tier's reward manager is unavailable.
func GetProjectTierStartTime
ActionGetProjectTierStartTime returns the start time of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- startTime: tier start timestamp in Unix seconds.
- err: non-nil when the project or tier cannot be found.
func GetProjectTierTotalCollectedAmount
ActionGetProjectTierTotalCollectedAmount returns the total collected amount of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- amount: cumulative project-token reward collected from the tier, in token base units.
- err: non-nil when the project or tier cannot be found.
func GetProjectTierTotalDepositAmount
ActionGetProjectTierTotalDepositAmount returns the total deposit amount of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- amount: cumulative GNS principal deposited into the tier, in base units.
- err: non-nil when the project or tier cannot be found.
func GetProjectTierTotalDepositCount
ActionGetProjectTierTotalDepositCount returns the total deposit count of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- count: cumulative number of deposits created in the tier.
- err: non-nil when the project or tier cannot be found.
func GetProjectTierTotalDistributeAmount
ActionGetProjectTierTotalDistributeAmount returns the total distribute amount of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- amount: total project-token allocation for the tier, in token base units.
- err: non-nil when the project or tier cannot be found.
func GetProjectTierTotalWithdrawAmount
ActionGetProjectTierTotalWithdrawAmount returns the total withdraw amount of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- amount: cumulative GNS principal withdrawn from the tier, in base units.
- err: non-nil when the project or tier cannot be found.
func GetProjectTierTotalWithdrawCount
ActionGetProjectTierTotalWithdrawCount returns the total withdraw count of a project tier.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- count: cumulative number of withdrawals completed in the tier.
- err: non-nil when the project or tier cannot be found.
func GetProjectTiersRatios
ActionGetProjectTiersRatios returns the tiers ratios map of a project by its ID.
Parameters:
- projectId: unique identifier of the launchpad project to inspect.
Returns:
- tiersRatios: cloned map from tier duration to its allocation ratio.
- err: non-nil when projectId does not identify a stored project.
func GetProjectTokenPath
ActionGetProjectTokenPath returns the token path of a project by its ID.
Parameters:
- projectId: unique identifier of the launchpad project to inspect.
Returns:
- tokenPath: reward-token contract path configured for the project.
- err: non-nil when projectId does not identify a stored project.
func GetProjects
ActionGetProjects returns a read-only view of every project, keyed by project ID. Callers paginate it themselves through IterateByOffset. Reading an entry yields a clone, so the view cannot mutate realm state.
Returns:
- projects: read-only tree keyed by project ID; reading an entry yields a clone.
func GetTotalGNSStakedAmount
ActionGetTotalGNSStakedAmount returns the total amount of GNS currently staked across all launchpad deposits.
Returns:
- amount: total GNS principal currently staked across launchpad deposits, in base units.
func MakeProjectID
ActionMakeProjectID combines a token path and creation height into a project identifier.
Parameters:
- tokenPath: token path associated with the project.
- createdHeight: block height at which the project was created.
Returns:
- projectID: identifier in "{tokenPath}:{createdHeight}" form.
func MakeProjectTierID
ActionMakeProjectTierID constructs the tier identifier from a project ID and duration. The resulting identifier uses the "{projectID}:{duration}" format.
Parameters:
- projectID: unique launchpad project identifier associated with the tier.
- duration: tier duration in days, such as 30, 90, or 180.
Returns:
- projectTierID: identifier combining projectID and duration with a colon.
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.
Parameters:
- fanout: branching factor passed to the BP-tree constructor.
Returns:
- tree: new BP-tree allocated under the launchpad realm's package context.
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.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
- initializer: callback that receives the implementation realm context and launchpad store, then returns the version's ILaunchpad implementation; its leading integer discriminator is invoked as 0.
func Render
Render delegates web rendering to the active implementation.
func TransferLeftFromProjectByAdmin
crossing ActionTransferLeftFromProjectByAdmin transfers unreserved reward tokens from an ended project. Active depositor claims remain reserved and are excluded; only the administrator may call it.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
- projectID: identifier of the ended project whose remaining balance is transferred.
- recipient: destination address for the transferable balance.
Returns:
- amount: number of reward tokens transferred after active claims are reserved.
Halt check: reverts while the Launchpad halt scope is active.
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.
Parameters:
- cur: current realm context; callers use cross(cur) when crossing into this realm.
- packagePath: registered package path of the launchpad implementation to activate.
func NewCounter
ActionNewCounter creates a new Counter starting at zero.
Returns:
- counter: counter initialized with current ID zero.
func DefaultDeposit
ActionDefaultDeposit returns the zero Deposit value.
Returns:
- deposit: zero-valued Deposit with no identifier, amounts, timestamps, or withdrawal markers.
func GetDeposit
ActionGetDeposit retrieves a deposit by its ID.
Parameters:
- depositId: unique identifier of the deposit to inspect.
Returns:
- deposit: stored deposit value.
- err: non-nil when depositId does not identify a stored deposit.
func MakeDeposit
ActionMakeDeposit returns a new Deposit value with the given values.
Parameters:
- depositID: unique identifier to assign to the new deposit.
- projectID: launchpad project identifier associated with the deposit.
- tier: tier duration in days; launchpad tiers use 30, 90, or 180.
- depositor: account address making the deposit.
- depositAmount: amount of GNS deposited for the project.
- createdHeight: block height at which the deposit was created.
- createdTime: creation timestamp in Unix seconds.
- endTime: tier end timestamp in Unix seconds.
Returns:
- deposit: new Deposit populated with the supplied fields and zero withdrawal markers.
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.
Parameters:
- kvStore: key-value store used to persist launchpad state.
Returns:
- launchpadStore: storage implementation backed by kvStore.
func NewProject
ActionNewProject creates a project with empty conditions, tiers, and tier-ratio maps.
Parameters:
- name: human-readable project name.
- tokenPath: token path whose tokens are distributed as project rewards.
- depositAmount: total reward-token amount allocated to the project.
- recipient: address authorized to receive project rewards.
- createdHeight: block height at which the project is created.
- createdAt: Unix timestamp at which the project is created.
Returns:
- project: initialized project with an ID derived from tokenPath and createdHeight.
func GetProjectCondition
ActionGetProjectCondition retrieves a specific condition of a project. Returns a cloned condition to prevent external modification.
Parameters:
- projectId: unique identifier of the project containing the condition.
- tokenPath: token contract path used as the condition key.
Returns:
- condition: cloned condition for the requested token; nil when the implementation returns no condition without an error.
- err: non-nil when the project or condition cannot be found.
func NewProjectCondition
ActionNewProjectCondition creates a project condition for a token path and minimum amount.
Parameters:
- tokenPath: token contract path whose balance is required.
- minimumAmount: minimum balance in the token's base units.
Returns:
- condition: newly allocated project condition containing the supplied values.
func NewProjectConditionsWithError
Action1func NewProjectConditionsWithError(conditionTokens string, conditionAmounts string) ([]*ProjectCondition, error)NewProjectConditionsWithError parses parallel *PAD*-separated token paths and minimum amounts.
Parameters:
- conditionTokens: *PAD*-separated token contract paths, in condition order.
- conditionAmounts: *PAD*-separated decimal int64 minimum amounts paired by index with conditionTokens; entries beyond the token list are not consumed.
Returns:
- conditions: parsed available conditions in the same order as their token paths; empty when both inputs are empty.
- err: nil on successful parsing; non-nil when a token lacks a matching amount, an amount is not a valid int64, or a condition is unavailable.
func GetProjectTier
ActionGetProjectTier retrieves a specific tier of a project. Returns a cloned tier to prevent external modification.
Parameters:
- projectId: unique identifier of the project containing the tier.
- tier: tier duration key, such as 30, 90, or 180.
Returns:
- projectTier: cloned project tier; nil when the implementation supplies no tier without an error.
- err: non-nil when the project or tier cannot be found.
func NewProjectTier
ActionNewProjectTier returns a pointer to a new ProjectTier with the given values.
Parameters:
- projectID: launchpad project identifier associated with the tier.
- tierDuration: tier duration in days; launchpad tiers use 30, 90, or 180.
- totalDistributeAmount: total token amount allocated for this tier.
- startTime: tier start timestamp in Unix seconds.
- endTime: tier end timestamp in Unix seconds.
Returns:
- tier: new ProjectTier with the supplied identity, allocation, and time window; counters and rates start at zero.
func GetProjectTierRewardManager
ActionGetProjectTierRewardManager retrieves a reward manager by project tier ID. Returns a cloned reward manager to prevent external modification.
Parameters:
- projectTierId: composite project-tier identifier whose manager is requested.
Returns:
- rewardManager: cloned reward manager; nil when the implementation supplies no manager without an error.
- err: non-nil when projectTierId does not identify a stored reward manager.
func NewRewardManager
ActionNewRewardManager returns a pointer to a new RewardManager with the given values.
Parameters:
- totalDistributeAmount: total reward allocation for the tier in token base units.
- distributeStartTime: reward distribution start timestamp in Unix seconds.
- distributeEndTime: reward distribution end timestamp in Unix seconds.
- rewardCollectableDuration: duration in seconds for which each accrued reward remains claimable.
Returns:
- rewardManager: initialized manager with zeroed accounting counters and an empty reward tree.
func GetRewardState
ActionGetRewardState retrieves a reward state by project tier ID and deposit ID. Returns a cloned reward state to prevent external modification.
Parameters:
- projectTierId: composite project-tier identifier containing the reward state.
- depositId: deposit identifier whose reward state is requested.
Returns:
- rewardState: cloned reward state; nil when the implementation supplies no state without an error.
- err: non-nil when the reward manager or reward state cannot be found.
func NewRewardState
ActionNewRewardState creates a reward state initialized from a reward-per-deposit index.
Parameters:
- accumulatedRewardPerDepositX128: current accumulated reward-per-deposit index in Q128 fixed-point units; it becomes this deposit's initial price debt.
- depositAmount: GNS amount staked by the deposit, in base units.
- distributeStartTime: Unix timestamp in seconds when this deposit begins accruing rewards.
- distributeEndTime: Unix timestamp in seconds when this deposit stops accruing rewards.
- claimableTime: Unix timestamp in seconds after which the accrued reward can be claimed.
Returns:
- rewardState: newly allocated state with claimed and legacy accumulation fields initialized to zero.
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 duration of the deposit (30, 90, or 180 days). - depositAmount (int64): The amount of the deposit. - withdrawnHeight (int64): The height at which the deposit was withdrawn. - withdrawnTime (int64): The Unix timestamp when the deposit was withdrawn. - createdHeight (int64): The block height at which the deposit was created. - createdAt (int64): The Unix timestamp when the deposit was created. - endTime (int64): The Unix timestamp when the deposit ends.
Methods on Deposit
func CreatedAt
method on DepositCreatedAt returns the Unix timestamp at which the deposit was created.
Returns:
- createdAt: creation timestamp in Unix seconds.
func CreatedHeight
method on DepositCreatedHeight returns the block height at which the deposit was created.
Returns:
- createdHeight: creation block height stored on the deposit.
func DepositAmount
method on DepositDepositAmount returns the amount recorded for the deposit.
Returns:
- depositAmount: amount of GNS deposited for the associated project.
func Depositor
method on DepositDepositor returns the address that made the deposit.
Returns:
- depositor: account address recorded as the deposit owner.
func EndTime
method on DepositEndTime returns the Unix timestamp at which the deposit's tier ends.
Returns:
- endTime: tier end timestamp in Unix seconds.
func ID
method on DepositID returns the unique identifier stored for the deposit.
Returns:
- id: deposit identifier used to retrieve this deposit from launchpad state.
func IsDepositor
method on DepositIsDepositor reports whether an address matches the deposit owner.
Parameters:
- address: account address to compare with the recorded depositor.
Returns:
- matches: true when the supplied address has the same string representation as the depositor; false otherwise.
func IsEnded
method on DepositIsEnded reports whether the deposit's tier end time is before the supplied time.
Parameters:
- currentTime: current Unix timestamp in seconds used for the end-time comparison.
Returns:
- ended: true when endTime is strictly less than currentTime; false at or before the end time.
func IsWithdrawn
method on DepositIsWithdrawn reports whether both withdrawal markers have been recorded.
Returns:
- withdrawn: true when both withdrawnHeight and withdrawnTime are greater than zero; false when either marker is zero.
func ProjectID
method on DepositProjectID returns the identifier of the launchpad project associated with the deposit.
Returns:
- projectID: associated launchpad project identifier.
func ProjectTierID
method on DepositProjectTierID returns the composite identifier for the deposit's project tier.
Returns:
- projectTierID: identifier formed from the project ID and tier duration.
func SetCreatedAt
method on DepositSetCreatedAt updates the Unix timestamp recorded for deposit creation.
Parameters:
- createdAt: creation timestamp in Unix seconds.
func SetCreatedHeight
method on DepositSetCreatedHeight updates the block height recorded for deposit creation.
Parameters:
- createdHeight: block height at which the deposit was created.
func SetDepositAmount
method on DepositSetDepositAmount updates the amount recorded for the deposit.
Parameters:
- depositAmount: amount of GNS to record as deposited for the associated project.
func SetDepositor
method on DepositSetDepositor updates the account address recorded as the deposit owner.
Parameters:
- depositor: account address to record as the deposit owner.
func SetEndTime
method on DepositSetEndTime updates the Unix timestamp at which the deposit's tier ends.
Parameters:
- endTime: tier end timestamp in Unix seconds.
func SetID
method on DepositSetID updates the unique identifier stored for the deposit.
Parameters:
- id: new identifier to associate with the deposit.
func SetProjectID
method on DepositSetProjectID updates the launchpad project identifier associated with the deposit.
Parameters:
- projectID: identifier of the launchpad project to associate with the deposit.
func SetTier
method on DepositSetTier updates the tier duration recorded for the deposit.
Parameters:
- tier: tier duration in days; valid launchpad tiers are 30, 90, or 180.
func SetWithdrawn
method on DepositSetWithdrawn records the block height and Unix timestamp of withdrawal.
Parameters:
- withdrawnHeight: block height at which the deposit was withdrawn.
- withdrawnTime: withdrawal timestamp in Unix seconds.
func SetWithdrawnHeight
method on DepositSetWithdrawnHeight updates the block height recorded for withdrawal.
Parameters:
- withdrawnHeight: block height at which the deposit was withdrawn.
func SetWithdrawnTime
method on DepositSetWithdrawnTime updates the Unix timestamp recorded for withdrawal.
Parameters:
- withdrawnTime: withdrawal timestamp in Unix seconds.
func Tier
method on DepositTier returns the deposit's tier duration.
Returns:
- tier: tier duration in days; launchpad tiers use 30, 90, or 180.
func WithdrawnHeight
method on DepositWithdrawnHeight returns the block height recorded for withdrawal.
Returns:
- withdrawnHeight: withdrawal block height; zero before withdrawal is recorded.
func WithdrawnTime
method on DepositWithdrawnTime returns the Unix timestamp recorded for withdrawal.
Returns:
- withdrawnTime: withdrawal timestamp in Unix seconds; zero before withdrawal is recorded.
type ILaunchpad
interfacetype ILaunchpadDeposit
interface 1type ILaunchpadDeposit interface {
2 // DepositGns creates a GNS deposit in the selected project tier.
3 //
4 // Parameters:
5 // - _: Noncrossing implementation-call discriminator; pass 0.
6 // - rlm: Current realm context forwarded unchanged by the launchpad proxy.
7 // - targetProjectTierID: project-tier identifier in `{projectID}:{tierDuration}` form.
8 // - depositAmount: amount of GNS to stake in the selected tier.
9 // - referrer: optional referral address associated with the deposit.
10 //
11 // Returns:
12 // - depositID: identifier assigned to the newly created deposit.
13 DepositGns(_ int, rlm realm, targetProjectTierID string, depositAmount int64, referrer string) string
14 // CollectDepositGns withdraws a deposit's staked GNS after its tier permits withdrawal.
15 //
16 // Parameters:
17 // - _: Noncrossing implementation-call discriminator; pass 0.
18 // - rlm: Current realm context forwarded unchanged by the launchpad proxy.
19 // - depositID: identifier of the deposit whose GNS is collected.
20 //
21 // Returns:
22 // - amount: GNS amount withdrawn from the deposit.
23 // - err: non-nil when the deposit cannot be collected.
24 CollectDepositGns(_ int, rlm realm, depositID string) (int64, error)
25 // CollectRewardByDepositId collects the project-token reward earned by a deposit.
26 //
27 // Parameters:
28 // - _: Noncrossing implementation-call discriminator; pass 0.
29 // - rlm: Current realm context forwarded unchanged by the launchpad proxy.
30 // - depositID: identifier of the deposit whose reward is collected.
31 //
32 // Returns:
33 // - amount: project-token reward amount transferred to the depositor.
34 CollectRewardByDepositId(_ int, rlm realm, depositID string) int64
35}type ILaunchpadGetter
interface 1type ILaunchpadGetter interface {
2 // GetProjects returns a read-only tree containing projects keyed by project ID.
3 //
4 // Returns:
5 // - projects: read-only project tree for iteration without mutating stored state.
6 GetProjects() *rotree.ReadOnlyTree
7 // GetProjectName returns the human-readable name of a project.
8 //
9 // Parameters:
10 // - projectId: identifier of the project to inspect.
11 //
12 // Returns:
13 // - name: stored project name, or an empty string when lookup fails.
14 // - err: non-nil when projectId does not identify a stored project.
15 GetProjectName(projectId string) (string, error)
16 // GetProjectTokenPath returns the reward-token path configured for a project.
17 //
18 // Parameters:
19 // - projectId: identifier of the project to inspect.
20 //
21 // Returns:
22 // - tokenPath: configured project reward-token path, or an empty string on lookup failure.
23 // - err: non-nil when projectId does not identify a stored project.
24 GetProjectTokenPath(projectId string) (string, error)
25 // GetProjectDepositAmount returns the total reward-token allocation configured for a project.
26 //
27 // Parameters:
28 // - projectId: identifier of the project to inspect.
29 //
30 // Returns:
31 // - amount: configured project reward-token amount, or zero on lookup failure.
32 // - err: non-nil when projectId does not identify a stored project.
33 GetProjectDepositAmount(projectId string) (int64, error)
34 // GetProjectRecipient returns the address configured to receive a project's rewards.
35 //
36 // Parameters:
37 // - projectId: identifier of the project to inspect.
38 //
39 // Returns:
40 // - recipient: configured project recipient address, or the zero address on lookup failure.
41 // - err: non-nil when projectId does not identify a stored project.
42 GetProjectRecipient(projectId string) (address, error)
43 // GetProjectCondition returns the deposit condition for one token path in a project.
44 //
45 // Parameters:
46 // - projectId: identifier of the project to inspect.
47 // - tokenPath: token path whose required balance condition is requested.
48 //
49 // Returns:
50 // - condition: configured token condition, or nil when lookup fails.
51 // - err: non-nil when the project or token condition is not found.
52 GetProjectCondition(projectId string, tokenPath string) (*ProjectCondition, error)
53 // GetProjectTiersRatios returns reward allocation ratios keyed by tier duration.
54 //
55 // Parameters:
56 // - projectId: identifier of the project to inspect.
57 //
58 // Returns:
59 // - ratios: map from tier duration to its reward allocation ratio.
60 // - err: non-nil when projectId does not identify a stored project.
61 GetProjectTiersRatios(projectId string) (map[int64]int64, error)
62 // GetProjectCreatedHeight returns the block height at which a project was created.
63 //
64 // Parameters:
65 // - projectId: identifier of the project to inspect.
66 //
67 // Returns:
68 // - height: creation block height, or zero on lookup failure.
69 // - err: non-nil when projectId does not identify a stored project.
70 GetProjectCreatedHeight(projectId string) (int64, error)
71 // GetProjectCreatedAt returns the Unix timestamp at which a project was created.
72 //
73 // Parameters:
74 // - projectId: identifier of the project to inspect.
75 //
76 // Returns:
77 // - time: creation Unix timestamp, or zero on lookup failure.
78 // - err: non-nil when projectId does not identify a stored project.
79 GetProjectCreatedAt(projectId string) (int64, error)
80
81 // GetProjectTier returns one tier of a project by its duration.
82 //
83 // Parameters:
84 // - projectId: identifier of the project to inspect.
85 // - tier: tier duration in seconds.
86 //
87 // Returns:
88 // - projectTier: requested tier, or nil when lookup fails.
89 // - err: non-nil when the project or requested tier is not found.
90 GetProjectTier(projectId string, tier int64) (*ProjectTier, error)
91 // GetProjectTierDistributeAmountPerSecondX128 returns a tier's Q128-scaled reward rate.
92 //
93 // Parameters:
94 // - projectId: identifier of the project to inspect.
95 // - tier: tier duration in seconds.
96 //
97 // Returns:
98 // - amountPerSecondX128: reward tokens per second scaled by 2^128.
99 // - err: non-nil when the project or requested tier is not found.
100 GetProjectTierDistributeAmountPerSecondX128(projectId string, tier int64) (*uint256.Uint, error)
101 // GetProjectTierTotalDistributeAmount returns the total reward allocation for a tier.
102 //
103 // Parameters:
104 // - projectId: identifier of the project to inspect.
105 // - tier: tier duration in seconds.
106 //
107 // Returns:
108 // - amount: total reward-token amount allocated to the tier.
109 // - err: non-nil when the project or requested tier is not found.
110 GetProjectTierTotalDistributeAmount(projectId string, tier int64) (int64, error)
111 // GetProjectTierTotalDepositAmount returns the cumulative GNS deposited into a tier.
112 //
113 // Parameters:
114 // - projectId: identifier of the project to inspect.
115 // - tier: tier duration in seconds.
116 //
117 // Returns:
118 // - amount: cumulative GNS amount deposited into the tier.
119 // - err: non-nil when the project or requested tier is not found.
120 GetProjectTierTotalDepositAmount(projectId string, tier int64) (int64, error)
121 // GetProjectTierTotalWithdrawAmount returns the cumulative GNS withdrawn from a tier.
122 //
123 // Parameters:
124 // - projectId: identifier of the project to inspect.
125 // - tier: tier duration in seconds.
126 //
127 // Returns:
128 // - amount: cumulative GNS amount withdrawn from the tier.
129 // - err: non-nil when the project or requested tier is not found.
130 GetProjectTierTotalWithdrawAmount(projectId string, tier int64) (int64, error)
131 // GetProjectTierTotalDepositCount returns the cumulative number of tier deposits.
132 //
133 // Parameters:
134 // - projectId: identifier of the project to inspect.
135 // - tier: tier duration in seconds.
136 //
137 // Returns:
138 // - count: cumulative number of deposits recorded for the tier.
139 // - err: non-nil when the project or requested tier is not found.
140 GetProjectTierTotalDepositCount(projectId string, tier int64) (int64, error)
141 // GetProjectTierTotalWithdrawCount returns the cumulative number of tier withdrawals.
142 //
143 // Parameters:
144 // - projectId: identifier of the project to inspect.
145 // - tier: tier duration in seconds.
146 //
147 // Returns:
148 // - count: cumulative number of withdrawals recorded for the tier.
149 // - err: non-nil when the project or requested tier is not found.
150 GetProjectTierTotalWithdrawCount(projectId string, tier int64) (int64, error)
151 // GetProjectTierTotalCollectedAmount returns the cumulative reward amount collected from a tier.
152 //
153 // Parameters:
154 // - projectId: identifier of the project to inspect.
155 // - tier: tier duration in seconds.
156 //
157 // Returns:
158 // - amount: cumulative project-token reward amount collected from the tier.
159 // - err: non-nil when the project or requested tier is not found.
160 GetProjectTierTotalCollectedAmount(projectId string, tier int64) (int64, error)
161 // GetProjectTierStartTime returns the Unix timestamp when a tier starts distributing rewards.
162 //
163 // Parameters:
164 // - projectId: identifier of the project to inspect.
165 // - tier: tier duration in seconds.
166 //
167 // Returns:
168 // - time: tier distribution start Unix timestamp.
169 // - err: non-nil when the project or requested tier is not found.
170 GetProjectTierStartTime(projectId string, tier int64) (int64, error)
171 // GetProjectTierEndTime returns the Unix timestamp when a tier stops distributing rewards.
172 //
173 // Parameters:
174 // - projectId: identifier of the project to inspect.
175 // - tier: tier duration in seconds.
176 //
177 // Returns:
178 // - time: tier distribution end Unix timestamp.
179 // - err: non-nil when the project or requested tier is not found.
180 GetProjectTierEndTime(projectId string, tier int64) (int64, error)
181
182 // GetDepositCount returns the number of deposits currently stored.
183 //
184 // Returns:
185 // - count: number of stored deposits.
186 GetDepositCount() int
187 // GetCurrentDepositId returns the latest allocated deposit identifier.
188 //
189 // Returns:
190 // - depositID: latest numeric deposit identifier.
191 GetCurrentDepositId() int64
192 // GetProjectTierRewards returns a read-only reward-state tree for a project tier.
193 //
194 // Parameters:
195 // - projectId: identifier of the project to inspect.
196 // - tier: tier duration in seconds.
197 //
198 // Returns:
199 // - rewards: read-only tree of reward states keyed by deposit ID.
200 GetProjectTierRewards(projectId string, tier int64) *rotree.ReadOnlyTree
201
202 // GetDeposit returns the stored deposit identified by depositId.
203 //
204 // Parameters:
205 // - depositId: identifier of the deposit to inspect.
206 //
207 // Returns:
208 // - deposit: stored deposit, or its zero value when lookup fails.
209 // - err: non-nil when depositId does not identify a stored deposit.
210 GetDeposit(depositId string) (Deposit, error)
211 // GetDepositProjectID returns the project identifier associated with a deposit.
212 //
213 // Parameters:
214 // - depositId: identifier of the deposit to inspect.
215 //
216 // Returns:
217 // - projectID: project identifier recorded in the deposit.
218 // - err: non-nil when depositId does not identify a stored deposit.
219 GetDepositProjectID(depositId string) (string, error)
220 // GetDepositTier returns the tier duration recorded in a deposit.
221 //
222 // Parameters:
223 // - depositId: identifier of the deposit to inspect.
224 //
225 // Returns:
226 // - tier: deposit tier duration in seconds.
227 // - err: non-nil when depositId does not identify a stored deposit.
228 GetDepositTier(depositId string) (int64, error)
229 // GetDepositProjectTierID returns the combined project-tier identifier for a deposit.
230 //
231 // Parameters:
232 // - depositId: identifier of the deposit to inspect.
233 //
234 // Returns:
235 // - projectTierID: identifier in `{projectID}:{tierDuration}` form.
236 // - err: non-nil when depositId does not identify a stored deposit.
237 GetDepositProjectTierID(depositId string) (string, error)
238 // GetDepositAmount returns the currently staked GNS amount in a deposit.
239 //
240 // Parameters:
241 // - depositId: identifier of the deposit to inspect.
242 //
243 // Returns:
244 // - amount: current GNS amount held by the deposit.
245 // - err: non-nil when depositId does not identify a stored deposit.
246 GetDepositAmount(depositId string) (int64, error)
247 // GetDepositWithdrawnHeight returns the block height at which a deposit was withdrawn.
248 //
249 // Parameters:
250 // - depositId: identifier of the deposit to inspect.
251 //
252 // Returns:
253 // - height: withdrawal block height, or the stored zero value if not withdrawn.
254 // - err: non-nil when depositId does not identify a stored deposit.
255 GetDepositWithdrawnHeight(depositId string) (int64, error)
256 // GetDepositWithdrawnTime returns the Unix timestamp at which a deposit was withdrawn.
257 //
258 // Parameters:
259 // - depositId: identifier of the deposit to inspect.
260 //
261 // Returns:
262 // - time: withdrawal Unix timestamp, or the stored zero value if not withdrawn.
263 // - err: non-nil when depositId does not identify a stored deposit.
264 GetDepositWithdrawnTime(depositId string) (int64, error)
265 // GetDepositCreatedHeight returns the block height at which a deposit was created.
266 //
267 // Parameters:
268 // - depositId: identifier of the deposit to inspect.
269 //
270 // Returns:
271 // - height: deposit creation block height.
272 // - err: non-nil when depositId does not identify a stored deposit.
273 GetDepositCreatedHeight(depositId string) (int64, error)
274 // GetDepositCreatedAt returns the Unix timestamp at which a deposit was created.
275 //
276 // Parameters:
277 // - depositId: identifier of the deposit to inspect.
278 //
279 // Returns:
280 // - time: deposit creation Unix timestamp.
281 // - err: non-nil when depositId does not identify a stored deposit.
282 GetDepositCreatedAt(depositId string) (int64, error)
283 // GetDepositEndTime returns the Unix timestamp when a deposit's tier ends.
284 //
285 // Parameters:
286 // - depositId: identifier of the deposit to inspect.
287 //
288 // Returns:
289 // - time: deposit tier end Unix timestamp.
290 // - err: non-nil when depositId does not identify a stored deposit.
291 GetDepositEndTime(depositId string) (int64, error)
292 // GetTotalGNSStakedAmount returns the current GNS amount staked across all deposits.
293 //
294 // Returns:
295 // - amount: aggregate currently staked GNS amount.
296 GetTotalGNSStakedAmount() int64
297
298 // GetProjectTierRewardManagerCount returns the number of stored tier reward managers.
299 //
300 // Returns:
301 // - count: number of project-tier reward managers.
302 GetProjectTierRewardManagerCount() int
303 // GetProjectTierRewardManager returns the reward manager for a project tier.
304 //
305 // Parameters:
306 // - projectTierId: identifier of the project tier.
307 //
308 // Returns:
309 // - manager: reward manager for the project tier, or nil on lookup failure.
310 // - err: non-nil when projectTierId does not identify a stored manager.
311 GetProjectTierRewardManager(projectTierId string) (*RewardManager, error)
312 // GetProjectTierRewardDistributeAmountPerSecondX128 returns a tier manager's Q128 reward rate.
313 //
314 // Parameters:
315 // - projectTierId: identifier of the project tier.
316 //
317 // Returns:
318 // - amountPerSecondX128: reward tokens per second scaled by 2^128.
319 // - err: non-nil when projectTierId does not identify a stored manager.
320 GetProjectTierRewardDistributeAmountPerSecondX128(projectTierId string) (*uint256.Uint, error)
321 // GetProjectTierRewardAccumulatedRewardPerDepositX128 returns accumulated Q128 reward per deposit.
322 //
323 // Parameters:
324 // - projectTierId: identifier of the project tier.
325 //
326 // Returns:
327 // - accumulatedX128: accumulated reward-per-deposit value scaled by 2^128.
328 // - err: non-nil when projectTierId does not identify a stored manager.
329 GetProjectTierRewardAccumulatedRewardPerDepositX128(projectTierId string) (*uint256.Uint, error)
330 // GetProjectTierRewardTotalDistributeAmount returns total reward tokens allocated to a tier.
331 //
332 // Parameters:
333 // - projectTierId: identifier of the project tier.
334 //
335 // Returns:
336 // - amount: total reward-token allocation.
337 // - err: non-nil when projectTierId does not identify a stored manager.
338 GetProjectTierRewardTotalDistributeAmount(projectTierId string) (int64, error)
339 // GetProjectTierRewardTotalClaimedAmount returns total reward tokens claimed from a tier.
340 //
341 // Parameters:
342 // - projectTierId: identifier of the project tier.
343 //
344 // Returns:
345 // - amount: cumulative claimed reward-token amount.
346 // - err: non-nil when projectTierId does not identify a stored manager.
347 GetProjectTierRewardTotalClaimedAmount(projectTierId string) (int64, error)
348 // GetProjectTierRewardDistributeStartTime returns a tier manager's distribution start time.
349 //
350 // Parameters:
351 // - projectTierId: identifier of the project tier.
352 //
353 // Returns:
354 // - time: distribution start Unix timestamp.
355 // - err: non-nil when projectTierId does not identify a stored manager.
356 GetProjectTierRewardDistributeStartTime(projectTierId string) (int64, error)
357 // GetProjectTierRewardDistributeEndTime returns a tier manager's distribution end time.
358 //
359 // Parameters:
360 // - projectTierId: identifier of the project tier.
361 //
362 // Returns:
363 // - time: distribution end Unix timestamp.
364 // - err: non-nil when projectTierId does not identify a stored manager.
365 GetProjectTierRewardDistributeEndTime(projectTierId string) (int64, error)
366 // GetProjectTierRewardAccumulatedDistributeAmount returns the accumulated distributed reward amount.
367 //
368 // Parameters:
369 // - projectTierId: identifier of the project tier.
370 //
371 // Returns:
372 // - amount: accumulated reward-token amount accounted for distribution.
373 // - err: non-nil when projectTierId does not identify a stored manager.
374 GetProjectTierRewardAccumulatedDistributeAmount(projectTierId string) (int64, error)
375 // GetProjectTierRewardAccumulatedTime returns the timestamp through which rewards are accumulated.
376 //
377 // Parameters:
378 // - projectTierId: identifier of the project tier.
379 //
380 // Returns:
381 // - time: accumulated Unix timestamp.
382 // - err: non-nil when projectTierId does not identify a stored manager.
383 GetProjectTierRewardAccumulatedTime(projectTierId string) (int64, error)
384 // GetProjectTierRewardClaimableDuration returns the delay before rewards become claimable.
385 //
386 // Parameters:
387 // - projectTierId: identifier of the project tier.
388 //
389 // Returns:
390 // - duration: claimable delay in seconds.
391 // - err: non-nil when projectTierId does not identify a stored manager.
392 GetProjectTierRewardClaimableDuration(projectTierId string) (int64, error)
393
394 // GetRewardState returns the reward state for one deposit in a project tier.
395 //
396 // Parameters:
397 // - projectTierId: identifier of the project tier.
398 // - depositId: identifier of the deposit whose reward state is requested.
399 //
400 // Returns:
401 // - rewardState: stored reward state, or nil on lookup failure.
402 // - err: non-nil when the project tier or deposit reward state is missing.
403 GetRewardState(projectTierId string, depositId string) (*RewardState, error)
404 // GetProjectActiveStatus reports whether a project is active at the current time.
405 //
406 // Parameters:
407 // - projectId: identifier of the project to inspect.
408 //
409 // Returns:
410 // - active: true when the project is currently active; false otherwise.
411 // - err: non-nil when projectId does not identify a stored project.
412 GetProjectActiveStatus(projectId string) (bool, error)
413}type ILaunchpadProject
interface 1type ILaunchpadProject interface {
2 // CreateProject creates a project and its reward tiers in the current launchpad realm.
3 //
4 // Parameters:
5 // - _: Noncrossing implementation-call discriminator; pass 0.
6 // - rlm: Current realm context forwarded unchanged by the launchpad proxy.
7 // - name: human-readable project name.
8 // - tokenPath: token path whose tokens are distributed as project rewards.
9 // - recipient: address authorized to receive project rewards and project proceeds.
10 // - depositAmount: total reward-token amount allocated to the project.
11 // - conditionTokens: optional `*PAD*`-separated token paths required for deposits.
12 // - conditionAmounts: optional `*PAD*`-separated required amounts matching conditionTokens.
13 // - tier30Ratio: reward allocation ratio for the 30-day tier.
14 // - tier90Ratio: reward allocation ratio for the 90-day tier.
15 // - tier180Ratio: reward allocation ratio for the 180-day tier.
16 // - startTime: Unix timestamp at which project reward distribution starts.
17 //
18 // Returns:
19 // - projectID: identifier assigned to the newly created project.
20 CreateProject(
21 _ int,
22 rlm realm,
23 name string,
24 tokenPath string,
25 recipient address,
26 depositAmount int64,
27 conditionTokens string,
28 conditionAmounts string,
29 tier30Ratio int64,
30 tier90Ratio int64,
31 tier180Ratio int64,
32 startTime int64,
33 ) string
34 // TransferLeftFromProjectByAdmin transfers unreserved reward tokens from an ended project.
35 //
36 // Parameters:
37 // - _: Noncrossing implementation-call discriminator; pass 0.
38 // - rlm: Current realm context forwarded unchanged by the launchpad proxy.
39 // - projectID: identifier of the ended project whose remaining balance is transferred.
40 // - recipient: destination address for the transferable balance.
41 //
42 // Returns:
43 // - amount: number of reward tokens transferred after active claims are reserved.
44 TransferLeftFromProjectByAdmin(_ int, rlm realm, projectID string, recipient address) int64
45 // CollectProtocolFee collects protocol-fee rewards allocated to the project recipient.
46 //
47 // Parameters:
48 // - _: Noncrossing implementation-call discriminator; pass 0.
49 // - rlm: Current realm context forwarded unchanged by the launchpad proxy.
50 CollectProtocolFee(_ int, rlm realm)
51 // CollectEmissionReward collects accumulated launchpad emission rewards.
52 //
53 // Parameters:
54 // - _: Noncrossing implementation-call discriminator; pass 0.
55 // - rlm: Current realm context forwarded unchanged by the launchpad proxy.
56 CollectEmissionReward(_ int, rlm realm)
57 // CollectProtocolFeeReward collects accumulated protocol-fee rewards for one token path.
58 //
59 // Parameters:
60 // - _: Noncrossing implementation-call discriminator; pass 0.
61 // - rlm: Current realm context forwarded unchanged by the launchpad proxy.
62 // - tokenPath: token path whose accumulated protocol-fee reward is collected.
63 CollectProtocolFeeReward(_ int, rlm realm, tokenPath string)
64}type ILaunchpadStore
interface 1type ILaunchpadStore interface {
2 // HasProjectsKey reports whether the projects tree has a persisted store key.
3 //
4 // Returns:
5 // - exists: true when the projects store key is present.
6 HasProjectsKey() bool
7 // GetProjects returns the persisted project tree.
8 //
9 // Returns:
10 // - projects: tree containing projects keyed by project ID.
11 GetProjects() *bptree.BPTree
12 // SetProjects persists the project tree in the current store realm.
13 //
14 // Parameters:
15 // - _: Noncrossing implementation-call discriminator; pass 0.
16 // - rlm: current realm context forwarded for current-realm validation.
17 // - projects: project tree to persist.
18 //
19 // Returns:
20 // - err: non-nil when the realm context fails store validation or persistence fails.
21 SetProjects(_ int, rlm realm, projects *bptree.BPTree) error
22
23 // HasProjectRecipientsKey reports whether the project-recipient tree has a persisted key.
24 //
25 // Returns:
26 // - exists: true when the project-recipient store key is present.
27 HasProjectRecipientsKey() bool
28 // GetProjectRecipients returns the persisted project-recipient membership tree.
29 //
30 // Returns:
31 // - recipients: tree mapping project identifiers to recipient membership data.
32 GetProjectRecipients() *bptree.BPTree
33 // SetProjectRecipients persists the project-recipient membership tree.
34 //
35 // Parameters:
36 // - _: Noncrossing implementation-call discriminator; pass 0.
37 // - rlm: current realm context forwarded for current-realm validation.
38 // - recipients: project-recipient membership tree to persist.
39 //
40 // Returns:
41 // - err: non-nil when the realm context fails store validation or persistence fails.
42 SetProjectRecipients(_ int, rlm realm, recipients *bptree.BPTree) error
43
44 // HasProjectTierRewardManagersKey reports whether tier reward managers have a persisted key.
45 //
46 // Returns:
47 // - exists: true when the reward-manager store key is present.
48 HasProjectTierRewardManagersKey() bool
49 // GetProjectTierRewardManagers returns the persisted tier reward-manager tree.
50 //
51 // Returns:
52 // - managers: tree keyed by project-tier identifier.
53 GetProjectTierRewardManagers() *bptree.BPTree
54 // SetProjectTierRewardManagers persists the tier reward-manager tree.
55 //
56 // Parameters:
57 // - _: Noncrossing implementation-call discriminator; pass 0.
58 // - rlm: current realm context forwarded for current-realm validation.
59 // - managers: tier reward-manager tree to persist.
60 //
61 // Returns:
62 // - err: non-nil when the realm context fails store validation or persistence fails.
63 SetProjectTierRewardManagers(_ int, rlm realm, managers *bptree.BPTree) error
64
65 // DepositCounter
66 // HasDepositCounterStoreKey reports whether the deposit counter has a persisted key.
67 //
68 // Returns:
69 // - exists: true when the deposit-counter store key is present.
70 HasDepositCounterStoreKey() bool
71 // GetDepositCounter returns the persisted counter used to allocate deposit IDs.
72 //
73 // Returns:
74 // - counter: deposit ID counter.
75 GetDepositCounter() *Counter
76 // SetDepositCounter persists the counter used to allocate deposit IDs.
77 //
78 // Parameters:
79 // - _: Noncrossing implementation-call discriminator; pass 0.
80 // - rlm: current realm context forwarded for current-realm validation.
81 // - counter: counter state to persist.
82 //
83 // Returns:
84 // - err: non-nil when the realm context fails store validation or persistence fails.
85 SetDepositCounter(_ int, rlm realm, counter *Counter) error
86 // NextDepositID advances the deposit counter and returns its new identifier.
87 //
88 // Returns:
89 // - depositID: newly allocated deposit identifier.
90 NextDepositID() string
91
92 // HasDepositsKey reports whether the deposits tree has a persisted store key.
93 //
94 // Returns:
95 // - exists: true when the deposits store key is present.
96 HasDepositsKey() bool
97 // GetDeposits returns the persisted deposit tree.
98 //
99 // Returns:
100 // - deposits: tree containing deposits keyed by deposit ID.
101 GetDeposits() *bptree.BPTree
102 // SetDeposits persists the deposit tree in the current store realm.
103 //
104 // Parameters:
105 // - _: Noncrossing implementation-call discriminator; pass 0.
106 // - rlm: current realm context forwarded for current-realm validation.
107 // - deposits: deposit tree to persist.
108 //
109 // Returns:
110 // - err: non-nil when the realm context fails store validation or persistence fails.
111 SetDeposits(_ int, rlm realm, deposits *bptree.BPTree) error
112
113 // HasTotalGNSStakedAmountKey reports whether the aggregate GNS stake has a persisted key.
114 //
115 // Returns:
116 // - exists: true when the total-stake store key is present.
117 HasTotalGNSStakedAmountKey() bool
118 // GetTotalGNSStakedAmount returns the aggregate GNS amount currently staked.
119 //
120 // Returns:
121 // - amount: total GNS amount currently held in deposits.
122 GetTotalGNSStakedAmount() int64
123 // SetTotalGNSStakedAmount persists the aggregate current GNS stake.
124 //
125 // Parameters:
126 // - _: Noncrossing implementation-call discriminator; pass 0.
127 // - rlm: current realm context forwarded for current-realm validation.
128 // - amount: aggregate GNS amount currently staked.
129 //
130 // Returns:
131 // - err: non-nil when the realm context fails store validation or persistence fails.
132 SetTotalGNSStakedAmount(_ int, rlm realm, amount int64) error
133}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 (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. - createdHeight (int64): The block height at which the project was created. - createdAt (int64): The Unix timestamp at which the project was created.
Methods on Project
func Clone
method on ProjectClone returns a deep-enough copy of the project for independent map and nested condition/tier mutation; scalar fields are copied directly.
Returns:
- clone: project copy with independently allocated condition, tier, and ratio maps.
func Conditions
method on ProjectConditions returns a copy of the project's token deposit conditions.
Returns:
- conditions: map from token path to cloned condition values; mutations do not alter project state.
func CreatedAt
method on ProjectCreatedAt returns the Unix timestamp at which the project was created.
Returns:
- time: project creation Unix timestamp.
func CreatedHeight
method on ProjectCreatedHeight returns the block height at which the project was created.
Returns:
- height: project creation block height.
func DepositAmount
method on ProjectDepositAmount returns the total reward-token allocation configured for the project.
Returns:
- amount: project reward-token allocation.
func GetTier
method on ProjectGetTier returns a copy of the project's tier for one duration.
Parameters:
- duration: tier duration in seconds.
Returns:
- tier: cloned tier configuration for the duration, or nil when absent.
- err: non-nil when no tier is configured for duration.
func ID
method on ProjectID returns the project identifier in "{tokenPath}:{createdHeight}" form.
Returns:
- id: unique identifier assigned to this project.
func IsRecipient
method on ProjectIsRecipient reports whether recipient matches the project's configured recipient address.
Parameters:
- recipient: address to compare with the configured project recipient.
Returns:
- matches: true when recipient is the configured project recipient.
func Name
method on ProjectName returns the project's human-readable name.
Returns:
- name: stored project name.
func Recipient
method on ProjectRecipient returns the address authorized to receive the project's rewards.
Returns:
- recipient: configured project recipient address.
func SetCondition
method on ProjectSetCondition replaces one token-path deposit condition in the project-owned map.
Parameters:
- tokenPath: token path whose condition is replaced.
- condition: required balance condition for that token path.
func SetConditions
method on ProjectSetConditions replaces the project's token deposit conditions. The map and its entries are retained in the project realm for later mutation.
Parameters:
- conditions: map from required token path to its deposit condition.
func SetCreatedAt
method on ProjectSetCreatedAt replaces the project's creation timestamp.
Parameters:
- time: Unix timestamp to store as the project creation time.
func SetCreatedHeight
method on ProjectSetCreatedHeight replaces the project's creation block height.
Parameters:
- height: block height to store as the project creation height.
func SetDepositAmount
method on ProjectSetDepositAmount replaces the project's total reward-token allocation.
Parameters:
- amount: total reward-token amount allocated to the project.
func SetID
method on ProjectSetID replaces the project's identifier.
Parameters:
- id: project identifier to store, normally in "{tokenPath}:{createdHeight}" form.
func SetName
method on ProjectSetName replaces the project's human-readable name.
Parameters:
- name: project name to store.
func SetRecipient
method on ProjectSetRecipient replaces the address authorized to receive project rewards.
Parameters:
- recipient: address to store as the project recipient.
func SetTier
method on ProjectSetTier replaces one duration entry in the project-owned tier map.
Parameters:
- duration: tier duration in seconds used as the map key.
- tier: tier configuration to store for duration.
func SetTiers
method on ProjectSetTiers replaces the project's tier map with a project-owned map.
Parameters:
- tiers: map from tier duration in seconds to its tier configuration.
func SetTiersRatios
method on ProjectSetTiersRatios replaces the project's tier allocation ratios.
Parameters:
- tiersRatios: map from tier duration in seconds to its reward allocation ratio.
func SetTokenPath
method on ProjectSetTokenPath replaces the project's reward-token path.
Parameters:
- tokenPath: token path to store as the project's reward token.
func Tiers
method on ProjectTiers returns a copy of the project's configured duration-to-tier map.
Returns:
- tiers: map from tier duration in seconds to cloned tier values.
func TiersRatios
method on ProjectTiersRatios returns reward allocation ratios keyed by tier duration.
Returns:
- ratios: map from tier duration in seconds to its allocation ratio.
func TokenPath
method on ProjectTokenPath returns the token path whose tokens are distributed as project rewards.
Returns:
- tokenPath: configured project reward-token path.
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 ProjectCondition1func (p *ProjectCondition) CheckBalanceCondition(inputTokenPath string, inputAmount int64) errorCheckBalanceCondition validates an input token balance against this condition.
Parameters:
- inputTokenPath: token path whose balance is being checked; it must equal the condition token path.
- inputAmount: input token balance in base units; it must be at least the configured minimum.
Returns:
- err: nil when the token path and amount satisfy the condition; non-nil describing a mismatch otherwise.
func Clone
method on ProjectConditionClone returns an independent copy of this project condition.
Returns:
- condition: copied token path and minimum amount in a new ProjectCondition value.
func IsAvailable
method on ProjectConditionIsAvailable reports whether this condition has a non-empty token path and a positive minimum amount.
Returns:
- available: true when both the token path and minimum amount are valid; false otherwise.
func MinimumAmount
method on ProjectConditionMinimumAmount returns the minimum balance amount required by this condition.
Returns:
- minimumAmount: minimum amount in the token's base units; values at or below zero make the condition unavailable.
func TokenPath
method on ProjectConditionTokenPath returns the token contract path required by this condition.
Returns:
- tokenPath: configured condition token path; an empty string means no token is configured.
type ProjectTier
struct 1type ProjectTier struct {
2 distributeAmountPerSecondX128 *u256.Uint // distribute amount per second, Q128
3 id string // '{projectId}:duration' // duration == 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 ProjectTierClone returns an independent copy of the project tier, including a cloned Q128 distribution-rate value and all aggregate counters.
Returns:
- clone: copy whose mutable fixed-point value is independent of the receiver.
func DistributeAmountPerSecondX128
method on ProjectTierDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the project tier.
Returns:
- amount: per-second distribution rate encoded as a Q128 fixed-point value.
func EndTime
method on ProjectTierEndTime returns the end time of the project tier.
Returns:
- time: tier end timestamp in Unix seconds.
func ID
method on ProjectTierID returns the ID of the project tier.
Returns:
- id: tier identifier in the "{projectID}:{duration}" form.
func IsActivated
method on ProjectTierIsActivated reports whether the tier is active at the supplied timestamp.
Parameters:
- currentTime: timestamp in Unix seconds to compare with the tier window.
Returns:
- activated: true when startTime <= currentTime and currentTime < endTime; false otherwise.
func IsEnded
method on ProjectTierIsEnded returns true if the project tier has ended.
Parameters:
- currentTime: timestamp in Unix seconds to compare with the tier end time.
Returns:
- ended: true when endTime is strictly less than currentTime; false at or before the end time.
func SetDistributeAmountPerSecondX128
method on ProjectTierSetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the project tier.
Parameters:
- amount: per-second distribution rate to store, encoded as a Q128 fixed-point value.
func SetEndTime
method on ProjectTierSetEndTime sets the end time of the project tier.
Parameters:
- time: tier end timestamp in Unix seconds.
func SetID
method on ProjectTierSetID sets the ID of the project tier.
Parameters:
- id: tier identifier to store, normally "{projectID}:{duration}".
func SetStartTime
method on ProjectTierSetStartTime sets the start time of the project tier.
Parameters:
- time: tier start timestamp in Unix seconds.
func SetTotalCollectedAmount
method on ProjectTierSetTotalCollectedAmount sets the total collected amount of the project tier.
Parameters:
- amount: aggregate reward amount to record as collected from this tier.
func SetTotalDepositAmount
method on ProjectTierSetTotalDepositAmount sets the total deposit amount of the project tier.
Parameters:
- amount: aggregate token amount to record as deposited into this tier.
func SetTotalDepositCount
method on ProjectTierSetTotalDepositCount sets the total deposit count of the project tier.
Parameters:
- count: number of deposits to record for this tier.
func SetTotalDistributeAmount
method on ProjectTierSetTotalDistributeAmount sets the total distribute amount of the project tier.
Parameters:
- amount: total token amount allocated for distribution by this tier.
func SetTotalWithdrawAmount
method on ProjectTierSetTotalWithdrawAmount sets the total withdraw amount of the project tier.
Parameters:
- amount: aggregate token amount to record as withdrawn from this tier.
func SetTotalWithdrawCount
method on ProjectTierSetTotalWithdrawCount sets the total withdraw count of the project tier.
Parameters:
- count: number of withdrawals to record for this tier.
func StartTime
method on ProjectTierStartTime returns the start time of the project tier.
Returns:
- time: tier start timestamp in Unix seconds.
func TotalCollectedAmount
method on ProjectTierTotalCollectedAmount returns the total collected amount of the project tier.
Returns:
- amount: aggregate reward amount collected from this tier.
func TotalDepositAmount
method on ProjectTierTotalDepositAmount returns the total deposit amount of the project tier.
Returns:
- amount: aggregate token amount deposited into this tier.
func TotalDepositCount
method on ProjectTierTotalDepositCount returns the total deposit count of the project tier.
Returns:
- count: number of deposits recorded for this tier.
func TotalDistributeAmount
method on ProjectTierTotalDistributeAmount returns the total distribute amount of the project tier.
Returns:
- amount: total token amount allocated for distribution by this tier.
func TotalWithdrawAmount
method on ProjectTierTotalWithdrawAmount returns the total withdraw amount of the project tier.
Returns:
- amount: aggregate token amount withdrawn from this tier.
func TotalWithdrawCount
method on ProjectTierTotalWithdrawCount returns the total withdraw count of the project tier.
Returns:
- count: number of withdrawals recorded for this 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 token allocation for this tier
8 totalClaimedAmount int64 // total claimed amount
9 activeDepositAmount int64 // principal represented by active reward states
10 activeClaimedAmount int64 // claims paid to active reward states
11 distributeStartTime int64 // start time of reward calculation
12 distributeEndTime int64 // end time of reward calculation
13 accumulatedDistributeAmount int64 // legacy field; v1 reward paths do not update it
14 accumulatedTime int64 // last time when reward was calculated
15 rewardClaimableDuration int64 // duration of reward claimable
16
17 activePriceDebtX128 *u256.Uint // sum of active deposit amount × initial reward index
18}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 token allocation for this tier. - 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): A legacy field not maintained by v1 reward accounting; normally zero unless explicitly set. - rewardClaimableDuration (int64): The duration of reward claimable.
Methods on RewardManager
func AccumulatedDistributeAmount
method on RewardManagerAccumulatedDistributeAmount returns the legacy reward-manager field. v1 reward paths do not maintain it, so normal reads return zero unless it was explicitly set.
Returns:
- amount: legacy accumulated distribution amount in token base units; v1 accounting normally leaves it at zero unless explicitly set.
func AccumulatedRewardPerDepositX128
method on RewardManagerAccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of the reward manager.
Returns:
- accumulatedRewardPerDepositX128: accumulated reward index per deposited GNS unit in Q128 fixed-point units.
func AccumulatedTime
method on RewardManagerAccumulatedTime returns the accumulated time of the reward manager.
Returns:
- time: last reward-accumulation timestamp in Unix seconds, or zero before accumulation.
func ActiveClaimedAmount
method on RewardManagerActiveClaimedAmount returns the reward amount claimed by currently active reward states.
Returns:
- amount: active claimed reward amount in token base units.
func ActiveDepositAmount
method on RewardManagerActiveDepositAmount returns the principal represented by currently active reward states.
Returns:
- amount: active deposited GNS principal in base units.
func ActivePriceDebtX128
method on RewardManagerActivePriceDebtX128 returns the sum of active deposits' initial reward-index debts.
Returns:
- debt: aggregate active price debt in Q128 fixed-point units.
func Clone
method on RewardManagerClone returns an independent copy of the reward manager, including its reward states and Q128 values.
Returns:
- rewardManager: deep copy with a separate reward tree and mutable numeric values.
func DistributeAmountPerSecondX128
method on RewardManagerDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the reward manager.
Returns:
- amountPerSecondX128: reward distribution rate in Q128 fixed-point token units per second.
func DistributeEndTime
method on RewardManagerDistributeEndTime returns the distribute end time of the reward manager.
Returns:
- endTime: reward distribution end timestamp in Unix seconds.
func DistributeStartTime
method on RewardManagerDistributeStartTime returns the distribute start time of the reward manager.
Returns:
- startTime: reward distribution start timestamp in Unix seconds.
func RemoveReward
method on RewardManagerRemoveReward removes the reward state associated with a deposit ID.
Parameters:
- depositID: deposit identifier whose reward state is removed.
func RewardClaimableDuration
method on RewardManagerRewardClaimableDuration returns the reward claimable duration of the reward manager.
Returns:
- duration: time after a reward becomes claimable during which it remains collectible, in seconds.
func Rewards
method on RewardManagerRewards returns the rewards tree of the reward manager.
Returns:
- rewards: reward-state tree keyed by deposit ID.
func SetAccumulatedDistributeAmount
method on RewardManagerSetAccumulatedDistributeAmount sets the legacy reward-manager field. It is not used by v1 reward accounting.
Parameters:
- amount: legacy accumulated distribution amount in token base units; v1 accounting does not update this field.
func SetAccumulatedRewardPerDepositX128
method on RewardManagerSetAccumulatedRewardPerDepositX128 sets the accumulated reward per deposit (Q128) of the reward manager.
Parameters:
- amount: replacement accumulated reward-per-deposit index in Q128 fixed-point units; the value is copied.
func SetAccumulatedTime
method on RewardManagerSetAccumulatedTime sets the accumulated time of the reward manager.
Parameters:
- time: last reward-accumulation timestamp in Unix seconds.
func SetActiveClaimedAmount
method on RewardManagerSetActiveClaimedAmount replaces the reward amount claimed by currently active reward states.
Parameters:
- amount: active claimed reward amount in token base units.
func SetActiveDepositAmount
method on RewardManagerSetActiveDepositAmount replaces the principal represented by currently active reward states.
Parameters:
- amount: active deposited GNS principal in base units.
func SetActivePriceDebtX128
method on RewardManagerSetActivePriceDebtX128 replaces the aggregate active price-index debt.
Parameters:
- debt: aggregate active price debt in Q128 fixed-point units; the value is copied.
func SetDistributeAmountPerSecondX128
method on RewardManagerSetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the reward manager.
Parameters:
- amount: replacement reward distribution rate in Q128 fixed-point token units per second; the value is copied.
func SetDistributeEndTime
method on RewardManagerSetDistributeEndTime sets the distribute end time of the reward manager.
Parameters:
- time: reward distribution end timestamp in Unix seconds.
func SetDistributeStartTime
method on RewardManagerSetDistributeStartTime sets the distribute start time of the reward manager.
Parameters:
- time: reward distribution start timestamp in Unix seconds.
func SetReward
method on RewardManagerSetReward associates a reward state with a deposit ID in the manager's reward tree.
Parameters:
- depositID: deposit identifier used as the reward-tree key.
- rewardState: reward state to store for that deposit.
func SetRewardClaimableDuration
method on RewardManagerSetRewardClaimableDuration sets the reward claimable duration of the reward manager.
Parameters:
- duration: claimable reward window in seconds.
func SetRewards
method on RewardManagerSetRewards sets the rewards tree of the reward manager.
Parameters:
- rewards: reward-state tree to use for this manager.
func SetTotalClaimedAmount
method on RewardManagerSetTotalClaimedAmount sets the total claimed amount of the reward manager.
Parameters:
- amount: total claimed reward amount in token base units.
func SetTotalDistributeAmount
method on RewardManagerSetTotalDistributeAmount sets the total distribute amount of the reward manager.
Parameters:
- amount: total reward allocation for the tier in token base units.
func TotalClaimedAmount
method on RewardManagerTotalClaimedAmount returns the total claimed amount of the reward manager.
Returns:
- amount: total reward amount claimed from the tier in token base units.
func TotalDistributeAmount
method on RewardManagerTotalDistributeAmount returns the total distribute amount of the reward manager.
Returns:
- amount: total reward allocation for the tier in token base units.
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 // legacy field; v1 reward accounting does not populate it
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 legacy accumulated reward field.
Returns:
- amount: legacy reward amount in token base units; v1 accounting normally leaves it at zero unless explicitly set.
func AccumulatedTime
method on RewardStateAccumulatedTime returns the last timestamp recorded for reward accumulation.
Returns:
- time: last accumulated timestamp in Unix seconds, or zero before one is recorded.
func ClaimableTime
method on RewardStateClaimableTime returns the earliest Unix timestamp at which this reward may be claimed.
Returns:
- claimableTime: claimability timestamp in Unix seconds.
func ClaimedAmount
method on RewardStateClaimedAmount returns the reward amount already claimed for this deposit.
Returns:
- amount: claimed reward amount in token base units.
func Clone
method on RewardStateClone returns an independent copy of this reward state, including a cloned Q128 price debt value.
Returns:
- rewardState: deep copy of the reward state that can be modified without changing the source.
func DepositAmount
method on RewardStateDepositAmount returns the GNS principal represented by this reward state.
Returns:
- amount: staked GNS amount in base units used for reward allocation.
func DistributeEndTime
method on RewardStateDistributeEndTime returns the Unix timestamp when this deposit stops accruing rewards.
Returns:
- endTime: reward accrual end timestamp in Unix seconds.
func DistributeStartTime
method on RewardStateDistributeStartTime returns the Unix timestamp when this deposit starts accruing rewards.
Returns:
- startTime: reward accrual start timestamp in Unix seconds.
func PriceDebtX128
method on RewardStatePriceDebtX128 returns the deposit's initial reward index debt in Q128 fixed-point units.
Returns:
- debt: stored price debt used to subtract rewards accrued before this deposit joined.
func SetAccumulatedRewardAmount
method on RewardStateSetAccumulatedRewardAmount sets the legacy accumulated reward field.
Parameters:
- amount: legacy reward amount in token base units; v1 accounting does not update this field.
func SetAccumulatedTime
method on RewardStateSetAccumulatedTime sets the last timestamp recorded for reward accumulation.
Parameters:
- time: last accumulated timestamp in Unix seconds.
func SetClaimableTime
method on RewardStateSetClaimableTime sets the earliest Unix timestamp at which this reward may be claimed.
Parameters:
- time: claimability timestamp in Unix seconds.
func SetClaimedAmount
method on RewardStateSetClaimedAmount replaces the reward amount already claimed for this deposit.
Parameters:
- amount: claimed reward amount in token base units.
func SetDepositAmount
method on RewardStateSetDepositAmount replaces the GNS principal represented by this reward state.
Parameters:
- amount: staked GNS amount in base units used for reward allocation.
func SetDistributeEndTime
method on RewardStateSetDistributeEndTime sets the Unix timestamp when this deposit stops accruing rewards.
Parameters:
- time: reward accrual end timestamp in Unix seconds.
func SetDistributeStartTime
method on RewardStateSetDistributeStartTime sets the Unix timestamp when this deposit starts accruing rewards.
Parameters:
- time: reward accrual start timestamp in Unix seconds.
func SetPriceDebtX128
method on RewardStateSetPriceDebtX128 replaces the deposit's initial reward index debt.
Parameters:
- debt: new price debt in Q128 fixed-point units; the value is copied into the state.
type StoreKey
ident11
- errors stdlib
- gno.land/p/gnoswap/store/v1 package
- gno.land/p/gnoswap/uint256/v1 package
- gno.land/p/gnoswap/version_manager/v1 package
- gno.land/p/nt/bptree/rotree/v0 package
- gno.land/p/nt/bptree/v0 package
- gno.land/p/nt/ufmt/v0 package
- gno.land/r/gnoswap/access/v1 realm
- gno.land/r/gnoswap/rbac/v1 realm
- strconv stdlib
- strings stdlib