Merge branch 'main' into borrow_limits
# Conflicts: # src/client.ts # src/index.ts # src/layout.ts
This commit is contained in:
commit
8404d8d4fa
11
package.json
11
package.json
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "@mango/client",
|
||||
"name": "@blockworks-foundation/mango-client",
|
||||
"version": "0.1.0",
|
||||
"description": "Library for interacting with Mango Margin solana smart contracts.",
|
||||
"repository": "blockworks-foundation/mango",
|
||||
"description": "Library for interacting with Mango Markets' solana smart contracts.",
|
||||
"repository": "blockworks-foundation/mango-client-ts",
|
||||
"author": {
|
||||
"name": "Blockworks Foundation",
|
||||
"email": "hello@blockworks.foundation",
|
||||
|
@ -13,7 +13,7 @@
|
|||
"types": "lib/index.d.ts",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
"node": ">=14"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
|
@ -52,7 +52,8 @@
|
|||
],
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
"trailingComma": "all",
|
||||
"printWidth": 120
|
||||
},
|
||||
"dependencies": {
|
||||
"@project-serum/serum": "^0.13.20",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import BN from 'bn.js';
|
||||
import { PublicKey, SYSVAR_CLOCK_PUBKEY, TransactionInstruction } from '@solana/web3.js';
|
||||
import { Order } from '@project-serum/serum/lib/market';
|
||||
import { encodeMangoInstruction } from './layout';
|
||||
|
@ -49,7 +50,7 @@ export function makeCancelOrderInstruction(
|
|||
openOrdersPk: PublicKey,
|
||||
signerKey: PublicKey,
|
||||
eventQueuePk: PublicKey,
|
||||
order: Order
|
||||
order: Order,
|
||||
): TransactionInstruction {
|
||||
const keys = [
|
||||
{ isSigner: false, isWritable: true, pubkey: mangoGroupPk },
|
||||
|
@ -63,17 +64,16 @@ export function makeCancelOrderInstruction(
|
|||
{ isSigner: false, isWritable: true, pubkey: openOrdersPk },
|
||||
{ isSigner: false, isWritable: false, pubkey: signerKey },
|
||||
{ isSigner: false, isWritable: true, pubkey: eventQueuePk },
|
||||
]
|
||||
];
|
||||
|
||||
const data = encodeMangoInstruction({
|
||||
CancelOrder: {
|
||||
side: order.side,
|
||||
orderId: order.orderId,
|
||||
},
|
||||
});
|
||||
return new TransactionInstruction({ keys, data, programId });
|
||||
}
|
||||
})
|
||||
return new TransactionInstruction( { keys, data, programId })
|
||||
}
|
||||
|
||||
|
||||
export function makeSettleFundsInstruction(
|
||||
programId: PublicKey,
|
||||
|
@ -105,8 +105,28 @@ export function makeSettleFundsInstruction(
|
|||
{ isSigner: false, isWritable: true, pubkey: mangoQuoteVaultPk },
|
||||
{ isSigner: false, isWritable: false, pubkey: dexSignerKey },
|
||||
{ isSigner: false, isWritable: false, pubkey: TOKEN_PROGRAM_ID },
|
||||
]
|
||||
const data = encodeMangoInstruction( {SettleFunds: {}} )
|
||||
];
|
||||
const data = encodeMangoInstruction({ SettleFunds: {} });
|
||||
|
||||
return new TransactionInstruction( { keys, data, programId })
|
||||
return new TransactionInstruction({ keys, data, programId });
|
||||
}
|
||||
|
||||
export function makeSettleBorrowInstruction(
|
||||
programId: PublicKey,
|
||||
mangoGroupPk: PublicKey,
|
||||
marginAccountPk: PublicKey,
|
||||
walletPk: PublicKey,
|
||||
tokenIndex: number,
|
||||
quantity: number,
|
||||
): TransactionInstruction {
|
||||
const keys = [
|
||||
{ isSigner: false, isWritable: true, pubkey: mangoGroupPk },
|
||||
{ isSigner: false, isWritable: true, pubkey: marginAccountPk },
|
||||
{ isSigner: true, isWritable: false, pubkey: walletPk },
|
||||
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY },
|
||||
];
|
||||
const data = encodeMangoInstruction({
|
||||
SettleBorrow: { tokenIndex: new BN(tokenIndex), quantity },
|
||||
});
|
||||
return new TransactionInstruction({ keys, data, programId });
|
||||
}
|
Loading…
Reference in New Issue