Skip to content

Commit

Permalink
Add positionId to OmniFormView and use it in useOmniProductTypeTransi…
Browse files Browse the repository at this point in the history
…tion (#3748)

* Add positionId to OmniFormView and use it in useOmniProductTypeTransition

* Remove debug console.log statements

* Update resolvedId to openFlowResolvedDpmId
  • Loading branch information
marcinciarka authored Apr 2, 2024
1 parent 9f9779a commit cecb745
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion features/omni-kit/contexts/OmniProductContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function OmniProductContextProvider({
simulation: simulation?.position,
},
isSimulationLoading,
resolvedId: positionIdFromDpmProxyData,
openFlowResolvedDpmId: positionIdFromDpmProxyData,
positionAuction,
swap: {
current: formatSwapData({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface GetOmniAutomationSidebarPrimaryButtonActionsParams {
pseudoProtocol?: string
quoteAddress: string
quoteToken: string
resolvedId?: string
openFlowResolvedDpmId?: string
shouldSwitchNetwork: boolean
walletAddress?: string
}
Expand All @@ -50,7 +50,7 @@ export function getOmniAutomationSidebarPrimaryButtonActions({
pseudoProtocol,
quoteAddress,
quoteToken,
resolvedId,
openFlowResolvedDpmId,
shouldSwitchNetwork,
walletAddress,
}: GetOmniAutomationSidebarPrimaryButtonActionsParams) {
Expand All @@ -67,7 +67,7 @@ export function getOmniAutomationSidebarPrimaryButtonActions({
isPoolOracless: isOracless,
label,
networkName: network.name,
positionId: resolvedId,
positionId: openFlowResolvedDpmId,
productType,
protocol,
pseudoProtocol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface GetOmniSidebarPrimaryButtonActionsParams {
pseudoProtocol?: string
quoteAddress: string
quoteToken: string
resolvedId?: string
openFlowResolvedDpmId?: string
shouldSwitchNetwork: boolean
walletAddress?: string
}
Expand Down Expand Up @@ -58,7 +58,7 @@ export function getOmniSidebarPrimaryButtonActions({
pseudoProtocol,
quoteAddress,
quoteToken,
resolvedId,
openFlowResolvedDpmId,
shouldSwitchNetwork,
walletAddress,
}: GetOmniSidebarPrimaryButtonActionsParams) {
Expand All @@ -75,7 +75,7 @@ export function getOmniSidebarPrimaryButtonActions({
isPoolOracless: isOracless,
label,
networkName: network.name,
positionId: resolvedId,
positionId: openFlowResolvedDpmId,
productType,
protocol,
pseudoProtocol,
Expand Down
2 changes: 1 addition & 1 deletion features/omni-kit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ interface ProductContextPosition<Position, Auction> {
cached?: OmniSimulationSwap
}
isSimulationLoading?: boolean
resolvedId?: string
openFlowResolvedDpmId?: string
setCachedPosition: (positionSet: OmniPositionSet<OmniGenericPosition>) => void
setIsLoadingSimulation: Dispatch<SetStateAction<boolean>>
setSimulation: Dispatch<SetStateAction<OmniSimulationData<OmniGenericPosition> | undefined>>
Expand Down
4 changes: 2 additions & 2 deletions features/omni-kit/views/OmniAutomationFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function OmniAutomationFormView({
setSimulation,
setCachedOrderInfoItems,
},
position: { resolvedId },
position: { openFlowResolvedDpmId },
dynamicMetadata: {
featureToggles: { suppressValidation, safetySwitch },
validations: { isFormFrozen },
Expand Down Expand Up @@ -147,7 +147,7 @@ export function OmniAutomationFormView({
quoteAddress,
quoteToken,
shouldSwitchNetwork,
resolvedId,
openFlowResolvedDpmId,
walletAddress,
})
const textButtonAction = () => {
Expand Down
11 changes: 6 additions & 5 deletions features/omni-kit/views/OmniFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function OmniFormView({
quoteToken,
settings,
shouldSwitchNetwork,
positionId,
},
steps: {
currentStep,
Expand All @@ -86,7 +87,7 @@ export function OmniFormView({
} = useOmniGeneralContext()
const {
form: { dispatch, state },
position: { isSimulationLoading, resolvedId },
position: { isSimulationLoading, openFlowResolvedDpmId },
dynamicMetadata: {
elements: { sidebarContent },
featureToggles: { suppressValidation, safetySwitch },
Expand Down Expand Up @@ -157,7 +158,7 @@ export function OmniFormView({
transitionHandler,
} = useOmniProductTypeTransition({
action: state.action,
positionId: resolvedId,
positionId: positionId || openFlowResolvedDpmId,
protocol,
productType,
tokenPair: `${collateralToken}-${quoteToken}`,
Expand Down Expand Up @@ -234,7 +235,7 @@ export function OmniFormView({
quoteAddress,
quoteToken,
shouldSwitchNetwork,
resolvedId,
openFlowResolvedDpmId,
walletAddress,
})
const textButtonAction = () => {
Expand Down Expand Up @@ -262,9 +263,9 @@ export function OmniFormView({
<Grid gap={3}>
{sidebarContent}
{children}
{OmniKitDebug && resolvedId && (
{OmniKitDebug && openFlowResolvedDpmId && (
<VaultChangesInformationContainer title="DPM debug data">
<VaultChangesInformationItem label="DPM ID" value={resolvedId} />
<VaultChangesInformationItem label="DPM ID" value={openFlowResolvedDpmId} />
<VaultChangesInformationItem
label="Address"
value={
Expand Down

0 comments on commit cecb745

Please sign in to comment.