Skip to content

Commit

Permalink
improve: unit accurate pricing
Browse files Browse the repository at this point in the history
Signed-off-by: james-a-morris <[email protected]>
  • Loading branch information
james-a-morris committed Jan 22, 2025
1 parent 5f819fc commit 01a1443
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/utils/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ export type GetBridgeFeesResult = BridgeFees & {
isAmountTooLow: boolean;
};

/**
*
*/
export async function getBridgeFeesWithExternalProjectId(
externalProjectId: string,
args: GetBridgeFeesArgs
Expand Down
12 changes: 7 additions & 5 deletions src/views/Bridge/hooks/useBridgeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
hyperLiquidBridge2Address,
externalProjectNameToId,
generateHyperLiquidPayload,
fixedPointAdjustment,
} from "utils";
import { TransferQuote } from "./useTransferQuote";
import { SelectedRoute } from "../utils";
Expand Down Expand Up @@ -127,11 +128,12 @@ export function useBridgeAction(
// 4. We must construct a payload to send to HL's Bridge2 contract
// 5. The user must sign this signature

// Estimated fee for this HL deposit. Sum of the fees plus a 2 unit buffer
const estimatedFee = frozenFeeQuote.relayerCapitalFee.total
.add(frozenFeeQuote.lpFee.total)
.add(frozenFeeQuote.relayerGasFee.total);
const amount = frozenDepositArgs.amount.sub(estimatedFee).sub(2);
// Subtract the relayer fee pct just like we do for our output token amount
const amount = frozenDepositArgs.amount.sub(
frozenDepositArgs.amount
.mul(frozenDepositArgs.relayerFeePct)
.div(fixedPointAdjustment)
);

// Build the payload
const hyperLiquidPayload = await generateHyperLiquidPayload(
Expand Down

0 comments on commit 01a1443

Please sign in to comment.