Skip to content

Commit

Permalink
Merge branch 'master' into 86c0xn677
Browse files Browse the repository at this point in the history
  • Loading branch information
vkulinich-cl committed Dec 10, 2024
2 parents 5f9b0a1 + d9b3226 commit c4c5ca0
Show file tree
Hide file tree
Showing 59 changed files with 759 additions and 492 deletions.
6 changes: 3 additions & 3 deletions .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 All @@ -11,8 +11,8 @@ VITE_HDX_CAIP_ID=polkadot:afdc188f45c71dacbaa0b62e16a91f72
VITE_STABLECOIN_ASSET_ID=10
VITE_FF_DISPLAY_ASSET_ENABLED=true
VITE_FF_ADD_TOKEN=true
VITE_REFERENDUM_LINK=https://hydradx.subsquare.io/democracy/referendum
VITE_REFERENDUM_DATA_URL=https://hydradx.subsquare.io/api/democracy/referendums
VITE_REFERENDUM_LINK=https://hydration.subsquare.io/democracy/referendum
VITE_REFERENDUM_DATA_URL=https://hydration.subsquare.io/api/democracy/referendums
VITE_EVM_CHAIN_ID=222222
VITE_EVM_NATIVE_ASSET_ID=20
VITE_MIGRATION_TRIGGER_DOMAIN="deploy-preview-1334--testnet-hydra-app.netlify.app"
Expand Down
6 changes: 3 additions & 3 deletions .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 All @@ -11,8 +11,8 @@ VITE_HDX_CAIP_ID=polkadot:afdc188f45c71dacbaa0b62e16a91f72
VITE_STABLECOIN_ASSET_ID=10
VITE_FF_DISPLAY_ASSET_ENABLED=false
VITE_FF_ADD_TOKEN=true
VITE_REFERENDUM_LINK=https://hydradx.subsquare.io/democracy/referendum
VITE_REFERENDUM_DATA_URL=https://hydradx.subsquare.io/api/democracy/referendums
VITE_REFERENDUM_LINK=https://hydration.subsquare.io/democracy/referendum
VITE_REFERENDUM_DATA_URL=https://hydration.subsquare.io/api/democracy/referendums
VITE_EVM_CHAIN_ID=222222
VITE_EVM_NATIVE_ASSET_ID=20
VITE_MIGRATION_TRIGGER_DOMAIN="app.hydradx.io"
Expand Down
12 changes: 6 additions & 6 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 All @@ -11,8 +11,8 @@ VITE_HDX_CAIP_ID=polkadot:afdc188f45c71dacbaa0b62e16a91f72
VITE_STABLECOIN_ASSET_ID=10
VITE_FF_DISPLAY_ASSET_ENABLED=false
VITE_FF_ADD_TOKEN=false
VITE_REFERENDUM_LINK=https://hydradx.subsquare.io/democracy/referendum
VITE_REFERENDUM_DATA_URL=https://hydradx.subsquare.io/api/democracy/referendums
VITE_REFERENDUM_LINK=https://hydration.subsquare.io/democracy/referendum
VITE_REFERENDUM_DATA_URL=https://hydration.subsquare.io/api/democracy/referendums
VITE_EVM_CHAIN_ID=
VITE_EVM_NATIVE_ASSET_ID=20
VITE_MIGRATION_TRIGGER_DOMAIN=""
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@
"@emotion/styled": "^11.10.4",
"@ethersproject/address": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@galacticcouncil/apps": "^9.0.2",
"@galacticcouncil/apps": "^9.1.0",
"@galacticcouncil/math-lbp": "^1.0.0",
"@galacticcouncil/math-liquidity-mining": "^1.0.0",
"@galacticcouncil/math-omnipool": "^1.0.0",
"@galacticcouncil/math-stableswap": "^1.0.0",
"@galacticcouncil/math-staking": "^1.0.0",
"@galacticcouncil/math-xyk": "^1.0.0",
"@galacticcouncil/sdk": "^5.0.1",
"@galacticcouncil/sdk": "^5.1.0",
"@galacticcouncil/ui": "^5.2.3",
"@galacticcouncil/xcm-cfg": "^5.6.0",
"@galacticcouncil/xcm-cfg": "^5.7.1",
"@galacticcouncil/xcm-core": "^5.4.0",
"@galacticcouncil/xcm-sdk": "^7.0.0",
"@hookform/resolvers": "^3.3.4",
"@lit-labs/react": "^1.1.0",
"@polkadot/api": "14.0.1",
"@polkadot/apps-config": "^0.132.1",
"@polkadot/extension-inject": "^0.48.2",
"@polkadot/networks": "^13.2.2",
"@polkadot/networks": "^13.2.3",
"@polkadot/ui-shared": "^3.1.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
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,
},
)),
}
}
}
15 changes: 8 additions & 7 deletions src/api/external/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import {
TRegisteredAsset,
useUserExternalTokenStore,
} from "sections/wallet/addToken/AddToken.utils"
import { BN_0, HYDRATION_PARACHAIN_ID } from "utils/constants"
import { HYDRATION_PARACHAIN_ID } from "utils/constants"
import { isAnyParachain, isNotNil } from "utils/helpers"
import { QUERY_KEYS } from "utils/queryKeys"
import { assethub, useAssetHubAssetRegistry } from "./assethub"
import { pendulum, usePendulumAssetRegistry } from "./pendulum"
import { usePolkadotRegistry } from "./polkadot"
import { useAssets } from "providers/assets"
import BigNumber from "bignumber.js"

export { assethub, pendulum }

Expand Down Expand Up @@ -180,11 +181,11 @@ export const useExternalTokensRugCheck = (ids?: string[]) => {

const totalSupplyExternal =
!shouldIgnoreRugCheck && externalToken.supply
? BN(externalToken.supply)
? externalToken.supply
: null

const totalSupplyInternal =
!shouldIgnoreRugCheck && issuance ? BN(issuance) : null
!shouldIgnoreRugCheck && issuance ? issuance.toString() : null

const warnings = createRugWarningList({
totalSupplyExternal,
Expand Down Expand Up @@ -241,8 +242,8 @@ const createRugWarningList = ({
storedToken,
externalToken,
}: {
totalSupplyExternal: BN | null
totalSupplyInternal: BN | null
totalSupplyExternal: string | null
totalSupplyInternal: string | null
externalToken: TExternalAsset
storedToken?: TRegisteredAsset
}) => {
Expand All @@ -251,12 +252,12 @@ const createRugWarningList = ({
if (
totalSupplyExternal &&
totalSupplyInternal &&
totalSupplyExternal.lt(totalSupplyInternal)
BigNumber(totalSupplyExternal).lt(totalSupplyInternal)
) {
warnings.push({
type: "supply",
severity: "high",
diff: [totalSupplyInternal ?? BN_0, totalSupplyExternal ?? BN_0],
diff: [totalSupplyInternal ?? "0", totalSupplyExternal ?? "0"],
})
}

Expand Down
Loading

0 comments on commit c4c5ca0

Please sign in to comment.