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
4 changes: 2 additions & 2 deletions apps/hyperdrive-trading/src/hyperdrive/getLpApy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { fixed } from "@delvtech/fixed-point-wasm";
import {
appConfig,
findYieldSource,
getRewardsFn,
getYieldSource,
HyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { ReadHyperdrive } from "@delvtech/hyperdrive-js";
Expand Down Expand Up @@ -50,7 +50,7 @@
const currentBlock = (await readHyperdrive.drift.getBlock()) as Block;
const currentBlockNumber = currentBlock.blockNumber!;
// Appconfig tells us how many days to look back for historical rates
const yieldSource = findYieldSource({
const yieldSource = getYieldSource({
hyperdriveAddress: hyperdrive.address,
hyperdriveChainId: hyperdrive.chainId,
appConfig,
Expand Down Expand Up @@ -80,7 +80,7 @@
});
lpApy = lpApyResult.lpApy;
netLpApy = lpApy;
const publicClient = getPublicClient(wagmiConfig as any, {

Check warning on line 83 in apps/hyperdrive-trading/src/hyperdrive/getLpApy.ts

View workflow job for this annotation

GitHub Actions / verify (lint)

Unexpected any. Specify a different type
chainId: hyperdrive.chainId,
}) as PublicClient;
const rewardsFn = getRewardsFn({
Expand Down
14 changes: 7 additions & 7 deletions apps/hyperdrive-trading/src/hyperdrive/getYieldSourceRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { fixed } from "@delvtech/fixed-point-wasm";
import {
AppConfig,
findHyperdriveConfig,
findYieldSource,
getHyperdriveConfig,
getRewardsFn,
getYieldSource,
HyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { ReadHyperdrive } from "@delvtech/hyperdrive-js";
Expand All @@ -19,10 +19,10 @@
appConfig: AppConfig,
): Promise<{ rate: bigint; ratePeriodDays: number; netRate: bigint }> {
const hyperdriveChainId = await readHyperdrive.drift.getChainId();
const hyperdrive = findHyperdriveConfig({
const hyperdrive = getHyperdriveConfig({
hyperdriveChainId,
hyperdriveAddress: readHyperdrive.address,
hyperdrives: appConfig.hyperdrives,
appConfig,
});

const numBlocksForHistoricalRate = getNumBlocksForHistoricalRate({
Expand Down Expand Up @@ -67,10 +67,10 @@

const netRate = await calcNetRate(rate, appConfig, hyperdrive);

const yieldSource = findYieldSource({
appConfig,
const yieldSource = getYieldSource({
hyperdriveAddress: hyperdrive.address,
hyperdriveChainId: hyperdrive.chainId,
appConfig,
});

return {
Expand All @@ -91,7 +91,7 @@
appConfig,
});
if (rewardsFn) {
const publicClient = getPublicClient(wagmiConfig as any, {

Check warning on line 94 in apps/hyperdrive-trading/src/hyperdrive/getYieldSourceRate.ts

View workflow job for this annotation

GitHub Actions / verify (lint)

Unexpected any. Specify a different type
chainId: hyperdrive.chainId,
}) as PublicClient;
const rewards = await rewardsFn(publicClient);
Expand All @@ -115,7 +115,7 @@
hyperdrive: HyperdriveConfig;
}) {
const blocksPerDay = appConfig.chains[hyperdrive.chainId].dailyAverageBlocks;
const yieldSource = findYieldSource({
const yieldSource = getYieldSource({
hyperdriveAddress: hyperdrive.address,
hyperdriveChainId: hyperdrive.chainId,
appConfig,
Expand Down
6 changes: 3 additions & 3 deletions apps/hyperdrive-trading/src/token/getTokenFiatPrice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseFixed } from "@delvtech/fixed-point-wasm";
import { appConfig, findToken } from "@delvtech/hyperdrive-appconfig";
import { appConfig, getToken } from "@delvtech/hyperdrive-appconfig";
import { fetchCoinGeckoPrice } from "src/token/coingecko";
import { ETH_MAGIC_NUMBER } from "src/token/ETH_MAGIC_NUMBER";
import { Address } from "viem";
Expand All @@ -26,10 +26,10 @@ export async function getTokenFiatPrice({
let price = data?.coins?.[defiLlamaTokenId]?.price;
if (price === undefined) {
// fallback to coingecko if defillama is not available
const tokenConfig = findToken({
const tokenConfig = getToken({
chainId,
tokenAddress,
tokens: appConfig.tokens,
appConfig,
});
price = await fetchCoinGeckoPrice(tokenConfig!.symbol);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AppConfig,
HyperdriveConfig,
appConfig,
findBaseToken,
getBaseToken,
makeAddressUrl,
makeTransactionUrl,
} from "@delvtech/hyperdrive-appconfig";
Expand Down Expand Up @@ -182,7 +182,7 @@ export function TransactionTable({
}

function getColumns(hyperdrive: HyperdriveConfig, appConfig: AppConfig) {
const baseToken = findBaseToken({
const baseToken = getBaseToken({
hyperdriveChainId: hyperdrive.chainId,
hyperdriveAddress: hyperdrive.address,
appConfig,
Expand Down Expand Up @@ -305,7 +305,7 @@ function formatTransactionTableMobileData(
hyperdrive: HyperdriveConfig,
appConfig: AppConfig,
) {
const baseToken = findBaseToken({
const baseToken = getBaseToken({
hyperdriveChainId: hyperdrive.chainId,
hyperdriveAddress: hyperdrive.address,
appConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
appConfig,
findHyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { appConfig, getHyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
import { makeQueryKey } from "src/base/makeQueryKey";
Expand Down Expand Up @@ -37,10 +34,10 @@ export function useTransactionData({
address: hyperdriveAddress,
});

const { decimals } = findHyperdriveConfig({
const { decimals } = getHyperdriveConfig({
hyperdriveAddress,
hyperdriveChainId: chainId,
hyperdrives: appConfig.hyperdrives,
appConfig,
});

const { data: longs, status: longEventsStatus } = useQuery({
Expand Down
9 changes: 3 additions & 6 deletions apps/hyperdrive-trading/src/ui/hyperdrive/hooks/useLpApy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
appConfig,
findHyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { appConfig, getHyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
import { useQuery } from "@tanstack/react-query";
import { makeQueryKey } from "src/base/makeQueryKey";
import { getLpApy, LpApyResult } from "src/hyperdrive/getLpApy";
Expand All @@ -25,10 +22,10 @@ export function useLpApy({
chainId,
});

const hyperdrive = findHyperdriveConfig({
const hyperdrive = getHyperdriveConfig({
hyperdriveChainId: chainId,
hyperdriveAddress,
hyperdrives: appConfig.hyperdrives,
appConfig,
});

const { data: blockNumber } = useBlockNumber({ chainId });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
AppConfig,
appConfig,
findHyperdriveConfig,
findYieldSource,
getHyperdriveConfig,
getYieldSource,
} from "@delvtech/hyperdrive-appconfig";
import { ReadHyperdrive } from "@delvtech/hyperdrive-js";
import { useQuery } from "@tanstack/react-query";
Expand Down Expand Up @@ -67,16 +67,16 @@ export async function prepareSharesIn({
sharesAmount: bigint;
readHyperdrive: ReadHyperdrive;
}): Promise<bigint> {
const hyperdriveConfig = findHyperdriveConfig({
const hyperdriveConfig = getHyperdriveConfig({
hyperdriveChainId: chainId,
hyperdrives: appConfig.hyperdrives,
hyperdriveAddress: readHyperdrive.address,
appConfig,
});

// If the shares token is pegged to its base token (e.g., stETH to ETH), then
// we need to treat the amount as if it were base. To get the actual shares
// amount then, we convert to the shares used by the pool (eg: lidoShares).
const yieldSource = findYieldSource({
const yieldSource = getYieldSource({
hyperdriveAddress: hyperdriveConfig.address,
hyperdriveChainId: hyperdriveConfig.chainId,
appConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
AppConfig,
appConfig,
findHyperdriveConfig,
findYieldSource,
getHyperdriveConfig,
getYieldSource,
} from "@delvtech/hyperdrive-appconfig";
import { ReadHyperdrive } from "@delvtech/hyperdrive-js";
import { useQuery } from "@tanstack/react-query";
Expand Down Expand Up @@ -71,18 +71,18 @@ export async function prepareSharesOut({
return sharesAmount;
}

const hyperdriveConfig = findHyperdriveConfig({
const hyperdriveConfig = getHyperdriveConfig({
hyperdriveChainId: chainId,
hyperdrives: appConfig.hyperdrives,
hyperdriveAddress: readHyperdrive.address,
appConfig,
});

// If the shares token is pegged to its base token (e.g., stETH to ETH), then
// we need to treat the shares amount out as base. To get the actual shares
// amount then, we convert to base. For example, when preparing lido shares
// received back from a steth hyperdrive, this will convert lido shares to
// eth, and since 1 eth = 1 steth we return this as the shares value.
const yieldSource = findYieldSource({
const yieldSource = getYieldSource({
hyperdriveAddress: hyperdriveConfig.address,
hyperdriveChainId: hyperdriveConfig.chainId,
appConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
appConfig,
findHyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { appConfig, getHyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
import { getHyperdrive, ReadHyperdrive } from "@delvtech/hyperdrive-js";
import { useQuery } from "@tanstack/react-query";
import { makeQueryKey } from "src/base/makeQueryKey";
Expand All @@ -26,10 +23,10 @@ export function useReadHyperdrive({
enabled,
queryFn: enabled
? () => {
const { initializationBlock } = findHyperdriveConfig({
const { initializationBlock } = getHyperdriveConfig({
hyperdriveAddress: address,
hyperdriveChainId: chainId,
hyperdrives: appConfig.hyperdrives,
appConfig,
});
return getHyperdrive({
address,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
appConfig,
findHyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { appConfig, getHyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
import { getHyperdrive, ReadWriteHyperdrive } from "@delvtech/hyperdrive-js";
import { useQuery } from "@tanstack/react-query";
import { makeQueryKey } from "src/base/makeQueryKey";
Expand All @@ -27,10 +24,10 @@ export function useReadWriteHyperdrive({
enabled,
queryFn: enabled
? () => {
const { initializationBlock } = findHyperdriveConfig({
const { initializationBlock } = getHyperdriveConfig({
hyperdriveAddress: address,
hyperdriveChainId: chainId,
hyperdrives: appConfig.hyperdrives,
appConfig,
});
return getHyperdrive({
address,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
appConfig,
findHyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { appConfig, getHyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
import { useQuery } from "@tanstack/react-query";
import { makeQueryKey } from "src/base/makeQueryKey";
import { useReadHyperdrive } from "src/ui/hyperdrive/hooks/useReadHyperdrive";
Expand All @@ -17,10 +14,10 @@ export function useTradingVolume(
shortVolume: bigint | undefined;
tradingVolumeStatus: "loading" | "error" | "success";
} {
const hyperdrive = findHyperdriveConfig({
const hyperdrive = getHyperdriveConfig({
hyperdriveChainId: chainId,
hyperdriveAddress,
hyperdrives: appConfig.hyperdrives,
appConfig,
});
const readHyperdrive = useReadHyperdrive({
chainId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fixed } from "@delvtech/fixed-point-wasm";
import {
appConfig,
findBaseToken,
findToken,
getBaseToken,
getToken,
HyperdriveConfig,
TokenConfig,
} from "@delvtech/hyperdrive-appconfig";
Expand Down Expand Up @@ -40,7 +40,7 @@ export function CloseLongForm({
const { address: account } = useAccount();

const defaultItems: TokenConfig[] = [];
const baseToken = findBaseToken({
const baseToken = getBaseToken({
hyperdriveAddress: hyperdrive.address,
hyperdriveChainId: hyperdrive.chainId,
appConfig,
Expand All @@ -49,10 +49,10 @@ export function CloseLongForm({
defaultItems.push(baseToken);
}

const sharesToken = findToken({
const sharesToken = getToken({
chainId: hyperdrive.chainId,
tokenAddress: hyperdrive.poolConfig.vaultSharesToken,
tokens: appConfig.tokens,
appConfig,
});
if (hyperdrive.withdrawOptions.isShareTokenWithdrawalEnabled) {
// Safe to cast: sharesToken must be defined if its enabled for withdrawal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
HyperdriveConfig,
TokenConfig,
appConfig,
findBaseToken,
findToken,
getBaseToken,
getToken,
} from "@delvtech/hyperdrive-appconfig";
import { Long } from "@delvtech/hyperdrive-js";
import { ReactElement } from "react";
Expand All @@ -21,15 +21,15 @@ export function CloseLongModalButton({
long,
hyperdrive,
}: CloseLongModalButtonProps): ReactElement {
const baseToken = findBaseToken({
const baseToken = getBaseToken({
hyperdriveChainId: hyperdrive.chainId,
hyperdriveAddress: hyperdrive.address,
appConfig,
});
const sharesToken = findToken({
const sharesToken = getToken({
chainId: hyperdrive.chainId,
tokenAddress: hyperdrive.poolConfig.vaultSharesToken,
tokens: appConfig.tokens,
appConfig,
});

const subHeading = sharesToken
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fixed } from "@delvtech/fixed-point-wasm";
import {
appConfig,
findBaseToken,
findToken,
getBaseToken,
getToken,
HyperdriveConfig,
} from "@delvtech/hyperdrive-appconfig";
import { adjustAmountByPercentage } from "@delvtech/hyperdrive-js";
Expand Down Expand Up @@ -71,7 +71,7 @@ export function OpenLongForm({
hyperdriveAddress: hyperdrive.address,
chainId: hyperdrive.chainId,
});
const baseToken = findBaseToken({
const baseToken = getBaseToken({
hyperdriveChainId: hyperdrive.chainId,
hyperdriveAddress: hyperdrive.address,
appConfig,
Expand All @@ -97,10 +97,10 @@ export function OpenLongForm({
});
}

const sharesToken = findToken({
const sharesToken = getToken({
chainId: hyperdrive.chainId,
tokens: appConfig.tokens,
tokenAddress: hyperdrive.poolConfig.vaultSharesToken,
appConfig,
});

if (sharesToken && hyperdrive.depositOptions.isShareTokenDepositsEnabled) {
Expand Down
Loading
Loading