Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

launchpad source realm

Readme View source

Launchpad

Token distribution platform for early-stage projects.

Overview

Launchpad enables new projects to distribute tokens to GNS stakers with tiered lock periods and pro-rata reward distribution. For more details about the concept, check out docs.

Configuration

  • Pool Tiers: 30, 90, 180 days
  • Minimum Start Delay: 3 days
  • Minimum Deposit Amount: 1,000,000 GNS (must be a multiple of 1,000,000)
  • Auto-delegation: Staked GNS converts to xGNS
  • Tier Allocation: Customizable per project

Core Features

  • GNS staking for project token rewards
  • Multiple tier durations with different rewards
  • Automatic xGNS delegation for governance
  • Pro-rata distribution based on stake size
  • Conditional participation requirements

Key Functions

CreateProject

Creates new token distribution project.

DepositGns

Stakes GNS to earn project tokens.

CollectRewardByDepositId

Claims earned project tokens.

CollectDepositGns

Withdraws GNS after lock period.

TransferLeftFromProjectByAdmin

Refunds unclaimed rewards to project.

Usage

 1// Create project
 2projectId := CreateProject(
 3    name, tokenPath, recipient, amount,
 4    conditionTokens, conditionAmounts,
 5    tier30Ratio, tier90Ratio, tier180Ratio,
 6    startTime
 7)
 8
 9// Stake GNS
10depositId := DepositGns(projectTierId, amount, referrer)
11
12// Collect rewards
13CollectRewardByDepositId(depositId)
14
15// Withdraw after lock period
16CollectDepositGns(depositId)

Security

  • GNS locked until tier period ends
  • Automatic governance delegation
  • Conditional requirements prevent abuse

Constants 2

const StoreKeyProjects, StoreKeyProjectTierRewardManagers, StoreKeyDepositCounter, StoreKeyDeposits, StoreKeyTotalGNSStakedAmount

1const (
2	StoreKeyProjects                  StoreKey = "projects"                  // Projects tree
3	StoreKeyProjectTierRewardManagers StoreKey = "projectTierRewardManagers" // Project tier reward managers tree
4	StoreKeyDepositCounter            StoreKey = "depositCounter"            // Deposit counter
5	StoreKeyDeposits                  StoreKey = "deposits"                  // Deposits tree
6	StoreKeyTotalGNSStakedAmount      StoreKey = "totalGNSStakedAmount"      // Total active launchpad GNS stake
7)
source

Functions 71

func CollectDepositGns

crossing Action
1func CollectDepositGns(cur realm, depositID string) (int64, error)
source

CollectDepositGns collects rewards from a deposit.

func CollectProtocolFee

crossing Action
1func CollectProtocolFee(cur realm)
source

CollectProtocolFee collects accumulated protocol fees from launchpad operations.

func CollectProtocolFeeReward

crossing Action
1func CollectProtocolFeeReward(cur realm, tokenPath string)
source

CollectProtocolFeeReward collects accumulated launchpad protocol fee rewards for the provided token path.

func CreateProject

crossing Action
 1func CreateProject(
 2	cur realm,
 3	name string,
 4	tokenPath string,
 5	recipient address,
 6	depositAmount int64,
 7	conditionTokens string,
 8	conditionAmounts string,
 9	tier30Ratio int64,
10	tier90Ratio int64,
11	tier180Ratio int64,
12	startTime int64,
13) string
source

CreateProject creates a new launchpad project with tiered allocations.

func DepositGns

crossing Action
1func DepositGns(cur realm, targetProjectTierID string, depositAmount int64, referrer string) string
source

DepositGns deposits GNS tokens to a launchpad project tier.

func GetDepositAmount

Action
1func GetDepositAmount(depositId string) (int64, error)
source

GetDepositAmount returns the deposit amount of a deposit by its ID.

func GetDepositCreatedAt

Action
1func GetDepositCreatedAt(depositId string) (int64, error)
source

GetDepositCreatedAt returns the created time of a deposit by its ID.

func GetDepositEndTime

Action
1func GetDepositEndTime(depositId string) (int64, error)
source

GetDepositEndTime returns the end time of a deposit by its ID.

func GetDepositProjectID

Action
1func GetDepositProjectID(depositId string) (string, error)
source

GetDepositProjectID returns the project ID of a deposit by its ID.

func GetDepositTier

Action
1func GetDepositTier(depositId string) (int64, error)
source

GetDepositTier returns the tier of a deposit by its ID.

func GetProjectCreatedAt

Action
1func GetProjectCreatedAt(projectId string) (int64, error)
source

GetProjectCreatedAt returns the created time of a project by its ID.

func GetProjectIDs

Action
1func GetProjectIDs(offset, count int) []string
source

GetProjectIDs returns a paginated list of project IDs.

func GetProjectName

Action
1func GetProjectName(projectId string) (string, error)
source

GetProjectName returns the name of a project by its ID.

func GetProjectTierDepositIDs

Action
1func GetProjectTierDepositIDs(projectId string, tier int64, offset, count int) []string
source

GetProjectTierDepositIDs returns a paginated list of deposit IDs for a project tier.

func GetProjectTierEndTime

