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

Fixes from all functionalities #55

Merged
merged 27 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d0c000a
removed manage & addliq btn from unsupported farms
spacewixard Aug 16, 2023
f6b8114
Gas estimation loading state
spacewixard Aug 16, 2023
08307f3
charcter restrictions in inputs
spacewixard Aug 16, 2023
7ab09f6
skywalker: disable input @addstandard
JackSparrowYB Aug 16, 2023
a7dd778
skywalker: disable input @addstable wip
JackSparrowYB Aug 16, 2023
f969a4b
lint fix
JackSparrowYB Aug 16, 2023
2dc9656
Added max decimal places limit based on tokens
spacewixard Aug 17, 2023
d7ffe3a
updated // token allownace method
spacewixard Aug 17, 2023
ab09035
fixed: token approval limit
spacewixard Aug 18, 2023
08425c5
revamped the approval logic, using input for checking
spacewixard Aug 18, 2023
a81001a
set slippage box revamp/fix
spacewixard Aug 18, 2023
2ede988
approval balance bug // wrong obj passed
spacewixard Aug 18, 2023
11f9978
estimate gas fees hook revamp
sahilnanda1995 Aug 21, 2023
ea21945
commented logs
sahilnanda1995 Aug 22, 2023
4888dc6
fix: linting errors
spacewixard Aug 22, 2023
bc6aad9
fix: input issues in stable
spacewixard Aug 23, 2023
fbd95ac
revamped: useapprovalhooks improvised
spacewixard Aug 23, 2023
9cca276
addstable fix
spacewixard Aug 23, 2023
cdea57a
approval stable fix
spacewixard Aug 23, 2023
bf000ac
add standard approve btn copy
spacewixard Aug 23, 2023
32f4fb1
rest modals approve btn copy
spacewixard Aug 23, 2023
ddb3530
Audit: AddLiquidity Standard
spacewixard Aug 24, 2023
25320ca
gasEstimate UI error handling & small amounts
spacewixard Aug 24, 2023
c77753e
AddStable minor-audit, tokenInput for ASTR, Hide a pool
spacewixard Aug 24, 2023
c428168
fix: disable reading functions if wrong chain
spacewixard Aug 24, 2023
46220b1
fix: for stable disable read_methods on wrong chain
spacewixard Aug 24, 2023
1f8b8e4
audited PositionCard + fixed Banner on staked
spacewixard Aug 24, 2023
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
8 changes: 8 additions & 0 deletions src/components/App/FarmList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const FarmsList: FC<Props> = ({ farms, positions }) => {
undefined;
const isSupported = checkIfPoolSupported(farm);

// Skipping a particular farm
if (
farm?.id == 1 &&
farm?.asset.address == "0xcB274236fBA7B873FC8F154bb0475a166C24B119"
) {
return;
}

return (
<tr
key={`${farm.asset.address}-${farm.tvl}`}
Expand Down
12 changes: 5 additions & 7 deletions src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ const Home: NextPage = () => {

useEffect(() => {
if (router.query.id) {
router.push(
`${
typeof window !== "undefined"
? `http://${window.location.host}` // for testing locally
: "https://list.yieldbay.io"
}/farm/${router.query.id}?addr=${router.query.farm}`
);
const url =
typeof window !== "undefined"
? `http://${window.location.host}` // for testing locally
: "https://list.yieldbay.io";
router.push(`${url}/farm/${router.query.id}?addr=${router.query.farm}`);
}
}, [router]);

Expand Down
8 changes: 3 additions & 5 deletions src/components/Common/Layout/evmUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
interface SupportedPoolsType {
[pool: string]: string[];
}

// Pools which are supported for interacting in current version
export const supportedPools: SupportedPoolsType = {
export const supportedPools: {
[pool: string]: string[];
} = {
moonriver: ["zenlink", "solarbeam", "sushiswap"],
moonbeam: ["curve", "zenlink", "stellaswap", "solarflare", "beamswap"],
astar: ["zenlink", "sirius", "arthswap"],
Expand Down
54 changes: 27 additions & 27 deletions src/components/Common/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Layout: FC<Props> = ({ children }) => {
const [tokenPricesMap, setTokenPricesMap] = useAtom(tokenPricesAtom);

useEffect(() => {
console.log("---- Updated Positions ----\n", positions);
// console.log("---- Updated Positions ----\n", positions);
}, [positions]);

const { isConnected, address, connector } = useAccount();
Expand Down Expand Up @@ -143,15 +143,15 @@ const Layout: FC<Props> = ({ children }) => {
});
useEffect(() => {
if (isLpPricesLoading) {
console.log("loading lp prices...");
// console.log("loading lp prices...");
} else {
const tempLpTokenPrices: { [key: string]: number } = {};
lpTokenPrices?.forEach((lptp: TokenPriceType) => {
tempLpTokenPrices[
`${lptp.chain}-${lptp.protocol}-${lptp.symbol}-${lptp.address}` // key
] = lptp.price; // assigning lp token price to the key
});
console.log("lpTokenPricesMap", tempLpTokenPrices);
// console.log("lpTokenPricesMap", tempLpTokenPrices);
setLpTokenPricesMap(tempLpTokenPrices);
}
}, [isLpPricesLoading]);
Expand All @@ -170,65 +170,65 @@ const Layout: FC<Props> = ({ children }) => {
});
useEffect(() => {
if (isTPricesLoading) {
console.log("loading token prices...");
// console.log("loading token prices...");
} else {
// Setting Token prices data
// console.log("token prices", tokenPrices);
// // console.log("token prices", tokenPrices);
// Mapped token prices in a variable
const tokenPricesMap: any = {};
tokenPrices?.forEach((tp: any) => {
tokenPricesMap[
`${tp.chain}-${tp.protocol}-${tp.symbol}-${tp.address}` // key
] = tp.price; // assigning token price to the key
});
console.log("tokenPricesMap", tokenPricesMap);
// console.log("tokenPricesMap", tokenPricesMap);
setTokenPricesMap(tokenPricesMap);
}
}, [isTPricesLoading]);

useEffect(() => {
console.log("lpTokenPrices useeffect", lpTokenPricesMap);
// console.log("lpTokenPrices useeffect", lpTokenPricesMap);
}, [lpTokenPricesMap]);

useEffect(() => {
console.log("tokenPrices useeffect", tokenPricesMap);
// console.log("tokenPrices useeffect", tokenPricesMap);
}, [tokenPricesMap]);

const setupMangataHelper = async (accountInit: Account | null) => {
if (account?.address == null) {
console.log("Connect wallet to use App!");
// console.log("Connect wallet to use App!");
return;
}

if (mangataHelperx != null && accountInit?.address === account.address) {
console.log("accountinit", accountInit?.address);
console.log("account address", account.address);
console.log("Already initialised!");
// console.log("accountinit", accountInit?.address);
// console.log("account address", account.address);
// console.log("Already initialised!");
return;
}

console.log("Initializing APIs of both chains ...");
// console.log("Initializing APIs of both chains ...");

let mangataConfig = MangataConfig;
const mangataHelper = new MangataHelper(mangataConfig);
console.log("initiliazing mangata helper...");
// console.log("initiliazing mangata helper...");
await mangataHelper.initialize();
console.log("✅ mangata helper initialized\n", mangataHelper);
// console.log("✅ mangata helper initialized\n", mangataHelper);
setMangataHelper(mangataHelper);

const mangataChainName = mangataHelper.config.key;

console.log("mangata Assets", mangataHelper.config.assets);
// console.log("mangata Assets", mangataHelper.config.assets);

const mangataNativeToken = _.first(mangataHelper.config.assets);

console.log(
`Mangata chain name: ${mangataChainName}, native token: ${JSON.stringify(
mangataNativeToken
)}\n`
);
// console.log(
// `Mangata chain name: ${mangataChainName}, native token: ${JSON.stringify(
// mangataNativeToken
// )}\n`
// );

console.log("1. Reading token and balance of account ...");
// console.log("1. Reading token and balance of account ...");

// New account instance from connected account
const account1 = new Account({
Expand All @@ -238,7 +238,7 @@ const Layout: FC<Props> = ({ children }) => {
},
});
await account1.init([mangataHelper]);
console.log("account1", account1);
// console.log("account1", account1);
// It is setting Account1 here, and this fn runs only once in starting
// it should re-run when an account is updated.
setAccountInit(account1);
Expand All @@ -247,7 +247,7 @@ const Layout: FC<Props> = ({ children }) => {
setMangataAddress(mangataAddress);

const pools = await mangataHelper.getPools({ isPromoted: true });
console.log("Promoted Pools", pools);
// console.log("Promoted Pools", pools);
setPools(pools);
setIsInitialised(true);
};
Expand All @@ -260,7 +260,7 @@ const Layout: FC<Props> = ({ children }) => {
walletType: "DOT",
connector: account?.wallet?.extensionName!,
});
console.log("running mangata setup\n==> account", account);
// console.log("running mangata setup\n==> account", account);
fetchSubstratePositions({
farms,
positions,
Expand All @@ -270,7 +270,7 @@ const Layout: FC<Props> = ({ children }) => {
});
setupMangataHelper(accountInit);
} else if (!isConnectedDot && farms.length > 0) {
console.log("emptying mangata positions...");
// console.log("emptying mangata positions...");
emptySubstratePositions({
farms,
positions,
Expand Down Expand Up @@ -309,7 +309,7 @@ const Layout: FC<Props> = ({ children }) => {
lpTokensPricesLength > 0 &&
tokenPricesLength > 0
) {
console.log("emptying evm positions running...");
// console.log("emptying evm positions running...");
emptyEvmPositions({
farms,
positions,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Common/Providers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const Providers = ({ children }: { children: ReactNode }) => {
}
);
} catch (err) {
console.log("Error in subscribing accounts: ", err);
// console.log("Error in subscribing accounts: ", err);
}
})();
}
Expand Down
18 changes: 11 additions & 7 deletions src/components/FarmPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import MetaTags from "@components/Common/metaTags/MetaTags";
import useSpecificFarm from "@hooks/useSpecificFarm";
import { fetchListicleFarms } from "@utils/api";
import {
checkIfPoolSupported,
farmURL,
formatFarmType,
formatFirstLetter,
Expand Down Expand Up @@ -124,12 +125,12 @@ const FarmPage: NextPage = () => {
const unclaimedRewardsUSD = parseFloat(
calcUnclaimedRewardUSD(farmPosition.unclaimedRewards)
);
console.log(
"total unclaimed rewards",
farmPosition.unclaimedRewards,
farm?.asset.symbol,
unclaimedRewards
);
// console.log(
// "total unclaimed rewards",
// farmPosition.unclaimedRewards,
// farm?.asset.symbol,
// unclaimedRewards
// );
setUnclaimedReward(unclaimedRewards);
setUnclaimedRewardUSD(unclaimedRewardsUSD);
}
Expand All @@ -156,6 +157,8 @@ const FarmPage: NextPage = () => {
const safetyScore = parseFloat((farm?.safetyScore * 10).toFixed(1));
const safetyScoreColor = useSafetyscoreColor(safetyScore);

const isSupported = checkIfPoolSupported(farm);

return !isLoading && idQuery ? (
<div className="px-6 sm:px-[72px] text-[#475467] z-0">
<MetaTags title={`Farm • ${APP_NAME}`} />
Expand Down Expand Up @@ -189,6 +192,7 @@ const FarmPage: NextPage = () => {
</div>
)}
{!hasPosition &&
isSupported &&
(farm?.chain.toLowerCase() == "mangata kusama" ||
farm?.protocol.toLowerCase() == "mangata x"
? isConnectedDot
Expand All @@ -197,7 +201,7 @@ const FarmPage: NextPage = () => {
size="custom"
style="inline-flex justify-between items-center gap-x-2 bg-[#F0F0FF]"
onButtonClick={() => {
console.log("farm in farmpage", farm);
// console.log("farm in farmpage", farm);
setSelectedFarm(farm);
setAddLiqModalOpen(true);
}}
Expand Down
Loading