diff --git a/packages/inter-protocol/src/auction/auctionBook.js b/packages/inter-protocol/src/auction/auctionBook.js index e961e6ab0c83..4ba8ae4d1e77 100644 --- a/packages/inter-protocol/src/auction/auctionBook.js +++ b/packages/inter-protocol/src/auction/auctionBook.js @@ -2,7 +2,7 @@ import '@agoric/governance/exported.js'; import '@agoric/zoe/exported.js'; import '@agoric/zoe/src/contracts/exported.js'; -import { AmountMath } from '@agoric/ertp'; +import { AmountMath, AmountShape, RatioShape } from '@agoric/ertp'; import { mustMatch } from '@agoric/store'; import { M, @@ -104,6 +104,18 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => { * added in.) * @property {Amount<'nat'> | null} collateralAvailable The amount of collateral remaining */ +export const BookDataNotificationShape = M.splitRecord( + { + startPrice: M.or(RatioShape, null), + currentPriceLevel: M.or(RatioShape, null), + startCollateral: AmountShape, + collateralAvailable: M.or(AmountShape, null), + }, + { + proceedsRaised: AmountShape, + }, +); +harden(BookDataNotificationShape); /** * @typedef {object} ScaledBidData @@ -127,6 +139,11 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => { * @property {Array} scaledBids * @property {Array} pricedBids */ +export const BidDataNotificationShape = { + scaledBids: M.arrayOf(M.any()), + pricedBids: M.arrayOf(M.any()), +}; +harden(BidDataNotificationShape); /** * @param {Baggage} baggage @@ -203,13 +220,13 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => { const bookDataKit = makeRecorderKit( bookNode, /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher} */ ( - M.any() + BookDataNotificationShape ), ); const bidsDataKit = makeRecorderKit( bidsNode, /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher} */ ( - M.any() + BidDataNotificationShape ), ); diff --git a/packages/inter-protocol/src/auction/auctioneer.js b/packages/inter-protocol/src/auction/auctioneer.js index bc1ff1bcb954..602bd1917287 100644 --- a/packages/inter-protocol/src/auction/auctioneer.js +++ b/packages/inter-protocol/src/auction/auctioneer.js @@ -21,9 +21,9 @@ import { makeRatioFromAmounts, makeRecorderTopic, natSafeMath, + offerTo, prepareRecorder, provideEmptySeat, - offerTo, } from '@agoric/zoe/src/contractSupport/index.js'; import { FullProposalShape } from '@agoric/zoe/src/typeGuards.js'; import { E } from '@endo/eventual-send'; @@ -32,7 +32,7 @@ import { Far } from '@endo/marshal'; import { makeNatAmountShape } from '../contractSupport.js'; import { makeOfferSpecShape, prepareAuctionBook } from './auctionBook.js'; import { auctioneerParamTypes } from './params.js'; -import { makeScheduler } from './scheduler.js'; +import { makeScheduler, ScheduleNotificationShape } from './scheduler.js'; import { AuctionState } from './util.js'; /** @typedef {import('@agoric/vat-data').Baggage} Baggage */ @@ -428,7 +428,7 @@ export const start = async (zcf, privateArgs, baggage) => { const scheduleKit = makeERecorderKit( E(privateArgs.storageNode).makeChildNode('schedule'), /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher} */ ( - M.any() + ScheduleNotificationShape ), ); diff --git a/packages/inter-protocol/src/auction/scheduler.js b/packages/inter-protocol/src/auction/scheduler.js index 2d3737b53847..51a8306c1122 100644 --- a/packages/inter-protocol/src/auction/scheduler.js +++ b/packages/inter-protocol/src/auction/scheduler.js @@ -1,9 +1,10 @@ import { E } from '@endo/eventual-send'; -import { TimeMath } from '@agoric/time'; +import { TimeMath, TimestampShape } from '@agoric/time'; import { Far } from '@endo/marshal'; import { makeTracer } from '@agoric/internal'; import { observeIteration, subscribeEach } from '@agoric/notifier'; +import { M } from '@agoric/store'; import { AuctionState, makeCancelTokenMaker } from './util.js'; import { computeRoundTiming, @@ -56,6 +57,12 @@ const makeCancelToken = makeCancelTokenMaker('scheduler'); * @property {Timestamp | null} nextDescendingStepTime when the next descending step * will take place */ +export const ScheduleNotificationShape = { + activeStartTime: M.or(null, TimestampShape), + nextStartTime: M.or(null, TimestampShape), + nextDescendingStepTime: M.or(null, TimestampShape), +}; +harden(ScheduleNotificationShape); const safelyComputeRoundTiming = (params, baseTime) => { try {