Action
1func GetProjectTierEndTime(projectId string, tier int64) (int64, error)
source

GetProjectTierEndTime returns the end time of a project tier.

func GetProjectTierStartTime

Action
1func GetProjectTierStartTime(projectId string, tier int64) (int64, error)
source

GetProjectTierStartTime returns the start time of a project tier.

func GetProjectTiersRatios

Action
1func GetProjectTiersRatios(projectId string) (map[int64]int64, error)
source

GetProjectTiersRatios returns the tiers ratios map of a project by its ID.

func GetProjectTokenPath

Action
1func GetProjectTokenPath(projectId string) (string, error)
source

GetProjectTokenPath returns the token path of a project by its ID.

func GetTotalGNSStakedAmount

Action
1func GetTotalGNSStakedAmount() int64
source

GetTotalGNSStakedAmount returns the total amount of GNS currently staked across all launchpad deposits.

func MakeProjectID

Action
1func MakeProjectID(tokenPath string, createdHeight int64) string
source

MakeProjectID generates a unique project ID based on the given token path and the current block height.

The generated ID combines the `tokenPath` and the current block height in the following format: "{tokenPath}:{height}"

Parameters: - tokenPath (string): The path of the token associated with the project.

Returns: - string: A unique project ID in the format "tokenPath:height".

func MakeProjectTierID

Action
1func MakeProjectTierID(projectID string, duration int64) string
source

MakeProjectTierID generates a unique tier ID based on the given project ID and the tier duration.

The generated ID combines the `projectId` and the `duration` in the following format: "{projectId}:{duration}"

Parameters: - projectId (string): The unique ID of the project associated with the tier. - duration (uint64): The duration of the tier (e.g., 30, 90, 180 days).

Returns: - string: A unique tier ID in the format "projectId:duration".

func NewBPTreeN

Action
1func NewBPTreeN(fanout int) *bptree.BPTree
source

NewBPTreeN allocates a BP-tree under /r/gnoswap/launchpad's realm context (the realm that declares Project/Deposit/RewardManager). The tree's PkgID is therefore /r/gnoswap/launchpad, matching the domain values it stores, so tree.Set leaf-slot writes clear the readonly-taint gate regardless of which realm (launchpad/v1, mock, tests) calls Set. Implementations, mocks, and tests must allocate launchpad trees through here rather than calling bptree.NewBPTreeN directly in their own realm.

func RegisterInitializer

crossing Action
1func RegisterInitializer(cur realm, initializer func(_ int, rlm realm, launchpadStore ILaunchpadStore) ILaunchpad)
source

RegisterInitializer registers a new launchpad implementation version. This function is called by each version (v1, v2, etc.) during initialization to register their implementation with the proxy system.

The initializer function creates a new instance of the implementation using the provided launchpadStore interface.

Security: Only contracts within the domain path can register initializers. Each package path can only register once to prevent duplicate registrations.

func TransferLeftFromProjectByAdmin

crossing Action
1func TransferLeftFromProjectByAdmin(cur realm, projectID string, recipient address) int64
source

TransferLeftFromProjectByAdmin transfers the remaining rewards of a project to a specified recipient.

func UpgradeImpl

crossing Action
1func UpgradeImpl(cur realm, packagePath string)
source

UpgradeImpl switches the active launchpad implementation to a different version. This function allows seamless upgrades from one version to another without data migration or downtime.

Security: Only admin or governance can perform upgrades. The new implementation must have been previously registered via RegisterInitializer.

func GetDeposit

Action
1func GetDeposit(depositId string) (*Deposit, error)
source

GetDeposit retrieves a deposit by its ID. Returns a cloned deposit to prevent external modification.

func NewDeposit

Action
 1func NewDeposit(
 2	depositID string,
 3	projectID string,
 4	tier int64,
 5	depositor address,
 6	depositAmount int64,
 7	createdHeight int64,
 8	createdTime int64,
 9	endTime int64,
10) *Deposit
source

NewDeposit returns a pointer to a new Deposit with the given values.

func NewLaunchpadStore

Action
1func NewLaunchpadStore(kvStore store.KVStore) ILaunchpadStore
source

NewLaunchpadStore creates a new launchpad store instance with the provided KV store. This function is used by the upgrade system to create storage instances for each implementation.

func GetProject

Action
1func GetProject(projectId string) (*Project, error)
source

GetProject retrieves a project by its ID. Returns a cloned project to prevent external modification.

func NewProject

Action
1func NewProject(
2	name string,
3	tokenPath string,
4	depositAmount int64,
5	recipient address,
6	createdHeight int64,
7	createdAt int64,
8) *Project
source

func GetProjectCondition

Action
1func GetProjectCondition(projectId string, tokenPath string) (*ProjectCondition, error)
source

GetProjectCondition retrieves a specific condition of a project. Returns a cloned condition to prevent external modification.

func GetProjectTier

Action
1func GetProjectTier(projectId string, tier int64) (*ProjectTier, error)
source

GetProjectTier retrieves a specific tier of a project. Returns a cloned tier to prevent external modification.

func NewProjectTier

Action
1func NewProjectTier(
2	projectID string,
3	tierDuration int64,
4	totalDistributeAmount int64,
5	startTime int64,
6	endTime int64,
7) *ProjectTier
source

