Update DEX program ID and expose makeMatchOrdersInstruction

This commit is contained in:
Nishad 2020-08-23 14:13:20 +08:00
parent 438c5eb469
commit 91cd66b4df
2 changed files with 16 additions and 13 deletions

View File

@ -11,7 +11,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from './token-instructions';
export const DEX_PROGRAM_ID = new PublicKey(
'44LJB33bthJ9CJ9AhD3jvd8WgUyrxrcNUZYDjuqcsd8D',
'8FxUAcZc27zBH39TfH1G7qVqDTZn3Bm4ym1qxWnAsdKa',
);
export const INSTRUCTION_LAYOUT = new VersionedLayout(

View File

@ -10,6 +10,7 @@ import {
PublicKey,
SystemProgram,
Transaction,
TransactionInstruction,
TransactionSignature,
} from '@solana/web3.js';
import { decodeEventQueue, decodeRequestQueue } from './queue';
@ -458,20 +459,22 @@ export class Market {
return this.priceLotsToNumber(new BN(1));
}
makeMatchOrdersInstruction(limit: number): TransactionInstruction {
return DexInstructions.matchOrders({
market: this.address,
requestQueue: this._decoded.requestQueue,
eventQueue: this._decoded.eventQueue,
bids: this._decoded.bids,
asks: this._decoded.asks,
baseVault: this._decoded.baseVault,
quoteVault: this._decoded.quoteVault,
limit,
});
}
async matchOrders(connection: Connection, feePayer: Account, limit: number) {
const tx = new Transaction();
tx.add(
DexInstructions.matchOrders({
market: this.address,
requestQueue: this._decoded.requestQueue,
eventQueue: this._decoded.eventQueue,
bids: this._decoded.bids,
asks: this._decoded.asks,
baseVault: this._decoded.baseVault,
quoteVault: this._decoded.quoteVault,
limit,
}),
);
tx.add(this.makeMatchOrdersInstruction(limit));
return await this._sendTransaction(connection, tx, [feePayer]);
}
}