@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-fbe72e7.0.fbe72e7

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 (166) hide show
  1. package/README.md +6 -6
  2. package/package.json +46 -39
  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 +182 -151
  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 +70 -0
  11. package/src/auction/auctioneer.d.ts.map +1 -0
  12. package/src/auction/auctioneer.js +72 -59
  13. package/src/auction/offerBook.d.ts +46 -0
  14. package/src/auction/offerBook.d.ts.map +1 -0
  15. package/src/auction/offerBook.js +17 -12
  16. package/src/auction/params.d.ts +145 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/params.js +11 -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 +31 -0
  29. package/src/auction/util.d.ts.map +1 -0
  30. package/src/auction/util.js +12 -6
  31. package/src/clientSupport.d.ts +168 -0
  32. package/src/clientSupport.d.ts.map +1 -0
  33. package/src/clientSupport.js +161 -98
  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 +43 -0
  40. package/src/econCommitteeCharter.d.ts.map +1 -0
  41. package/src/econCommitteeCharter.js +25 -20
  42. package/src/feeDistributor.d.ts +224 -0
  43. package/src/feeDistributor.d.ts.map +1 -0
  44. package/src/feeDistributor.js +41 -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 +4 -0
  49. package/src/interest-math.d.ts.map +1 -0
  50. package/src/interest-math.js +5 -1
  51. package/src/interest.d.ts +30 -0
  52. package/src/interest.d.ts.map +1 -0
  53. package/src/interest.js +25 -23
  54. package/src/price/README.md +14 -1
  55. package/src/price/fluxAggregatorContract.d.ts +71 -0
  56. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  57. package/src/price/fluxAggregatorContract.js +64 -55
  58. package/src/price/fluxAggregatorKit.d.ts +104 -0
  59. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  60. package/src/price/fluxAggregatorKit.js +55 -42
  61. package/src/price/priceOracleKit.d.ts +39 -0
  62. package/src/price/priceOracleKit.d.ts.map +1 -0
  63. package/src/price/priceOracleKit.js +17 -15
  64. package/src/price/roundsManager.d.ts +204 -0
  65. package/src/price/roundsManager.d.ts.map +1 -0
  66. package/src/price/roundsManager.js +132 -85
  67. package/src/proposals/README.md +2 -3
  68. package/src/proposals/add-auction.js +285 -0
  69. package/src/proposals/addAssetToVault.js +192 -40
  70. package/src/proposals/committee-proposal.js +25 -31
  71. package/src/proposals/core-proposal.js +9 -11
  72. package/src/proposals/deploy-price-feeds.js +341 -0
  73. package/src/proposals/econ-behaviors.js +84 -49
  74. package/src/proposals/price-feed-proposal.js +109 -51
  75. package/src/proposals/replace-fee-distributor.js +198 -0
  76. package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
  77. package/src/proposals/replaceElectorate.js +610 -0
  78. package/src/proposals/startEconCommittee.js +2 -2
  79. package/src/proposals/startPSM.js +44 -29
  80. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  81. package/src/proposals/upgrade-vaults.js +207 -0
  82. package/src/proposals/utils.d.ts +21 -0
  83. package/src/proposals/utils.d.ts.map +1 -0
  84. package/src/proposals/utils.js +66 -9
  85. package/src/proposals/withdraw-reserve-proposal.js +63 -0
  86. package/src/provisionPool.d.ts +69 -0
  87. package/src/provisionPool.d.ts.map +1 -0
  88. package/src/provisionPool.js +138 -0
  89. package/src/provisionPoolKit.d.ts +129 -0
  90. package/src/provisionPoolKit.d.ts.map +1 -0
  91. package/src/provisionPoolKit.js +608 -0
  92. package/src/psm/psm.d.ts +133 -0
  93. package/src/psm/psm.d.ts.map +1 -0
  94. package/src/psm/psm.js +85 -79
  95. package/src/psm/types-ambient.d.ts +2 -0
  96. package/src/psm/types-ambient.d.ts.map +1 -0
  97. package/src/psm/types-ambient.js +3 -0
  98. package/src/reserve/assetReserve.d.ts +58 -0
  99. package/src/reserve/assetReserve.d.ts.map +1 -0
  100. package/src/reserve/assetReserve.js +42 -34
  101. package/src/reserve/assetReserveKit.d.ts +103 -0
  102. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  103. package/src/reserve/assetReserveKit.js +134 -32
  104. package/src/reserve/params.d.ts +16 -0
  105. package/src/reserve/params.d.ts.map +1 -0
  106. package/src/reserve/params.js +8 -2
  107. package/src/tokens.d.ts +3 -0
  108. package/src/tokens.d.ts.map +1 -0
  109. package/src/tokens.js +5 -0
  110. package/src/vaultFactory/burn.d.ts +2 -0
  111. package/src/vaultFactory/burn.d.ts.map +1 -0
  112. package/src/vaultFactory/burn.js +1 -1
  113. package/src/vaultFactory/liquidation.d.ts +25 -0
  114. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  115. package/src/vaultFactory/liquidation.js +37 -24
  116. package/src/vaultFactory/math.d.ts +11 -0
  117. package/src/vaultFactory/math.d.ts.map +1 -0
  118. package/src/vaultFactory/math.js +11 -10
  119. package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
  120. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  121. package/src/vaultFactory/orderedVaultStore.js +9 -10
  122. package/src/vaultFactory/params.d.ts +143 -0
  123. package/src/vaultFactory/params.d.ts.map +1 -0
  124. package/src/vaultFactory/params.js +56 -25
  125. package/src/vaultFactory/prioritizedVaults.d.ts +280 -0
  126. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  127. package/src/vaultFactory/prioritizedVaults.js +7 -4
  128. package/src/vaultFactory/proceeds.d.ts +35 -0
  129. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  130. package/src/vaultFactory/proceeds.js +26 -18
  131. package/src/vaultFactory/storeUtils.d.ts +25 -0
  132. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  133. package/src/vaultFactory/storeUtils.js +10 -12
  134. package/src/vaultFactory/types-ambient.d.ts +137 -0
  135. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  136. package/src/vaultFactory/{types.js → types-ambient.js} +47 -44
  137. package/src/vaultFactory/vault.d.ts +344 -0
  138. package/src/vaultFactory/vault.d.ts.map +1 -0
  139. package/src/vaultFactory/vault.js +107 -100
  140. package/src/vaultFactory/vaultDirector.d.ts +347 -0
  141. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  142. package/src/vaultFactory/vaultDirector.js +94 -64
  143. package/src/vaultFactory/vaultFactory.d.ts +250 -0
  144. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  145. package/src/vaultFactory/vaultFactory.js +56 -33
  146. package/src/vaultFactory/vaultHolder.d.ts +170 -0
  147. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  148. package/src/vaultFactory/vaultHolder.js +14 -15
  149. package/src/vaultFactory/vaultKit.d.ts +33 -0
  150. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  151. package/src/vaultFactory/vaultKit.js +9 -4
  152. package/src/vaultFactory/vaultManager.d.ts +676 -0
  153. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  154. package/src/vaultFactory/vaultManager.js +286 -167
  155. package/CHANGELOG.md +0 -1041
  156. package/exported.js +0 -2
  157. package/scripts/add-collateral-core.js +0 -112
  158. package/scripts/deploy-contracts.js +0 -100
  159. package/scripts/init-core.js +0 -198
  160. package/scripts/invite-committee-core.js +0 -42
  161. package/scripts/manual-price-feed.js +0 -117
  162. package/scripts/price-feed-core.js +0 -104
  163. package/scripts/start-local-chain.sh +0 -84
  164. package/src/psm/types.js +0 -3
  165. package/src/typeGuards.js +0 -13
  166. package/src/vaultFactory/type-imports.js +0 -4
