Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thorchain Staking - Enforce "dust_thresholds" #5411

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased (develop)

- fixed: Thorchain stake minimum amount requirements

## 4.20.0 (staging)

- added: 'numAccounts' to 'Signup_Complete' event
Expand Down
4 changes: 2 additions & 2 deletions src/components/scenes/Staking/StakeModifyScene.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/stake-plugins/thorchainSavers/tcSaversPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
Loading