Transaction

769EDB2BCC27B1…C983C6D7B672

Block 77,262 · index 0 · indexed

Summary

Hash
769EDB2BCC27B1E208E84236FF3ED0991A1C517D57C096D44FFEC983C6D7B672
Block
77,262
Size
132500 bytes
Gas used
168,131,415 / 201,757,638
Fee
201758 ugnot
Status
success

Messages

#1AddPackagegno.land/r/gnoswap/launchpad24 arguments

Arguments · 24

  1. #1launchpad
  2. #2README.md
  3. #3# 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 - `DepositGns` pulls GNS from the caller into the launchpad realm, so approve the launchpad realm for at least the deposit amount before calling. - `CollectRewardByDepositId` and `CollectDepositGns` pay out to the caller and require no approval. ```go // Approve the launchpad realm before depositing launchpadAddress := access.MustGetAddress(prabc.ROLE_LAUNCHPAD.String()) gns.Approve(cross(cur), launchpadAddress, 10_000_000) ``` ## Usage ```go // Create a project (admin or governance; start must be at least 3 days away) projectID := CreateProject( cross(cur), "Example Project", "gno.land/r/demo/projecttoken", recipientAddr, 1_000_000_000, "", // no condition tokens "", // no condition amounts 10, // 30-day tier ratio 20, // 90-day tier ratio 70, // 180-day tier ratio futureStartTimestamp, ) // Deposit GNS into a 30-day tier; referrer is optional depositID := DepositGns(cross(cur), projectID+":30", 10_000_000, "") // Claim after the one-day delay CollectRewardByDepositId(cross(cur), depositID) // After the tier has ended, settle reward and withdraw principal CollectDepositGns(cross(cur), depositID) // Admin refund of the remaining project-token balance TransferLeftFromProjectByAdmin(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
  4. #4counter.gno
  5. #5package launchpad // Counter manages unique incrementing IDs. type Counter struct { id int64 } // NewCounter creates a new Counter starting at zero. // // Returns: // - counter: counter initialized with current ID zero. func NewCounter() *Counter { return &Counter{ id: 0, } } // Next increments the counter and returns the next unique ID. // // Returns: // - id: incremented counter value. func (c *Counter) Next() int64 { c.id++ return c.id } // Get returns the current counter ID without incrementing it. // // Returns: // - id: current counter value. func (c *Counter) Get() int64 { return c.id }
  6. #6deposit.gno
  7. #7package launchpad // Deposit 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. type Deposit struct { depositor address id string projectID string tier int64 // 30, 90, 180 // instead of tierId depositAmount int64 withdrawnHeight int64 withdrawnTime int64 createdHeight int64 createdAt int64 endTime int64 } // ID returns the unique identifier stored for the deposit. // // Returns: // - id: deposit identifier used to retrieve this deposit from launchpad state. func (d Deposit) ID() string { return d.id } // SetID updates the unique identifier stored for the deposit. // // Parameters: // - id: new identifier to associate with the deposit. func (d *Deposit) SetID(id string) { d.id = id } // ProjectID returns the identifier of the launchpad project associated with the deposit. // // Returns: // - projectID: associated launchpad project identifier. func (d Deposit) ProjectID() string { return d.projectID } // SetProjectID updates the launchpad project identifier associated with the deposit. // // Parameters: // - projectID: identifier of the launchpad project to associate with the deposit. func (d *Deposit) SetProjectID(projectID string) { d.projectID = projectID } // Tier returns the deposit's tier duration. // // Returns: // - tier: tier duration in days; launchpad tiers use 30, 90, or 180. func (d Deposit) Tier() int64 { return d.tier } // SetTier updates the tier duration recorded for the deposit. // // Parameters: // - tier: tier duration in days; valid launchpad tiers are 30, 90, or 180. func (d *Deposit) SetTier(tier int64) { d.tier = tier } // Depositor returns the address that made the deposit. // // Returns: // - depositor: account address recorded as the deposit owner. func (d Deposit) Depositor() address { return d.depositor } // SetDepositor updates the account address recorded as the deposit owner. // // Parameters: // - depositor: account address to record as the deposit owner. func (d *Deposit) SetDepositor(depositor address) { d.depositor = depositor } // DepositAmount returns the amount recorded for the deposit. // // Returns: // - depositAmount: amount of GNS deposited for the associated project. func (d Deposit) DepositAmount() int64 { return d.depositAmount } // SetDepositAmount updates the amount recorded for the deposit. // // Parameters: // - depositAmount: amount of GNS to record as deposited for the associated project. func (d *Deposit) SetDepositAmount(depositAmount int64) { d.depositAmount = depositAmount } // CreatedHeight returns the block height at which the deposit was created. // // Returns: // - createdHeight: creation block height stored on the deposit. func (d Deposit) CreatedHeight() int64 { return d.createdHeight } // SetCreatedHeight updates the block height recorded for deposit creation. // // Parameters: // - createdHeight: block height at which the deposit was created. func (d *Deposit) SetCreatedHeight(createdHeight int64) { d.createdHeight = createdHeight } // CreatedAt returns the Unix timestamp at which the deposit was created. // // Returns: // - createdAt: creation timestamp in Unix seconds. func (d Deposit) CreatedAt() int64 { return d.createdAt } // SetCreatedAt updates the Unix timestamp recorded for deposit creation. // // Parameters: // - createdAt: creation timestamp in Unix seconds. func (d *Deposit) SetCreatedAt(createdAt int64) { d.createdAt = createdAt } // WithdrawnTime returns the Unix timestamp recorded for withdrawal. // // Returns: // - withdrawnTime: withdrawal timestamp in Unix seconds; zero before withdrawal is recorded. func (d Deposit) WithdrawnTime() int64 { return d.withdrawnTime } // SetWithdrawnTime updates the Unix timestamp recorded for withdrawal. // // Parameters: // - withdrawnTime: withdrawal timestamp in Unix seconds. func (d *Deposit) SetWithdrawnTime(withdrawnTime int64) { d.withdrawnTime = withdrawnTime } // WithdrawnHeight returns the block height recorded for withdrawal. // // Returns: // - withdrawnHeight: withdrawal block height; zero before withdrawal is recorded. func (d Deposit) WithdrawnHeight() int64 { return d.withdrawnHeight } // SetWithdrawnHeight updates the block height recorded for withdrawal. // // Parameters: // - withdrawnHeight: block height at which the deposit was withdrawn. func (d *Deposit) SetWithdrawnHeight(withdrawnHeight int64) { d.withdrawnHeight = withdrawnHeight } // EndTime returns the Unix timestamp at which the deposit's tier ends. // // Returns: // - endTime: tier end timestamp in Unix seconds. func (d Deposit) EndTime() int64 { return d.endTime } // SetEndTime updates the Unix timestamp at which the deposit's tier ends. // // Parameters: // - endTime: tier end timestamp in Unix seconds. func (d *Deposit) SetEndTime(endTime int64) { d.endTime = endTime } // ProjectTierID returns the composite identifier for the deposit's project tier. // // Returns: // - projectTierID: identifier formed from the project ID and tier duration. func (d Deposit) ProjectTierID() string { return MakeProjectTierID(d.projectID, d.tier) } // IsDepositor 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 (d Deposit) IsDepositor(address address) bool { return d.depositor.String() == address.String() } // IsEnded 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 (d Deposit) IsEnded(currentTime int64) bool { return d.endTime < currentTime } // IsWithdrawn 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 (d Deposit) IsWithdrawn() bool { return d.withdrawnTime > 0 && d.withdrawnHeight > 0 } // SetWithdrawn 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 (d *Deposit) SetWithdrawn(withdrawnHeight int64, withdrawnTime int64) { d.withdrawnHeight = withdrawnHeight d.withdrawnTime = withdrawnTime } // MakeDeposit 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 MakeDeposit( depositID string, projectID string, tier int64, depositor address, depositAmount int64, createdHeight int64, createdTime int64, endTime int64, ) Deposit { return Deposit{ id: depositID, projectID: projectID, tier: tier, depositor: depositor, depositAmount: depositAmount, withdrawnHeight: 0, createdHeight: createdHeight, createdAt: createdTime, endTime: endTime, } } // DefaultDeposit returns the zero Deposit value. // // Returns: // - deposit: zero-valued Deposit with no identifier, amounts, timestamps, or withdrawal markers. func DefaultDeposit() Deposit { return Deposit{} }
  8. #8doc.gno
  9. #9package launchpad
  10. #10errors.gno
  11. #11package launchpad const ErrSpoofedRealm = "rlm does not match the current crossing frame"
  12. #12getter.gno
  13. #13package launchpad import ( u256 "gno.land/p/gnoswap/uint256/v1" rotree "gno.land/p/nt/bptree/rotree/v0" ) // GetProjects 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 GetProjects() *rotree.ReadOnlyTree { return getImplementation().GetProjects() } // GetProjectName 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 GetProjectName(projectId string) (string, error) { return getImplementation().GetProjectName(projectId) } // GetProjectTokenPath 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 GetProjectTokenPath(projectId string) (string, error) { return getImplementation().GetProjectTokenPath(projectId) } // GetProjectDepositAmount 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 GetProjectDepositAmount(projectId string) (int64, error) { return getImplementation().GetProjectDepositAmount(projectId) } // GetProjectRecipient returns the recipient address of a project by its ID. // // Parameters: // - projectId: unique identifier of the launchpad project to inspect. // // Returns: // - recipient: address configured to receive the project's launchpad proceeds. // - err: non-nil when projectId does not identify a stored project. func GetProjectRecipient(projectId string) (address, error) { return getImplementation().GetProjectRecipient(projectId) } // GetProjectCondition 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 GetProjectCondition(projectId string, tokenPath string) (*ProjectCondition, error) { condition, err := getImplementation().GetProjectCondition(projectId, tokenPath) if err != nil { return nil, err } if condition == nil { return nil, nil } return condition.Clone(), nil } // GetProjectTiersRatios 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 GetProjectTiersRatios(projectId string) (map[int64]int64, error) { tiersRatios, err := getImplementation().GetProjectTiersRatios(projectId) if err != nil { return nil, err } return cloneInt64Map(tiersRatios), nil } // GetProjectCreatedHeight 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 GetProjectCreatedHeight(projectId string) (int64, error) { return getImplementation().GetProjectCreatedHeight(projectId) } // GetProjectCreatedAt 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 GetProjectCreatedAt(projectId string) (int64, error) { return getImplementation().GetProjectCreatedAt(projectId) } // GetProjectTier 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 GetProjectTier(projectId string, tier int64) (*ProjectTier, error) { projectTier, err := getImplementation().GetProjectTier(projectId, tier) if err != nil { return nil, err } if projectTier == nil { return nil, nil } return projectTier.Clone(), nil } // 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 GetProjectTierDistributeAmountPerSecondX128(projectId string, tier int64) (*u256.Uint, error) { amount, err := getImplementation().GetProjectTierDistributeAmountPerSecondX128(projectId, tier) if err != nil { return nil, err } if amount == nil { return nil, nil } return amount.Clone(), nil } // GetProjectTierTotalDistributeAmount 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 GetProjectTierTotalDistributeAmount(projectId string, tier int64) (int64, error) { return getImplementation().GetProjectTierTotalDistributeAmount(projectId, tier) } // GetProjectTierTotalDepositAmount 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 GetProjectTierTotalDepositAmount(projectId string, tier int64) (int64, error) { return getImplementation().GetProjectTierTotalDepositAmount(projectId, tier) } // GetProjectTierTotalWithdrawAmount 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 GetProjectTierTotalWithdrawAmount(projectId string, tier int64) (int64, error) { return getImplementation().GetProjectTierTotalWithdrawAmount(projectId, tier) } // GetProjectTierTotalDepositCount 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 GetProjectTierTotalDepositCount(projectId string, tier int64) (int64, error) { return getImplementation().GetProjectTierTotalDepositCount(projectId, tier) } // GetProjectTierTotalWithdrawCount 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 GetProjectTierTotalWithdrawCount(projectId string, tier int64) (int64, error) { return getImplementation().GetProjectTierTotalWithdrawCount(projectId, tier) } // GetProjectTierTotalCollectedAmount 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 GetProjectTierTotalCollectedAmount(projectId string, tier int64) (int64, error) { return getImplementation().GetProjectTierTotalCollectedAmount(projectId, tier) } // GetProjectTierStartTime 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 GetProjectTierStartTime(projectId string, tier int64) (int64, error) { return getImplementation().GetProjectTierStartTime(projectId, tier) } // GetProjectTierEndTime 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 GetProjectTierEndTime(projectId string, tier int64) (int64, error) { return getImplementation().GetProjectTierEndTime(projectId, tier) } // GetDepositCount returns the total number of deposits. // // Returns: // - count: number of deposit records currently stored. func GetDepositCount() int { return getImplementation().GetDepositCount() } // GetCurrentDepositId returns the current deposit counter value. // // Returns: // - depositId: current deposit counter value; it is not incremented by this read. func GetCurrentDepositId() int64 { return getImplementation().GetCurrentDepositId() } // GetProjectTierRewards 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 GetProjectTierRewards(projectId string, tier int64) *rotree.ReadOnlyTree { return getImplementation().GetProjectTierRewards(projectId, tier) } // GetDeposit 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 GetDeposit(depositId string) (Deposit, error) { return getImplementation().GetDeposit(depositId) } // GetDepositProjectID 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 GetDepositProjectID(depositId string) (string, error) { return getImplementation().GetDepositProjectID(depositId) } // GetDepositTier 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 GetDepositTier(depositId string) (int64, error) { return getImplementation().GetDepositTier(depositId) } // GetDepositProjectTierID 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 GetDepositProjectTierID(depositId string) (string, error) { return getImplementation().GetDepositProjectTierID(depositId) } // GetDepositAmount 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 GetDepositAmount(depositId string) (int64, error) { return getImplementation().GetDepositAmount(depositId) } // GetDepositWithdrawnHeight 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 GetDepositWithdrawnHeight(depositId string) (int64, error) { return getImplementation().GetDepositWithdrawnHeight(depositId) } // GetDepositWithdrawnTime 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 GetDepositWithdrawnTime(depositId string) (int64, error) { return getImplementation().GetDepositWithdrawnTime(depositId) } // GetDepositCreatedHeight 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 GetDepositCreatedHeight(depositId string) (int64, error) { return getImplementation().GetDepositCreatedHeight(depositId) } // GetDepositCreatedAt 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 GetDepositCreatedAt(depositId string) (int64, error) { return getImplementation().GetDepositCreatedAt(depositId) } // GetDepositEndTime 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 GetDepositEndTime(depositId string) (int64, error) { return getImplementation().GetDepositEndTime(depositId) } // GetTotalGNSStakedAmount 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 GetTotalGNSStakedAmount() int64 { return getImplementation().GetTotalGNSStakedAmount() } // GetProjectTierRewardManagerCount returns the total number of reward managers. // // Returns: // - count: number of project-tier reward managers currently stored. func GetProjectTierRewardManagerCount() int { return getImplementation().GetProjectTierRewardManagerCount() } // GetProjectTierRewardManager 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 GetProjectTierRewardManager(projectTierId string) (*RewardManager, error) { rewardManager, err := getImplementation().GetProjectTierRewardManager(projectTierId) if err != nil { return nil, err } if rewardManager == nil { return nil, nil } return rewardManager.Clone(), nil } // 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 GetProjectTierRewardDistributeAmountPerSecondX128(projectTierId string) (*u256.Uint, error) { amount, err := getImplementation().GetProjectTierRewardDistributeAmountPerSecondX128(projectTierId) if err != nil { return nil, err } if amount == nil { return nil, nil } return amount.Clone(), nil } // 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 GetProjectTierRewardAccumulatedRewardPerDepositX128(projectTierId string) (*u256.Uint, error) { amount, err := getImplementation().GetProjectTierRewardAccumulatedRewardPerDepositX128(projectTierId) if err != nil { return nil, err } if amount == nil { return nil, nil } return amount.Clone(), nil } // GetProjectTierRewardTotalDistributeAmount 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 GetProjectTierRewardTotalDistributeAmount(projectTierId string) (int64, error) { return getImplementation().GetProjectTierRewardTotalDistributeAmount(projectTierId) } // GetProjectTierRewardTotalClaimedAmount 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 GetProjectTierRewardTotalClaimedAmount(projectTierId string) (int64, error) { return getImplementation().GetProjectTierRewardTotalClaimedAmount(projectTierId) } // GetProjectTierRewardDistributeStartTime 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 GetProjectTierRewardDistributeStartTime(projectTierId string) (int64, error) { return getImplementation().GetProjectTierRewardDistributeStartTime(projectTierId) } // GetProjectTierRewardDistributeEndTime 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 GetProjectTierRewardDistributeEndTime(projectTierId string) (int64, error) { return getImplementation().GetProjectTierRewardDistributeEndTime(projectTierId) } // GetProjectTierRewardAccumulatedDistributeAmount 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 GetProjectTierRewardAccumulatedDistributeAmount(projectTierId string) (int64, error) { return getImplementation().GetProjectTierRewardAccumulatedDistributeAmount(projectTierId) } // GetProjectTierRewardAccumulatedTime 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 GetProjectTierRewardAccumulatedTime(projectTierId string) (int64, error) { return getImplementation().GetProjectTierRewardAccumulatedTime(projectTierId) } // GetProjectTierRewardClaimableDuration 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 GetProjectTierRewardClaimableDuration(projectTierId string) (int64, error) { return getImplementation().GetProjectTierRewardClaimableDuration(projectTierId) } // GetRewardState 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 GetRewardState(projectTierId string, depositId string) (*RewardState, error) { rewardState, err := getImplementation().GetRewardState(projectTierId, depositId) if err != nil { return nil, err } if rewardState == nil { return nil, nil } return rewardState.Clone(), nil } // GetProjectActiveStatus 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 GetProjectActiveStatus(projectId string) (bool, error) { return getImplementation().GetProjectActiveStatus(projectId) }
  14. #14getter_utils.gno
  15. #15package launchpad func cloneInt64Map(src map[int64]int64) map[int64]int64 { if src == nil { return nil } dst := make(map[int64]int64, len(src)) for key, value := range src { dst[key] = value } return dst }
  16. #16gnomod.toml
  17. #17module = "gno.land/r/gnoswap/launchpad" gno = "0.9"
  18. #18project.gno
  19. #19package launchpad import ( ufmt "gno.land/p/nt/ufmt/v0" ) // 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. type Project struct { id string // 'tokenPath:createdHeight' name string tokenPath string depositAmount int64 recipient address // string conditions map[string]*ProjectCondition // tokenPath -> Condition tiers map[int64]*ProjectTier tiersRatios map[int64]int64 createdHeight int64 createdAt int64 } // ID returns the project identifier in "{tokenPath}:{createdHeight}" form. // // Returns: // - id: unique identifier assigned to this project. func (p *Project) ID() string { return p.id } // SetID replaces the project's identifier. // // Parameters: // - id: project identifier to store, normally in "{tokenPath}:{createdHeight}" form. func (p *Project) SetID(id string) { p.id = id } // Name returns the project's human-readable name. // // Returns: // - name: stored project name. func (p *Project) Name() string { return p.name } // SetName replaces the project's human-readable name. // // Parameters: // - name: project name to store. func (p *Project) SetName(name string) { p.name = name } // TokenPath returns the token path whose tokens are distributed as project rewards. // // Returns: // - tokenPath: configured project reward-token path. func (p *Project) TokenPath() string { return p.tokenPath } // SetTokenPath replaces the project's reward-token path. // // Parameters: // - tokenPath: token path to store as the project's reward token. func (p *Project) SetTokenPath(tokenPath string) { p.tokenPath = tokenPath } // DepositAmount returns the total reward-token allocation configured for the project. // // Returns: // - amount: project reward-token allocation. func (p *Project) DepositAmount() int64 { return p.depositAmount } // SetDepositAmount replaces the project's total reward-token allocation. // // Parameters: // - amount: total reward-token amount allocated to the project. func (p *Project) SetDepositAmount(amount int64) { p.depositAmount = amount } // Recipient returns the address authorized to receive the project's rewards. // // Returns: // - recipient: configured project recipient address. func (p *Project) Recipient() address { return p.recipient } // SetRecipient replaces the address authorized to receive project rewards. // // Parameters: // - recipient: address to store as the project recipient. func (p *Project) SetRecipient(recipient address) { p.recipient = recipient } // Conditions 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 (p *Project) Conditions() map[string]*ProjectCondition { conditions := make(map[string]*ProjectCondition) for tokenPath, condition := range p.conditions { conditions[tokenPath] = condition.Clone() } return conditions } // SetConditions 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 (p *Project) SetConditions(conditions map[string]*ProjectCondition) { owned := make(map[string]*ProjectCondition, len(conditions)) for tokenPath, condition := range conditions { owned[tokenPath] = condition } p.conditions = owned } // SetCondition 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 (p *Project) SetCondition(tokenPath string, condition *ProjectCondition) { p.conditions[tokenPath] = condition } // Tiers 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 (p *Project) Tiers() map[int64]*ProjectTier { tiers := make(map[int64]*ProjectTier) for duration, tier := range p.tiers { tiers[duration] = tier.Clone() } return tiers } // SetTiers replaces the project's tier map with a project-owned map. // // Parameters: // - tiers: map from tier duration in seconds to its tier configuration. func (p *Project) SetTiers(tiers map[int64]*ProjectTier) { owned := make(map[int64]*ProjectTier, len(tiers)) for duration, tier := range tiers { owned[duration] = tier } p.tiers = owned } // TiersRatios returns reward allocation ratios keyed by tier duration. // // Returns: // - ratios: map from tier duration in seconds to its allocation ratio. func (p *Project) TiersRatios() map[int64]int64 { return p.tiersRatios } // SetTiersRatios replaces the project's tier allocation ratios. // // Parameters: // - tiersRatios: map from tier duration in seconds to its reward allocation ratio. func (p *Project) SetTiersRatios(tiersRatios map[int64]int64) { p.tiersRatios = tiersRatios } // CreatedHeight returns the block height at which the project was created. // // Returns: // - height: project creation block height. func (p *Project) CreatedHeight() int64 { return p.createdHeight } // SetCreatedHeight replaces the project's creation block height. // // Parameters: // - height: block height to store as the project creation height. func (p *Project) SetCreatedHeight(height int64) { p.createdHeight = height } // CreatedAt returns the Unix timestamp at which the project was created. // // Returns: // - time: project creation Unix timestamp. func (p *Project) CreatedAt() int64 { return p.createdAt } // SetCreatedAt replaces the project's creation timestamp. // // Parameters: // - time: Unix timestamp to store as the project creation time. func (p *Project) SetCreatedAt(time int64) { p.createdAt = time } // GetTier 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 (p *Project) GetTier(duration int64) (*ProjectTier, error) { tier, exists := p.tiers[duration] if !exists { return nil, ufmt.Errorf("tier(%d) not found", duration) } return tier.Clone(), nil } // SetTier 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 (p *Project) SetTier(duration int64, tier *ProjectTier) { p.tiers[duration] = tier } // IsRecipient 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 (p *Project) IsRecipient(recipient address) bool { return p.recipient == recipient } // NewProject 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 NewProject( name string, tokenPath string, depositAmount int64, recipient address, createdHeight int64, createdAt int64, ) *Project { return &Project{ id: MakeProjectID(tokenPath, createdHeight), name: name, tokenPath: tokenPath, depositAmount: depositAmount, recipient: recipient, conditions: make(map[string]*ProjectCondition), tiers: make(map[int64]*ProjectTier), tiersRatios: make(map[int64]int64), createdHeight: createdHeight, createdAt: createdAt, } } // Clone 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 (p Project) Clone() *Project { conditions := make(map[string]*ProjectCondition) for k, v := range p.conditions { conditions[k] = v.Clone() } tiers := make(map[int64]*ProjectTier) for k, v := range p.tiers { tiers[k] = v.Clone() } tiersRatios := make(map[int64]int64) for k, v := range p.tiersRatios { tiersRatios[k] = v } return &Project{ id: p.id, name: p.name, tokenPath: p.tokenPath, depositAmount: p.depositAmount, recipient: p.recipient, conditions: conditions, tiers: tiers, tiersRatios: tiersRatios, createdHeight: p.createdHeight, createdAt: p.createdAt, } } // MakeProjectID 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 MakeProjectID(tokenPath string, createdHeight int64) string { return ufmt.Sprintf("%s:%d", tokenPath, createdHeight) }
  20. #20project_condition.gno
  21. #21package launchpad import ( "strconv" "strings" ufmt "gno.land/p/nt/ufmt/v0" ) const stringSplitterPad = "*PAD*" // ProjectCondition 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. type ProjectCondition struct { tokenPath string minimumAmount int64 } // TokenPath returns the token contract path required by this condition. // // Returns: // - tokenPath: configured condition token path; an empty string means no token is configured. func (p *ProjectCondition) TokenPath() string { return p.tokenPath } // MinimumAmount 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 (p *ProjectCondition) MinimumAmount() int64 { return p.minimumAmount } // IsAvailable 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 (p *ProjectCondition) IsAvailable() bool { return p.tokenPath != "" && p.minimumAmount > 0 } // CheckBalanceCondition 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 (p *ProjectCondition) CheckBalanceCondition(inputTokenPath string, inputAmount int64) error { if p.tokenPath != inputTokenPath { return ufmt.Errorf("token path(%s) is not matched", inputTokenPath) } if inputAmount < p.minimumAmount { return ufmt.Errorf("input amount(%d) is less than minimum amount(%d)", inputAmount, p.minimumAmount) } return nil } // Clone returns an independent copy of this project condition. // // Returns: // - condition: copied token path and minimum amount in a new ProjectCondition value. func (p ProjectCondition) Clone() *ProjectCondition { return &ProjectCondition{ tokenPath: p.tokenPath, minimumAmount: p.minimumAmount, } } // NewProjectCondition 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 NewProjectCondition(tokenPath string, minimumAmount int64) *ProjectCondition { return &ProjectCondition{ tokenPath: tokenPath, minimumAmount: minimumAmount, } } // 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 NewProjectConditionsWithError(conditionTokens string, conditionAmounts string) ([]*ProjectCondition, error) { if conditionTokens == "" && conditionAmounts == "" { return []*ProjectCondition{}, nil } conditions := []*ProjectCondition{} tokenPaths := strings.Split(conditionTokens, stringSplitterPad) minimumAmounts := strings.Split(conditionAmounts, stringSplitterPad) for index, tokenPath := range tokenPaths { if index >= len(minimumAmounts) { return nil, ufmt.Errorf("condition amount(%s) is not matched with condition token(%s)", conditionAmounts, conditionTokens) } minimumAmount, err := strconv.ParseInt(minimumAmounts[index], 10, 64) if err != nil { return nil, ufmt.Errorf("condition amount(%s) is not a valid integer", minimumAmounts[index]) } condition := NewProjectCondition(tokenPath, minimumAmount) if !condition.IsAvailable() { return nil, ufmt.Errorf("condition(%s) is not available", condition.TokenPath()) } conditions = append(conditions, condition) } return conditions, nil }
  22. #22project_tier.gno
  23. #23package launchpad import ( ufmt "gno.land/p/nt/ufmt/v0" u256 "gno.land/p/gnoswap/uint256/v1" ) // 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. type ProjectTier struct { distributeAmountPerSecondX128 *u256.Uint // distribute amount per second, Q128 id string // '{projectId}:duration' // duration == 30, 90, 180 totalDistributeAmount int64 totalDepositAmount int64 // accumulated deposit amount totalWithdrawAmount int64 // accumulated withdraw amount totalDepositCount int64 // accumulated deposit count totalWithdrawCount int64 // accumulated withdraw count totalCollectedAmount int64 // total collected amount by user (reward) startTime int64 endTime int64 } // DistributeAmountPerSecondX128 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 (pt *ProjectTier) DistributeAmountPerSecondX128() *u256.Uint { return pt.distributeAmountPerSecondX128 } // SetDistributeAmountPerSecondX128 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 (pt *ProjectTier) SetDistributeAmountPerSecondX128(amount *u256.Uint) { pt.distributeAmountPerSecondX128 = u256.Zero().Set(amount) } // ID returns the ID of the project tier. // // Returns: // - id: tier identifier in the "{projectID}:{duration}" form. func (pt *ProjectTier) ID() string { return pt.id } // SetID sets the ID of the project tier. // // Parameters: // - id: tier identifier to store, normally "{projectID}:{duration}". func (pt *ProjectTier) SetID(id string) { pt.id = id } // TotalDistributeAmount returns the total distribute amount of the project tier. // // Returns: // - amount: total token amount allocated for distribution by this tier. func (pt *ProjectTier) TotalDistributeAmount() int64 { return pt.totalDistributeAmount } // SetTotalDistributeAmount sets the total distribute amount of the project tier. // // Parameters: // - amount: total token amount allocated for distribution by this tier. func (pt *ProjectTier) SetTotalDistributeAmount(amount int64) { pt.totalDistributeAmount = amount } // TotalDepositAmount returns the total deposit amount of the project tier. // // Returns: // - amount: aggregate token amount deposited into this tier. func (pt *ProjectTier) TotalDepositAmount() int64 { return pt.totalDepositAmount } // SetTotalDepositAmount sets the total deposit amount of the project tier. // // Parameters: // - amount: aggregate token amount to record as deposited into this tier. func (pt *ProjectTier) SetTotalDepositAmount(amount int64) { pt.totalDepositAmount = amount } // TotalWithdrawAmount returns the total withdraw amount of the project tier. // // Returns: // - amount: aggregate token amount withdrawn from this tier. func (pt *ProjectTier) TotalWithdrawAmount() int64 { return pt.totalWithdrawAmount } // SetTotalWithdrawAmount sets the total withdraw amount of the project tier. // // Parameters: // - amount: aggregate token amount to record as withdrawn from this tier. func (pt *ProjectTier) SetTotalWithdrawAmount(amount int64) { pt.totalWithdrawAmount = amount } // TotalDepositCount returns the total deposit count of the project tier. // // Returns: // - count: number of deposits recorded for this tier. func (pt *ProjectTier) TotalDepositCount() int64 { return pt.totalDepositCount } // SetTotalDepositCount sets the total deposit count of the project tier. // // Parameters: // - count: number of deposits to record for this tier. func (pt *ProjectTier) SetTotalDepositCount(count int64) { pt.totalDepositCount = count } // TotalWithdrawCount returns the total withdraw count of the project tier. // // Returns: // - count: number of withdrawals recorded for this tier. func (pt *ProjectTier) TotalWithdrawCount() int64 { return pt.totalWithdrawCount } // SetTotalWithdrawCount sets the total withdraw count of the project tier. // // Parameters: // - count: number of withdrawals to record for this tier. func (pt *ProjectTier) SetTotalWithdrawCount(count int64) { pt.totalWithdrawCount = count } // TotalCollectedAmount returns the total collected amount of the project tier. // // Returns: // - amount: aggregate reward amount collected from this tier. func (pt *ProjectTier) TotalCollectedAmount() int64 { return pt.totalCollectedAmount } // SetTotalCollectedAmount sets the total collected amount of the project tier. // // Parameters: // - amount: aggregate reward amount to record as collected from this tier. func (pt *ProjectTier) SetTotalCollectedAmount(amount int64) { pt.totalCollectedAmount = amount } // StartTime returns the start time of the project tier. // // Returns: // - time: tier start timestamp in Unix seconds. func (pt *ProjectTier) StartTime() int64 { return pt.startTime } // SetStartTime sets the start time of the project tier. // // Parameters: // - time: tier start timestamp in Unix seconds. func (pt *ProjectTier) SetStartTime(time int64) { pt.startTime = time } // EndTime returns the end time of the project tier. // // Returns: // - time: tier end timestamp in Unix seconds. func (pt *ProjectTier) EndTime() int64 { return pt.endTime } // SetEndTime sets the end time of the project tier. // // Parameters: // - time: tier end timestamp in Unix seconds. func (pt *ProjectTier) SetEndTime(time int64) { pt.endTime = time } // IsActivated 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 (pt *ProjectTier) IsActivated(currentTime int64) bool { return pt.startTime <= currentTime && currentTime < pt.endTime } // IsEnded 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 (pt *ProjectTier) IsEnded(currentTime int64) bool { return pt.endTime < currentTime } // Clone 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 (pt ProjectTier) Clone() *ProjectTier { return &ProjectTier{ id: pt.id, totalDistributeAmount: pt.totalDistributeAmount, distributeAmountPerSecondX128: pt.distributeAmountPerSecondX128.Clone(), startTime: pt.startTime, endTime: pt.endTime, totalDepositAmount: pt.totalDepositAmount, totalWithdrawAmount: pt.totalWithdrawAmount, totalDepositCount: pt.totalDepositCount, totalWithdrawCount: pt.totalWithdrawCount, totalCollectedAmount: pt.totalCollectedAmount, } } // NewProjectTier 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 NewProjectTier( projectID string, tierDuration int64, totalDistributeAmount int64, startTime int64, endTime int64, ) *ProjectTier { return &ProjectTier{ id: MakeProjectTierID(projectID, tierDuration), totalDistributeAmount: totalDistributeAmount, distributeAmountPerSecondX128: u256.Zero(), startTime: startTime, endTime: endTime, totalDepositAmount: 0, totalWithdrawAmount: 0, totalDepositCount: 0, totalWithdrawCount: 0, totalCollectedAmount: 0, } } // MakeProjectTierID 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 MakeProjectTierID(projectID string, duration int64) string { return ufmt.Sprintf("%s:%d", projectID, duration) }
  24. #24proxy.gno

Result log

msg:0,success:true,log:,events:[]