@@ -0,0 +1,168 @@
1
+ export function lookupOfferIdForVault(vaultId: string, currentP: Promise<import("@agoric/smart-wallet/src/smartWallet.js").CurrentWalletRecord>): Promise<string>;
2
+ export function makeParseAmount(agoricNames: Pick<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes, "brand" | "vbankAsset">, makeError?: (msg: string) => Error): (a: string) => Amount<"nat">;
3
+ export namespace Offers {
4
+ namespace auction {
5
+ export { makeBidOffer as Bid };
6
+ }
7
+ namespace fluxAggregator {
8
+ export { makePushPriceOffer as PushPrice };
9
+ }
10
+ namespace psm {
11
+ export { makePsmSwapOffer as swap };
12
+ }
13
+ namespace vaults {
14
+ export { makeOpenOffer as OpenVault };
15
+ export { makeAdjustOffer as AdjustBalances };
16
+ export { makeCloseOffer as CloseVault };
17
+ }
18
+ namespace reserve {
19
+ export { makeAddCollateralOffer as AddCollateral };
20
+ }
21
+ }
22
+ import type { Amount } from '@agoric/ertp';
23
+ /**
24
+ * @param {Pick<
25
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
26
+ * 'brand' | 'vbankAsset'
27
+ * >} agoricNames
28
+ * @param {{
29
+ * offerId: string;
30
+ * give: string;
31
+ * maxBuy: string;
32
+ * wantMinimum?: string;
33
+ * } & (
34
+ * | {
35
+ * price: number;
36
+ * }
37
+ * | {
38
+ * discount: number; // -1 to 1. e.g. 0.10 for 10% discount, -0.05 for 5% markup
39
+ * }
40
+ * )} opts
41
+ * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
42
+ */
43
+ declare function makeBidOffer(agoricNames: Pick<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes, "brand" | "vbankAsset">, opts: {
44
+ offerId: string;
45
+ give: string;
46
+ maxBuy: string;
47
+ wantMinimum?: string;
48
+ } & ({
49
+ price: number;
50
+ } | {
51
+ discount: number;
52
+ })): import("@agoric/smart-wallet/src/offers.js").OfferSpec;
53
+ /**
54
+ * @param {unknown} _agoricNames
55
+ * @param {{
56
+ * offerId: string;
57
+ * roundId?: bigint;
58
+ * unitPrice: bigint;
59
+ * }} opts
60
+ * @param {string} previousOffer
61
+ * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
62
+ */
63
+ declare function makePushPriceOffer(_agoricNames: unknown, opts: {
64
+ offerId: string;
65
+ roundId?: bigint;
66
+ unitPrice: bigint;
67
+ }, previousOffer: string): import("@agoric/smart-wallet/src/offers.js").OfferSpec;
68
+ /**
69
+ * @param {Pick<
70
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
71
+ * 'brand'
72
+ * >} agoricNames
73
+ * @param {Instance} instance
74
+ * @param {{ offerId: string; feePct?: number; pair: [string, string] } & (
75
+ * | { wantMinted: number }
76
+ * | { giveMinted: number }
77
+ * )} opts
78
+ * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
79
+ */
80
+ declare function makePsmSwapOffer({ brand }: Pick<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes, "brand">, instance: Instance, opts: {
81
+ offerId: string;
82
+ feePct?: number;
83
+ pair: [string, string];
84
+ } & ({
85
+ wantMinted: number;
86
+ } | {
87
+ giveMinted: number;
88
+ })): import("@agoric/smart-wallet/src/offers.js").OfferSpec;
89
+ /**
90
+ * @param {Pick<
91
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
92
+ * 'brand'
93
+ * >} agoricNames
94
+ * @param {{
95
+ * offerId: string;
96
+ * wantMinted: number;
97
+ * giveCollateral: number;
98
+ * collateralBrandKey: string;
99
+ * }} opts
100
+ * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
101
+ */
102
+ declare function makeOpenOffer({ brand }: Pick<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes, "brand">, opts: {
103
+ offerId: string;
104
+ wantMinted: number;
105
+ giveCollateral: number;
106
+ collateralBrandKey: string;
107
+ }): import("@agoric/smart-wallet/src/offers.js").OfferSpec;
108
+ /**
109
+ * @param {Pick<
110
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
111
+ * 'brand'
112
+ * >} agoricNames
113
+ * @param {{
114
+ * offerId: string;
115
+ * collateralBrandKey?: string;
116
+ * giveCollateral?: number;
117
+ * wantCollateral?: number;
118
+ * giveMinted?: number;
119
+ * wantMinted?: number;
120
+ * }} opts
121
+ * @param {string} previousOffer
122
+ * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
123
+ */
124
+ declare function makeAdjustOffer({ brand }: Pick<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes, "brand">, opts: {
125
+ offerId: string;
126
+ collateralBrandKey?: string;
127
+ giveCollateral?: number;
128
+ wantCollateral?: number;
129
+ giveMinted?: number;
130
+ wantMinted?: number;
131
+ }, previousOffer: string): import("@agoric/smart-wallet/src/offers.js").OfferSpec;
132
+ /**
133
+ * @param {Pick<
134
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
135
+ * 'brand'
136
+ * >} agoricNames
137
+ * @param {{
138
+ * offerId: string;
139
+ * collateralBrandKey?: string;
140
+ * giveMinted: number;
141
+ * }} opts
142
+ * @param {string} previousOffer
143
+ * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
144
+ */
145
+ declare function makeCloseOffer({ brand }: Pick<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes, "brand">, opts: {
146
+ offerId: string;
147
+ collateralBrandKey?: string;
148
+ giveMinted: number;
149
+ }, previousOffer: string): import("@agoric/smart-wallet/src/offers.js").OfferSpec;
150
+ /**
151
+ * @param {Pick<
152
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
153
+ * 'brand'
154
+ * >} agoricNames
155
+ * @param {{
156
+ * offerId: string;
157
+ * give: number;
158
+ * collateralBrandKey: string;
159
+ * }} opts
160
+ * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
161
+ */
162
+ declare function makeAddCollateralOffer({ brand }: Pick<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes, "brand">, opts: {
163
+ offerId: string;
164
+ give: number;
165
+ collateralBrandKey: string;
166
+ }): import("@agoric/smart-wallet/src/offers.js").OfferSpec;
167
+ export {};
168
+ //# sourceMappingURL=clientSupport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientSupport.d.ts","sourceRoot":"","sources":["clientSupport.js"],"names":[],"mappings":"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"}
@@ -1,9 +1,14 @@
1
1
  // @ts-check
