PathrockNetwork Gno Explorer
HomeBlocksTransactionsRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/r/gnoswap/launchpad/v1

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
v1
Namespace
gnoswap / launchpad
Files
23 (README)(gnomod.toml)
Exported functions
1
Module
gno.land/r/gnoswap/launchpad/v1
gno
0.9

Files (23)

  • README.mdmarkdown
  • gnomod.tomltoml
  • assert.gnogno
  • consts.gnogno
  • deposit.gnogno
  • emits.gnogno
  • errors.gnogno
  • getter_utils.gnogno
  • getter.gnogno
  • init.gnogno
  • instance.gnogno
  • launchpad_deposit.gnogno
  • launchpad_project.gnogno
  • launchpad_protocol_fee.gnogno
  • launchpad_reward.gnogno
  • launchpad_withdraw.gnogno
  • project_tier.gnogno
  • project.gnogno
  • render.gnogno
  • reward_manager.gnogno
  • reward_state.gnogno
  • state.gnogno
  • utils.gnogno
  • getter.gnogno
    1package launchpad23import (4	"errors"5	"time"67	rotree "gno.land/p/nt/bptree/rotree/v0"8

    Functions

    • NewLaunchpadV1(launchpadStore interface {GetDepositCounter func() *gno.land/r/gnoswap/launchpad.Counter; GetDeposits func() *gno.land/p/nt/bptree/v0.BPTree; GetProjectRecipients func() *gno.land/p/nt/bptree/v0.BPTree; GetProjectTierRewardManagers func() *gno.land/p/nt/bptree/v0.BPTree; GetProjects func() *gno.land/p/nt/bptree/v0.BPTree; GetTotalGNSStakedAmount func() int64; HasDepositCounterStoreKey func() bool; HasDepositsKey func() bool; HasProjectRecipientsKey func() bool; HasProjectTierRewardManagersKey func() bool; HasProjectsKey func() bool; HasTotalGNSStakedAmountKey func() bool; NextDepositID func() string; SetDepositCounter func(int, .uverse.realm, *gno.land/r/gnoswap/launchpad.Counter) .uverse.error; SetDeposits func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProjectRecipients func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProjectTierRewardManagers func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProjects func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetTotalGNSStakedAmount func(int, .uverse.realm, int64) .uverse.error}) interface {CollectDepositGns func(int, .uverse.realm, string) (int64, .uverse.error); CollectEmissionReward func(int, .uverse.realm); CollectProtocolFee func(int, .uverse.realm); CollectProtocolFeeReward func(int, .uverse.realm, string); CollectRewardByDepositId func(int, .uverse.realm, string) int64; CreateProject func(int, .uverse.realm, string, string, .uverse.address, int64, string, string, int64, int64, int64, int64) string; DepositGns func(int, .uverse.realm, string, int64, string) string; GetCurrentDepositId func() int64; GetDeposit func(string) (gno.land/r/gnoswap/launchpad.Deposit, .uverse.error); GetDepositAmount func(string) (int64, .uverse.error); GetDepositCount func() int; GetDepositCreatedAt func(string) (int64, .uverse.error); GetDepositCreatedHeight func(string) (int64, .uverse.error); GetDepositEndTime func(string) (int64, .uverse.error); GetDepositProjectID func(string) (string, .uverse.error); GetDepositProjectTierID func(string) (string, .uverse.error); GetDepositTier func(string) (int64, .uverse.error); GetDepositWithdrawnHeight func(string) (int64, .uverse.error); GetDepositWithdrawnTime func(string) (int64, .uverse.error); GetProjectActiveStatus func(string) (bool, .uverse.error); GetProjectCondition func(string, string) (*gno.land/r/gnoswap/launchpad.ProjectCondition, .uverse.error); GetProjectCreatedAt func(string) (int64, .uverse.error); GetProjectCreatedHeight func(string) (int64, .uverse.error); GetProjectDepositAmount func(string) (int64, .uverse.error); GetProjectName func(string) (string, .uverse.error); GetProjectRecipient func(string) (.uverse.address, .uverse.error); GetProjectTier func(string, int64) (*gno.land/r/gnoswap/launchpad.ProjectTier, .uverse.error); GetProjectTierDistributeAmountPerSecondX128 func(string, int64) (*gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); GetProjectTierEndTime func(string, int64) (int64, .uverse.error); GetProjectTierRewardAccumulatedDistributeAmount func(string) (int64, .uverse.error); GetProjectTierRewardAccumulatedRewardPerDepositX128 func(string) (*gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); GetProjectTierRewardAccumulatedTime func(string) (int64, .uverse.error); GetProjectTierRewardClaimableDuration func(string) (int64, .uverse.error); GetProjectTierRewardDistributeAmountPerSecondX128 func(string) (*gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); GetProjectTierRewardDistributeEndTime func(string) (int64, .uverse.error); GetProjectTierRewardDistributeStartTime func(string) (int64, .uverse.error); GetProjectTierRewardManager func(string) (*gno.land/r/gnoswap/launchpad.RewardManager, .uverse.error); GetProjectTierRewardManagerCount func() int; GetProjectTierRewardTotalClaimedAmount func(string) (int64, .uverse.error); GetProjectTierRewardTotalDistributeAmount func(string) (int64, .uverse.error); GetProjectTierRewards func(string, int64) *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree; GetProjectTierStartTime func(string, int64) (int64, .uverse.error); GetProjectTierTotalCollectedAmount func(string, int64) (int64, .uverse.error); GetProjectTierTotalDepositAmount func(string, int64) (int64, .uverse.error); GetProjectTierTotalDepositCount func(string, int64) (int64, .uverse.error); GetProjectTierTotalDistributeAmount func(string, int64) (int64, .uverse.error); GetProjectTierTotalWithdrawAmount func(string, int64) (int64, .uverse.error); GetProjectTierTotalWithdrawCount func(string, int64) (int64, .uverse.error); GetProjectTiersRatios func(string) (map[int64]int64, .uverse.error); GetProjectTokenPath func(string) (string, .uverse.error); GetProjects func() *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree; GetRewardState func(string, string) (*gno.land/r/gnoswap/launchpad.RewardState, .uverse.error); GetTotalGNSStakedAmount func() int64; Render func(string) string; TransferLeftFromProjectByAdmin func(int, .uverse.realm, string, .uverse.address) int64}

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.

    Rendered

    RenderedRawgnoweb ↗
    This realm does not provide renderable output (vm/qrender → NoRenderDeclError). View on gnoweb ↗

    vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.

    ufmt "gno.land/p/nt/ufmt/v0"
    9
    10 "gno.land/p/gnoswap/uint256/v1"
    11 "gno.land/r/gnoswap/launchpad"
    12)
    13
    14// GetProjects returns a read-only view of every project, keyed by project ID.
    15//
    16// Returns:
    17// - projects: read-only tree keyed by project ID; project entries are cloned before being exposed.
    18func (lp *launchpadV1) GetProjects() *rotree.ReadOnlyTree {
    19 return rotree.Wrap(lp.store.GetProjects(), cloneProjectEntry)
    20}
    21
    22// GetProjectName returns the name of a project by its ID.
    23// Returns empty string and error if project not found.
    24//
    25// Parameters:
    26// - projectId: unique launchpad project identifier to look up.
    27//
    28// Returns:
    29// - name: configured project name; empty when the project is absent.
    30// - err: nil when found; non-nil when projectId is not present in state.
    31func (lp *launchpadV1) GetProjectName(projectId string) (string, error) {
    32 project, err := lp.getProject(projectId)
    33 if err != nil {
    34 return "", err
    35 }
    36
    37 return project.Name(), nil
    38}
    39
    40// GetProjectTokenPath returns the token path of a project by its ID.
    41// Returns empty string and error if project not found.
    42//
    43// Parameters:
    44// - projectId: unique launchpad project identifier to look up.
    45//
    46// Returns:
    47// - tokenPath: reward-token contract path configured for the project; empty when absent.
    48// - err: nil when found; non-nil when projectId is not present in state.
    49func (lp *launchpadV1) GetProjectTokenPath(projectId string) (string, error) {
    50 project, err := lp.getProject(projectId)
    51 if err != nil {
    52 return "", err
    53 }
    54
    55 return project.TokenPath(), nil
    56}
    57
    58// GetProjectDepositAmount returns the deposit amount of a project by its ID.
    59// Returns 0 and error if project not found.
    60//
    61// Parameters:
    62// - projectId: unique launchpad project identifier to look up.
    63//
    64// Returns:
    65// - amount: project-level token amount deposited for distribution; zero when absent.
    66// - err: nil when found; non-nil when projectId is not present in state.
    67func (lp *launchpadV1) GetProjectDepositAmount(projectId string) (int64, error) {
    68 project, err := lp.getProject(projectId)
    69 if err != nil {
    70 return 0, err
    71 }
    72
    73 return project.DepositAmount(), nil
    74}
    75
    76// GetProjectRecipient returns the recipient address of a project by its ID.
    77// Returns empty address and error if project not found.
    78//
    79// Parameters:
    80// - projectId: unique launchpad project identifier to look up.
    81//
    82// Returns:
    83// - recipient: address configured to receive the project's tokens; empty address when absent.
    84// - err: nil when found; non-nil when projectId is not present in state.
    85func (lp *launchpadV1) GetProjectRecipient(projectId string) (address, error) {
    86 project, err := lp.getProject(projectId)
    87 if err != nil {
    88 return address(""), err
    89 }
    90
    91 return project.Recipient(), nil
    92}
    93
    94// GetProjectCondition retrieves a specific condition of a project.
    95// Returns nil and error if project or condition not found.
    96//
    97// Parameters:
    98// - projectId: unique launchpad project identifier to look up.
    99// - tokenPath: condition-token contract path used as the project's condition key.
    100//
    101// Returns:
    102// - condition: matching project condition; nil when the project or condition is absent.
    103// - err: nil when found; non-nil when projectId or tokenPath is not present.
    104func (lp *launchpadV1) GetProjectCondition(projectId string, tokenPath string) (*launchpad.ProjectCondition, error) {
    105 project, err := lp.getProject(projectId)
    106 if err != nil {
    107 return nil, err
    108 }
    109
    110 conditions := project.Conditions()
    111 condition, exists := conditions[tokenPath]
    112 if !exists {
    113 return nil, makeErrorWithDetails(errDataNotFound, ufmt.Sprintf("condition(%s) not found", tokenPath))
    114 }
    115
    116 return condition, nil
    117}
    118
    119// GetProjectTiersRatios returns the tiers ratios map of a project by its ID.
    120// Returns nil and error if project not found.
    121//
    122// Parameters:
    123// - projectId: unique launchpad project identifier to look up.
    124//
    125// Returns:
    126// - ratios: map from tier duration (30, 90, or 180) to its allocation percentage; nil when the project is absent.
    127// - err: nil when found; non-nil when projectId is not present in state.
    128func (lp *launchpadV1) GetProjectTiersRatios(projectId string) (map[int64]int64, error) {
    129 project, err := lp.getProject(projectId)
    130 if err != nil {
    131 return nil, err
    132 }
    133
    134 return project.TiersRatios(), nil
    135}
    136
    137// GetProjectCreatedHeight returns the created height of a project by its ID.
    138// Returns 0 and error if project not found.
    139//
    140// Parameters:
    141// - projectId: unique launchpad project identifier to look up.
    142//
    143// Returns:
    144// - height: project creation block height; zero when the project is absent.
    145// - err: nil when found; non-nil when projectId is not present in state.
    146func (lp *launchpadV1) GetProjectCreatedHeight(projectId string) (int64, error) {
    147 project, err := lp.getProject(projectId)
    148 if err != nil {
    149 return 0, err
    150 }
    151
    152 return project.CreatedHeight(), nil
    153}
    154
    155// GetProjectCreatedAt returns the created time of a project by its ID.
    156// Returns 0 and error if project not found.
    157//
    158// Parameters:
    159// - projectId: unique launchpad project identifier to look up.
    160//
    161// Returns:
    162// - createdAt: project creation timestamp in Unix seconds; zero when the project is absent.
    163// - err: nil when found; non-nil when projectId is not present in state.
    164func (lp *launchpadV1) GetProjectCreatedAt(projectId string) (int64, error) {
    165 project, err := lp.getProject(projectId)
    166 if err != nil {
    167 return 0, err
    168 }
    169
    170 return project.CreatedAt(), nil
    171}
    172
    173// GetProjectTier retrieves a specific tier of a project.
    174// Returns nil and error if project or tier not found.
    175//
    176// Parameters:
    177// - projectId: unique launchpad project identifier to look up.
    178// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    179//
    180// Returns:
    181// - projectTier: matching project tier; nil when the project or tier is absent.
    182// - err: nil when found; non-nil when projectId or tier is not present.
    183func (lp *launchpadV1) GetProjectTier(projectId string, tier int64) (*launchpad.ProjectTier, error) {
    184 project, err := lp.getProject(projectId)
    185 if err != nil {
    186 return nil, err
    187 }
    188
    189 projectTier, err := getProjectTier(project, tier)
    190 if err != nil {
    191 return nil, err
    192 }
    193
    194 return projectTier, nil
    195}
    196
    197// GetProjectTierDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of a project tier.
    198// Returns nil and error if project or tier not found.
    199//
    200// Parameters:
    201// - projectId: unique launchpad project identifier to look up.
    202// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    203//
    204// Returns:
    205// - amountPerSecondX128: per-second distribution rate encoded as a Q128 fixed-point value; nil when lookup fails.
    206// - err: nil when found; non-nil when projectId or tier is not present.
    207func (lp *launchpadV1) GetProjectTierDistributeAmountPerSecondX128(projectId string, tier int64) (*uint256.Uint, error) {
    208 projectTier, err := lp.GetProjectTier(projectId, tier)
    209 if err != nil {
    210 return nil, err
    211 }
    212
    213 return projectTier.DistributeAmountPerSecondX128(), nil
    214}
    215
    216// GetProjectTierTotalDistributeAmount returns the total distribute amount of a project tier.
    217// Returns 0 and error if project or tier not found.
    218//
    219// Parameters:
    220// - projectId: unique launchpad project identifier to look up.
    221// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    222//
    223// Returns:
    224// - amount: total token amount allocated for distribution by the tier; zero when lookup fails.
    225// - err: nil when found; non-nil when projectId or tier is not present.
    226func (lp *launchpadV1) GetProjectTierTotalDistributeAmount(projectId string, tier int64) (int64, error) {
    227 projectTier, err := lp.GetProjectTier(projectId, tier)
    228 if err != nil {
    229 return 0, err
    230 }
    231
    232 return projectTier.TotalDistributeAmount(), nil
    233}
    234
    235// GetProjectTierTotalDepositAmount returns the total deposit amount of a project tier.
    236// Returns 0 and error if project or tier not found.
    237//
    238// Parameters:
    239// - projectId: unique launchpad project identifier to look up.
    240// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    241//
    242// Returns:
    243// - amount: aggregate token amount deposited into the tier; zero when lookup fails.
    244// - err: nil when found; non-nil when projectId or tier is not present.
    245func (lp *launchpadV1) GetProjectTierTotalDepositAmount(projectId string, tier int64) (int64, error) {
    246 projectTier, err := lp.GetProjectTier(projectId, tier)
    247 if err != nil {
    248 return 0, err
    249 }
    250
    251 return projectTier.TotalDepositAmount(), nil
    252}
    253
    254// GetProjectTierTotalWithdrawAmount returns the total withdraw amount of a project tier.
    255// Returns 0 and error if project or tier not found.
    256//
    257// Parameters:
    258// - projectId: unique launchpad project identifier to look up.
    259// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    260//
    261// Returns:
    262// - amount: aggregate token amount withdrawn from the tier; zero when lookup fails.
    263// - err: nil when found; non-nil when projectId or tier is not present.
    264func (lp *launchpadV1) GetProjectTierTotalWithdrawAmount(projectId string, tier int64) (int64, error) {
    265 projectTier, err := lp.GetProjectTier(projectId, tier)
    266 if err != nil {
    267 return 0, err
    268 }
    269
    270 return projectTier.TotalWithdrawAmount(), nil
    271}
    272
    273// GetProjectTierTotalDepositCount returns the total deposit count of a project tier.
    274// Returns 0 and error if project or tier not found.
    275//
    276// Parameters:
    277// - projectId: unique launchpad project identifier to look up.
    278// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    279//
    280// Returns:
    281// - count: number of deposits recorded for the tier; zero when lookup fails.
    282// - err: nil when found; non-nil when projectId or tier is not present.
    283func (lp *launchpadV1) GetProjectTierTotalDepositCount(projectId string, tier int64) (int64, error) {
    284 projectTier, err := lp.GetProjectTier(projectId, tier)
    285 if err != nil {
    286 return 0, err
    287 }
    288
    289 return projectTier.TotalDepositCount(), nil
    290}
    291
    292// GetProjectTierTotalWithdrawCount returns the total withdraw count of a project tier.
    293// Returns 0 and error if project or tier not found.
    294//
    295// Parameters:
    296// - projectId: unique launchpad project identifier to look up.
    297// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    298//
    299// Returns:
    300// - count: number of withdrawals recorded for the tier; zero when lookup fails.
    301// - err: nil when found; non-nil when projectId or tier is not present.
    302func (lp *launchpadV1) GetProjectTierTotalWithdrawCount(projectId string, tier int64) (int64, error) {
    303 projectTier, err := lp.GetProjectTier(projectId, tier)
    304 if err != nil {
    305 return 0, err
    306 }
    307
    308 return projectTier.TotalWithdrawCount(), nil
    309}
    310
    311// GetProjectTierTotalCollectedAmount returns the total collected amount of a project tier.
    312// Returns 0 and error if project or tier not found.
    313//
    314// Parameters:
    315// - projectId: unique launchpad project identifier to look up.
    316// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    317//
    318// Returns:
    319// - amount: aggregate reward amount collected from the tier; zero when lookup fails.
    320// - err: nil when found; non-nil when projectId or tier is not present.
    321func (lp *launchpadV1) GetProjectTierTotalCollectedAmount(projectId string, tier int64) (int64, error) {
    322 projectTier, err := lp.GetProjectTier(projectId, tier)
    323 if err != nil {
    324 return 0, err
    325 }
    326
    327 return projectTier.TotalCollectedAmount(), nil
    328}
    329
    330// GetProjectTierStartTime returns the start time of a project tier.
    331// Returns 0 and error if project or tier not found.
    332//
    333// Parameters:
    334// - projectId: unique launchpad project identifier to look up.
    335// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    336//
    337// Returns:
    338// - startTime: tier start timestamp in Unix seconds; zero when lookup fails.
    339// - err: nil when found; non-nil when projectId or tier is not present.
    340func (lp *launchpadV1) GetProjectTierStartTime(projectId string, tier int64) (int64, error) {
    341 projectTier, err := lp.GetProjectTier(projectId, tier)
    342 if err != nil {
    343 return 0, err
    344 }
    345
    346 return projectTier.StartTime(), nil
    347}
    348
    349// GetProjectTierEndTime returns the end time of a project tier.
    350// Returns 0 and error if project or tier not found.
    351//
    352// Parameters:
    353// - projectId: unique launchpad project identifier to look up.
    354// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    355//
    356// Returns:
    357// - endTime: tier end timestamp in Unix seconds; zero when lookup fails.
    358// - err: nil when found; non-nil when projectId or tier is not present.
    359func (lp *launchpadV1) GetProjectTierEndTime(projectId string, tier int64) (int64, error) {
    360 projectTier, err := lp.GetProjectTier(projectId, tier)
    361 if err != nil {
    362 return 0, err
    363 }
    364
    365 return projectTier.EndTime(), nil
    366}
    367
    368// GetDepositCount returns the total number of deposits.
    369//
    370// Returns:
    371// - count: number of deposit entries currently stored.
    372func (lp *launchpadV1) GetDepositCount() int {
    373 deposits := lp.store.GetDeposits()
    374 return deposits.Size()
    375}
    376
    377// GetCurrentDepositId returns the current deposit counter value.
    378//
    379// Returns:
    380// - depositID: current int64 deposit counter used to generate subsequent deposit identifiers.
    381func (lp *launchpadV1) GetCurrentDepositId() int64 {
    382 counter := lp.store.GetDepositCounter()
    383 return counter.Get()
    384}
    385
    386// GetProjectTierRewards returns a read-only view of a project tier's reward
    387// states, keyed by deposit ID. nil is returned when the project tier does not
    388// exist.
    389//
    390// Parameters:
    391// - projectId: unique launchpad project identifier used to form the tier ID.
    392// - tier: tier duration in days; launchpad tiers use 30, 90, or 180.
    393//
    394// Returns:
    395// - rewards: read-only tree of reward states keyed by deposit ID; nil when the tier's reward manager lookup fails.
    396func (lp *launchpadV1) GetProjectTierRewards(projectId string, tier int64) *rotree.ReadOnlyTree {
    397 projectTierID := launchpad.MakeProjectTierID(projectId, tier)
    398
    399 rewardManager, err := lp.getProjectTierRewardManager(projectTierID)
    400 if err != nil {
    401 return nil
    402 }
    403 return rotree.Wrap(rewardManager.Rewards(), cloneRewardStateEntry)
    404}
    405
    406// GetDeposit retrieves the value payload of a deposit by its ID.
    407//
    408// Parameters:
    409// - depositId: unique deposit identifier to look up.
    410//
    411// Returns:
    412// - deposit: stored deposit value; zero-valued when the entry is missing or has an invalid type.
    413// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    414func (lp *launchpadV1) GetDeposit(depositId string) (launchpad.Deposit, error) {
    415 return lp.getDepositValue(depositId)
    416}
    417
    418// GetDepositProjectID returns the project ID of a deposit by its ID.
    419//
    420// Parameters:
    421// - depositId: unique deposit identifier to look up.
    422//
    423// Returns:
    424// - projectID: project identifier recorded on the deposit; empty when the entry is missing or invalid.
    425// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    426func (lp *launchpadV1) GetDepositProjectID(depositId string) (string, error) {
    427 deposit, err := lp.getDepositValue(depositId)
    428 if err != nil {
    429 return "", err
    430 }
    431 return deposit.ProjectID(), nil
    432}
    433
    434// GetDepositTier returns the tier of a deposit by its ID.
    435//
    436// Parameters:
    437// - depositId: unique deposit identifier to look up.
    438//
    439// Returns:
    440// - tier: tier duration recorded on the deposit; zero when the entry is missing or invalid.
    441// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    442func (lp *launchpadV1) GetDepositTier(depositId string) (int64, error) {
    443 deposit, err := lp.getDepositValue(depositId)
    444 if err != nil {
    445 return 0, err
    446 }
    447 return deposit.Tier(), nil
    448}
    449
    450// GetDepositProjectTierID returns the project tier ID of a deposit by its ID.
    451//
    452// Parameters:
    453// - depositId: unique deposit identifier to look up.
    454//
    455// Returns:
    456// - projectTierID: composite project-tier identifier derived from the deposit; empty when the entry is missing or invalid.
    457// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    458func (lp *launchpadV1) GetDepositProjectTierID(depositId string) (string, error) {
    459 deposit, err := lp.getDepositValue(depositId)
    460 if err != nil {
    461 return "", err
    462 }
    463 return deposit.ProjectTierID(), nil
    464}
    465
    466// GetDepositAmount returns the deposit amount of a deposit by its ID.
    467//
    468// Parameters:
    469// - depositId: unique deposit identifier to look up.
    470//
    471// Returns:
    472// - amount: GNS amount recorded on the deposit; zero when the entry is missing or invalid.
    473// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    474func (lp *launchpadV1) GetDepositAmount(depositId string) (int64, error) {
    475 deposit, err := lp.getDepositValue(depositId)
    476 if err != nil {
    477 return 0, err
    478 }
    479 return deposit.DepositAmount(), nil
    480}
    481
    482// GetDepositWithdrawnHeight returns the withdrawn height of a deposit by its ID.
    483//
    484// Parameters:
    485// - depositId: unique deposit identifier to look up.
    486//
    487// Returns:
    488// - withdrawnHeight: withdrawal block height recorded on the deposit; zero when the entry is missing or invalid.
    489// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    490func (lp *launchpadV1) GetDepositWithdrawnHeight(depositId string) (int64, error) {
    491 deposit, err := lp.getDepositValue(depositId)
    492 if err != nil {
    493 return 0, err
    494 }
    495 return deposit.WithdrawnHeight(), nil
    496}
    497
    498// GetDepositWithdrawnTime returns the withdrawn time of a deposit by its ID.
    499//
    500// Parameters:
    501// - depositId: unique deposit identifier to look up.
    502//
    503// Returns:
    504// - withdrawnTime: withdrawal timestamp in Unix seconds; zero when the entry is missing or invalid.
    505// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    506func (lp *launchpadV1) GetDepositWithdrawnTime(depositId string) (int64, error) {
    507 deposit, err := lp.getDepositValue(depositId)
    508 if err != nil {
    509 return 0, err
    510 }
    511 return deposit.WithdrawnTime(), nil
    512}
    513
    514// GetDepositCreatedHeight returns the created height of a deposit by its ID.
    515//
    516// Parameters:
    517// - depositId: unique deposit identifier to look up.
    518//
    519// Returns:
    520// - createdHeight: creation block height recorded on the deposit; zero when the entry is missing or invalid.
    521// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    522func (lp *launchpadV1) GetDepositCreatedHeight(depositId string) (int64, error) {
    523 deposit, err := lp.getDepositValue(depositId)
    524 if err != nil {
    525 return 0, err
    526 }
    527 return deposit.CreatedHeight(), nil
    528}
    529
    530// GetDepositCreatedAt returns the created time of a deposit by its ID.
    531//
    532// Parameters:
    533// - depositId: unique deposit identifier to look up.
    534//
    535// Returns:
    536// - createdAt: creation timestamp in Unix seconds; zero when the entry is missing or invalid.
    537// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    538func (lp *launchpadV1) GetDepositCreatedAt(depositId string) (int64, error) {
    539 deposit, err := lp.getDepositValue(depositId)
    540 if err != nil {
    541 return 0, err
    542 }
    543 return deposit.CreatedAt(), nil
    544}
    545
    546// GetDepositEndTime returns the end time of a deposit by its ID.
    547//
    548// Parameters:
    549// - depositId: unique deposit identifier to look up.
    550//
    551// Returns:
    552// - endTime: tier end timestamp in Unix seconds; zero when the entry is missing or invalid.
    553// - err: nil for a valid stored deposit; non-nil when the entry is missing or has an invalid type.
    554func (lp *launchpadV1) GetDepositEndTime(depositId string) (int64, error) {
    555 deposit, err := lp.getDepositValue(depositId)
    556 if err != nil {
    557 return 0, err
    558 }
    559 return deposit.EndTime(), nil
    560}
    561
    562// GetTotalGNSStakedAmount returns the total amount of GNS currently staked across all launchpad deposits.
    563//
    564// Returns:
    565// - amount: aggregate GNS amount currently staked across all launchpad deposits.
    566func (lp *launchpadV1) GetTotalGNSStakedAmount() int64 {
    567 return lp.store.GetTotalGNSStakedAmount()
    568}
    569
    570// GetProjectTierRewardManagerCount returns the total number of reward managers.
    571//
    572// Returns:
    573// - count: number of project-tier reward-manager entries currently stored.
    574func (lp *launchpadV1) GetProjectTierRewardManagerCount() int {
    575 managers := lp.store.GetProjectTierRewardManagers()
    576 return managers.Size()
    577}
    578
    579// GetProjectTierRewardManager retrieves a reward manager by project tier ID.
    580// Returns nil and error if reward manager not found.
    581//
    582// Parameters:
    583// - projectTierId: composite project-tier identifier whose reward manager is requested.
    584//
    585// Returns:
    586// - manager: matching reward manager; nil when no entry exists or its value has an invalid type.
    587// - err: nil for a valid manager; non-nil when the entry is absent or has an invalid type.
    588func (lp *launchpadV1) GetProjectTierRewardManager(projectTierId string) (*launchpad.RewardManager, error) {
    589 managers := lp.store.GetProjectTierRewardManagers()
    590 value := managers.Get(projectTierId)
    591 if value == nil {
    592 return nil, makeErrorWithDetails(errDataNotFound, "reward manager not found")
    593 }
    594
    595 manager, ok := value.(*launchpad.RewardManager)
    596 if !ok {
    597 return nil, errors.New("invalid reward manager type")
    598 }
    599
    600 return manager, nil
    601}
    602
    603// GetProjectTierRewardDistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of a reward manager.
    604// Returns nil and error if reward manager not found.
    605//
    606// Parameters:
    607// - projectTierId: composite project-tier identifier whose reward manager is requested.
    608//
    609// Returns:
    610// - amountPerSecondX128: per-second distribution rate encoded as a Q128 fixed-point value; nil when lookup fails.
    611// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    612func (lp *launchpadV1) GetProjectTierRewardDistributeAmountPerSecondX128(projectTierId string) (*uint256.Uint, error) {
    613 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    614 if err != nil {
    615 return nil, err
    616 }
    617
    618 return manager.DistributeAmountPerSecondX128(), nil
    619}
    620
    621// GetProjectTierRewardAccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of a reward manager.
    622// Returns nil and error if reward manager not found.
    623//
    624// Parameters:
    625// - projectTierId: composite project-tier identifier whose reward manager is requested.
    626//
    627// Returns:
    628// - accumulatedRewardPerDepositX128: accumulated reward index per deposited GNS, encoded as Q128; nil when lookup fails.
    629// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    630func (lp *launchpadV1) GetProjectTierRewardAccumulatedRewardPerDepositX128(projectTierId string) (*uint256.Uint, error) {
    631 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    632 if err != nil {
    633 return nil, err
    634 }
    635
    636 return manager.AccumulatedRewardPerDepositX128(), nil
    637}
    638
    639// GetProjectTierRewardTotalDistributeAmount returns the total distribute amount of a reward manager.
    640// Returns 0 and error if reward manager not found.
    641//
    642// Parameters:
    643// - projectTierId: composite project-tier identifier whose reward manager is requested.
    644//
    645// Returns:
    646// - amount: total token amount allocated to the reward manager; zero when lookup fails.
    647// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    648func (lp *launchpadV1) GetProjectTierRewardTotalDistributeAmount(projectTierId string) (int64, error) {
    649 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    650 if err != nil {
    651 return 0, err
    652 }
    653
    654 return manager.TotalDistributeAmount(), nil
    655}
    656
    657// GetProjectTierRewardTotalClaimedAmount returns the total claimed amount of a reward manager.
    658// Returns 0 and error if reward manager not found.
    659//
    660// Parameters:
    661// - projectTierId: composite project-tier identifier whose reward manager is requested.
    662//
    663// Returns:
    664// - amount: total token amount already claimed from the reward manager; zero when lookup fails.
    665// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    666func (lp *launchpadV1) GetProjectTierRewardTotalClaimedAmount(projectTierId string) (int64, error) {
    667 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    668 if err != nil {
    669 return 0, err
    670 }
    671
    672 return manager.TotalClaimedAmount(), nil
    673}
    674
    675// GetProjectTierRewardDistributeStartTime returns the distribute start time of a reward manager.
    676// Returns 0 and error if reward manager not found.
    677//
    678// Parameters:
    679// - projectTierId: composite project-tier identifier whose reward manager is requested.
    680//
    681// Returns:
    682// - startTime: reward distribution start timestamp in Unix seconds; zero when lookup fails.
    683// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    684func (lp *launchpadV1) GetProjectTierRewardDistributeStartTime(projectTierId string) (int64, error) {
    685 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    686 if err != nil {
    687 return 0, err
    688 }
    689
    690 return manager.DistributeStartTime(), nil
    691}
    692
    693// GetProjectTierRewardDistributeEndTime returns the distribute end time of a reward manager.
    694// Returns 0 and error if reward manager not found.
    695//
    696// Parameters:
    697// - projectTierId: composite project-tier identifier whose reward manager is requested.
    698//
    699// Returns:
    700// - endTime: reward distribution end timestamp in Unix seconds; zero when lookup fails.
    701// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    702func (lp *launchpadV1) GetProjectTierRewardDistributeEndTime(projectTierId string) (int64, error) {
    703 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    704 if err != nil {
    705 return 0, err
    706 }
    707
    708 return manager.DistributeEndTime(), nil
    709}
    710
    711// GetProjectTierRewardAccumulatedDistributeAmount returns a legacy reward-manager field.
    712// The v1 reward paths do not maintain it, so normal reads return zero unless it
    713// was explicitly set.
    714//
    715// Parameters:
    716// - projectTierId: composite project-tier identifier whose reward manager is requested.
    717//
    718// Returns:
    719// - amount: legacy accumulated-distribution amount, normally zero in v1 unless explicitly set.
    720// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    721func (lp *launchpadV1) GetProjectTierRewardAccumulatedDistributeAmount(projectTierId string) (int64, error) {
    722 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    723 if err != nil {
    724 return 0, err
    725 }
    726
    727 return manager.AccumulatedDistributeAmount(), nil
    728}
    729
    730// GetProjectTierRewardAccumulatedTime returns the accumulated time of a reward manager.
    731// Returns 0 and error if reward manager not found.
    732//
    733// Parameters:
    734// - projectTierId: composite project-tier identifier whose reward manager is requested.
    735//
    736// Returns:
    737// - accumulatedTime: timestamp in Unix seconds at which reward accumulation was last updated; zero before an update.
    738// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    739func (lp *launchpadV1) GetProjectTierRewardAccumulatedTime(projectTierId string) (int64, error) {
    740 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    741 if err != nil {
    742 return 0, err
    743 }
    744
    745 return manager.AccumulatedTime(), nil
    746}
    747
    748// GetProjectTierRewardClaimableDuration returns the reward claimable duration of a reward manager.
    749// Returns 0 and error if reward manager not found.
    750//
    751// Parameters:
    752// - projectTierId: composite project-tier identifier whose reward manager is requested.
    753//
    754// Returns:
    755// - duration: configured period during which rewards remain claimable, in the manager's timestamp units; zero when lookup fails.
    756// - err: nil when found; non-nil when the reward manager is absent or has an invalid type.
    757func (lp *launchpadV1) GetProjectTierRewardClaimableDuration(projectTierId string) (int64, error) {
    758 manager, err := lp.GetProjectTierRewardManager(projectTierId)
    759 if err != nil {
    760 return 0, err
    761 }
    762
    763 return manager.RewardClaimableDuration(), nil
    764}
    765
    766// GetRewardState retrieves a reward state by project tier ID and deposit ID.
    767// Returns nil and error if reward manager or reward state not found.
    768//
    769// Parameters:
    770// - projectTierId: composite project-tier identifier whose reward manager contains the state.
    771// - depositId: unique deposit identifier whose reward state is requested.
    772//
    773// Returns:
    774// - rewardState: matching reward state; nil when the manager or state is absent or has an invalid type.
    775// - err: nil when found; non-nil when the manager or state is absent or has an invalid type.
    776func (lp *launchpadV1) GetRewardState(projectTierId string, depositId string) (*launchpad.RewardState, error) {
    777 managers := lp.store.GetProjectTierRewardManagers()
    778 value := managers.Get(projectTierId)
    779 if value == nil {
    780 return nil, makeErrorWithDetails(errDataNotFound, "reward manager not found")
    781 }
    782
    783 manager, ok := value.(*launchpad.RewardManager)
    784 if !ok {
    785 return nil, errors.New("invalid reward manager type")
    786 }
    787
    788 rewards := manager.Rewards()
    789 rewardValue := rewards.Get(depositId)
    790 if rewardValue == nil {
    791 return nil, makeErrorWithDetails(errDataNotFound, "reward state not found")
    792 }
    793
    794 rewardState, ok := rewardValue.(*launchpad.RewardState)
    795 if !ok {
    796 return nil, errors.New("invalid reward state type")
    797 }
    798
    799 return rewardState, nil
    800}
    801
    802// GetProjectActiveStatus returns whether a project is currently active.
    803// Returns false and error if project not found.
    804//
    805// Parameters:
    806// - projectId: unique launchpad project identifier to look up.
    807//
    808// Returns:
    809// - active: true when the project's standard 180-day tier is active at the current Unix time; false when inactive.
    810// - err: nil when found; non-nil when projectId is not present in state.
    811func (lp *launchpadV1) GetProjectActiveStatus(projectId string) (bool, error) {
    812 project, err := lp.getProject(projectId)
    813 if err != nil {
    814 return false, err
    815 }
    816
    817 currentTime := time.Now().Unix()
    818 return isProjectActive(project, currentTime), nil
    819}
    820