@agoric/inter-protocol 0.16.2-upgrade-14-dev-0169c7e.0 → 0.16.2-upgrade-16-dev-8879538.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 (175) hide show
  1. package/package.json +41 -34
  2. package/scripts/build-bundles.js +5 -21
  3. package/src/auction/auctionBook.d.ts +84 -0
  4. package/src/auction/auctionBook.d.ts.map +1 -0
  5. package/src/auction/auctionBook.js +135 -103
  6. package/src/auction/auctioneer.d.ts +83 -0
  7. package/src/auction/auctioneer.d.ts.map +1 -0
  8. package/src/auction/auctioneer.js +63 -49
  9. package/src/auction/offerBook.d.ts +45 -0
  10. package/src/auction/offerBook.d.ts.map +1 -0
  11. package/src/auction/offerBook.js +13 -12
  12. package/src/auction/params.d.ts +149 -0
  13. package/src/auction/params.d.ts.map +1 -0
  14. package/src/auction/params.js +10 -9
  15. package/src/auction/scheduleMath.d.ts +5 -0
  16. package/src/auction/scheduleMath.d.ts.map +1 -0
  17. package/src/auction/scheduleMath.js +17 -15
  18. package/src/auction/scheduler.d.ts +49 -0
  19. package/src/auction/scheduler.d.ts.map +1 -0
  20. package/src/auction/scheduler.js +51 -43
  21. package/src/auction/sortedOffers.d.ts +8 -0
  22. package/src/auction/sortedOffers.d.ts.map +1 -0
  23. package/src/auction/sortedOffers.js +9 -7
  24. package/src/auction/util.d.ts +32 -0
  25. package/src/auction/util.d.ts.map +1 -0
  26. package/src/auction/util.js +6 -4
  27. package/src/clientSupport.d.ts +167 -0
  28. package/src/clientSupport.d.ts.map +1 -0
  29. package/src/clientSupport.js +97 -40
  30. package/src/collectFees.d.ts +2 -0
  31. package/src/collectFees.d.ts.map +1 -0
  32. package/src/contractSupport.d.ts +28 -0
  33. package/src/contractSupport.d.ts.map +1 -0
  34. package/src/contractSupport.js +14 -12
  35. package/src/econCommitteeCharter.d.ts +39 -0
  36. package/src/econCommitteeCharter.d.ts.map +1 -0
  37. package/src/econCommitteeCharter.js +21 -20
  38. package/src/feeDistributor.d.ts +224 -0
  39. package/src/feeDistributor.d.ts.map +1 -0
  40. package/src/feeDistributor.js +37 -33
  41. package/src/index.d.ts +2 -0
  42. package/src/index.d.ts.map +1 -0
  43. package/src/index.js +1 -0
  44. package/src/interest-math.d.ts +3 -0
  45. package/src/interest-math.d.ts.map +1 -0
  46. package/src/interest.d.ts +28 -0
  47. package/src/interest.d.ts.map +1 -0
  48. package/src/interest.js +21 -16
  49. package/src/price/README.md +13 -0
  50. package/src/price/fluxAggregatorContract.d.ts +70 -0
  51. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  52. package/src/price/fluxAggregatorContract.js +62 -55
  53. package/src/price/fluxAggregatorKit.d.ts +103 -0
  54. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  55. package/src/price/fluxAggregatorKit.js +50 -37
  56. package/src/price/priceOracleKit.d.ts +38 -0
  57. package/src/price/priceOracleKit.d.ts.map +1 -0
  58. package/src/price/priceOracleKit.js +11 -13
  59. package/src/price/roundsManager.d.ts +238 -0
  60. package/src/price/roundsManager.d.ts.map +1 -0
  61. package/src/price/roundsManager.js +77 -82
  62. package/src/proposals/README.md +2 -3
  63. package/src/proposals/add-auction.d.ts +69 -0
  64. package/src/proposals/add-auction.d.ts.map +1 -0
  65. package/src/proposals/add-auction.js +181 -0
  66. package/src/proposals/addAssetToVault.d.ts +160 -0
  67. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  68. package/src/proposals/addAssetToVault.js +172 -38
  69. package/src/proposals/committee-proposal.d.ts +113 -0
  70. package/src/proposals/committee-proposal.d.ts.map +1 -0
  71. package/src/proposals/committee-proposal.js +25 -31
  72. package/src/proposals/core-proposal.d.ts +149 -0
  73. package/src/proposals/core-proposal.d.ts.map +1 -0
  74. package/src/proposals/core-proposal.js +9 -11
  75. package/src/proposals/econ-behaviors.d.ts +1169 -0
  76. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  77. package/src/proposals/econ-behaviors.js +66 -45
  78. package/src/proposals/price-feed-proposal.d.ts +84 -0
  79. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  80. package/src/proposals/price-feed-proposal.js +108 -51
  81. package/src/proposals/startEconCommittee.d.ts +34 -0
  82. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  83. package/src/proposals/startEconCommittee.js +2 -2
  84. package/src/proposals/startPSM.d.ts +59 -0
  85. package/src/proposals/startPSM.d.ts.map +1 -0
  86. package/src/proposals/startPSM.js +38 -27
  87. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
  88. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
  89. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  90. package/src/proposals/upgrade-vaults.d.ts +35 -0
  91. package/src/proposals/upgrade-vaults.d.ts.map +1 -0
  92. package/src/proposals/upgrade-vaults.js +202 -0
  93. package/src/proposals/utils.d.ts +17 -0
  94. package/src/proposals/utils.d.ts.map +1 -0
  95. package/src/proposals/utils.js +34 -7
  96. package/src/provisionPool.d.ts +167 -0
  97. package/src/provisionPool.d.ts.map +1 -0
  98. package/src/provisionPool.js +122 -0
  99. package/src/provisionPoolKit.d.ts +770 -0
  100. package/src/provisionPoolKit.d.ts.map +1 -0
  101. package/src/provisionPoolKit.js +463 -0
  102. package/src/psm/psm.d.ts +122 -0
  103. package/src/psm/psm.d.ts.map +1 -0
  104. package/src/psm/psm.js +73 -69
  105. package/src/psm/types-ambient.d.ts +2 -0
  106. package/src/psm/types-ambient.d.ts.map +1 -0
  107. package/src/psm/types-ambient.js +3 -0
  108. package/src/reserve/assetReserve.d.ts +47 -0
  109. package/src/reserve/assetReserve.d.ts.map +1 -0
  110. package/src/reserve/assetReserve.js +28 -19
  111. package/src/reserve/assetReserveKit.d.ts +74 -0
  112. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  113. package/src/reserve/assetReserveKit.js +18 -24
  114. package/src/reserve/params.d.ts +10 -0
  115. package/src/reserve/params.d.ts.map +1 -0
  116. package/src/tokens.d.ts +3 -0
  117. package/src/tokens.d.ts.map +1 -0
  118. package/src/tokens.js +5 -0
  119. package/src/vaultFactory/burn.d.ts +2 -0
  120. package/src/vaultFactory/burn.d.ts.map +1 -0
  121. package/src/vaultFactory/burn.js +1 -1
  122. package/src/vaultFactory/liquidation.d.ts +163 -0
  123. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  124. package/src/vaultFactory/liquidation.js +36 -22
  125. package/src/vaultFactory/math.d.ts +11 -0
  126. package/src/vaultFactory/math.d.ts.map +1 -0
  127. package/src/vaultFactory/math.js +10 -9
  128. package/src/vaultFactory/orderedVaultStore.d.ts +360 -0
  129. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  130. package/src/vaultFactory/orderedVaultStore.js +8 -11
  131. package/src/vaultFactory/params.d.ts +145 -0
  132. package/src/vaultFactory/params.d.ts.map +1 -0
  133. package/src/vaultFactory/params.js +52 -24
  134. package/src/vaultFactory/prioritizedVaults.d.ts +992 -0
  135. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  136. package/src/vaultFactory/prioritizedVaults.js +4 -4
  137. package/src/vaultFactory/proceeds.d.ts +35 -0
  138. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  139. package/src/vaultFactory/proceeds.js +26 -18
  140. package/src/vaultFactory/storeUtils.d.ts +25 -0
  141. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  142. package/src/vaultFactory/storeUtils.js +10 -12
  143. package/src/vaultFactory/types-ambient.d.ts +234 -0
  144. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  145. package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
  146. package/src/vaultFactory/vault.d.ts +402 -0
  147. package/src/vaultFactory/vault.d.ts.map +1 -0
  148. package/src/vaultFactory/vault.js +99 -93
  149. package/src/vaultFactory/vaultDirector.d.ts +388 -0
  150. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  151. package/src/vaultFactory/vaultDirector.js +61 -50
  152. package/src/vaultFactory/vaultFactory.d.ts +277 -0
  153. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  154. package/src/vaultFactory/vaultFactory.js +49 -32
  155. package/src/vaultFactory/vaultHolder.d.ts +270 -0
  156. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  157. package/src/vaultFactory/vaultHolder.js +10 -14
  158. package/src/vaultFactory/vaultKit.d.ts +102 -0
  159. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  160. package/src/vaultFactory/vaultKit.js +5 -4
  161. package/src/vaultFactory/vaultManager.d.ts +819 -0
  162. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  163. package/src/vaultFactory/vaultManager.js +248 -151
  164. package/CHANGELOG.md +0 -1066
  165. package/exported.js +0 -2
  166. package/scripts/add-collateral-core.js +0 -113
  167. package/scripts/deploy-contracts.js +0 -100
  168. package/scripts/init-core.js +0 -200
  169. package/scripts/invite-committee-core.js +0 -42
  170. package/scripts/manual-price-feed.js +0 -117
  171. package/scripts/price-feed-core.js +0 -104
  172. package/scripts/start-local-chain.sh +0 -84
  173. package/src/psm/types.js +0 -3
  174. package/src/typeGuards.js +0 -13
  175. package/src/vaultFactory/type-imports.js +0 -4
