Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize grants thresholds and duration per tier #139

Merged
merged 4 commits into from Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion .env.example
Expand Up @@ -26,13 +26,23 @@ GATSBY_DISCOURSE_USER=dao
GATSBY_DISCOURSE_API=https://forum.decentraland.org
DISCOURSE_API_KEY=

# Requiref voting power to pass a proposal by type
# Required voting power to pass a proposal by type
GATSBY_VOTING_POWER_TO_PASS_GRANT=0
GATSBY_VOTING_POWER_TO_PASS_CATALYST=0
GATSBY_VOTING_POWER_TO_PASS_BAN_NAME=0
GATSBY_VOTING_POWER_TO_PASS_POI=0
GATSBY_VOTING_POWER_TO_PASS_POLL=0

# Override VP for Grant Tires, defaults to GATSBY_VOTING_POWER_TO_PASS_GRANT
GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER4 = 600
GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER5 = 700
GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER6 = 800

# Override Duration for Grant Tires, defaults to GATSBY_SNAPSHOT_DURATION
GATSBY_DURATION_GRANT_TIER4 = 1200
GATSBY_DURATION_GRANT_TIER5 = 1200
GATSBY_DURATION_GRANT_TIER6 = 1200

# Segment integration
GATSBY_SEGMENT_KEY=

Expand Down
8 changes: 7 additions & 1 deletion Pulumi.website-dao-dev.yml
Expand Up @@ -27,9 +27,15 @@ config:
website-dao:GATSBY_SNAPSHOT_URL: https://snapshot.org/
website-dao:GATSBY_VOTING_POWER_TO_PASS_BAN_NAME: "10000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_CATALYST: "10000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT: "10000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_POI: "10000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_POLL: "0"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT: "10000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER4: "600"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER5: "700"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER6: "800"
website-dao:GATSBY_DURATION_GRANT_TIER4: "1200"
website-dao:GATSBY_DURATION_GRANT_TIER5: "1200"
website-dao:GATSBY_DURATION_GRANT_TIER6: "1200"
website-dao:SNAPSHOT_PRIVATE_KEY:
secure: v1:7NFT72GUXbMf02Vk:5V+Z/QxPQkWUpMzzCwDfYiOtzsa7c16JuMymd8gL/GWfc2+cwtLWDktnzUXZK42q9zRjd7deYNTChkZpWKdlQpW6Q6tQd2j9ze4Iq2Lnk2M=
website-dao:USE_PUBLIC_TLD: "false"
8 changes: 7 additions & 1 deletion Pulumi.website-dao-prd.yml
Expand Up @@ -27,9 +27,15 @@ config:
website-dao:GATSBY_SNAPSHOT_URL: https://snapshot.org/
website-dao:GATSBY_VOTING_POWER_TO_PASS_BAN_NAME: "500000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_CATALYST: "500000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT: "1000000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_POI: "500000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_POLL: "0"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT: "1000000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER4: "2000000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER5: "4000000"
website-dao:GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER6: "8000000"
website-dao:GATSBY_DURATION_GRANT_TIER4: "1209600"
website-dao:GATSBY_DURATION_GRANT_TIER5: "1209600"
website-dao:GATSBY_DURATION_GRANT_TIER6: "1209600"
website-dao:SNAPSHOT_PRIVATE_KEY:
secure: v1:NCALHJc3wgvqdspj:vZ5nu/emrqARzgCo/nkJ6XsGvHdEHaYzBwSj3UpJu+ZdNuy4M4W0ruHyJ12U0KOXTAvi5+vWXJYGeW5tvzLVubYAT7hEXuhVtHYb6QKyyPg=
website-dao:USE_PUBLIC_TLD: "true"
17 changes: 14 additions & 3 deletions src/entities/Proposal/routes.ts
Expand Up @@ -29,6 +29,8 @@ import {
updateProposalStatusScheme,
newProposalBanNameScheme,
ProposalRequiredVP,
GrantRequiredVP,
GrantDuration,
INVALID_PROPOSAL_POLL_OPTIONS
} from './types';
import RequestError from 'decentraland-gatsby/dist/entities/Route/error';
Expand Down Expand Up @@ -132,6 +134,10 @@ export async function getProposals(req: WithAuth<Request>) {
return { ok: true, total, data }
}

function proposalDuration(duration: number){
return Time.utc().set('seconds', 0).add(duration, 'seconds').toDate()
}

