Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix refinance target protocol selection and flow issues #4036

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ export const RefinanceProductTableStep = () => {
perPage={refinanceProductHubItemsPerPage}
hiddenBanners
initialFilters={{
protocol: [
lendingProtocol === LendingProtocol.SparkV3
? LendingProtocol.AaveV3
: LendingProtocol.SparkV3,
],
protocol: lendingProtocol === LendingProtocol.SparkV3 ? [LendingProtocol.AaveV3] : [],
network: [network.name],
}}
hiddenColumns={refinanceProductHubHiddenColumns}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function getRefinanceSidebarButtonsStatus({
(isSimulationLoading || isTxInProgress || isTxWaitingForApproval)

const isPrimaryButtonHidden =
!!(walletAddress && !isOwner) ||
(walletAddress && !isOwner) ||
safetySwitch ||
[RefinanceSidebarStep.Option, RefinanceSidebarStep.Strategy].includes(currentStep)

Expand Down
29 changes: 9 additions & 20 deletions features/refinance/hooks/useSdkTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@ export function useSdkRefinanceTransaction({
const [txRefinance, setTxRefinance] = useState<null | Order>(null)

const {
environment: {
slippage,
chainInfo,
marketPrices: { ethPrice },
address,
},
position: { positionId, collateralTokenData, debtTokenData, positionType, lendingProtocol },
poolData: { poolId },
environment: { chainInfo, address },
position: { lendingProtocol },
form: {
state: { strategy, dpm },
state: { dpm },
},
steps: { currentStep },
} = useRefinanceContext()
Expand All @@ -43,7 +37,11 @@ export function useSdkRefinanceTransaction({
}, [currentStep])

useEffect(() => {
if (!strategy || !dpm?.address || refinanceSimulation == null) {
if (
!dpm?.address ||
refinanceSimulation == null ||
(lendingProtocol === LendingProtocol.Maker && importPositionSimulation == null)
) {
return
}
const fetchData = async () => {
Expand Down Expand Up @@ -87,18 +85,9 @@ export function useSdkRefinanceTransaction({
}, [
sdk,
dpm?.address,
slippage,
ethPrice,
address,
chainInfo,
poolId,
positionId,
JSON.stringify(collateralTokenData),
JSON.stringify(debtTokenData),
positionType,
strategy?.product,
strategy?.primaryToken,
strategy?.secondaryToken,
lendingProtocol,
JSON.stringify(importPositionSimulation),
JSON.stringify(refinanceSimulation),
])
Expand Down
18 changes: 10 additions & 8 deletions features/refinance/views/RefinanceFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,19 @@ export const RefinanceFormView: FC = ({ children }) => {
txDetails,
})

const primaryButton = {
label: t(primaryButtonLabel),
disabled: isPrimaryButtonDisabled,
isLoading: isPrimaryButtonLoading,
hidden: isPrimaryButtonHidden,
withoutNextLink: true,
...primaryButtonActions,
}

const sidebarSectionProps: SidebarSectionProps = {
title: sidebarTitle,
content: <Grid gap={3}>{children}</Grid>,
primaryButton: {
label: t(primaryButtonLabel),
disabled: isPrimaryButtonDisabled,
isLoading: isPrimaryButtonLoading,
hidden: isPrimaryButtonHidden,
withoutNextLink: true,
...primaryButtonActions,
},
primaryButton,
status,
withMobilePanel: false,
disableMaxHeight: currentStep === RefinanceSidebarStep.Strategy,
Expand Down
Loading