Skip to content

Commit

Permalink
Yield Farming User Deposit issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-01k committed Apr 23, 2024
1 parent c6b6da0 commit 20631a5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 22 deletions.
6 changes: 4 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ const extendConsole = () => {
window.console = {};
}
if (window.console[level] === 'undefined' || !window.console[level] || window.console[level] === null) {
window.console[level] = function () {};
window.console[level] = function () { };
}
if (enabled) {
if (disabledConsoles[level]) {
window.console[level] = disabledConsoles[level];
}
} else {
disabledConsoles[level] = window.console[level];
window.console[level] = function () {};
window.console[level] = function () { };
}
};
} catch (e) {
Expand Down Expand Up @@ -360,6 +360,8 @@ const HeaderContainer = styled.header`

const ParentContainer = styled.div`
flex-wrap: wrap;
position: relative;
z-index:0;
display: flex;
flex-direction: row;
justify-content: center;
Expand Down
22 changes: 16 additions & 6 deletions src/components/YieldFarmChainError.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import React from 'react';
import React, { useEffect } from 'react';
import Close from 'assets/chat/group-chat/close.svg?react';
import { ButtonV2, ItemHV2, ItemVV2 } from './reusables/SharedStylingV2';
import styled from 'styled-components';
import styled, { useTheme } from 'styled-components';
import { ethers } from 'ethers';
import { appConfig } from 'config/index.js';
import { useAccount } from 'hooks';

const YieldFarmChainError = () => {
const YieldFarmChainError = ({ onClose }) => {
const { account, chainId: currentChainId, switchChain } = useAccount();

const theme = useTheme();

const handleChainChange = () => {
const chainIdToPass = appConfig.allowedNetworks[0];

if (currentChainId !== 1 && currentChainId !== 11155111) {
console.debug('Current Chain ID ', currentChainId);
console.debug('Chain Id to pass', chainIdToPass);
console.info('Current Chain ID ', currentChainId);
console.info('Chain Id to pass', chainIdToPass);
switchChain(appConfig.coreContractChain);
}
};

useEffect(() => {
if (currentChainId === 1 || currentChainId === 11155111) {
onClose();
}
}, [currentChainId])


return (
<Container>
<Close style={{ cursor: 'pointer', alignSelf: 'end' }} />
Expand Down Expand Up @@ -56,10 +65,11 @@ const BodyContainer = styled(ItemVV2)`
const PrimaryText = styled.div`
font-size: 28px;
font-weight: 500;
color: ${(props) => props.theme.stakingSecondaryText};
`;

const SecondaryText = styled.div`
color: #657795;
color: ${(props) => props.theme.activeButtonText};
text-align: center;
font-size: 18px;
font-weight: 400;
Expand Down
14 changes: 7 additions & 7 deletions src/primaries/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { AppContextType } from 'types/context';

// Create Header
const Profile = ({ isDarkMode }) => {
const { web3NameList,initialisePushSdkReadMode }: AppContextType = useContext(AppContext);
const { web3NameList, initialisePushSdkReadMode }: AppContextType = useContext(AppContext);
const { setReadOnlyWallet, readOnlyWallet, mode, setMode }: GlobalContextType = useContext(GlobalContext);
const { authError } = useContext(ErrorContext);
const toggleArrowRef = useRef(null);
Expand All @@ -44,7 +44,7 @@ const Profile = ({ isDarkMode }) => {
// Get theme
const theme = useTheme();
const [showDropdown, setShowDropdown] = React.useState<boolean>(false);
useClickAway(modalRef, dropdownRef, () => showDropdown && setShowDropdown(false));
// useClickAway(modalRef, dropdownRef, () => showDropdown && setShowDropdown(false));

const dropdownValues = [
{
Expand Down Expand Up @@ -88,11 +88,11 @@ const Profile = ({ isDarkMode }) => {
setShowDropdown(false);
});

const ConnectWallet = ()=>{
const ConnectWallet = () => {
connect();
}


// to create blockies
return (
<>
Expand All @@ -105,7 +105,7 @@ const Profile = ({ isDarkMode }) => {
bg="linear-gradient(87.17deg, #B6A0F5 0%, #F46EF7 57.29%, #FF95D5 100%)"
color='#FFF'
isDarkMode={isDarkMode}
onClick={()=>ConnectWallet()}
onClick={() => ConnectWallet()}
>
Connect Wallet
</Wallet>
Expand Down Expand Up @@ -149,7 +149,7 @@ const Profile = ({ isDarkMode }) => {
align="flex-start"
ref={dropdownRef}
>
<Dropdown dropdownValues={dropdownValues} setShowDropdown={setShowDropdown}/>
<Dropdown dropdownValues={dropdownValues} setShowDropdown={setShowDropdown} />
</DropdownItem>
<ItemModal ref={modalRef}>
<ProfileModal
Expand All @@ -168,7 +168,7 @@ const Profile = ({ isDarkMode }) => {
bg="linear-gradient(87.17deg, #B6A0F5 0%, #F46EF7 57.29%, #FF95D5 100%)"
color='#FFF'
isDarkMode={isDarkMode}
onClick={()=>ConnectWallet()}
onClick={() => ConnectWallet()}
>
Connect Wallet
</Wallet>
Expand Down
32 changes: 25 additions & 7 deletions src/sections/yield/NewYieldFarming.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import useModalBlur, { MODAL_POSITION } from 'hooks/useModalBlur';
import StepsTransactionModal from 'components/StepsTransactionModal';

const NewYieldFarming = ({ setActiveTab }) => {
const { provider, account } = useAccount();
const { provider, account, chainId } = useAccount();

const [pushToken, setPushToken] = useState(null);
const [staking, setStaking] = useState(null);
Expand All @@ -37,11 +37,16 @@ const NewYieldFarming = ({ setActiveTab }) => {

const library = provider?.getSigner(account);

const getPoolStats = React.useCallback(async () => {
const poolStats = await YieldFarmingDataStoreV2.getInstance().getPoolStats(provider);
setPoolStats({ ...poolStats });
}, [staking, pushToken, pushCoreV2, yieldFarmingLP, uniswapV2Router02Instance]);


const getLpPoolStats = React.useCallback(async () => {
const poolStats = await YieldFarmingDataStoreV2.getInstance().getPoolStats(provider);
const lpPoolStats = await YieldFarmingDataStoreV2.getInstance().getLPPoolStats(poolStats);

setPoolStats({ ...poolStats });
setLpPoolStats({ ...lpPoolStats });
}, [staking, pushToken, pushCoreV2, yieldFarmingLP, uniswapV2Router02Instance]);

Expand All @@ -65,6 +70,11 @@ const NewYieldFarming = ({ setActiveTab }) => {

//initiate the YieldFarmV2 data store here
React.useEffect(() => {

if (chainId !== 1 && chainId !== 11155111) {
return;
}

setLpPoolStats(null);
setUserDataLP(null);
setPUSHPoolStats(null);
Expand Down Expand Up @@ -98,6 +108,7 @@ const NewYieldFarming = ({ setActiveTab }) => {
setUniswapV2Router02Instance(uniswapV2Router02Instance);
}


YieldFarmingDataStoreV2.getInstance().init(
account,
staking,
Expand All @@ -107,11 +118,18 @@ const NewYieldFarming = ({ setActiveTab }) => {
uniswapV2Router02Instance
);

getLpPoolStats();
getUserDataLP();
getUserDataPush();
getPUSHPoolStats();
}, [account]);

getPoolStats();

if (account !== '0x0000000000000000000000000000000000000001') {
getUserDataPush();
getUserDataLP();
getLpPoolStats();
}



}, [account, chainId]);

return (
<>
Expand Down

0 comments on commit 20631a5

Please sign in to comment.