const newProposalPollValidator = schema.compile(newProposalPollScheme)
export async function createProposalPoll(req: WithAuth) {
const user = req.auth!
Expand All @@ -147,6 +153,7 @@ export async function createProposalPoll(req: WithAuth) {
user,
type: ProposalType.Poll,
required_to_pass: ProposalRequiredVP[ProposalType.Poll],
finish_at: proposalDuration(SNAPSHOT_DURATION),
configuration,
})
}
Expand All @@ -169,6 +176,7 @@ export async function createProposalBanName(req: WithAuth) {
user,
type: ProposalType.BanName,
required_to_pass: ProposalRequiredVP[ProposalType.BanName],
finish_at: proposalDuration(SNAPSHOT_DURATION),
configuration: {
...configuration,
choices: DEFAULT_CHOICES
Expand All @@ -194,6 +202,7 @@ export async function createProposalPOI(req: WithAuth) {
user,
type: ProposalType.POI,
required_to_pass: ProposalRequiredVP[ProposalType.POI],
finish_at: proposalDuration(SNAPSHOT_DURATION),
configuration: {
...configuration,
choices: DEFAULT_CHOICES
Expand All @@ -214,6 +223,7 @@ export async function createProposalCatalyst(req: WithAuth) {
user,
type: ProposalType.Catalyst,
required_to_pass: ProposalRequiredVP[ProposalType.Catalyst],
finish_at: proposalDuration(SNAPSHOT_DURATION),
configuration: {
...configuration,
choices: DEFAULT_CHOICES
Expand All @@ -229,19 +239,20 @@ export async function createProposalGrant(req: WithAuth) {
return createProposal({
user,
type: ProposalType.Grant,
required_to_pass: ProposalRequiredVP[ProposalType.Grant],
required_to_pass: GrantRequiredVP[configuration.tier],
finish_at: proposalDuration(GrantDuration[configuration.tier]),
configuration: {
...configuration,
choices: DEFAULT_CHOICES
},
})
}

export async function createProposal(data: Pick<ProposalAttributes, 'type' | 'user' | 'configuration' | 'required_to_pass'>) {
export async function createProposal(data: Pick<ProposalAttributes, 'type' | 'user' | 'configuration' | 'required_to_pass' | 'finish_at'>) {
const id = uuid()
const address = SNAPSHOT_ADDRESS
const start = Time.utc().set('seconds', 0)
const end = Time.utc(start).add(SNAPSHOT_DURATION, 'seconds')
const end = data.finish_at
const proposal_url = proposalUrl({ id })
const title = await templates.title({ type: data.type, configuration: data.configuration })
const description = await templates.description({ type: data.type, configuration: data.configuration })
Expand Down
37 changes: 29 additions & 8 deletions src/entities/Proposal/types.ts
Expand Up @@ -102,14 +102,6 @@ function requiredVotingPower(value: string | undefined | null, defaultValue: num
return defaultValue
}

export const ProposalRequiredVP = {
[ProposalType.Grant]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_GRANT, 0),
[ProposalType.Catalyst]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_CATALYST, 0),
[ProposalType.BanName]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_BAN_NAME, 0),
[ProposalType.POI]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_POI, 0),
[ProposalType.Poll]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_POLL, 0),
}

export type UpdateProposalStatusProposal = {
status:
| ProposalStatus.Rejected
Expand Down Expand Up @@ -299,6 +291,35 @@ export function isProposalGrantTier(value: string | null | undefined): boolean
}
}

export const ProposalRequiredVP = {
[ProposalType.Grant]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_GRANT, 0),
[ProposalType.Catalyst]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_CATALYST, 0),
[ProposalType.BanName]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_BAN_NAME, 0),
[ProposalType.POI]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_POI, 0),
[ProposalType.Poll]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_POLL, 0),
}

export const GrantRequiredVP = {
[ProposalGrantTier.Tier1]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER1, ProposalRequiredVP[ProposalType.Grant]),
[ProposalGrantTier.Tier2]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER2, ProposalRequiredVP[ProposalType.Grant]),
[ProposalGrantTier.Tier3]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER3, ProposalRequiredVP[ProposalType.Grant]),
[ProposalGrantTier.Tier4]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER4, ProposalRequiredVP[ProposalType.Grant]),
[ProposalGrantTier.Tier5]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER5, ProposalRequiredVP[ProposalType.Grant]),
[ProposalGrantTier.Tier6]: requiredVotingPower(process.env.GATSBY_VOTING_POWER_TO_PASS_GRANT_TIER6, ProposalRequiredVP[ProposalType.Grant]),
}

function grantDuration(value: string | undefined | null) {
return Number(value || process.env.GATSBY_SNAPSHOT_DURATION);
}
export const GrantDuration = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the first 3 env variables for the first 3 tiers should be dao:GATSBY_SNAPSHOT_DURATION, or else the values should be added to the.yml & .env files

[ProposalGrantTier.Tier1]: grantDuration(process.env.GATSBY_DURATION_GRANT_TIER1),
[ProposalGrantTier.Tier2]: grantDuration(process.env.GATSBY_DURATION_GRANT_TIER2),
[ProposalGrantTier.Tier3]: grantDuration(process.env.GATSBY_DURATION_GRANT_TIER3),
[ProposalGrantTier.Tier4]: grantDuration(process.env.GATSBY_DURATION_GRANT_TIER4),
[ProposalGrantTier.Tier5]: grantDuration(process.env.GATSBY_DURATION_GRANT_TIER5),
[ProposalGrantTier.Tier6]: grantDuration(process.env.GATSBY_DURATION_GRANT_TIER6),
}

export type NewProposalGrant = {
title: string,
abstract: string,
Expand Down