From a691c70ff4f21a589663de1edc996e5a6457b579 Mon Sep 17 00:00:00 2001 From: james-a-morris Date: Fri, 10 Jan 2025 12:02:47 -0500 Subject: [PATCH] improve: hone in the fees Signed-off-by: james-a-morris --- src/views/Bridge/hooks/useBridgeAction.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/views/Bridge/hooks/useBridgeAction.ts b/src/views/Bridge/hooks/useBridgeAction.ts index 83a5ad45a..27a027fe3 100644 --- a/src/views/Bridge/hooks/useBridgeAction.ts +++ b/src/views/Bridge/hooks/useBridgeAction.ts @@ -125,8 +125,13 @@ export function useBridgeAction( // 4. We must construct a payload to send to HL's Bridge2 contract // 5. The user must sign this signature - // For now let's assume a 2% loss in the amount - const amount = frozenDepositArgs.amount.mul(98).div(100); + // Estimated fee for this HL deposit. Sum of the relayer capital fee, + // the lp fee, and 2x the relayer gas fee. + const estimatedFee = frozenFeeQuote.relayerCapitalFee.total + .add(frozenFeeQuote.lpFee.total) + .add(frozenFeeQuote.relayerGasFee.total.mul(2)); + + const amount = frozenDepositArgs.amount.sub(estimatedFee); // Build the payload const hyperLiquidPayload = await generateHyperLiquidPayload(