Skip to content

Commit

Permalink
fix amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 committed Jul 4, 2024
1 parent 1e355ae commit 00bfed1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions components/StakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ function StakeForm({ token: selectedToken, clientContext }: StakeFormProps) {
!!(stakeBank?.mint && depositBank?.mint && inputAmount && isSwapMode),
})

const uiOutAmount =
bestRoute?.outAmount && stakeBank
? toUiDecimals(bestRoute.outAmount, stakeBank.mintDecimals) * 0.999
: 0
const liquidationPrice = useMemo(() => {
let price
if (borrowBank?.name == 'SOL') {
Expand Down Expand Up @@ -233,9 +237,7 @@ function StakeForm({ token: selectedToken, clientContext }: StakeFormProps) {

const amountToBorrow = useMemo(() => {
const stakeAmount =
isSwapMode && bestRoute && stakeBank
? toUiDecimals(bestRoute.outAmount, stakeBank.mintDecimals)
: inputAmount
isSwapMode && bestRoute && stakeBank ? uiOutAmount : inputAmount
const borrowPrice = borrowBank?.uiPrice
const stakePrice = stakeBank?.uiPrice
if (!borrowPrice || !stakePrice || !Number(stakeAmount)) return 0
Expand Down Expand Up @@ -571,12 +573,7 @@ function StakeForm({ token: selectedToken, clientContext }: StakeFormProps) {
) : (
<InlineNotification
desc={`Your ${inputAmount} ${depositToken} will be swapped to ${
bestRoute?.outAmount
? `~${toUiDecimals(
bestRoute.outAmount,
stakeBank.mintDecimals,
)}`
: ''
uiOutAmount ? `~${uiOutAmount}` : ''
} ${selectedToken} before Boosting!`}
type="info"
/>
Expand Down Expand Up @@ -846,7 +843,9 @@ function StakeForm({ token: selectedToken, clientContext }: StakeFormProps) {
})}
</div>
) : ipAllowed ? (
`Boost! ${inputAmount} ${formatTokenSymbol(selectedToken)}`
`Boost! ${
isSwapMode && uiOutAmount ? uiOutAmount : inputAmount
} ${formatTokenSymbol(selectedToken)}`
) : (
'Country not allowed'
)}
Expand Down

0 comments on commit 00bfed1

Please sign in to comment.