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

Pass default ticks #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -23,6 +23,10 @@ export interface WidgetProps {
chainId: number;
networkChainId: number;

defaultTickLower?: number;
defaultTickUpper?: number;
defaultInputAmount?: string;

poolAddress: string;
positionId?: string;
onDismiss: () => void;
Expand All @@ -42,6 +46,9 @@ export default function Widget({
chainId,
networkChainId,

defaultTickLower,
defaultTickUpper,

poolAddress,
positionId,
onDismiss,
Expand Down Expand Up @@ -109,6 +116,8 @@ export default function Widget({
includedSources={includedSources}
excludedSources={excludedSources}
source={source}
defaultTickLower={defaultTickLower}
defaultTickUpper={defaultTickUpper}
>
<div className="ks-lw">
<WidgetContent onDismiss={onDismiss} onTxSubmit={onTxSubmit} />
Expand Down
10 changes: 8 additions & 2 deletions packages/pancake-liquidity-widgets/src/hooks/useZapInState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,17 @@ export const ZapContextProvider = ({
source,
excludedSources,
includedSources,

defaultTickLower,
defaultTickUpper,
}: {
children: ReactNode;
source: string;
includedSources?: string;
excludedSources?: string;

defaultTickLower?: number;
defaultTickUpper?: number;
}) => {
const { pool, poolAddress, position, positionId, feePcm, feeAddress } =
useWidgetInfo();
Expand All @@ -249,10 +255,10 @@ export const ZapContextProvider = ({

const [revertPrice, setRevertPrice] = useState(false);
const [tickLower, setTickLower] = useState<number | null>(
position?.tickLower ?? null
position?.tickLower ?? defaultTickLower ?? null
);
const [tickUpper, setTickUpper] = useState<number | null>(
position?.tickUpper ?? null
position?.tickUpper ?? defaultTickUpper ?? null
);

useEffect(() => {
Expand Down