Skip to content

Commit

Permalink
Adds cloudchain pools to config (#1705)
Browse files Browse the repository at this point in the history
* adds zaps config

* add correct rpc urls
  • Loading branch information
jackburrus authored Jan 2, 2025
1 parent e090f92 commit 28f18e4
Show file tree
Hide file tree
Showing 13 changed files with 1,890 additions and 321 deletions.
6 changes: 2 additions & 4 deletions apps/hyperdrive-trading/src/hyperdrive/getLpApy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "@delvtech/hyperdrive-appconfig";
import { ReadHyperdrive } from "@delvtech/hyperdrive-js";
import { convertMillisecondsToDays } from "src/base/convertMillisecondsToDays";
import { isForkChain } from "src/chains/isForkChain";
import { queryClient } from "src/network/queryClient";
import { makeRewardsQuery } from "src/ui/rewards/useRewards";

Expand Down Expand Up @@ -61,9 +60,8 @@ export async function getLpApy({
appConfig,
});

const numBlocksForHistoricalRate = isForkChain(hyperdrive.chainId)
? 1000n // roughly 3 hours for cloudchain
: chainConfig.dailyAverageBlocks * BigInt(yieldSource.historicalRatePeriod);
const numBlocksForHistoricalRate =
chainConfig.dailyAverageBlocks * BigInt(yieldSource.historicalRatePeriod);

const targetFromBlock = currentBlockNumber - numBlocksForHistoricalRate;

Expand Down
6 changes: 2 additions & 4 deletions apps/hyperdrive-trading/src/hyperdrive/getYieldSourceRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from "@delvtech/hyperdrive-appconfig";
import { ReadHyperdrive } from "@delvtech/hyperdrive-js";
import { convertMillisecondsToDays } from "src/base/convertMillisecondsToDays";
import { isForkChain } from "src/chains/isForkChain";
import { queryClient } from "src/network/queryClient";
import { makeRewardsQuery } from "src/ui/rewards/useRewards";

Expand Down Expand Up @@ -126,9 +125,8 @@ function getNumBlocksForHistoricalRate({
});
const historicalRatePeriod = yieldSource.historicalRatePeriod;

const numBlocksForHistoricalRate = isForkChain(hyperdrive.chainId)
? 1000n // roughly 3 hours for cloudchain
: blocksPerDay * BigInt(historicalRatePeriod);
const numBlocksForHistoricalRate =
blocksPerDay * BigInt(historicalRatePeriod);

return numBlocksForHistoricalRate;
}
14 changes: 10 additions & 4 deletions apps/hyperdrive-trading/src/ui/markets/PoolRow/LpApyCta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { HyperdriveConfig } from "@delvtech/hyperdrive-appconfig";
import { Link } from "@tanstack/react-router";
import { ReactElement } from "react";
import { Tooltip } from "src/ui/base/components/Tooltip/Tooltip";
import { useFeatureFlag } from "src/ui/base/featureFlags/featureFlags";
import { useLpApy } from "src/ui/hyperdrive/lp/hooks/useLpApy";
import { LpApyStat } from "src/ui/markets/PoolRow/LpApyStat";
import { PoolStat } from "src/ui/markets/PoolRow/PoolStat";
Expand All @@ -21,6 +22,8 @@ export function LpApyCta({ hyperdrive }: LpApyCtaProps): ReactElement {
chainId: hyperdrive.chainId,
});

const { isFlagEnabled: isZapsEnabled } = useFeatureFlag("zaps");

const label = lpApy ? `LP APY (${lpApy.ratePeriodDays}d)` : "LP APY";

