@agoric/inter-protocol 0.13.2-dev-bf35d83.0 → 0.13.2-dev-58d36fb.0
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.
- package/bundles/bundle-auctioneer-meta.js +120 -120
- package/bundles/bundle-auctioneer.js +1 -1
- package/bundles/bundle-econCommitteeCharter-meta.js +81 -81
- package/bundles/bundle-feeDistributor-meta.js +67 -67
- package/bundles/bundle-fluxAggregator-meta.js +158 -158
- package/bundles/bundle-psm-meta.js +114 -114
- package/bundles/bundle-reserve-meta.js +112 -112
- package/bundles/bundle-scaledPriceAuthority-meta.js +151 -151
- package/bundles/bundle-stakeFactory-meta.js +120 -120
- package/bundles/bundle-vaultFactory-meta.js +143 -143
- package/bundles/bundle-vaultFactory.js +1 -1
- package/package.json +16 -16
- package/src/auction/auctionBook.js +42 -29
- package/src/auction/auctioneer.js +3 -1
- package/src/auction/offerBook.js +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.13.2-dev-
|
|
3
|
+
"version": "0.13.2-dev-58d36fb.0+58d36fb",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agoric/assert": "0.5.2-dev-
|
|
33
|
-
"@agoric/ertp": "0.15.4-dev-
|
|
34
|
-
"@agoric/governance": "0.9.2-dev-
|
|
35
|
-
"@agoric/internal": "0.2.2-dev-
|
|
36
|
-
"@agoric/notifier": "0.5.2-dev-
|
|
37
|
-
"@agoric/store": "0.8.4-dev-
|
|
38
|
-
"@agoric/time": "0.2.2-dev-
|
|
39
|
-
"@agoric/vat-data": "0.4.4-dev-
|
|
40
|
-
"@agoric/vats": "0.13.1-dev-
|
|
41
|
-
"@agoric/zoe": "0.25.4-dev-
|
|
32
|
+
"@agoric/assert": "0.5.2-dev-58d36fb.0+58d36fb",
|
|
33
|
+
"@agoric/ertp": "0.15.4-dev-58d36fb.0+58d36fb",
|
|
34
|
+
"@agoric/governance": "0.9.2-dev-58d36fb.0+58d36fb",
|
|
35
|
+
"@agoric/internal": "0.2.2-dev-58d36fb.0+58d36fb",
|
|
36
|
+
"@agoric/notifier": "0.5.2-dev-58d36fb.0+58d36fb",
|
|
37
|
+
"@agoric/store": "0.8.4-dev-58d36fb.0+58d36fb",
|
|
38
|
+
"@agoric/time": "0.2.2-dev-58d36fb.0+58d36fb",
|
|
39
|
+
"@agoric/vat-data": "0.4.4-dev-58d36fb.0+58d36fb",
|
|
40
|
+
"@agoric/vats": "0.13.1-dev-58d36fb.0+58d36fb",
|
|
41
|
+
"@agoric/zoe": "0.25.4-dev-58d36fb.0+58d36fb",
|
|
42
42
|
"@endo/captp": "^2.0.18",
|
|
43
43
|
"@endo/eventual-send": "^0.16.8",
|
|
44
44
|
"@endo/far": "^0.2.14",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"@endo/nat": "^4.1.23"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@agoric/deploy-script-support": "0.9.5-dev-
|
|
50
|
-
"@agoric/smart-wallet": "0.4.3-dev-
|
|
51
|
-
"@agoric/swingset-liveslots": "0.9.1-dev-
|
|
52
|
-
"@agoric/swingset-vat": "0.30.3-dev-
|
|
49
|
+
"@agoric/deploy-script-support": "0.9.5-dev-58d36fb.0+58d36fb",
|
|
50
|
+
"@agoric/smart-wallet": "0.4.3-dev-58d36fb.0+58d36fb",
|
|
51
|
+
"@agoric/swingset-liveslots": "0.9.1-dev-58d36fb.0+58d36fb",
|
|
52
|
+
"@agoric/swingset-vat": "0.30.3-dev-58d36fb.0+58d36fb",
|
|
53
53
|
"@endo/bundle-source": "^2.4.2",
|
|
54
54
|
"@endo/init": "^0.5.52",
|
|
55
55
|
"@endo/promise-kit": "^0.2.52",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "58d36fb9dfaaad0c0a962ba2940b6fcba2ea8b25"
|
|
79
79
|
}
|
|
@@ -54,10 +54,12 @@ const trace = makeTracer('AucBook', false);
|
|
|
54
54
|
/**
|
|
55
55
|
* @typedef {{
|
|
56
56
|
* want: Amount<'nat'>
|
|
57
|
+
* } & {
|
|
58
|
+
* exitAfterBuy?: boolean,
|
|
57
59
|
* } & ({
|
|
58
|
-
*
|
|
60
|
+
* offerPrice: Ratio,
|
|
59
61
|
* } | {
|
|
60
|
-
*
|
|
62
|
+
* offerBidScaling: Ratio,
|
|
61
63
|
* })} BidSpec
|
|
62
64
|
*/
|
|
63
65
|
/**
|
|
@@ -71,6 +73,7 @@ export const makeBidSpecShape = (currencyBrand, collateralBrand) => {
|
|
|
71
73
|
return M.splitRecord(
|
|
72
74
|
{ want: collateralAmountShape },
|
|
73
75
|
{
|
|
76
|
+
exitAfterBuy: M.boolean(),
|
|
74
77
|
// xxx should have exactly one of these properties
|
|
75
78
|
offerPrice: makeBrandedRatioPattern(
|
|
76
79
|
currencyAmountShape,
|
|
@@ -266,9 +269,16 @@ export const prepareAuctionBook = (baggage, zcf) => {
|
|
|
266
269
|
* @param {ZCFSeat} seat
|
|
267
270
|
* @param {Ratio} price
|
|
268
271
|
* @param {Amount<'nat'>} want
|
|
269
|
-
* @param {
|
|
272
|
+
* @param {object} opts
|
|
273
|
+
* @param {boolean} opts.trySettle
|
|
274
|
+
* @param {boolean} [opts.exitAfterBuy]
|
|
270
275
|
*/
|
|
271
|
-
acceptPriceOffer(
|
|
276
|
+
acceptPriceOffer(
|
|
277
|
+
seat,
|
|
278
|
+
price,
|
|
279
|
+
want,
|
|
280
|
+
{ trySettle, exitAfterBuy = false },
|
|
281
|
+
) {
|
|
272
282
|
const { priceBook, curAuctionPrice } = this.state;
|
|
273
283
|
const { helper } = this.facets;
|
|
274
284
|
trace('acceptPrice');
|
|
@@ -281,13 +291,14 @@ export const prepareAuctionBook = (baggage, zcf) => {
|
|
|
281
291
|
|
|
282
292
|
const stillWant = AmountMath.subtract(want, collateralSold);
|
|
283
293
|
if (
|
|
294
|
+
(exitAfterBuy && !AmountMath.isEmpty(collateralSold)) ||
|
|
284
295
|
AmountMath.isEmpty(stillWant) ||
|
|
285
296
|
AmountMath.isEmpty(seat.getCurrentAllocation().Currency)
|
|
286
297
|
) {
|
|
287
298
|
seat.exit();
|
|
288
299
|
} else {
|
|
289
300
|
trace('added Offer ', price, stillWant.value);
|
|
290
|
-
priceBook.add(seat, price, stillWant);
|
|
301
|
+
priceBook.add(seat, price, stillWant, exitAfterBuy);
|
|
291
302
|
}
|
|
292
303
|
},
|
|
293
304
|
|
|
@@ -299,9 +310,16 @@ export const prepareAuctionBook = (baggage, zcf) => {
|
|
|
299
310
|
* @param {ZCFSeat} seat
|
|
300
311
|
* @param {Ratio} bidScaling
|
|
301
312
|
* @param {Amount<'nat'>} want
|
|
302
|
-
* @param {
|
|
313
|
+
* @param {object} opts
|
|
314
|
+
* @param {boolean} opts.trySettle
|
|
315
|
+
* @param {boolean} [opts.exitAfterBuy]
|
|
303
316
|
*/
|
|
304
|
-
acceptScaledBidOffer(
|
|
317
|
+
acceptScaledBidOffer(
|
|
318
|
+
seat,
|
|
319
|
+
bidScaling,
|
|
320
|
+
want,
|
|
321
|
+
{ trySettle, exitAfterBuy = false },
|
|
322
|
+
) {
|
|
305
323
|
trace('accept scaled bid offer');
|
|
306
324
|
const { curAuctionPrice, lockedPriceForRound, scaledBidBook } =
|
|
307
325
|
this.state;
|
|
@@ -318,12 +336,13 @@ export const prepareAuctionBook = (baggage, zcf) => {
|
|
|
318
336
|
|
|
319
337
|
const stillWant = AmountMath.subtract(want, collateralSold);
|
|
320
338
|
if (
|
|
339
|
+
(exitAfterBuy && !AmountMath.isEmpty(collateralSold)) ||
|
|
321
340
|
AmountMath.isEmpty(stillWant) ||
|
|
322
341
|
AmountMath.isEmpty(seat.getCurrentAllocation().Currency)
|
|
323
342
|
) {
|
|
324
343
|
seat.exit();
|
|
325
344
|
} else {
|
|
326
|
-
scaledBidBook.add(seat, bidScaling, stillWant);
|
|
345
|
+
scaledBidBook.add(seat, bidScaling, stillWant, exitAfterBuy);
|
|
327
346
|
}
|
|
328
347
|
},
|
|
329
348
|
},
|
|
@@ -418,7 +437,8 @@ export const prepareAuctionBook = (baggage, zcf) => {
|
|
|
418
437
|
|
|
419
438
|
const { totalProceedsGoal } = this.state;
|
|
420
439
|
const { helper } = this.facets;
|
|
421
|
-
for (const [key,
|
|
440
|
+
for (const [key, seatRecord] of prioritizedOffers) {
|
|
441
|
+
const { seat, price: p, wanted, exitAfterBuy } = seatRecord;
|
|
422
442
|
if (totalProceedsGoal && AmountMath.isEmpty(totalProceedsGoal)) {
|
|
423
443
|
break;
|
|
424
444
|
} else if (seat.hasExited()) {
|
|
@@ -428,6 +448,7 @@ export const prepareAuctionBook = (baggage, zcf) => {
|
|
|
428
448
|
|
|
429
449
|
const alloc = seat.getCurrentAllocation();
|
|
430
450
|
if (
|
|
451
|
+
(exitAfterBuy && !AmountMath.isEmpty(collateralSold)) ||
|
|
431
452
|
AmountMath.isEmpty(alloc.Currency) ||
|
|
432
453
|
('Collateral' in alloc &&
|
|
433
454
|
AmountMath.isGTE(alloc.Collateral, wanted))
|
|
@@ -462,32 +483,17 @@ export const prepareAuctionBook = (baggage, zcf) => {
|
|
|
462
483
|
);
|
|
463
484
|
},
|
|
464
485
|
/**
|
|
465
|
-
*
|
|
466
486
|
* @param {BidSpec} bidSpec
|
|
467
487
|
* @param {ZCFSeat} seat
|
|
468
488
|
* @param {boolean} trySettle
|
|
469
489
|
*/
|
|
470
490
|
addOffer(bidSpec, seat, trySettle) {
|
|
471
|
-
const {
|
|
472
|
-
const BidSpecShape =
|
|
473
|
-
{
|
|
474
|
-
want: collateralAmountShape,
|
|
475
|
-
offerPrice: makeBrandedRatioPattern(
|
|
476
|
-
currencyAmountShape,
|
|
477
|
-
collateralAmountShape,
|
|
478
|
-
),
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
want: collateralAmountShape,
|
|
482
|
-
offerBidScaling: makeBrandedRatioPattern(
|
|
483
|
-
currencyAmountShape,
|
|
484
|
-
currencyAmountShape,
|
|
485
|
-
),
|
|
486
|
-
},
|
|
487
|
-
);
|
|
491
|
+
const { currencyBrand, collateralBrand } = this.state;
|
|
492
|
+
const BidSpecShape = makeBidSpecShape(currencyBrand, collateralBrand);
|
|
488
493
|
|
|
489
494
|
mustMatch(bidSpec, BidSpecShape);
|
|
490
495
|
const { give } = seat.getProposal();
|
|
496
|
+
const { currencyAmountShape } = this.state;
|
|
491
497
|
mustMatch(
|
|
492
498
|
give.Currency,
|
|
493
499
|
currencyAmountShape,
|
|
@@ -495,19 +501,26 @@ export const prepareAuctionBook = (baggage, zcf) => {
|
|
|
495
501
|
);
|
|
496
502
|
|
|
497
503
|
const { helper } = this.facets;
|
|
504
|
+
const { exitAfterBuy } = bidSpec;
|
|
498
505
|
if ('offerPrice' in bidSpec) {
|
|
499
506
|
return helper.acceptPriceOffer(
|
|
500
507
|
seat,
|
|
501
508
|
bidSpec.offerPrice,
|
|
502
509
|
bidSpec.want,
|
|
503
|
-
|
|
510
|
+
{
|
|
511
|
+
trySettle,
|
|
512
|
+
exitAfterBuy,
|
|
513
|
+
},
|
|
504
514
|
);
|
|
505
515
|
} else if ('offerBidScaling' in bidSpec) {
|
|
506
516
|
return helper.acceptScaledBidOffer(
|
|
507
517
|
seat,
|
|
508
518
|
bidSpec.offerBidScaling,
|
|
509
519
|
bidSpec.want,
|
|
510
|
-
|
|
520
|
+
{
|
|
521
|
+
trySettle,
|
|
522
|
+
exitAfterBuy,
|
|
523
|
+
},
|
|
511
524
|
);
|
|
512
525
|
} else {
|
|
513
526
|
throw Fail`Offer was neither a price nor a scaled bid`;
|
|
@@ -420,7 +420,9 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
420
420
|
deposits.set(brand, []);
|
|
421
421
|
} else if (depositsForBrand.length > 1) {
|
|
422
422
|
const collProceeds = collateralSeat.getCurrentAllocation().Collateral;
|
|
423
|
-
const currProceeds =
|
|
423
|
+
const currProceeds =
|
|
424
|
+
currencySeat.getCurrentAllocation().Currency ||
|
|
425
|
+
AmountMath.makeEmpty(brands.Currency);
|
|
424
426
|
const transfers = distributeProportionalSharesWithLimits(
|
|
425
427
|
collProceeds,
|
|
426
428
|
currProceeds,
|
package/src/auction/offerBook.js
CHANGED
|
@@ -29,7 +29,7 @@ const nextSequenceNumber = () => {
|
|
|
29
29
|
* wanted: Amount<'nat'>,
|
|
30
30
|
* seqNum: NatValue,
|
|
31
31
|
* received: Amount<'nat'>,
|
|
32
|
-
* } & ({ bidScaling: Pattern, price: undefined } | { bidScaling: undefined, price: Ratio})
|
|
32
|
+
* } & {exitAfterBuy: boolean} & ({ bidScaling: Pattern, price: undefined } | { bidScaling: undefined, price: Ratio})
|
|
33
33
|
* } BidderRecord
|
|
34
34
|
*/
|
|
35
35
|
|
|
@@ -60,8 +60,9 @@ export const prepareScaledBidBook = baggage =>
|
|
|
60
60
|
* @param {ZCFSeat} seat
|
|
61
61
|
* @param {Ratio} bidScaling
|
|
62
62
|
* @param {Amount<'nat'>} wanted
|
|
63
|
+
* @param {boolean} exitAfterBuy
|
|
63
64
|
*/
|
|
64
|
-
add(seat, bidScaling, wanted) {
|
|
65
|
+
add(seat, bidScaling, wanted, exitAfterBuy) {
|
|
65
66
|
const { bidScalingPattern, collateralBrand, records } = this.state;
|
|
66
67
|
mustMatch(bidScaling, bidScalingPattern);
|
|
67
68
|
|
|
@@ -76,6 +77,7 @@ export const prepareScaledBidBook = baggage =>
|
|
|
76
77
|
seat,
|
|
77
78
|
seqNum,
|
|
78
79
|
wanted,
|
|
80
|
+
exitAfterBuy,
|
|
79
81
|
};
|
|
80
82
|
records.init(key, harden(bidderRecord));
|
|
81
83
|
return key;
|
|
@@ -139,7 +141,13 @@ export const preparePriceBook = baggage =>
|
|
|
139
141
|
records: makeScalarBigMapStore('scaledBidRecords', { durable: true }),
|
|
140
142
|
}),
|
|
141
143
|
{
|
|
142
|
-
|
|
144
|
+
/**
|
|
145
|
+
* @param {ZCFSeat} seat
|
|
146
|
+
* @param {Ratio} price
|
|
147
|
+
* @param {Amount<'nat'>} wanted
|
|
148
|
+
* @param {boolean} exitAfterBuy
|
|
149
|
+
*/
|
|
150
|
+
add(seat, price, wanted, exitAfterBuy) {
|
|
143
151
|
const { priceRatioPattern, collateralBrand, records } = this.state;
|
|
144
152
|
mustMatch(price, priceRatioPattern);
|
|
145
153
|
|
|
@@ -154,6 +162,7 @@ export const preparePriceBook = baggage =>
|
|
|
154
162
|
seat,
|
|
155
163
|
seqNum,
|
|
156
164
|
wanted,
|
|
165
|
+
exitAfterBuy,
|
|
157
166
|
};
|
|
158
167
|
records.init(key, harden(bidderRecord));
|
|
159
168
|
return key;
|