Terra Classic reintroduced the tax in September 2022. This patch reverts commits
d863c76ab74ee6e6137c9f1949e935b042360627 ("Deprecate tax") and
80a0c1a430eb0dec8b9fef57329939802a845c80 ("Remove unused variables") and
resolves a conflict with commit 49a52f57b1154ee145fde826c1f3e65aaa1bc1d4 ("Fix
market state check logic").

diff --git a/src/data/native/gqldocs.ts b/src/data/native/gqldocs.ts
index 334c494..cb86c5d 100644
--- a/src/data/native/gqldocs.ts
+++ b/src/data/native/gqldocs.ts
@@ -23,6 +23,18 @@ export const ORACLE_DENOMS_EXCHANGE_RATES = gql`
   }
 `
 
+export const TAX = gql`
+  query tax {
+    TreasuryTaxRate {
+      Result
+    }
+
+    TreasuryTaxCapDenom(Denom: "uusd") {
+      Result
+    }
+  }
+`
+
 export const WASM = gql`
   query WasmContractsContractAddressStore($contract: String, $msg: String) {
     WasmContractsContractAddressStore(
diff --git a/src/data/native/tax.ts b/src/data/native/tax.ts
new file mode 100644
index 0000000..951cd72
--- /dev/null
+++ b/src/data/native/tax.ts
@@ -0,0 +1,13 @@
+import { selector } from "recoil"
+import { request } from "graphql-request"
+import { mantleURLQuery } from "../network"
+import { TAX } from "./gqldocs"
+
+export const taxQuery = selector({
+  key: "tax",
+  get: async ({ get }) => {
+    // request once
+    const url = get(mantleURLQuery)
+    return await request<TaxData>(url + "?tax", TAX)
+  },
+})
diff --git a/src/forms/BurnForm.tsx b/src/forms/BurnForm.tsx
index 5f34a4a..41feccf 100644
--- a/src/forms/BurnForm.tsx
+++ b/src/forms/BurnForm.tsx
@@ -67,6 +67,11 @@ const BurnForm = () => {
     },
   ]
 
+  const uusdCollaterals = byCollateralToken(list)["uusd"]?.map(
+    ({ collateral }) => collateral
+  )
+  const uusd = uusdCollaterals ? sum(uusdCollaterals) : "0"
+
   /* submit */
   const newContractMsg = useNewContractMsg()
   const createSend = (msg: object, amount?: string) => ({
@@ -82,11 +87,12 @@ const BurnForm = () => {
 
   /* result */
   const parseTx = useBurnReceipt()
+  const tax = { pretax: uusd, deduct: true }
   const container = { contents, data, parseTx, label: "Burn" }
 
   return (
     <Container sm>
-      <FormContainer {...container} />
+      <FormContainer {...container} {...tax} />
     </Container>
   )
 }
diff --git a/src/forms/MintForm.tsx b/src/forms/MintForm.tsx
index bb68d26..579ed12 100644
--- a/src/forms/MintForm.tsx
+++ b/src/forms/MintForm.tsx
@@ -20,7 +20,7 @@ import calc from "../libs/calc"
 import { useProtocol } from "../data/contract/protocol"
 import { slippageQuery } from "../data/tx/slippage"
 import { PriceKey } from "../hooks/contractKeys"
-import useGetMax from "../hooks/useGetMax"
+import useTax from "../hooks/useTax"
 import { useFindBalance } from "../data/contract/normalize"
 import { useFindPrice } from "../data/contract/normalize"
 import { useGetMinRatio } from "../data/contract/collateral"
@@ -75,7 +75,7 @@ const MintForm = ({ position, type }: Props) => {
   const findPrice = useFindPrice()
   const { contents: findBalance, ...findBalanceStore } = useFindBalance()
 
-  const getMaxAmount = useGetMax()
+  const { getMax: getMaxAmount } = useTax()
 
   const getSafeRatio = (ratio: string) =>
     gt(ratio, 0) ? plus(ratio, 0.5) : "0"
@@ -586,6 +586,7 @@ const MintForm = ({ position, type }: Props) => {
     label,
     disabled,
     data,
+    pretax: token1 === "uusd" ? (edit ? diffCollateral : amount1) : "0",
     deduct: close || (edit && lt(diffCollateral, 0)),
     gasAdjust: 2,
     parseTx,
diff --git a/src/forms/PoolForm.tsx b/src/forms/PoolForm.tsx
index b58387d..3a57fe2 100644
--- a/src/forms/PoolForm.tsx
+++ b/src/forms/PoolForm.tsx
@@ -99,6 +99,11 @@ const PoolForm = ({ type }: Props) => {
   const fromLP = pool?.fromLP
   const estimated = pool?.toLP.estimated
 
+  const uusd = {
+    [PoolType.PROVIDE]: estimated,
+    [PoolType.WITHDRAW]: fromLP?.uusd.amount,
+  }[type]
+
   /* render:form */
   const config = {
     token,
@@ -257,6 +262,7 @@ const PoolForm = ({ type }: Props) => {
   const parseTx = usePoolReceipt(type)
   const label = autoStake ? "Farm" : "Provide liquidity"
   const container = { attrs, contents, disabled, data, parseTx, label }
+  const tax = { pretax: uusd, deduct: withdraw, gasAdjust: 1.5 }
 
   const steps = [
     {
@@ -280,13 +286,13 @@ const PoolForm = ({ type }: Props) => {
   return (
     <WithPriceChart token={token}>
       {provide ? (
-        <FormContainer {...container} gasAdjust={1.5} full>
+        <FormContainer {...container} {...tax} full>
           {steps.map((step) => (
             <Step {...step} key={step.index} />
           ))}
         </FormContainer>
       ) : (
-        <FormContainer {...container} gasAdjust={1.5}>
+        <FormContainer {...container} {...tax}>
           <FormGroup {...fields[Key.value]} />
           {icons[type]}
           <FormGroup {...fields["estimated"]} />
diff --git a/src/forms/SendForm.tsx b/src/forms/SendForm.tsx
index 9b797ef..4f7e15b 100644
--- a/src/forms/SendForm.tsx
+++ b/src/forms/SendForm.tsx
@@ -14,7 +14,7 @@ import { useNetwork } from "../hooks"
 import { useAddress } from "../hooks"
 import { useProtocol } from "../data/contract/protocol"
 import { PriceKey } from "../hooks/contractKeys"
-import useGetMax from "../hooks/useGetMax"
+import useTax from "../hooks/useTax"
 import { useFindBalance } from "../data/contract/normalize"
 import { useFindPrice } from "../data/contract/normalize"
 
@@ -92,6 +92,7 @@ const SendForm = ({ tab, shuttleList }: Props) => {
   const { to, value, token, memo: $memo, network } = values
   const amount = toAmount(value)
   const symbol = getSymbol(token)
+  const uusd = token === "uusd" ? amount : undefined
   const isEthereum = ethers.utils.isAddress(to)
   const isTerra = AccAddress.validate(to)
 
@@ -117,7 +118,7 @@ const SendForm = ({ tab, shuttleList }: Props) => {
   const select = useSelectAsset(config)
   const balance = findBalance(token)
 
-  const getMax = useGetMax()
+  const { getMax } = useTax()
   const maxAmount =
     symbol === "uusd"
       ? lookup(getMax(balance), "uusd")
@@ -235,7 +236,12 @@ const SendForm = ({ tab, shuttleList }: Props) => {
 
   return (
     <Container sm>
-      <FormContainer {...container} label="send" parseTx={parseTx}>
+      <FormContainer
+        {...container}
+        label="send"
+        pretax={uusd}
+        parseTx={parseTx}
+      >
         <FormGroup {...fields[Key.network]} />
         <FormGroup {...fields[Key.to]} />
         <FormGroup {...fields[Key.value]} />
diff --git a/src/forms/TradeForm.tsx b/src/forms/TradeForm.tsx
index be422c9..bee39ae 100644
--- a/src/forms/TradeForm.tsx
+++ b/src/forms/TradeForm.tsx
@@ -17,7 +17,7 @@ import { renderBalance } from "../libs/formHelpers"
 import calc from "../libs/calc"
 import { useProtocol } from "../data/contract/protocol"
 import { PriceKey, BalanceKey } from "../hooks/contractKeys"
-import useGetMax from "../hooks/useGetMax"
+import useTax from "../hooks/useTax"
 import { useFindBalance } from "../data/contract/normalize"
 import { useFindPrice } from "../data/contract/normalize"
 import { slippageQuery } from "../data/tx/slippage"
@@ -104,6 +104,7 @@ const TradeForm = ({ type }: { type: TradeType }) => {
   const symbol = getSymbol(token)
   const symbol1 = getSymbol(token1)
   const symbol2 = getSymbol(token2)
+  const uusd = { [TradeType.BUY]: amount1, [TradeType.SELL]: amount2 }[type]
 
   /* form:focus input on select asset */
   const value1Ref = useRef<HTMLInputElement>(null)
@@ -179,7 +180,7 @@ const TradeForm = ({ type }: { type: TradeType }) => {
   const select = useSelectAsset(config)
   const delisted = whitelist[token1]?.["status"] === "DELISTED"
 
-  const getMax = useGetMax()
+  const { getMax } = useTax()
   const max = {
     [TradeType.BUY]: lookup(getMax(balance), "uusd"),
     [TradeType.SELL]: lookup(balance, symbol),
@@ -374,6 +375,7 @@ const TradeForm = ({ type }: { type: TradeType }) => {
   const parseTx = isLimitOrder ? parseLimitOrder : parseTrade
 
   const container = { attrs, contents, data, disabled, messages, parseTx }
+  const tax = { pretax: uusd, deduct: type === TradeType.SELL }
 
   return (
     <WithPriceChart token={token}>
@@ -381,7 +383,7 @@ const TradeForm = ({ type }: { type: TradeType }) => {
         <DelistModal type={delist[token].type} tokens={[token]} key={token} />
       )}
 
-      <FormContainer {...container}>
+      <FormContainer {...container} {...tax}>
         <div className={styles.header}>
           <ToggleLimitOrder state={limitOrderState} />
           {!isLimitOrder && <SetSlippageTolerance />}
diff --git a/src/forms/modules/FormContainer.tsx b/src/forms/modules/FormContainer.tsx
index c2d23d2..d7f7c47 100644
--- a/src/forms/modules/FormContainer.tsx
+++ b/src/forms/modules/FormContainer.tsx
@@ -9,11 +9,12 @@ import { TxFailed, TxUnspecifiedError } from "@terra-money/wallet-provider"
 
 import MESSAGE from "../../lang/MESSAGE.json"
 import Tooltips from "../../lang/Tooltips"
-import { gt } from "../../libs/math"
+import { gt, plus, sum } from "../../libs/math"
 import { capitalize } from "../../libs/utils"
 import useHash from "../../libs/useHash"
 import useLocalStorage from "../../libs/useLocalStorage"
 import { useAddress } from "../../hooks"
+import useTax from "../../hooks/useTax"
 import useFee from "../../hooks/useFee"
 import { useUusdBalance } from "../../data/native/balance"
 
@@ -37,6 +38,10 @@ interface Props {
 
   /** Form information */
   contents?: Content[]
+  /** uusd amount for tax calculation */
+  pretax?: string
+  /** Exclude tax from the contract */
+  deduct?: boolean
   /** Form feedback */
   messages?: ReactNode[]
   warnings?: ReactNode[]
@@ -68,7 +73,7 @@ export type PostError =
 
 export const Component = ({ data: msgs, memo, gasAdjust, ...props }: Props) => {
   const { contents, messages, warnings, label, children, full } = props
-  const { attrs, parseTx = () => [], gov, afterTx } = props
+  const { attrs, pretax, deduct, parseTx = () => [], gov, afterTx } = props
 
   /* context */
   const modal = useModal()
@@ -83,11 +88,16 @@ export const Component = ({ data: msgs, memo, gasAdjust, ...props }: Props) => {
   const uusd = useUusdBalance()
   const address = useAddress()
 
-  /* fee */
+  /* tax */
   const fee = useFee(msgs?.length, gasAdjust)
+  const { calcTax } = useTax()
+  const tax = pretax ? calcTax(pretax) : "0"
+  const uusdAmount = !deduct
+    ? sum([pretax ?? "0", tax, fee.amount])
+    : fee.amount
 
   const invalidMessages =
-    address && !gt(uusd, fee.amount) ? ["Not enough UST"] : undefined
+    address && !gt(uusd, uusdAmount) ? ["Not enough UST"] : undefined
 
   /* confirm */
   const [confirming, setConfirming] = useState(false)
@@ -109,7 +119,7 @@ export const Component = ({ data: msgs, memo, gasAdjust, ...props }: Props) => {
         msgs,
         memo,
         gasPrices: `${gasPrice}uusd`,
-        fee: new Fee(gas, { uusd: amount }),
+        fee: new Fee(gas, { uusd: plus(amount, !deduct ? tax : undefined) }),
         purgeQueue: true,
       }
 
@@ -154,7 +164,7 @@ export const Component = ({ data: msgs, memo, gasAdjust, ...props }: Props) => {
 
     const txFee = (
       <Formatted symbol="uusd" dp={6}>
-        {String(fee.amount)}
+        {plus(!deduct ? tax : 0, fee.amount)}
       </Formatted>
     )
 
diff --git a/src/forms/receipts/useMintReceipt.ts b/src/forms/receipts/useMintReceipt.ts
index 8f730bf..c4d529a 100644
--- a/src/forms/receipts/useMintReceipt.ts
+++ b/src/forms/receipts/useMintReceipt.ts
@@ -28,6 +28,7 @@ export default (type: MintType) => (logs: TxLog[]) => {
   const deposit = splitTokenText(fc("deposit")("deposit_amount"))
   const withdraw = splitTokenText(fc("withdraw")("withdraw_amount"))
   const burn = splitTokenText(fc("burn")("burn_amount"))
+  const tax = splitTokenText(fc("withdraw")("tax_amount"))
   const protocolFee = splitTokenText(fc("burn")("protocol_fee"))
 
   const getRatio = () => {
@@ -67,6 +68,7 @@ export default (type: MintType) => (logs: TxLog[]) => {
     { title: "Burned Asset", content: renderAsset(burn) },
     { title: "Withdrawn Collateral", content: renderAsset(withdraw) },
     { title: "Deposited Collateral", content: renderAsset(deposit) },
+    { title: "Tax", content: renderAsset(tax) },
     { title: "Protocol Fee", content: renderAsset(protocolFee) },
   ]
 }
diff --git a/src/forms/receipts/useTradeReceipt.ts b/src/forms/receipts/useTradeReceipt.ts
index 95a4e25..d90f230 100644
--- a/src/forms/receipts/useTradeReceipt.ts
+++ b/src/forms/receipts/useTradeReceipt.ts
@@ -1,5 +1,6 @@
 import { div, minus } from "../../libs/math"
 import { format, formatAsset, lookupSymbol } from "../../libs/parse"
+import { insertIf } from "../../libs/utils"
 import { percent } from "../../libs/num"
 import { useProtocol } from "../../data/contract/protocol"
 import { TradeType } from "../../types/Types"
@@ -15,6 +16,7 @@ export default (type: TradeType, simulatedPrice?: string) => (logs: TxLog[]) =>
   const rtnAsset = val("ask_asset")
   const spread = val("spread_amount")
   const commission = val("commission_amount")
+  const tax = val("tax_amount")
 
   const rtnSymbol = getSymbol(rtnAsset)
   const offerSymbol = getSymbol(offerAsset)
@@ -46,6 +48,10 @@ export default (type: TradeType, simulatedPrice?: string) => (logs: TxLog[]) =>
     children: [
       { title: "Spread", content: formatAsset(spread, rtnSymbol) },
       { title: "Commission", content: formatAsset(commission, rtnSymbol) },
+      ...insertIf(rtnSymbol === "uusd", {
+        title: "Tax",
+        content: formatAsset(tax, rtnSymbol),
+      }),
     ],
   }
 
diff --git a/src/hooks/useGetMax.ts b/src/hooks/useGetMax.ts
deleted file mode 100644
index 9c90370..0000000
--- a/src/hooks/useGetMax.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import BigNumber from "bignumber.js"
-import useFee from "./useFee"
-
-export const useGetMax = () => {
-  const fee = useFee()
-
-  return (balance = "0") => {
-    const balanceSafe = new BigNumber(balance).minus(1e6)
-    const max = BigNumber.max(new BigNumber(balanceSafe).minus(fee.amount), 0)
-    return max.toString()
-  }
-}
-
-export default useGetMax
diff --git a/src/hooks/useTax.ts b/src/hooks/useTax.ts
new file mode 100644
index 0000000..306039a
--- /dev/null
+++ b/src/hooks/useTax.ts
@@ -0,0 +1,44 @@
+import BigNumber from "bignumber.js"
+import { useRecoilValueLoadable } from "recoil"
+import { taxQuery } from "../data/native/tax"
+import { getLoadableContents } from "../data/utils/loadable"
+import useFee from "./useFee"
+
+export default () => {
+  const taxLoadable = useRecoilValueLoadable(taxQuery)
+  const data = getLoadableContents(taxLoadable)
+  const fee = useFee()
+
+  const rate = data?.TreasuryTaxRate.Result
+  const cap = data?.TreasuryTaxCapDenom.Result
+
+  const calcTax = (amount = "0") =>
+    rate && cap
+      ? BigNumber.min(new BigNumber(amount).times(rate), cap)
+          .integerValue(BigNumber.ROUND_CEIL)
+          .toString()
+      : "0"
+
+  const getMax = (balance = "0") => {
+    if (rate && cap) {
+      const balanceSafe = new BigNumber(balance).minus(1e6)
+      const calculatedTax = new BigNumber(balanceSafe)
+        .times(rate)
+        .div(new BigNumber(1).plus(rate))
+        .integerValue(BigNumber.ROUND_CEIL)
+        .toString()
+
+      const tax = BigNumber.min(calculatedTax, cap)
+      const max = BigNumber.max(
+        new BigNumber(balanceSafe).minus(tax).minus(fee.amount),
+        0
+      )
+
+      return max.toString()
+    } else {
+      return "0"
+    }
+  }
+
+  return { calcTax, getMax }
+}
diff --git a/src/pages/My/useParseTx.ts b/src/pages/My/useParseTx.ts
index 698202d..6076842 100644
--- a/src/pages/My/useParseTx.ts
+++ b/src/pages/My/useParseTx.ts
@@ -68,6 +68,7 @@ const useParseTx = ({ type, data, token }: Tx) => {
   const mint = splitTokenText(data.mintAmount)
   const burn = splitTokenText(data.burnAmount)
   const { amount: unlocked } = splitTokenText(data.unlockedAmount)
+  const { amount: tax } = splitTokenText(data.taxAmount)
 
   /* pool */
   const assets = parseTokenText(data.assets)
@@ -157,7 +158,10 @@ const useParseTx = ({ type, data, token }: Tx) => {
       "from position",
       positionIdx,
     ],
-    WITHDRAW_UNLOCKED_UST: ["Claimed", formatAsset(unlocked, "uusd")],
+    WITHDRAW_UNLOCKED_UST: [
+      "Claimed",
+      formatAsset(minus(unlocked, tax), "uusd"),
+    ],
     MINT: ["Borrowed", formatToken(mint), "to position", positionIdx],
     BURN: ["Burned", formatToken(burn), "from position", positionIdx],
     AUCTION: [
diff --git a/src/types/tx.d.ts b/src/types/tx.d.ts
index cbd9b98..c17d26e 100644
--- a/src/types/tx.d.ts
+++ b/src/types/tx.d.ts
@@ -34,3 +34,18 @@ interface Attribute {
   Key: string
   Value: string
 }
+
+/* Tax */
+interface TaxData {
+  TreasuryTaxCapDenom: {
+    Result: string
+  }
+  TreasuryTaxRate: {
+    Result: string
+  }
+}
+
+interface Tax {
+  rate?: string
+  cap?: string
+}
