diff --git a/src/lib/buy.ts b/src/lib/buy.ts index 07983e5..1235822 100644 --- a/src/lib/buy.ts +++ b/src/lib/buy.ts @@ -41,6 +41,7 @@ interface SfBuyOptions { start?: string; yes?: boolean; quote?: boolean; + colocate?: Array; } export function registerBuy(program: Command) { @@ -56,6 +57,12 @@ export function registerBuy(program: Command) { "Specify the start date. Can be a date, relative time like '+1d', or the string 'NOW'", ) .option("-y, --yes", "Automatically confirm the order") + .option( + "-colo, --colocate ", + "Colocate with existing contracts", + (value) => value.split(","), + [], + ) .option("--quote", "Only provide a quote for the order") .action(buyOrderAction); } @@ -76,6 +83,8 @@ async function buyOrderAction(options: SfBuyOptions) { return logAndQuit(`Invalid duration: ${options.duration}`); } + const colocateWithContractIds = options.colocate ? options.colocate : []; + // default to 1 node if not specified const accelerators = options.accelerators ? Number(options.accelerators) : 1; @@ -233,6 +242,7 @@ async function buyOrderAction(options: SfBuyOptions) { endsAt: endDate, confirmWithUser, quoteOnly: isQuoteOnly, + colocate_with: colocateWithContractIds, }); const confirmed = await confirm({ message: confirmationMessage, @@ -254,6 +264,7 @@ async function buyOrderAction(options: SfBuyOptions) { endsAt: endDate, confirmWithUser, quoteOnly: isQuoteOnly, + colocate_with: colocateWithContractIds, }); const order = await waitForOrderToNotBePending(res.id); @@ -366,6 +377,7 @@ type BuyOptions = { durationSeconds: number; confirmWithUser: boolean; quoteOnly: boolean; + colocate_with: Array; }; export async function placeBuyOrder( options: Omit, @@ -383,6 +395,7 @@ export async function placeBuyOrder( : roundStartDate(options.startsAt).toISOString(), end_at: options.endsAt.toISOString(), price: options.priceCents, + colocate_with: options.colocate_with, }, });