From 6fb4036e1ec1307adad8d5ad4b81607e03e7cda8 Mon Sep 17 00:00:00 2001 From: dd Date: Tue, 9 Feb 2021 17:03:58 -0500 Subject: [PATCH] fixed liquidate bug --- src/client.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 33458ba..23a2e6b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -431,6 +431,11 @@ export class MangoClient { depositQuantities: number[] ): Promise { + const depositsBN: BN[] = [] + for (let i = 0; i < mangoGroup.tokens.length; i++) { + depositsBN[i] = uiToNative(depositQuantities[i], mangoGroup.mintDecimals[i]) + } + const keys = [ { isSigner: false, isWritable: true, pubkey: mangoGroup.publicKey}, { isSigner: true, isWritable: false, pubkey: liqor.publicKey }, @@ -443,7 +448,7 @@ export class MangoClient { ...tokenAccs.map( (pubkey) => ( { isSigner: false, isWritable: true, pubkey })), ...mangoGroup.tokens.map( (pubkey) => ( { isSigner: false, isWritable: false, pubkey })), ] - const data = encodeMangoInstruction({Liquidate: {depositQuantities}}) + const data = encodeMangoInstruction({Liquidate: {depositQuantities: depositsBN}}) const instruction = new TransactionInstruction( { keys, data, programId })