remove unused functions in withdraw modal

This commit is contained in:
Tyler Shipe 2021-04-22 11:12:23 -04:00
parent d61e64a681
commit adad2a967f
1 changed files with 5 additions and 34 deletions

View File

@ -160,31 +160,12 @@ const WithdrawModal = ({ isOpen, onClose }) => {
} }
} }
const DECIMALS = {
BTC: 4,
ETH: 3,
USDT: 2,
}
const getBorrowAmount = () => { const getBorrowAmount = () => {
const tokenBalance = getMaxForSelectedAccount() const tokenBalance = getMaxForSelectedAccount()
const borrowAmount = parseFloat(inputAmount) - tokenBalance const borrowAmount = parseFloat(inputAmount) - tokenBalance
return borrowAmount > 0 ? borrowAmount : 0 return borrowAmount > 0 ? borrowAmount : 0
} }
const getInterestCostPerYear = () => {
const borrowAmount = getBorrowAmount()
const interestRate = selectedMangoGroup.getBorrowRate(tokenIndex)
const symbol = getSymbolForTokenMintAddress(
selectedAccount?.account?.mint.toString()
)
if (borrowAmount > 0) {
const borrowCostPerYear = borrowAmount * interestRate
return `~${borrowCostPerYear.toFixed(DECIMALS[symbol])} ${symbol}`
}
return `0 ${symbol}`
}
if (!selectedAccount) return null if (!selectedAccount) return null
return ( return (
@ -202,8 +183,8 @@ const WithdrawModal = ({ isOpen, onClose }) => {
/> />
<div className="flex items-center jusitfy-between text-th-fgd-1 mt-4 p-2 rounded-md bg-th-bkg-3"> <div className="flex items-center jusitfy-between text-th-fgd-1 mt-4 p-2 rounded-md bg-th-bkg-3">
<div className="flex items-center text-fgd-1 pr-4"> <div className="flex items-center text-fgd-1 pr-4">
<span>Include Borrow</span> <span>Borrow Funds</span>
<Tooltip content="Borrow allows you to loan funds and pay them back at a later date. Interest is charged on your loan balance and is subject to change."> <Tooltip content="Interest is charged on your borrowed balance and is subject to change.">
<InformationCircleIcon <InformationCircleIcon
className={`h-5 w-5 ml-2 text-th-primary cursor-help`} className={`h-5 w-5 ml-2 text-th-primary cursor-help`}
/> />
@ -246,23 +227,13 @@ const WithdrawModal = ({ isOpen, onClose }) => {
{includeBorrow ? ( {includeBorrow ? (
<div className="p-2 bg-th-bkg-1 rounded-md mt-4"> <div className="p-2 bg-th-bkg-1 rounded-md mt-4">
<div className="flex justify-between pb-2"> <div className="flex justify-between pb-2">
<div className="text-th-fgd-3">Loan Amount</div> <div className="text-th-fgd-3">Borrow Amount</div>
<div className="text-th-fgd-1">{`${getBorrowAmount().toFixed( <div className="text-th-fgd-1">{`${getBorrowAmount()} ${getSymbolForTokenMintAddress(
DECIMALS[
getSymbolForTokenMintAddress(
selectedAccount?.account?.mint.toString()
)
]
)} ${getSymbolForTokenMintAddress(
selectedAccount?.account?.mint.toString() selectedAccount?.account?.mint.toString()
)}`}</div> )}`}</div>
</div> </div>
<div className="flex justify-between pb-2">
<div className="text-th-fgd-3">Yearly Loan Cost</div>
<div className="text-th-fgd-1">{getInterestCostPerYear()}</div>
</div>
<div className="flex justify-between"> <div className="flex justify-between">
<div className="text-th-fgd-3">Interest Rate</div> <div className="text-th-fgd-3">Current APR</div>
<div className="text-th-fgd-1"> <div className="text-th-fgd-1">
{(selectedMangoGroup.getBorrowRate(tokenIndex) * 100).toFixed( {(selectedMangoGroup.getBorrowRate(tokenIndex) * 100).toFixed(
2 2