Skip to content

Commit

Permalink
run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yvesfracari committed Nov 18, 2024
1 parent 16f30ab commit 2bb81aa
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion apps/withdraw-balancer-v2/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useGetHookInfo } from "#/hooks/useGetHookInfo";
import { RootLayout, WithdrawFormContextProvider } from "@bleu/cow-hooks-ui";
import { useGetHookInfo } from "#/hooks/useGetHookInfo";
import "@bleu/cow-hooks-ui/global.css";
import Head from "next/head";

Expand Down
4 changes: 2 additions & 2 deletions apps/withdraw-balancer-v2/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function Page() {

try {
const data = await decodeExitPoolHookCalldata(
context?.hookToEdit?.hook.callData as `0x${string}`
context?.hookToEdit?.hook.callData as `0x${string}`,
);
setValue("poolId", data.poolId);
setValue("withdrawPct", data.withdrawPct);
Expand All @@ -41,7 +41,7 @@ export default function Page() {

const selectedPool = useMemo(() => {
return pools?.find(
(pool) => pool.id.toLowerCase() === poolId?.toLowerCase()
(pool) => pool.id.toLowerCase() === poolId?.toLowerCase(),
);
}, [pools, poolId]);

Expand Down
10 changes: 4 additions & 6 deletions apps/withdraw-balancer-v2/src/hooks/useGetHookInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@ export function useGetHookInfo() {
return useCallback(
async (
pool: IPool,
withdrawPct: number
withdrawPct: number,
): Promise<IHooksInfo | undefined> => {
if (!pool) return;

const bptAmount = multiplyValueByPct(
pool.userBalance.walletBalance,
withdrawPct
withdrawPct,
);
console.log({ bptAmount });
const poolWithdrawArgs = await getPoolWithdrawArgs(pool, bptAmount);
console.log({ poolWithdrawArgs });
if (!poolWithdrawArgs) return;

const txs = await Promise.all(
poolWithdrawArgs.map((arg) => {
return TransactionFactory.createRawTx(arg.type, arg);
})
}),
);

const permitData = poolWithdrawArgs
Expand All @@ -46,6 +44,6 @@ export function useGetHookInfo() {
permitData: permitData,
};
},
[getPoolWithdrawArgs]
[getPoolWithdrawArgs],
);
}
2 changes: 1 addition & 1 deletion apps/withdraw-cow-amm/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useGetHookInfo } from "#/hooks/useGetHookInfo";
import { RootLayout, WithdrawFormContextProvider } from "@bleu/cow-hooks-ui";
import { useGetHookInfo } from "#/hooks/useGetHookInfo";
import "@bleu/cow-hooks-ui/global.css";
import Head from "next/head";

Expand Down
4 changes: 2 additions & 2 deletions apps/withdraw-cow-amm/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function Page() {

try {
const data = await decodeExitPoolHookCalldata(
context?.hookToEdit?.hook.callData as `0x${string}`
context?.hookToEdit?.hook.callData as `0x${string}`,
);
setValue("poolId", data.poolId);
setValue("withdrawPct", data.withdrawPct);
Expand All @@ -42,7 +42,7 @@ export default function Page() {

const selectedPool = useMemo(() => {
return pools?.find(
(pool) => pool.id.toLowerCase() === poolId?.toLowerCase()
(pool) => pool.id.toLowerCase() === poolId?.toLowerCase(),
);
}, [pools, poolId]);

Expand Down
9 changes: 3 additions & 6 deletions packages/cow-hooks-ui/src/context/withdrawHookForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function WithdrawFormContextProvider({
children: React.ReactNode;
getHookInfo: (
selectedPool: IPool,
withdrawPct: number
withdrawPct: number,
) => Promise<IHooksInfo | undefined>;
poolTypeIn: "COW_AMM" | "WEIGHTED";
}) {
Expand All @@ -40,7 +40,7 @@ export function WithdrawFormContextProvider({

const selectedPool = useMemo(() => {
return pools?.find(
(pool) => pool.id.toLowerCase() === poolId?.toLowerCase()
(pool) => pool.id.toLowerCase() === poolId?.toLowerCase(),
);
}, [pools, poolId]);

Expand All @@ -49,15 +49,12 @@ export function WithdrawFormContextProvider({
const onSubmitCallback = useCallback(
async (data: WithdrawSchemaType) => {
if (!selectedPool) return;
console.log({ selectedPool });
const hookInfo = await getHookInfo(selectedPool, data.withdrawPct);
console.log({ hookInfo });
if (!hookInfo) return;
console.log("oi");
setHookInfo(hookInfo);
router.push("/signing");
},
[getHookInfo, setHookInfo, router, selectedPool]
[getHookInfo, setHookInfo, router, selectedPool],
);

// biome-ignore lint:
Expand Down
10 changes: 5 additions & 5 deletions packages/cow-hooks-ui/src/hooks/usePools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ interface IGetPoolsWhere {
export function usePools(
where: IGetPoolsWhere,
chainId?: SupportedChainId,
orderBy?: string
orderBy?: string,
) {
return useSWR(
[where, chainId],
Expand All @@ -125,12 +125,12 @@ export function usePools(
...pool.userBalance,
walletBalance: parseUnits(
pool.userBalance.walletBalance,
pool.decimals
pool.decimals,
),
stakedBalances: pool.userBalance.stakedBalances.map((staked) => ({
balance: parseUnits(
Number(staked.balance).toFixed(pool.decimals),
pool.decimals
pool.decimals,
),
stakingId: staked.stakingId,
})),
Expand All @@ -139,14 +139,14 @@ export function usePools(
...pool.dynamicData,
totalShares: parseUnits(
Number(pool.dynamicData.totalShares).toFixed(pool.decimals),
pool.decimals
pool.decimals,
),
},
}));
});
},
{
revalidateOnFocus: false,
}
},
);
}
6 changes: 3 additions & 3 deletions packages/cow-hooks-ui/src/hooks/useUserPools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BigNumber } from "ethers";
import { usePools } from "./usePools";
import { useIFrameContext } from "../context/iframe";
import { usePools } from "./usePools";

export function useUserPools(poolType: "WEIGHTED" | "COW_AMM") {
const { context } = useIFrameContext();
Expand All @@ -12,11 +12,11 @@ export function useUserPools(poolType: "WEIGHTED" | "COW_AMM") {
protocolVersionIn,
},
context?.chainId,
"userbalanceUsd"
"userbalanceUsd",
);

const data = useSwrData.data?.filter((pool) =>
BigNumber.from(pool.userBalance.walletBalance).gt(BigNumber.from("10"))
BigNumber.from(pool.userBalance.walletBalance).gt(BigNumber.from("10")),
);

return { ...useSwrData, data };
Expand Down

0 comments on commit 2bb81aa

Please sign in to comment.