Skip to content
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
1 change: 0 additions & 1 deletion apps/hyperdrive-trading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"serve": "vite preview",
"test": "vitest run",
"test:watch": "vitest --reporter=verbose",
"gen:coingecko": "bash ./scripts/generate-coingecko.sh",
"typecheck": "tsc --project tsconfig.json --noEmit",
"gen:version": "bash ./scripts/generate-version.sh",
"gen:walletconnect": "bash ./scripts/generate-walletconnect.sh"
Expand Down
3 changes: 0 additions & 3 deletions apps/hyperdrive-trading/scripts/generate-coingecko.sh

This file was deleted.

1 change: 0 additions & 1 deletion apps/hyperdrive-trading/src/token/coin-gecko.json

This file was deleted.

49 changes: 0 additions & 49 deletions apps/hyperdrive-trading/src/token/coingecko/index.ts

This file was deleted.

45 changes: 0 additions & 45 deletions apps/hyperdrive-trading/src/token/getTokenFiatPrice.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ export function CloseLongForm({
tokenAddress: hyperdrive.poolConfig.vaultSharesToken,
appConfig,
});
if (hyperdrive.withdrawOptions.isShareTokenWithdrawalEnabled) {
// Safe to cast: sharesToken must be defined if its enabled for withdrawal
defaultItems.push(sharesToken!);
if (sharesToken && hyperdrive.withdrawOptions.isShareTokenWithdrawalEnabled) {
defaultItems.push(sharesToken);
}

const { balance: baseTokenBalance } = useTokenBalance({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ export function OpenLongForm({
address: tokenFromTokenList.address as Address,
places: 4,
tags: ["zap"],
// TODO: Change this for a "uniswapv3" price oracle
priceOracle: "defillama",
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ export function LpAndWithdrawalSharesContainer(): ReactElement {
<div className="flex flex-col gap-6" key={hyperdrive.address}>
<div className="flex items-center justify-between">
<div className="flex items-center gap-1 font-chakraPetch text-h4">
<AssetStack hyperdriveAddress={hyperdrive.address} />
<AssetStack
hyperdriveAddress={hyperdrive.address}
hyperdriveChainId={hyperdrive.chainId}
/>
<p className="text-h4">
{/*
This regex removes the term from the hyperdrive name since it's already shown in the table.
Expand Down
21 changes: 11 additions & 10 deletions apps/hyperdrive-trading/src/ui/markets/AssetStack.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import {
appConfig,
getBaseToken,
getHyperdriveConfig,
getToken,
} from "@delvtech/hyperdrive-appconfig";
import { ReactElement } from "react";
import { Address } from "viem";

export function AssetStack({
hyperdriveAddress,
hyperdriveChainId,
}: {
hyperdriveAddress: Address;
hyperdriveChainId: number;
}): ReactElement {
const hyperdrive = appConfig.hyperdrives.find(
(hyperdrive) => hyperdrive.address === hyperdriveAddress,
)!;
const hyperdrive = getHyperdriveConfig({
hyperdriveAddress,
appConfig,
hyperdriveChainId,
});
const baseToken = getBaseToken({
hyperdriveChainId: hyperdrive.chainId,
hyperdriveAddress: hyperdrive.address,
Expand All @@ -39,16 +44,12 @@ export function AssetStack({
<img src={baseToken.iconUrl} className="rounded-full" />
</div>
) : null}
{hyperdrive.poolConfig.vaultSharesToken &&
hyperdrive.depositOptions.isShareTokenDepositsEnabled ? (
{sharesToken && hyperdrive.depositOptions.isShareTokenDepositsEnabled ? (
<div
className="daisy-avatar daisy-tooltip daisy-tooltip-top w-12 overflow-visible before:bg-base-100"
data-tip={sharesToken?.symbol}
data-tip={sharesToken.symbol}
>
<img
src={sharesToken?.iconUrl}
className="rounded-full bg-base-100"
/>
<img src={sharesToken.iconUrl} className="rounded-full bg-base-100" />
</div>
) : null}
</div>
Expand Down
5 changes: 4 additions & 1 deletion apps/hyperdrive-trading/src/ui/markets/PoolDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export function PoolDetails({
Back to All Pools
</Link>
<h1 className="flex items-center gap-2 text-h2">
<AssetStack hyperdriveAddress={hyperdrive.address} />
<AssetStack
hyperdriveAddress={hyperdrive.address}
hyperdriveChainId={hyperdrive.chainId}
/>
{yieldSource.shortName}
</h1>
{marketState?.isPaused && (
Expand Down
4 changes: 4 additions & 0 deletions apps/hyperdrive-trading/src/ui/markets/PoolRow/LpApyStat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export function LpApyStat({
);
}
if (reward.type === "transferableToken") {
// safe to cast because we assume all rewards tokens are
// available in appConfig
const token = getToken({
tokenAddress: reward.tokenAddress,
chainId: reward.chainId,
Expand Down Expand Up @@ -133,6 +135,8 @@ export function LpApyStat({
}

if (reward.type === "nonTransferableToken") {
// safe to cast because we assume all rewards tokens are
// available in appConfig
const token = getToken({
tokenAddress: reward.tokenAddress,
chainId: reward.chainId,
Expand Down
5 changes: 4 additions & 1 deletion apps/hyperdrive-trading/src/ui/markets/PoolRow/PoolRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export function PoolRow({ hyperdrive }: PoolRowProps): ReactElement {
"w-16"
}
>
<AssetStack hyperdriveAddress={hyperdrive.address} />
<AssetStack
hyperdriveAddress={hyperdrive.address}
hyperdriveChainId={hyperdrive.chainId}
/>
</div>
<div className="flex flex-col gap-1.5">
<h4 className="text-left">{yieldSource.shortName}</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export function YieldMultiplierStat({
);
}
if (reward.type === "transferableToken") {
// safe to cast because we assume all rewards tokens are
// available in appConfig
const token = getToken({
tokenAddress: reward.tokenAddress,
chainId: reward.chainId,
Expand Down Expand Up @@ -142,6 +144,8 @@ export function YieldMultiplierStat({
}

if (reward.type === "nonTransferableToken") {
// safe to cast because we assume all rewards tokens are
// available in appConfig
const token = getToken({
tokenAddress: reward.tokenAddress,
chainId: reward.chainId,
Expand Down
29 changes: 23 additions & 6 deletions apps/hyperdrive-trading/src/ui/token/hooks/useTokenFiatPrice.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { appConfig, getPriceOracleFn } from "@delvtech/hyperdrive-appconfig";
import { useQuery } from "@tanstack/react-query";
import { getPublicClient } from "@wagmi/core";
import { ZERO_ADDRESS } from "src/base/constants";
import { makeQueryKey } from "src/base/makeQueryKey";
import { isTestnetChain } from "src/chains/isTestnetChain";
import { getTokenFiatPrice } from "src/token/getTokenFiatPrice";
import { Address } from "viem";
import { wagmiConfig } from "src/network/wagmiClient";
import { Address, PublicClient } from "viem";

export function useTokenFiatPrice({
tokenAddress,
Expand All @@ -13,17 +16,31 @@ export function useTokenFiatPrice({
}): {
fiatPrice: bigint | undefined;
} {
const queryEnabled = !isTestnetChain(chainId) && !!tokenAddress;
const queryEnabled =
!isTestnetChain(chainId) && !!tokenAddress && tokenAddress !== ZERO_ADDRESS;

const { data } = useQuery({
queryKey: makeQueryKey("tokenFiatPrice", { chainId, tokenAddress }),
enabled: queryEnabled,
queryFn: queryEnabled
? async () =>
getTokenFiatPrice({
? async () => {
const publicClient = getPublicClient(wagmiConfig as any, {
chainId,
}) as PublicClient;

const priceOracleFn = getPriceOracleFn({
chainId,
tokenAddress,
appConfig,
});

return priceOracleFn({
chainId,
})
denomination: "usd",
publicClient,
tokenAddress,
});
}
: undefined,
});
return { fiatPrice: data };
Expand Down
Loading
Loading