return (
Expand All @@ -38,10 +41,13 @@ export function LpApyCta({ hyperdrive }: LpApyCtaProps): ReactElement {
isLoading={lpApyStatus === "loading"}
isNew={lpApy?.isNew}
value={
<LpApyStat
chainId={hyperdrive.chainId}
hyperdriveAddress={hyperdrive.address}
/>
// TODO: LP APY stat is broken on cloudchain due to issues with the mainnet fork blocktimes. This can be removed once zaps are fully implemented.
isZapsEnabled ? null : (
<LpApyStat
chainId={hyperdrive.chainId}
hyperdriveAddress={hyperdrive.address}
/>
)
}
action={
<div className="daisy-indicator">
Expand Down
4 changes: 3 additions & 1 deletion packages/hyperdrive-appconfig/src/appconfig/AppConfig.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Address } from "abitype";
import { ChainConfig } from "src/chains/chains";
import { ChainConfig, ChainId } from "src/chains/chains";
import { HyperdriveConfig } from "src/hyperdrives/HyperdriveConfig";
import { protocols } from "src/protocols";
import { TokenConfig } from "src/tokens/types";
import { yieldSources } from "src/yieldSources/yieldSources";
import { ZapConfig } from "src/zaps/ZapsConfig";

export interface AppConfig {
chains: Record<number, ChainConfig>;
Expand All @@ -15,4 +16,5 @@ export interface AppConfig {
tokens: TokenConfig[];
protocols: typeof protocols;
yieldSources: typeof yieldSources;
zaps: Record<ChainId, ZapConfig>;
}
4 changes: 3 additions & 1 deletion packages/hyperdrive-appconfig/src/appconfig/getAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import {
import { TokenConfig } from "src/tokens/types";
import { YieldSourceId } from "src/yieldSources/types";
import { yieldSources } from "src/yieldSources/yieldSources";
import { zaps } from "src/zaps/zaps";
import { Address, PublicClient } from "viem";

type HyperdriveConfigResolver = (
hyperdrive: ReadHyperdrive,
publicClient: PublicClient,
Expand Down Expand Up @@ -204,6 +204,7 @@ const hyperdriveKindResolvers: Record<
if (hyperdriveName.includes("sGYD Hyperdrive")) {
const yieldSourceByChainId: Record<number, YieldSourceId> = {
1: "sgyd",
707: "sgyd", // cloudchain is a mainnet fork
100: "gnosisSgyd",
};
const yieldSource =
Expand Down Expand Up @@ -636,6 +637,7 @@ export async function getAppConfig({
protocols,
yieldSources,
chains,
zaps,
};

return config;
Expand Down
22 changes: 12 additions & 10 deletions packages/hyperdrive-appconfig/src/chains/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ export const sepoliaChainConfig: ChainConfig = {
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMqADAAQAAAABAAAAMgAAAAB1y6+rAAAFjUlEQVRYCaVZW28TRxT2em3HGEqcBERERQEVEWipCKiRKrUSaaU+8xeo1If+gfBUCfWHtK88IcEbFaIg1KhURU3SCnEppiE32a7jmMR2fNlLv9nxzo53x7Mzy8qyz56Zc86353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Am+VttBmZC/2ltnp+nYTurYlIkMzZzMmqaBcj/6swul+mHovt8C93/4boIF+HW5c+dha7vhYLOA1g9eo2p4WsQKzeaQu2Rf+SYkBPSy5RoxbwRYAAi7TQcV/OTM4Knrg+kMMgdH/6z1+aoxk5WXvbWKUgulJqg91kRSxOjTI3MqFFDKmVM5tmYX8mmgRE3zWQNdDVVjVvW3zqOlDjtVEbx3RMp9K+Txp9t7yBmvBMrJ8aF2A0o9eLLPz4mVmUfmiGlibckEbLBu3m3Kp6J8OpQizlieGSw0L6aUhxuMoqPee9weNfXVev/VRtDGRk3j9XxiGCzcALyenz9SvvOwjTU4Oozy/fG0F9VLNbjtgiOA5en0kIFeP97eDZz50oMnHfUd38BoeKkJwcJbSd+32u+L1X6olKBUfVeQQok/8ip0OG4IlvYzI4LdvNvCFp5GRfmWX+qXbzhVcBWGJbkmyRDtF72++/Nveh1h1Pti1W2gBBOG0C+wBG1WLM2OQCvHc30QRwbLWwfkeILRe4/18gQ+0YYeuOAkWRH9ig+zkTN+B1GGCW5lsPyo9E8D/+zdfv13a4LC8Y5VYJElHTbePxq8rZ7s5Rw9Uyn3SrBofA6ckmtqhanYOJEvch6TJGqCbxnl2SRe4HlK8uclko82gAxGAwRdaIfWFd7ZSPl/Ad8oNMb3hysAAAAASUVORK5CYII=",
earliestBlock: 6137333n, // The first pool to be deployed, as it pre-dates the registry
};
export const cloudChainConfig = {
id: cloudChain.id,
name: "Cloudchain",
isTestnet: true,
dailyAverageBlocks: 7172n,
blockExplorerName: "Etherscan",
blockExplorerUrl: "https://etherscan.io",
earliestBlock: 20180617n, // The first pool to be deployed, as it pre-dates the registry
iconUrl:
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMqADAAQAAAABAAAAMgAAAAB1y6+rAAAFjUl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X45brmpeuLHDbL+ZWIJRrdiFvfPnpgcvnxgCxtGFt/WeX1vuT4ya9FSgsQKnu2M0O2Zdg9/zVXB43IHrp3yXldpo2zEvzCwIII1SvN6y5C/mjRRPIsLdZet5tNAm+VttBmZC/2ltnp+nYTurYlIkMzZzMmqaBcj/6swul+mHovt8C93/4boIF+HW5c+dha7vhYLOA1g9eo2p4WsQKzeaQu2Rf+SYkBPSy5RoxbwRYAAi7TQcV/OTM4Knrg+kMMgdH/6z1+aoxk5WXvbWKUgulJqg91kRSxOjTI3MqFFDKmVM5tmYX8mmgRE3zWQNdDVVjVvW3zqOlDjtVEbx3RMp9K+Txp9t7yBmvBMrJ8aF2A0o9eLLPz4mVmUfmiGlibckEbLBu3m3Kp6J8OpQizlieGSw0L6aUhxuMoqPee9weNfXVev/VRtDGRk3j9XxiGCzcALyenz9SvvOwjTU4Oozy/fG0F9VLNbjtgiOA5en0kIFeP97eDZz50oMnHfUd38BoeKkJwcJbSd+32u+L1X6olKBUfVeQQok/8ip0OG4IlvYzI4LdvNvCFp5GRfmWX+qXbzhVcBWGJbkmyRDtF72++/Nveh1h1Pti1W2gBBOG0C+wBG1WLM2OQCvHc30QRwbLWwfkeILRe4/18gQ+0YYeuOAkWRH9ig+zkTN+B1GGCW5lsPyo9E8D/+zdfv13a4LC8Y5VYJElHTbePxq8rZ7s5Rw9Uyn3SrBofA6ckmtqhanYOJEvch6TJGqCbxnl2SRe4HlK8uclko82gAxGAwRdaIfWFd7ZSPl/Ad8oNMb3hysAAAAASUVORK5CYII=",
};
export const chains: Record<ChainId, ChainConfig> = {
/* Public chains */
[mainnet.id]: mainnetChainConfig,
Expand All @@ -95,16 +106,7 @@ export const chains: Record<ChainId, ChainConfig> = {
[sepolia.id]: sepoliaChainConfig,

/* Internal Testnets */
[cloudChain.id]: {
id: cloudChain.id,
name: "Cloudchain",
isTestnet: true,
dailyAverageBlocks: 7172n,
blockExplorerName: "Etherscan",
blockExplorerUrl: "https://etherscan.io",
iconUrl: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",
Expand Down
4 changes: 2 additions & 2 deletions packages/hyperdrive-appconfig/src/chains/cloudChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const cloudChain = defineChain({
name: "CloudChain",
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
rpcUrls: {
public: { http: [process.env.CLOUDCHAIN_NODE_RPC_URL as string] },
default: { http: [process.env.CLOUDCHAIN_NODE_RPC_URL as string] },
public: { http: [process.env.CLOUDCHAIN_RPC_URL as string] },
default: { http: [process.env.CLOUDCHAIN_RPC_URL as string] },
},
});
Loading

0 comments on commit 28f18e4

Please sign in to comment.