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

[QN] CRT constraints proposal support #5124

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions query-node/mappings/src/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
UpdateWorkingGroupBudgetProposalDetails,
VetoProposalDetails,
DecreaseCouncilBudgetProposalDetails,
UpdateTokenPalletTokenConstraintsProposalDetails,
} from 'query-node/dist/model'
import {
INT32MAX,
Expand All @@ -83,7 +84,6 @@ import {
ProposalsEngine_ProposalStatusUpdatedEvent_V1001 as ProposalStatusUpdatedEvent_V1001,
ProposalsEngine_VotedEvent_V1001 as ProposalVotedEvent_V1001,
} from '../generated/types'
import { PalletProposalsCodexProposalDetails as RuntimeProposalDetails_V2002 } from '../generated/types/2002/types-lookup'
import { PalletProposalsCodexProposalDetails as RuntimeProposalDetails_V2003 } from '../generated/types/2003/types-lookup'

import { createWorkingGroupOpeningMetadata } from './workingGroups'
Expand Down Expand Up @@ -320,7 +320,7 @@ async function parseProposalDetails(
// RuntimeProposalDetails
else if (proposalDetails.isSetPalletFozenStatus) {
const details = new UpdatePalletFrozenStatusProposalDetails()
const [frozen, pallet] = (proposalDetails as RuntimeProposalDetails_V2002).asSetPalletFozenStatus
const [frozen, pallet] = proposalDetails.asSetPalletFozenStatus
details.frozen = frozen.isTrue
details.pallet = pallet.toString()
return details
Expand All @@ -329,6 +329,23 @@ async function parseProposalDetails(
else if (proposalDetails.isDecreaseCouncilBudget) {
const details = new DecreaseCouncilBudgetProposalDetails()
details.amount = new BN(proposalDetails.asDecreaseCouncilBudget.toString())
return details
}
// UpdateTokenPalletTokenConstraints
else if (proposalDetails.isUpdateTokenPalletTokenConstraints) {
const details = new UpdateTokenPalletTokenConstraintsProposalDetails()
const specificDetails = proposalDetails.asUpdateTokenPalletTokenConstraints

details.maxYearlyRate = unwrap(specificDetails.maxYearlyRate)?.toNumber()
details.minAmmSlope = whenDef(unwrap(specificDetails.minAmmSlope), asBN)
details.minSaleDuration = unwrap(specificDetails.minSaleDuration)?.toNumber()
details.minRevenueSplitDuration = unwrap(specificDetails.minRevenueSplitDuration)?.toNumber()
details.minRevenueSplitTimeToStart = unwrap(specificDetails.minRevenueSplitTimeToStart)?.toNumber()
details.salePlatformFee = unwrap(specificDetails.salePlatformFee)?.toNumber()
details.ammBuyTxFees = unwrap(specificDetails.ammBuyTxFees)?.toNumber()
details.ammSellTxFees = unwrap(specificDetails.ammSellTxFees)?.toNumber()
details.bloatBond = whenDef(unwrap(specificDetails.bloatBond), asBN)

return details
} else {
unimplementedError(`Unsupported proposal details type: ${proposalDetails.type}`)
Expand Down
30 changes: 30 additions & 0 deletions query-node/schemas/proposals.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,35 @@ type DecreaseCouncilBudgetProposalDetails @variant {
amount: BigInt!
}

type UpdateTokenPalletTokenConstraintsProposalDetails @variant {
"Proposed maximum patronage yearly interest rate (in part per million)"
maxYearlyRate: Int

"Proposed minimum value of the slope amm parameter"
minAmmSlope: BigInt

"Proposed minimum block duration of sales"
minSaleDuration: Int

"Proposed minimum block duration for a revenue split"
minRevenueSplitDuration: Int

"Proposed minimum blocks between revenue share issuance block and actual revenue share starting block"
minRevenueSplitTimeToStart: Int

"Proposed platform fee ratio charged on top of each sale and burned (in part per million)"
salePlatformFee: Int

"Proposed ratio of fees charged on top of each token purchase from the AMM (in part per million)"
ammBuyTxFees: Int

"Proposed ratio of fees charged on top of each token sold to the AMM (in part per million)"
ammSellTxFees: Int

"Proposed bloat bond value used during account creation"
bloatBond: BigInt
}

union ProposalDetails =
SignalProposalDetails
| RuntimeUpgradeProposalDetails
Expand All @@ -378,3 +407,4 @@ union ProposalDetails =
| UpdatePalletFrozenStatusProposalDetails
| UpdateGlobalNftLimitProposalDetails
| DecreaseCouncilBudgetProposalDetails
| UpdateTokenPalletTokenConstraintsProposalDetails
Loading