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. variable typo #314

Merged
merged 1 commit into from
Mar 13, 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 @@ -22,7 +22,7 @@ import BigNumber from "bignumber.js";
import { makeSwapFeeTier, priceToNearTick, tickToPrice } from "@utils/swap-utils";
import { usePoolData } from "@hooks/pool/use-pool-data";
import { useGnotToGnot } from "@hooks/token/use-gnot-wugnot";
import { encriptId } from "@utils/common";
import { encryptId } from "@utils/common";

export interface AddLiquidityPriceRage {
type: PriceRangeType;
Expand Down Expand Up @@ -316,7 +316,7 @@ const EarnAddLiquidityContainer: React.FC = () => {
return;
}
if (!initialized) {
const convertPath = encriptId(router.query["pool-path"] as string);
const convertPath = encryptId(router.query["pool-path"] as string);
const splitPath: string[] = convertPath.split(":") || [];
const currentTokenA = tokens.find(token => token.path === splitPath[0]) || null;
const currentTokenB = tokens.find(token => token.path === splitPath[1]) || null;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/hooks/common/use-position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const usePosition = (positions: PoolPositionModel[]) => {
return positionRepository
.claimAll({
positions: claimablePositions,
receipient: address,
recipient: address,
})
.catch(() => null);
}, [account?.address, positionRepository, positions]);
Expand Down
44 changes: 22 additions & 22 deletions packages/web/src/hooks/swap/use-swap-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const findKeyByValue = (
};

export const useSwapHandler = () => {
const [memoryzeTokenSwap, setMemoryzeTokenSwap] = useAtom(
SwapState.memoryzeTokenSwap,
const [memorizeTokenSwap, setMemorizeTokenSwap] = useAtom(
SwapState.memorizeTokenSwap,
);
const router = useRouter();
const [swapValue, setSwapValue] = useAtom(SwapState.swap);
Expand Down Expand Up @@ -406,7 +406,7 @@ export const useSwapHandler = () => {
const changeTokenAAmount = useCallback(
(value: string, none?: boolean) => {
const memoryzeTokenB =
memoryzeTokenSwap?.[`${tokenA?.symbol}:${value}:${tokenB?.symbol}`];
memorizeTokenSwap?.[`${tokenA?.symbol}:${value}:${tokenB?.symbol}`];
if (memoryzeTokenB) {
setTokenAAmount(value);
setTokenBAmount(memoryzeTokenB.split(":")[1]);
Expand Down Expand Up @@ -442,7 +442,7 @@ export const useSwapHandler = () => {
}));
setTokenAAmount(value);
},
[isSameToken, memoryzeTokenSwap, tokenA],
[isSameToken, memorizeTokenSwap, tokenA],
);
useEffect(() => {
setSwapValue(prev => ({
Expand All @@ -454,7 +454,7 @@ export const useSwapHandler = () => {
const changeTokenBAmount = useCallback(
(value: string, none?: boolean) => {
const memoryzeTokenA =
memoryzeTokenSwap?.[`${tokenB?.symbol}:${value}:${tokenB?.symbol}`];
memorizeTokenSwap?.[`${tokenB?.symbol}:${value}:${tokenB?.symbol}`];
if (memoryzeTokenA) {
setTokenBAmount(value);
setTokenAAmount(memoryzeTokenA.split(":")[1]);
Expand Down Expand Up @@ -489,7 +489,7 @@ export const useSwapHandler = () => {
}));
setTokenBAmount(value);
},
[isSameToken, memoryzeTokenSwap, tokenB],
[isSameToken, memorizeTokenSwap, tokenB],
);

const changeTokenA = useCallback(
Expand Down Expand Up @@ -555,18 +555,18 @@ export const useSwapHandler = () => {
const keyForValue =
findKeyByValue(
`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`,
memoryzeTokenSwap,
memorizeTokenSwap,
) ?? "";
if (memoryzeTokenSwap?.[keyForValue]) {
if (memorizeTokenSwap?.[keyForValue]) {
setTokenAAmount(keyForValue?.split(":")?.[1]);
setTokenBAmount(memoryzeTokenSwap?.[keyForValue]?.split(":")?.[1]);
setTokenBAmount(memorizeTokenSwap?.[keyForValue]?.split(":")?.[1]);
return;
}
} else {
const keyForValue = `${tokenB?.symbol}:${tokenBAmount}:${tokenA?.symbol}`;
if (memoryzeTokenSwap?.[keyForValue]) {
if (memorizeTokenSwap?.[keyForValue]) {
setTokenAAmount(tokenBAmount);
setTokenBAmount(memoryzeTokenSwap?.[keyForValue]?.split(":")?.[1]);
setTokenBAmount(memorizeTokenSwap?.[keyForValue]?.split(":")?.[1]);
return;
}
}
Expand All @@ -591,7 +591,7 @@ export const useSwapHandler = () => {
type,
tokenAAmount,
tokenBAmount,
memoryzeTokenSwap,
memorizeTokenSwap,
]);

const copyURL = async () => {
Expand Down Expand Up @@ -823,15 +823,15 @@ export const useSwapHandler = () => {
}, []);
useEffect(() => {
if (
memoryzeTokenSwap?.[
memorizeTokenSwap?.[
`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`
] &&
type === "EXACT_IN"
) {
return;
}
if (
memoryzeTokenSwap?.[
memorizeTokenSwap?.[
`${tokenB?.symbol}:${tokenBAmount}:${tokenA?.symbol}`
] &&
type === "EXACT_OUT"
Expand All @@ -848,7 +848,7 @@ export const useSwapHandler = () => {
}
}, [
defaultTokenAAmount,
memoryzeTokenSwap,
memorizeTokenSwap,
tokenA?.symbol,
tokenAAmount,
tokenBAmount,
Expand All @@ -862,7 +862,7 @@ export const useSwapHandler = () => {
return;
}
if (
memoryzeTokenSwap?.[
memorizeTokenSwap?.[
`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`
] &&
type === "EXACT_IN"
Expand All @@ -871,7 +871,7 @@ export const useSwapHandler = () => {
return;
}
if (
memoryzeTokenSwap?.[
memorizeTokenSwap?.[
`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`
] &&
type === "EXACT_OUT"
Expand Down Expand Up @@ -917,14 +917,14 @@ export const useSwapHandler = () => {
!!Number(tokenAAmount || 0) &&
!!Number(tokenBAmount || 0)
) {
setMemoryzeTokenSwap(prev => ({
setMemorizeTokenSwap(prev => ({
...prev,
[`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`]: `${tokenB?.symbol}:${tokenBAmount}`,
}));
setIsChangeBalancesToken(false);
} else {
setIsChangeBalancesToken(false);
setMemoryzeTokenSwap(prev => ({
setMemorizeTokenSwap(prev => ({
...prev,
[`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`]: `${tokenB?.symbol}:${tokenBAmount}`,
}));
Expand All @@ -938,7 +938,7 @@ export const useSwapHandler = () => {
tokenB,
tokenBAmount,
isSameToken,
memoryzeTokenSwap,
memorizeTokenSwap,
]);

useEffect(() => {
Expand All @@ -951,12 +951,12 @@ export const useSwapHandler = () => {
if (!isError) {
if (isExactIn) {
setTokenBAmount(expectedAmount);
setMemoryzeTokenSwap(prev => ({
setMemorizeTokenSwap(prev => ({
...prev,
[`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`]: `${tokenB?.symbol}:${tokenBAmount}`,
}));
} else {
setMemoryzeTokenSwap(prev => ({
setMemorizeTokenSwap(prev => ({
...prev,
[`${tokenB?.symbol}:${tokenBAmount}:${tokenA?.symbol}`]: `${tokenA?.symbol}:${tokenAAmount}`,
}));
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/models/position/mapper/position-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
PositionListResponse,
PositionResponse,
} from "@repositories/position/response";
import { RewardResposne } from "@repositories/position/response/reward-response";
import { RewardResponse } from "@repositories/position/response/reward-response";
import { PoolPositionModel } from "../pool-position-model";
import { PositionModel } from "../position-model";
import { RewardModel } from "../reward-model";
Expand Down Expand Up @@ -73,7 +73,7 @@ export class PositionMapper {
return positions.map(PositionMapper.from);
}

public static rewardFromResponse(reward: RewardResposne): RewardModel {
public static rewardFromResponse(reward: RewardResponse): RewardModel {
return {
token: reward.rewardToken,
accumulatedRewardOf1d:
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import DashbordLayout from "@layouts/dashboard-layout/DashboardLayout";
import DashboardLayout from "@layouts/dashboard-layout/DashboardLayout";
import HeaderContainer from "@containers/header-container/HeaderContainer";
import Footer from "@components/common/footer/Footer";
import TvlChartContainer from "@containers/tvl-chart-container/TvlChartContainer";
Expand All @@ -8,7 +8,7 @@ import DashboardActivitiesContainer from "@containers/dashboard-activities-conta

export default function Dashboard() {
return (
<DashbordLayout
<DashboardLayout
header={<HeaderContainer />}
tvl={<TvlChartContainer />}
volume={<VolumeChartContainer />}
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/react-query/pools/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UseQueryOptions, useQuery } from "@tanstack/react-query";
import { useGnoswapContext } from "@hooks/common/use-gnoswap-context";
import { PoolModel } from "@models/pool/pool-model";
import { QUERY_KEY } from "./types";
import { encriptId } from "@utils/common";
import { encryptId } from "@utils/common";
import { PoolDetailModel } from "@models/pool/pool-detail-model";

export const useGetPoolList = (
Expand All @@ -26,7 +26,7 @@ export const useGetPoolDetailByPath = (
options?: UseQueryOptions<PoolDetailModel, Error>
) => {
const { poolRepository } = useGnoswapContext();
const convertPath = encriptId(path);
const convertPath = encryptId(path);
return useQuery<PoolDetailModel, Error>({
queryKey: [QUERY_KEY.poolDetail, convertPath],
queryFn: async () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/web/src/react-query/token/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UseQueryOptions, useQuery } from "@tanstack/react-query";
import { QUERY_KEY } from "./types";
import { useGnoswapContext } from "@hooks/common/use-gnoswap-context";
import { TokenPriceModel } from "@models/token/token-price-model";
import { IBalancesByAddressReponse } from "@repositories/token/response/balance-by-address-response";
import { IBalancesByAddressResponse } from "@repositories/token/response/balance-by-address-response";

export const useGetTokensList = (
options?: UseQueryOptions<TokenListResponse, Error>,
Expand Down Expand Up @@ -68,7 +68,7 @@ export const useGetChainList = (

export const useGetTokenByPath = (
path: string,
option?: UseQueryOptions<ITokenResponse, Error>
option?: UseQueryOptions<ITokenResponse, Error>,
) => {
const { tokenRepository } = useGnoswapContext();
return useQuery<ITokenResponse, Error>({
Expand All @@ -80,10 +80,10 @@ export const useGetTokenByPath = (

export const useGetBalancesByAddress = (
address: string,
option?: UseQueryOptions<IBalancesByAddressReponse, Error>
option?: UseQueryOptions<IBalancesByAddressResponse, Error>,
) => {
const { tokenRepository } = useGnoswapContext();
return useQuery<IBalancesByAddressReponse, Error>({
return useQuery<IBalancesByAddressResponse, Error>({
queryKey: [QUERY_KEY.tokenBalancesByAddress, address],
queryFn: () => tokenRepository.getBalancesByAddress(address),
...option,
Expand Down
19 changes: 12 additions & 7 deletions packages/web/src/repositories/position/position-repository-impl.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { NetworkClient } from "@common/clients/network-client";
import { WalletClient } from "@common/clients/wallet-client";
import { SendTransactionResponse, WalletResponse } from "@common/clients/wallet-client/protocols";
import {
SendTransactionResponse,
WalletResponse,
} from "@common/clients/wallet-client/protocols";
import { CommonError } from "@common/errors";
import { DEFAULT_GAS_FEE, DEFAULT_GAS_WANTED } from "@common/values";
import { GnoProvider } from "@gnolang/gno-js-client";
import { PositionMapper } from "@models/position/mapper/position-mapper";
import { PositionModel } from "@models/position/position-model";
import { PositionRepository } from "./position-repository";
import { ClaimAllRequest } from "./request/claim-all-request";
import { RemoveLiquidityReqeust } from "./request/remove-liquidity-request";
import { RemoveLiquidityRequest } from "./request/remove-liquidity-request";
import { StakePositionsRequest } from "./request/stake-positions-request";
import { UnstakePositionsRequest } from "./request/unstake-positions-request";
import { PositionListResponse } from "./response";
Expand Down Expand Up @@ -45,11 +48,13 @@ export class PositionRepositoryImpl implements PositionRepository {
return PositionMapper.fromList(response.data);
};

claimAll = async (request: ClaimAllRequest): Promise<WalletResponse<SendTransactionResponse<string[] | null>>> => {
claimAll = async (
request: ClaimAllRequest,
): Promise<WalletResponse<SendTransactionResponse<string[] | null>>> => {
if (this.walletClient === null) {
throw new CommonError("FAILED_INITIALIZE_WALLET");
}
const { positions, receipient } = request;
const { positions, recipient } = request;
const messages = positions.flatMap(position => {
const messages = [];
const hasSwapFee =
Expand All @@ -62,11 +67,11 @@ export class PositionRepositoryImpl implements PositionRepository {
) > -1;
if (hasSwapFee) {
messages.push(
makePositionCollectFeeMessage(position.lpTokenId, receipient),
makePositionCollectFeeMessage(position.lpTokenId, recipient),
);
}
if (hasReward) {
messages.push(makeCollectRewardMessage(position.lpTokenId, receipient));
messages.push(makeCollectRewardMessage(position.lpTokenId, recipient));
}
return messages;
});
Expand Down Expand Up @@ -116,7 +121,7 @@ export class PositionRepositoryImpl implements PositionRepository {
};

removeLiquidity = async (
request: RemoveLiquidityReqeust,
request: RemoveLiquidityRequest,
): Promise<WalletResponse<SendTransactionResponse<string[] | null>>> => {
if (this.walletClient === null) {
throw new CommonError("FAILED_INITIALIZE_WALLET");
Expand Down
19 changes: 14 additions & 5 deletions packages/web/src/repositories/position/position-repository.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import { PositionModel } from "@models/position/position-model";
import { ClaimAllRequest } from "./request/claim-all-request";
import { RemoveLiquidityReqeust } from "./request/remove-liquidity-request";
import { RemoveLiquidityRequest } from "./request/remove-liquidity-request";
import { StakePositionsRequest } from "./request/stake-positions-request";
import { UnstakePositionsRequest } from "./request/unstake-positions-request";
import { SendTransactionResponse, WalletResponse } from "@common/clients/wallet-client/protocols";
import {
SendTransactionResponse,
WalletResponse,
} from "@common/clients/wallet-client/protocols";

export interface PositionRepository {
getPositionsByAddress: (address: string) => Promise<PositionModel[]>;

claimAll: (request: ClaimAllRequest) => Promise<WalletResponse<SendTransactionResponse<string[] | null>>>;
claimAll: (
request: ClaimAllRequest,
) => Promise<WalletResponse<SendTransactionResponse<string[] | null>>>;

stakePositions: (request: StakePositionsRequest) => Promise<WalletResponse<SendTransactionResponse<string[] | null>>> ;
stakePositions: (
request: StakePositionsRequest,
) => Promise<WalletResponse<SendTransactionResponse<string[] | null>>>;

unstakePositions: (
request: UnstakePositionsRequest,
) => Promise<WalletResponse<SendTransactionResponse<string[] | null>>>;

removeLiquidity: (request: RemoveLiquidityReqeust) => Promise<WalletResponse<SendTransactionResponse<string[] | null>>>;
removeLiquidity: (
request: RemoveLiquidityRequest,
) => Promise<WalletResponse<SendTransactionResponse<string[] | null>>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { PositionModel } from "@models/position/position-model";
export interface ClaimAllRequest {
positions: PositionModel[];

receipient: string;
recipient: string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface RemoveLiquidityReqeust {
export interface RemoveLiquidityRequest {
lpTokenIds: string[];

caller: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PoolBinModel } from "@models/pool/pool-bin-model";
import { RewardResposne } from "./reward-response";
import { RewardResponse } from "./reward-response";

export type PositionListResponse = PositionResponse[];

Expand Down Expand Up @@ -48,8 +48,8 @@ export interface PositionResponse {

stakedUsdValue?: string;

rewards?: RewardResposne[];
rewards?: RewardResponse[];

dailyRewards?: RewardResposne[];
dailyRewards?: RewardResponse[];
bins: PoolBinModel[];
}
Loading
Loading