This commit is contained in:
Adrian Brzeziński 2024-02-28 02:41:37 +01:00
parent c1b285f50d
commit 8e346df4b8
2 changed files with 5 additions and 5 deletions

View File

@ -195,14 +195,14 @@ function UnstakeForm({ token: selectedToken }: UnstakeFormProps) {
mangoAccount.getTokenBalanceUi(borrowBank),
)
const amountToRepay = (leverage - 1) * Number(inputAmount)
const stakeAmountToRepay = (leverage - 1) * Number(inputAmount)
const { signature: tx } = await unstakeAndSwap(
client,
group,
mangoAccount,
stakeBank.mint,
amountToRepay,
stakeAmountToRepay,
)
notify({

View File

@ -113,7 +113,7 @@ export const unstakeAndSwap = async (
group: Group,
mangoAccount: MangoAccount,
stakeMintPk: PublicKey,
amountToRepay?: number,
stakeAmountToRepay?: number,
): Promise<MangoSignatureStatus> => {
console.log('unstake and swap')
@ -130,8 +130,8 @@ export const unstakeAndSwap = async (
let swapAlts: AddressLookupTableAccount[] = []
if (borrowed.toNumber() < 0) {
const toRepay = Math.ceil(
(amountToRepay
? toNativeI80F48(amountToRepay, stakeBank.mintDecimals)
(stakeAmountToRepay
? toNativeI80F48(stakeAmountToRepay, stakeBank.mintDecimals)
: borrowed.abs().div(stakeBank.getAssetPrice())
)
.add(I80F48.fromNumber(100))