← Back to Realms

Realm

gno.land/r/gnoswap/launchpad/v2

Overview

Realm Path
gno.land/r/gnoswap/launchpad/v2
Exported Functions
1
State Entries
36
Source Files
22
Total Package Entries
91

Exported Functions

1 exported function

State

36 state entries

Source Code

FILES
assert.gno
go
1package launchpad
2
3import (
4	ufmt "gno.land/p/nt/ufmt/v0"
5	"gno.land/r/gnoswap/launchpad"
6)
7
8// assertIsDepositOwner asserts that the caller is the owner of the deposit.
9// Panics if the caller is not the owner of the deposit.
10func (lp *launchpadV1) assertIsDepositOwner(depositID string, caller address) {
11	deposit, err := lp.getDeposit(depositID)
12	if err != nil {
13		panic(err.Error())
14	}
15
16	if !deposit.IsDepositor(caller) {
17		panic(makeErrorWithDetails(errInvalidOwner, ufmt.Sprintf("(%s)", caller.String())).Error())
18	}
19}
20
21// assertIsValidAmount panics if the amount is zero.
22func assertIsValidAmount(amount int64) {
23	if amount < minimumDepositAmount {
24		panic(makeErrorWithDetails(
25			errInvalidAmount,
26			ufmt.Sprintf("amount(%d) should greater than minimum deposit amount(%d)", amount, minimumDepositAmount),
27		))
28	}
29
30	if (amount % minimumDepositAmount) != 0 {
31		panic(makeErrorWithDetails(
32			errInvalidAmount,
33			ufmt.Sprintf("amount(%d) must be a multiple of 1_000_000", amount),
34		))
35	}
36}
37
38// assertIsDepositNotWithdrawn asserts that the deposit is not withdrawn.
39func assertIsDepositNotWithdrawn(deposit launchpad.Deposit) {
40	if deposit.IsWithdrawn() {
41		panic(makeErrorWithDetails(errAlreadyCollected, ufmt.Sprintf("(%s)", deposit.ID())))
42	}
43}
44
45// assertIsDepositEnded asserts that the deposit is ended.
46func assertIsDepositEnded(deposit launchpad.Deposit, currentTime int64) {
47	if !deposit.IsEnded(currentTime) {
48		panic(makeErrorWithDetails(errNotYetEndedProject, ufmt.Sprintf("(%s)", deposit.ID())))
49	}
50}
51
52// assertHasTierReward asserts that the tier has rewards to distribute.
53// A zero-rate tier cannot settle rewards, which would lock withdrawals.
54func assertHasTierReward(tier *launchpad.ProjectTier) {
55	if tier.DistributeAmountPerSecondX128().IsZero() {
56		panic(makeErrorWithDetails(errNoLeftReward, ufmt.Sprintf("(%s)", tier.ID())))
57	}
58}
59
60// assertHasProject asserts that the caller is the owner of at least one project.
61// Panics if the caller is not the owner of any project.
62func (lp *launchpadV1) assertHasProject(caller address) {
63	if !lp.store.GetProjectRecipients().Has(caller.String()) {
64		panic(makeErrorWithDetails(
65			errInvalidOwner,
66			ufmt.Sprintf("caller %s is not the owner of any project", caller.String()),
67		))
68	}
69}
70
71func assertNotImplementYet() {
72	panic("NotImplementYet")
73}
74

Raw Package Data

Raw JSON data