Skip to content

Commit

Permalink
Remove unused code (#1738)
Browse files Browse the repository at this point in the history
* Remove unused files

* Remove unused packages

* Remove unused file

* Remove unused function

* Remove unused `v2BondDetails`

* Remove `AllBonds`

* Remove unused file

* Remove unused deps

* Remove unused `ZapCta` component

* Remove unused test snapshot

Co-authored-by: brightiron <brightiron@protonmail.com>
Co-authored-by: appleseed-iii <appleseed-iii@protonmail.com>
  • Loading branch information
3 people committed May 25, 2022
1 parent 5c7d2b7 commit 7871435
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 1,570 deletions.
28 changes: 0 additions & 28 deletions gulpfile.js

This file was deleted.

28 changes: 0 additions & 28 deletions ledgerLiveManifest.json

This file was deleted.

5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"fast-check": "^2.25.0",
"gulp": "^4.0.2",
"gulp-csso": "^4.0.1",
"gulp-debug": "^4.0.0",
"gulp-less": "^5.0.0",
"gulp-postcss": "^9.0.0",
"hardhat": "^2.9.3",
"husky": "^7.0.4",
"jest-coverage-badges": "^1.1.2",
Expand Down
18 changes: 0 additions & 18 deletions scripts/watch.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/constants/decimals.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/helpers/AllBonds.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/helpers/BondCalculator.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/helpers/BondCalculator.unit.test.ts

This file was deleted.

36 changes: 1 addition & 35 deletions src/helpers/NetworkHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JsonRpcProvider, StaticJsonRpcProvider } from "@ethersproject/providers";

import { NetworkId, NETWORKS } from "../constants";
import { NetworkId } from "../constants";
import { Providers } from "./providers/Providers/Providers";

interface IGetCurrentNetwork {
Expand Down Expand Up @@ -62,40 +62,6 @@ export const initNetworkFunc = async ({ provider }: IGetCurrentNetwork) => {
}
};

interface ISwitchNetwork {
provider: StaticJsonRpcProvider | JsonRpcProvider;
networkId: number;
}

export const switchNetwork = async ({ provider, networkId }: ISwitchNetwork) => {
try {
await provider.send("wallet_switchEthereumChain", [{ chainId: idToHexString(networkId) }]);
} catch (e) {
// If the chain has not been added to the user's wallet
// @ts-ignore
if (e.code === 4902) {
const network = NETWORKS[networkId];
const params = [
{
chainId: idToHexString(networkId),
chainName: network["chainName"],
nativeCurrency: network["nativeCurrency"],
rpcUrls: network["rpcUrls"],
blockExplorerUrls: network["blockExplorerUrls"],
},
];

try {
await provider.send("wallet_addEthereumChain", params);
} catch (e) {
console.log(e);
// dispatch(error("Error switching network!"));
}
}
// }
}
};

export const idToHexString = (id: number) => {
return "0x" + id.toString(16);
};
Expand Down
4 changes: 0 additions & 4 deletions src/helpers/QueryParameterHelper.ts

This file was deleted.

26 changes: 0 additions & 26 deletions src/helpers/QueryParameterHelper.unit.test.ts

This file was deleted.

13 changes: 3 additions & 10 deletions src/helpers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
import { formatUnits } from "@ethersproject/units";
import axios from "axios";
import { ethers } from "ethers";
import { OHM_DAI_LP_TOKEN } from "src/constants/tokens";

import { abi as PairContractABI } from "../abi/PairContract.json";
import { NetworkId } from "../constants";
import { PairContract } from "../typechain";
import { ohm_dai } from "./AllBonds";
import { Environment } from "./environment/Environment/Environment";
import { Providers } from "./providers/Providers/Providers";

/**
* gets marketPrice from Ohm-DAI v2
* @returns Number like 333.33
*/
export async function getMarketPrice() {
const mainnetProvider = Providers.getStaticProvider(NetworkId.MAINNET);
// v2 price
const ohm_dai_address = ohm_dai.getAddressForReserve(NetworkId.MAINNET);
const pairContract = new ethers.Contract(ohm_dai_address || "", PairContractABI, mainnetProvider) as PairContract;
const reserves = await pairContract.getReserves();
const contract = OHM_DAI_LP_TOKEN.getEthersContract(NetworkId.MAINNET);
const reserves = await contract.getReserves();

return Number(reserves[1].toString()) / Number(reserves[0].toString()) / 10 ** 9;
}
Expand Down
15 changes: 4 additions & 11 deletions src/hooks/usePrices.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { useQuery } from "react-query";
import { NetworkId } from "src/constants";
import { OHM_DAI_RESERVE_CONTRACT_DECIMALS } from "src/constants/decimals";
import { OHM_DAI_LP_TOKEN, OHM_TOKEN } from "src/constants/tokens";
import { parseBigNumber } from "src/helpers";
import { ohm_dai } from "src/helpers/AllBonds";
import { DecimalBigNumber } from "src/helpers/DecimalBigNumber/DecimalBigNumber";
import { queryAssertion } from "src/helpers/react-query/queryAssertion";
import { assert } from "src/helpers/types/assert";
import { nonNullable } from "src/helpers/types/nonNullable";

import { useStaticPairContract } from "./useContract";
import { useCurrentIndex } from "./useCurrentIndex";

export const ohmPriceQueryKey = () => ["useOhmPrice"];
Expand All @@ -17,16 +14,12 @@ export const ohmPriceQueryKey = () => ["useOhmPrice"];
* Returns the market price of OHM.
*/
export const useOhmPrice = () => {
const address = ohm_dai.getAddressForReserve(NetworkId.MAINNET);
assert(address, "Contract should exist for NetworkId.MAINNET");

const reserveContract = useStaticPairContract(address, NetworkId.MAINNET);

const key = ohmPriceQueryKey();
return useQuery<number, Error>(key, async () => {
const [ohm, dai] = await reserveContract.getReserves();
const contract = OHM_DAI_LP_TOKEN.getEthersContract(NetworkId.MAINNET);
const [ohm, dai] = await contract.getReserves();

return parseBigNumber(dai.div(ohm), OHM_DAI_RESERVE_CONTRACT_DECIMALS);
return parseBigNumber(dai.div(ohm), OHM_TOKEN.decimals);
});
};

Expand Down
Empty file removed src/store/store.dev.js
Empty file.
3 changes: 0 additions & 3 deletions src/views/Stake/Stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ const Stake: React.FC = () => {
<div id="stake-view">
<StakeArea />

{/* NOTE (appleseed-olyzaps) olyzaps disabled until v2 contracts */}
{/* <ZapCta /> */}

<ExternalStakePools />
</div>
);
Expand Down
77 changes: 0 additions & 77 deletions src/views/Zap/ZapCta.tsx

This file was deleted.

Loading

1 comment on commit 7871435

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 67.43% 3317/4919
🔴 Branches 55.42% 1473/2658
🟡 Functions 61.25% 781/1275
🟡 Lines 68.47% 3110/4542

Test suite run success

205 tests passing in 50 suites.

Report generated by 🧪jest coverage report action from 7871435

Please sign in to comment.