NewProjectTier returns a pointer to a new ProjectTier with the given values.

func GetProjectTierRewardManager

Action
1func GetProjectTierRewardManager(projectTierId string) (*RewardManager, error)
source

GetProjectTierRewardManager retrieves a reward manager by project tier ID. Returns a cloned reward manager to prevent external modification.

func NewRewardManager

Action
1func NewRewardManager(
2	totalDistributeAmount int64,
3	distributeStartTime int64,
4	distributeEndTime int64,
5	rewardCollectableDuration int64,
6) *RewardManager
source

NewRewardManager returns a pointer to a new RewardManager with the given values.

func GetRewardState

Action
1func GetRewardState(projectTierId string, depositId string) (*RewardState, error)
source

GetRewardState retrieves a reward state by project tier ID and deposit ID. Returns a cloned reward state to prevent external modification.

func NewRewardState

Action
1func NewRewardState(
2	accumulatedRewardPerDepositX128 *u256.Uint,
3	depositAmount,
4	distributeStartTime,
5	distributeEndTime int64,
6	claimableTime int64,
7) *RewardState
source

NewRewardState returns a pointer to a new RewardState with the given values.

Types 13

type Counter

struct
1type Counter struct {
2	id int64
3}
source

Counter manages unique incrementing IDs.

Methods on Counter

func Get

method on Counter
1func (c *Counter) Get() int64
source

Get returns the current ID without incrementing.

func Next

method on Counter
1func (c *Counter) Next() int64
source

Next increments the counter and returns the next ID.

type Deposit

struct
 1type Deposit struct {
 2	depositor address
 3
 4	id              string
 5	projectID       string
 6	tier            int64 // 30, 60, 180 // instead of tierId
 7	depositAmount   int64
 8	withdrawnHeight int64
 9	withdrawnTime   int64
10	createdHeight   int64
11	createdAt       int64
12	endTime         int64
13}
source

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 of the deposit. - depositAmount (int64): The amount of the deposit. - withdrawnHeight (int64): The height at which the deposit was withdrawn. - withdrawnTime (int64): The time when the deposit was withdrawn. - createdTime (int64): The time when the deposit was created. - endTime (int64): The time when the deposit ends.

Methods on Deposit

func Clone

method on Deposit
1func (d Deposit) Clone() *Deposit
source

func CreatedAt

method on Deposit
1func (d *Deposit) CreatedAt() int64
source

func Depositor

method on Deposit
1func (d *Deposit) Depositor() address
source

func EndTime

method on Deposit
1func (d *Deposit) EndTime() int64
source

func ID

method on Deposit
1func (d *Deposit) ID() string
source

func IsDepositor

method on Deposit
1func (d *Deposit) IsDepositor(address address) bool
source

func IsEnded

method on Deposit
1func (d *Deposit) IsEnded(currentTime int64) bool
source

func ProjectID

method on Deposit
1func (d *Deposit) ProjectID() string
source

func SetCreatedAt

method on Deposit
1func (d *Deposit) SetCreatedAt(createdAt int64)
source

func SetDepositor

method on Deposit
1func (d *Deposit) SetDepositor(depositor address)
source

func SetEndTime

method on Deposit
1func (d *Deposit) SetEndTime(endTime int64)
source

func SetID

method on Deposit
1func (d *Deposit) SetID(id string)
source

func SetProjectID

method on Deposit
1func (d *Deposit) SetProjectID(projectID string)
source

func SetTier

method on Deposit
1func (d *Deposit) SetTier(tier int64)
source

func SetWithdrawn

method on Deposit
1func (d *Deposit) SetWithdrawn(withdrawnHeight int64, withdrawnTime int64)
source

func Tier

method on Deposit
1func (d *Deposit) Tier() int64
source

type ILaunchpad

interface
1type ILaunchpad interface {
2	ILaunchpadProject
3	ILaunchpadDeposit
4	ILaunchpadGetter
5}
source

type ILaunchpadDeposit

interface
1type ILaunchpadDeposit interface {
2	DepositGns(_ int, rlm realm, targetProjectTierID string, depositAmount int64, referrer string) string
3	CollectDepositGns(_ int, rlm realm, depositID string) (int64, error)
4	CollectRewardByDepositId(_ int, rlm realm, depositID string) int64
5}
source

type ILaunchpadGetter

