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

CHORE: Constants consistency #83

Merged
merged 1 commit into from
Aug 7, 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
4 changes: 2 additions & 2 deletions src/components/farms/Farms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useInternalFarms } from "@/lib/queries/farms/useInternalFarms";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Accordion } from "@/components/ui/accordion";
import { FarmsAccordionRow } from "./row/FarmsAccordionRow";
import { staticExternalFarms } from "@/lib/config/farms";
import { STATIC_EXTERNAL_FARMS } from "@/lib/config/farms";
import { LiquidityMigration } from "./LiquidityMigration";
import { GAlcsWrapper } from "./GAlcxWrapper";
import { windowOpen } from "@/utils/windowOpen";
Expand Down Expand Up @@ -89,7 +89,7 @@ export const Farms = () => {
<p className="text-sm">External Farms</p>
</div>
<div className="flex flex-wrap gap-8 p-4">
{staticExternalFarms.map((farm) => (
{STATIC_EXTERNAL_FARMS.map((farm) => (
<div
key={farm.name}
className="flex w-64 flex-col justify-between gap-2 rounded border border-grey5inverse bg-grey10inverse p-2 dark:bg-grey10"
Expand Down
12 changes: 6 additions & 6 deletions src/components/farms/row/CurveFarmContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useAllowance } from "@/hooks/useAllowance";
import { useWatchQuery } from "@/hooks/useWatchQuery";
import { curve } from "@/lib/config/farms";
import { CURVE } from "@/lib/config/farms";
import { QueryKeys } from "@/lib/queries/queriesSchema";
import { Farm } from "@/lib/types";
import { isInputZero } from "@/utils/inputNotZero";
Expand Down Expand Up @@ -35,7 +35,7 @@ export const CurveFarmContent = ({ farm }: { farm: Farm }) => {
const { address = zeroAddress } = useAccount();

const { data: withdrawBalance, queryKey: balanceQueryKey } = useReadContract({
address: curve.gauge,
address: CURVE.gauge,
abi: curveGaugeAbi,
chainId: chain.id,
functionName: "balanceOf",
Expand All @@ -51,13 +51,13 @@ export const CurveFarmContent = ({ farm }: { farm: Farm }) => {
//-- Deposit --//
const { isApprovalNeeded, approveConfig, approve } = useAllowance({
tokenAddress: farm.poolTokenAddress,
spender: curve.gauge,
spender: CURVE.gauge,
amount: depositAmount,
decimals: 18,
});

const { data: depositConfig } = useSimulateContract({
address: curve.gauge,
address: CURVE.gauge,
abi: curveGaugeAbi,
chainId: chain.id,
functionName: "deposit",
Expand Down Expand Up @@ -93,7 +93,7 @@ export const CurveFarmContent = ({ farm }: { farm: Farm }) => {

//-- Withdraw --//
const { data: withdrawConfig } = useSimulateContract({
address: curve.gauge,
address: CURVE.gauge,
abi: curveGaugeAbi,
chainId: chain.id,
functionName: "withdraw",
Expand Down Expand Up @@ -125,7 +125,7 @@ export const CurveFarmContent = ({ farm }: { farm: Farm }) => {

//-- Claim --//
const { data: claimConfig } = useSimulateContract({
address: curve.gauge,
address: CURVE.gauge,
abi: curveGaugeAbi,
chainId: chain.id,
functionName: "claim_rewards",
Expand Down
8 changes: 4 additions & 4 deletions src/components/farms/row/ExitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sushiMasterchefAbi } from "@/abi/sushiMasterchef";
import { Button } from "@/components/ui/button";
import { useChain } from "@/hooks/useChain";
import { useWriteContractMutationCallback } from "@/hooks/useWriteContractMutationCallback";
import { curve, stakingPoolsAddresses, sushi } from "@/lib/config/farms";
import { CURVE, STAKING_POOL_ADDRESSES, SUSHI } from "@/lib/config/farms";
import { QueryKeys } from "@/lib/queries/queriesSchema";
import { Farm } from "@/lib/types";
import { useQueryClient } from "@tanstack/react-query";
Expand All @@ -29,7 +29,7 @@ export const ExitButton = ({ farm }: { farm: Farm }) => {
//-- Internal --//
const { data: internalExitConfig, error: internalError } =
useSimulateContract({
address: stakingPoolsAddresses[mainnet.id],
address: STAKING_POOL_ADDRESSES[mainnet.id],
abi: stakingPoolsAbi,
chainId: chain.id,
functionName: "exit",
Expand Down Expand Up @@ -57,7 +57,7 @@ export const ExitButton = ({ farm }: { farm: Farm }) => {

//-- Sushi --//
const { data: sushiExitConfig, error: sushiError } = useSimulateContract({
address: sushi.masterchef,
address: SUSHI.masterchef,
abi: sushiMasterchefAbi,
chainId: chain.id,
functionName: "emergencyWithdraw",
Expand All @@ -84,7 +84,7 @@ export const ExitButton = ({ farm }: { farm: Farm }) => {

//-- Curve --//
const { data: curveExitConfig, error: curveError } = useSimulateContract({
address: curve.gauge,
address: CURVE.gauge,
abi: curveGaugeAbi,
chainId: chain.id,
functionName: "withdraw",
Expand Down
12 changes: 6 additions & 6 deletions src/components/farms/row/InternalFarmContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { stakingPoolsAbi } from "@/abi/stakingPools";
import { useAllowance } from "@/hooks/useAllowance";
import { useChain } from "@/hooks/useChain";
import { useWatchQuery } from "@/hooks/useWatchQuery";
import { stakingPoolsAddresses } from "@/lib/config/farms";
import { STAKING_POOL_ADDRESSES } from "@/lib/config/farms";
import { QueryKeys } from "@/lib/queries/queriesSchema";
import { Farm } from "@/lib/types";
import { isInputZero } from "@/utils/inputNotZero";
Expand Down Expand Up @@ -36,7 +36,7 @@ export const InternalFarmContent = ({ farm }: { farm: Farm }) => {
const { address = zeroAddress } = useAccount();

const { data: withdrawBalance, queryKey: balanceQueryKey } = useReadContract({
address: stakingPoolsAddresses[mainnet.id],
address: STAKING_POOL_ADDRESSES[mainnet.id],
abi: stakingPoolsAbi,
chainId: chain.id,
functionName: "getStakeTotalDeposited",
Expand All @@ -52,13 +52,13 @@ export const InternalFarmContent = ({ farm }: { farm: Farm }) => {
//-- Deposit --//
const { isApprovalNeeded, approveConfig, approve } = useAllowance({
tokenAddress: farm.poolTokenAddress,
spender: stakingPoolsAddresses[mainnet.id],
spender: STAKING_POOL_ADDRESSES[mainnet.id],
amount: depositAmount,
decimals: 18,
});

const { data: depositConfig } = useSimulateContract({
address: stakingPoolsAddresses[mainnet.id],
address: STAKING_POOL_ADDRESSES[mainnet.id],
abi: stakingPoolsAbi,
chainId: chain.id,
functionName: "deposit",
Expand Down Expand Up @@ -94,7 +94,7 @@ export const InternalFarmContent = ({ farm }: { farm: Farm }) => {

//-- Withdraw --//
const { data: withdrawConfig } = useSimulateContract({
address: stakingPoolsAddresses[mainnet.id],
address: STAKING_POOL_ADDRESSES[mainnet.id],
abi: stakingPoolsAbi,
chainId: chain.id,
functionName: "withdraw",
Expand Down Expand Up @@ -126,7 +126,7 @@ export const InternalFarmContent = ({ farm }: { farm: Farm }) => {

//-- Claim --//
const { data: claimConfig } = useSimulateContract({
address: stakingPoolsAddresses[mainnet.id],
address: STAKING_POOL_ADDRESSES[mainnet.id],
abi: stakingPoolsAbi,
chainId: chain.id,
functionName: "claim",
Expand Down
12 changes: 6 additions & 6 deletions src/components/farms/row/SushiFarmContent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useAllowance } from "@/hooks/useAllowance";
import { useChain } from "@/hooks/useChain";
import { useWatchQuery } from "@/hooks/useWatchQuery";
import { sushi } from "@/lib/config/farms";
import { SUSHI } from "@/lib/config/farms";
import { QueryKeys } from "@/lib/queries/queriesSchema";
import { Farm } from "@/lib/types";
import { isInputZero } from "@/utils/inputNotZero";
Expand Down Expand Up @@ -35,7 +35,7 @@ export const SushiFarmContent = ({ farm }: { farm: Farm }) => {
const { address = zeroAddress } = useAccount();

const { data: withdrawBalance, queryKey: balanceQueryKey } = useReadContract({
address: sushi.masterchef,
address: SUSHI.masterchef,
abi: sushiMasterchefAbi,
chainId: chain.id,
functionName: "userInfo",
Expand All @@ -51,13 +51,13 @@ export const SushiFarmContent = ({ farm }: { farm: Farm }) => {
//-- Deposit --//
const { isApprovalNeeded, approveConfig, approve } = useAllowance({
tokenAddress: farm.poolTokenAddress,
spender: sushi.masterchef,
spender: SUSHI.masterchef,
amount: depositAmount,
decimals: 18,
});

const { data: depositConfig } = useSimulateContract({
address: sushi.masterchef,
address: SUSHI.masterchef,
abi: sushiMasterchefAbi,
chainId: chain.id,
functionName: "deposit",
Expand Down Expand Up @@ -93,7 +93,7 @@ export const SushiFarmContent = ({ farm }: { farm: Farm }) => {

//-- Withdraw --//
const { data: withdrawConfig } = useSimulateContract({
address: sushi.masterchef,
address: SUSHI.masterchef,
abi: sushiMasterchefAbi,
chainId: chain.id,
functionName: "withdraw",
Expand Down Expand Up @@ -125,7 +125,7 @@ export const SushiFarmContent = ({ farm }: { farm: Farm }) => {

//-- Claim --//
const { data: claimConfig } = useSimulateContract({
address: sushi.masterchef,
address: SUSHI.masterchef,
abi: sushiMasterchefAbi,
chainId: chain.id,
functionName: "harvest",
Expand Down
6 changes: 3 additions & 3 deletions src/components/transmuters/Transmuters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useChain } from "@/hooks/useChain";
import { TransmuterAccordionRow } from "@/components/transmuters/row/TransmuterAccordionRow";
import { useTransmuters } from "@/lib/queries/useTransmuters";
import { Button } from "../ui/button";
import { externalLiquidityProviders } from "@/lib/config/externalLiquidityProviders";
import { EXTERNAL_LIQUIDITY_PROVIDERS } from "@/lib/config/externalLiquidityProviders";
import { windowOpen } from "@/utils/windowOpen";
import { LoadingBar } from "../common/LoadingBar";
import { ScrollArea, ScrollBar } from "../ui/scroll-area";
Expand Down Expand Up @@ -53,12 +53,12 @@ export const Transmuters = () => {
</p>
</div>
<div className="flex max-h-44 flex-col gap-4 overflow-y-auto px-6 py-4 lg:flex-row">
{externalLiquidityProviders[chain.id].map((provider) => (
{EXTERNAL_LIQUIDITY_PROVIDERS[chain.id].map((provider) => (
<Button
key={provider.label}
variant="action"
weight="normal"
className="w-full gap-2 border-grey5inverse dark:border-grey5 lg:w-max"
className="w-full gap-2 border-grey5inverse lg:w-max dark:border-grey5"
onClick={() => windowOpen(provider.url)}
>
<img
Expand Down
12 changes: 6 additions & 6 deletions src/lib/config/externalLiquidityProviders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { arbitrum, fantom, mainnet, optimism } from "viem/chains";

const defaultSwapProviders = [
const DEFAULT_SWAP_PROVIDERS = [
{
label: "Curve",
url: "https://curve.fi/",
Expand All @@ -23,23 +23,23 @@ const defaultSwapProviders = [
},
];

export const externalLiquidityProviders = {
[mainnet.id]: defaultSwapProviders,
export const EXTERNAL_LIQUIDITY_PROVIDERS = {
[mainnet.id]: DEFAULT_SWAP_PROVIDERS,
[optimism.id]: [
...defaultSwapProviders,
...DEFAULT_SWAP_PROVIDERS,
{
label: "Velodrome",
url: "https://velodrome.finance/swap",
icon: "velodrome.svg",
},
],
[arbitrum.id]: [
...defaultSwapProviders,
...DEFAULT_SWAP_PROVIDERS,
{
label: "Ramses",
url: "https://app.ramses.exchange/swap",
icon: "ramses.svg",
},
],
[fantom.id]: defaultSwapProviders,
[fantom.id]: DEFAULT_SWAP_PROVIDERS,
};
10 changes: 5 additions & 5 deletions src/lib/config/farms.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { mainnet } from "viem/chains";

export const stakingPoolsAddresses = {
export const STAKING_POOL_ADDRESSES = {
[mainnet.id]: "0xAB8e74017a8Cc7c15FFcCd726603790d26d7DeCa",
} as const;

export const sushi = {
export const SUSHI = {
pool: "0xC3f279090a47e80990Fe3a9c30d24Cb117EF91a8",
masterchef: "0xEF0881eC094552b2e128Cf945EF17a6752B4Ec5d",
onsenRewarder: "0x7519C93fC5073E15d89131fD38118D73A72370F8",
Expand All @@ -17,7 +17,7 @@ export const sushi = {
},
} as const;

export const curve = {
export const CURVE = {
gauge: "0x9582C4ADACB3BCE56Fea3e590F05c3ca2fb9C477",
metapool: "0x43b4fdfd4ff969587185cdb6f0bd875c5fc83f8c",
rewards: "0xb76256d1091e93976c61449d6e500d9f46d827d4",
Expand All @@ -30,7 +30,7 @@ export const curve = {
},
} as const;

export const internalFarmsMetadata = [
export const INTERNAL_FARMS_METADATA = [
{
type: "internal",
address: "0xbc6da0fe9ad5f3b0d58160288917aa56653660e9",
Expand Down Expand Up @@ -89,7 +89,7 @@ export const internalFarmsMetadata = [
},
] as const;

export const staticExternalFarms = [
export const STATIC_EXTERNAL_FARMS = [
{
icon: "saddle.svg",
name: "Saddle d4",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/config/rewardRouterAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { arbitrum, mainnet, optimism } from "viem/chains";

export const rewardRouterAddresses = {
export const REWARD_ROUTER_ADDRESSES = {
[optimism.id]: "0x343910697C03477E5Cc0D386FfA5133d1A827Ad7",
[arbitrum.id]: "0xaBad1aDaB8A51a00665A3B76DA0E32b2D2F1a6db",
[mainnet.id]: "0x665f58d975963cdE0C843800DF6178FACBfdADE1",
} as const;

export const rewardTokens = {
export const REWARD_TOKENS = {
[optimism.id]: {
rewardTokenAddress: "0x4200000000000000000000000000000000000042",
rewardTokenSymbol: "OP",
Expand All @@ -17,7 +17,7 @@ export const rewardTokens = {
},
} as const;

export const bonusRewardEndTimestamp = {
export const BONUS_REWARDS_END_TIMESTAMPS = {
// December 13th
[optimism.id]: 1734048000,
// September 8th
Expand Down
14 changes: 7 additions & 7 deletions src/lib/middleware/bonuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { getTokenPriceInEth } from "@/lib/queries/useTokenPrice";
import { formatEther, formatUnits } from "viem";
import { rewardRouterAbi } from "@/abi/rewardRouter";
import {
bonusRewardEndTimestamp,
rewardRouterAddresses,
rewardTokens,
BONUS_REWARDS_END_TIMESTAMPS,
REWARD_ROUTER_ADDRESSES,
REWARD_TOKENS,
} from "@/lib/config/rewardRouterAddresses";
import { BonusFn } from "@/lib/config/metadataTypes";
import { getAaveReserves } from "./aave";
Expand Down Expand Up @@ -93,23 +93,23 @@ export const getMeltedRewardsBonusData: BonusFn = async ({

// [rewardCollectorAddress, rewardToken, rewardAmount, rewardTimeframe, lastRewardTimestamp]
const [, , rewardAmount, rewardTimeframe] = await publicClient.readContract({
address: rewardRouterAddresses[chainId],
address: REWARD_ROUTER_ADDRESSES[chainId],
abi: rewardRouterAbi,
functionName: "getRewardCollector",
args: [vault.address],
});

const bonusYieldTokenSymbol = rewardTokens[chainId].rewardTokenSymbol;
const bonusYieldTokenSymbol = REWARD_TOKENS[chainId].rewardTokenSymbol;
const bonusTimeLimit = true;

const rewardEnd = dayjs.unix(bonusRewardEndTimestamp[chainId]);
const rewardEnd = dayjs.unix(BONUS_REWARDS_END_TIMESTAMPS[chainId]);
const distributionTimeAmount = rewardEnd.diff(dayjs(), "days");

const distributionTimeUnit = distributionTimeAmount > 1 ? "days" : "day";

const bonusYieldValue = await getTokenPriceInEth({
chainId,
tokenAddress: rewardTokens[chainId].rewardTokenAddress,
tokenAddress: REWARD_TOKENS[chainId].rewardTokenAddress,
});
const tokenPriceInEth = await getTokenPriceInEth({
chainId,
Expand Down
Loading