2
2
 
3
- import { Fail } from '@agoric/assert';
3
+ import { Fail } from '@endo/errors';
4
4
  import { AmountMath } from '@agoric/ertp';
5
5
  import { assertAllDefined } from '@agoric/internal';
6
- import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
6
+ import { parseRatio } from '@agoric/ertp/src/ratio.js';
7
+
8
+ /**
9
+ * @import {Amount, Brand, Payment, Purse} from '@agoric/ertp';
10
+ * @import {Proposal} from '@agoric/zoe';
11
+ */
7
12
 
8
13
  // XXX support other decimal places
9
14
  const COSMOS_UNIT = 1_000_000n;
@@ -15,23 +20,31 @@ const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
15
20
  /**
16
21
  * Give/want
17
22
  *
18
- * @param {Record<string, Brand>} brands
19
- * @param {{ giveMinted?: number, wantMinted?: number } | { collateralBrandKey: string, giveCollateral?: number, wantCollateral?: number }} opts
23
+ * @param {Pick<
24
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
25
+ * 'brand'
26
+ * >} agoricNames
27
+ * @param {{ giveMinted?: number; wantMinted?: number }
28
+ * | {
29
+ * collateralBrandKey: string;
30
+ * giveCollateral?: number;
31
+ * wantCollateral?: number;
32
+ * }} opts
20
33
  * @returns {Proposal}
21
34
  */