interface
 1type ILaunchpadGetter interface {
 2	GetProjectCount() int
 3	GetProjectIDs(offset, count int) []string
 4	GetProject(projectId string) (*Project, error)
 5	GetProjectName(projectId string) (string, error)
 6	GetProjectTokenPath(projectId string) (string, error)
 7	GetProjectDepositAmount(projectId string) (int64, error)
 8	GetProjectRecipient(projectId string) (address, error)
 9	GetProjectCondition(projectId string, tokenPath string) (*ProjectCondition, error)
10	GetProjectTiersRatios(projectId string) (map[int64]int64, error)
11	GetProjectCreatedHeight(projectId string) (int64, error)
12	GetProjectCreatedAt(projectId string) (int64, error)
13
14	GetProjectTier(projectId string, tier int64) (*ProjectTier, error)
15	GetProjectTierDistributeAmountPerSecondX128(projectId string, tier int64) (*uint256.Uint, error)
16	GetProjectTierTotalDistributeAmount(projectId string, tier int64) (int64, error)
17	GetProjectTierTotalDepositAmount(projectId string, tier int64) (int64, error)
18	GetProjectTierTotalWithdrawAmount(projectId string, tier int64) (int64, error)
19	GetProjectTierTotalDepositCount(projectId string, tier int64) (int64, error)
20	GetProjectTierTotalWithdrawCount(projectId string, tier int64) (int64, error)
21	GetProjectTierTotalCollectedAmount(projectId string, tier int64) (int64, error)
22	GetProjectTierStartTime(projectId string, tier int64) (int64, error)
23	GetProjectTierEndTime(projectId string, tier int64) (int64, error)
24
25	GetDepositCount() int
26	GetCurrentDepositId() int64
27	GetProjectTierDepositCount(projectId string, tier int64) int
28	GetProjectTierDepositIDs(projectId string, tier int64, offset, count int) []string
29
30	GetDeposit(depositId string) (*Deposit, error)
31	GetDepositProjectID(depositId string) (string, error)
32	GetDepositTier(depositId string) (int64, error)
33	GetDepositProjectTierID(depositId string) (string, error)
34	GetDepositAmount(depositId string) (int64, error)
35	GetDepositWithdrawnHeight(depositId string) (int64, error)
36	GetDepositWithdrawnTime(depositId string) (int64, error)
37	GetDepositCreatedHeight(depositId string) (int64, error)
38	GetDepositCreatedAt(depositId string) (int64, error)
39	GetDepositEndTime(depositId string) (int64, error)
40	GetTotalGNSStakedAmount() int64
41
42	GetProjectTierRewardManagerCount() int
43	GetProjectTierRewardManager(projectTierId string) (*RewardManager, error)
44	GetProjectTierRewardDistributeAmountPerSecondX128(projectTierId string) (*uint256.Uint, error)
45	GetProjectTierRewardAccumulatedRewardPerDepositX128(projectTierId string) (*uint256.Uint, error)
46	GetProjectTierRewardTotalDistributeAmount(projectTierId string) (int64, error)
47	GetProjectTierRewardTotalClaimedAmount(projectTierId string) (int64, error)
48	GetProjectTierRewardDistributeStartTime(projectTierId string) (int64, error)
49	GetProjectTierRewardDistributeEndTime(projectTierId string) (int64, error)
50	GetProjectTierRewardAccumulatedDistributeAmount(projectTierId string) (int64, error)
51	GetProjectTierRewardAccumulatedTime(projectTierId string) (int64, error)
52	GetProjectTierRewardClaimableDuration(projectTierId string) (int64, error)
53
54	GetRewardState(projectTierId string, depositId string) (*RewardState, error)
55	GetProjectActiveStatus(projectId string) (bool, error)
56}
source

type ILaunchpadProject

interface
 1type ILaunchpadProject interface {
 2	CreateProject(
 3		_ int,
 4		rlm realm,
 5		name string,
 6		tokenPath string,
 7		recipient address,
 8		depositAmount int64,
 9		conditionTokens string,
10		conditionAmounts string,
11		tier30Ratio int64,
12		tier90Ratio int64,
13		tier180Ratio int64,
14		startTime int64,
15	) string
16	TransferLeftFromProjectByAdmin(_ int, rlm realm, projectID string, recipient address) int64
17	CollectProtocolFee(_ int, rlm realm)
18	CollectEmissionReward(_ int, rlm realm)
19	CollectProtocolFeeReward(_ int, rlm realm, tokenPath string)
20}
source

type ILaunchpadStore

interface
 1type ILaunchpadStore interface {
 2	HasProjectsKey() bool
 3	GetProjects() *bptree.BPTree
 4	SetProjects(_ int, rlm realm, projects *bptree.BPTree) error
 5
 6	HasProjectTierRewardManagersKey() bool
 7	GetProjectTierRewardManagers() *bptree.BPTree
 8	SetProjectTierRewardManagers(_ int, rlm realm, managers *bptree.BPTree) error
 9
10	// DepositCounter
11	HasDepositCounterStoreKey() bool
12	GetDepositCounter() *Counter
13	SetDepositCounter(_ int, rlm realm, counter *Counter) error
14	NextDepositID() string
15
16	HasDepositsKey() bool
17	GetDeposits() *bptree.BPTree
18	SetDeposits(_ int, rlm realm, deposits *bptree.BPTree) error
19
20	HasTotalGNSStakedAmountKey() bool
21	GetTotalGNSStakedAmount() int64
22	SetTotalGNSStakedAmount(_ int, rlm realm, amount int64) error
23}
source

type Project

struct
 1type Project struct {
 2	id            string // 'tokenPath:createdHeight'
 3	name          string
 4	tokenPath     string
 5	depositAmount int64
 6	recipient     address                      // string
 7	conditions    map[string]*ProjectCondition // tokenPath -> Condition
 8	tiers         map[int64]*ProjectTier
 9	tiersRatios   map[int64]int64
10	createdHeight int64
11	createdAt     int64
12}
source

