@agoric/inter-protocol 0.17.0-upgrade-16-dev-0df76a7.0 → 0.17.0-upgrade-17-dev-a1453b2.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/package.json +26 -26
- package/src/auction/auctionBook.d.ts.map +1 -1
- package/src/auction/auctionBook.js +27 -46
- package/src/auction/auctionMath.d.ts +17 -0
- package/src/auction/auctionMath.d.ts.map +1 -0
- package/src/auction/auctionMath.js +81 -0
- package/src/auction/auctioneer.d.ts.map +1 -1
- package/src/auction/auctioneer.js +7 -10
- package/src/auction/offerBook.d.ts.map +1 -1
- package/src/auction/scheduleMath.d.ts.map +1 -1
- package/src/auction/scheduleMath.js +1 -1
- package/src/auction/scheduler.d.ts.map +1 -1
- package/src/auction/scheduler.js +3 -4
- package/src/auction/sortedOffers.d.ts.map +1 -1
- package/src/auction/sortedOffers.js +1 -2
- package/src/clientSupport.js +1 -1
- package/src/contractSupport.d.ts.map +1 -1
- package/src/contractSupport.js +6 -2
- package/src/interest.js +2 -2
- package/src/price/fluxAggregatorContract.d.ts.map +1 -1
- package/src/price/fluxAggregatorKit.d.ts.map +1 -1
- package/src/price/fluxAggregatorKit.js +6 -7
- package/src/price/priceOracleKit.d.ts.map +1 -1
- package/src/price/priceOracleKit.js +1 -1
- package/src/price/roundsManager.d.ts.map +1 -1
- package/src/price/roundsManager.js +1 -1
- package/src/proposals/add-auction.d.ts +40 -14
- package/src/proposals/add-auction.d.ts.map +1 -1
- package/src/proposals/add-auction.js +102 -49
- package/src/proposals/addAssetToVault.d.ts.map +1 -1
- package/src/proposals/addAssetToVault.js +1 -2
- package/src/proposals/econ-behaviors.d.ts +2 -0
- package/src/proposals/econ-behaviors.d.ts.map +1 -1
- package/src/proposals/econ-behaviors.js +0 -3
- package/src/proposals/startPSM.d.ts.map +1 -1
- package/src/proposals/startPSM.js +16 -12
- package/src/proposals/upgrade-vaults.d.ts +14 -10
- package/src/proposals/upgrade-vaults.d.ts.map +1 -1
- package/src/proposals/upgrade-vaults.js +99 -116
- package/src/proposals/utils.d.ts.map +1 -1
- package/src/proposals/utils.js +3 -4
- package/src/provisionPool.d.ts.map +1 -1
- package/src/provisionPoolKit.d.ts +6 -0
- package/src/provisionPoolKit.d.ts.map +1 -1
- package/src/provisionPoolKit.js +109 -50
- package/src/psm/psm.d.ts +4 -1
- package/src/psm/psm.d.ts.map +1 -1
- package/src/psm/psm.js +7 -7
- package/src/reserve/assetReserveKit.d.ts.map +1 -1
- package/src/reserve/assetReserveKit.js +6 -6
- package/src/vaultFactory/liquidation.d.ts.map +1 -1
- package/src/vaultFactory/liquidation.js +1 -2
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -1
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -1
- package/src/vaultFactory/storeUtils.d.ts +1 -1
- package/src/vaultFactory/storeUtils.d.ts.map +1 -1
- package/src/vaultFactory/vault.d.ts.map +1 -1
- package/src/vaultFactory/vault.js +1 -2
- package/src/vaultFactory/vaultDirector.d.ts +3 -2
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -1
- package/src/vaultFactory/vaultDirector.js +25 -16
- package/src/vaultFactory/vaultFactory.d.ts +1 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -1
- package/src/vaultFactory/vaultFactory.js +3 -1
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -1
- package/src/vaultFactory/vaultHolder.js +1 -2
- package/src/vaultFactory/vaultManager.d.ts.map +1 -1
- package/src/vaultFactory/vaultManager.js +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.17.0-upgrade-
|
|
3
|
+
"version": "0.17.0-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -31,32 +31,32 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@agoric/
|
|
35
|
-
"@agoric/
|
|
36
|
-
"@agoric/
|
|
37
|
-
"@agoric/
|
|
38
|
-
"@agoric/
|
|
39
|
-
"@agoric/
|
|
40
|
-
"@agoric/
|
|
41
|
-
"@agoric/
|
|
42
|
-
"@agoric/
|
|
43
|
-
"@
|
|
44
|
-
"@endo/
|
|
45
|
-
"@endo/eventual-send": "^1.2.
|
|
46
|
-
"@endo/far": "^1.1.
|
|
47
|
-
"@endo/marshal": "^1.5.
|
|
48
|
-
"@endo/nat": "^5.0.
|
|
49
|
-
"@endo/promise-kit": "^1.1.
|
|
34
|
+
"@agoric/ertp": "0.16.3-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
35
|
+
"@agoric/governance": "0.10.4-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
36
|
+
"@agoric/internal": "0.4.0-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
37
|
+
"@agoric/notifier": "0.7.0-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
38
|
+
"@agoric/store": "0.9.3-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
39
|
+
"@agoric/time": "0.3.3-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
40
|
+
"@agoric/vat-data": "0.5.3-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
41
|
+
"@agoric/vats": "0.16.0-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
42
|
+
"@agoric/zoe": "0.26.3-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
43
|
+
"@endo/captp": "^4.3.0",
|
|
44
|
+
"@endo/errors": "^1.2.5",
|
|
45
|
+
"@endo/eventual-send": "^1.2.5",
|
|
46
|
+
"@endo/far": "^1.1.5",
|
|
47
|
+
"@endo/marshal": "^1.5.3",
|
|
48
|
+
"@endo/nat": "^5.0.10",
|
|
49
|
+
"@endo/promise-kit": "^1.1.5",
|
|
50
50
|
"jessie.js": "^0.3.4"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@agoric/smart-wallet": "0.5.4-upgrade-
|
|
54
|
-
"@agoric/swingset-liveslots": "0.10.3-upgrade-
|
|
55
|
-
"@agoric/swingset-vat": "0.33.0-upgrade-
|
|
56
|
-
"@agoric/zone": "0.3.0-upgrade-
|
|
57
|
-
"@endo/bundle-source": "^3.
|
|
58
|
-
"@endo/init": "^1.1.
|
|
59
|
-
"@endo/promise-kit": "^1.1.
|
|
53
|
+
"@agoric/smart-wallet": "0.5.4-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
54
|
+
"@agoric/swingset-liveslots": "0.10.3-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
55
|
+
"@agoric/swingset-vat": "0.33.0-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
56
|
+
"@agoric/zone": "0.3.0-upgrade-17-dev-a1453b2.0+a1453b2",
|
|
57
|
+
"@endo/bundle-source": "^3.4.0",
|
|
58
|
+
"@endo/init": "^1.1.4",
|
|
59
|
+
"@endo/promise-kit": "^1.1.5",
|
|
60
60
|
"@fast-check/ava": "^1.1.5",
|
|
61
61
|
"ava": "^5.3.0",
|
|
62
62
|
"c8": "^9.1.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
84
|
"typeCoverage": {
|
|
85
|
-
"atLeast": 95.
|
|
85
|
+
"atLeast": 95.8
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "a1453b2877b017a7f5b43a92364067d001901953"
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auctionBook.d.ts","sourceRoot":"","sources":["auctionBook.js"],"names":[],"mappings":"AA8EO,6CAHI,KAAK,CAAC,KAAK,CAAC,mBACZ,KAAK,CAAC,KAAK,CAAC,oCAiBtB;AA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BACZ,KAAK,GAAG,IAAI;;;;;uBAEZ,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;;;;2BAEpB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;;;;oBAEpB,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;;;;;qBAEzB,MAAM,CAAC,KAAK,CAAC;;;;;yBAEb,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;0BA2pBpB,UAAU,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;6BAzuBrC,kBAAkB;oCACiD,4BAA4B"}
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
/// <reference types="@agoric/governance/exported" />
|
|
3
3
|
/// <reference types="@agoric/zoe/exported" />
|
|
4
4
|
|
|
5
|
+
import { Fail } from '@endo/errors';
|
|
6
|
+
import { E } from '@endo/captp';
|
|
5
7
|
import { AmountMath, RatioShape } from '@agoric/ertp';
|
|
6
8
|
import { mustMatch } from '@agoric/store';
|
|
7
9
|
import { M, prepareExoClassKit } from '@agoric/vat-data';
|
|
8
10
|
|
|
9
11
|
import { assertAllDefined, makeTracer } from '@agoric/internal';
|
|
10
12
|
import {
|
|
11
|
-
atomicRearrange,
|
|
12
13
|
ceilMultiplyBy,
|
|
13
|
-
floorDivideBy,
|
|
14
14
|
makeRatioFromAmounts,
|
|
15
15
|
makeRecorderTopic,
|
|
16
16
|
multiplyRatios,
|
|
17
17
|
ratioGTE,
|
|
18
18
|
} from '@agoric/zoe/src/contractSupport/index.js';
|
|
19
|
-
import { E } from '@endo/captp';
|
|
20
19
|
import { observeNotifier } from '@agoric/notifier';
|
|
21
20
|
|
|
22
21
|
import { makeNatAmountShape } from '../contractSupport.js';
|
|
22
|
+
import { amountsToSettle } from './auctionMath.js';
|
|
23
23
|
import { preparePriceBook, prepareScaledBidBook } from './offerBook.js';
|
|
24
24
|
import {
|
|
25
25
|
isScaledBidPriceHigher,
|
|
@@ -30,9 +30,9 @@ import {
|
|
|
30
30
|
/**
|
|
31
31
|
* @import {Baggage} from '@agoric/vat-data';
|
|
32
32
|
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
33
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
33
34
|
*/
|
|
34
35
|
|
|
35
|
-
const { Fail } = assert;
|
|
36
36
|
const { makeEmpty } = AmountMath;
|
|
37
37
|
|
|
38
38
|
const DEFAULT_DECIMALS = 9;
|
|
@@ -172,9 +172,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
172
172
|
|
|
173
173
|
const bookDataKit = makeRecorderKit(
|
|
174
174
|
node,
|
|
175
|
-
/** @type {
|
|
176
|
-
M.any()
|
|
177
|
-
),
|
|
175
|
+
/** @type {TypedPattern<BookDataNotification>} */ (M.any()),
|
|
178
176
|
);
|
|
179
177
|
|
|
180
178
|
return {
|
|
@@ -283,46 +281,36 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
283
281
|
return makeEmpty(collateralBrand);
|
|
284
282
|
}
|
|
285
283
|
|
|
286
|
-
/** @type {Amount<'nat'>} */
|
|
287
|
-
const initialCollateralTarget = AmountMath.min(
|
|
288
|
-
collateralWanted,
|
|
289
|
-
collateralAvailable,
|
|
290
|
-
);
|
|
291
|
-
|
|
292
284
|
const { curAuctionPrice, bidHoldingSeat, remainingProceedsGoal } =
|
|
293
285
|
this.state;
|
|
294
286
|
curAuctionPrice !== null ||
|
|
295
287
|
Fail`auctionPrice must be set before each round`;
|
|
296
288
|
assert(curAuctionPrice);
|
|
297
289
|
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
290
|
+
const { proceedsExpected, proceedsTarget, collateralTarget } =
|
|
291
|
+
amountsToSettle(
|
|
292
|
+
{
|
|
293
|
+
bidAlloc,
|
|
294
|
+
collateralWanted,
|
|
295
|
+
collateralAvailable,
|
|
296
|
+
curAuctionPrice,
|
|
297
|
+
remainingProceedsGoal,
|
|
298
|
+
},
|
|
299
|
+
trace,
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
if (proceedsExpected === null) {
|
|
303
303
|
seat.fail(Error('price fell to zero'));
|
|
304
304
|
return makeEmpty(collateralBrand);
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
|
|
308
|
-
const proceedsLimit = remainingProceedsGoal
|
|
309
|
-
? AmountMath.min(remainingProceedsGoal, minProceedsTarget)
|
|
310
|
-
: minProceedsTarget;
|
|
311
|
-
const isRaiseLimited =
|
|
312
|
-
remainingProceedsGoal ||
|
|
313
|
-
!AmountMath.isGTE(proceedsLimit, proceedsNeeded);
|
|
314
|
-
|
|
315
|
-
const [proceedsTarget, collateralTarget] = isRaiseLimited
|
|
316
|
-
? [proceedsLimit, floorDivideBy(proceedsLimit, curAuctionPrice)]
|
|
317
|
-
: [minProceedsTarget, initialCollateralTarget];
|
|
318
|
-
|
|
307
|
+
// check that the requested amount could be satisfied
|
|
319
308
|
const { Collateral } = seat.getProposal().want;
|
|
320
309
|
if (Collateral && AmountMath.isGTE(Collateral, collateralTarget)) {
|
|
321
310
|
seat.exit('unable to satisfy want');
|
|
322
311
|
}
|
|
323
312
|
|
|
324
|
-
atomicRearrange(
|
|
325
|
-
zcf,
|
|
313
|
+
zcf.atomicRearrange(
|
|
326
314
|
harden([
|
|
327
315
|
[collateralSeat, seat, { Collateral: collateralTarget }],
|
|
328
316
|
[seat, bidHoldingSeat, { Bid: proceedsTarget }],
|
|
@@ -336,7 +324,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
336
324
|
);
|
|
337
325
|
}
|
|
338
326
|
|
|
339
|
-
trace('
|
|
327
|
+
trace('settled', {
|
|
340
328
|
collateralTarget,
|
|
341
329
|
proceedsTarget,
|
|
342
330
|
remainingProceedsGoal: this.state.remainingProceedsGoal,
|
|
@@ -579,8 +567,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
579
567
|
state.startProceedsGoal = nextProceedsGoal;
|
|
580
568
|
}
|
|
581
569
|
|
|
582
|
-
atomicRearrange(
|
|
583
|
-
zcf,
|
|
570
|
+
zcf.atomicRearrange(
|
|
584
571
|
harden([[sourceSeat, collateralSeat, { Collateral: assetAmount }]]),
|
|
585
572
|
);
|
|
586
573
|
|
|
@@ -612,20 +599,14 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
612
599
|
const pricedOffers = priceBook.offersAbove(curAuctionPrice);
|
|
613
600
|
const scaledBidOffers = scaledBidBook.offersAbove(reduction);
|
|
614
601
|
|
|
615
|
-
const compareValues = (v1, v2) => {
|
|
616
|
-
if (v1 < v2) {
|
|
617
|
-
return -1;
|
|
618
|
-
} else if (v1 === v2) {
|
|
619
|
-
return 0;
|
|
620
|
-
} else {
|
|
621
|
-
return 1;
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
trace(`settling`, pricedOffers.length, scaledBidOffers.length);
|
|
625
602
|
// requested price or BidScaling gives no priority beyond specifying which
|
|
626
603
|
// round the order will be serviced in.
|
|
627
604
|
const prioritizedOffers = [...pricedOffers, ...scaledBidOffers].sort(
|
|
628
|
-
(a, b) =>
|
|
605
|
+
(a, b) => Number(a[1].seqNum - b[1].seqNum),
|
|
606
|
+
);
|
|
607
|
+
|
|
608
|
+
trace(
|
|
609
|
+
`settling ${prioritizedOffers.length} offers at ${curAuctionPrice} (priced ${pricedOffers.length}, scaled ${scaledBidOffers.length}) `,
|
|
629
610
|
);
|
|
630
611
|
|
|
631
612
|
const { remainingProceedsGoal } = state;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function amountsToSettle({ bidAlloc, collateralWanted, collateralAvailable, curAuctionPrice, remainingProceedsGoal, }: {
|
|
2
|
+
bidAlloc: Amount<"nat">;
|
|
3
|
+
collateralWanted: Amount<"nat">;
|
|
4
|
+
collateralAvailable: Amount<"nat">;
|
|
5
|
+
curAuctionPrice: Ratio;
|
|
6
|
+
remainingProceedsGoal: Amount<"nat"> | null;
|
|
7
|
+
}, log?: ((...msgs: any[]) => void) | undefined): {
|
|
8
|
+
proceedsExpected: null;
|
|
9
|
+
proceedsTarget?: undefined;
|
|
10
|
+
collateralTarget?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
proceedsExpected: import("@agoric/ertp/src/types.js").NatAmount;
|
|
13
|
+
proceedsTarget: import("@agoric/ertp/src/types.js").NatAmount;
|
|
14
|
+
collateralTarget: import("@agoric/ertp/src/types.js").NatAmount;
|
|
15
|
+
};
|
|
16
|
+
import type { Amount } from '@agoric/ertp/src/types.js';
|
|
17
|
+
//# sourceMappingURL=auctionMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auctionMath.d.ts","sourceRoot":"","sources":["auctionMath.js"],"names":[],"mappings":"AAoBO,8HARJ;IAAyB,QAAQ,EAAzB,OAAO,KAAK,CAAC;IACI,gBAAgB,EAAjC,OAAO,KAAK,CAAC;IACI,mBAAmB,EAApC,OAAO,KAAK,CAAC;IACJ,eAAe,EAAxB,KAAK;IACmB,qBAAqB,EAA7C,OAAO,KAAK,CAAC,GAAG,IAAI;CAE5B,mBAAkB,GAAG,EAAE,KAAK,IAAI;;;;;;;;EA6DlC;4BAxEwB,2BAA2B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AmountMath } from '@agoric/ertp';
|
|
2
|
+
import {
|
|
3
|
+
ceilMultiplyBy,
|
|
4
|
+
floorDivideBy,
|
|
5
|
+
} from '@agoric/zoe/src/contractSupport/index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @import {Amount} from '@agoric/ertp/src/types.js';
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {object} p
|
|
13
|
+
* @param {Amount<'nat'>} p.bidAlloc current allocation of the bidding seat
|
|
14
|
+
* @param {Amount<'nat'>} p.collateralWanted want of the offer
|
|
15
|
+
* @param {Amount<'nat'>} p.collateralAvailable available to auction
|
|
16
|
+
* @param {Ratio} p.curAuctionPrice current auction price
|
|
17
|
+
* @param {Amount<'nat'> | null} p.remainingProceedsGoal amount still needing
|
|
18
|
+
* liquidating over multiple rounds; null indicates no limit
|
|
19
|
+
* @param {(...msgs: any[]) => void} [log]
|
|
20
|
+
*/
|
|
21
|
+
export const amountsToSettle = (
|
|
22
|
+
{
|
|
23
|
+
bidAlloc,
|
|
24
|
+
collateralWanted,
|
|
25
|
+
collateralAvailable,
|
|
26
|
+
curAuctionPrice,
|
|
27
|
+
remainingProceedsGoal,
|
|
28
|
+
},
|
|
29
|
+
log = () => {},
|
|
30
|
+
) => {
|
|
31
|
+
log('amountsToSettle', {
|
|
32
|
+
bidAlloc,
|
|
33
|
+
collateralWanted,
|
|
34
|
+
collateralAvailable,
|
|
35
|
+
curAuctionPrice,
|
|
36
|
+
remainingProceedsGoal,
|
|
37
|
+
});
|
|
38
|
+
const initialCollateralTarget = AmountMath.min(
|
|
39
|
+
collateralWanted,
|
|
40
|
+
collateralAvailable,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const proceedsExpected = ceilMultiplyBy(
|
|
44
|
+
initialCollateralTarget,
|
|
45
|
+
curAuctionPrice,
|
|
46
|
+
);
|
|
47
|
+
if (AmountMath.isEmpty(proceedsExpected)) {
|
|
48
|
+
return { proceedsExpected: null };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const targetByProceeds = proceedsLimit =>
|
|
52
|
+
AmountMath.min(
|
|
53
|
+
collateralAvailable,
|
|
54
|
+
floorDivideBy(proceedsLimit, curAuctionPrice),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const [proceedsTarget, collateralTarget] = (() => {
|
|
58
|
+
// proceeds cannot exceed what is needed or being offered
|
|
59
|
+
const proceedsBidded = AmountMath.min(proceedsExpected, bidAlloc);
|
|
60
|
+
if (remainingProceedsGoal) {
|
|
61
|
+
const goalProceeds = AmountMath.min(
|
|
62
|
+
remainingProceedsGoal,
|
|
63
|
+
proceedsBidded,
|
|
64
|
+
);
|
|
65
|
+
return [goalProceeds, targetByProceeds(goalProceeds)];
|
|
66
|
+
} else if (AmountMath.isGTE(proceedsBidded, proceedsExpected)) {
|
|
67
|
+
// initial collateral suffices
|
|
68
|
+
return [proceedsBidded, initialCollateralTarget];
|
|
69
|
+
} else {
|
|
70
|
+
return [proceedsBidded, targetByProceeds(proceedsBidded)];
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
|
|
74
|
+
assert(
|
|
75
|
+
AmountMath.isGTE(collateralAvailable, collateralTarget),
|
|
76
|
+
'target cannot exceed available',
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return { proceedsExpected, proceedsTarget, collateralTarget };
|
|
80
|
+
};
|
|
81
|
+
harden(amountsToSettle);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auctioneer.d.ts","sourceRoot":"","sources":["auctioneer.js"],"names":[],"mappings":"AAgLO,yEAXI,MAAM,CAAC,KAAK,CAAC,YACb,MAAM,CAAC,KAAK,CAAC,YACb;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;CAAE,EAAE,kBAC/D,OAAO,kBACP,OAAO,qBAEP,MAAM,eAEN,OAAO,SACP,KAAK,kBAgNf;AAiBM,2BAdI,GAAG,CACb,eAAmB,CAAC,OAAO,oBAAoB,CAAC,GAAG;IACnD,YAAkB,EAAE,OAAO,cAAc,EAAE,YAAY,CAAC;IACxD,kBAAwB,EAAE,uBAAuB,CAAC;IAClD,cAAoB,EAAE,cAAc,CAAC;CAChC,CACF,eACO;IACV,sBAA0B,EAAE,UAAU,CAAC;IACvC,WAAe,EAAE,WAAW,CAAC;IAC7B,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;;;;;;;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,4BAA4B;6BAD/F,kBAAkB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="@agoric/governance/exported" />
|
|
2
2
|
/// <reference types="@agoric/zoe/exported" />
|
|
3
3
|
|
|
4
|
+
import { Fail, q } from '@endo/errors';
|
|
5
|
+
import { E } from '@endo/eventual-send';
|
|
6
|
+
import { Far } from '@endo/marshal';
|
|
4
7
|
import { AmountMath, AmountShape, BrandShape } from '@agoric/ertp';
|
|
5
8
|
import { handleParamGovernance } from '@agoric/governance';
|
|
6
9
|
import { BASIS_POINTS, makeTracer } from '@agoric/internal';
|
|
@@ -9,7 +12,6 @@ import { mustMatch } from '@agoric/store';
|
|
|
9
12
|
import { appendToStoredArray } from '@agoric/store/src/stores/store-utils.js';
|
|
10
13
|
import { M, provideDurableMapStore } from '@agoric/vat-data';
|
|
11
14
|
import {
|
|
12
|
-
atomicRearrange,
|
|
13
15
|
ceilDivideBy,
|
|
14
16
|
ceilMultiplyBy,
|
|
15
17
|
defineERecorderKit,
|
|
@@ -25,8 +27,6 @@ import {
|
|
|
25
27
|
offerTo,
|
|
26
28
|
} from '@agoric/zoe/src/contractSupport/index.js';
|
|
27
29
|
import { FullProposalShape } from '@agoric/zoe/src/typeGuards.js';
|
|
28
|
-
import { E } from '@endo/eventual-send';
|
|
29
|
-
import { Far } from '@endo/marshal';
|
|
30
30
|
|
|
31
31
|
import { makeNatAmountShape } from '../contractSupport.js';
|
|
32
32
|
import { makeOfferSpecShape, prepareAuctionBook } from './auctionBook.js';
|
|
@@ -35,11 +35,11 @@ import { makeScheduler } from './scheduler.js';
|
|
|
35
35
|
import { AuctionState } from './util.js';
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
38
39
|
* @import {Baggage} from '@agoric/vat-data';
|
|
39
40
|
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
40
41
|
*/
|
|
41
42
|
|
|
42
|
-
const { Fail, quote: q } = assert;
|
|
43
43
|
const { add, multiply } = natSafeMath;
|
|
44
44
|
|
|
45
45
|
const trace = makeTracer('Auction', true);
|
|
@@ -440,9 +440,7 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
440
440
|
const scheduleKit = makeERecorderKit(
|
|
441
441
|
E(privateArgs.storageNode).makeChildNode('schedule'),
|
|
442
442
|
/**
|
|
443
|
-
* @type {import('
|
|
444
|
-
* import('./scheduler.js').ScheduleNotification
|
|
445
|
-
* >}
|
|
443
|
+
* @type {TypedPattern<import('./scheduler.js').ScheduleNotification>}
|
|
446
444
|
*/ (M.any()),
|
|
447
445
|
);
|
|
448
446
|
|
|
@@ -491,8 +489,7 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
491
489
|
// send it all to the one
|
|
492
490
|
const liqSeat = depositsForBrand[0].seat;
|
|
493
491
|
|
|
494
|
-
atomicRearrange(
|
|
495
|
-
zcf,
|
|
492
|
+
zcf.atomicRearrange(
|
|
496
493
|
harden([
|
|
497
494
|
[collateralSeat, liqSeat, collateralSeat.getCurrentAllocation()],
|
|
498
495
|
[bidHoldingSeat, liqSeat, bidHoldingSeat.getCurrentAllocation()],
|
|
@@ -515,7 +512,7 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
515
512
|
reserveSeat,
|
|
516
513
|
brand,
|
|
517
514
|
);
|
|
518
|
-
atomicRearrange(
|
|
515
|
+
zcf.atomicRearrange(harden(transfers));
|
|
519
516
|
|
|
520
517
|
for (const { seat } of depositsForBrand) {
|
|
521
518
|
seat.exit();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offerBook.d.ts","sourceRoot":"","sources":["offerBook.js"],"names":[],"mappings":"AAkDO,8CAFI,OAAO,
|
|
1
|
+
{"version":3,"file":"offerBook.d.ts","sourceRoot":"","sources":["offerBook.js"],"names":[],"mappings":"AAkDO,8CAFI,OAAO,wFA8KgD,WAAW;IA5JvE;;;;;OAKG;cAJQ,OAAO,cACP,KAAK,UACL,MAAM,CAAC,KAAK,CAAC,gBACb,OAAO;IAsBlB,gCAAgC;4BAApB,KAAK;;;;;GAqCpB;AAcI,0CAFI,OAAO,wFAiFgD,WAAW;IA/DvE;;;;;OAKG;cAJQ,OAAO,SACP,KAAK,UACL,MAAM,CAAC,KAAK,CAAC,gBACb,OAAO;;;;;;GA0DrB;2BAnMU;IACZ,IAAQ,EAAE,OAAO,CAAC;IAClB,MAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAU,EAAE,QAAQ,CAAC;IACrB,QAAY,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;6BApBqB,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduleMath.d.ts","sourceRoot":"","sources":["scheduleMath.js"],"names":[],"mappings":"AA0CO,2CAJI,OAAO,CAAC,OAAO,aAAa,EAAE,mBAAmB,CAAC,YAClD,eAAe,GACb,OAAO,gBAAgB,EAAE,QAAQ,CAqE7C;AAcM,qDALI,OAAO,gBAAgB,EAAE,QAAQ,GAAG,IAAI,gBACxC,OAAO,gBAAgB,EAAE,QAAQ,GAAG,IAAI,OACxC,SAAS,GACP,SAAS,GAAG,IAAI,CAuB5B;AAQM,qCAJI,SAAS,YACT,OAAO,gBAAgB,EAAE,QAAQ,GAC/B,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,CAiBxD;
|
|
1
|
+
{"version":3,"file":"scheduleMath.d.ts","sourceRoot":"","sources":["scheduleMath.js"],"names":[],"mappings":"AA0CO,2CAJI,OAAO,CAAC,OAAO,aAAa,EAAE,mBAAmB,CAAC,YAClD,eAAe,GACb,OAAO,gBAAgB,EAAE,QAAQ,CAqE7C;AAcM,qDALI,OAAO,gBAAgB,EAAE,QAAQ,GAAG,IAAI,gBACxC,OAAO,gBAAgB,EAAE,QAAQ,GAAG,IAAI,OACxC,SAAS,GACP,SAAS,GAAG,IAAI,CAuB5B;AAQM,qCAJI,SAAS,YACT,OAAO,gBAAgB,EAAE,QAAQ,GAC/B,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,CAiBxD;qCAhKkC,cAAc"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
+
import { Fail } from '@endo/errors';
|
|
3
4
|
import { TimeMath } from '@agoric/time';
|
|
4
5
|
import { natSafeMath } from '@agoric/zoe/src/contractSupport/index.js';
|
|
5
6
|
import { assertAllDefined, makeTracer } from '@agoric/internal';
|
|
@@ -7,7 +8,6 @@ import { assertAllDefined, makeTracer } from '@agoric/internal';
|
|
|
7
8
|
/** @import {TimestampRecord} from '@agoric/time'; */
|
|
8
9
|
|
|
9
10
|
const { subtract, multiply, floorDivide } = natSafeMath;
|
|
10
|
-
const { Fail } = assert;
|
|
11
11
|
|
|
12
12
|
const trace = makeTracer('SMath', true);
|
|
13
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["scheduler.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["scheduler.js"],"names":[],"mappings":"AA8EO,6CAPI,aAAa,SACb,OAAO,cAAc,EAAE,YAAY,UACnC,OAAO,CAAC,OAAO,aAAa,EAAE,mBAAmB,CAAC,cAClD,OAAO,cAAc,EAAE,UAAU,oBACjC,OAAO,6CAA6C,EAAE,QAAQ,CAAC,oBAAoB,CAAC,2BACpF,kBAAkB,CAAC,2BAA2B,CAAC;;;;;;;;;;;;IA2RzD;;yBA5Ta,MAAM,IAAI;cACV,MAAM,IAAI;gBACV,MAAM,IAAI;mBACV,MAAM,IAAI;;;;;;;qBAKV,SAAS,GAAG,IAAI;;;;mBAEhB,SAAS,GAAG,IAAI;;;;;4BAChB,SAAS,GAAG,IAAI;;;eAqThB,OAAO,cAAc,EAAE,eAAe;aACtC,OAAO,cAAc,EAAE,eAAe;WACtC,QAAQ;aACR,QAAQ;gBACR,YAAY;eACZ,YAAY;;;;yBAMZ,QAAQ,GAAG,IAAI;yBACf,QAAQ,GAAG,IAAI"}
|
package/src/auction/scheduler.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { X, Fail, q, makeError } from '@endo/errors';
|
|
1
2
|
import { E } from '@endo/eventual-send';
|
|
2
|
-
import { TimeMath } from '@agoric/time';
|
|
3
3
|
import { Far } from '@endo/marshal';
|
|
4
|
+
import { TimeMath } from '@agoric/time';
|
|
4
5
|
import { makeTracer } from '@agoric/internal';
|
|
5
6
|
import { observeIteration, subscribeEach } from '@agoric/notifier';
|
|
6
7
|
|
|
@@ -11,8 +12,6 @@ import {
|
|
|
11
12
|
timeVsSchedule,
|
|
12
13
|
} from './scheduleMath.js';
|
|
13
14
|
|
|
14
|
-
const { details: X, Fail, quote: q } = assert;
|
|
15
|
-
|
|
16
15
|
const trace = makeTracer('SCHED', true);
|
|
17
16
|
|
|
18
17
|
// If the startAuction wakeup is no more than 5 minutes late, go ahead with it.
|
|
@@ -263,7 +262,7 @@ export const makeScheduler = async (
|
|
|
263
262
|
|
|
264
263
|
if (!nextSchedule) {
|
|
265
264
|
console.error(
|
|
266
|
-
|
|
265
|
+
makeError(X`tried to start auction when none is scheduled`),
|
|
267
266
|
);
|
|
268
267
|
return;
|
|
269
268
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortedOffers.d.ts","sourceRoot":"","sources":["sortedOffers.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sortedOffers.d.ts","sourceRoot":"","sources":["sortedOffers.js"],"names":[],"mappings":"AA6BO,8CAFI,KAAK,UAMf;AAUM,4CALI,KAAK,kBACL,MAAM,GACJ,MAAM,CAWlB;AAqCM,uCANI,MAAM,YACN,KAAK,CAAC,KAAK,CAAC,cACZ,KAAK,CAAC,KAAK,CAAC,eACZ,MAAM,GACJ,CAAC,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,CAS5D;AAED,sCAAsC;AACtC,qCADW,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAKhC;AAUK,2CALI,KAAK,kBACL,MAAM,GACJ,MAAM,CAWlB;AAUM,4CALI,MAAM,SACN,KAAK,eACL,MAAM,GACJ,CAAC,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,CAQ5D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
+
import { Fail } from '@endo/errors';
|
|
3
4
|
import {
|
|
4
5
|
makeRatio,
|
|
5
6
|
ratioToNumber,
|
|
@@ -9,8 +10,6 @@ import { RatioShape } from '@agoric/ertp';
|
|
|
9
10
|
|
|
10
11
|
import { decodeData, encodeData } from '../vaultFactory/storeUtils.js';
|
|
11
12
|
|
|
12
|
-
const { Fail } = assert;
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* @file we use a floating point representation of the price or rate as the
|
|
16
15
|
* first part of the key in the store. The second part is the sequence number
|
package/src/clientSupport.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractSupport.d.ts","sourceRoot":"","sources":["contractSupport.js"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"contractSupport.d.ts","sourceRoot":"","sources":["contractSupport.js"],"names":[],"mappings":";;;;;;;;AA4BO,4BANe,CAAC,SAAT,MAAO,QACV,CAAC,QACD,CAAC,QACD,CAAC,GACC,CAAC,CAGyC;AAQhD,gCALe,CAAC,SAAT,MAAO,QACV,CAAC,SACD,CAAC,GACC,CAAC,CAK2C;AAQlD,yCAHI,cAAc,QACd,MAAM,EAAE,QAQlB;AAMM,kCAHI,MAAM,EAAE,GACN,OAAO,CAInB;AAUM,0CAPI,MAAM,CAAC,KAAK,CAAC,aACb,MAAM,CAAC,KAAK,CAAC,UACb,MAAM,CAAC,KAAK,CAAC,QAcvB;AAoBM,0CAHI,KAAK;;;EAIsC;AAG/C,0CADK,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,WAAW,CAAC,SAEO;gCAtBtD,CAAC;wBAEA,iBAAiB,CAAC,CAAC,CAAC;yBACpB,kBAAkB,CAAC,CAAC,CAAC;;8BAItB,CAAC;sBAEA,SAAS,CAAC,CAAC,CAAC;uBACZ,gBAAgB,CAAC,CAAC,CAAC;;sCAvF6D,4BAA4B"}
|
package/src/contractSupport.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
+
import { Fail, q } from '@endo/errors';
|
|
3
4
|
import { AmountMath } from '@agoric/ertp';
|
|
4
5
|
import { M } from '@agoric/store';
|
|
5
6
|
import { makeRatioFromAmounts } from '@agoric/zoe/src/contractSupport/index.js';
|
|
6
7
|
|
|
7
8
|
/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
|
|
8
9
|
|
|
9
|
-
const { Fail, quote: q } = assert;
|
|
10
|
-
|
|
11
10
|
export const amountPattern = harden({ brand: M.remotable(), value: M.any() });
|
|
12
11
|
export const ratioPattern = harden({
|
|
13
12
|
numerator: amountPattern,
|
|
@@ -68,8 +67,13 @@ export const allEmpty = amounts => {
|
|
|
68
67
|
* @param {Amount<'nat'>} totalDebt
|
|
69
68
|
* @param {Amount<'nat'>} toMint
|
|
70
69
|
* @throws if minting would exceed total debt
|
|
70
|
+
*
|
|
71
|
+
* Note: Succeeds regardless of debtLimit if toMint is empty.
|
|
71
72
|
*/
|
|
72
73
|
export const checkDebtLimit = (debtLimit, totalDebt, toMint) => {
|
|
74
|
+
if (AmountMath.isEmpty(toMint)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
73
77
|
const debtPost = AmountMath.add(totalDebt, toMint);
|
|
74
78
|
AmountMath.isGTE(debtLimit, debtPost) ||
|
|
75
79
|
Fail`Minting ${q(toMint)} past ${q(
|
package/src/interest.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
+
import { Fail } from '@endo/errors';
|
|
3
4
|
import { AmountMath } from '@agoric/ertp';
|
|
4
5
|
import { natSafeMath } from '@agoric/zoe/src/contractSupport/index.js';
|
|
5
6
|
import {
|
|
@@ -7,7 +8,6 @@ import {
|
|
|
7
8
|
multiplyRatios,
|
|
8
9
|
quantize,
|
|
9
10
|
} from '@agoric/zoe/src/contractSupport/ratio.js';
|
|
10
|
-
import { Fail } from '@agoric/assert';
|
|
11
11
|
import { TimeMath } from '@agoric/time';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -197,7 +197,7 @@ export const chargeInterest = (powers, params, prior, accruedUntil) => {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
// NB: This method of inferring the compounded rate from the ratio of debts
|
|
200
|
-
//
|
|
200
|
+
// accrued suffers slightly from the integer nature of debts. However in
|
|
201
201
|
// testing with small numbers there's 5 digits of precision, and with large
|
|
202
202
|
// numbers the ratios tend towards ample precision.
|
|
203
203
|
// TODO adopt banker's rounding https://github.com/Agoric/agoric-sdk/issues/4573
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluxAggregatorContract.d.ts","sourceRoot":"","sources":["fluxAggregatorContract.js"],"names":[],"mappings":"AAcA;;;GAGG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAmBrB;AA0BK,2BAlBI,GAAG,CACb,OAAW,wBAAwB,EAAE,eAAe,GAAG;IACvD,KAAW,EAAE,YAAY,CAAC;IAC1B,OAAa,EAAE,KAAK,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/0F;kCAnL8B,cAAc;6BADnB,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluxAggregatorKit.d.ts","sourceRoot":"","sources":["fluxAggregatorKit.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fluxAggregatorKit.d.ts","sourceRoot":"","sources":["fluxAggregatorKit.js"],"names":[],"mappings":"AA2BA,yDAA0D;AAgEnD,kDAfI,OAAO,OACP,GAAG,CACb,eAAmB,GAAG;IACtB,KAAW,EAAE,YAAY,CAAC;IAC1B,OAAa,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,QAAc,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,YAAkB,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CAC9B,CACF,iBACO,YAAY,YACZ,OAAO,oBAAoB,EAAE,QAAQ,eACrC,WAAW,yBACX,MAAM,UAAU,CAAC,GAAG,CAAC,gBACrB,OAAO,6CAA6C,EAAE,YAAY,wBA+H9D,WAAW;;QAgBlB;;;;;;;;;WASG;uCADQ,MAAM;;gBAiBX,8DAA8D;kCAAlD,OAAO,oBAAoB,EAAE,UAAU;;gBAAnD,8DAA8D;kCAAlD,OAAO,oBAAoB,EAAE,UAAU;;;;;;;QAqBzD,+BAA+B;+BAAnB,MAAM;;QAalB,+BAA+B;6BAAnB,MAAM;;;;;;;;;QAoBlB;;;;;;;;WAQG;mCAHQ,MAAM,kBACN,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC;;;;;;;;;IAqDvC;;8BAxUa,OAAO;oBACP,MAAM;sBACN,MAAM;eACN,SAAS;kBACT,MAAM;iBACN,MAAM;;;wBAMN,MAAM;wBACN,MAAM;;;;;kBACN,MAAM;;;;;wBAEN,MAAM;;;;;wBAEN,MAAM;;;;;;aAEN,MAAM;;gCAuTN,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC;6BAvVpD,kBAAkB;kCAKb,cAAc;oCAbgD,4BAA4B;sCAA5B,4BAA4B;+BAS7F,cAAc"}
|
|
@@ -18,7 +18,10 @@ import { Far } from '@endo/marshal';
|
|
|
18
18
|
import { prepareOracleAdminKit } from './priceOracleKit.js';
|
|
19
19
|
import { prepareRoundsManagerKit } from './roundsManager.js';
|
|
20
20
|
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
23
|
+
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
24
|
+
*/
|
|
22
25
|
|
|
23
26
|
const trace = makeTracer('FlxAgg', true);
|
|
24
27
|
|
|
@@ -144,18 +147,14 @@ export const prepareFluxAggregatorKit = async (
|
|
|
144
147
|
priceKit: () =>
|
|
145
148
|
makeRecorderKit(
|
|
146
149
|
storageNode,
|
|
147
|
-
/** @type {
|
|
148
|
-
M.any()
|
|
149
|
-
),
|
|
150
|
+
/** @type {TypedPattern<PriceDescription>} */ (M.any()),
|
|
150
151
|
),
|
|
151
152
|
latestRoundKit: () =>
|
|
152
153
|
E.when(E(storageNode).makeChildNode('latestRound'), node =>
|
|
153
154
|
makeRecorderKit(
|
|
154
155
|
node,
|
|
155
156
|
/**
|
|
156
|
-
* @type {import('
|
|
157
|
-
* import('./roundsManager.js').LatestRound
|
|
158
|
-
* >}
|
|
157
|
+
* @type {TypedPattern<import('./roundsManager.js').LatestRound>}
|
|
159
158
|
*/ (M.any()),
|
|
160
159
|
),
|
|
161
160
|
),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priceOracleKit.d.ts","sourceRoot":"","sources":["priceOracleKit.js"],"names":[],"mappings":"AAMA,yDAA0D;AA4DnD,
|
|
1
|
+
{"version":3,"file":"priceOracleKit.d.ts","sourceRoot":"","sources":["priceOracleKit.js"],"names":[],"mappings":"AAMA,yDAA0D;AA4DnD,oFA2DqoH,WAAW;;;;;QA7C/oH;;;;WAIG;iEADQ,UAAU;QA0BrB,8BAA8B;qBAAhB,YAAY;;GAa/B;yBAjHU;IACZ,QAAY,EAAE,MAAM,CAAC;IACrB,WAAe,EAAE;QACjB,UAAgB,EAAE,CAClB,MAAc,EAAE,YAAY,EAC5B,MAAc,EAAE,OAAO,oBAAoB,EAAE,UAAU,KAC5C,OAAO,CAAC,YAAY,CAAC,CAAC;KAC5B,CAAC;CACH;yBAGU;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,EAAE,QAAQ,CAAA;CAAE;;;uBAKpD,MAAM;sBACN,MAAM;sBACN,MAAM;cACN,MAAM;;6BAGP,QAAQ,CAAC,UAAU,GAAG,EAAE,CAAC;2BAEzB,YAAY,GAAG,EAAE;oBAEhB,cAAc,GAAG,YAAY;wBAyF7B,UAAU,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|