Skip to content

Commit

Permalink
Merge pull request #1810 from galacticcouncil/master
Browse files Browse the repository at this point in the history
master -> rococo
  • Loading branch information
jak-pan authored Nov 8, 2024
2 parents 8002d43 + f915efd commit ede0bb7
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/api/external/assethub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { useCrossChainWallet } from "api/xcm"
import { SubmittableExtrinsic } from "@polkadot/api/types"
import { Buffer } from "buffer"

export const ASSETHUB_XCM_ASSET_SUFFIX = "_ah_"
export const ASSETHUB_TREASURY_ADDRESS =
"13UVJyLnbVp9RBZYFwFGyDvVd1y27Tt8tkntv6Q7JVPhFsTB"

Expand All @@ -53,6 +52,7 @@ export const ASSETHUB_ID_BLACKLIST = [
"22222002",
"22222003",
"22222004",
"50000019",
]

export const assethub = chainsMap.get("assethub") as Parachain
Expand Down
9 changes: 6 additions & 3 deletions src/api/xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Transaction, useStore } from "state/store"
import { isAnyParachain } from "utils/helpers"
import { QUERY_KEYS } from "utils/queryKeys"
import { external } from "@galacticcouncil/apps"
import { ASSETHUB_XCM_ASSET_SUFFIX } from "./external/assethub"
import { TRegisteredAsset } from "sections/wallet/addToken/AddToken.utils"
import { useMemo } from "react"
import { useTranslation } from "react-i18next"
Expand All @@ -27,8 +26,12 @@ type TransferProps = {
dstChain: string
}

export const createXcmAssetKey = (id: string, symbol: string) => {
return `${symbol.toLowerCase()}${ASSETHUB_XCM_ASSET_SUFFIX}${id}`
export const createXcmAssetKey = (
id: string,
symbol: string,
parachainId: number,
) => {
return [symbol.toLowerCase(), parachainId, id].join("_")
}

export const syncAssethubXcmConfig = (
Expand Down
2 changes: 1 addition & 1 deletion src/sections/memepad/form/MemepadForm.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export const useMemepad = () => {
}

// Transfer created token to Hydration
const xcmAssetKey = createXcmAssetKey(id, values.symbol)
const xcmAssetKey = createXcmAssetKey(id, values.symbol, values.origin)
await xTransfer.mutateAsync({
amount: BN(values.supply).minus(values.deposit).toString(),
asset: xcmAssetKey,
Expand Down
9 changes: 5 additions & 4 deletions src/sections/pools/PoolsPage.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ export const usePools = () => {
)?.spotPrice

const tvlDisplay = BN(
tvls.data?.find((tvl) => tvl.asset_id === Number(asset.id))?.tvl_usd ??
tvls.data?.find((tvl) => tvl?.asset_id === Number(asset.id))?.tvl_usd ??
BN_NAN,
).multipliedBy(apiSpotPrice ?? 1)

const volume = BN(
volumes.data?.find((volume) => volume.asset_id.toString() === asset.id)
?.volume_usd ?? BN_NAN,
volumes.data?.find(
(volume) => volume?.asset_id?.toString() === asset.id,
)?.volume_usd ?? BN_NAN,
).multipliedBy(apiSpotPrice ?? 1)

const isFeeLoading = fees?.isLoading || isAllFarmsLoading
Expand All @@ -118,7 +119,7 @@ export const usePools = () => {
native.id === asset.id
? BN_0
: BN(
fees.data?.find((fee) => fee.asset_id.toString() === asset.id)
fees.data?.find((fee) => fee?.asset_id?.toString() === asset.id)
?.projected_apr_perc ?? BN_NAN,
)

Expand Down
7 changes: 5 additions & 2 deletions src/sections/pools/farms/position/FarmingPosition.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,13 @@ export const useFarmDepositsTotal = (address?: string) => {

for (const id in xyk) {
const xykTotal = xyk[id].reduce((memo, deposit) => {
if (deposit.amountUSD) return memo.plus(deposit.amountUSD)
if (deposit.amountUSD) {
memo = memo.plus(deposit.amountUSD)
}
return memo
}, BN_0)
poolsTotal.plus(xykTotal)

poolsTotal = poolsTotal.plus(xykTotal)
}

return poolsTotal
Expand Down
8 changes: 5 additions & 3 deletions src/sections/pools/header/MyLiquidityTotal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export const MyLiquidityTotal = () => {
if (xykPools.data) {
return xykPools.data.reduce((acc, xykPool) => {
if (xykPool.isPositions) {
const myTotalDisplay = xykPool.tvlDisplay
?.div(100)
.times(xykPool.shareTokenIssuance?.myPoolShare ?? 1)
const myTotalDisplay = xykPool.shareTokenIssuance?.myPoolShare
? xykPool.tvlDisplay
?.div(100)
.times(xykPool.shareTokenIssuance?.myPoolShare ?? 1)
: BN_0

return acc.plus(!myTotalDisplay.isNaN() ? myTotalDisplay : BN_0)
}
Expand Down
2 changes: 1 addition & 1 deletion src/sections/pools/pool/details/PoolDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const PoolDetails = () => {
}}
>
<div sx={{ flex: "row", gap: 4, align: "center" }}>
<MultipleAssetLogo iconId={meta.iconId} size={26} />
<MultipleAssetLogo iconId={meta?.iconId} size={26} />
<div sx={{ flex: "column", gap: 0, width: "max-content" }}>
<Text fs={16} lh={16} color="white" font="GeistMedium">
{meta.symbol}
Expand Down
6 changes: 3 additions & 3 deletions src/sections/stats/StatsPage.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ export const useOmnipoolAssetDetails = (sortBy: "tvl" | "pol") => {
const pol = valueOfLiquidityPositions.plus(valueOfShares)

const tvl = BN(
tvls?.data?.find((tvl) => tvl.asset_id === Number(omnipoolAssetId))
tvls?.data?.find((tvl) => tvl?.asset_id === Number(omnipoolAssetId))
?.tvl_usd ?? BN_NAN,
)

const volume = BN(
volumes?.data?.find(
(volume) => volume.asset_id === Number(omnipoolAssetId),
(volume) => volume?.asset_id === Number(omnipoolAssetId),
)?.volume_usd ?? BN_NAN,
)
const isLoadingFee = fees?.isInitialLoading || isAllFarmsLoading
Expand All @@ -113,7 +113,7 @@ export const useOmnipoolAssetDetails = (sortBy: "tvl" | "pol") => {
? BN_0
: BN(
fees?.data?.find(
(fee) => fee.asset_id === Number(omnipoolAssetId),
(fee) => fee?.asset_id === Number(omnipoolAssetId),
)?.projected_apr_perc ?? BN_NAN,
)

Expand Down

0 comments on commit ede0bb7

Please sign in to comment.