update settleborrowinstructions fn to accept native quantity
This commit is contained in:
parent
fdd723fac1
commit
f7fb17168e
|
@ -1,8 +1,13 @@
|
||||||
import BN from 'bn.js';
|
import BN from 'bn.js';
|
||||||
import { PublicKey, SYSVAR_CLOCK_PUBKEY, TransactionInstruction } from '@solana/web3.js';
|
import {
|
||||||
|
PublicKey,
|
||||||
|
SYSVAR_CLOCK_PUBKEY,
|
||||||
|
TransactionInstruction,
|
||||||
|
} from '@solana/web3.js';
|
||||||
import { Order } from '@project-serum/serum/lib/market';
|
import { Order } from '@project-serum/serum/lib/market';
|
||||||
import { encodeMangoInstruction } from './layout';
|
import { encodeMangoInstruction } from './layout';
|
||||||
import { TOKEN_PROGRAM_ID } from '@project-serum/serum/lib/token-instructions';
|
import { TOKEN_PROGRAM_ID } from '@project-serum/serum/lib/token-instructions';
|
||||||
|
import { uiToNative } from './utils';
|
||||||
|
|
||||||
// export function makeInitMangoGroupInstruction(
|
// export function makeInitMangoGroupInstruction(
|
||||||
// programId: PublicKey,
|
// programId: PublicKey,
|
||||||
|
@ -116,7 +121,7 @@ export function makeSettleBorrowInstruction(
|
||||||
marginAccountPk: PublicKey,
|
marginAccountPk: PublicKey,
|
||||||
walletPk: PublicKey,
|
walletPk: PublicKey,
|
||||||
tokenIndex: number,
|
tokenIndex: number,
|
||||||
quantity: number,
|
nativeQuantity: BN,
|
||||||
): TransactionInstruction {
|
): TransactionInstruction {
|
||||||
const keys = [
|
const keys = [
|
||||||
{ isSigner: false, isWritable: true, pubkey: mangoGroupPk },
|
{ isSigner: false, isWritable: true, pubkey: mangoGroupPk },
|
||||||
|
@ -125,7 +130,7 @@ export function makeSettleBorrowInstruction(
|
||||||
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY },
|
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY },
|
||||||
];
|
];
|
||||||
const data = encodeMangoInstruction({
|
const data = encodeMangoInstruction({
|
||||||
SettleBorrow: { tokenIndex: new BN(tokenIndex), quantity },
|
SettleBorrow: { tokenIndex: new BN(tokenIndex), nativeQuantity },
|
||||||
});
|
});
|
||||||
return new TransactionInstruction({ keys, data, programId });
|
return new TransactionInstruction({ keys, data, programId });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue