@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-3eb1a1d.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 (191) hide show
  1. package/README.md +6 -6
  2. package/package.json +42 -36
  3. package/scripts/build-bundles.js +5 -21
  4. package/src/auction/auctionBook.d.ts +147 -0
  5. package/src/auction/auctionBook.d.ts.map +1 -0
  6. package/src/auction/auctionBook.js +156 -150
  7. package/src/auction/auctionMath.d.ts +17 -0
  8. package/src/auction/auctionMath.d.ts.map +1 -0
  9. package/src/auction/auctionMath.js +81 -0
  10. package/src/auction/auctioneer.d.ts +69 -0
  11. package/src/auction/auctioneer.d.ts.map +1 -0
  12. package/src/auction/auctioneer.js +70 -59
  13. package/src/auction/offerBook.d.ts +45 -0
  14. package/src/auction/offerBook.d.ts.map +1 -0
  15. package/src/auction/offerBook.js +13 -12
  16. package/src/auction/params.d.ts +144 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/params.js +10 -9
  19. package/src/auction/scheduleMath.d.ts +5 -0
  20. package/src/auction/scheduleMath.d.ts.map +1 -0
  21. package/src/auction/scheduleMath.js +18 -16
  22. package/src/auction/scheduler.d.ts +50 -0
  23. package/src/auction/scheduler.d.ts.map +1 -0
  24. package/src/auction/scheduler.js +53 -47
  25. package/src/auction/sortedOffers.d.ts +8 -0
  26. package/src/auction/sortedOffers.d.ts.map +1 -0
  27. package/src/auction/sortedOffers.js +10 -9
  28. package/src/auction/util.d.ts +30 -0
  29. package/src/auction/util.d.ts.map +1 -0
  30. package/src/auction/util.js +9 -6
  31. package/src/clientSupport.d.ts +167 -0
  32. package/src/clientSupport.d.ts.map +1 -0
  33. package/src/clientSupport.js +155 -97
  34. package/src/collectFees.d.ts +2 -0
  35. package/src/collectFees.d.ts.map +1 -0
  36. package/src/contractSupport.d.ts +28 -0
  37. package/src/contractSupport.d.ts.map +1 -0
  38. package/src/contractSupport.js +19 -13
  39. package/src/econCommitteeCharter.d.ts +40 -0
  40. package/src/econCommitteeCharter.d.ts.map +1 -0
  41. package/src/econCommitteeCharter.js +21 -20
  42. package/src/feeDistributor.d.ts +224 -0
  43. package/src/feeDistributor.d.ts.map +1 -0
  44. package/src/feeDistributor.js +37 -33
  45. package/src/index.d.ts +2 -0
  46. package/src/index.d.ts.map +1 -0
  47. package/src/index.js +1 -0
  48. package/src/interest-math.d.ts +3 -0
  49. package/src/interest-math.d.ts.map +1 -0
  50. package/src/interest.d.ts +28 -0
  51. package/src/interest.d.ts.map +1 -0
  52. package/src/interest.js +23 -18
  53. package/src/price/README.md +13 -0
  54. package/src/price/fluxAggregatorContract.d.ts +71 -0
  55. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  56. package/src/price/fluxAggregatorContract.js +64 -55
  57. package/src/price/fluxAggregatorKit.d.ts +103 -0
  58. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  59. package/src/price/fluxAggregatorKit.js +52 -40
  60. package/src/price/priceOracleKit.d.ts +38 -0
  61. package/src/price/priceOracleKit.d.ts.map +1 -0
  62. package/src/price/priceOracleKit.js +12 -14
  63. package/src/price/roundsManager.d.ts +204 -0
  64. package/src/price/roundsManager.d.ts.map +1 -0
  65. package/src/price/roundsManager.js +131 -85
  66. package/src/proposals/README.md +2 -3
  67. package/src/proposals/add-auction.d.ts +109 -0
  68. package/src/proposals/add-auction.d.ts.map +1 -0
  69. package/src/proposals/add-auction.js +256 -0
  70. package/src/proposals/addAssetToVault.d.ts +173 -0
  71. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  72. package/src/proposals/addAssetToVault.js +192 -40
  73. package/src/proposals/committee-proposal.d.ts +113 -0
  74. package/src/proposals/committee-proposal.d.ts.map +1 -0
  75. package/src/proposals/committee-proposal.js +25 -31
  76. package/src/proposals/core-proposal.d.ts +149 -0
  77. package/src/proposals/core-proposal.d.ts.map +1 -0
  78. package/src/proposals/core-proposal.js +9 -11
  79. package/src/proposals/deploy-price-feeds.d.ts +76 -0
  80. package/src/proposals/deploy-price-feeds.d.ts.map +1 -0
  81. package/src/proposals/deploy-price-feeds.js +316 -0
  82. package/src/proposals/econ-behaviors.d.ts +541 -0
  83. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  84. package/src/proposals/econ-behaviors.js +64 -45
  85. package/src/proposals/price-feed-proposal.d.ts +84 -0
  86. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  87. package/src/proposals/price-feed-proposal.js +109 -51
  88. package/src/proposals/replace-fee-distributor.d.ts +48 -0
  89. package/src/proposals/replace-fee-distributor.d.ts.map +1 -0
  90. package/src/proposals/replace-fee-distributor.js +195 -0
  91. package/src/proposals/replace-scaledPriceAuthorities.d.ts +30 -0
  92. package/src/proposals/replace-scaledPriceAuthorities.d.ts.map +1 -0
  93. package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
  94. package/src/proposals/replaceElectorate.d.ts +55 -0
  95. package/src/proposals/replaceElectorate.d.ts.map +1 -0
  96. package/src/proposals/replaceElectorate.js +521 -0
  97. package/src/proposals/startEconCommittee.d.ts +34 -0
  98. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  99. package/src/proposals/startEconCommittee.js +2 -2
  100. package/src/proposals/startPSM.d.ts +59 -0
  101. package/src/proposals/startPSM.d.ts.map +1 -0
  102. package/src/proposals/startPSM.js +44 -29
  103. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
  104. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
  105. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  106. package/src/proposals/upgrade-vaults.d.ts +41 -0
  107. package/src/proposals/upgrade-vaults.d.ts.map +1 -0
  108. package/src/proposals/upgrade-vaults.js +202 -0
  109. package/src/proposals/utils.d.ts +19 -0
  110. package/src/proposals/utils.d.ts.map +1 -0
  111. package/src/proposals/utils.js +43 -9
  112. package/src/provisionPool.d.ts +163 -0
  113. package/src/provisionPool.d.ts.map +1 -0
  114. package/src/provisionPool.js +122 -0
  115. package/src/provisionPoolKit.d.ts +359 -0
  116. package/src/provisionPoolKit.d.ts.map +1 -0
  117. package/src/provisionPoolKit.js +522 -0
  118. package/src/psm/psm.d.ts +125 -0
  119. package/src/psm/psm.d.ts.map +1 -0
  120. package/src/psm/psm.js +80 -79
  121. package/src/psm/types-ambient.d.ts +2 -0
  122. package/src/psm/types-ambient.d.ts.map +1 -0
  123. package/src/psm/types-ambient.js +3 -0
  124. package/src/reserve/assetReserve.d.ts +47 -0
  125. package/src/reserve/assetReserve.d.ts.map +1 -0
  126. package/src/reserve/assetReserve.js +28 -19
  127. package/src/reserve/assetReserveKit.d.ts +74 -0
  128. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  129. package/src/reserve/assetReserveKit.js +24 -30
  130. package/src/reserve/params.d.ts +10 -0
  131. package/src/reserve/params.d.ts.map +1 -0
  132. package/src/tokens.d.ts +3 -0
  133. package/src/tokens.d.ts.map +1 -0
  134. package/src/tokens.js +5 -0
  135. package/src/vaultFactory/burn.d.ts +2 -0
  136. package/src/vaultFactory/burn.d.ts.map +1 -0
  137. package/src/vaultFactory/burn.js +1 -1
  138. package/src/vaultFactory/liquidation.d.ts +23 -0
  139. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  140. package/src/vaultFactory/liquidation.js +37 -24
  141. package/src/vaultFactory/math.d.ts +11 -0
  142. package/src/vaultFactory/math.d.ts.map +1 -0
  143. package/src/vaultFactory/math.js +10 -9
  144. package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
  145. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  146. package/src/vaultFactory/orderedVaultStore.js +8 -11
  147. package/src/vaultFactory/params.d.ts +140 -0
  148. package/src/vaultFactory/params.d.ts.map +1 -0
  149. package/src/vaultFactory/params.js +52 -24
  150. package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
  151. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  152. package/src/vaultFactory/prioritizedVaults.js +4 -4
  153. package/src/vaultFactory/proceeds.d.ts +35 -0
  154. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  155. package/src/vaultFactory/proceeds.js +26 -18
  156. package/src/vaultFactory/storeUtils.d.ts +25 -0
  157. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  158. package/src/vaultFactory/storeUtils.js +10 -12
  159. package/src/vaultFactory/types-ambient.d.ts +137 -0
  160. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  161. package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
  162. package/src/vaultFactory/vault.d.ts +343 -0
  163. package/src/vaultFactory/vault.d.ts.map +1 -0
  164. package/src/vaultFactory/vault.js +105 -99
  165. package/src/vaultFactory/vaultDirector.d.ts +341 -0
  166. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  167. package/src/vaultFactory/vaultDirector.js +86 -64
  168. package/src/vaultFactory/vaultFactory.d.ts +202 -0
  169. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  170. package/src/vaultFactory/vaultFactory.js +52 -33
  171. package/src/vaultFactory/vaultHolder.d.ts +126 -0
  172. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  173. package/src/vaultFactory/vaultHolder.js +11 -16
  174. package/src/vaultFactory/vaultKit.d.ts +32 -0
  175. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  176. package/src/vaultFactory/vaultKit.js +5 -4
  177. package/src/vaultFactory/vaultManager.d.ts +674 -0
  178. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  179. package/src/vaultFactory/vaultManager.js +257 -158
  180. package/CHANGELOG.md +0 -1041
  181. package/exported.js +0 -2
  182. package/scripts/add-collateral-core.js +0 -112
  183. package/scripts/deploy-contracts.js +0 -100
  184. package/scripts/init-core.js +0 -198
  185. package/scripts/invite-committee-core.js +0 -42
  186. package/scripts/manual-price-feed.js +0 -117
  187. package/scripts/price-feed-core.js +0 -104
  188. package/scripts/start-local-chain.sh +0 -84
  189. package/src/psm/types.js +0 -3
  190. package/src/typeGuards.js +0 -13
  191. package/src/vaultFactory/type-imports.js +0 -4
