Skip to content

Commit

Permalink
Merge branch 'master' into update-network-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
jvonasek authored Dec 4, 2024
2 parents 3bd7b26 + e20229a commit 441815f
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@galacticcouncil/math-xyk": "^1.0.0",
"@galacticcouncil/sdk": "^5.0.1",
"@galacticcouncil/ui": "^5.2.3",
"@galacticcouncil/xcm-cfg": "^5.5.1",
"@galacticcouncil/xcm-cfg": "^5.6.0",
"@galacticcouncil/xcm-core": "^5.4.0",
"@galacticcouncil/xcm-sdk": "^7.0.0",
"@hookform/resolvers": "^3.3.4",
Expand Down
45 changes: 34 additions & 11 deletions src/api/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,46 @@ export const getAcceptedCurrency = (api: ApiPromise) => async () => {
}

export const useAcceptedCurrencies = (ids: string[]) => {
const { api, isLoaded } = useRpcProvider()
const { api, isLoaded, tradeRouter } = useRpcProvider()
const { native } = useAssets()

return useQuery(QUERY_KEYS.acceptedCurrencies, getAcceptedCurrency(api), {
enabled: isLoaded && ids.length > 0,
select: (assets) => {
return useQuery(
QUERY_KEYS.acceptedCurrencies(ids),
async () => {
const [pools, acceptedCurrency] = await Promise.all([
tradeRouter.getPools(),
getAcceptedCurrency(api)(),
])

return ids.map((id) => {
const response = assets.find((asset) => asset.id === id)
const currency = acceptedCurrency.find((currency) => currency.id === id)

if (currency) {
return currency
}

if (id === native.id) {
return { id, accepted: true, data: undefined }
}

const hasPoolWithDOT = !!pools.find((pool) => {
return (
pool.tokens.find((token) => token.id === id) &&
pool.tokens.find((token) => token.id === "5")
)
})

return response
? response
: id === native.id
? { id, accepted: true, data: undefined }
: { id, accepted: false, data: undefined }
if (hasPoolWithDOT) {
return { id, accepted: true, data: undefined }
}

return { id, accepted: false, data: undefined }
})
},
})
{
enabled: isLoaded && ids.length > 0,
},
)
}

export const useSetAsFeePayment = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@
"staking.dashboard.rewards.legend.current": "Current rewards",
"staking.dashboard.rewards.legend.future": "Rewards after voting",
"staking.dashboard.rewards.legend.tooltip": "You have to vote max conviction with whole staking position",
"staking.dashboard.graph.axisY": "Paylable Percentage",
"staking.dashboard.graph.axisY": "Payable Percentage",
"staking.dashboard.graph.axisX": "Days",
"staking.dashboard.rewards.button": "Claim",
"staking.dashboard.stats.chart.label": "Staked HDX",
Expand Down
3 changes: 3 additions & 0 deletions src/sections/assets/AssetsModal.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface useAssetsModalProps {
allAssets?: boolean
confirmRequired?: boolean
defaultSelectedAsssetId?: string
withExternal?: boolean
}

export const useAssetsModal = ({
Expand All @@ -28,6 +29,7 @@ export const useAssetsModal = ({
allAssets,
confirmRequired,
defaultSelectedAsssetId,
withExternal,
}: useAssetsModalProps) => {
const { t } = useTranslation()
const [isOpen, setIsOpen] = useState(false)
Expand Down Expand Up @@ -61,6 +63,7 @@ export const useAssetsModal = ({
allAssets={allAssets}
confirmRequired={confirmRequired}
defaultSelectedAsssetId={defaultSelectedAsssetId}
withExternal={withExternal}
/>
</Modal>
) : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export const PoolAddLiquidityInformationCard = () => {
<Text fs={13} lh={16}>
{t("liquidity.add.modal.information.text")}
</Text>
<SLink href={`${DOC_LINK}/omnipool_impermanent_loss`} target="_blank">
<SLink
href={`${DOC_LINK}/products/trading/pools/learn_amm#impermanent-loss`}
target="_blank"
>
{t("liquidity.add.modal.information.linkText")}
</SLink>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/sections/staking/StakingPage.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,9 @@ export const useClaimReward = () => {
stakePosition.accumulatedSlashPoints.toString(),
)

const extraPaylablePercentage = wasm.sigmoid(extraPoints, a, b)
const extraPayablePercentage = wasm.sigmoid(extraPoints, a, b)

extraPayablePercentageHuman = scaleHuman(extraPaylablePercentage, "q")
extraPayablePercentageHuman = scaleHuman(extraPayablePercentage, "q")
.multipliedBy(100)
.toString()
}
Expand All @@ -571,7 +571,7 @@ export const useClaimReward = () => {
BN(payablePercentageHuman).gte(chartPoints.y) &&
(arr[i + 1] ? BN(payablePercentageHuman).lt(arr[i + 1].y) : true)

//calculate paylable percentage if vote ongoing referendas
// calculate payable percentage if vote ongoing referendas
const currentSecondary = extraPayablePercentageHuman
? BN(extraPayablePercentageHuman).gte(chartPoints.y) &&
(arr[i + 1] ? BN(extraPayablePercentageHuman).lt(arr[i + 1].y) : true)
Expand Down
1 change: 1 addition & 0 deletions src/sections/transaction/ReviewTransactionForm.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export const useEditFeePaymentAsset = (
defaultSelectedAsssetId: feePaymentAssetId,
allowedAssets: acceptedFeePaymentAssets,
onSelect: (asset) => feeAsPayment.mutate(asset.id),
withExternal: true,
})

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const WalletAssetsTableActions = (props: Props) => {
icon: <PlusIcon />,
label: t("wallet.assets.table.actions.deposit"),
onSelect: () => navigate({ to: LINKS.cross_chain }),
disabled: account?.isExternalWalletConnected,
disabled: account?.isExternalWalletConnected || props.asset.meta.isErc20,
},
]

Expand Down Expand Up @@ -176,8 +176,10 @@ export const WalletAssetsTableActions = (props: Props) => {
account?.isExternalWalletConnected
? []
: [
...buttons.filter((button) =>
hiddenElementsKeys.includes(button.key),
...buttons.filter(
(button) =>
hiddenElementsKeys.includes(button.key) &&
!button.disabled,
),
...actionItems,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ export const WalletAssetsTableActionsMob = ({
<Button
sx={{ width: "100%" }}
size="small"
disabled={account?.isExternalWalletConnected}
disabled={
account?.isExternalWalletConnected || row.meta.isErc20
}
>
<PlusIcon />
{t("wallet.assets.table.actions.deposit")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ export function WalletTransferSectionOnchain({
return await createTransaction(
{
tx:
asset.toString() === native.id
asset.toString() === native.id || assetMeta.isErc20
? api.tx.currencies.transfer(
normalizedDest,
native.id,
asset.toString(),
amount.toFixed(),
)
: api.tx.tokens.transfer(normalizedDest, asset, amount.toFixed()),
Expand Down
14 changes: 6 additions & 8 deletions src/sections/web3-connect/signer/EthereumSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,19 @@ export class EthereumSigner {
let gasLimit = BigNumber(0)
if (tx.gasLimit) {
gasLimit = BigNumber(tx.gasLimit.toString())
.multipliedBy(12)
.dividedBy(10)
.decimalPlaces(0)
} else {
/* const gas = await this.getGasValues(tx)
gasLimit = BigNumber(gas[0].toString()) */
// Use hardcoded gas limit for now, because the estimator is not working correctly
gasLimit = BigNumber(4000000)
const { gas } = await this.getGasValues(tx)
gasLimit = BigNumber(gas.toString())
}

const createPermitMessageData = () => {
const message: PermitMessage = {
...tx,
value: 0,
gaslimit: gasLimit.toNumber(),
gaslimit: gasLimit
.multipliedBy(1.2) // add 20%
.decimalPlaces(0)
.toNumber(),
nonce: nonce.toNumber(),
deadline: Math.floor(Date.now() / 1000 + 3600),
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/queryKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const QUERY_KEYS = {
math: ["@galacticcouncil/math"],
existentialDeposit: [QUERY_KEY_PREFIX, "existentialDeposit"],
metadataVersion: ["metadataVersion"],
acceptedCurrencies: ["acceptedCurrencies"],
acceptedCurrencies: (ids: string[]) => ["acceptedCurrencies", ids.join(",")],
accountCurrency: (address: Maybe<AccountId32 | string>) => [
"accountCurrency",
address,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2294,10 +2294,10 @@
lit "^3.1.4"
ts-debounce "^4.0.0"

"@galacticcouncil/xcm-cfg@^5.5.1":
version "5.5.1"
resolved "https://registry.yarnpkg.com/@galacticcouncil/xcm-cfg/-/xcm-cfg-5.5.1.tgz#6d0e518cbab0a66bf3246dc574d025f8bf273de4"
integrity sha512-S4dFcdhY/K+hYTyFBqpRksKgAQXbqXL2DVtk92dPMGvQfFu6C0AQyYySaUnnW7CBpbjxY9imNeSJZtsfW/s0HQ==
"@galacticcouncil/xcm-cfg@^5.6.0":
version "5.6.0"
resolved "https://registry.yarnpkg.com/@galacticcouncil/xcm-cfg/-/xcm-cfg-5.6.0.tgz#c58f1a6931d374b34c0ad6012b3eb1dc3392c964"
integrity sha512-y42O/L2rkYAkio+lxMpRLwDVCAKD43IJ5NrnIGy4i2lvGyH6PcuKGaB7szHxM6QGUPyL4IMXGaNdxoe9IfeStA==
dependencies:
"@galacticcouncil/xcm-core" "^5.4.0"

Expand Down

0 comments on commit 441815f

Please sign in to comment.