From b116a2eeb8e1bc655218da3f772613812fb00c93 Mon Sep 17 00:00:00 2001 From: Jon Tzeng Date: Mon, 23 Dec 2024 17:32:40 -0800 Subject: [PATCH] Enforce "dust_thresholds" https://dev.thorchain.org/saving-guide/quickstart-guide.html#3-send-memoless-savers-transactions --- CHANGELOG.md | 2 ++ src/components/scenes/Staking/StakeModifyScene.tsx | 4 ++-- .../stake-plugins/thorchainSavers/tcSaversPlugin.ts | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe47821a0a2..b0a64968d11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased (develop) +- fixed: Thorchain stake minimum amount requirements + ## 4.20.0 (staging) - added: 'numAccounts' to 'Signup_Complete' event diff --git a/src/components/scenes/Staking/StakeModifyScene.tsx b/src/components/scenes/Staking/StakeModifyScene.tsx index fbc02998038..cf12e0475cc 100644 --- a/src/components/scenes/Staking/StakeModifyScene.tsx +++ b/src/components/scenes/Staking/StakeModifyScene.tsx @@ -1,5 +1,5 @@ import { eq, gt, toFixed } from 'biggystring' -import { EdgeCurrencyWallet, EdgeTokenId, InsufficientFundsError } from 'edge-core-js' +import { DustSpendError, EdgeCurrencyWallet, EdgeTokenId, InsufficientFundsError } from 'edge-core-js' import * as React from 'react' import { Image, View } from 'react-native' import { sprintf } from 'sprintf-js' @@ -172,7 +172,7 @@ const StakeModifySceneComponent = (props: Props) => { setErrorMessage(errMessage) } else if (err instanceof InsufficientFundsError) { setErrorMessage(lstrings.exchange_insufficient_funds_title) - } else if (err instanceof HumanFriendlyError) { + } else if (err instanceof HumanFriendlyError || err instanceof DustSpendError) { setErrorMessage(err.message) } else { showError(err) diff --git a/src/plugins/stake-plugins/thorchainSavers/tcSaversPlugin.ts b/src/plugins/stake-plugins/thorchainSavers/tcSaversPlugin.ts index 9b344737c05..036e3ad224c 100644 --- a/src/plugins/stake-plugins/thorchainSavers/tcSaversPlugin.ts +++ b/src/plugins/stake-plugins/thorchainSavers/tcSaversPlugin.ts @@ -122,6 +122,15 @@ const tcChainCodePluginIdMap: StringMap = { LTC: 'litecoin' } +const DUST_THRESHOLDS: StringMap = { + AVAX: '0', + BTC: '10000', + BCH: '10000', + DOGE: '100000000', + ETH: '0', + LTC: '10000' +} + const asThorNodePool = asObject({ asset: asString, // "AVAX.AVAX", // short_code: asString, // "a", @@ -440,6 +449,10 @@ const stakeRequest = async (opts: EdgeGuiPluginOptions, request: ChangeQuoteRequ throw new InsufficientFundsError({ tokenId }) } + if (lt(nativeAmount, DUST_THRESHOLDS[currencyCode])) { + throw new StakeBelowLimitError(request, currencyCode) + } + await updateInboundAddresses(opts) const { primaryAddress, parentBalance, addressBalance } = await getPrimaryAddress(account, wallet, currencyCode)