From 7769557afe78b8a50396976a76cb6cce4a5628c8 Mon Sep 17 00:00:00 2001 From: Kobe Date: Fri, 18 Oct 2024 12:56:54 +0200 Subject: [PATCH] fix: added config for flashloan actionbox platform fee --- .../loop-box/hooks/use-loop-simulation.hooks.ts | 9 +++++++-- .../actions/loop-box/utils/loop-action.utils.ts | 4 +++- .../hooks/use-repay-simulation.hooks.ts | 10 ++++++++-- .../repay-collat-box/utils/repay-action.utils.ts | 6 ++++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/mrgn-ui/src/components/action-box-v2/actions/loop-box/hooks/use-loop-simulation.hooks.ts b/packages/mrgn-ui/src/components/action-box-v2/actions/loop-box/hooks/use-loop-simulation.hooks.ts index 7a55faa347..7fb711fb7f 100644 --- a/packages/mrgn-ui/src/components/action-box-v2/actions/loop-box/hooks/use-loop-simulation.hooks.ts +++ b/packages/mrgn-ui/src/components/action-box-v2/actions/loop-box/hooks/use-loop-simulation.hooks.ts @@ -57,7 +57,11 @@ export function useLoopSimulation({ setIsLoading, setMaxLeverage, }: LoopSimulationProps) { - const [slippageBps, priorityFee] = useActionBoxStore((state) => [state.slippageBps, state.priorityFee]); + const [slippageBps, priorityFee, platformFeeBps] = useActionBoxStore((state) => [ + state.slippageBps, + state.priorityFee, + state.platformFeeBps, + ]); const prevDebouncedAmount = usePrevious(debouncedAmount); const prevDebouncedLeverage = usePrevious(debouncedLeverage); @@ -142,7 +146,8 @@ export function useLoopSimulation({ amount, slippageBps, marginfiClient.provider.connection, - 0 //priorityFee + 0, + platformFeeBps ); if (loopingObject && "loopingTxn" in loopingObject) { diff --git a/packages/mrgn-ui/src/components/action-box-v2/actions/loop-box/utils/loop-action.utils.ts b/packages/mrgn-ui/src/components/action-box-v2/actions/loop-box/utils/loop-action.utils.ts index 218fff02d6..c2c0f345b4 100644 --- a/packages/mrgn-ui/src/components/action-box-v2/actions/loop-box/utils/loop-action.utils.ts +++ b/packages/mrgn-ui/src/components/action-box-v2/actions/loop-box/utils/loop-action.utils.ts @@ -64,7 +64,8 @@ export async function calculateLooping( amount: number, slippageBps: number, connection: Connection, - priorityFee: number + priorityFee: number, + platformFeeBps: number ): Promise { // TODO setup logging again // capture("looper", { @@ -84,6 +85,7 @@ export async function calculateLooping( slippageBps, connection, priorityFee, + platformFeeBps, }); return result; diff --git a/packages/mrgn-ui/src/components/action-box-v2/actions/repay-collat-box/hooks/use-repay-simulation.hooks.ts b/packages/mrgn-ui/src/components/action-box-v2/actions/repay-collat-box/hooks/use-repay-simulation.hooks.ts index 157d6d06d4..d5c22ead0d 100644 --- a/packages/mrgn-ui/src/components/action-box-v2/actions/repay-collat-box/hooks/use-repay-simulation.hooks.ts +++ b/packages/mrgn-ui/src/components/action-box-v2/actions/repay-collat-box/hooks/use-repay-simulation.hooks.ts @@ -53,7 +53,11 @@ export function useRepayCollatSimulation({ setIsLoading, setMaxAmountCollateral, }: RepayCollatSimulationProps) { - const [slippageBps, priorityFee] = useActionBoxStore((state) => [state.slippageBps, state.priorityFee]); + const [slippageBps, priorityFee, platformFeeBps] = useActionBoxStore((state) => [ + state.slippageBps, + state.priorityFee, + state.platformFeeBps, + ]); const prevDebouncedAmount = usePrevious(debouncedAmount); const prevSelectedSecondaryBank = usePrevious(selectedSecondaryBank); @@ -120,7 +124,8 @@ export function useRepayCollatSimulation({ amount, slippageBps, marginfiClient.provider.connection, - 0 //priorityFee + 0, //priorityFee, + platformFeeBps ); if (repayObject && "repayTxn" in repayObject) { @@ -154,6 +159,7 @@ export function useRepayCollatSimulation({ setActionTxns, setSimulationResult, slippageBps, + platformFeeBps, setRepayAmount, setErrorMessage, ] diff --git a/packages/mrgn-ui/src/components/action-box-v2/actions/repay-collat-box/utils/repay-action.utils.ts b/packages/mrgn-ui/src/components/action-box-v2/actions/repay-collat-box/utils/repay-action.utils.ts index 6c52eed4e7..9f41ff1cfd 100644 --- a/packages/mrgn-ui/src/components/action-box-v2/actions/repay-collat-box/utils/repay-action.utils.ts +++ b/packages/mrgn-ui/src/components/action-box-v2/actions/repay-collat-box/utils/repay-action.utils.ts @@ -62,7 +62,8 @@ export async function calculateRepayCollateral( amount: number, slippageBps: number, connection: Connection, - priorityFee: number + priorityFee: number, + platformFeeBps: number ): Promise< | { repayTxn: VersionedTransaction; @@ -89,7 +90,8 @@ export async function calculateRepayCollateral( amount, slippageBps, connection, - priorityFee + priorityFee, + platformFeeBps ); return result;