Skip to content

Commit

Permalink
Merge pull request #1776 from galacticcouncil/86c0uwc86
Browse files Browse the repository at this point in the history
Add Paseo rpc config
  • Loading branch information
vkulinich-cl authored Dec 9, 2024
2 parents 14268bf + 335df96 commit a00bf73
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VITE_PROVIDER_URL=wss://rpc.nice.hydration.cloud
VITE_DOMAIN_URL=https://testnet-mining-app.hydradx.io
VITE_INDEXER_URL=https://archive.nice.hydration.cloud/graphql
VITE_SQUID_URL=https://data-squid.nice.hydration.cloud/graphql
VITE_SQUID_URL=https://galacticcouncil.squids.live/hydration-pools:prod/api/graphql
VITE_GRAFANA_URL=https://grafana-api.play.hydration.cloud/api/ds/query
VITE_GRAFANA_DSN=11
VITE_ENV=development
Expand Down
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VITE_PROVIDER_URL=wss://rpc.hydradx.cloud
VITE_DOMAIN_URL=https://app.hydration.net
VITE_INDEXER_URL=https://explorer.hydradx.cloud/graphql
VITE_SQUID_URL=https://hydra-data-squid.play.hydration.cloud/graphql
VITE_SQUID_URL=https://galacticcouncil.squids.live/hydration-pools:prod/api/graphql
VITE_GRAFANA_URL=https://grafana.hydradx.cloud/api/ds/query
VITE_GRAFANA_DSN=10
VITE_ENV=production
Expand Down
8 changes: 4 additions & 4 deletions .env.rococo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VITE_PROVIDER_URL=wss://rpc.nice.hydration.cloud
VITE_DOMAIN_URL=https://rococo-app.hydradx.io
VITE_INDEXER_URL=https://hydradx-rococo-explorer.play.hydration.cloud/graphql
VITE_SQUID_URL=https://squid.subsquid.io/hydradx-rococo-data-squid/v/v1/graphql
VITE_PROVIDER_URL=wss://paseo-rpc.play.hydration.cloud
VITE_DOMAIN_URL=https://paseo-app.hydration.net
VITE_INDEXER_URL=https://explorer.hydradx.cloud/graphql
VITE_SQUID_URL=https://galacticcouncil.squids.live/hydration-paseo-pools:prod/api/graphql
VITE_GRAFANA_URL=https://grafana-api.play.hydration.cloud/api/ds/query
VITE_GRAFANA_DSN=11
VITE_ENV=rococo
Expand Down
118 changes: 72 additions & 46 deletions src/api/bonds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type Bond = {
}

