@agoric/inter-protocol 0.16.2-dev-6ad0038.0.6ad0038 → 0.16.2-dev-b95c1c8.0.b95c1c8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/package.json +16 -16
  2. package/src/index.js +1 -0
  3. package/src/proposals/addAssetToVault.js +3 -97
  4. package/src/proposals/committee-proposal.js +3 -9
  5. package/src/proposals/core-proposal.js +1 -32
  6. package/src/proposals/econ-behaviors.js +1 -140
  7. package/src/vaultFactory/params.d.ts.map +1 -1
  8. package/src/vaultFactory/params.js +1 -0
  9. package/src/vaultFactory/types-ambient.d.ts +0 -2
  10. package/src/vaultFactory/types-ambient.d.ts.map +1 -1
  11. package/src/vaultFactory/types-ambient.js +0 -3
  12. package/src/vaultFactory/vaultDirector.d.ts +5 -40
  13. package/src/vaultFactory/vaultDirector.d.ts.map +1 -1
  14. package/src/vaultFactory/vaultDirector.js +3 -58
  15. package/src/vaultFactory/vaultFactory.d.ts +4 -22
  16. package/src/vaultFactory/vaultFactory.d.ts.map +1 -1
  17. package/src/vaultFactory/vaultFactory.js +2 -9
  18. package/src/vaultFactory/vaultManager.d.ts +2 -180
  19. package/src/vaultFactory/vaultManager.d.ts.map +1 -1
  20. package/src/vaultFactory/vaultManager.js +3 -300
  21. package/src/auction/auctionBook.d.ts +0 -150
  22. package/src/auction/auctionBook.d.ts.map +0 -1
  23. package/src/auction/auctionBook.js +0 -796
  24. package/src/auction/auctionMath.d.ts +0 -18
  25. package/src/auction/auctionMath.d.ts.map +0 -1
  26. package/src/auction/auctionMath.js +0 -82
  27. package/src/auction/auctioneer.d.ts +0 -76
  28. package/src/auction/auctioneer.d.ts.map +0 -1
  29. package/src/auction/auctioneer.js +0 -745
  30. package/src/auction/offerBook.d.ts +0 -47
  31. package/src/auction/offerBook.d.ts.map +0 -1
  32. package/src/auction/offerBook.js +0 -227
  33. package/src/auction/params.d.ts +0 -156
  34. package/src/auction/params.d.ts.map +0 -1
  35. package/src/auction/params.js +0 -184
  36. package/src/auction/scheduleMath.d.ts +0 -8
  37. package/src/auction/scheduleMath.d.ts.map +0 -1
  38. package/src/auction/scheduleMath.js +0 -174
  39. package/src/auction/scheduler.d.ts +0 -57
  40. package/src/auction/scheduler.d.ts.map +0 -1
  41. package/src/auction/scheduler.js +0 -391
  42. package/src/auction/sortedOffers.d.ts +0 -9
  43. package/src/auction/sortedOffers.d.ts.map +0 -1
  44. package/src/auction/sortedOffers.js +0 -141
  45. package/src/proposals/add-auction.js +0 -290
  46. package/src/proposals/upgrade-vaults.js +0 -212
  47. package/src/vaultFactory/liquidation.d.ts +0 -29
  48. package/src/vaultFactory/liquidation.d.ts.map +0 -1
  49. package/src/vaultFactory/liquidation.js +0 -313
  50. package/src/vaultFactory/proceeds.d.ts +0 -36
  51. package/src/vaultFactory/proceeds.d.ts.map +0 -1
  52. package/src/vaultFactory/proceeds.js +0 -285
