Add parsed for CancelAllPerpOrders
This commit is contained in:
parent
e3d4401c53
commit
b7e3424275
|
@ -353,7 +353,19 @@ export function anchorParser(parsedTransactions, result, signature, blockTime, s
|
||||||
blockDatetime
|
blockDatetime
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else if (eventName === "CancelAllPerpOrdersLog") {
|
||||||
|
parsedTransactions.cancel_all_perp_orders.push(
|
||||||
|
...parseCancelAllPerpOrders(
|
||||||
|
eventNum,
|
||||||
|
eventData,
|
||||||
|
signature,
|
||||||
|
blockTime,
|
||||||
|
slot,
|
||||||
|
blockDatetime
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
throw new Error("Unknown anchor event: " + eventName);
|
throw new Error("Unknown anchor event: " + eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,4 +1297,57 @@ function parseFillLog(
|
||||||
blocktime: blockTime,
|
blocktime: blockTime,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseCancelAllPerpOrders (
|
||||||
|
instructionNum,
|
||||||
|
eventData,
|
||||||
|
signature,
|
||||||
|
blockTime,
|
||||||
|
slot,
|
||||||
|
blockDatetime
|
||||||
|
) {
|
||||||
|
const config = new Config(IDS);
|
||||||
|
|
||||||
|
const groupConfig = config.groups.find((g) =>
|
||||||
|
g.publicKey.equals(eventData.mangoGroup)
|
||||||
|
) as GroupConfig;
|
||||||
|
|
||||||
|
let perpMarketConfig = groupConfig.perpMarkets.find(
|
||||||
|
(p) => p.marketIndex === eventData.marketIndex.toNumber()
|
||||||
|
) as PerpMarketConfig;
|
||||||
|
|
||||||
|
let mangoGroupPk = eventData.mangoGroup.toString();
|
||||||
|
let mangoAccount = eventData.mangoAccount.toString();
|
||||||
|
|
||||||
|
let allOrderIds = eventData.allOrderIds.map(e => e.toString())
|
||||||
|
let cancelledOrderIds = eventData.cancelledOrderIds.map(e => e.toString())
|
||||||
|
|
||||||
|
let cancelled;
|
||||||
|
let result: any = [];
|
||||||
|
for (let orderId of allOrderIds) {
|
||||||
|
|
||||||
|
if (cancelledOrderIds.includes(orderId)) {
|
||||||
|
cancelled = true
|
||||||
|
} else {
|
||||||
|
cancelled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
result.push({
|
||||||
|
order_id: orderId,
|
||||||
|
cancelled: cancelled,
|
||||||
|
perp_market: perpMarketConfig.name,
|
||||||
|
base_symbol: perpMarketConfig.baseSymbol,
|
||||||
|
|
||||||
|
mango_account: mangoAccount,
|
||||||
|
instruction_num: instructionNum,
|
||||||
|
mango_group: mangoGroupPk,
|
||||||
|
block_datetime: blockDatetime,
|
||||||
|
slot: slot,
|
||||||
|
signature: signature,
|
||||||
|
blocktime: blockTime,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ export function parseTransactions(transactionsResult, mangoProgramId) {
|
||||||
|
|
||||||
open_orders_balances: [],
|
open_orders_balances: [],
|
||||||
mango_accrual: [],
|
mango_accrual: [],
|
||||||
|
cancel_all_perp_orders: [],
|
||||||
// Mango: PlacePerpOrder
|
// Mango: PlacePerpOrder
|
||||||
// Mango: CancelPerpOrderByClientI
|
// Mango: CancelPerpOrderByClientI
|
||||||
// Mango: CancelPerpOrder
|
// Mango: CancelPerpOrder
|
||||||
|
|
Loading…
Reference in New Issue