@agoric/inter-protocol 0.16.2-dev-57802f9.0 → 0.16.2-other-dev-70beeb7.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.
Files changed (160) hide show
  1. package/CHANGELOG.md +1041 -0
  2. package/package.json +30 -33
  3. package/scripts/add-collateral-core.js +112 -0
  4. package/scripts/build-bundles.js +21 -5
  5. package/scripts/deploy-contracts.js +100 -0
  6. package/scripts/init-core.js +198 -0
  7. package/scripts/invite-committee-core.js +42 -0
  8. package/scripts/manual-price-feed.js +117 -0
  9. package/scripts/price-feed-core.js +104 -0
  10. package/scripts/start-local-chain.sh +84 -0
  11. package/src/auction/auctionBook.js +59 -74
  12. package/src/auction/auctioneer.js +44 -56
  13. package/src/auction/offerBook.js +11 -12
  14. package/src/auction/params.js +5 -3
  15. package/src/auction/scheduleMath.js +13 -13
  16. package/src/auction/scheduler.js +32 -32
  17. package/src/auction/sortedOffers.js +7 -8
  18. package/src/auction/util.js +4 -4
  19. package/src/clientSupport.js +96 -152
  20. package/src/contractSupport.js +5 -5
  21. package/src/econCommitteeCharter.js +17 -18
  22. package/src/feeDistributor.js +33 -34
  23. package/src/interest.js +14 -20
  24. package/src/price/fluxAggregatorContract.js +45 -51
  25. package/src/price/fluxAggregatorKit.js +33 -48
  26. package/src/price/priceOracleKit.js +13 -11
  27. package/src/price/roundsManager.js +64 -52
  28. package/src/proposals/addAssetToVault.js +6 -15
  29. package/src/proposals/committee-proposal.js +27 -21
  30. package/src/proposals/core-proposal.js +7 -7
  31. package/src/proposals/econ-behaviors.js +32 -57
  32. package/src/proposals/price-feed-proposal.js +34 -66
  33. package/src/proposals/startEconCommittee.js +1 -1
  34. package/src/proposals/startPSM.js +22 -32
  35. package/src/proposals/utils.js +7 -26
  36. package/src/psm/psm.js +63 -69
  37. package/src/reserve/assetReserve.js +18 -27
  38. package/src/reserve/assetReserveKit.js +22 -14
  39. package/src/typeGuards.js +13 -0
  40. package/src/vaultFactory/liquidation.js +17 -30
  41. package/src/vaultFactory/math.js +9 -8
  42. package/src/vaultFactory/orderedVaultStore.js +9 -6
  43. package/src/vaultFactory/params.js +18 -24
  44. package/src/vaultFactory/prioritizedVaults.js +2 -2
  45. package/src/vaultFactory/proceeds.js +18 -24
  46. package/src/vaultFactory/storeUtils.js +12 -8
  47. package/src/vaultFactory/types.js +28 -38
  48. package/src/vaultFactory/vault.js +89 -88
  49. package/src/vaultFactory/vaultDirector.js +44 -35
  50. package/src/vaultFactory/vaultFactory.js +26 -33
  51. package/src/vaultFactory/vaultHolder.js +13 -8
  52. package/src/vaultFactory/vaultKit.js +2 -3
  53. package/src/vaultFactory/vaultManager.js +120 -138
  54. package/src/auction/auctionBook.d.ts +0 -83
  55. package/src/auction/auctionBook.d.ts.map +0 -1
  56. package/src/auction/auctioneer.d.ts +0 -75
  57. package/src/auction/auctioneer.d.ts.map +0 -1
  58. package/src/auction/offerBook.d.ts +0 -72
  59. package/src/auction/offerBook.d.ts.map +0 -1
  60. package/src/auction/params.d.ts +0 -142
  61. package/src/auction/params.d.ts.map +0 -1
  62. package/src/auction/scheduleMath.d.ts +0 -4
  63. package/src/auction/scheduleMath.d.ts.map +0 -1
  64. package/src/auction/scheduler.d.ts +0 -49
  65. package/src/auction/scheduler.d.ts.map +0 -1
  66. package/src/auction/sortedOffers.d.ts +0 -8
  67. package/src/auction/sortedOffers.d.ts.map +0 -1
  68. package/src/auction/util.d.ts +0 -30
  69. package/src/auction/util.d.ts.map +0 -1
  70. package/src/clientSupport.d.ts +0 -167
  71. package/src/clientSupport.d.ts.map +0 -1
  72. package/src/collectFees.d.ts +0 -2
  73. package/src/collectFees.d.ts.map +0 -1
  74. package/src/contractSupport.d.ts +0 -33
  75. package/src/contractSupport.d.ts.map +0 -1
  76. package/src/econCommitteeCharter.d.ts +0 -41
  77. package/src/econCommitteeCharter.d.ts.map +0 -1
  78. package/src/feeDistributor.d.ts +0 -212
  79. package/src/feeDistributor.d.ts.map +0 -1
  80. package/src/index.d.ts +0 -2
  81. package/src/index.d.ts.map +0 -1
  82. package/src/interest-math.d.ts +0 -3
  83. package/src/interest-math.d.ts.map +0 -1
  84. package/src/interest.d.ts +0 -29
  85. package/src/interest.d.ts.map +0 -1
  86. package/src/price/fluxAggregatorContract.d.ts +0 -112
  87. package/src/price/fluxAggregatorContract.d.ts.map +0 -1
  88. package/src/price/fluxAggregatorKit.d.ts +0 -155
  89. package/src/price/fluxAggregatorKit.d.ts.map +0 -1
  90. package/src/price/priceOracleKit.d.ts +0 -52
  91. package/src/price/priceOracleKit.d.ts.map +0 -1
  92. package/src/price/roundsManager.d.ts +0 -330
  93. package/src/price/roundsManager.d.ts.map +0 -1
  94. package/src/proposals/addAssetToVault.d.ts +0 -143
  95. package/src/proposals/addAssetToVault.d.ts.map +0 -1
  96. package/src/proposals/committee-proposal.d.ts +0 -113
  97. package/src/proposals/committee-proposal.d.ts.map +0 -1
  98. package/src/proposals/core-proposal.d.ts +0 -149
  99. package/src/proposals/core-proposal.d.ts.map +0 -1
  100. package/src/proposals/econ-behaviors.d.ts +0 -201
  101. package/src/proposals/econ-behaviors.d.ts.map +0 -1
  102. package/src/proposals/price-feed-proposal.d.ts +0 -82
  103. package/src/proposals/price-feed-proposal.d.ts.map +0 -1
  104. package/src/proposals/startEconCommittee.d.ts +0 -34
  105. package/src/proposals/startEconCommittee.d.ts.map +0 -1
  106. package/src/proposals/startPSM.d.ts +0 -61
  107. package/src/proposals/startPSM.d.ts.map +0 -1
  108. package/src/proposals/utils.d.ts +0 -15
  109. package/src/proposals/utils.d.ts.map +0 -1
  110. package/src/provisionPool.d.ts +0 -165
  111. package/src/provisionPool.d.ts.map +0 -1
  112. package/src/provisionPool.js +0 -119
  113. package/src/provisionPoolKit.d.ts +0 -379
  114. package/src/provisionPoolKit.d.ts.map +0 -1
  115. package/src/provisionPoolKit.js +0 -461
  116. package/src/psm/psm.d.ts +0 -178
  117. package/src/psm/psm.d.ts.map +0 -1
  118. package/src/psm/types.d.ts +0 -2
  119. package/src/psm/types.d.ts.map +0 -1
  120. package/src/reserve/assetReserve.d.ts +0 -44
  121. package/src/reserve/assetReserve.d.ts.map +0 -1
  122. package/src/reserve/assetReserveKit.d.ts +0 -114
  123. package/src/reserve/assetReserveKit.d.ts.map +0 -1
  124. package/src/reserve/params.d.ts +0 -10
  125. package/src/reserve/params.d.ts.map +0 -1
  126. package/src/tokens.d.ts +0 -3
  127. package/src/tokens.d.ts.map +0 -1
  128. package/src/tokens.js +0 -5
  129. package/src/vaultFactory/burn.d.ts +0 -2
  130. package/src/vaultFactory/burn.d.ts.map +0 -1
  131. package/src/vaultFactory/liquidation.d.ts +0 -24
  132. package/src/vaultFactory/liquidation.d.ts.map +0 -1
  133. package/src/vaultFactory/math.d.ts +0 -10
  134. package/src/vaultFactory/math.d.ts.map +0 -1
  135. package/src/vaultFactory/orderedVaultStore.d.ts +0 -94
  136. package/src/vaultFactory/orderedVaultStore.d.ts.map +0 -1
  137. package/src/vaultFactory/params.d.ts +0 -159
  138. package/src/vaultFactory/params.d.ts.map +0 -1
  139. package/src/vaultFactory/prioritizedVaults.d.ts +0 -279
  140. package/src/vaultFactory/prioritizedVaults.d.ts.map +0 -1
  141. package/src/vaultFactory/proceeds.d.ts +0 -34
  142. package/src/vaultFactory/proceeds.d.ts.map +0 -1
  143. package/src/vaultFactory/storeUtils.d.ts +0 -25
  144. package/src/vaultFactory/storeUtils.d.ts.map +0 -1
  145. package/src/vaultFactory/type-imports.d.ts +0 -2
  146. package/src/vaultFactory/type-imports.d.ts.map +0 -1
  147. package/src/vaultFactory/types.d.ts +0 -137
  148. package/src/vaultFactory/types.d.ts.map +0 -1
  149. package/src/vaultFactory/vault.d.ts +0 -529
  150. package/src/vaultFactory/vault.d.ts.map +0 -1
  151. package/src/vaultFactory/vaultDirector.d.ts +0 -560
  152. package/src/vaultFactory/vaultDirector.d.ts.map +0 -1
  153. package/src/vaultFactory/vaultFactory.d.ts +0 -162
  154. package/src/vaultFactory/vaultFactory.d.ts.map +0 -1
  155. package/src/vaultFactory/vaultHolder.d.ts +0 -201
  156. package/src/vaultFactory/vaultHolder.d.ts.map +0 -1
  157. package/src/vaultFactory/vaultKit.d.ts +0 -32
  158. package/src/vaultFactory/vaultKit.d.ts.map +0 -1
  159. package/src/vaultFactory/vaultManager.d.ts +0 -554
  160. package/src/vaultFactory/vaultManager.d.ts.map +0 -1
