Skip to content

Commit

Permalink
Merge pull request #531 from terra-money/is-sprint-27
Browse files Browse the repository at this point in the history
IS-SPRINT-27
  • Loading branch information
mwmerz authored Oct 2, 2023
2 parents cfd88e0 + b328fcb commit e16e750
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"hompage": "https://station.money",
"author": "Terra <[email protected]> (https://station.money)",
"repository": "github:terra-money/station",
"version": "7.3.4",
"version": "7.3.5",
"license": "MIT",
"scripts": {
"start": "echo \"$CF_PAGES_COMMIT_SHA\" > public/commit_hash && react-scripts start",
Expand Down
5 changes: 5 additions & 0 deletions src/data/external/osmosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export const useGammTokens = () => {
"/pools/v2/all?low_liquidity=true",
{ baseURL: OSMOSIS_API_URL }
)

if (!data || typeof data !== "object") {
throw new Error("Invalid API response format")
}

return data
} catch (error) {
console.error(error)
Expand Down
19 changes: 11 additions & 8 deletions src/txs/Tx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,20 @@ function Tx<TxValues>(props: Props<TxValues>) {
const gasAmount = getGasAmount(gasDenom)
const gasFee = { amount: gasAmount, denom: gasDenom }

/* tax */
const taxAmount =
token && amount && shouldTax
? calcMinimumTaxAmount(amount, { rate: taxRate, cap: taxCap })
: undefined

/* max */
const getNativeMax = () => {
if (!balance) return
return gasFee.denom === token
? (Number(balance) - Number(gasFee.amount)).toFixed(0)
? new BigNumber(balance)
.minus(gasFee.amount)
.minus(taxAmount ?? 0)
.toString()
: balance
}
const max = !gasFee.amount
Expand All @@ -205,12 +214,6 @@ function Tx<TxValues>(props: Props<TxValues>) {
if (max && isMax && onChangeMax) onChangeMax(toInput(max, decimals))
}, [decimals, isMax, max, onChangeMax])

/* tax */
const taxAmount =
token && amount && shouldTax
? calcMinimumTaxAmount(amount, { rate: taxRate, cap: taxCap })
: undefined

/* (effect): Log error on console */
const failed = getErrorMessage(taxState.error ?? estimatedGasState.error)
useEffect(() => {
Expand Down Expand Up @@ -307,7 +310,7 @@ function Tx<TxValues>(props: Props<TxValues>) {
amount &&
new BigNumber(balance)
.minus(amount)
.minus(taxAmount ?? 0)
.minus(taxAmount ? (gasFee.denom === token ? taxAmount : 0) : 0)
.minus((gasFee.denom === token && gasFee.amount) || 0)
.toString()

Expand Down

0 comments on commit e16e750

Please sign in to comment.