@@ -1,47 +0,0 @@
1
- export function prepareScaledBidBook(baggage: Baggage): (bidScalingPattern: Pattern, collateralBrand: globalThis.Brand) => import("@endo/exo").Guarded<{
2
- /**
3
- * @param {ZCFSeat} seat
4
- * @param {Ratio} bidScaling
5
- * @param {Amount<'nat'>} wanted
6
- * @param {boolean} exitAfterBuy
7
- */
8
- add(seat: ZCFSeat, bidScaling: Ratio, wanted: Amount<"nat">, exitAfterBuy: boolean): string;
9
- /** @param {Ratio} bidScaling */
10
- offersAbove(bidScaling: Ratio): [string, BidderRecord][];
11
- hasOrders(): boolean;
12
- delete(key: any): void;
13
- updateReceived(key: any, sold: any): void;
14
- exitAllSeats(): void;
15
- }>;
16
- export function preparePriceBook(baggage: Baggage): (priceRatioPattern: Pattern, collateralBrand: globalThis.Brand) => import("@endo/exo").Guarded<{
17
- /**
18
- * @param {ZCFSeat} seat
19
- * @param {Ratio} price
20
- * @param {Amount<'nat'>} wanted
21
- * @param {boolean} exitAfterBuy
22
- */
23
- add(seat: ZCFSeat, price: Ratio, wanted: Amount<"nat">, exitAfterBuy: boolean): string;
24
- offersAbove(price: any): [string, BidderRecord][];
25
- hasOrders(): boolean;
26
- delete(key: any): void;
27
- updateReceived(key: any, sold: any): void;
28
- exitAllSeats(): void;
29
- }>;
30
- export type BidderRecord = {
31
- seat: ZCFSeat;
32
- wanted: Amount<"nat">;
33
- seqNum: NatValue;
34
- received: Amount<"nat">;
35
- } & {
36
- exitAfterBuy: boolean;
37
- } & ({
38
- bidScaling: Pattern;
39
- price: undefined;
40
- } | {
41
- bidScaling: undefined;
42
- price: Ratio;
43
- });
44
- import type { Baggage } from '@agoric/vat-data';
45
- import type { Pattern } from '@endo/patterns';
46
- import type { Ratio } from '@agoric/ertp';
47
- //# sourceMappingURL=offerBook.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"offerBook.d.ts","sourceRoot":"","sources":["offerBook.js"],"names":[],"mappings":"AAuDO,8CAFI,OAAO;IAkBZ;;;;;OAKG;cAJQ,OAAO,cACP,KAAK,UACL,MAAM,CAAC,KAAK,CAAC,gBACb,OAAO;IAsBlB,gCAAgC;4BAApB,KAAK;;;;;GAqCpB;AAcI,0CAFI,OAAO;IAkBZ;;;;;OAKG;cAJQ,OAAO,SACP,KAAK,UACL,MAAM,CAAC,KAAK,CAAC,gBACb,OAAO;;;;;;GA0DrB;2BAnMU;IACR,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CACzB,GAAG;IAAE,YAAY,EAAE,OAAO,CAAA;CAAE,GAAG,CAC1B;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACzC;IAAE,UAAU,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAC1C;6BAvBoB,kBAAkB;6BACb,gBAAgB;2BACvB,cAAc"}
@@ -1,227 +0,0 @@
1
- // book of offers to buy liquidating vaults with prices in terms of
2
- // discount/markup from the current oracle price.
3
-
4
- import { AmountMath } from '@agoric/ertp';
5
- import { M, mustMatch } from '@agoric/store';
6
- import { makeScalarBigMapStore, prepareExoClass } from '@agoric/vat-data';
7
-
8
- import {
9
- toBidScalingComparator,
10
- toPartialOfferKey,
11
- toPriceOfferKey,
12
- toScaledRateOfferKey,
13
- } from './sortedOffers.js';
14
-
15
- /**
16
- * @import {MapStore} from '@agoric/store';
17
- * @import {Baggage} from '@agoric/vat-data';
18
- * @import {Key, Pattern} from '@endo/patterns';
19
- * @import {Ratio} from '@agoric/ertp';
20
- */
21
-
22
- // multiple offers might be provided at the same time (since the time
23
- // granularity is limited to blocks), so we increment a sequenceNumber with each
24
- // offer for uniqueness.
25
- let latestSequenceNumber = 0n;
26
- const nextSequenceNumber = () => {
27
- latestSequenceNumber += 1n;
28
- return latestSequenceNumber;
29
- };
30
-
31
- /**
32
- * @typedef {{
33
- * seat: ZCFSeat;
34
- * wanted: Amount<'nat'>;
35
- * seqNum: NatValue;
36
- * received: Amount<'nat'>;
37
- * } & { exitAfterBuy: boolean } & (
38
- * | { bidScaling: Pattern; price: undefined }
39
- * | { bidScaling: undefined; price: Ratio }
40
- * )} BidderRecord
41
- */
42
-
43
- const ScaledBidBookStateShape = harden({
44
- bidScalingPattern: M.any(),
45
- collateralBrand: M.any(),
46
- records: M.any(),
47
- });
48
-
49
- /**
50
- * Prices in this book are expressed as percentage of the full oracle price
51
- * snapshot taken when the auction started. .4 is 60% off. 1.1 is 10% above
52
- * par.
53
- *
54
- * @param {Baggage} baggage
55
- */
56
- export const prepareScaledBidBook = baggage =>
57
- prepareExoClass(
58
- baggage,
59
- 'scaledBidBook',
60
- undefined,
61
- /**
62
- * @param {Pattern} bidScalingPattern
63
- * @param {Brand} collateralBrand
64
- */
65
- (bidScalingPattern, collateralBrand) => ({
66
- bidScalingPattern,
67
- collateralBrand,
68
- /** @type {MapStore<string, BidderRecord>} */
69
- records: makeScalarBigMapStore('scaledBidRecords', { durable: true }),
70
- }),
71
- {
72
- /**
73
- * @param {ZCFSeat} seat
74
- * @param {Ratio} bidScaling
75
- * @param {Amount<'nat'>} wanted
76
- * @param {boolean} exitAfterBuy
77
- */
78
- add(seat, bidScaling, wanted, exitAfterBuy) {
79
- const { bidScalingPattern, collateralBrand, records } = this.state;
80
- mustMatch(bidScaling, bidScalingPattern);
81
-
82
- const seqNum = nextSequenceNumber();
83
- const key = toScaledRateOfferKey(bidScaling, seqNum);
84
- const empty = AmountMath.makeEmpty(collateralBrand);
85
- /** @type {BidderRecord} */
86
- const bidderRecord = {
87
- bidScaling,
88
- price: undefined,
89
- received: empty,
90
- seat,
91
- seqNum,
92
- wanted,
93
- exitAfterBuy,
94
- };
95
- records.init(key, harden(bidderRecord));
96
- return key;
97
- },
98
- /** @param {Ratio} bidScaling */
99
- offersAbove(bidScaling) {
100
- const { records } = this.state;
101
- return [...records.entries(M.gte(toBidScalingComparator(bidScaling)))];
102
- },
103
- hasOrders() {
104
- const { records } = this.state;
105
- return records.getSize() > 0;
106
- },
107
- delete(key) {
108
- const { records } = this.state;
109
- records.delete(key);
110
- },
111
- updateReceived(key, sold) {
112
- const { records } = this.state;
113
- const oldRec = records.get(key);
114
- records.set(
115
- key,
116
- harden({
117
- ...oldRec,
118
- received: AmountMath.add(oldRec.received, sold),
119
- }),
120
- );
121
- },
122
- exitAllSeats() {
123
- const { records } = this.state;
124
- for (const [key, { seat }] of records.entries()) {
125
- if (!seat.hasExited()) {
126
- seat.exit();
127
- records.delete(key);
128
- }
129
- }
130
- },
131
- },
132
- {
133
- stateShape: ScaledBidBookStateShape,
134
- },
135
- );
136
-
137
- const PriceBookStateShape = harden({
138
- priceRatioPattern: M.any(),
139
- collateralBrand: M.any(),
140
- records: M.any(),
141
- });
142
-
143
- /**
144
- * Prices in this book are actual prices expressed in terms of bid amount and
145
- * collateral amount.
146
- *
147
- * @param {Baggage} baggage
148
- */
149
- export const preparePriceBook = baggage =>
150
- prepareExoClass(
151
- baggage,
152
- 'priceBook',
153
- undefined,
154
- /**
155
- * @param {Pattern} priceRatioPattern
156
- * @param {Brand} collateralBrand
157
- */
158
- (priceRatioPattern, collateralBrand) => ({
159
- priceRatioPattern,
160
- collateralBrand,
161
- /** @type {MapStore<string, BidderRecord>} */
162
- records: makeScalarBigMapStore('scaledBidRecords', { durable: true }),
163
- }),
164
- {
165
- /**
166
- * @param {ZCFSeat} seat
167
- * @param {Ratio} price
168
- * @param {Amount<'nat'>} wanted
169
- * @param {boolean} exitAfterBuy
170
- */
171
- add(seat, price, wanted, exitAfterBuy) {
172
- const { priceRatioPattern, collateralBrand, records } = this.state;
173
- mustMatch(price, priceRatioPattern);
174
-
175
- const seqNum = nextSequenceNumber();
176
- const key = toPriceOfferKey(price, seqNum);
177
- const empty = AmountMath.makeEmpty(collateralBrand);
178
- /** @type {BidderRecord} */
179
- const bidderRecord = {
180
- bidScaling: undefined,
181
- price,
182
- received: empty,
183
- seat,
184
- seqNum,
185
- wanted,
186
- exitAfterBuy,
187
- };
188
- records.init(key, harden(bidderRecord));
189
- return key;
190
- },
191
- offersAbove(price) {
192
- const { records } = this.state;
193
- return [...records.entries(M.gte(toPartialOfferKey(price)))];
194
- },
195
- hasOrders() {
196
- const { records } = this.state;
197
- return records.getSize() > 0;
198
- },
199
- delete(key) {
200
- const { records } = this.state;
201
- records.delete(key);
202
- },
203
- updateReceived(key, sold) {
204
- const { records } = this.state;
205
- const oldRec = records.get(key);
206
- records.set(
207
- key,
208
- harden({
209
- ...oldRec,
210
- received: AmountMath.add(oldRec.received, sold),
211
- }),
212
- );
213
- },
214
- exitAllSeats() {
215
- const { records } = this.state;
216
- for (const [key, { seat }] of records.entries()) {
217
- if (!seat.hasExited()) {
218
- seat.exit();
219
- records.delete(key);
220
- }
221
- }
222
- },
223
- },
224
- {
225
- stateShape: PriceBookStateShape,
226
- },
227
- );
@@ -1,156 +0,0 @@
1
- /**
2
- * @import {AsyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
3
- * @import {SyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
4
- * @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
5
- * @import {Remote} from '@agoric/internal';
6
- * @import {TimerBrand} from '@agoric/time';
7
- * @import {StoredPublisherKit} from '@agoric/notifier';
8
- * @import {RelativeTime, TimerService} from '@agoric/time';
9
- * @import {AssetReservePublicFacet} from '../reserve/assetReserve.js';
10
- */
11
- export const InvitationShape: import("@endo/patterns").Matcher;
12
- /**
13
- * In seconds, how often to start an auction. The auction will start at
14
- * AUCTION_START_DELAY seconds after a multiple of START_FREQUENCY, with the
15
- * price at STARTING_RATE_BP. Every CLOCK_STEP, the price will be reduced by
16
- * DISCOUNT_STEP_BP, as long as the rate is at or above LOWEST_RATE_BP, or until
17
- * START_FREQUENCY has elapsed.
18
- */
19
- export const START_FREQUENCY: "StartFrequency";
20
- /** in seconds, how often to reduce the price */
21
- export const CLOCK_STEP: "ClockStep";
22
- /** discount or markup for starting price in basis points. 9999 = 1bp discount */
23
- export const STARTING_RATE_BP: "StartingRate";
24
- /** A limit below which the price will not be discounted. */
25
- export const LOWEST_RATE_BP: "LowestRate";
26
- /** amount to reduce prices each time step in bp, as % of the start price */
27
- export const DISCOUNT_STEP_BP: "DiscountStep";
28
- /**
29
- * VaultManagers liquidate vaults at a frequency configured by START_FREQUENCY.
30
- * Auctions start this long after the hour to give vaults time to finish.
31
- */
32
- export const AUCTION_START_DELAY: "AuctionStartDelay";
33
- export const PRICE_LOCK_PERIOD: "PriceLockPeriod";
34
- export const auctioneerParamPattern: import("@endo/patterns").Matcher;
35
- export namespace auctioneerParamTypes {
36
- let Electorate: "invitation";
37
- let StartFrequency: "relativeTime";
38
- let ClockStep: "relativeTime";
39
- let StartingRate: "nat";
40
- let LowestRate: "nat";
41
- let DiscountStep: "nat";
42
- let AuctionStartDelay: "relativeTime";
43
- let PriceLockPeriod: "relativeTime";
44
- }
45
- export function makeAuctioneerParams({ ElectorateInvitationAmount, StartFrequency, ClockStep, LowestRate, StartingRate, DiscountStep, AuctionStartDelay, PriceLockPeriod, TimerBrand, }: AuctionParams): {
46
- Electorate: {
47
- type: "invitation";
48
- value: import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>;
49
- };
50
- StartFrequency: {
51
- type: "relativeTime";
52
- value: import("@agoric/time").RelativeTimeRecord;
53
- };
54
- ClockStep: {
55
- type: "relativeTime";
56
- value: import("@agoric/time").RelativeTimeRecord;
57
- };
58
- AuctionStartDelay: {
59
- type: "relativeTime";
60
- value: import("@agoric/time").RelativeTimeRecord;
61
- };
62
- PriceLockPeriod: {
63
- type: "relativeTime";
64
- value: import("@agoric/time").RelativeTimeRecord;
65
- };
66
- StartingRate: {
67
- type: "nat";
68
- value: bigint;
69
- };
70
- LowestRate: {
71
- type: "nat";
72
- value: bigint;
73
- };
74
- DiscountStep: {
75
- type: "nat";
76
- value: bigint;
77
- };
78
- };
79
- export function makeAuctioneerParamManager(publisherKit: StoredPublisherKit<GovernanceSubscriptionState>, zcf: ZCF, initial: AuctionParams): import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
80
- Electorate: "invitation";
81
- StartFrequency: "relativeTime";
82
- ClockStep: "relativeTime";
83
- StartingRate: "nat";
84
- LowestRate: "nat";
85
- DiscountStep: "nat";
86
- AuctionStartDelay: "relativeTime";
87
- PriceLockPeriod: "relativeTime";
88
- }>;
89
- export function makeGovernedTerms({ storageNode: _storageNode, marshaller: _marshaller }: {
90
- storageNode: Remote<StorageNode>;
91
- marshaller: Remote<Marshaller>;
92
- }, timer: ERef<TimerService>, priceAuthority: ERef<PriceAuthority>, reservePublicFacet: ERef<AssetReservePublicFacet>, params: AuctionParams): {
93
- priceAuthority: globalThis.ERef<PriceAuthority>;
94
- reservePublicFacet: globalThis.ERef<globalThis.GovernedPublicFacet<import("@endo/exo").Guarded<{
95
- makeAddCollateralInvitation(): Promise<globalThis.Invitation<string, never>>;
96
- getPublicTopics(): {
97
- metrics: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("../reserve/assetReserveKit.js").MetricsNotification>;
98
- };
99
- }>>>;
100
- timerService: globalThis.ERef<TimerService>;
101
- governedParams: {
102
- Electorate: {
103
- type: "invitation";
104
- value: import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>;
105
- };
106
- StartFrequency: {
107
- type: "relativeTime";
108
- value: import("@agoric/time").RelativeTimeRecord;
109
- };
110
- ClockStep: {
111
- type: "relativeTime";
112
- value: import("@agoric/time").RelativeTimeRecord;
113
- };
114
- AuctionStartDelay: {
115
- type: "relativeTime";
116
- value: import("@agoric/time").RelativeTimeRecord;
117
- };
118
- PriceLockPeriod: {
119
- type: "relativeTime";
120
- value: import("@agoric/time").RelativeTimeRecord;
121
- };
122
- StartingRate: {
123
- type: "nat";
124
- value: bigint;
125
- };
126
- LowestRate: {
127
- type: "nat";
128
- value: bigint;
129
- };
130
- DiscountStep: {
131
- type: "nat";
132
- value: bigint;
133
- };
134
- };
135
- };
136
- export type AuctionParams = {
137
- ElectorateInvitationAmount: Amount<"set">;
138
- StartFrequency: RelativeTime;
139
- ClockStep: RelativeTime;
140
- StartingRate: bigint;
141
- LowestRate: bigint;
142
- DiscountStep: bigint;
143
- AuctionStartDelay: RelativeTime;
144
- PriceLockPeriod: RelativeTime;
145
- TimerBrand: TimerBrand;
146
- };
147
- export type AuctionParamRecord = ReturnType<typeof makeAuctioneerParams>;
148
- export type AuctionParamManager = ReturnType<typeof makeAuctioneerParamManager>;
149
- import type { StoredPublisherKit } from '@agoric/notifier';
150
- import type { Remote } from '@agoric/internal';
151
- import type { TimerService } from '@agoric/time';
152
- import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
153
- import type { AssetReservePublicFacet } from '../reserve/assetReserve.js';
154
- import type { RelativeTime } from '@agoric/time';
155
- import type { TimerBrand } from '@agoric/time';
156
- //# sourceMappingURL=params.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["params.js"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AAGH,+DAAyD;AAEzD;;;;;;GAMG;AACH,8BAA+B,gBAAgB,CAAC;AAChD,gDAAgD;AAChD,yBAA0B,WAAW,CAAC;AACtC,iFAAiF;AACjF,+BAAgC,cAAc,CAAC;AAC/C,4DAA4D;AAC5D,6BAA8B,YAAY,CAAC;AAC3C,4EAA4E;AAC5E,+BAAgC,cAAc,CAAC;AAC/C;;;GAGG;AACH,kCAAmC,mBAAmB,CAAC;AAIvD,gCAAiC,iBAAiB,CAAC;AAEnD,sEASG;;;;;;;;;;;AA2BI,yLADK,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCxB;AAQM,yDAJI,mBAAmB,2BAA2B,CAAC,OAC/C,GAAG,WACH,aAAa;;;;;;;;;GA0BvB;AAcM,0FATI;IACN,WAAW,EAAE,OAAO,WAAW,CAAC,CAAC;IACjC,UAAU,EAAE,OAAO,UAAU,CAAC,CAAC;CAChC,SACO,IAAI,CAAC,YAAY,CAAC,kBAClB,IAAI,CAAC,cAAc,CAAC,sBACpB,IAAI,CAAC,uBAAuB,CAAC,UAC7B,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBvB;;gCA5Ga,MAAM,CAAC,KAAK,CAAC;oBACb,YAAY;eACZ,YAAY;kBACZ,MAAM;gBACN,MAAM;kBACN,MAAM;uBACN,YAAY;qBACZ,YAAY;gBACZ,UAAU;;iCA0EV,UAAU,CAAC,OAAO,oBAAoB,CAAC;kCA6BvC,UAAU,CAAC,OAAO,0BAA0B,CAAC;wCAzKtB,kBAAkB;4BAF9B,kBAAkB;kCAGE,cAAc;oCAJkC,4BAA4B;6CAK/E,4BAA4B;kCADzB,cAAc;gCAF9B,cAAc"}
@@ -1,184 +0,0 @@
1
- import {
2
- CONTRACT_ELECTORATE,
3
- makeParamManager,
4
- ParamTypes,
5
- } from '@agoric/governance';
6
- import { TimeMath, RelativeTimeRecordShape } from '@agoric/time';
7
- import { M } from '@agoric/store';
8
-
9
- /**
10
- * @import {AsyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
11
- * @import {SyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
12
- * @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
13
- * @import {Remote} from '@agoric/internal';
14
- * @import {TimerBrand} from '@agoric/time';
15
- * @import {StoredPublisherKit} from '@agoric/notifier';
16
- * @import {RelativeTime, TimerService} from '@agoric/time';
17
- * @import {AssetReservePublicFacet} from '../reserve/assetReserve.js';
18
- */
19
-
20
- // TODO duplicated with zoe/src/TypeGuards.js
21
- export const InvitationShape = M.remotable('Invitation');
22
-
23
- /**
24
- * In seconds, how often to start an auction. The auction will start at
25
- * AUCTION_START_DELAY seconds after a multiple of START_FREQUENCY, with the
26
- * price at STARTING_RATE_BP. Every CLOCK_STEP, the price will be reduced by
27
- * DISCOUNT_STEP_BP, as long as the rate is at or above LOWEST_RATE_BP, or until
28
- * START_FREQUENCY has elapsed.
29
- */
30
- export const START_FREQUENCY = 'StartFrequency';
31
- /** in seconds, how often to reduce the price */
32
- export const CLOCK_STEP = 'ClockStep';
33
- /** discount or markup for starting price in basis points. 9999 = 1bp discount */
34
- export const STARTING_RATE_BP = 'StartingRate';
35
- /** A limit below which the price will not be discounted. */
36
- export const LOWEST_RATE_BP = 'LowestRate';
37
- /** amount to reduce prices each time step in bp, as % of the start price */
38
- export const DISCOUNT_STEP_BP = 'DiscountStep';
39
- /**
40
- * VaultManagers liquidate vaults at a frequency configured by START_FREQUENCY.
41
- * Auctions start this long after the hour to give vaults time to finish.
42
- */
43
- export const AUCTION_START_DELAY = 'AuctionStartDelay';
44
-
45
- // /////// used by VaultDirector /////////////////////
46
- // time before each auction that the prices are locked.
47
- export const PRICE_LOCK_PERIOD = 'PriceLockPeriod';
48
-
49
- export const auctioneerParamPattern = M.splitRecord({
50
- [CONTRACT_ELECTORATE]: InvitationShape,
51
- [START_FREQUENCY]: RelativeTimeRecordShape,
52
- [CLOCK_STEP]: RelativeTimeRecordShape,
53
- [STARTING_RATE_BP]: M.nat(),
54
- [LOWEST_RATE_BP]: M.nat(),
55
- [DISCOUNT_STEP_BP]: M.nat(),
56
- [AUCTION_START_DELAY]: RelativeTimeRecordShape,
57
- [PRICE_LOCK_PERIOD]: RelativeTimeRecordShape,
58
- });
59
-
60
- export const auctioneerParamTypes = harden({
61
- [CONTRACT_ELECTORATE]: ParamTypes.INVITATION,
62
- [START_FREQUENCY]: ParamTypes.RELATIVE_TIME,
63
- [CLOCK_STEP]: ParamTypes.RELATIVE_TIME,
64
- [STARTING_RATE_BP]: ParamTypes.NAT,
65
- [LOWEST_RATE_BP]: ParamTypes.NAT,
66
- [DISCOUNT_STEP_BP]: ParamTypes.NAT,
67
- [AUCTION_START_DELAY]: ParamTypes.RELATIVE_TIME,
68
- [PRICE_LOCK_PERIOD]: ParamTypes.RELATIVE_TIME,
69
- });
70
-
71
- /**
72
- * @typedef {object} AuctionParams
73
- * @property {Amount<'set'>} ElectorateInvitationAmount
74
- * @property {RelativeTime} StartFrequency
75
- * @property {RelativeTime} ClockStep
76
- * @property {bigint} StartingRate
77
- * @property {bigint} LowestRate
78
- * @property {bigint} DiscountStep
79
- * @property {RelativeTime} AuctionStartDelay
80
- * @property {RelativeTime} PriceLockPeriod
81
- * @property {TimerBrand} TimerBrand
82
- */
83
-
84
- /** @param {AuctionParams} initial */
85
- export const makeAuctioneerParams = ({
86
- ElectorateInvitationAmount,
87
- StartFrequency,
88
- ClockStep,
89
- LowestRate,
90
- StartingRate,
91
- DiscountStep,
92
- AuctionStartDelay,
93
- PriceLockPeriod,
94
- TimerBrand,
95
- }) => {
96
- return harden({
97
- [CONTRACT_ELECTORATE]: {
98
- type: ParamTypes.INVITATION,
99
- value: ElectorateInvitationAmount,
100
- },
101
- [START_FREQUENCY]: {
102
- type: ParamTypes.RELATIVE_TIME,
103
- value: TimeMath.coerceRelativeTimeRecord(StartFrequency, TimerBrand),
104
- },
105
- [CLOCK_STEP]: {
106
- type: ParamTypes.RELATIVE_TIME,
107
- value: TimeMath.coerceRelativeTimeRecord(ClockStep, TimerBrand),
108
- },
109
- [AUCTION_START_DELAY]: {
110
- type: ParamTypes.RELATIVE_TIME,
111
- value: TimeMath.coerceRelativeTimeRecord(AuctionStartDelay, TimerBrand),
112
- },
113
- [PRICE_LOCK_PERIOD]: {
114
- type: ParamTypes.RELATIVE_TIME,
115
- value: TimeMath.coerceRelativeTimeRecord(PriceLockPeriod, TimerBrand),
116
- },
117
- [STARTING_RATE_BP]: { type: ParamTypes.NAT, value: StartingRate },
118
- [LOWEST_RATE_BP]: { type: ParamTypes.NAT, value: LowestRate },
119
- [DISCOUNT_STEP_BP]: { type: ParamTypes.NAT, value: DiscountStep },
120
- });
121
- };
122
- harden(makeAuctioneerParams);
123
-
124
- /**
125
- * @param {StoredPublisherKit<GovernanceSubscriptionState>} publisherKit
126
- * @param {ZCF} zcf
127
- * @param {AuctionParams} initial
128
- */
129
- export const makeAuctioneerParamManager = (publisherKit, zcf, initial) => {
130
- return makeParamManager(
131
- publisherKit,
132
- {
133
- [CONTRACT_ELECTORATE]: [
134
- ParamTypes.INVITATION,
135
- initial[CONTRACT_ELECTORATE],
136
- ],
137
- [START_FREQUENCY]: [ParamTypes.RELATIVE_TIME, initial[START_FREQUENCY]],
138
- [CLOCK_STEP]: [ParamTypes.RELATIVE_TIME, initial[CLOCK_STEP]],
139
- [STARTING_RATE_BP]: [ParamTypes.NAT, initial[STARTING_RATE_BP]],
140
- [LOWEST_RATE_BP]: [ParamTypes.NAT, initial[LOWEST_RATE_BP]],
141
- [DISCOUNT_STEP_BP]: [ParamTypes.NAT, initial[DISCOUNT_STEP_BP]],
142
- [AUCTION_START_DELAY]: [
143
- ParamTypes.RELATIVE_TIME,
144
- initial[AUCTION_START_DELAY],
145
- ],
146
- [PRICE_LOCK_PERIOD]: [
147
- ParamTypes.RELATIVE_TIME,
148
- initial[PRICE_LOCK_PERIOD],
149
- ],
150
- },
151
- zcf,
152
- );
153
- };
154
- harden(makeAuctioneerParamManager);
155
- /** @typedef {ReturnType<typeof makeAuctioneerParams>} AuctionParamRecord */
156
-
157
- /**
158
- * @param {{
159
- * storageNode: Remote<StorageNode>;
160
- * marshaller: Remote<Marshaller>;
161
- * }} caps
162
- * @param {ERef<TimerService>} timer
163
- * @param {ERef<PriceAuthority>} priceAuthority
164
- * @param {ERef<AssetReservePublicFacet>} reservePublicFacet
165
- * @param {AuctionParams} params
166
- */
167
- export const makeGovernedTerms = (
168
- { storageNode: _storageNode, marshaller: _marshaller },
169
- timer,
170
- priceAuthority,
171
- reservePublicFacet,
172
- params,
173
- ) => {
174
- // XXX use storageNode and Marshaller
175
- return harden({
176
- priceAuthority,
177
- reservePublicFacet,
178
- timerService: timer,
179
- governedParams: makeAuctioneerParams(params),
180
- });
181
- };
182
- harden(makeGovernedTerms);
183
-
184
- /** @typedef {ReturnType<typeof makeAuctioneerParamManager>} AuctionParamManager */
@@ -1,8 +0,0 @@
1
- export function computeRoundTiming(params: Awaited<AuctionParamManager>, baseTime: TimestampRecord): Schedule;
2
- export function nextDescendingStepTime(liveSchedule: Schedule | null, nextSchedule: Schedule | null, now: Timestamp): Timestamp | null;
3
- export function timeVsSchedule(time: Timestamp, schedule: Schedule): "before" | "during" | "endExactly" | "after";
4
- import type { AuctionParamManager } from './params.js';
5
- import type { TimestampRecord } from '@agoric/time';
6
- import type { Schedule } from './scheduler.js';
7
- import type { Timestamp } from '@agoric/time';
8
- //# sourceMappingURL=scheduleMath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduleMath.d.ts","sourceRoot":"","sources":["scheduleMath.js"],"names":[],"mappings":"AA+CO,2CAJI,OAAO,CAAC,mBAAmB,CAAC,YAC5B,eAAe,GACb,QAAQ,CAqEpB;AAcM,qDALI,QAAQ,GAAG,IAAI,gBACf,QAAQ,GAAG,IAAI,OACf,SAAS,GACP,SAAS,GAAG,IAAI,CAuB5B;AAQM,qCAJI,SAAS,YACT,QAAQ,GACN,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,CAiBxD;yCAnKqC,aAAa;qCADjB,cAAc;8BAErB,gBAAgB;+BACf,cAAc"}