From 71ef0d4a8daed3a4926f23eecbe7158c81e54fb5 Mon Sep 17 00:00:00 2001 From: Theophile Sandoz Date: Fri, 29 Mar 2024 10:37:22 +0100 Subject: [PATCH 1/3] Add UpdateTokenPalletTokenConstraintsProposalDetails mappings --- query-node/mappings/src/proposals.ts | 21 +++++++++++++++++++-- query-node/schemas/proposals.graphql | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/query-node/mappings/src/proposals.ts b/query-node/mappings/src/proposals.ts index 5441144364..b1f29692d2 100644 --- a/query-node/mappings/src/proposals.ts +++ b/query-node/mappings/src/proposals.ts @@ -61,6 +61,7 @@ import { UpdateWorkingGroupBudgetProposalDetails, VetoProposalDetails, DecreaseCouncilBudgetProposalDetails, + UpdateTokenPalletTokenConstraintsProposalDetails, } from 'query-node/dist/model' import { INT32MAX, @@ -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' @@ -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 @@ -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 = unwrap(specificDetails.minAmmSlope)?.toBn() + 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 = unwrap(specificDetails.bloatBond)?.toBn() + return details } else { unimplementedError(`Unsupported proposal details type: ${proposalDetails.type}`) diff --git a/query-node/schemas/proposals.graphql b/query-node/schemas/proposals.graphql index 0a253dbde1..c425cf1100 100644 --- a/query-node/schemas/proposals.graphql +++ b/query-node/schemas/proposals.graphql @@ -352,6 +352,27 @@ type DecreaseCouncilBudgetProposalDetails @variant { amount: BigInt! } +type UpdateTokenPalletTokenConstraintsProposalDetails @variant { + " (Permill)" + maxYearlyRate: Int + "" + minAmmSlope: BigInt + "" + minSaleDuration: Int + "" + minRevenueSplitDuration: Int + "" + minRevenueSplitTimeToStart: Int + " (Permill)" + salePlatformFee: Int + " (Permill)" + ammBuyTxFees: Int + " (Permill)" + ammSellTxFees: Int + "" + bloatBond: BigInt +} + union ProposalDetails = SignalProposalDetails | RuntimeUpgradeProposalDetails @@ -378,3 +399,4 @@ union ProposalDetails = | UpdatePalletFrozenStatusProposalDetails | UpdateGlobalNftLimitProposalDetails | DecreaseCouncilBudgetProposalDetails + | UpdateTokenPalletTokenConstraintsProposalDetails From d1c0e887868eaa8e8de36fd63a143688464c904a Mon Sep 17 00:00:00 2001 From: Theophile Sandoz Date: Fri, 29 Mar 2024 12:19:36 +0100 Subject: [PATCH 2/3] Add fields description --- query-node/schemas/proposals.graphql | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/query-node/schemas/proposals.graphql b/query-node/schemas/proposals.graphql index c425cf1100..cbce2459e6 100644 --- a/query-node/schemas/proposals.graphql +++ b/query-node/schemas/proposals.graphql @@ -353,23 +353,31 @@ type DecreaseCouncilBudgetProposalDetails @variant { } type UpdateTokenPalletTokenConstraintsProposalDetails @variant { - " (Permill)" + "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 - " (Permill)" + + "Proposed platform fee ratio charged on top of each sale and burned (in part per million)" salePlatformFee: Int - " (Permill)" + + "Proposed ratio of fees charged on top of each token purchase from the AMM (in part per million)" ammBuyTxFees: Int - " (Permill)" + + "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 } From a8ca67609d82e268815112c4dfc57f34c2d7ddae Mon Sep 17 00:00:00 2001 From: Theophile Sandoz Date: Wed, 3 Apr 2024 11:18:04 +0200 Subject: [PATCH 3/3] Fix the BN conversions --- query-node/mappings/src/proposals.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/query-node/mappings/src/proposals.ts b/query-node/mappings/src/proposals.ts index b1f29692d2..47b9472ad5 100644 --- a/query-node/mappings/src/proposals.ts +++ b/query-node/mappings/src/proposals.ts @@ -337,14 +337,14 @@ async function parseProposalDetails( const specificDetails = proposalDetails.asUpdateTokenPalletTokenConstraints details.maxYearlyRate = unwrap(specificDetails.maxYearlyRate)?.toNumber() - details.minAmmSlope = unwrap(specificDetails.minAmmSlope)?.toBn() + 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 = unwrap(specificDetails.bloatBond)?.toBn() + details.bloatBond = whenDef(unwrap(specificDetails.bloatBond), asBN) return details } else {