reorg
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
8a9f3dd184
commit
74055f5f2b
|
@ -451,6 +451,52 @@ class MangoSimpleClient {
|
|||
);
|
||||
}
|
||||
|
||||
public async cancelOrder(orderInfo: OrderInfo, market?: Market | PerpMarket) {
|
||||
if (orderInfo.market.config.kind === "perp") {
|
||||
const perpMarketConfig = getMarketByBaseSymbolAndKind(
|
||||
this.mangoGroupConfig,
|
||||
orderInfo.market.config.baseSymbol,
|
||||
"perp"
|
||||
);
|
||||
if (market === undefined) {
|
||||
market = await this.mangoGroup.loadPerpMarket(
|
||||
this.connection,
|
||||
perpMarketConfig.marketIndex,
|
||||
perpMarketConfig.baseDecimals,
|
||||
perpMarketConfig.quoteDecimals
|
||||
);
|
||||
}
|
||||
await this.client.cancelPerpOrder(
|
||||
this.mangoGroup,
|
||||
this.mangoAccount,
|
||||
this.owner,
|
||||
market as PerpMarket,
|
||||
orderInfo.order as PerpOrder
|
||||
);
|
||||
} else {
|
||||
const spotMarketConfig = getMarketByBaseSymbolAndKind(
|
||||
this.mangoGroupConfig,
|
||||
orderInfo.market.config.baseSymbol,
|
||||
"spot"
|
||||
);
|
||||
if (market === undefined) {
|
||||
market = await Market.load(
|
||||
this.connection,
|
||||
spotMarketConfig.publicKey,
|
||||
undefined,
|
||||
this.mangoGroupConfig.serumProgramId
|
||||
);
|
||||
}
|
||||
await this.client.cancelSpotOrder(
|
||||
this.mangoGroup,
|
||||
this.mangoAccount,
|
||||
this.owner,
|
||||
market as Market,
|
||||
orderInfo.order as Order
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public async getOrderByOrderId(orderId: string): Promise<OrderInfo[]> {
|
||||
const orders = (await this.fetchAllBidsAndAsks(true)).flat();
|
||||
const orderInfos = orders.filter(
|
||||
|
@ -529,52 +575,6 @@ class MangoSimpleClient {
|
|||
market: { account: market, config },
|
||||
}));
|
||||
}
|
||||
|
||||
public async cancelOrder(orderInfo: OrderInfo, market?: Market | PerpMarket) {
|
||||
if (orderInfo.market.config.kind === "perp") {
|
||||
const perpMarketConfig = getMarketByBaseSymbolAndKind(
|
||||
this.mangoGroupConfig,
|
||||
orderInfo.market.config.baseSymbol,
|
||||
"perp"
|
||||
);
|
||||
if (market === undefined) {
|
||||
market = await this.mangoGroup.loadPerpMarket(
|
||||
this.connection,
|
||||
perpMarketConfig.marketIndex,
|
||||
perpMarketConfig.baseDecimals,
|
||||
perpMarketConfig.quoteDecimals
|
||||
);
|
||||
}
|
||||
await this.client.cancelPerpOrder(
|
||||
this.mangoGroup,
|
||||
this.mangoAccount,
|
||||
this.owner,
|
||||
market as PerpMarket,
|
||||
orderInfo.order as PerpOrder
|
||||
);
|
||||
} else {
|
||||
const spotMarketConfig = getMarketByBaseSymbolAndKind(
|
||||
this.mangoGroupConfig,
|
||||
orderInfo.market.config.baseSymbol,
|
||||
"spot"
|
||||
);
|
||||
if (market === undefined) {
|
||||
market = await Market.load(
|
||||
this.connection,
|
||||
spotMarketConfig.publicKey,
|
||||
undefined,
|
||||
this.mangoGroupConfig.serumProgramId
|
||||
);
|
||||
}
|
||||
await this.client.cancelSpotOrder(
|
||||
this.mangoGroup,
|
||||
this.mangoAccount,
|
||||
this.owner,
|
||||
market as Market,
|
||||
orderInfo.order as Order
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default MangoSimpleClient;
|
||||
|
|
Loading…
Reference in New Issue