package/src/psm/psm.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // @jessie-check
2
-
3
- import '@agoric/governance/exported.js';
4
- import '@agoric/zoe/exported.js';
5
- import '@agoric/zoe/src/contracts/exported.js';
2
+ /// <reference types="@agoric/governance/exported" />
3
+ /// <reference types="@agoric/zoe/exported" />
6
4
 
7
5
  import { AmountMath, AmountShape, BrandShape, RatioShape } from '@agoric/ertp';
8
6
  import {
@@ -41,80 +39,86 @@ const { Fail } = assert;
41
39
 
42
40
  /**
43
41
  * @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.
42
+ * stable token at a specified fixed ratio to a reference stable token, which
43
+ * thereby acts as an anchor to provide additional stability. For flexible
44
+ * economic policies, the fee percentage for trading into and out of the
45
+ * stable token are specified separately.
48
46
  */
49
47
 
50
48
  /**
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
49
+ * @typedef {object} MetricsNotification Metrics naming scheme is that nouns are
50
+ * present values and past-participles are accumulative.
51
+ * @property {Amount<'nat'>} anchorPoolBalance amount of Anchor token available
52
+ * to be swapped
53
+ * @property {Amount<'nat'>} mintedPoolBalance amount of Minted token
54
+ * outstanding (the amount minted minus the amount burned).
55
+ * @property {Amount<'nat'>} feePoolBalance amount of Minted token fees
56
+ * available to be collected
57
+ * @property {Amount<'nat'>} totalAnchorProvided running sum of Anchor ever
58
+ * given by this contract
59
+ * @property {Amount<'nat'>} totalMintedProvided running sum of Minted ever
60
+ * given by this contract
66
61
  */
67
62
 
68
- /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
69
-
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,
63
+ /** @import {Baggage} from '@agoric/vat-data' */
64
+
65
+ /** @type {ContractMeta} */
66
+ export const meta = {
67
+ upgradability: 'canUpgrade',
68
+ customTermsShape: {
69
+ anchorBrand: BrandShape,
70
+ anchorPerMinted: RatioShape,
71
+ electionManager: InstanceHandleShape,
72
+ governedParams: {
73
+ [CONTRACT_ELECTORATE]: {
74
+ type: ParamTypes.INVITATION,
75
+ value: AmountShape,
76
+ },
77
+ WantMintedFee: {
78
+ type: ParamTypes.RATIO,
79
+ value: RatioShape,
80
+ },
81
+ GiveMintedFee: {
82
+ type: ParamTypes.RATIO,
83
+ value: RatioShape,
84
+ },
85
+ MintLimit: { type: ParamTypes.AMOUNT, value: AmountShape },
78
86
  },
79
- WantMintedFee: {
80
- type: ParamTypes.RATIO,
81
- value: RatioShape,
87
+ },
88
+ privateArgsShape: M.splitRecord(
89
+ {
90
+ marshaller: M.remotable('Marshaller'),
91
+ storageNode: StorageNodeShape,
82
92
  },
83
- GiveMintedFee: {
84
- type: ParamTypes.RATIO,
85
- value: RatioShape,
93
+ {
94
+ // only necessary on first invocation, not subsequent
95
+ feeMintAccess: FeeMintAccessShape,
96
+ initialPoserInvitation: InvitationShape,
86
97
  },
87
- MintLimit: { type: ParamTypes.AMOUNT, value: AmountShape },
88
- },
98
+ ),
89
99
  };
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);
100
+ harden(meta);
104
101
 
105
102
  /**
106
- * @param {ZCF<GovernanceTerms<{
107
- * GiveMintedFee: 'ratio',
108
- * WantMintedFee: 'ratio',
109
- * MintLimit: 'amount',
103
+ * @param {ZCF<
104
+ * GovernanceTerms<{
105
+ * GiveMintedFee: 'ratio';
106
+ * WantMintedFee: 'ratio';
107
+ * MintLimit: 'amount';
110
108
  * }> & {
111
- * anchorBrand: Brand<'nat'>,
112
- * anchorPerMinted: Ratio,
113
- * }>} zcf
114
- * @param {{feeMintAccess: FeeMintAccess, initialPoserInvitation: Invitation, storageNode: StorageNode, marshaller: Marshaller}} privateArgs
109
+ * anchorBrand: Brand<'nat'>;
110
+ * anchorPerMinted: Ratio;
111
+ * }
112
+ * >} zcf
113
+ * @param {{
114
+ * feeMintAccess: FeeMintAccess;
115
+ * initialPoserInvitation: Invitation;
116
+ * storageNode: StorageNode;
117
+ * marshaller: Marshaller;
118
+ * }} privateArgs
115
119
  * @param {Baggage} baggage
116
120
  */
117
- export const prepare = async (zcf, privateArgs, baggage) => {
121
+ export const start = async (zcf, privateArgs, baggage) => {
118
122
  const { anchorBrand, anchorPerMinted } = zcf.getTerms();
119
123
  console.log('PSM Starting', anchorBrand, anchorPerMinted);
120
124
 
@@ -231,9 +235,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
231
235
  updateMetrics();
232
236
  };
233
237
 
234
- /**
235
- * @param {Amount<'nat'>} toMint
236
- */
238
+ /** @param {Amount<'nat'>} toMint */
237
239
  const assertUnderLimit = toMint => {
238
240
  const mintedAfter = AmountMath.add(
239
241
  baggage.get('mintedPoolBalance'),
@@ -262,7 +264,8 @@ export const prepare = async (zcf, privateArgs, baggage) => {
262
264
  /**
263
265
  * @param {ZCFSeat} seat
264
266
  * @param {Amount<'nat'>} given
265
- * @param {Amount<'nat'>} [wanted] defaults to maximum anchor (given exchange rate minus fees)
267
+ * @param {Amount<'nat'>} [wanted] defaults to maximum anchor (given exchange
268
+ * rate minus fees)
266
269
  */
267
270
  const giveMinted = (seat, given, wanted = emptyAnchor) => {
268
271
  const fee = ceilMultiplyBy(given, params.getGiveMintedFee());
@@ -440,5 +443,6 @@ export const prepare = async (zcf, privateArgs, baggage) => {
440
443
  publicFacet,
441
444
  });
442
445
  };
446
+ harden(start);
443
447
 
444
- /** @typedef {Awaited<ReturnType<typeof prepare>>['publicFacet']} PsmPublicFacet */
448
+ /** @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} */
2
+ export const meta: ContractMeta;
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: globalThis.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: globalThis.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,2BAA2B;AAC3B,mBADW,YAAY,CAGrB;AAgCK,2BAbI,GAAG,CACb,eAAmB,CAAC,EAAE,CAAC,GAAG;IAC1B,YAAkB,EAAE,CAAC,2BAA2B,CAAC,CAAC;CAC7C,CACF,eACO;IACV,aAAiB,EAAE,aAAa,CAAC;IACjC,sBAA0B,EAAE,UAAU,CAAC;IACvC,UAAc,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACjC,WAAe,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;CAChC;IA8DA,mEAAmE;;0BA4BmwD,MAAM;;;oDAAs5E,OAAO,KAAK,CAAC;kDAA8X,OAAO,KAAK,CAAC;;;IA1B1nJ,iEAAiE;;;;;;;GAKpE;sCA9FY;IACZ,4BAAgC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7D,0BAA8B,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} */
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/topics.js").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":"AAmCO,gDARI,OAAO,kBAAkB,EAAE,OAAO,kDAClC;IACV,OAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,eAAmB,EAAE,OAAO,6CAA6C,EAAE,eAAe,CAAC;IAC3F,WAAe,EAAE,WAAW,CAAC;IAC7B,GAAO,EAAE,GAAG,CAAC;CACV;;QAsEI,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;;iBA7Qa,mBAAmB;;;;;sBACnB,MAAM,CAAC,KAAK,CAAC;;;;oBAEb,MAAM,CAAC,KAAK,CAAC;;;;oBACb,MAAM,CAAC,KAAK,CAAC;;8BA2Qb,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC"}
@@ -9,7 +9,7 @@ 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';
12
+ import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js';
13
13
 
14
14
  const { quote: q } = assert;
15
15
 
@@ -17,7 +17,6 @@ const trace = makeTracer('ReserveKit', true);
17
17
 
18
18
  /**
19
19
  * @typedef {object} MetricsNotification
20
- *
21
20
  * @property {AmountKeywordRecord} allocations
22
21
  * @property {Amount<'nat'>} shortfallBalance shortfall from liquidation that
23
22
  * has not yet been compensated.
@@ -28,10 +27,11 @@ const trace = makeTracer('ReserveKit', true);
28
27
  /**
29
28
  * @param {import('@agoric/vat-data').Baggage} baggage
30
29
  * @param {{
31
- * feeMint: ZCFMint<'nat'>,
32
- * makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit,
33
- * storageNode: StorageNode,
34
- * zcf: ZCF}} powers
30
+ * feeMint: ZCFMint<'nat'>;
31
+ * makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit;
32
+ * storageNode: StorageNode;
33
+ * zcf: ZCF;
34
+ * }} powers
35
35
  */
36
36
  export const prepareAssetReserveKit = async (
37
37
  baggage,
@@ -63,10 +63,7 @@ export const prepareAssetReserveKit = async (
63
63
  reduceLiquidationShortfall: M.call(AmountShape).returns(),
64
64
  }),
65
65
  },
66
- /**
67
- *
68
- * @param {StorageNode} metricsNode
69
- */
66
+ /** @param {StorageNode} metricsNode */
70
67
  metricsNode => {
71
68
  /**
72
69
  * Used to look up the unique keyword for each brand, including Fee brand.
@@ -77,7 +74,8 @@ export const prepareAssetReserveKit = async (
77
74
  durable: true,
78
75
  });
79
76
  /**
80
- * Used to look up the brands for keywords, excluding Fee because it's a special case.
77
+ * Used to look up the brands for keywords, excluding Fee because it's a
78
+ * special case.
81
79
  *
82
80
  * @type {MapStore<Keyword, Brand>}
83
81
  */
@@ -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