return tx signature while placing and cancelling orders
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
ff896bafaf
commit
dd3d9647cf
|
@ -383,7 +383,7 @@ class MangoSimpleClient {
|
||||||
price?: number,
|
price?: number,
|
||||||
orderType: "ioc" | "postOnly" | "market" | "limit" = "limit",
|
orderType: "ioc" | "postOnly" | "market" | "limit" = "limit",
|
||||||
clientOrderId?: number
|
clientOrderId?: number
|
||||||
): Promise<void> {
|
): Promise<TransactionSignature> {
|
||||||
if (market.includes("PERP")) {
|
if (market.includes("PERP")) {
|
||||||
const perpMarketConfig = getMarketByBaseSymbolAndKind(
|
const perpMarketConfig = getMarketByBaseSymbolAndKind(
|
||||||
this.mangoGroupConfig,
|
this.mangoGroupConfig,
|
||||||
|
@ -399,7 +399,7 @@ class MangoSimpleClient {
|
||||||
// TODO: this is a workaround, mango-v3 has a assertion for price>0 for all order types
|
// TODO: this is a workaround, mango-v3 has a assertion for price>0 for all order types
|
||||||
// this will be removed soon hopefully
|
// this will be removed soon hopefully
|
||||||
price = orderType !== "market" ? price : 1;
|
price = orderType !== "market" ? price : 1;
|
||||||
await this.client.placePerpOrder(
|
return await this.client.placePerpOrder(
|
||||||
this.mangoGroup,
|
this.mangoGroup,
|
||||||
this.mangoAccount,
|
this.mangoAccount,
|
||||||
this.mangoGroup.mangoCache,
|
this.mangoGroup.mangoCache,
|
||||||
|
@ -429,7 +429,7 @@ class MangoSimpleClient {
|
||||||
undefined,
|
undefined,
|
||||||
this.mangoGroupConfig.serumProgramId
|
this.mangoGroupConfig.serumProgramId
|
||||||
);
|
);
|
||||||
await this.client.placeSpotOrder(
|
return await this.client.placeSpotOrder(
|
||||||
this.mangoGroup,
|
this.mangoGroup,
|
||||||
this.mangoAccount,
|
this.mangoAccount,
|
||||||
this.mangoGroup.mangoCache,
|
this.mangoGroup.mangoCache,
|
||||||
|
@ -520,7 +520,10 @@ class MangoSimpleClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async cancelOrder(orderInfo: OrderInfo, market?: Market | PerpMarket) {
|
public async cancelOrder(
|
||||||
|
orderInfo: OrderInfo,
|
||||||
|
market?: Market | PerpMarket
|
||||||
|
): Promise<TransactionSignature> {
|
||||||
if (orderInfo.market.config.kind === "perp") {
|
if (orderInfo.market.config.kind === "perp") {
|
||||||
const perpMarketConfig = getMarketByBaseSymbolAndKind(
|
const perpMarketConfig = getMarketByBaseSymbolAndKind(
|
||||||
this.mangoGroupConfig,
|
this.mangoGroupConfig,
|
||||||
|
@ -535,7 +538,7 @@ class MangoSimpleClient {
|
||||||
perpMarketConfig.quoteDecimals
|
perpMarketConfig.quoteDecimals
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.client.cancelPerpOrder(
|
return await this.client.cancelPerpOrder(
|
||||||
this.mangoGroup,
|
this.mangoGroup,
|
||||||
this.mangoAccount,
|
this.mangoAccount,
|
||||||
this.owner,
|
this.owner,
|
||||||
|
@ -556,7 +559,7 @@ class MangoSimpleClient {
|
||||||
this.mangoGroupConfig.serumProgramId
|
this.mangoGroupConfig.serumProgramId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.client.cancelSpotOrder(
|
return await this.client.cancelSpotOrder(
|
||||||
this.mangoGroup,
|
this.mangoGroup,
|
||||||
this.mangoAccount,
|
this.mangoAccount,
|
||||||
this.owner,
|
this.owner,
|
||||||
|
|
|
@ -126,8 +126,11 @@ class OrdersController implements Controller {
|
||||||
: "limit",
|
: "limit",
|
||||||
placeOrderDto.clientId
|
placeOrderDto.clientId
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then((transactionSignature) => {
|
||||||
return response.status(200).send();
|
return response.send({
|
||||||
|
success: true,
|
||||||
|
result: { tx: transactionSignature },
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
logger.error(`message - ${error.message}, ${error.stack}`);
|
logger.error(`message - ${error.message}, ${error.stack}`);
|
||||||
|
@ -173,7 +176,12 @@ class OrdersController implements Controller {
|
||||||
}
|
}
|
||||||
this.mangoSimpleClient
|
this.mangoSimpleClient
|
||||||
.cancelOrder(orderInfos[0])
|
.cancelOrder(orderInfos[0])
|
||||||
.then(() => response.send())
|
.then((transactionSignature) =>
|
||||||
|
response.send({
|
||||||
|
success: true,
|
||||||
|
result: { tx: transactionSignature },
|
||||||
|
})
|
||||||
|
)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
logger.error(`message - ${error.message}, ${error.stack}`);
|
logger.error(`message - ${error.message}, ${error.stack}`);
|
||||||
return response
|
return response
|
||||||
|
@ -204,7 +212,12 @@ class OrdersController implements Controller {
|
||||||
}
|
}
|
||||||
this.mangoSimpleClient
|
this.mangoSimpleClient
|
||||||
.cancelOrder(orderInfos[0])
|
.cancelOrder(orderInfos[0])
|
||||||
.then(() => response.send())
|
.then((transactionSignature) =>
|
||||||
|
response.send({
|
||||||
|
success: true,
|
||||||
|
result: { tx: transactionSignature },
|
||||||
|
})
|
||||||
|
)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
logger.error(`message - ${error.message}, ${error.stack}`);
|
logger.error(`message - ${error.message}, ${error.stack}`);
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Reference in New Issue