Project represents a launchpad project.

This struct contains the necessary data and methods to manage and distribute rewards for a specific project.

Fields: - id (string): The unique identifier for the project, formatted as "{tokenPath}:{createdHeight}". - name (string): The name of the project. - tokenPath (string): The path of the token associated with the project. - depositAmount (int64): The total amount of tokens deposited for the project. - recipient (std.Address): The address to receive the project's rewards. - conditions (map[string]*ProjectCondition): A map of token paths to their associated conditions. - tiers (map[int64]*ProjectTier): A map of tier durations to their associated tiers. - tiersRatios (map[int64]int64): A map of tier durations to their associated ratios. - createdBlockTimeInfo (BlockTimeInfo): The block time and height information for the creation of the project.

Methods on Project

func Clone

method on Project
1func (p Project) Clone() *Project
source

func Conditions

method on Project
1func (p *Project) Conditions() map[string]*ProjectCondition
source

GetConditions returns the conditions map of the project.

func CreatedAt

method on Project
1func (p *Project) CreatedAt() int64
source

GetCreatedAt returns the created time of the project.

func CreatedHeight

method on Project
1func (p *Project) CreatedHeight() int64
source

GetCreatedHeight returns the created height of the project.

func DepositAmount

method on Project
1func (p *Project) DepositAmount() int64
source

GetDepositAmount returns the deposit amount of the project.

func GetTier

method on Project
1func (p *Project) GetTier(duration int64) (*ProjectTier, error)
source

func ID

method on Project
1func (p *Project) ID() string
source

GetID returns the ID of the project.

func IsRecipient

method on Project
1func (p *Project) IsRecipient(recipient address) bool
source

IsRecipient returns true if the project recipient is the given address.

func Name

method on Project
1func (p *Project) Name() string
source

GetName returns the name of the project.

func Recipient

method on Project
1func (p *Project) Recipient() address
source

GetRecipient returns the recipient address of the project.

func SetCondition

method on Project
1func (p *Project) SetCondition(tokenPath string, condition *ProjectCondition)
source

SetCondition sets a single condition by token path. Mutating the map inside the domain method avoids the readonly taint that arises when a caller in another realm round-trips Conditions()/SetConditions().

func SetConditions

method on Project
1func (p *Project) SetConditions(conditions map[string]*ProjectCondition)
source

SetConditions sets the conditions map of the project. The map is rebuilt so it is owned by this realm, allowing later in-domain mutations (e.g. SetCondition) without hitting the readonly taint on a foreign map.

func SetCreatedAt

method on Project
1func (p *Project) SetCreatedAt(time int64)
source

SetCreatedAt sets the created time of the project.

func SetCreatedHeight

method on Project
1func (p *Project) SetCreatedHeight(height int64)
source

SetCreatedHeight sets the created height of the project.

func SetDepositAmount

method on Project
1func (p *Project) SetDepositAmount(amount int64)
source

SetDepositAmount sets the deposit amount of the project.

func SetID

method on Project
1func (p *Project) SetID(id string)
source

SetID sets the ID of the project.

func SetName

method on Project
1func (p *Project) SetName(name string)
source

SetName sets the name of the project.

func SetRecipient

method on Project
1func (p *Project) SetRecipient(recipient address)
source

SetRecipient sets the recipient address of the project.

func SetTier

method on Project
1func (p *Project) SetTier(duration int64, tier *ProjectTier)
source

func SetTiers

method on Project
1func (p *Project) SetTiers(tiers map[int64]*ProjectTier)
source

SetTiers sets the tiers map of the project. The map is rebuilt so it is owned by this realm, allowing later in-domain mutations (e.g. SetTier) without hitting the readonly taint on a map passed in from another realm.

func SetTiersRatios

method on Project
1func (p *Project) SetTiersRatios(tiersRatios map[int64]int64)
source

SetTiersRatios sets the tiers ratios map of the project.

func SetTokenPath

method on Project
1func (p *Project) SetTokenPath(tokenPath string)
source

SetTokenPath sets the token path of the project.

func Tiers

method on Project
1func (p *Project) Tiers() map[int64]*ProjectTier
source

GetTiers returns the tiers map of the project.

func TiersRatios

method on Project
1func (p *Project) TiersRatios() map[int64]int64
source

GetTiersRatios returns the tiers ratios map of the project.

func TokenPath

method on Project
1func (p *Project) TokenPath() string
source

GetTokenPath returns the token path of the project.

type ProjectCondition

struct
1type ProjectCondition struct {
2	tokenPath     string
3	minimumAmount int64
4}
source

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.

Methods on ProjectCondition

func CheckBalanceCondition

method on ProjectCondition
1func (p *ProjectCondition) CheckBalanceCondition(inputTokenPath string, inputAmount int64) error
source

func Clone

method on ProjectCondition
1func (p ProjectCondition) Clone() *ProjectCondition
source

func IsAvailable

method on ProjectCondition
1func (p *ProjectCondition) IsAvailable() bool
source

func MinimumAmount

method on ProjectCondition
1func (p *ProjectCondition) MinimumAmount() int64
source

