Skip to content

Commit

Permalink
Merge pull request #5124 from thesan/feature/crt-constraints-proposal-qn
Browse files Browse the repository at this point in the history
[QN] CRT constraints proposal support
  • Loading branch information
mnaamani committed Apr 8, 2024
2 parents a4625f2 + a8ca676 commit 0d97754
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
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

0 comments on commit 0d97754

Please sign in to comment.