package/src/psm/psm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @jessie-check
2
+ /// <reference types="@agoric/governance/exported" />
3
+ /// <reference types="@agoric/zoe/exported" />
2
4
 
3
- import '@agoric/governance/exported.js';
4
- import '@agoric/zoe/exported.js';
5
- import '@agoric/zoe/src/contracts/exported.js';
6
-
5
+ import { Fail } from '@endo/errors';
6
+ import { E } from '@endo/eventual-send';
7
7
  import { AmountMath, AmountShape, BrandShape, RatioShape } from '@agoric/ertp';
8
8
  import {
9
9
  CONTRACT_ELECTORATE,
@@ -14,7 +14,6 @@ import {
14
14
  import { StorageNodeShape } from '@agoric/internal';
15
15
  import { M, prepareExo, provide } from '@agoric/vat-data';
16
16
  import {
17
- atomicRearrange,
18
17
  atomicTransfer,
19
18
  ceilMultiplyBy,
20
19
  floorDivideBy,
@@ -31,90 +30,96 @@ import {
31
30
  InstanceHandleShape,
32
31
  InvitationShape,
33
32
  } from '@agoric/zoe/src/typeGuards.js';
34
- import { E } from '@endo/eventual-send';
35
33
 
36
34
  import { mustMatch } from '@agoric/store';
37
35
  import { makeCollectFeesInvitation } from '../collectFees.js';
38
36
  import { makeNatAmountShape } from '../contractSupport.js';
39
37
 
40
- const { Fail } = assert;
41
-
42
38
  /**
43
39
  * @file The Parity Stability Module supports efficiently minting/burning a
44
- * stable token at a specified fixed ratio to a reference stable token, which
45
- * thereby acts as an anchor to provide additional stability. For flexible
46
- * economic policies, the fee percentage for trading into and out of the stable
47
- * token are specified separately.
40
+ * stable token at a specified fixed ratio to a reference stable token, which
41
+ * thereby acts as an anchor to provide additional stability. For flexible
42
+ * economic policies, the fee percentage for trading into and out of the
43
+ * stable token are specified separately.
48
44
  */
49
45
 
50
46
  /**
51
- * @typedef {object} MetricsNotification
52
- * Metrics naming scheme is that nouns are present values and past-participles
53
- * are accumulative.
54
- *
55
- * @property {Amount<'nat'>} anchorPoolBalance amount of Anchor token
56
- * available to be swapped
57
- * @property {Amount<'nat'>} mintedPoolBalance amount of Minted token
58
- * outstanding (the amount minted minus the amount burned).
59
- * @property {Amount<'nat'>} feePoolBalance amount of Minted token
60
- * fees available to be collected
61
- *
62
- * @property {Amount<'nat'>} totalAnchorProvided running sum of Anchor
63
- * ever given by this contract
64
- * @property {Amount<'nat'>} totalMintedProvided running sum of Minted
65
- * ever given by this contract
47
+ * @typedef {object} MetricsNotification Metrics naming scheme is that nouns are
48
+ * present values and past-participles are accumulative.
49
+ * @property {Amount<'nat'>} anchorPoolBalance amount of Anchor token available
50
+ * to be swapped
51
+ * @property {Amount<'nat'>} mintedPoolBalance amount of Minted token
52
+ * outstanding (the amount minted minus the amount burned).
53
+ * @property {Amount<'nat'>} feePoolBalance amount of Minted token fees
54
+ * available to be collected
55
+ * @property {Amount<'nat'>} totalAnchorProvided running sum of Anchor ever
56
+ * given by this contract
57
+ * @property {Amount<'nat'>} totalMintedProvided running sum of Minted ever
58
+ * given by this contract
66
59
  */
67
60
 
68
- /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
61
+ /**
62
+ * @import {TypedPattern} from '@agoric/internal';
63
+ * @import {Baggage} from '@agoric/vat-data'
64
+ */
69
65
 
70
- export const customTermsShape = {
71
- anchorBrand: BrandShape,
72
- anchorPerMinted: RatioShape,
73
- electionManager: InstanceHandleShape,
74
- governedParams: {
75
- [CONTRACT_ELECTORATE]: {
76
- type: ParamTypes.INVITATION,
77
- value: AmountShape,
66
+ /** @type {ContractMeta} */
67
+ export const meta = {
68
+ upgradability: 'canUpgrade',
69
+ customTermsShape: {
70
+ anchorBrand: BrandShape,
71
+ anchorPerMinted: RatioShape,
72
+ electionManager: InstanceHandleShape,
73
+ governedParams: {
74
+ [CONTRACT_ELECTORATE]: {
75
+ type: ParamTypes.INVITATION,
76
+ value: AmountShape,
77
+ },
78
+ WantMintedFee: {
79
+ type: ParamTypes.RATIO,
80
+ value: RatioShape,
81
+ },
82
+ GiveMintedFee: {
83
+ type: ParamTypes.RATIO,
84
+ value: RatioShape,
85
+ },
86
+ MintLimit: { type: ParamTypes.AMOUNT, value: AmountShape },
78
87
  },
79
- WantMintedFee: {
80
- type: ParamTypes.RATIO,
81
- value: RatioShape,
88
+ },
89
+ privateArgsShape: M.splitRecord(
90
+ {
91
+ marshaller: M.remotable('Marshaller'),
92
+ storageNode: StorageNodeShape,
82
93
  },
83
- GiveMintedFee: {
84
- type: ParamTypes.RATIO,
85
- value: RatioShape,
94
+ {
95
+ // only necessary on first invocation, not subsequent
96
+ feeMintAccess: FeeMintAccessShape,
97
+ initialPoserInvitation: InvitationShape,
86
98
  },
87
- MintLimit: { type: ParamTypes.AMOUNT, value: AmountShape },
88
- },
99
+ ),
89
100
  };
90
- harden(customTermsShape);
91
-
92
- export const privateArgsShape = M.splitRecord(
93
- harden({
94
- marshaller: M.remotable('Marshaller'),
95
- storageNode: StorageNodeShape,
96
- }),
97
- harden({
98
- // only necessary on first invocation, not subsequent
99
- feeMintAccess: FeeMintAccessShape,
100
- initialPoserInvitation: InvitationShape,
101
- }),
102
- );
103
- harden(privateArgsShape);
101
+ harden(meta);
104
102
 
105
103
  /**
106
- * @param {ZCF<GovernanceTerms<{
107
- * GiveMintedFee: 'ratio',
108
- * WantMintedFee: 'ratio',
109
- * MintLimit: 'amount',
104
+ * @param {ZCF<
105
+ * GovernanceTerms<{
106
+ * GiveMintedFee: 'ratio';
107
+ * WantMintedFee: 'ratio';
108
+ * MintLimit: 'amount';
110
109
  * }> & {
111
- * anchorBrand: Brand<'nat'>,
112
- * anchorPerMinted: Ratio,
113
- * }>} zcf
114
- * @param {{feeMintAccess: FeeMintAccess, initialPoserInvitation: Invitation, storageNode: StorageNode, marshaller: Marshaller}} privateArgs
110
+ * anchorBrand: Brand<'nat'>;
111
+ * anchorPerMinted: Ratio;
112
+ * }
113
+ * >} zcf
114
+ * @param {{
115
+ * feeMintAccess: FeeMintAccess;
116
+ * initialPoserInvitation: Invitation;
117
+ * storageNode: StorageNode;
118
+ * marshaller: Marshaller;
119
+ * }} privateArgs
115
120
  * @param {Baggage} baggage
116
121
  */
117
- export const prepare = async (zcf, privateArgs, baggage) => {
122
+ export const start = async (zcf, privateArgs, baggage) => {
118
123
  const { anchorBrand, anchorPerMinted } = zcf.getTerms();
119
124
  console.log('PSM Starting', anchorBrand, anchorPerMinted);
120
125
 
@@ -171,9 +176,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
171
176
  E.when(E(privateArgs.storageNode).makeChildNode('metrics'), node =>
172
177
  makeRecorderKit(
173
178
  node,
174
- /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */ (
175
- M.any()
176
- ),
179
+ /** @type {TypedPattern<MetricsNotification>} */ (M.any()),
177
180
  ),
178
181
  ),
179
182
  });
@@ -231,9 +234,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
231
234
  updateMetrics();
232
235
  };
233
236
 
234
- /**
235
- * @param {Amount<'nat'>} toMint
236
- */
237
+ /** @param {Amount<'nat'>} toMint */
237
238
  const assertUnderLimit = toMint => {
238
239
  const mintedAfter = AmountMath.add(
239
240
  baggage.get('mintedPoolBalance'),
@@ -262,7 +263,8 @@ export const prepare = async (zcf, privateArgs, baggage) => {
262
263
  /**
263
264
  * @param {ZCFSeat} seat
264
265
  * @param {Amount<'nat'>} given
265
- * @param {Amount<'nat'>} [wanted] defaults to maximum anchor (given exchange rate minus fees)
266
+ * @param {Amount<'nat'>} [wanted] defaults to maximum anchor (given exchange
267
+ * rate minus fees)
266
268
  */
267
269
  const giveMinted = (seat, given, wanted = emptyAnchor) => {
268
270
  const fee = ceilMultiplyBy(given, params.getGiveMintedFee());
@@ -270,8 +272,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
270
272
  const maxAnchor = floorMultiplyBy(afterFee, anchorPerMinted);
271
273
  AmountMath.isGTE(maxAnchor, wanted) ||
272
274
  Fail`wanted ${wanted} is more than ${given} minus fees ${fee}`;
273
- atomicRearrange(
274
- zcf,
275
+ zcf.atomicRearrange(
275
276
  harden([
276
277
  [seat, stage, { In: afterFee }, { Minted: afterFee }],
277
278
  [seat, feePool, { In: fee }, { Minted: fee }],
@@ -302,8 +303,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
302
303
  Fail`wanted ${wanted} is more than ${given} minus fees ${fee}`;
303
304
  mintMinted(asStable);
304
305
  try {
305
- atomicRearrange(
306
- zcf,
306
+ zcf.atomicRearrange(
307
307
  harden([
308
308
  [seat, anchorPool, { In: given }, { Anchor: given }],
309
309
  [stage, seat, { Minted: afterFee }, { Out: afterFee }],
@@ -440,5 +440,6 @@ export const prepare = async (zcf, privateArgs, baggage) => {
440
440
  publicFacet,
441
441
  });
442
442
  };
443
+ harden(start);
443
444
 
444
- /** @typedef {Awaited<ReturnType<typeof prepare>>['publicFacet']} PsmPublicFacet */
445
+ /** @typedef {Awaited<ReturnType<typeof start>>['publicFacet']} PsmPublicFacet */
@@ -0,0 +1,2 @@
1
+ import type { PsmPublicFacet } from './psm.js';
2
+ //# sourceMappingURL=types-ambient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-ambient.d.ts","sourceRoot":"","sources":["types-ambient.js"],"names":[],"mappings":"oCAEkC,UAAU"}
@@ -0,0 +1,3 @@
1
+ // @jessie-check
2
+
3
+ /** @import {PsmPublicFacet} from './psm.js' */
@@ -0,0 +1,47 @@
1
+ /** @type {ContractMeta<typeof start>} */
2
+ export const meta: ContractMeta<typeof start>;
3
+ export function start(zcf: ZCF<GovernanceTerms<{}> & {
4
+ governedApis: ["burnFeesToReduceShortfall"];
5
+ }>, privateArgs: {
6
+ feeMintAccess: FeeMintAccess;
7
+ initialPoserInvitation: Invitation;
8
+ marshaller: ERef<Marshaller>;
9
+ storageNode: ERef<StorageNode>;
10
+ }, baggage: Baggage): Promise<{
11
+ /** @type {GovernedCreatorFacet<typeof assetReserveKit.machine>} */
12
+ creatorFacet: GovernedCreatorFacet<import("@endo/exo").Guarded<{
13
+ addIssuer(issuer: Issuer, keyword: string): Promise<void>;
14
+ getAllocations(): Allocation;
15
+ makeShortfallReportingInvitation(): Promise<Invitation<import("@endo/exo").Guarded<{
16
+ increaseLiquidationShortfall(shortfall: Amount<"nat">): void;
17
+ reduceLiquidationShortfall(reduction: Amount<"nat">): void;
18
+ }>, undefined>>;
19
+ }>>;
20
+ /** @type {GovernedPublicFacet<typeof assetReserveKit.public>} */
21
+ publicFacet: GovernedPublicFacet<import("@endo/exo").Guarded<{
22
+ makeAddCollateralInvitation(): Promise<Invitation<string, never>>;
23
+ getPublicTopics(): {
24
+ metrics: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./assetReserveKit.js").MetricsNotification>;
25
+ };
26
+ }>>;
27
+ }>;
28
+ export type ShortfallReportingFacet = {
29
+ increaseLiquidationShortfall: (increase: Amount) => void;
30
+ reduceLiquidationShortfall: (reduction: Amount) => void;
31
+ };
32
+ export type ShortfallReporter = {
33
+ increaseLiquidationShortfall: (shortfall: Amount) => void;
34
+ reduceLiquidationShortfall: (shortfall: Amount) => void;
35
+ };
36
+ export type AssetReserveLimitedCreatorFacet = {
37
+ addIssuer: (issuer: Issuer, kwd: string) => void;
38
+ getAllocations: () => Allocation;
39
+ makeShortfallReportingInvitation: () => Promise<Invitation<ShortfallReporter>>;
40
+ };
41
+ export type AssetReservePublicFacet = Awaited<ReturnType<typeof start>>["publicFacet"];
42
+ /**
43
+ * the creator facet for the governor
44
+ */
45
+ export type AssetReserveCreatorFacet = Awaited<ReturnType<typeof start>>["creatorFacet"];
46
+ import type { Baggage } from '@agoric/vat-data';
47
+ //# sourceMappingURL=assetReserve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assetReserve.d.ts","sourceRoot":"","sources":["assetReserve.js"],"names":[],"mappings":"AAYA,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAGnC;AAgCK,2BAbI,GAAG,CACT,eAAe,CAAC,EAAE,CAAC,GAAG;IACpB,YAAY,EAAE,CAAC,2BAA2B,CAAC,CAAC;CAC7C,CACF,eACO;IACN,aAAa,EAAE,aAAa,CAAC;IAC7B,sBAAsB,EAAE,UAAU,CAAC;IACnC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7B,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;CAChC,WACO,OAAO;IA6Dd,mEAAmE;kBAAxD,oBAAoB;;;;;;;OAAgC;IAE/D,iEAAiE;iBAAtD,mBAAmB;;;;;OAA+B;GAKhE;sCA9FY;IACR,4BAA4B,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,0BAA0B,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACzD;;kCAgGU,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI;gCAC3B,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI;;;eAK3B,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI;oBACrC,MAAM,UAAU;sCAChB,MAAM,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;;sCAG5C,OAAO,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC;;;;uCAEjD,OAAO,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC;6BA1GnC,kBAAkB"}
@@ -10,36 +10,42 @@ import { prepareAssetReserveKit } from './assetReserveKit.js';
10
10
 
11
11
  const trace = makeTracer('AR', true);
12
12
 
13
+ /** @type {ContractMeta<typeof start>} */
14
+ export const meta = {
15
+ upgradability: 'canUpgrade',
16
+ };
17
+ harden(meta);
18
+
13
19
  /**
14
20
  * @typedef {{
15
- * increaseLiquidationShortfall: (increase: Amount) => void
16
- * reduceLiquidationShortfall: (reduction: Amount) => void
21
+ * increaseLiquidationShortfall: (increase: Amount) => void;
22
+ * reduceLiquidationShortfall: (reduction: Amount) => void;
17
23
  * }} ShortfallReportingFacet
18
24
  */
19
25
 
20
- /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
26
+ /** @import {Baggage} from '@agoric/vat-data' */
21
27
 
22
28
  /**
23
- * Asset Reserve holds onto assets for the Inter Protocol, and can
24
- * dispense it for various purposes under governance control.
29
+ * Asset Reserve holds onto assets for the Inter Protocol, and can dispense it
30
+ * for various purposes under governance control.
25
31
  *
26
32
  * This contract has the ability to mint Fee tokens, granted through its private
27
33
  * arguments.
28
34
  *
29
- * @param {ZCF<GovernanceTerms<{}> &
30
- * {
31
- * governedApis: ['burnFeesToReduceShortfall'],
32
- * }
35
+ * @param {ZCF<
36
+ * GovernanceTerms<{}> & {
37
+ * governedApis: ['burnFeesToReduceShortfall'];
38
+ * }
33
39
  * >} zcf
34
40
  * @param {{
35
- * feeMintAccess: FeeMintAccess,
36
- * initialPoserInvitation: Invitation,
37
- * marshaller: ERef<Marshaller>,
38
- * storageNode: ERef<StorageNode>,
41
+ * feeMintAccess: FeeMintAccess;
42
+ * initialPoserInvitation: Invitation;
43
+ * marshaller: ERef<Marshaller>;
44
+ * storageNode: ERef<StorageNode>;
39
45
  * }} privateArgs
40
46
  * @param {Baggage} baggage
41
47
  */
42
- export const prepare = async (zcf, privateArgs, baggage) => {
48
+ export const start = async (zcf, privateArgs, baggage) => {
43
49
  trace('prepare', Object.keys(privateArgs), [...baggage.keys()]);
44
50
  // This contract mixes two styles of access to durable state. durableStores
45
51
  // are declared at the top level and referenced lexically. local state is
@@ -66,11 +72,11 @@ export const prepare = async (zcf, privateArgs, baggage) => {
66
72
  };
67
73
  trace('awaiting takeFeeMint');
68
74
  const feeMint = await takeFeeMint();
75
+ const storageNode = await privateArgs.storageNode;
69
76
  const makeAssetReserveKit = await prepareAssetReserveKit(baggage, {
70
77
  feeMint,
71
78
  makeRecorderKit,
72
- // eslint-disable-next-line @jessie.js/no-nested-await -- spurious
73
- storageNode: await privateArgs.storageNode,
79
+ storageNode,
74
80
  zcf,
75
81
  });
76
82
 
@@ -106,7 +112,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
106
112
  publicFacet: /** @type {any} */ (assetReserveKit.public),
107
113
  };
108
114
  };
109
- harden(prepare);
115
+ harden(start);
110
116
 
111
117
  /**
112
118
  * @typedef {object} ShortfallReporter
@@ -121,5 +127,8 @@ harden(prepare);
121
127
  * @property {() => Promise<Invitation<ShortfallReporter>>} makeShortfallReportingInvitation
122
128
  */
123
129
 
124
- /** @typedef {Awaited<ReturnType<typeof prepare>>['publicFacet']} AssetReservePublicFacet */
125
- /** @typedef {Awaited<ReturnType<typeof prepare>>['creatorFacet']} AssetReserveCreatorFacet the creator facet for the governor */
130
+ /** @typedef {Awaited<ReturnType<typeof start>>['publicFacet']} AssetReservePublicFacet */
131
+ /**
132
+ * @typedef {Awaited<ReturnType<typeof start>>['creatorFacet']} AssetReserveCreatorFacet
133
+ * the creator facet for the governor
134
+ */
@@ -0,0 +1,74 @@
1
+ export function prepareAssetReserveKit(baggage: import("@agoric/vat-data").Baggage, { feeMint, makeRecorderKit, storageNode, zcf }: {
2
+ feeMint: ZCFMint<"nat">;
3
+ makeRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").MakeRecorderKit;
4
+ storageNode: StorageNode;
5
+ zcf: ZCF;
6
+ }): Promise<() => Promise<import("@endo/exo").GuardedKit<{
7
+ helper: {
8
+ /** @param {Brand} brand */
9
+ getKeywordForBrand(brand: Brand): string;
10
+ /**
11
+ * @param {Brand} brand
12
+ * @param {Keyword} keyword
13
+ */
14
+ saveBrandKeyword(brand: Brand, keyword: Keyword): void;
15
+ writeMetrics(): void;
16
+ };
17
+ governedApis: {
18
+ /**
19
+ * @param {Amount<'nat'>} reduction
20
+ * @returns {void}
21
+ */
22
+ burnFeesToReduceShortfall(reduction: Amount<"nat">): void;
23
+ };
24
+ machine: {
25
+ /**
26
+ * @param {Issuer} issuer
27
+ * @param {string} keyword
28
+ */
29
+ addIssuer(issuer: Issuer, keyword: string): Promise<void>;
30
+ /** XXX redundant with getPublicTopics metrics `allocation` */
31
+ getAllocations(): Allocation;
32
+ makeShortfallReportingInvitation(): Promise<Invitation<import("@endo/exo").Guarded<{
33
+ /** @param {Amount<'nat'>} shortfall */
34
+ increaseLiquidationShortfall(shortfall: Amount<"nat">): void;
35
+ /** @param {Amount<'nat'>} reduction */
36
+ reduceLiquidationShortfall(reduction: Amount<"nat">): void;
37
+ }>, undefined>>;
38
+ };
39
+ /**
40
+ * XXX missing governance public methods
41
+ * https://github.com/Agoric/agoric-sdk/issues/5200
42
+ */
43
+ public: {
44
+ /** Anyone can deposit any assets to the reserve */
45
+ makeAddCollateralInvitation(): Promise<Invitation<string, never>>;
46
+ getPublicTopics(): {
47
+ metrics: import("@agoric/zoe/src/contractSupport").PublicTopic<MetricsNotification>;
48
+ };
49
+ };
50
+ shortfallReportingFacet: {
51
+ /** @param {Amount<'nat'>} shortfall */
52
+ increaseLiquidationShortfall(shortfall: Amount<"nat">): void;
53
+ /** @param {Amount<'nat'>} reduction */
54
+ reduceLiquidationShortfall(reduction: Amount<"nat">): void;
55
+ };
56
+ }>>>;
57
+ export type MetricsNotification = {
58
+ allocations: AmountKeywordRecord;
59
+ /**
60
+ * shortfall from liquidation that
61
+ * has not yet been compensated.
62
+ */
63
+ shortfallBalance: Amount<"nat">;
64
+ /**
65
+ * total Fee tokens minted to date
66
+ */
67
+ totalFeeMinted: Amount<"nat">;
68
+ /**
69
+ * total Fee tokens burned to date
70
+ */
71
+ totalFeeBurned: Amount<"nat">;
72
+ };
73
+ export type AssetReserveKit = ReturnType<Awaited<ReturnType<typeof prepareAssetReserveKit>>>;
74
+ //# sourceMappingURL=assetReserveKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assetReserveKit.d.ts","sourceRoot":"","sources":["assetReserveKit.js"],"names":[],"mappings":"AAqCO,gDARI,OAAO,kBAAkB,EAAE,OAAO,kDAClC;IACN,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACxB,eAAe,EAAE,OAAO,6CAA6C,EAAE,eAAe,CAAC;IACvF,WAAW,EAAE,WAAW,CAAC;IACzB,GAAG,EAAE,GAAG,CAAC;CACV;;QAoEI,2BAA2B;kCAAf,KAAK;QAUjB;;;WAGG;gCAFQ,KAAK,WACL,OAAO;;;;QAqBlB;;;WAGG;6CAFQ,MAAM,CAAC,KAAK,CAAC,GACX,IAAI;;;QA6BjB;;;WAGG;0BAFQ,MAAM,WACN,MAAM;QAmBjB,8DAA8D;;;YA2D9D,uCAAuC;oDAA3B,MAAM,CAAC,KAAK,CAAC;YAWzB,uCAAuC;kDAA3B,MAAM,CAAC,KAAK,CAAC;;;IArD3B;;;OAGG;;QAED,mDAAmD;;;;;;;QAqCnD,uCAAuC;gDAA3B,MAAM,CAAC,KAAK,CAAC;QAWzB,uCAAuC;8CAA3B,MAAM,CAAC,KAAK,CAAC;;KA8BhC;;iBA3Qa,mBAAmB;;;;;sBACnB,MAAM,CAAC,KAAK,CAAC;;;;oBAEb,MAAM,CAAC,KAAK,CAAC;;;;oBACb,MAAM,CAAC,KAAK,CAAC;;8BAyQb,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Fail } from '@agoric/assert';
1
+ import { Fail, q } from '@endo/errors';
2
2
  import { AmountMath, AmountShape, IssuerShape } from '@agoric/ertp';
3
3
  import { makeTracer } from '@agoric/internal';
4
4
  import { M, makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
@@ -9,15 +9,16 @@ import {
9
9
  } from '@agoric/zoe/src/contractSupport/topics.js';
10
10
  import { AmountKeywordRecordShape } from '@agoric/zoe/src/typeGuards.js';
11
11
  import { E } from '@endo/eventual-send';
12
- import { UnguardedHelperI } from '../typeGuards.js';
13
-
14
- const { quote: q } = assert;
12
+ import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js';
15
13
 
16
14
  const trace = makeTracer('ReserveKit', true);
17
15
 
16
+ /**
17
+ * @import {TypedPattern} from '@agoric/internal';
18
+ */
19
+
18
20
  /**
19
21
  * @typedef {object} MetricsNotification
20
- *
21
22
  * @property {AmountKeywordRecord} allocations
22
23
  * @property {Amount<'nat'>} shortfallBalance shortfall from liquidation that
23
24
  * has not yet been compensated.
@@ -28,10 +29,11 @@ const trace = makeTracer('ReserveKit', true);
28
29
  /**
29
30
  * @param {import('@agoric/vat-data').Baggage} baggage
30
31
  * @param {{
31
- * feeMint: ZCFMint<'nat'>,
32
- * makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit,
33
- * storageNode: StorageNode,
34
- * zcf: ZCF}} powers
32
+ * feeMint: ZCFMint<'nat'>;
33
+ * makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit;
34
+ * storageNode: StorageNode;
35
+ * zcf: ZCF;
36
+ * }} powers
35
37
  */
36
38
  export const prepareAssetReserveKit = async (
37
39
  baggage,
@@ -63,10 +65,7 @@ export const prepareAssetReserveKit = async (
63
65
  reduceLiquidationShortfall: M.call(AmountShape).returns(),
64
66
  }),
65
67
  },
66
- /**
67
- *
68
- * @param {StorageNode} metricsNode
69
- */
68
+ /** @param {StorageNode} metricsNode */
70
69
  metricsNode => {
71
70
  /**
72
71
  * Used to look up the unique keyword for each brand, including Fee brand.
@@ -77,7 +76,8 @@ export const prepareAssetReserveKit = async (
77
76
  durable: true,
78
77
  });
79
78
  /**
80
- * Used to look up the brands for keywords, excluding Fee because it's a special case.
79
+ * Used to look up the brands for keywords, excluding Fee because it's a
80
+ * special case.
81
81
  *
82
82
  * @type {MapStore<Keyword, Brand>}
83
83
  */
@@ -92,9 +92,7 @@ export const prepareAssetReserveKit = async (
92
92
  keywordForBrand,
93
93
  metricsKit: makeRecorderKit(
94
94
  metricsNode,
95
- /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */ (
96
- M.any()
97
- ),
95
+ /** @type {TypedPattern<MetricsNotification>} */ (M.any()),
98
96
  ),
99
97
  totalFeeMinted: emptyAmount,
100
98
  totalFeeBurned: emptyAmount,
@@ -137,7 +135,6 @@ export const prepareAssetReserveKit = async (
137
135
  },
138
136
  governedApis: {
139
137
  /**
140
- *
141
138
  * @param {Amount<'nat'>} reduction
142
139
  * @returns {void}
143
140
  */
@@ -146,8 +143,10 @@ export const prepareAssetReserveKit = async (
146
143
  trace('burnFeesToReduceShortfall', reduction);
147
144
  reduction = AmountMath.coerce(feeKit.brand, reduction);
148
145
  const feeKeyword = state.keywordForBrand.get(feeKit.brand);
149
- const feeBalance =
150
- state.collateralSeat.getAmountAllocated(feeKeyword);
146
+ const feeBalance = state.collateralSeat.getAmountAllocated(
147
+ feeKeyword,
148
+ feeKit.brand,
149
+ );
151
150
  const amountToBurn = AmountMath.min(reduction, feeBalance);
152
151
  if (AmountMath.isEmpty(amountToBurn)) {
153
152
  return;
@@ -205,12 +204,11 @@ export const prepareAssetReserveKit = async (
205
204
  },
206
205
  },
207
206
  /**
208
- * XXX missing governance public methods https://github.com/Agoric/agoric-sdk/issues/5200
207
+ * XXX missing governance public methods
208
+ * https://github.com/Agoric/agoric-sdk/issues/5200
209
209
  */
210
210
  public: {
211
- /**
212
- * Anyone can deposit any assets to the reserve
213
- */
211
+ /** Anyone can deposit any assets to the reserve */
214
212
  makeAddCollateralInvitation() {
215
213
  /** @type {OfferHandler<Promise<string>>} */
216
214
  const handler = async seat => {
@@ -247,9 +245,7 @@ export const prepareAssetReserveKit = async (
247
245
  },
248
246
  },
249
247
  shortfallReportingFacet: {
250
- /**
251
- * @param {Amount<"nat">} shortfall
252
- */
248
+ /** @param {Amount<'nat'>} shortfall */
253
249
  increaseLiquidationShortfall(shortfall) {
254
250
  const { facets, state } = this;
255
251
  state.shortfallBalance = AmountMath.add(
@@ -260,9 +256,7 @@ export const prepareAssetReserveKit = async (
260
256
  },
261
257
 
262
258
  // currently exposed for testing. Maybe it only gets called internally?
263
- /**
264
- * @param {Amount<"nat">} reduction
265
- */
259
+ /** @param {Amount<'nat'>} reduction */
266
260
  reduceLiquidationShortfall(reduction) {
267
261
  const { state } = this;
268
262
  if (AmountMath.isGTE(reduction, state.shortfallBalance)) {
@@ -0,0 +1,10 @@
1
+ export function makeReserveTerms(poserInvitationAmount: any, timer: any): {
2
+ timer: any;
3
+ governedParams: {
4
+ Electorate: {
5
+ type: "invitation";
6
+ value: any;
7
+ };
8
+ };
9
+ };
10
+ //# sourceMappingURL=params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["params.js"],"names":[],"mappings":"AAIA;;;;;;;;EAQE"}
@@ -0,0 +1,3 @@
1
+ export type TokenKeyword = "IST" | "BLD";
2
+ export { Stable, Stake } from "@agoric/internal/src/tokens.js";
3
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["tokens.js"],"names":[],"mappings":"2BAEc,KAAK,GAAG,KAAK"}
package/src/tokens.js ADDED
@@ -0,0 +1,5 @@
1
+ // @ts-check
2
+
3
+ /** @typedef {'IST' | 'BLD'} TokenKeyword */
4
+
5
+ export { Stable, Stake } from '@agoric/internal/src/tokens.js';
@@ -0,0 +1,2 @@
1
+ export function paymentFromZCFMint(zcf: ZCF, zcfMint: ZCFMint, amount: Amount): Promise<globalThis.Payment<any>>;
2
+ //# sourceMappingURL=burn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"burn.d.ts","sourceRoot":"","sources":["burn.js"],"names":[],"mappings":"AAWO,wCAJI,GAAG,WACH,OAAO,UACP,MAAM,oCAOhB"}
@@ -1,6 +1,6 @@
1
1
  // @jessie-check
2
2
 
3
- import '@agoric/zoe/exported.js';
3
+ /// <reference types="@agoric/zoe/exported" />
4
4
 
5
5
  import { E } from '@endo/eventual-send';
6
6