export const useLbpPool = (params?: { id?: string }) => {
const { api } = useRpcProvider()
const { api, isLoaded } = useRpcProvider()

const { id } = params ?? {}

Expand Down Expand Up @@ -49,7 +49,7 @@ export const useLbpPool = (params?: { id?: string }) => {
return data
},
{
enabled: !(params && !id),
enabled: !(params && !id) && isLoaded,
select: (pools) => {
if (id) {
const pool = pools.find((pool) =>
Expand Down Expand Up @@ -355,31 +355,38 @@ export const useHistoricalPoolBalance = (pool?: string, block?: number) => {
}

type THistoricalPoolBalance = {
id: string
poolId: string
assetBId: number
assetAId: number
historicalBalances: Array<{
assetABalance: string
assetBBalance: string
}>
paraChainBlockHeight: number
assetBBalance: string
assetABalance: string
}

const getHistoricalPoolBalance =
(url: string, pool: string, block: number) => async () => {
return {
...(await request<{
pools: Array<THistoricalPoolBalance>
lbpPoolHistoricalData: { nodes: Array<THistoricalPoolBalance> }
}>(
url,
gql`
query PoolHistoricalBalance($pool: String, $block: Int) {
pools(where: { id_eq: $pool }) {
id
assetBId
assetAId
historicalBalances(where: { paraChainBlockHeight_eq: $block }) {
assetABalance
lbpPoolHistoricalData(
filter: {
poolId: { equalTo: $pool }
paraChainBlockHeight: { lessThanOrEqualTo: $block }
}
orderBy: PARA_CHAIN_BLOCK_HEIGHT_DESC
first: 1
) {
nodes {
assetBBalance
assetABalance
assetAId
assetBId
paraChainBlockHeight
poolId
}
}
}
Expand All @@ -391,13 +398,23 @@ const getHistoricalPoolBalance =

export const useLBPAveragePrice = (poolAddress?: string) => {
const { getAssets } = useAssets()
const url = useSquidUrl()

return useQuery(
QUERY_KEYS.lbpAveragePrice(poolAddress),
poolAddress
? async () => {
const { historicalVolumes } = await getLBPAveragePrice(poolAddress)()
const { assetAId, assetBId, averagePrice, id } =
historicalVolumes?.[0] ?? []
const { lbpPoolHistoricalVolumes } = await getLBPAveragePrice(
url,
poolAddress,
)()

const {
assetAId,
assetBId,
averagePrice,
poolId: id,
} = lbpPoolHistoricalVolumes?.edges?.[0].node ?? {}
const [assetAMeta, assetBMeta] = getAssets([
assetAId?.toString(),
assetBId?.toString(),
Expand All @@ -414,34 +431,43 @@ export const useLBPAveragePrice = (poolAddress?: string) => {
)
}

const getLBPAveragePrice = (poolAddress: string) => async () => {
return {
...(await request<{
historicalVolumes: Array<{
averagePrice: number
assetAId: number
assetBId: number
id: string
}>
}>(
"https://squid.subsquid.io/hydradx-lbp-squid/graphql",
gql`
query LBPAveragePrice($poolAddress: String) {
historicalVolumes(
orderBy: id_DESC
limit: 1
where: { id_contains: $poolAddress }
) {
averagePrice
assetAId
assetBId
id
}
const getLBPAveragePrice =
(indexerUrl: string, poolAddress: string) => async () => {
return {
...(await request<{
lbpPoolHistoricalVolumes: {
edges: Array<{
node: {
averagePrice: string
assetAId: string
assetBId: string
poolId: string
}
}>
}
`,
{
poolAddress,
},
)),
}>(
indexerUrl,
gql`
query LBPAveragePrice($poolAddress: String) {
lbpPoolHistoricalVolumes(
filter: { poolId: { equalTo: $poolAddress } }
orderBy: ID_DESC
last: 1
) {
edges {
node {
averagePrice
assetAId
assetBId
poolId
}
}
}
}
`,
{
poolAddress,
},
)),
}
}
}
26 changes: 21 additions & 5 deletions src/api/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,47 +37,63 @@ export type TFeatureFlags = {
dispatchPermit: boolean
}

export const PASEO_WS_URL = "paseo-rpc.play.hydration.cloud"

export const PROVIDERS: ProviderProps[] = [
{
name: "GalacticCouncil",
url: "wss://rpc.hydradx.cloud",
indexerUrl: "https://explorer.hydradx.cloud/graphql",
squidUrl: "https://hydra-data-squid.play.hydration.cloud/graphql",
squidUrl:
"https://galacticcouncil.squids.live/hydration-pools:prod/api/graphql",
env: "production",
dataEnv: "mainnet",
},
{
name: "Dwellir",
url: "wss://hydradx-rpc.dwellir.com",
indexerUrl: "https://explorer.hydradx.cloud/graphql",
squidUrl: "https://hydra-data-squid.play.hydration.cloud/graphql",
squidUrl:
"https://galacticcouncil.squids.live/hydration-pools:prod/api/graphql",
env: "production",
dataEnv: "mainnet",
},
{
name: "Helikon",
url: "wss://rpc.helikon.io/hydradx",
indexerUrl: "https://explorer.hydradx.cloud/graphql",
squidUrl: "https://hydra-data-squid.play.hydration.cloud/graphql",
squidUrl:
"https://galacticcouncil.squids.live/hydration-pools:prod/api/graphql",
env: "production",
dataEnv: "mainnet",
},
{
name: "Dotters",
url: "wss://hydration.dotters.network",
indexerUrl: "https://explorer.hydradx.cloud/graphql",
squidUrl: "https://hydra-data-squid.play.hydration.cloud/graphql",
squidUrl:
"https://galacticcouncil.squids.live/hydration-pools:prod/api/graphql",
env: "production",
dataEnv: "mainnet",
},
{
name: "Testnet",
url: "wss://rpc.nice.hydration.cloud",
indexerUrl: "https://archive.nice.hydration.cloud/graphql",
squidUrl: "https://data-squid.nice.hydration.cloud/graphql",
squidUrl:
"https://galacticcouncil.squids.live/hydration-pools:prod/api/graphql",
env: ["development"],
dataEnv: "testnet",
},
{
name: "Paseo",
url: `wss://${PASEO_WS_URL}`,
indexerUrl: "https://explorer.hydradx.cloud/graphql",
squidUrl:
"https://galacticcouncil.squids.live/hydration-paseo-pools:prod/api/graphql",
env: ["rococo", "development"],
dataEnv: "testnet",
},
]

export const PROVIDER_LIST = PROVIDERS.filter((provider) =>
Expand Down
89 changes: 55 additions & 34 deletions src/components/HydrationLogo/HydrationLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,68 @@ import { theme } from "theme"
import ApeIcon from "assets/icons/ApeIcon.svg?react"
import { useTranslation } from "react-i18next"

const hostname = window.location.hostname
const DEPLOY_PREVIEW_NAME =
hostname.includes("deploy-preview") && hostname.match(/--([^-\s]+)-/)?.[1]
const getBadgeLabel = () => {
const hostname = window.location.hostname

if (hostname === "localhost") {
return "localhost"
} else if (hostname.includes("testnet-app")) {
return "testnet"
} else if (hostname.includes("paseo-app")) {
return "paseo"
} else if (hostname.includes("edge-app")) {
return "edge"
} else if (hostname.includes("deploy-preview")) {
return hostname.match(/--([^-\s]+)-/)?.[1]
} else {
return undefined
}
}

const HydrationLogoMobile: React.FC<{ degenMode: boolean }> = ({
degenMode,
}) => (
<>
<SMobileLogoMask cropped={degenMode}>
<svg width="24" height="24" viewBox="0 0 34 36" fill="none">
<path
d="M31.6056 20.3792C32.0061 19.9791 32.5216 19.4642 33.0334 18.9536C34.1751 17.8139 34.1757 15.9653 33.034 14.825L31.8246 13.617C27.4944 17.942 21.0145 18.811 15.8196 16.2245C19.3306 16.873 22.9693 16.3678 26.1935 14.6364C28.3505 13.478 28.7601 10.5561 27.0285 8.82661L19.8885 1.69517C18.293 0.10161 15.7065 0.10161 14.1116 1.69517L6.4156 9.38196C11.484 7.23123 17.5724 8.22834 21.6945 12.3739C15.4058 9.32516 7.61538 10.4069 2.39394 15.6214C1.99341 16.0215 1.47731 16.537 0.965456 17.0482C-0.175637 18.1885 -0.175032 20.0359 0.965456 21.1756L2.17431 22.383C6.50454 18.058 12.9844 17.189 18.1793 19.7755C14.6683 19.127 11.0296 19.6322 7.80536 21.3636C5.64842 22.522 5.23881 25.4439 6.97042 27.1734L14.1104 34.3048C15.7059 35.8984 18.2924 35.8984 19.8873 34.3048L27.5833 26.618C22.5149 28.7688 16.4265 27.7717 12.3038 23.6261C18.5925 26.6748 26.3829 25.5931 31.6044 20.3786L31.6056 20.3792Z"
fill="url(#hydration-logo-gradient)"
}) => {
const badgeLabel = getBadgeLabel()

return (
<>
<SMobileLogoMask cropped={degenMode}>
<svg width="24" height="24" viewBox="0 0 34 36" fill="none">
<path
d="M31.6056 20.3792C32.0061 19.9791 32.5216 19.4642 33.0334 18.9536C34.1751 17.8139 34.1757 15.9653 33.034 14.825L31.8246 13.617C27.4944 17.942 21.0145 18.811 15.8196 16.2245C19.3306 16.873 22.9693 16.3678 26.1935 14.6364C28.3505 13.478 28.7601 10.5561 27.0285 8.82661L19.8885 1.69517C18.293 0.10161 15.7065 0.10161 14.1116 1.69517L6.4156 9.38196C11.484 7.23123 17.5724 8.22834 21.6945 12.3739C15.4058 9.32516 7.61538 10.4069 2.39394 15.6214C1.99341 16.0215 1.47731 16.537 0.965456 17.0482C-0.175637 18.1885 -0.175032 20.0359 0.965456 21.1756L2.17431 22.383C6.50454 18.058 12.9844 17.189 18.1793 19.7755C14.6683 19.127 11.0296 19.6322 7.80536 21.3636C5.64842 22.522 5.23881 25.4439 6.97042 27.1734L14.1104 34.3048C15.7059 35.8984 18.2924 35.8984 19.8873 34.3048L27.5833 26.618C22.5149 28.7688 16.4265 27.7717 12.3038 23.6261C18.5925 26.6748 26.3829 25.5931 31.6044 20.3786L31.6056 20.3792Z"
fill="url(#hydration-logo-gradient)"
/>
</svg>
</SMobileLogoMask>
{badgeLabel && (
<div css={{ position: "absolute" }} sx={{ left: "100%" }}>
<SLogoBadge sx={{ ml: 4, color: "white", bg: "pink700" }}>
{badgeLabel}
</SLogoBadge>
</div>
)}
{degenMode && (
<ApeIcon
width={12}
height={12}
sx={{
bottom: -2,
right: -2,
}}
css={{ position: "absolute" }}
/>
</svg>
</SMobileLogoMask>
{DEPLOY_PREVIEW_NAME && (
<div css={{ position: "absolute" }} sx={{ left: "100%" }}>
<SLogoBadge sx={{ ml: 4, color: "white", bg: "pink700" }}>
{DEPLOY_PREVIEW_NAME}
</SLogoBadge>
</div>
)}
{degenMode && (
<ApeIcon
width={12}
height={12}
sx={{
bottom: -2,
right: -2,
}}
css={{ position: "absolute" }}
/>
)}
</>
)
)}
</>
)
}

const HyderationLogoDesktop: React.FC<{ degenMode: boolean }> = ({
degenMode,
}) => {
const { t } = useTranslation()

const badgeLabel = getBadgeLabel()

return (
<>
<svg width="105" height="22" viewBox="0 0 105 22" fill="none">
Expand Down Expand Up @@ -128,9 +149,9 @@ const HyderationLogoDesktop: React.FC<{ degenMode: boolean }> = ({
>
{t("header.settings.degenMode.title")}
</SLogoBadge>
{DEPLOY_PREVIEW_NAME && (
{badgeLabel && (
<SLogoBadge sx={{ ml: 2, color: "white", bg: "pink700" }}>
{DEPLOY_PREVIEW_NAME}
{badgeLabel}
</SLogoBadge>
)}
</SLogoBadgeContainer>
Expand Down
Loading

0 comments on commit a00bf73

Please sign in to comment.