func TokenPath

method on ProjectCondition
1func (p *ProjectCondition) TokenPath() string
source

type ProjectTier

struct
 1type ProjectTier struct {
 2	distributeAmountPerSecondX128 *u256.Uint // distribute amount per second, Q128
 3	id                            string     // '{projectId}:duration' // duartion == 30, 90, 180
 4	totalDistributeAmount         int64
 5	totalDepositAmount            int64 // accumulated deposit amount
 6	totalWithdrawAmount           int64 // accumulated withdraw amount
 7	totalDepositCount             int64 // accumulated deposit count
 8	totalWithdrawCount            int64 // accumulated withdraw count
 9	totalCollectedAmount          int64 // total collected amount by user (reward)
10	startTime                     int64
11	endTime                       int64
12}
source

ProjectTier represents a tier within a project.

This struct contains the necessary data and methods to manage and distribute rewards for a specific tier of a project.

Fields: - distributeAmountPerSecondX128 (u256.Uint): The amount of tokens to be distributed per second, represented as a Q128 fixed-point number. - startTime (int64): The time for the start of the tier. - endTime (int64): The time for the end of the tier. - id (string): The unique identifier for the tier, formatted as "{projectID}:duration". - totalDistributeAmount (int64): The total amount of tokens to be distributed for the tier. - totalDepositAmount (int64): The total amount of tokens deposited for the tier. - totalWithdrawAmount (int64): The total amount of tokens withdrawn from the tier. - totalDepositCount (int64): The total number of deposits made to the tier. - totalWithdrawCount (int64): The total number of withdrawals from the tier. - totalCollectedAmount (int64): The total amount of tokens collected as rewards for the tier.

Methods on ProjectTier

func Clone

method on ProjectTier
1func (pt ProjectTier) Clone() *ProjectTier
source

func DistributeAmountPerSecondX128

method on ProjectTier
1func (pt *ProjectTier) DistributeAmountPerSecondX128() *u256.Uint
source

DistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the project tier.

func EndTime

method on ProjectTier
1func (pt *ProjectTier) EndTime() int64
source

EndTime returns the end time of the project tier.

func ID

method on ProjectTier
1func (pt *ProjectTier) ID() string
source

ID returns the ID of the project tier.

func IsActivated

method on ProjectTier
1func (pt *ProjectTier) IsActivated(currentTime int64) bool
source

func IsEnded

method on ProjectTier
1func (pt *ProjectTier) IsEnded(currentTime int64) bool
source

IsEnded returns true if the project tier has ended.

func SetDistributeAmountPerSecondX128

method on ProjectTier
1func (pt *ProjectTier) SetDistributeAmountPerSecondX128(amount *u256.Uint)
source

SetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the project tier.

func SetEndTime

method on ProjectTier
1func (pt *ProjectTier) SetEndTime(time int64)
source

SetEndTime sets the end time of the project tier.

func SetID

method on ProjectTier
1func (pt *ProjectTier) SetID(id string)
source

SetID sets the ID of the project tier.

func SetStartTime

method on ProjectTier
1func (pt *ProjectTier) SetStartTime(time int64)
source

SetStartTime sets the start time of the project tier.

func SetTotalCollectedAmount

method on ProjectTier
1func (pt *ProjectTier) SetTotalCollectedAmount(amount int64)
source

SetTotalCollectedAmount sets the total collected amount of the project tier.

func SetTotalDepositAmount

method on ProjectTier
1func (pt *ProjectTier) SetTotalDepositAmount(amount int64)
source

SetTotalDepositAmount sets the total deposit amount of the project tier.

func SetTotalDepositCount

method on ProjectTier
1func (pt *ProjectTier) SetTotalDepositCount(count int64)
source

SetTotalDepositCount sets the total deposit count of the project tier.

func SetTotalDistributeAmount

method on ProjectTier
1func (pt *ProjectTier) SetTotalDistributeAmount(amount int64)
source

SetTotalDistributeAmount sets the total distribute amount of the project tier.

func SetTotalWithdrawAmount

method on ProjectTier
1func (pt *ProjectTier) SetTotalWithdrawAmount(amount int64)
source

SetTotalWithdrawAmount sets the total withdraw amount of the project tier.

func SetTotalWithdrawCount

method on ProjectTier
1func (pt *ProjectTier) SetTotalWithdrawCount(count int64)
source

SetTotalWithdrawCount sets the total withdraw count of the project tier.

func StartTime

method on ProjectTier
1func (pt *ProjectTier) StartTime() int64
source

StartTime returns the start time of the project tier.

func TotalCollectedAmount

method on ProjectTier
1func (pt *ProjectTier) TotalCollectedAmount() int64
source

TotalCollectedAmount returns the total collected amount of the project tier.

func TotalDepositAmount

method on ProjectTier
1func (pt *ProjectTier) TotalDepositAmount() int64
source

TotalDepositAmount returns the total deposit amount of the project tier.

func TotalDepositCount

method on ProjectTier
1func (pt *ProjectTier) TotalDepositCount() int64
source

TotalDepositCount returns the total deposit count of the project tier.

func TotalDistributeAmount