@@ -1,12 +1,11 @@
1
1
  // @jessie-check
2
2
 
3
3
  import { AmountMath, AssetKind } from '@agoric/ertp';
4
- import { deeplyFulfilledObject } from '@agoric/internal';
5
4
  import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
6
- import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
5
+ import { deeplyFulfilledObject } from '@agoric/internal';
6
+ import { Stable } from '@agoric/vats/src/tokens.js';
7
7
  import { E } from '@endo/far';
8
- import { Stable } from '@agoric/internal/src/tokens.js';
9
- import { instanceNameFor } from './price-feed-proposal.js';
8
+ import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
10
9
  import { reserveThenGetNames } from './utils.js';
11
10
 
12
11
  export * from './startPSM.js';
@@ -220,7 +219,6 @@ export const addAssetToVault = async (
220
219
  brand: {
221
220
  consume: { [Stable.symbol]: stableP },
222
221
  },
223
- instance: { consume: consumeInstance },
224
222
  },
225
223
  {
226
224
  options: {
@@ -241,11 +239,6 @@ export const addAssetToVault = async (
241
239
  [keyword],
242
240
  );
243
241
 
244
- const oracleInstanceName = instanceNameFor(oracleBrand, 'USD');
245
- // don't add the collateral offering to vaultFactory until its price feed is available
246
- // eslint-disable-next-line no-restricted-syntax -- allow this computed property
247
- await consumeInstance[oracleInstanceName];
248
-
249
242
  const stable = await stableP;
250
243
  const vaultFactoryCreator = E.get(vaultFactoryKit).creatorFacet;
251
244
  await E(vaultFactoryCreator).addVaultType(interchainIssuer, oracleBrand, {
@@ -293,7 +286,9 @@ export const getManifestForAddAssetToVault = (
293
286
  consume: {
294
287
  bankManager: true,
295
288
  agoricNamesAdmin: true,
289
+ bankMints: true,
296
290
  reserveKit: true,
291
+ vBankKits: true,
297
292
  startUpgradable: true,
298
293
  },
299
294
  produce: { bankMints: true, vBankKits: true },
@@ -308,6 +303,7 @@ export const getManifestForAddAssetToVault = (
308
303
  startUpgradable: true,
309
304
  priceAuthorityAdmin: true,
310
305
  priceAuthority: true,
306
+ scaledPriceAuthorityKits: true,
311
307
  },
312
308
  produce: {
313
309
  scaledPriceAuthorityKits: true,
@@ -325,11 +321,6 @@ export const getManifestForAddAssetToVault = (
325
321
  brand: {
326
322
  consume: { [Stable.symbol]: true },
327
323
  },
328
- instance: {
329
- // allow any instance because the AGORIC_INSTANCE_NAME of
330
- // priceFeedOptions cannot be known statically.
331
- consume: true,
332
- },
333
324
  },
334
325
  },
335
326
  installations: {
@@ -4,14 +4,14 @@ import { reserveThenDeposit } from './utils.js';
4
4
 
5
5
  const { values } = Object;
6
6
 
7
- /** @type {<X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
7
+ /** @type { <X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
8
8
  const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
9
9
 
10
10
  const EC_HIGH_PRIORITY_SENDERS_NAMESPACE = 'economicCommittee';
11
11
 
12
12
  /**
13
13
  * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
14
- * @param {{ options: { voterAddresses: Record<string, string> } }} param1
14
+ * @param {{ options: { voterAddresses: Record<string, string> }}} param1
15
15
  */
16
16
  export const inviteCommitteeMembers = async (
17
17
  {
@@ -26,14 +26,18 @@ export const inviteCommitteeMembers = async (
26
26
 
27
27
  const highPrioritySendersManager = await consume.highPrioritySendersManager;
28
28
 
29
- /** @param {[string, Promise<Invitation>][]} addrInvitations */
29
+ /**
30
+ * @param {[string, Promise<Invitation>][]} addrInvitations
31
+ */
30
32
  const distributeInvitations = async addrInvitations => {
31
33
  await Promise.all(
32
34
  addrInvitations.map(async ([addr, invitationP]) => {
33
- const debugName = `econ committee member ${addr}`;
34
- await reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
35
- invitationP,
36
- ]).catch(err => console.error(`failed deposit to ${debugName}`, err));
35
+ await reserveThenDeposit(
36
+ `econ committee member ${addr}`,
37
+ namesByAddressAdmin,
38
+ addr,
39
+ [invitationP],
40
+ );
37
41
  if (highPrioritySendersManager) {
38
42
  await E(highPrioritySendersManager).add(
39
43
  EC_HIGH_PRIORITY_SENDERS_NAMESPACE,
@@ -44,14 +48,14 @@ export const inviteCommitteeMembers = async (
44
48
  );
45
49
  };
46
50
 
47
- // This doesn't resolve until the committee members create their smart wallets.
48
- // Don't block bootstrap on it.
49
- void distributeInvitations(zip(values(voterAddresses), invitations));
51
+ await distributeInvitations(zip(values(voterAddresses), invitations));
50
52
  };
51
53
 
52
54
  harden(inviteCommitteeMembers);
53
55
 
54
- /** @param {import('./econ-behaviors').EconomyBootstrapPowers} powers */
56
+ /**
57
+ * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
58
+ */
55
59
  export const startEconCharter = async ({
56
60
  consume: { zoe },
57
61
  produce: { econCharterKit },
@@ -127,7 +131,7 @@ harden(addGovernorsToEconCharter);
127
131
 
128
132
  /**
129
133
  * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
130
- * @param {{ options: { voterAddresses: Record<string, string> } }} param1
134
+ * @param {{ options: { voterAddresses: Record<string, string> }}} param1
131
135
  */
132
136
  export const inviteToEconCharter = async (
133
137
  { consume: { namesByAddressAdmin, econCharterKit } },
@@ -135,15 +139,15 @@ export const inviteToEconCharter = async (
135
139
  ) => {
136
140
  const { creatorFacet } = E.get(econCharterKit);
137
141
 
138
- // This doesn't resolve until the committee members create their smart wallets.
139
- // Don't block bootstrap on it.
140
- void Promise.all(
141
- values(voterAddresses).map(async addr => {
142
- const debugName = `econ charter member ${addr}`;
143
- reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
144
- E(creatorFacet).makeCharterMemberInvitation(),
145
- ]).catch(err => console.error(`failed deposit to ${debugName}`, err));
146
- }),
142
+ await Promise.all(
143
+ values(voterAddresses).map(async addr =>
144
+ reserveThenDeposit(
145
+ `econ charter member ${addr}`,
146
+ namesByAddressAdmin,
147
+ addr,
148
+ [E(creatorFacet).makeCharterMemberInvitation()],
149
+ ),
150
+ ),
147
151
  );
148
152
  };
149
153
 
@@ -176,6 +180,8 @@ export const getManifestForInviteCommittee = async (
176
180
  [addGovernorsToEconCharter.name]: {
177
181
  consume: {
178
182
  auctioneerKit: t,
183
+ reserveGovernorCreatorFacet: t,
184
+ vaultFactoryGovernorCreator: t,
179
185
  econCharterKit: t,
180
186
  zoe: t,
181
187
  agoricNames: t,
@@ -1,6 +1,6 @@
1
1
  // @jessie-check
2
2
 
3
- import { Stable } from '@agoric/internal/src/tokens.js';
3
+ import { Stable } from '@agoric/vats/src/tokens.js';
4
4
  import * as econBehaviors from './econ-behaviors.js';
5
5
  import { ECON_COMMITTEE_MANIFEST } from './startEconCommittee.js';
6
6
 
@@ -15,7 +15,9 @@ export * from './startEconCommittee.js'; // eslint-disable-line import/export
15
15
  // require updating a lot of tests. So for now, we just
16
16
  // grab the kits afterward and store them.
17
17
 
18
- /** @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers */
18
+ /**
19
+ * @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers
20
+ */
19
21
  export const storeInterContractStartKits = async ({
20
22
  consume: {
21
23
  contractKits,
@@ -29,15 +31,13 @@ export const storeInterContractStartKits = async ({
29
31
  },
30
32
  }) => {
31
33
  /**
32
- * @param {Promise<MapStore<string, { instance: Instance }>>} storeP
33
- * @param {Promise<{ instance: Instance }>[]} kitPs
34
+ * @param {Promise<MapStore<string, {instance: Instance}>>} storeP
35
+ * @param {Promise<{instance: Instance}>[]} kitPs
34
36
  */
35
37
  const storeAll = async (storeP, kitPs) => {
36
38
  const store = await storeP;
37
39
  const kits = await Promise.all(kitPs);
38
- for (const kit of kits) {
39
- store.init(kit.instance, kit);
40
- }
40
+ kits.forEach(kit => store.init(kit.instance, kit));
41
41
  };
42
42
 
43
43
  await storeAll(contractKits, [
@@ -6,9 +6,11 @@ import { AmountMath } from '@agoric/ertp';
6
6
  import '@agoric/governance/exported.js';
7
7
  import { deeplyFulfilledObject, makeTracer } from '@agoric/internal';
8
8
  import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
9
+ import '@agoric/vats/exported.js';
10
+ import '@agoric/vats/src/core/types.js';
11
+ import { Stable } from '@agoric/vats/src/tokens.js';
9
12
  import { E } from '@endo/far';
10
13
  import { makeScalarBigMapStore } from '@agoric/vat-data';
11
- import { Stable } from '@agoric/internal/src/tokens.js';
12
14
  import { makeGovernedTerms as makeGovernedATerms } from '../auction/params.js';
13
15
  import { makeReserveTerms } from '../reserve/params.js';
14
16
  import { makeGovernedTerms as makeGovernedVFTerms } from '../vaultFactory/params.js';
@@ -22,9 +24,7 @@ export const SECONDS_PER_WEEK = 7n * SECONDS_PER_DAY;
22
24
 
23
25
  /**
24
26
  * @typedef {import('../vaultFactory/vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
25
- *
26
27
  * @typedef {import('../auction/auctioneer.js').AuctioneerPublicFacet} AuctioneerPublicFacet
27
- *
28
28
  * @typedef {import('../auction/auctioneer.js').AuctioneerCreatorFacet} AuctioneerCreatorFacet
29
29
  */
30
30
 
@@ -33,65 +33,43 @@ export const SECONDS_PER_WEEK = 7n * SECONDS_PER_DAY;
33
33
  * @property {string} label
34
34
  * @property {Instance} psm
35
35
  * @property {Instance} psmGovernor
36
- * @property {Awaited<
37
- * ReturnType<
38
- * Awaited<
39
- * ReturnType<import('../psm/psm.js')['start']>
40
- * >['creatorFacet']['getLimitedCreatorFacet']
41
- * >
42
- * >} psmCreatorFacet
43
- * @property {GovernorCreatorFacet<import('../../src/psm/psm.js')['start']>} psmGovernorCreatorFacet
36
+ * @property {Awaited<ReturnType<Awaited<ReturnType<import('../psm/psm.js')['prepare']>>['creatorFacet']['getLimitedCreatorFacet']>>} psmCreatorFacet
37
+ * @property {GovernorCreatorFacet<import('../../src/psm/psm.js')['prepare']>} psmGovernorCreatorFacet
44
38
  * @property {AdminFacet} psmAdminFacet
45
39
  */
46
40
 
47
- /** @typedef {GovernanceFacetKit<import('../auction/auctioneer.js').start>} AuctioneerKit */
41
+ /**
42
+ * @typedef {GovernanceFacetKit<import('../auction/auctioneer.js').start>} AuctioneerKit
43
+ */
48
44
 
49
45
  /**
50
- * @typedef {WellKnownSpaces & ChainBootstrapSpace & EconomyBootstrapSpace} EconomyBootstrapPowers
51
- *
46
+ * @typedef { WellKnownSpaces & ChainBootstrapSpace & EconomyBootstrapSpace
47
+ * } EconomyBootstrapPowers
52
48
  * @typedef {PromiseSpaceOf<{
53
- * economicCommitteeKit: CommitteeStartResult;
54
- * economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet;
55
- * feeDistributorKit: StartedInstanceKit<
56
- * typeof import('../feeDistributor.js').start
57
- * >;
58
- * periodicFeeCollectors: MapStore<
59
- * number,
60
- * import('../feeDistributor.js').PeriodicFeeCollector
61
- * >;
62
- * psmKit: MapStore<Brand, PSMKit>;
63
- * anchorBalancePayments: MapStore<Brand, Payment<'nat'>>;
64
- * econCharterKit: EconCharterStartResult;
65
- * reserveKit: GovernanceFacetKit<
66
- * import('../reserve/assetReserve.js')['start']
67
- * >;
68
- * vaultFactoryKit: GovernanceFacetKit<
69
- * import('../vaultFactory/vaultFactory.js')['start']
70
- * >;
71
- * auctioneerKit: AuctioneerKit;
72
- * minInitialDebt: NatValue;
49
+ * economicCommitteeKit: CommitteeStartResult,
50
+ * economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet,
51
+ * feeDistributorKit: StartedInstanceKit<typeof import('../feeDistributor.js').start>,
52
+ * periodicFeeCollectors: MapStore<number, import('../feeDistributor.js').PeriodicFeeCollector>,
53
+ * psmKit: MapStore<Brand, PSMKit>,
54
+ * anchorBalancePayments: MapStore<Brand, Payment<'nat'>>,
55
+ * econCharterKit: EconCharterStartResult,
56
+ * reserveKit: GovernanceFacetKit<import('../reserve/assetReserve.js')['prepare']>,
57
+ * vaultFactoryKit: GovernanceFacetKit<import('../vaultFactory/vaultFactory.js')['prepare']>,
58
+ * auctioneerKit: AuctioneerKit,
59
+ * minInitialDebt: NatValue,
73
60
  * }>} EconomyBootstrapSpace
74
61
  */
75
62
 
76
- /**
77
- * @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<
78
- * import('../econCommitteeCharter')['start']
79
- * >} EconCharterStartResult
80
- */
81
- /**
82
- * @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<
83
- * import('@agoric/governance/src/committee.js')['start']
84
- * >} CommitteeStartResult
85
- */
63
+ /** @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<import('../econCommitteeCharter')['prepare']>} EconCharterStartResult */
64
+ /** @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<import('@agoric/governance/src/committee.js')['prepare']>} CommitteeStartResult */
86
65
 
87
66
  /**
88
67
  * @file A collection of productions, each of which declares inputs and outputs.
89
- * Each function is passed a set of powers for reading from and writing to the
90
- * vat config.
68
+ * Each function is passed a set of powers for reading from and writing to the vat config.
91
69
  *
92
- * Each of the things they produce they're responsible for resolving or setting.
70
+ * Each of the things they produce they're responsible for resolving or setting.
93
71
  *
94
- * In production called by @agoric/vats to bootstrap.
72
+ * In production called by @agoric/vats to bootstrap.
95
73
  */
96
74
 
97
75
  /** @param {EconomyBootstrapPowers} powers */
@@ -323,11 +301,7 @@ export const startVaultFactory = async (
323
301
  }),
324
302
  );
325
303
 
326
- /**
327
- * @type {GovernorStartedInstallationKit<
328
- * typeof vaultFactoryInstallation
329
- * >}
330
- */
304
+ /** @type {GovernorStartedInstallationKit<typeof vaultFactoryInstallation>} */
331
305
  const g = await E(consume.zoe).startInstance(
332
306
  contractGovernorInstallation,
333
307
  undefined,
@@ -376,8 +350,8 @@ export const startVaultFactory = async (
376
350
  };
377
351
 
378
352
  /**
379
- * Grant access to the VaultFactory creatorFacet to up to one user based on
380
- * address.
353
+ * Grant access to the VaultFactory creatorFacet
354
+ * to up to one user based on address.
381
355
  *
382
356
  * @param {EconomyBootstrapPowers} powers
383
357
  * @param {object} [root0]
@@ -463,8 +437,9 @@ export const startRewardDistributor = async ({
463
437
 
464
438
  /**
465
439
  * @type {Awaited<
466
- * ReturnType<typeof import('../feeDistributor.js').makeFeeDistributor>
467
- * > & { adminFacet: AdminFacet; instance: Instance }}
440
+ * ReturnType<typeof import('../feeDistributor.js').makeFeeDistributor>>
441
+ * & { adminFacet: AdminFacet, instance: Instance }
442
+ * }
468
443
  */
469
444
  const instanceKit = await E(zoe).startInstance(
470
445
  feeDistributor,
@@ -1,10 +1,10 @@
1
1
  // @ts-nocheck -- lots of type errors. low prio b/c proposals are like scripts
2
- import { makeTracer } from '@agoric/internal';
2
+ import { E } from '@endo/far';
3
3
  import {
4
- assertPathSegment,
5
4
  makeStorageNodeChild,
5
+ assertPathSegment,
6
6
  } from '@agoric/internal/src/lib-chainStorage.js';
7
- import { E } from '@endo/far';
7
+ import { makeTracer } from '@agoric/internal';
8
8
 
9
9
  import { unitAmount } from '@agoric/zoe/src/contractSupport/priceQuote.js';
10
10
  import { reserveThenDeposit, reserveThenGetNames } from './utils.js';
@@ -18,17 +18,14 @@ const sanitizePathSegment = name => {
18
18
  return candidate;
19
19
  };
20
20
 
21
- export const instanceNameFor = (inBrandName, outBrandName) =>
22
- `${inBrandName}-${outBrandName} price feed`;
23
-
24
21
  /**
25
22
  * @typedef {{
26
- * brandIn?: ERef<Brand<'nat'> | undefined>;
27
- * brandOut?: ERef<Brand<'nat'> | undefined>;
28
- * IN_BRAND_NAME: string;
29
- * IN_BRAND_DECIMALS: string;
30
- * OUT_BRAND_NAME: string;
31
- * OUT_BRAND_DECIMALS: string;
23
+ * brandIn?: ERef<Brand<'nat'> | undefined>,
24
+ * brandOut?: ERef<Brand<'nat'> | undefined>,
25
+ * IN_BRAND_NAME: string,
26
+ * IN_BRAND_DECIMALS: string,
27
+ * OUT_BRAND_NAME: string,
28
+ * OUT_BRAND_DECIMALS: string,
32
29
  * }} PriceFeedOptions
33
30
  */
34
31
 
@@ -36,7 +33,7 @@ export const instanceNameFor = (inBrandName, outBrandName) =>
36
33
  * Create inert brands (no mint or issuer) referred to by price oracles.
37
34
  *
38
35
  * @param {ChainBootstrapSpace & NamedVatPowers} space
39
- * @param {{ options: { priceFeedOptions: PriceFeedOptions } }} opt
36
+ * @param {{options: {priceFeedOptions: PriceFeedOptions}}} opt
40
37
  * @returns {Promise<[Brand<'nat'>, Brand<'nat'>]>}
41
38
  */
42
39
  export const ensureOracleBrands = async (
@@ -65,6 +62,7 @@ export const ensureOracleBrands = async (
65
62
  let b = await brand;
66
63
  if (!b) {
67
64
  // not 1st await
65
+ // eslint-disable-next-line @jessie.js/no-nested-await
68
66
  b = await E(agoricNames).provideInertBrand(
69
67
  name,
70
68
  harden({ decimalPlaces: parseInt(decimals, 10) }),
@@ -81,17 +79,7 @@ export const ensureOracleBrands = async (
81
79
 
82
80
  /**
83
81
  * @param {ChainBootstrapSpace} powers
84
- * @param {{
85
- * options: {
86
- * priceFeedOptions: {
87
- * AGORIC_INSTANCE_NAME: string;
88
- * oracleAddresses: string[];
89
- * contractTerms: import('@agoric/inter-protocol/src/price/fluxAggregatorKit.js').ChainlinkConfig;
90
- * IN_BRAND_NAME: string;
91
- * OUT_BRAND_NAME: string;
92
- * };
93
- * };
94
- * }} config
82
+ * @param {{options: {priceFeedOptions: {AGORIC_INSTANCE_NAME: string, oracleAddresses: string[], contractTerms: import('@agoric/inter-protocol/src/price/fluxAggregatorKit.js').ChainlinkConfig, IN_BRAND_NAME: string, OUT_BRAND_NAME: string}}}} config
95
83
  */
96
84
  export const createPriceFeed = async (
97
85
  {
@@ -108,7 +96,6 @@ export const createPriceFeed = async (
108
96
  priceAuthorityAdmin,
109
97
  startGovernedUpgradable,
110
98
  },
111
- instance: { produce: produceInstance },
112
99
  },
113
100
  {
114
101
  options: {
@@ -130,17 +117,9 @@ export const createPriceFeed = async (
130
117
  const timer = await chainTimerService;
131
118
 
132
119
  /**
133
- * Values come from economy-template.json, which at this writing had IN:ATOM,
134
- * OUT:USD
120
+ * Values come from economy-template.json, which at this writing had IN:ATOM, OUT:USD
135
121
  *
136
- * @type {[
137
- * [Brand<'nat'>, Brand<'nat'>],
138
- * [
139
- * Installation<
140
- * import('@agoric/inter-protocol/src/price/fluxAggregatorContract.js')['start]
141
- * >,
142
- * ],
143
- * ]}
122
+ * @type {[[Brand<'nat'>, Brand<'nat'>], [Installation<import('@agoric/inter-protocol/src/price/fluxAggregatorContract.js').prepare>]]}
144
123
  */
145
124
  const [[brandIn, brandOut], [priceAggregator]] = await Promise.all([
146
125
  reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('oracleBrand'), [
@@ -182,27 +161,11 @@ export const createPriceFeed = async (
182
161
  installation: priceAggregator,
183
162
  });
184
163
 
185
- // Publish price feed in home.priceAuthority.
186
- const forceReplace = true;
187
- // Make sure this PA is registered before sharing the instance in agoricNames,
188
- // which allows contracts that depend on the registry value to wait for it and
189
- // prevent a race.
190
- await E(priceAuthorityAdmin).registerPriceAuthority(
191
- E(faKit.publicFacet).getPriceAuthority(),
192
- brandIn,
193
- brandOut,
194
- forceReplace,
195
- );
196
-
197
- await E(E(agoricNamesAdmin).lookupAdmin('instance'))
164
+ E(E(agoricNamesAdmin).lookupAdmin('instance'))
198
165
  .update(AGORIC_INSTANCE_NAME, faKit.instance)
199
166
  .catch(err =>
200
167
  console.error(`🚨 failed to update ${AGORIC_INSTANCE_NAME}`, err),
201
168
  );
202
- // being after the above awaits means that when this resolves, the consumer
203
- // gets notified that the authority is in the registry and its instance is in
204
- // agoricNames.
205
- produceInstance[AGORIC_INSTANCE_NAME].resolve(faKit.instance);
206
169
 
207
170
  E(E.get(econCharterKit).creatorFacet).addInstance(
208
171
  faKit.instance,
@@ -211,6 +174,15 @@ export const createPriceFeed = async (
211
174
  );
212
175
  trace('registered', AGORIC_INSTANCE_NAME, faKit.instance);
213
176
 
177
+ // Publish price feed in home.priceAuthority.
178
+ const forceReplace = true;
179
+ void E(priceAuthorityAdmin).registerPriceAuthority(
180
+ E(faKit.publicFacet).getPriceAuthority(),
181
+ brandIn,
182
+ brandOut,
183
+ forceReplace,
184
+ );
185
+
214
186
  /**
215
187
  * Initialize a new oracle and send an invitation to administer it.
216
188
  *
@@ -218,23 +190,22 @@ export const createPriceFeed = async (
218
190
  */
219
191
  const addOracle = async addr => {
220
192
  const invitation = await E(faKit.creatorFacet).makeOracleInvitation(addr);
221
- const debugName = `${AGORIC_INSTANCE_NAME} member ${addr}`;
222
- await reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
223
- invitation,
224
- ]).catch(err => console.error(`failed deposit to ${debugName}`, err));
193
+ await reserveThenDeposit(
194
+ `${AGORIC_INSTANCE_NAME} member ${addr}`,
195
+ namesByAddressAdmin,
196
+ addr,
197
+ [invitation],
198
+ );
225
199
  };
226
200
 
227
201
  trace('distributing invitations', oracleAddresses);
228
- // This doesn't resolve until oracle operators create their smart wallets.
229
- // Don't block bootstrap on it.
230
- void Promise.all(oracleAddresses.map(addOracle));
202
+ await Promise.all(oracleAddresses.map(addOracle));
231
203
  trace('createPriceFeed complete');
232
204
  };
233
205
 
234
206
  const t = 'priceFeed';
235
207
  /**
236
- * Add a price feed to a running chain, returning the manifest, installations,
237
- * and options.
208
+ * Add a price feed to a running chain, returning the manifest, installations, and options.
238
209
  *
239
210
  * @param {object} utils
240
211
  * @param {(ref: unknown) => Promise<unknown>} [utils.restoreRef]
@@ -252,6 +223,7 @@ export const getManifestForPriceFeed = async (
252
223
  chainStorage: t,
253
224
  chainTimerService: t,
254
225
  client: t,
226
+ contractGovernor: t,
255
227
  econCharterKit: t,
256
228
  economicCommitteeCreatorFacet: t,
257
229
  highPrioritySendersManager: t,
@@ -260,9 +232,6 @@ export const getManifestForPriceFeed = async (
260
232
  priceAuthorityAdmin: t,
261
233
  startGovernedUpgradable: t,
262
234
  },
263
- instance: {
264
- produce: t,
265
- },
266
235
  },
267
236
  [ensureOracleBrands.name]: {
268
237
  namedVat: {
@@ -274,7 +243,6 @@ export const getManifestForPriceFeed = async (
274
243
  },
275
244
  },
276
245
  installations: {
277
- // ??? will every eval of price-feed-proposal install priceAggregator ?
278
246
  priceAggregator: restoreRef(priceFeedOptions.priceAggregatorRef),
279
247
  },
280
248
  options: {
@@ -335,7 +303,7 @@ export const startPriceFeeds = async (
335
303
  {
336
304
  options: {
337
305
  priceFeedOptions: {
338
- AGORIC_INSTANCE_NAME: instanceNameFor(inBrandName, outBrandName),
306
+ AGORIC_INSTANCE_NAME: `${inBrandName}-${outBrandName} price feed`,
339
307
  contractTerms: {
340
308
  minSubmissionCount: 2,
341
309
  minSubmissionValue: 1,
@@ -22,7 +22,7 @@ const sanitizePathSegment = name => {
22
22
 
23
23
  /**
24
24
  * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
25
- * @param {object} config
25
+ * @param {object} [config]
26
26
  * @param {object} [config.options]
27
27
  * @param {EconCommitteeOptions} [config.options.econCommitteeOptions]
28
28
  */