diff --git a/.changeset/few-plants-hug.md b/.changeset/few-plants-hug.md new file mode 100644 index 0000000..d961c62 --- /dev/null +++ b/.changeset/few-plants-hug.md @@ -0,0 +1,5 @@ +--- +"@mangrovedao/mgv": patch +--- + +Add orderLabel function to lib to get the label of an order diff --git a/src/lib/index.ts b/src/lib/index.ts index d5844e3..d3d7ccc 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -44,6 +44,7 @@ export { rawLimitOrderResultFromLogs, limitOrderResultFromLogs, getDefaultLimitOrderGasreq, + orderLabel, } from './limit-order.js' // local diff --git a/src/lib/limit-order.ts b/src/lib/limit-order.ts index 724398b..a0a5924 100644 --- a/src/lib/limit-order.ts +++ b/src/lib/limit-order.ts @@ -4,7 +4,7 @@ import type { MarketParams, } from '../types/index.js' import type { OLKey } from '../types/lib.js' -import { BS } from './enums.js' +import { BS, Order } from './enums.js' import { mgvEventsABI, rawMarketOrderResultFromLogs } from './market-order.js' import { flip, hash } from './ol-key.js' import { inboundFromOutbound } from './tick.js' @@ -105,3 +105,17 @@ export type GetDefaultLimitOrderGasreqParams = { export function getDefaultLimitOrderGasreq(): bigint { return 250_000n } + +const _orderLabel = { + [Order.GTC]: 'Good Til Cancelled', + [Order.GTCE]: 'Good Til Cancelled Enforced', + [Order.PO]: 'Post Only', + [Order.IOC]: 'Immediate Or Cancel', + [Order.FOK]: 'Fill Or Kill', +} as const satisfies { [key in Order]: string } + +export function orderLabel( + order: TOrder, +): (typeof _orderLabel)[TOrder] { + return _orderLabel[order] +}