method on ProjectTier
1func (pt *ProjectTier) TotalDistributeAmount() int64
source

TotalDistributeAmount returns the total distribute amount of the project tier.

func TotalWithdrawAmount

method on ProjectTier
1func (pt *ProjectTier) TotalWithdrawAmount() int64
source

TotalWithdrawAmount returns the total withdraw amount of the project tier.

func TotalWithdrawCount

method on ProjectTier
1func (pt *ProjectTier) TotalWithdrawCount() int64
source

TotalWithdrawCount returns the total withdraw count of the project tier.

type RewardManager

struct
 1type RewardManager struct {
 2	rewards *bptree.BPTree // depositId -> RewardState
 3
 4	distributeAmountPerSecondX128   *u256.Uint // distribute amount per second, Q128
 5	accumulatedRewardPerDepositX128 *u256.Uint // accumulated reward per GNS stake, Q128
 6
 7	totalDistributeAmount       int64 // total distributed amount
 8	totalClaimedAmount          int64 // total claimed amount
 9	distributeStartTime         int64 // start time of reward calculation
10	distributeEndTime           int64 // end time of reward calculation
11	accumulatedDistributeAmount int64 // accumulated distribute amount
12	accumulatedTime             int64 // last time when reward was calculated
13	rewardClaimableDuration     int64 // duration of reward claimable
14}
source

RewardManager manages the distribution of rewards for a project tier.

This struct contains the necessary data and methods to calculate and track rewards for deposits associated with a project tier.

Fields: - rewards (bptree.BPTree): A map of deposit IDs to their associated reward states. - distributeAmountPerSecondX128 (u256.Uint): The amount of tokens to be distributed per second, represented as a Q128 fixed-point number. - accumulatedRewardPerDepositX128 (u256.Uint): The accumulated reward per GNS stake, represented as a Q128 fixed-point number. - totalDistributeAmount (int64): The total amount of tokens to be distributed. - totalClaimedAmount (int64): The total amount of tokens claimed. - distributeStartTime (int64): The start time of the reward calculation. - distributeEndTime (int64): The end time of the reward calculation. - accumulatedDistributeAmount (int64): The accumulated amount of tokens distributed. - rewardClaimableDuration (int64): The duration of reward claimable.

Methods on RewardManager

func AccumulatedDistributeAmount

method on RewardManager
1func (rm *RewardManager) AccumulatedDistributeAmount() int64
source

AccumulatedDistributeAmount returns the accumulated distribute amount of the reward manager.

func AccumulatedRewardPerDepositX128

method on RewardManager
1func (rm *RewardManager) AccumulatedRewardPerDepositX128() *u256.Uint
source

AccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of the reward manager.

func AccumulatedTime

method on RewardManager
1func (rm *RewardManager) AccumulatedTime() int64
source

AccumulatedTime returns the accumulated time of the reward manager.

func Clone

method on RewardManager
1func (rm RewardManager) Clone() *RewardManager
source

func DistributeAmountPerSecondX128

method on RewardManager
1func (rm *RewardManager) DistributeAmountPerSecondX128() *u256.Uint
source

DistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the reward manager.

func DistributeEndTime

method on RewardManager
1func (rm *RewardManager) DistributeEndTime() int64
source

DistributeEndTime returns the distribute end time of the reward manager.

func DistributeStartTime

method on RewardManager
1func (rm *RewardManager) DistributeStartTime() int64
source

DistributeStartTime returns the distribute start time of the reward manager.

func RemoveReward

method on RewardManager
1func (rm *RewardManager) RemoveReward(depositID string)
source

func RewardClaimableDuration

method on RewardManager
1func (rm *RewardManager) RewardClaimableDuration() int64
source

RewardClaimableDuration returns the reward claimable duration of the reward manager.

func Rewards

method on RewardManager
1func (rm *RewardManager) Rewards() *bptree.BPTree
source

Rewards returns the rewards tree of the reward manager.

func SetAccumulatedDistributeAmount

method on RewardManager
1func (rm *RewardManager) SetAccumulatedDistributeAmount(amount int64)
source

SetAccumulatedDistributeAmount sets the accumulated distribute amount of the reward manager.

func SetAccumulatedRewardPerDepositX128

method on RewardManager
1func (rm *RewardManager) SetAccumulatedRewardPerDepositX128(amount *u256.Uint)
source

SetAccumulatedRewardPerDepositX128 sets the accumulated reward per deposit (Q128) of the reward manager.

func SetAccumulatedTime

method on RewardManager
1func (rm *RewardManager) SetAccumulatedTime(time int64)
source

SetAccumulatedTime sets the accumulated time of the reward manager.

func SetDistributeAmountPerSecondX128

method on RewardManager
1func (rm *RewardManager) SetDistributeAmountPerSecondX128(amount *u256.Uint)
source

SetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the reward manager.

func SetDistributeEndTime

method on RewardManager
1func (rm *RewardManager) SetDistributeEndTime(time int64)
source

SetDistributeEndTime sets the distribute end time of the reward manager.

func SetDistributeStartTime

method on RewardManager
1func (rm *RewardManager) SetDistributeStartTime(time int64)
source

SetDistributeStartTime sets the distribute start time of the reward manager.

