Skip to content

Commit

Permalink
Merge pull request #542 from oraichain/hotfix/co-harvest
Browse files Browse the repository at this point in the history
hot fix list my bids
  • Loading branch information
haunv3 authored Jan 12, 2024
2 parents 37e5244 + 7a50fd5 commit ee60c8e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/pages/CoHarvest/components/BiddingChart/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
gap: 6px;
align-items: center;

@include mobile {
font-size: 16px;
}
.usd {
@include theme {
color: theme-get('sea-stone-200');
Expand Down
4 changes: 1 addition & 3 deletions src/pages/CoHarvest/components/BiddingChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const BiddingChart = (props: { round: number; bidInfo }) => {
const amountUsd = getUsd(totalBidAmount, USDC_TOKEN_INFO, prices);

const ORAIX_TOKEN_INFO = oraichainTokens.find((e) => e.coinGeckoId === 'oraidex');
const { allBidPoolRound, isLoading, refetchAllBidPoolRound } = useGetAllBidPoolInRound(round);
const { allBidPoolRound } = useGetAllBidPoolInRound(round);
const [visible, setVisible] = useState(false);

const [theme] = useConfigReducer('theme');
Expand Down Expand Up @@ -49,7 +49,6 @@ const BiddingChart = (props: { round: number; bidInfo }) => {
</div>
</div>

{/* <LoadingBox loading={isLoading}> */}
<div className={styles.content}>
<div className={styles.columnList}>
{allBidPoolRound.map((e, key) => (
Expand All @@ -64,7 +63,6 @@ const BiddingChart = (props: { round: number; bidInfo }) => {
))}
</div>
</div>
{/* </LoadingBox> */}
</div>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/pages/CoHarvest/components/BiddingHistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const BiddingHistory = ({ round }) => {
setShowFilter(false);
});

// console.log('listPotentialReturn', listPotentialReturn);
return (
<div className={styles.biddingHistory}>
<div className={styles.tabWrapper}>
Expand Down
6 changes: 1 addition & 5 deletions src/pages/CoHarvest/components/CountDownTime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ import { useState } from 'react';
import { TooltipIconBtn } from '../Tooltip';
import styles from './index.module.scss';

const CountDownTime = ({ timeRemaining, percent, isEnd, start, end, isStarted }: CountDownType) => {
const CountDownTime = ({ timeRemaining, percent, start, end, isStarted }: CountDownType) => {
const { days, hours, minutes, seconds } = formatCountdownTime(timeRemaining);
const [visible, setVisible] = useState(false);
const fmtPercent = percent >= 100 ? 0 : percent;
const [theme] = useConfigReducer('theme');

const startDateStr = formatDate(start);
const startTimeStr = getUTCTime(start);
// const startDateStr = dateFormat(start || new Date());
// const startTimeStr = dateFormat(start || new Date());

console.log('tmien');

return (
<div className={styles.countdownWrapper}>
Expand Down
20 changes: 9 additions & 11 deletions src/pages/CoHarvest/hooks/useGetBidRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getUsd } from 'libs/utils';
import { useEffect, useState } from 'react';
import { fetchRoundBid } from 'rest/api';
import { BidStatus, TIMER } from '../constants';
import { Bid, BiddingInfoResponse } from '@oraichain/oraidex-contracts-sdk/build/CoharvestBidPool.types';

export const useGetRound = () => {
const [round, setRound] = useState(0);
Expand Down Expand Up @@ -148,10 +149,10 @@ export const useGetPotentialReturn = (props: {
const getPotentialReturn = async () => {
const coHarvestBidPool = new CoharvestBidPoolQueryClient(window.client, network.bid_pool);
const data = await coHarvestBidPool.estimateAmountReceive({
bidAmount, // bidAmount: gia nhap
exchangeRate, // exchangeRate: 1 ORAX/USDC;
round, // round: lastRoundId;
slot // slot: %;
bidAmount,
exchangeRate,
round,
slot
});
return data;
};
Expand All @@ -174,18 +175,16 @@ export const useGetPotentialReturn = (props: {

export const useGetBidHistoryWithPotentialReturn = (props: {
exchangeRate: string;
listBidHistories: any[];
biddingInfo: any;
listBidHistories: Bid[];
biddingInfo: BiddingInfoResponse;
}) => {
const { listBidHistories, exchangeRate, biddingInfo } = props;
const ORAIX_TOKEN_INFO = oraichainTokens.find((e) => e.coinGeckoId === 'oraidex');
const USDC_TOKEN_INFO = oraichainTokens.find((e) => e.coinGeckoId === 'usd-coin');

const { data: prices } = useCoinGeckoPrices();

const getListPotentialReturn = async () => {
const multicall = new MulticallQueryClient(window.client, network.multicall);

const res = await multicall.aggregate({
queries: listBidHistories.map((bid) => ({
address: network.bid_pool,
Expand All @@ -201,7 +200,6 @@ export const useGetBidHistoryWithPotentialReturn = (props: {
});

return listBidHistories.map((bid, ind) => {
// get potential return
if (!res.return_data[ind].success) {
return {
...bid,
Expand Down Expand Up @@ -258,12 +256,12 @@ export const useGetBidHistoryWithPotentialReturn = (props: {
isRefetching,
refetch: refetchPotentialReturn
} = useQuery(
['all-potential-return', listBidHistories, biddingInfo?.bid_info.end_time],
['all-potential-return', listBidHistories, biddingInfo?.bid_info.end_time, biddingInfo?.bid_info.round],
() => getListPotentialReturn(),
{
refetchOnWindowFocus: false,
placeholderData: [],
enabled: !!listBidHistories && !!biddingInfo?.bid_info.end_time && !!biddingInfo?.round
enabled: !!listBidHistories?.length && !!biddingInfo?.bid_info.end_time && !!biddingInfo?.bid_info.round
}
);

Expand Down

0 comments on commit ee60c8e

Please sign in to comment.