From 8591bd7ca95a2c205e4ad76cfd585d9fa22de448 Mon Sep 17 00:00:00 2001 From: Leonn Leite Date: Wed, 5 Nov 2025 18:50:37 -0300 Subject: [PATCH] Validate fee allocation percentages in finaliseSale --- src/chaincode/launchpad/finaliseSale.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/chaincode/launchpad/finaliseSale.ts b/src/chaincode/launchpad/finaliseSale.ts index 8ab7d31..f1dcfe8 100644 --- a/src/chaincode/launchpad/finaliseSale.ts +++ b/src/chaincode/launchpad/finaliseSale.ts @@ -51,9 +51,13 @@ export async function finalizeSale(ctx: GalaChainContext, sale: LaunchpadSale): throw new PreConditionFailedError("Platform fee configuration is yet to be defined."); } - const platformFeePercentage = feeAllocation ? feeAllocation.platformFeePercentage : 0.01; - const ownerAllocationPercentage = feeAllocation ? feeAllocation.ownerAllocationPercentage : 0.05; - const liquidityAllocationPercentage = feeAllocation ? feeAllocation.liquidityAllocationPercentage : 0.94; + const platformFeePercentage = feeAllocation?.platformFeePercentage; + const ownerAllocationPercentage = feeAllocation?.ownerAllocationPercentage; + const liquidityAllocationPercentage = feeAllocation?.liquidityAllocationPercentage; + + if (!platformFeePercentage || !ownerAllocationPercentage || !liquidityAllocationPercentage) { + throw new PreConditionFailedError("Fee allocation percentages are not properly configured."); + } const nativeToken = sale.fetchNativeTokenInstanceKey(); const memeToken = sale.fetchSellingTokenInstanceKey();