22
- const makeVaultProposal = (brands, opts) => {
35
+ const makeVaultProposal = ({ brand }, opts) => {
23
36
  const proposal = { give: {}, want: {} };
24
37
 
25
38
  if ('giveCollateral' in opts && opts.giveCollateral) {
26
39
  const { collateralBrandKey } = opts;
27
40
  proposal.give.Collateral = {
28
- brand: brands[collateralBrandKey],
41
+ brand: brand[collateralBrandKey],
29
42
  value: scaleDecimals(opts.giveCollateral),
30
43
  };
31
44
  }
32
45
  if ('giveMinted' in opts && opts.giveMinted) {
33
46
  proposal.give.Minted = {
34
- brand: brands.IST,
47
+ brand: brand.IST,
35
48
  value: scaleDecimals(opts.giveMinted),
36
49
  };
37
50
  }
@@ -39,13 +52,13 @@ const makeVaultProposal = (brands, opts) => {
39
52
  if ('wantCollateral' in opts && opts.wantCollateral) {
40
53
  const { collateralBrandKey } = opts;
41
54
  proposal.want.Collateral = {
42
- brand: brands[collateralBrandKey],
55
+ brand: brand[collateralBrandKey],
43
56
  value: scaleDecimals(opts.wantCollateral),
44
57
  };
45
58
  }
46
59
  if ('wantMinted' in opts && opts.wantMinted) {
47
60
  proposal.want.Minted = {
48
- brand: brands.IST,
61
+ brand: brand.IST,
49
62
  value: scaleDecimals(opts.wantMinted),
50
63
  };
51
64
  }
@@ -54,18 +67,26 @@ const makeVaultProposal = (brands, opts) => {
54
67
  };
55
68
 
56
69
  /**
57
- * @param {Record<string, Brand>} brands
58
- * @param {{ offerId: string, wantMinted: number, giveCollateral: number, collateralBrandKey: string }} opts
70
+ * @param {Pick<
71
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
72
+ * 'brand'
73
+ * >} agoricNames
74
+ * @param {{
75
+ * offerId: string;
76
+ * wantMinted: number;
77
+ * giveCollateral: number;
78
+ * collateralBrandKey: string;
79
+ * }} opts
59
80
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
60
81
  */
61
- const makeOpenOffer = (brands, opts) => {
62
- const proposal = makeVaultProposal(brands, opts);
82
+ const makeOpenOffer = ({ brand }, opts) => {
83
+ const proposal = makeVaultProposal({ brand }, opts);
63
84
 
64
85
  // NB: not really a Proposal because the brands are not remotes
65
86
  // Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
66
87
  // mustMatch(harden(proposal), ProposalShape);
67
88
 
68
- const collateralBrand = brands[opts.collateralBrandKey];
89
+ const collateralBrand = brand[opts.collateralBrandKey];
69
90
 
70
91
  return {
71
92
  id: opts.offerId,
@@ -82,16 +103,26 @@ const makeOpenOffer = (brands, opts) => {
82
103
  };
83
104
 
84
105
  /**
85
- * @param {Record<string, Brand>} brands
86
- * @param {{ offerId: string, collateralBrandKey?: string, giveCollateral?: number, wantCollateral?: number, giveMinted?: number, wantMinted?: number }} opts
106
+ * @param {Pick<
107
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
108
+ * 'brand'
109
+ * >} agoricNames
110
+ * @param {{
111
+ * offerId: string;
112
+ * collateralBrandKey?: string;
113
+ * giveCollateral?: number;
114
+ * wantCollateral?: number;
115
+ * giveMinted?: number;
116
+ * wantMinted?: number;
117
+ * }} opts
87
118
  * @param {string} previousOffer
88
119
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
89
120
  */
90
- const makeAdjustOffer = (brands, opts, previousOffer) => {
121
+ const makeAdjustOffer = ({ brand }, opts, previousOffer) => {
91
122
  // NB: not really a Proposal because the brands are not remotes
92
123
  // Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
93
124
  // mustMatch(harden(proposal), ProposalShape);
94
- const proposal = makeVaultProposal(brands, opts);
125
+ const proposal = makeVaultProposal({ brand }, opts);
95
126
 
96
127
  return {
97
128
  id: opts.offerId,
@@ -105,13 +136,20 @@ const makeAdjustOffer = (brands, opts, previousOffer) => {
105
136
  };
106
137
 
107
138
  /**
108
- * @param {Record<string, Brand>} brands
109
- * @param {{ offerId: string, collateralBrandKey?: string, giveMinted: number }} opts
139
+ * @param {Pick<
140
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
141
+ * 'brand'
142
+ * >} agoricNames
143
+ * @param {{
144
+ * offerId: string;
145
+ * collateralBrandKey?: string;
146
+ * giveMinted: number;
147
+ * }} opts
110
148
  * @param {string} previousOffer
111
149
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
112
150
  */
113
- const makeCloseOffer = (brands, opts, previousOffer) => {
114
- const proposal = makeVaultProposal(brands, opts);
151
+ const makeCloseOffer = ({ brand }, opts, previousOffer) => {
152
+ const proposal = makeVaultProposal({ brand }, opts);
115
153
 
116
154
  return {
117
155
  id: opts.offerId,
@@ -126,7 +164,9 @@ const makeCloseOffer = (brands, opts, previousOffer) => {
126
164
 
127
165
  /**
128
166
  * @param {string} vaultId
129
- * @param {Promise<import('@agoric/smart-wallet/src/smartWallet').CurrentWalletRecord>} currentP
167
+ * @param {Promise<
168
+ * import('@agoric/smart-wallet/src/smartWallet.js').CurrentWalletRecord
169
+ * >} currentP
130
170
  * @returns {Promise<string>} offer id in which the vault was made
131
171
  */
132
172
  export const lookupOfferIdForVault = async (vaultId, currentP) => {
@@ -141,11 +181,14 @@ export const lookupOfferIdForVault = async (vaultId, currentP) => {
141
181
  };
142
182
 
143
183
  /**
144
- * @param {Record<string, Brand>} brands
145
- * @param {({ wantMinted: number, giveMinted?: undefined } | { giveMinted: number, wantMinted?: undefined })} opts
146
- * @param {number} [fee=0]
184
+ * @param {Record<
185
+ * string,
186
+ * import('@agoric/internal/src/marshal.js').BoardRemote
187
+ * >} brands
188
+ * @param {{ wantMinted: number; giveMinted?: undefined }
189
+ * | { giveMinted: number; wantMinted?: undefined }} opts
190
+ * @param {number} [fee]
147
191
  * @param {string} [anchor]
148
- * @returns {Proposal} XXX not a real proposal, uses BoardRemote
149
192
  */
150
193
  const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
151
194
  const giving = 'giveMinted' in opts ? 'minted' : 'anchor';
@@ -171,19 +214,24 @@ const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
171
214
  };
172
215
 
173
216
  /**
217
+ * @param {Pick<
218
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
219
+ * 'brand'
220
+ * >} agoricNames
174
221
  * @param {Instance} instance
175
- * @param {Record<string, Brand>} brands
176
- * @param {{ offerId: string, feePct?: number, pair: [string, string] } &
177
- * ({ wantMinted: number } | { giveMinted: number })} opts
222
+ * @param {{ offerId: string; feePct?: number; pair: [string, string] } & (
223
+ * | { wantMinted: number }
224
+ * | { giveMinted: number }
225
+ * )} opts
178
226
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
179
227
  */
180
- const makePsmSwapOffer = (instance, brands, opts) => {
228
+ const makePsmSwapOffer = ({ brand }, instance, opts) => {
181
229
  const method =
182
230
  'wantMinted' in opts
183
231
  ? 'makeWantMintedInvitation'
184
232
  : 'makeGiveMintedInvitation'; // ref psm.js
185
233
  const proposal = makePsmProposal(
186
- brands,
234
+ brand,
187
235
  opts,
188
236
  opts.feePct ? opts.feePct / 100 : undefined,
189
237
  opts.pair[1],
@@ -200,33 +248,81 @@ const makePsmSwapOffer = (instance, brands, opts) => {
200
248
  instance,
201
249
  publicInvitationMaker: method,
202
250
  },
251
+ // @ts-expect-error BoardRemote not a Brand object
203
252
  proposal,
204
253
  };
205
254
  };
206
255
 
207
256
  /**
208
- * @param {Record<string, Brand>} _brands
257
+ * @param {Pick<
258
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
259
+ * 'brand' | 'vbankAsset'
260
+ * >} agoricNames
261
+ * @param {(msg: string) => Error} makeError error constructor
262
+ * @returns {(a: string) => Amount<'nat'>}
263
+ */
264
+ export const makeParseAmount =
265
+ (agoricNames, makeError = msg => RangeError(msg)) =>
266
+ opt => {
267
+ assert.typeof(opt, 'string', 'parseAmount expected string');
268
+ const m = opt.match(
269
+ /^(?<value>[\d_]+(?:\.[\d_]+)?)\s*(?<brand>[A-Za-z]\w*)$/,
270
+ );
271
+ if (!m || !m.groups) {
272
+ throw makeError(`invalid amount: ${opt}`);
273
+ }
274
+ const anyBrand = agoricNames.brand[m.groups.brand];
275
+ if (!anyBrand) {
276
+ throw makeError(`unknown brand: ${m.groups.brand}`);
277
+ }
278
+ const assetDesc = Object.values(agoricNames.vbankAsset).find(
279
+ d => d.brand === anyBrand,
280
+ );
281
+ if (!assetDesc) {
282
+ throw makeError(`unknown brand: ${m.groups.brand}`);
283
+ }
284
+ const { displayInfo } = assetDesc;
285
+ if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
286
+ throw makeError(`bad brand: ${displayInfo}`);
287
+ }
288
+ const value = BigInt(
289
+ Number(m.groups.value.replace(/_/g, '')) *
290
+ 10 ** displayInfo.decimalPlaces,
291
+ );
292
+ /** @type {Brand<'nat'>} */
293
+ // @ts-expect-error dynamic cast
294
+ const natBrand = anyBrand;
295
+ const amt = { value, brand: natBrand };
296
+ return amt;
297
+ };
298
+
299
+ /**
300
+ * @param {Pick<
301
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
302
+ * 'brand' | 'vbankAsset'
303
+ * >} agoricNames
209
304
  * @param {{
210
- * offerId: string,
211
- * give: string,
212
- * maxBuy: string,
213
- * wantMinimum?: string,
214
- * parseAmount: (x: string) => Amount<'nat'>,
215
- * } & ({
216
- * price: number,
217
- * } | {
218
- * discount: number, // -1 to 1. e.g. 0.10 for 10% discount, -0.05 for 5% markup
219
- * })} opts
305
+ * offerId: string;
306
+ * give: string;
307
+ * maxBuy: string;
308
+ * wantMinimum?: string;
309
+ * } & (
310
+ * | {
311
+ * price: number;
312
+ * }
313
+ * | {
314
+ * discount: number; // -1 to 1. e.g. 0.10 for 10% discount, -0.05 for 5% markup
315
+ * }
316
+ * )} opts
220
317
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
221
318
  */
222
- const makeBidOffer = (_brands, opts) => {
223
- assert.typeof(opts.parseAmount, 'function');
319
+ const makeBidOffer = (agoricNames, opts) => {
224
320
  assertAllDefined({
225
321
  offerId: opts.offerId,
226
322
  give: opts.give,
227
323
  maxBuy: opts.maxBuy,
228
324
  });
229
- const { parseAmount } = opts;
325
+ const parseAmount = makeParseAmount(agoricNames);
230
326
  const proposal = {
231
327
  give: { Bid: parseAmount(opts.give) },
232
328
  ...(opts.wantMinimum
@@ -276,19 +372,23 @@ const makeBidOffer = (_brands, opts) => {
276
372
  };
277
373
 
278
374
  /**
279
- * @param {Record<string, Brand>} brands
375
+ * @param {Pick<
376
+ * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
377
+ * 'brand'
378
+ * >} agoricNames
280
379
  * @param {{
281
- * offerId: string,
282
- * give: number,
283
- * collateralBrandKey: string,
380
+ * offerId: string;
381
+ * give: number;
382
+ * collateralBrandKey: string;
284
383
  * }} opts
285
384
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
286
385
  */
287
- const makeAddCollateralOffer = (brands, opts) => {
386
+ const makeAddCollateralOffer = ({ brand }, opts) => {
288
387
  /** @type {AmountKeywordRecord} */
289
388
  const give = {
290
389
  Collateral: AmountMath.make(
291
- brands[opts.collateralBrandKey],
390
+ // @ts-expect-error BoardRemote not a Brand object
391
+ brand[opts.collateralBrandKey],
292
392
  scaleDecimals(opts.give),
293
393
  ),
294
394
  };
@@ -307,17 +407,16 @@ const makeAddCollateralOffer = (brands, opts) => {
307
407
  };
308
408
 
309
409
  /**
310
- *
311
- * @param {Record<string, Brand>} _brands
410
+ * @param {unknown} _agoricNames
312
411
  * @param {{
313
- * offerId: string,
314
- * roundId?: bigint,
315
- * unitPrice: bigint,
412
+ * offerId: string;
413
+ * roundId?: bigint;
414
+ * unitPrice: bigint;
316
415
  * }} opts
317
416
  * @param {string} previousOffer
318
417
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
319
418
  */
320
- const makePushPriceOffer = (_brands, opts, previousOffer) => {
419
+ const makePushPriceOffer = (_agoricNames, opts, previousOffer) => {
321
420
  return {
322
421
  id: opts.offerId,
323
422
  invitationSpec: {
@@ -332,48 +431,12 @@ const makePushPriceOffer = (_brands, opts, previousOffer) => {
332
431
  };
333
432
  };
334
433
 
335
- // TODO DRY with CLI wallet.js
336
434
  /**
337
- * @param {{
338
- * brand: Record<string, Brand>,
339
- * vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
340
- * }} agoricNames
341
- * @param {(msg: string) => Error} makeError error constructor
342
- * @returns {(a: string) => Amount<'nat'>}
435
+ * @satisfies {Record<
436
+ * string,
437
+ * Record<string, import('@agoric/smart-wallet/src/types.js').OfferMaker>
438
+ * >}
343
439
  */
344
- export const makeParseAmount =
345
- (agoricNames, makeError = msg => RangeError(msg)) =>
346
- opt => {
347
- assert.typeof(opt, 'string', 'parseAmount expected string');
348
- const m = opt.match(/^(?<value>[\d_]+(\.[\d_]+)?)(?<brand>[A-Z]\w*?)$/);
349
- if (!m || !m.groups) {
350
- throw makeError(`invalid amount: ${opt}`);
351
- }
352
- const anyBrand = agoricNames.brand[m.groups.brand];
353
- if (!anyBrand) {
354
- throw makeError(`unknown brand: ${m.groups.brand}`);
355
- }
356
- const assetDesc = Object.values(agoricNames.vbankAsset).find(
357
- d => d.brand === anyBrand,
358
- );
359
- if (!assetDesc) {
360
- throw makeError(`unknown brand: ${m.groups.brand}`);
361
- }
362
- const { displayInfo } = assetDesc;
363
- if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
364
- throw makeError(`bad brand: ${displayInfo}`);
365
- }
366
- const value = BigInt(
367
- Number(m.groups.value.replace(/_/g, '')) *
368
- 10 ** displayInfo.decimalPlaces,
369
- );
370
- /** @type {Brand<'nat'>} */
371
- // @ts-expect-error dynamic cast
372
- const natBrand = anyBrand;
373
- const amt = { value, brand: natBrand };
374
- return amt;
375
- };
376
-
377
440
  export const Offers = {
378
441
  auction: {
379
442
  Bid: makeBidOffer,
@@ -0,0 +1,2 @@
1
+ export function makeCollectFeesInvitation(zcf: ZCF, feeSeat: ZCFSeat, feeBrand: Brand, keyword: string): Promise<Invitation<string>>;
2
+ //# sourceMappingURL=collectFees.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectFees.d.ts","sourceRoot":"","sources":["collectFees.js"],"names":[],"mappings":"AAaO,+CANI,GAAG,WACH,OAAO,YACP,KAAK,WACL,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAYvC"}
@@ -0,0 +1,28 @@
1
+ export namespace amountPattern {
2
+ let brand: import("@endo/patterns").Matcher;
3
+ let value: import("@endo/patterns").Matcher;
4
+ }
5
+ export namespace ratioPattern {
6
+ export { amountPattern as numerator };
7
+ export { amountPattern as denominator };
8
+ }
9
+ export function addSubtract<A extends Amount>(base: A, gain: A, loss: A): A;
10
+ export function subtractToEmpty<T extends Amount>(left: T, right: T): T;
11
+ export function assertOnlyKeys(proposal: ProposalRecord, keys: string[]): void;
12
+ export function allEmpty(amounts: Amount[]): boolean;
13
+ export function checkDebtLimit(debtLimit: Amount<"nat">, totalDebt: Amount<"nat">, toMint: Amount<"nat">): void;
14
+ export function makeNatAmountShape(brand: Brand, min?: NatValue): {
15
+ brand: globalThis.Brand;
16
+ value: import("@endo/patterns").Matcher;
17
+ };
18
+ export function quoteAsRatio(quoteAmount: Pick<PriceDescription, "amountIn" | "amountOut">): import("@agoric/ertp/src/ratio").Ratio;
19
+ export type MetricsPublisherKit<T> = {
20
+ metricsPublication: IterationObserver<T>;
21
+ metricsSubscription: StoredSubscription<T>;
22
+ };
23
+ export type MetricsPublishKit<T> = {
24
+ metricsPublisher: Publisher<T>;
25
+ metricsSubscriber: StoredSubscriber<T>;
26
+ };
27
+ import type { PriceDescription } from '@agoric/zoe/tools/types.js';
28
+ //# sourceMappingURL=contractSupport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contractSupport.d.ts","sourceRoot":"","sources":["contractSupport.js"],"names":[],"mappings":";;;;;;;;AA4BO,4BANe,CAAC,SAAT,MAAO,QACV,CAAC,QACD,CAAC,QACD,CAAC,GACC,CAAC,CAGyC;AAQhD,gCALe,CAAC,SAAT,MAAO,QACV,CAAC,SACD,CAAC,GACC,CAAC,CAK2C;AAQlD,yCAHI,cAAc,QACd,MAAM,EAAE,QAQlB;AAMM,kCAHI,MAAM,EAAE,GACN,OAAO,CAInB;AAUM,0CAPI,MAAM,CAAC,KAAK,CAAC,aACb,MAAM,CAAC,KAAK,CAAC,UACb,MAAM,CAAC,KAAK,CAAC,QAcvB;AAoBM,0CAHI,KAAK,QACL,QAAQ;;;EAGmC;AAG/C,0CADK,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,WAAW,CAAC,0CAEO;gCAtBtD,CAAC;wBAEA,iBAAiB,CAAC,CAAC,CAAC;yBACpB,kBAAkB,CAAC,CAAC,CAAC;;8BAItB,CAAC;sBAEA,SAAS,CAAC,CAAC,CAAC;uBACZ,gBAAgB,CAAC,CAAC,CAAC;;sCAvF6D,4BAA4B"}