func SetReward

method on RewardManager
1func (rm *RewardManager) SetReward(depositID string, rewardState *RewardState)
source

func SetRewardClaimableDuration

method on RewardManager
1func (rm *RewardManager) SetRewardClaimableDuration(duration int64)
source

SetRewardClaimableDuration sets the reward claimable duration of the reward manager.

func SetRewards

method on RewardManager
1func (rm *RewardManager) SetRewards(rewards *bptree.BPTree)
source

SetRewards sets the rewards tree of the reward manager.

func SetTotalClaimedAmount

method on RewardManager
1func (rm *RewardManager) SetTotalClaimedAmount(amount int64)
source

SetTotalClaimedAmount sets the total claimed amount of the reward manager.

func SetTotalDistributeAmount

method on RewardManager
1func (rm *RewardManager) SetTotalDistributeAmount(amount int64)
source

SetTotalDistributeAmount sets the total distribute amount of the reward manager.

func TotalClaimedAmount

method on RewardManager
1func (rm *RewardManager) TotalClaimedAmount() int64
source

TotalClaimedAmount returns the total claimed amount of the reward manager.

func TotalDistributeAmount

method on RewardManager
1func (rm *RewardManager) TotalDistributeAmount() int64
source

TotalDistributeAmount returns the total distribute amount of the reward manager.

type RewardState

struct
 1type RewardState struct {
 2	priceDebtX128 *u256.Uint // price debt per GNS stake, Q128
 3	claimableTime int64      // time when reward can be claimed
 4
 5	depositAmount           int64 // amount of GNS staked
 6	distributeStartTime     int64 // time when launchpad started staking
 7	distributeEndTime       int64 // end time of reward calculation
 8	accumulatedRewardAmount int64 // calculated, not collected
 9	accumulatedTime         int64 // last time when reward was calculated
10	claimedAmount           int64 // amount of reward claimed so far
11}
source

RewardState represents the state of a reward for a deposit. It contains the necessary data to manage and distribute rewards for a specific deposit.

Methods on RewardState

func AccumulatedRewardAmount

method on RewardState
1func (rs *RewardState) AccumulatedRewardAmount() int64
source

AccumulatedRewardAmount returns the accumulated reward amount of the reward state.

func AccumulatedTime

method on RewardState
1func (rs *RewardState) AccumulatedTime() int64
source

AccumulatedTime returns the accumulated time of the reward state.

func ClaimableTime

method on RewardState
1func (rs *RewardState) ClaimableTime() int64
source

ClaimableTime returns the claimable time of the reward state.

func ClaimedAmount

method on RewardState
1func (rs *RewardState) ClaimedAmount() int64
source

ClaimedAmount returns the claimed amount of the reward state.

func Clone

method on RewardState
1func (rs RewardState) Clone() *RewardState
source

func DepositAmount

method on RewardState
1func (rs *RewardState) DepositAmount() int64
source

DepositAmount returns the deposit amount of the reward state.

func DistributeEndTime

method on RewardState
1func (rs *RewardState) DistributeEndTime() int64
source

DistributeEndTime returns the distribute end time of the reward state.

func DistributeStartTime

method on RewardState
1func (rs *RewardState) DistributeStartTime() int64
source

DistributeStartTime returns the distribute start time of the reward state.

func PriceDebtX128

method on RewardState
1func (rs *RewardState) PriceDebtX128() *u256.Uint
source

PriceDebtX128 returns the price debt (Q128) of the reward state.

func SetAccumulatedRewardAmount

method on RewardState
1func (rs *RewardState) SetAccumulatedRewardAmount(amount int64)
source

SetAccumulatedRewardAmount sets the accumulated reward amount of the reward state.

func SetAccumulatedTime

method on RewardState
1func (rs *RewardState) SetAccumulatedTime(time int64)
source

SetAccumulatedTime sets the accumulated time of the reward state.

func SetClaimableTime

method on RewardState
1func (rs *RewardState) SetClaimableTime(time int64)
source

SetClaimableTime sets the claimable time of the reward state.

func SetClaimedAmount

method on RewardState
1func (rs *RewardState) SetClaimedAmount(amount int64)
source

SetClaimedAmount sets the claimed amount of the reward state.

func SetDepositAmount

method on RewardState
1func (rs *RewardState) SetDepositAmount(amount int64)
source

SetDepositAmount sets the deposit amount of the reward state.

func SetDistributeEndTime

method on RewardState
1func (rs *RewardState) SetDistributeEndTime(time int64)
source

SetDistributeEndTime sets the distribute end time of the reward state.

func SetDistributeStartTime

method on RewardState
1func (rs *RewardState) SetDistributeStartTime(time int64)
source

SetDistributeStartTime sets the distribute start time of the reward state.

func SetPriceDebtX128

method on RewardState
1func (rs *RewardState) SetPriceDebtX128(debt *u256.Uint)
source

SetPriceDebtX128 sets the price debt (Q128) of the reward state.

type StoreKey

ident
1type StoreKey string
source

Methods on StoreKey

func String

method on StoreKey
1func (s StoreKey) String() string
source

Imports 10

Source Files 18

Directories 1