@agoric/inter-protocol 0.14.1-dev-bf164a0.0 → 0.14.1-dev-4a0bf28.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-js-meta.json +116 -116
- package/bundles/bundle-econCommitteeCharter-js-meta.json +71 -71
- package/bundles/bundle-feeDistributor-js-meta.json +59 -59
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +111 -111
- package/bundles/bundle-fluxAggregatorKit.js +1 -1
- package/bundles/bundle-psm-js-meta.json +109 -109
- package/bundles/bundle-reserve-js-meta.json +108 -108
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +78 -78
- package/bundles/bundle-vaultFactory-js-meta.json +132 -132
- package/bundles/bundle-vaultFactory.js +1 -1
- package/package.json +17 -17
- package/src/clientSupport.js +79 -7
- package/src/price/fluxAggregatorContract.js +1 -1
- package/src/price/fluxAggregatorKit.js +1 -0
- package/src/price/roundsManager.js +8 -0
- package/src/proposals/econ-behaviors.js +5 -4
- package/src/vaultFactory/liquidation.js +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.14.1-dev-
|
|
3
|
+
"version": "0.14.1-dev-4a0bf28.0+4a0bf28",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -29,29 +29,29 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agoric/assert": "0.6.1-dev-
|
|
33
|
-
"@agoric/ertp": "0.16.1-dev-
|
|
34
|
-
"@agoric/governance": "0.10.1-dev-
|
|
35
|
-
"@agoric/internal": "0.3.1-dev-
|
|
36
|
-
"@agoric/notifier": "0.6.1-dev-
|
|
37
|
-
"@agoric/store": "0.9.1-dev-
|
|
38
|
-
"@agoric/time": "0.3.1-dev-
|
|
39
|
-
"@agoric/vat-data": "0.5.1-dev-
|
|
40
|
-
"@agoric/vats": "0.14.1-dev-
|
|
41
|
-
"@agoric/zoe": "0.26.1-dev-
|
|
32
|
+
"@agoric/assert": "0.6.1-dev-4a0bf28.0+4a0bf28",
|
|
33
|
+
"@agoric/ertp": "0.16.1-dev-4a0bf28.0+4a0bf28",
|
|
34
|
+
"@agoric/governance": "0.10.1-dev-4a0bf28.0+4a0bf28",
|
|
35
|
+
"@agoric/internal": "0.3.1-dev-4a0bf28.0+4a0bf28",
|
|
36
|
+
"@agoric/notifier": "0.6.1-dev-4a0bf28.0+4a0bf28",
|
|
37
|
+
"@agoric/store": "0.9.1-dev-4a0bf28.0+4a0bf28",
|
|
38
|
+
"@agoric/time": "0.3.1-dev-4a0bf28.0+4a0bf28",
|
|
39
|
+
"@agoric/vat-data": "0.5.1-dev-4a0bf28.0+4a0bf28",
|
|
40
|
+
"@agoric/vats": "0.14.1-dev-4a0bf28.0+4a0bf28",
|
|
41
|
+
"@agoric/zoe": "0.26.1-dev-4a0bf28.0+4a0bf28",
|
|
42
42
|
"@endo/captp": "^3.1.1",
|
|
43
43
|
"@endo/eventual-send": "^0.17.2",
|
|
44
44
|
"@endo/far": "^0.2.18",
|
|
45
45
|
"@endo/marshal": "^0.8.5",
|
|
46
46
|
"@endo/nat": "^4.1.27",
|
|
47
|
-
"agoric": "0.19.1-dev-
|
|
47
|
+
"agoric": "0.19.1-dev-4a0bf28.0+4a0bf28",
|
|
48
48
|
"jessie.js": "^0.3.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@agoric/deploy-script-support": "0.10.1-dev-
|
|
52
|
-
"@agoric/smart-wallet": "0.5.1-dev-
|
|
53
|
-
"@agoric/swingset-liveslots": "0.10.1-dev-
|
|
54
|
-
"@agoric/swingset-vat": "0.32.1-dev-
|
|
51
|
+
"@agoric/deploy-script-support": "0.10.1-dev-4a0bf28.0+4a0bf28",
|
|
52
|
+
"@agoric/smart-wallet": "0.5.1-dev-4a0bf28.0+4a0bf28",
|
|
53
|
+
"@agoric/swingset-liveslots": "0.10.1-dev-4a0bf28.0+4a0bf28",
|
|
54
|
+
"@agoric/swingset-vat": "0.32.1-dev-4a0bf28.0+4a0bf28",
|
|
55
55
|
"@endo/bundle-source": "^2.5.1",
|
|
56
56
|
"@endo/init": "^0.5.56",
|
|
57
57
|
"@endo/promise-kit": "^0.2.56",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "4a0bf28cfbdaa4475b44332182f28ae948684f98"
|
|
83
83
|
}
|
package/src/clientSupport.js
CHANGED
|
@@ -142,13 +142,13 @@ export const lookupOfferIdForVault = async (vaultId, currentP) => {
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* @param {Record<string, Brand>} brands
|
|
145
|
-
* @param {({ wantMinted: number
|
|
145
|
+
* @param {({ wantMinted: number, giveMinted?: undefined } | { giveMinted: number, wantMinted?: undefined })} opts
|
|
146
146
|
* @param {number} [fee=0]
|
|
147
147
|
* @param {string} [anchor]
|
|
148
148
|
* @returns {Proposal} XXX not a real proposal, uses BoardRemote
|
|
149
149
|
*/
|
|
150
150
|
const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
|
|
151
|
-
const giving =
|
|
151
|
+
const giving = 'giveMinted' in opts ? 'minted' : 'anchor';
|
|
152
152
|
const brand =
|
|
153
153
|
giving === 'anchor'
|
|
154
154
|
? { in: brands[anchor], out: brands.IST }
|
|
@@ -173,14 +173,15 @@ const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
|
|
|
173
173
|
/**
|
|
174
174
|
* @param {Instance} instance
|
|
175
175
|
* @param {Record<string, Brand>} brands
|
|
176
|
-
* @param {{ offerId:
|
|
177
|
-
* ({ wantMinted: number |
|
|
176
|
+
* @param {{ offerId: string, feePct?: number, pair: [string, string] } &
|
|
177
|
+
* ({ wantMinted: number } | { giveMinted: number })} opts
|
|
178
178
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
179
179
|
*/
|
|
180
180
|
const makePsmSwapOffer = (instance, brands, opts) => {
|
|
181
|
-
const method =
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
const method =
|
|
182
|
+
'wantMinted' in opts
|
|
183
|
+
? 'makeWantMintedInvitation'
|
|
184
|
+
: 'makeGiveMintedInvitation'; // ref psm.js
|
|
184
185
|
const proposal = makePsmProposal(
|
|
185
186
|
brands,
|
|
186
187
|
opts,
|
|
@@ -305,10 +306,81 @@ const makeAddCollateralOffer = (brands, opts) => {
|
|
|
305
306
|
return offerSpec;
|
|
306
307
|
};
|
|
307
308
|
|
|
309
|
+
/**
|
|
310
|
+
*
|
|
311
|
+
* @param {Record<string, Brand>} _brands
|
|
312
|
+
* @param {{
|
|
313
|
+
* offerId: string,
|
|
314
|
+
* roundId?: bigint,
|
|
315
|
+
* unitPrice: bigint,
|
|
316
|
+
* }} opts
|
|
317
|
+
* @param {string} previousOffer
|
|
318
|
+
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
319
|
+
*/
|
|
320
|
+
const makePushPriceOffer = (_brands, opts, previousOffer) => {
|
|
321
|
+
return {
|
|
322
|
+
id: opts.offerId,
|
|
323
|
+
invitationSpec: {
|
|
324
|
+
source: 'continuing',
|
|
325
|
+
previousOffer,
|
|
326
|
+
invitationMakerName: 'PushPrice',
|
|
327
|
+
invitationArgs: harden([
|
|
328
|
+
{ unitPrice: opts.unitPrice, roundId: opts.roundId },
|
|
329
|
+
]),
|
|
330
|
+
},
|
|
331
|
+
proposal: {},
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// TODO DRY with CLI wallet.js
|
|
336
|
+
/**
|
|
337
|
+
* @param {{
|
|
338
|
+
* brand: Record<string, Brand>,
|
|
339
|
+
* vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
|
|
340
|
+
* }} agoricNames
|
|
341
|
+
* @param {(msg: string) => Error} makeError error constructor
|
|
342
|
+
* @returns {(a: string) => Amount<'nat'>}
|
|
343
|
+
*/
|
|
344
|
+
export const makeParseAmount =
|
|
345
|
+
(agoricNames, makeError = msg => RangeError(msg)) =>
|
|
346
|
+
opt => {
|
|
347
|
+
assert.typeof(opt, 'string', 'parseAmount expected string');
|
|
348
|
+
const m = opt.match(/^(?<value>[\d_]+(\.[\d_]+)?)(?<brand>[A-Z]\w*?)$/);
|
|
349
|
+
if (!m || !m.groups) {
|
|
350
|
+
throw makeError(`invalid amount: ${opt}`);
|
|
351
|
+
}
|
|
352
|
+
const anyBrand = agoricNames.brand[m.groups.brand];
|
|
353
|
+
if (!anyBrand) {
|
|
354
|
+
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
355
|
+
}
|
|
356
|
+
const assetDesc = Object.values(agoricNames.vbankAsset).find(
|
|
357
|
+
d => d.brand === anyBrand,
|
|
358
|
+
);
|
|
359
|
+
if (!assetDesc) {
|
|
360
|
+
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
361
|
+
}
|
|
362
|
+
const { displayInfo } = assetDesc;
|
|
363
|
+
if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
|
|
364
|
+
throw makeError(`bad brand: ${displayInfo}`);
|
|
365
|
+
}
|
|
366
|
+
const value = BigInt(
|
|
367
|
+
Number(m.groups.value.replace(/_/g, '')) *
|
|
368
|
+
10 ** displayInfo.decimalPlaces,
|
|
369
|
+
);
|
|
370
|
+
/** @type {Brand<'nat'>} */
|
|
371
|
+
// @ts-expect-error dynamic cast
|
|
372
|
+
const natBrand = anyBrand;
|
|
373
|
+
const amt = { value, brand: natBrand };
|
|
374
|
+
return amt;
|
|
375
|
+
};
|
|
376
|
+
|
|
308
377
|
export const Offers = {
|
|
309
378
|
auction: {
|
|
310
379
|
Bid: makeBidOffer,
|
|
311
380
|
},
|
|
381
|
+
fluxAggregator: {
|
|
382
|
+
PushPrice: makePushPriceOffer,
|
|
383
|
+
},
|
|
312
384
|
psm: {
|
|
313
385
|
// lowercase because it's not an invitation name. Instead it's an abstraction over two invitation makers.
|
|
314
386
|
swap: makePsmSwapOffer,
|
|
@@ -15,7 +15,7 @@ import { E } from '@endo/eventual-send';
|
|
|
15
15
|
import { reserveThenDeposit } from '../proposals/utils.js';
|
|
16
16
|
import { prepareFluxAggregatorKit } from './fluxAggregatorKit.js';
|
|
17
17
|
|
|
18
|
-
const trace = makeTracer('FluxAgg');
|
|
18
|
+
const trace = makeTracer('FluxAgg', false);
|
|
19
19
|
/**
|
|
20
20
|
* @typedef {import('@agoric/vat-data').Baggage} Baggage
|
|
21
21
|
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
|
|
@@ -189,6 +189,7 @@ export const prepareFluxAggregatorKit = async (
|
|
|
189
189
|
priceAuthority.makeQuoteNotifier(unitAmountIn, brandOut),
|
|
190
190
|
{
|
|
191
191
|
updateState: quote => {
|
|
192
|
+
trace('new quote', quote);
|
|
192
193
|
void priceKit.recorder.write(priceDescriptionFromQuote(quote));
|
|
193
194
|
},
|
|
194
195
|
fail: reason => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fail, q } from '@agoric/assert';
|
|
2
2
|
import { AmountMath } from '@agoric/ertp';
|
|
3
|
+
import { makeTracer } from '@agoric/internal';
|
|
3
4
|
import { TimeMath } from '@agoric/time';
|
|
4
5
|
import { M, makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
|
|
5
6
|
import {
|
|
@@ -25,6 +26,8 @@ const V3_NO_DATA_ERROR = 'No data present';
|
|
|
25
26
|
/** @type {bigint} */
|
|
26
27
|
export const ROUND_MAX = BigInt(2 ** 32 - 1);
|
|
27
28
|
|
|
29
|
+
const trace = makeTracer('RoundsM', false);
|
|
30
|
+
|
|
28
31
|
/**
|
|
29
32
|
* @param {bigint} roundId
|
|
30
33
|
*/
|
|
@@ -290,6 +293,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
290
293
|
* @returns {OracleStatus} the new status
|
|
291
294
|
*/
|
|
292
295
|
recordSubmission(submission, roundId, status) {
|
|
296
|
+
trace('recordSubmission', submission, roundId, status);
|
|
293
297
|
const { helper } = this.facets;
|
|
294
298
|
const { details } = this.state;
|
|
295
299
|
helper.acceptingSubmissions(roundId) ||
|
|
@@ -670,6 +674,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
670
674
|
status,
|
|
671
675
|
{ roundId: roundIdRaw = undefined, unitPrice: valueRaw },
|
|
672
676
|
) {
|
|
677
|
+
trace('handlePush', status, roundIdRaw, valueRaw);
|
|
673
678
|
const value = Nat(valueRaw);
|
|
674
679
|
const { minSubmissionValue, maxSubmissionValue, timerPresence } =
|
|
675
680
|
this.state;
|
|
@@ -681,6 +686,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
681
686
|
Fail`value above maxSubmissionValue ${q(maxSubmissionValue)}`;
|
|
682
687
|
|
|
683
688
|
const blockTimestamp = await E(timerPresence).getCurrentTimestamp();
|
|
689
|
+
trace('handlePush blockTimestamp', blockTimestamp.absValue);
|
|
684
690
|
|
|
685
691
|
let roundId;
|
|
686
692
|
if (roundIdRaw === undefined) {
|
|
@@ -719,6 +725,8 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
719
725
|
helper.updateRoundAnswer(roundId, blockTimestamp);
|
|
720
726
|
helper.deleteRoundDetails(roundId);
|
|
721
727
|
|
|
728
|
+
trace('handlePush returning', settledStatus);
|
|
729
|
+
|
|
722
730
|
return settledStatus;
|
|
723
731
|
},
|
|
724
732
|
},
|
|
@@ -17,6 +17,7 @@ import { makeGovernedTerms as makeGovernedVFTerms } from '../vaultFactory/params
|
|
|
17
17
|
|
|
18
18
|
const trace = makeTracer('RunEconBehaviors', true);
|
|
19
19
|
|
|
20
|
+
export const SECONDS_PER_MINUTE = 60n;
|
|
20
21
|
export const SECONDS_PER_HOUR = 60n * 60n;
|
|
21
22
|
export const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
|
|
22
23
|
export const SECONDS_PER_WEEK = 7n * SECONDS_PER_DAY;
|
|
@@ -411,7 +412,7 @@ export const startRewardDistributor = async ({
|
|
|
411
412
|
const feeDistributorTerms = await deeplyFulfilledObject(
|
|
412
413
|
harden({
|
|
413
414
|
timerService,
|
|
414
|
-
collectionInterval:
|
|
415
|
+
collectionInterval: 1n * SECONDS_PER_HOUR,
|
|
415
416
|
keywordShares: {
|
|
416
417
|
RewardDistributor: 0n,
|
|
417
418
|
Reserve: 1n,
|
|
@@ -523,13 +524,13 @@ export const startAuctioneer = async (
|
|
|
523
524
|
},
|
|
524
525
|
{
|
|
525
526
|
auctionParams = {
|
|
526
|
-
StartFrequency:
|
|
527
|
-
ClockStep: 3n *
|
|
527
|
+
StartFrequency: 1n * SECONDS_PER_HOUR,
|
|
528
|
+
ClockStep: 3n * SECONDS_PER_MINUTE,
|
|
528
529
|
StartingRate: 10500n,
|
|
529
530
|
LowestRate: 6500n,
|
|
530
531
|
DiscountStep: 500n,
|
|
531
532
|
AuctionStartDelay: 2n,
|
|
532
|
-
PriceLockPeriod:
|
|
533
|
+
PriceLockPeriod: SECONDS_PER_HOUR / 2n,
|
|
533
534
|
},
|
|
534
535
|
} = {},
|
|
535
536
|
) => {
|
|
@@ -157,7 +157,12 @@ const setWakeupsForNextAuction = async (
|
|
|
157
157
|
E(timer).getCurrentTimestamp(),
|
|
158
158
|
]);
|
|
159
159
|
|
|
160
|
-
trace(
|
|
160
|
+
trace(
|
|
161
|
+
'setWakeupsForNextAuction at',
|
|
162
|
+
now.absValue,
|
|
163
|
+
'with',
|
|
164
|
+
nextAuctionSchedule,
|
|
165
|
+
);
|
|
161
166
|
if (!nextAuctionSchedule) {
|
|
162
167
|
// There should always be a nextAuctionSchedule. If there isn't, give up for now.
|
|
163
168
|
cancelWakeups(timer);
|