@agoric/zoe 0.26.3-upgrade-14-dev-c8f9e7b.0 → 0.26.3-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 (269) hide show
  1. package/README.md +7 -7
  2. package/bundles/bundle-contractFacet-js-meta.json +622 -313
  3. package/bundles/bundle-contractFacet.d.ts +3 -3
  4. package/bundles/bundle-contractFacet.js +1 -1
  5. package/exported.js +1 -12
  6. package/package.json +75 -60
  7. package/src/cleanProposal.d.ts +2 -2
  8. package/src/cleanProposal.d.ts.map +1 -1
  9. package/src/cleanProposal.js +15 -12
  10. package/src/contractFacet/exit.d.ts.map +1 -1
  11. package/src/contractFacet/exit.js +1 -0
  12. package/src/contractFacet/internal-types.d.ts +2 -2
  13. package/src/contractFacet/internal-types.d.ts.map +1 -1
  14. package/src/contractFacet/internal-types.js +1 -1
  15. package/src/contractFacet/offerHandlerStorage.d.ts +4 -1
  16. package/src/contractFacet/offerHandlerStorage.d.ts.map +1 -1
  17. package/src/contractFacet/offerHandlerStorage.js +11 -3
  18. package/src/contractFacet/reallocate.d.ts +3 -0
  19. package/src/contractFacet/reallocate.d.ts.map +1 -0
  20. package/src/contractFacet/reallocate.js +94 -0
  21. package/src/contractFacet/rightsConservation.d.ts.map +1 -1
  22. package/src/contractFacet/rightsConservation.js +3 -0
  23. package/src/contractFacet/types-ambient.d.ts +259 -0
  24. package/src/contractFacet/types-ambient.js +1 -0
  25. package/src/contractFacet/vatRoot.d.ts +4 -4
  26. package/src/contractFacet/vatRoot.d.ts.map +1 -1
  27. package/src/contractFacet/zcfMint.d.ts +5 -3
  28. package/src/contractFacet/zcfMint.d.ts.map +1 -1
  29. package/src/contractFacet/zcfMint.js +4 -4
  30. package/src/contractFacet/zcfSeat.d.ts +4 -2
  31. package/src/contractFacet/zcfSeat.d.ts.map +1 -1
  32. package/src/contractFacet/zcfSeat.js +125 -5
  33. package/src/contractFacet/zcfZygote.d.ts +1 -2
  34. package/src/contractFacet/zcfZygote.d.ts.map +1 -1
  35. package/src/contractFacet/zcfZygote.js +95 -42
  36. package/src/contractSupport/atomicTransfer.d.ts +0 -6
  37. package/src/contractSupport/atomicTransfer.d.ts.map +1 -1
  38. package/src/contractSupport/atomicTransfer.js +5 -90
  39. package/src/contractSupport/bondingCurves.js +2 -2
  40. package/src/contractSupport/durability.d.ts +3 -3
  41. package/src/contractSupport/durability.d.ts.map +1 -1
  42. package/src/contractSupport/durability.js +5 -5
  43. package/src/contractSupport/index.d.ts +1 -0
  44. package/src/contractSupport/index.js +1 -0
  45. package/src/contractSupport/prepare-ownable.d.ts +11 -0
  46. package/src/contractSupport/prepare-ownable.d.ts.map +1 -0
  47. package/src/contractSupport/prepare-ownable.js +100 -0
  48. package/src/contractSupport/priceAuthority.d.ts +23 -15
  49. package/src/contractSupport/priceAuthority.d.ts.map +1 -1
  50. package/src/contractSupport/priceAuthority.js +32 -17
  51. package/src/contractSupport/priceAuthorityInitial.d.ts +3 -2
  52. package/src/contractSupport/priceAuthorityInitial.d.ts.map +1 -1
  53. package/src/contractSupport/priceAuthorityInitial.js +5 -2
  54. package/src/contractSupport/priceAuthorityQuoteMint.d.ts +2 -1
  55. package/src/contractSupport/priceAuthorityQuoteMint.d.ts.map +1 -1
  56. package/src/contractSupport/priceAuthorityQuoteMint.js +23 -27
  57. package/src/contractSupport/priceAuthorityTransform.d.ts +14 -12
  58. package/src/contractSupport/priceAuthorityTransform.d.ts.map +1 -1
  59. package/src/contractSupport/priceAuthorityTransform.js +10 -8
  60. package/src/contractSupport/priceQuote.d.ts +7 -5
  61. package/src/contractSupport/priceQuote.d.ts.map +1 -1
  62. package/src/contractSupport/priceQuote.js +5 -1
  63. package/src/contractSupport/ratio.d.ts +2 -2
  64. package/src/contractSupport/ratio.d.ts.map +1 -1
  65. package/src/contractSupport/ratio.js +19 -15
  66. package/src/contractSupport/recorder.d.ts +31 -117
  67. package/src/contractSupport/recorder.d.ts.map +1 -1
  68. package/src/contractSupport/recorder.js +21 -10
  69. package/src/contractSupport/safeMath.d.ts +7 -7
  70. package/src/contractSupport/safeMath.d.ts.map +1 -1
  71. package/src/contractSupport/statistics.d.ts +1 -1
  72. package/src/contractSupport/statistics.d.ts.map +1 -1
  73. package/src/contractSupport/topics.d.ts +1 -1
  74. package/src/contractSupport/topics.d.ts.map +1 -1
  75. package/src/contractSupport/{types.d.ts → types-ambient.d.ts} +4 -4
  76. package/src/contractSupport/types-ambient.d.ts.map +1 -0
  77. package/src/contractSupport/{types.js → types-ambient.js} +1 -1
  78. package/src/contractSupport/zoeHelpers.d.ts +1 -1
  79. package/src/contractSupport/zoeHelpers.d.ts.map +1 -1
  80. package/src/contractSupport/zoeHelpers.js +5 -11
  81. package/src/contracts/auction/firstPriceLogic.d.ts.map +1 -1
  82. package/src/contracts/auction/firstPriceLogic.js +5 -8
  83. package/src/contracts/auction/index.d.ts +10 -10
  84. package/src/contracts/auction/index.d.ts.map +1 -1
  85. package/src/contracts/auction/index.js +2 -1
  86. package/src/contracts/auction/secondPriceLogic.d.ts.map +1 -1
  87. package/src/contracts/auction/secondPriceLogic.js +1 -4
  88. package/src/contracts/automaticRefund.d.ts +1 -1
  89. package/src/contracts/automaticRefund.d.ts.map +1 -1
  90. package/src/contracts/autoswap.d.ts.map +1 -1
  91. package/src/contracts/autoswap.js +8 -9
  92. package/src/contracts/barterExchange.d.ts +1 -1
  93. package/src/contracts/barterExchange.d.ts.map +1 -1
  94. package/src/contracts/barterExchange.js +2 -3
  95. package/src/contracts/callSpread/calculateShares.d.ts +1 -8
  96. package/src/contracts/callSpread/calculateShares.d.ts.map +1 -1
  97. package/src/contracts/callSpread/calculateShares.js +1 -1
  98. package/src/contracts/callSpread/fundedCallSpread.d.ts +4 -0
  99. package/src/contracts/callSpread/fundedCallSpread.d.ts.map +1 -1
  100. package/src/contracts/callSpread/fundedCallSpread.js +6 -4
  101. package/src/contracts/callSpread/payoffHandler.d.ts.map +1 -1
  102. package/src/contracts/callSpread/payoffHandler.js +2 -1
  103. package/src/contracts/callSpread/percent.d.ts +2 -4
  104. package/src/contracts/callSpread/percent.d.ts.map +1 -1
  105. package/src/contracts/callSpread/position.d.ts +2 -2
  106. package/src/contracts/callSpread/pricedCallSpread.d.ts +6 -5
  107. package/src/contracts/callSpread/pricedCallSpread.d.ts.map +1 -1
  108. package/src/contracts/callSpread/pricedCallSpread.js +8 -4
  109. package/src/contracts/callSpread/{types.d.ts → types-ambient.d.ts} +3 -3
  110. package/src/contracts/callSpread/types-ambient.d.ts.map +1 -0
  111. package/src/contracts/coveredCall-durable.d.ts +2 -4
  112. package/src/contracts/coveredCall-durable.d.ts.map +1 -1
  113. package/src/contracts/exported.js +3 -3
  114. package/src/contracts/loan/borrow.d.ts.map +1 -1
  115. package/src/contracts/loan/borrow.js +7 -4
  116. package/src/contracts/loan/close.d.ts.map +1 -1
  117. package/src/contracts/loan/close.js +3 -7
  118. package/src/contracts/loan/index.d.ts +5 -1
  119. package/src/contracts/loan/index.d.ts.map +1 -1
  120. package/src/contracts/loan/index.js +4 -0
  121. package/src/contracts/loan/liquidate.d.ts +1 -12
  122. package/src/contracts/loan/liquidate.d.ts.map +1 -1
  123. package/src/contracts/loan/liquidate.js +4 -2
  124. package/src/contracts/loan/scheduleLiquidation.d.ts.map +1 -1
  125. package/src/contracts/loan/scheduleLiquidation.js +1 -0
  126. package/src/contracts/loan/{types.d.ts → types-ambient.d.ts} +16 -17
  127. package/src/contracts/loan/types-ambient.d.ts.map +1 -0
  128. package/src/contracts/loan/{types.js → types-ambient.js} +11 -18
  129. package/src/contracts/loan/updateDebt.js +1 -1
  130. package/src/contracts/mintAndSellNFT.d.ts.map +1 -1
  131. package/src/contracts/mintPayments.d.ts +14 -6
  132. package/src/contracts/mintPayments.d.ts.map +1 -1
  133. package/src/contracts/mintPayments.js +1 -1
  134. package/src/contracts/oracle.d.ts +25 -3
  135. package/src/contracts/oracle.d.ts.map +1 -1
  136. package/src/contracts/oracle.js +7 -0
  137. package/src/contracts/otcDesk.d.ts +3 -3
  138. package/src/contracts/otcDesk.d.ts.map +1 -1
  139. package/src/contracts/otcDesk.js +1 -1
  140. package/src/contracts/priceAggregator.d.ts +112 -18
  141. package/src/contracts/priceAggregator.d.ts.map +1 -1
  142. package/src/contracts/priceAggregator.js +16 -18
  143. package/src/contracts/priceAggregatorTypes.d.ts +2 -2
  144. package/src/contracts/priceAggregatorTypes.d.ts.map +1 -1
  145. package/src/contracts/scaledPriceAuthority.d.ts +4 -5
  146. package/src/contracts/scaledPriceAuthority.d.ts.map +1 -1
  147. package/src/contracts/scaledPriceAuthority.js +6 -0
  148. package/src/contracts/sellItems.d.ts +2 -2
  149. package/src/contracts/sellItems.d.ts.map +1 -1
  150. package/src/contracts/sellItems.js +2 -3
  151. package/src/contracts/simpleExchange.d.ts +3 -3
  152. package/src/contracts/{types.d.ts → types-ambient.d.ts} +1 -1
  153. package/src/contracts/types-ambient.d.ts.map +1 -0
  154. package/src/handleWarning.d.ts.map +1 -1
  155. package/src/instanceRecordStorage.d.ts +1 -1
  156. package/src/instanceRecordStorage.d.ts.map +1 -1
  157. package/src/internal-types.d.ts +20 -32
  158. package/src/internal-types.d.ts.map +1 -1
  159. package/src/internal-types.js +18 -58
  160. package/src/issuerRecord.d.ts +2 -2
  161. package/src/issuerRecord.d.ts.map +1 -1
  162. package/src/issuerStorage.d.ts +4 -4
  163. package/src/issuerStorage.d.ts.map +1 -1
  164. package/src/issuerStorage.js +12 -28
  165. package/src/makeHandle.d.ts +2 -2
  166. package/src/makeHandle.d.ts.map +1 -1
  167. package/src/makeHandle.js +1 -1
  168. package/src/typeGuards.d.ts +119 -20
  169. package/src/typeGuards.d.ts.map +1 -1
  170. package/src/typeGuards.js +18 -9
  171. package/src/types-ambient.d.ts +41 -0
  172. package/src/types-ambient.d.ts.map +1 -0
  173. package/src/{types.js → types-ambient.js} +6 -14
  174. package/src/zoeService/escrowStorage.d.ts +1 -1
  175. package/src/zoeService/escrowStorage.d.ts.map +1 -1
  176. package/src/zoeService/escrowStorage.js +20 -27
  177. package/src/zoeService/feeMint.d.ts +9 -16
  178. package/src/zoeService/feeMint.d.ts.map +1 -1
  179. package/src/zoeService/feeMint.js +21 -15
  180. package/src/zoeService/installationStorage.d.ts +5 -20
  181. package/src/zoeService/installationStorage.d.ts.map +1 -1
  182. package/src/zoeService/installationStorage.js +11 -7
  183. package/src/zoeService/instanceAdminStorage.d.ts +22 -42
  184. package/src/zoeService/instanceAdminStorage.d.ts.map +1 -1
  185. package/src/zoeService/instanceAdminStorage.js +1 -0
  186. package/src/zoeService/internal-types.d.ts +16 -16
  187. package/src/zoeService/internal-types.d.ts.map +1 -1
  188. package/src/zoeService/internal-types.js +6 -6
  189. package/src/zoeService/invitationQueries.d.ts.map +1 -1
  190. package/src/zoeService/invitationQueries.js +7 -5
  191. package/src/zoeService/makeInvitation.d.ts +3 -3
  192. package/src/zoeService/makeInvitation.d.ts.map +1 -1
  193. package/src/zoeService/makeInvitation.js +25 -21
  194. package/src/zoeService/offer/burnInvitation.d.ts.map +1 -1
  195. package/src/zoeService/offer/offer.d.ts.map +1 -1
  196. package/src/zoeService/offer/offer.js +2 -5
  197. package/src/zoeService/originalZoeSeat.d.ts +34 -0
  198. package/src/zoeService/originalZoeSeat.d.ts.map +1 -0
  199. package/src/zoeService/originalZoeSeat.js +353 -0
  200. package/src/zoeService/startInstance.d.ts +3 -3
  201. package/src/zoeService/startInstance.d.ts.map +1 -1
  202. package/src/zoeService/startInstance.js +17 -11
  203. package/src/zoeService/{types.d.ts → types-ambient.d.ts} +26 -31
  204. package/src/zoeService/types-ambient.d.ts.map +1 -0
  205. package/src/zoeService/{types.js → types-ambient.js} +19 -32
  206. package/src/zoeService/utils.d.ts +54 -58
  207. package/src/zoeService/utils.test-d.d.ts +2 -0
  208. package/src/zoeService/utils.test-d.d.ts.map +1 -0
  209. package/src/zoeService/utils.test-d.ts +33 -0
  210. package/src/zoeService/zoe.d.ts +9 -13
  211. package/src/zoeService/zoe.d.ts.map +1 -1
  212. package/src/zoeService/zoe.js +7 -7
  213. package/src/zoeService/zoeSeat.d.ts +15 -45
  214. package/src/zoeService/zoeSeat.d.ts.map +1 -1
  215. package/src/zoeService/zoeSeat.js +214 -114
  216. package/src/zoeService/zoeStorageManager.d.ts +9 -43
  217. package/src/zoeService/zoeStorageManager.d.ts.map +1 -1
  218. package/src/zoeService/zoeStorageManager.js +8 -6
  219. package/tools/fakePriceAuthority.d.ts +9 -8
  220. package/tools/fakePriceAuthority.d.ts.map +1 -1
  221. package/tools/fakePriceAuthority.js +21 -17
  222. package/tools/fakeVatAdmin.d.ts +10 -10
  223. package/tools/manualPriceAuthority.d.ts +11 -6
  224. package/tools/manualPriceAuthority.d.ts.map +1 -1
  225. package/tools/manualPriceAuthority.js +15 -2
  226. package/tools/manualTimer.d.ts +21 -40
  227. package/tools/manualTimer.d.ts.map +1 -1
  228. package/tools/manualTimer.js +30 -16
  229. package/tools/prepare-test-env.js +1 -1
  230. package/tools/scriptedOracle.d.ts +3 -3
  231. package/tools/scriptedOracle.d.ts.map +1 -1
  232. package/tools/scriptedOracle.js +1 -1
  233. package/tools/scriptedPriceAuthority.d.ts +4 -0
  234. package/tools/scriptedPriceAuthority.d.ts.map +1 -1
  235. package/tools/scriptedPriceAuthority.js +6 -1
  236. package/tools/setup-zoe.d.ts +8 -9
  237. package/tools/setup-zoe.d.ts.map +1 -1
  238. package/tools/setup-zoe.js +16 -1
  239. package/tools/test-utils.d.ts +20 -0
  240. package/tools/test-utils.d.ts.map +1 -0
  241. package/tools/test-utils.js +26 -0
  242. package/tools/types.d.ts +21 -21
  243. package/tools/types.d.ts.map +1 -1
  244. package/tools/types.js +10 -10
  245. package/CHANGELOG.md +0 -1203
  246. package/src/contractFacet/types.d.ts +0 -191
  247. package/src/contractFacet/types.d.ts.map +0 -1
  248. package/src/contractFacet/types.js +0 -256
  249. package/src/contractSupport/types.d.ts.map +0 -1
  250. package/src/contracts/callSpread/types.d.ts.map +0 -1
  251. package/src/contracts/loan/types.d.ts.map +0 -1
  252. package/src/contracts/types.d.ts.map +0 -1
  253. package/src/objArrayConversion.d.ts +0 -5
  254. package/src/objArrayConversion.d.ts.map +0 -1
  255. package/src/objArrayConversion.js +0 -35
  256. package/src/types.d.ts +0 -45
  257. package/src/types.d.ts.map +0 -1
  258. package/src/zoeService/types.d.ts.map +0 -1
  259. package/tools/internal-types.d.ts +0 -12
  260. package/tools/internal-types.d.ts.map +0 -1
  261. package/tools/internal-types.js +0 -14
  262. package/tools/priceAuthorityRegistry.d.ts +0 -20
  263. package/tools/priceAuthorityRegistry.d.ts.map +0 -1
  264. package/tools/priceAuthorityRegistry.js +0 -209
  265. package/tools/types-ambient.d.ts +0 -142
  266. package/tools/types-ambient.d.ts.map +0 -1
  267. package/tools/types-ambient.js +0 -160
  268. /package/src/contracts/callSpread/{types.js → types-ambient.js} +0 -0
  269. /package/src/contracts/{types.js → types-ambient.js} +0 -0
@@ -1,209 +0,0 @@
1
- import { BrandShape } from '@agoric/ertp';
2
- import {
3
- M,
4
- prepareExo,
5
- makeScalarBigMapStore,
6
- provideDurableMapStore,
7
- } from '@agoric/vat-data';
8
- import { provideLazy } from '@agoric/store';
9
- import { E } from '@endo/eventual-send';
10
- import { Far } from '@endo/marshal';
11
- import { PriceAuthorityI } from '../src/contractSupport/priceAuthority.js';
12
-
13
- const { Fail } = assert;
14
-
15
- /**
16
- * @typedef {object} Deleter
17
- * @property {() => void} delete
18
- */
19
-
20
- /**
21
- * @typedef {object} PriceAuthorityRegistryAdmin
22
- * @property {(pa: ERef<PriceAuthority>,
23
- * brandIn: Brand,
24
- * brandOut: Brand,
25
- * force?: boolean) => Promise<Deleter>} registerPriceAuthority
26
- * Add a unique price authority for a given pair
27
- */
28
-
29
- /**
30
- * @typedef {object} PriceAuthorityRegistry A price authority that is a facade
31
- * for other backing price authorities registered for a given asset and price
32
- * brand
33
- * @property {PriceAuthority} priceAuthority
34
- * @property {PriceAuthorityRegistryAdmin} adminFacet
35
- */
36
-
37
- /**
38
- * Make a singleton registry for priceAuthorities
39
- *
40
- * @param {import('@agoric/vat-data').Baggage} baggage
41
- * @returns {PriceAuthorityRegistry}
42
- */
43
- export const providePriceAuthorityRegistry = baggage => {
44
- /**
45
- * @typedef {object} PriceAuthorityRecord A record indicating a registered
46
- * price authority. We put a box around the priceAuthority to ensure the
47
- * deleter doesn't delete the wrong thing.
48
- * @property {ERef<PriceAuthority>} priceAuthority the sub-authority for a
49
- * given input and output brand pair
50
- */
51
-
52
- /** @type {MapStore<Brand, MapStore<Brand, PriceAuthorityRecord>>} */
53
- const assetToPriceStore = provideDurableMapStore(baggage, 'brandIn');
54
-
55
- /**
56
- * Get the registered price authority for a given input and output pair.
57
- *
58
- * @param {Brand} brandIn
59
- * @param {Brand} brandOut
60
- * @returns {ERef<PriceAuthority>}
61
- */
62
- const paFor = (brandIn, brandOut) => {
63
- const priceStore = assetToPriceStore.get(brandIn);
64
- return priceStore.get(brandOut).priceAuthority;
65
- };
66
-
67
- /**
68
- * Create a quoteWhen* method for the given condition.
69
- *
70
- * @param {'LT' | 'LTE' | 'GTE' | 'GT'} relation
71
- */
72
- const makeQuoteWhen =
73
- relation =>
74
- /**
75
- * Return a quote when relation is true of the arguments.
76
- *
77
- * @param {Amount<'nat'>} amountIn monitor the amountOut corresponding to this amountIn
78
- * @param {Amount<'nat'>} amountOutLimit the value to compare with the monitored amountOut
79
- * @returns {Promise<PriceQuote>} resolve with a quote when `amountOut
80
- * relation amountOutLimit` is true
81
- */
82
- async (amountIn, amountOutLimit) => {
83
- const pa = paFor(amountIn.brand, amountOutLimit.brand);
84
- return E(pa)[`quoteWhen${relation}`](amountIn, amountOutLimit);
85
- };
86
-
87
- /**
88
- * Create a mutableQuoteWhen* method for the given condition.
89
- *
90
- * @param {'LT' | 'LTE' | 'GTE' | 'GT'} relation
91
- */
92
- const makeMutableQuoteWhen =
93
- relation =>
94
- /**
95
- * Return a mutable quote when relation is true of the arguments.
96
- *
97
- * @param {Amount} amountIn monitor the amountOut corresponding to this amountIn
98
- * @param {Amount} amountOutLimit the value to compare with the monitored amountOut
99
- * @returns {Promise<MutableQuote>} resolve with a quote when `amountOut
100
- * relation amountOutLimit` is true
101
- */
102
- async (amountIn, amountOutLimit) => {
103
- const pa = paFor(amountIn.brand, amountOutLimit.brand);
104
- return E(pa)[`mutableQuoteWhen${relation}`](amountIn, amountOutLimit);
105
- };
106
-
107
- /**
108
- * This PriceAuthority is just a wrapper for multiple registered
109
- * PriceAuthorities.
110
- *
111
- * @type {PriceAuthority}
112
- */
113
- const priceAuthority = prepareExo(
114
- baggage,
115
- 'composite price authority',
116
- PriceAuthorityI,
117
- {
118
- getQuoteIssuer(brandIn, brandOut) {
119
- return E(paFor(brandIn, brandOut)).getQuoteIssuer(brandIn, brandOut);
120
- },
121
- getTimerService(brandIn, brandOut) {
122
- return E(paFor(brandIn, brandOut)).getTimerService(brandIn, brandOut);
123
- },
124
- quoteGiven(amountIn, brandOut) {
125
- return E(paFor(amountIn.brand, brandOut)).quoteGiven(
126
- amountIn,
127
- brandOut,
128
- );
129
- },
130
- quoteWanted(brandIn, amountOut) {
131
- return E(paFor(brandIn, amountOut.brand)).quoteWanted(
132
- brandIn,
133
- amountOut,
134
- );
135
- },
136
- makeQuoteNotifier(amountIn, brandOut) {
137
- return E(paFor(amountIn.brand, brandOut)).makeQuoteNotifier(
138
- amountIn,
139
- brandOut,
140
- );
141
- },
142
- quoteAtTime(deadline, amountIn, brandOut) {
143
- return E(paFor(amountIn.brand, brandOut)).quoteAtTime(
144
- deadline,
145
- amountIn,
146
- brandOut,
147
- );
148
- },
149
- quoteWhenLT: makeQuoteWhen('LT'),
150
- quoteWhenLTE: makeQuoteWhen('LTE'),
151
- quoteWhenGTE: makeQuoteWhen('GTE'),
152
- quoteWhenGT: makeQuoteWhen('GT'),
153
- mutableQuoteWhenLT: makeMutableQuoteWhen('LT'),
154
- mutableQuoteWhenLTE: makeMutableQuoteWhen('LTE'),
155
- mutableQuoteWhenGTE: makeMutableQuoteWhen('GTE'),
156
- mutableQuoteWhenGT: makeMutableQuoteWhen('GT'),
157
- },
158
- );
159
-
160
- /** @type {PriceAuthorityRegistryAdmin} */
161
- const adminFacet = prepareExo(
162
- baggage,
163
- 'price authority admin facet',
164
- M.interface('priceAuthorityRegistryAdmin', {
165
- registerPriceAuthority: M.callWhen(
166
- M.await(M.remotable('priceAuthority')),
167
- BrandShape,
168
- BrandShape,
169
- )
170
- .optional(M.boolean())
171
- .returns(M.remotable('deleter')),
172
- }),
173
- {
174
- registerPriceAuthority(pa, brandIn, brandOut, force = false) {
175
- /** @type {MapStore<Brand, PriceAuthorityRecord>} */
176
- const priceStore = provideLazy(assetToPriceStore, brandIn, () =>
177
- makeScalarBigMapStore('brandOut', { durable: true }),
178
- );
179
-
180
- // Put a box around the authority so that we can be ensured the deleter
181
- // won't delete the wrong thing.
182
- const record = {
183
- priceAuthority: pa,
184
- };
185
-
186
- // Set up the record.
187
- if (force && priceStore.has(brandOut)) {
188
- priceStore.set(brandOut, harden(record));
189
- } else {
190
- priceStore.init(brandOut, harden(record));
191
- }
192
-
193
- return Far('deleter', {
194
- // @ts-expect-error XXX callWhen
195
- delete() {
196
- (priceStore.has(brandOut) && priceStore.get(brandOut) === record) ||
197
- Fail`Price authority already dropped`;
198
- priceStore.delete(brandOut);
199
- },
200
- });
201
- },
202
- },
203
- );
204
-
205
- return harden({
206
- priceAuthority,
207
- adminFacet,
208
- });
209
- };
@@ -1,142 +0,0 @@
1
- type PriceQuote = {
2
- /**
3
- * Amount whose value is a PriceQuoteValue
4
- */
5
- quoteAmount: Amount<'set'>;
6
- /**
7
- * The `quoteAmount` wrapped as a payment
8
- */
9
- quotePayment: ERef<Payment<'set'>>;
10
- };
11
- /**
12
- * A single-valued set of PriceDescriptions. This is the `value` in
13
- * PriceQuote.quoteAmount (`{ brand, value: PriceQuoteValue }`).
14
- */
15
- type PriceQuoteValue = [PriceDescription];
16
- /**
17
- * A description of a single quote
18
- */
19
- type PriceDescription = {
20
- /**
21
- * The amount supplied to a trade
22
- */
23
- amountIn: Amount<'nat'>;
24
- /**
25
- * The quoted result of trading `amountIn`
26
- */
27
- amountOut: Amount<'nat'>;
28
- /**
29
- * The service that gave the `timestamp`
30
- */
31
- timer: import('@agoric/time/src/types').TimerService;
32
- /**
33
- * A timestamp according to `timer` for the quote
34
- */
35
- timestamp: import('@agoric/time/src/types').TimestampRecord;
36
- /**
37
- * Additional conditions for the quote
38
- */
39
- conditions?: any;
40
- };
41
- type PriceQuoteCreate = (priceQuery: PriceQuery) => ERef<PriceQuote> | undefined;
42
- type PriceQuoteTrigger = (createQuote: PriceQuoteCreate) => any;
43
- type PriceAuthorityAdmin = {
44
- fireTriggers: (createQuote: PriceQuoteCreate) => Promise<void>;
45
- };
46
- type PriceAuthorityKit = {
47
- priceAuthority: PriceAuthority;
48
- adminFacet: PriceAuthorityAdmin;
49
- };
50
- type MutableQuote = {
51
- cancel: (reason?: any) => void;
52
- updateLevel: (amountIn: Amount<'nat'>, amountOut: Amount<'nat'>) => void;
53
- getPromise: () => ERef<PriceQuote>;
54
- };
55
- /**
56
- * An object that mints PriceQuotes and handles
57
- * triggers and notifiers for changes in the price
58
- */
59
- type PriceAuthority = {
60
- /**
61
- * Get the ERTP issuer of PriceQuotes for a given brandIn/brandOut pair
62
- */
63
- getQuoteIssuer: (brandIn: Brand, brandOut: Brand) => ERef<Issuer<'set'>>;
64
- /**
65
- * Get the timer used in PriceQuotes for a given brandIn/brandOut pair
66
- */
67
- getTimerService: (brandIn: Brand, brandOut: Brand) => ERef<import('@agoric/time/src/types').TimerService>;
68
- /**
69
- * Be notified of the latest PriceQuotes for a given
70
- * `amountIn`. The rate at which these are issued may be very different between
71
- * `priceAuthorities`.
72
- */
73
- makeQuoteNotifier: (amountIn: Amount<'nat'>, brandOut: Brand<'nat'>) => ERef<Notifier<PriceQuote>>;
74
- /**
75
- * Resolves after `deadline` passes on the
76
- * priceAuthority's timerService with the price quote of `amountIn` at that time
77
- */
78
- quoteAtTime: (deadline: import('@agoric/time/src/types').Timestamp, amountIn: Amount<'nat'>, brandOut: Brand<'nat'>) => Promise<PriceQuote>;
79
- /**
80
- * Get a quote corresponding to the specified amountIn
81
- */
82
- quoteGiven: (amountIn: Amount<'nat'>, brandOut: Brand<'nat'>) => Promise<PriceQuote>;
83
- /**
84
- * Get a quote corresponding to the specified amountOut
85
- */
86
- quoteWanted: (brandIn: Brand<'nat'>, amountOut: Amount<'nat'>) => Promise<PriceQuote>;
87
- /**
88
- * Resolve when a price quote of `amountIn` exceeds `amountOutLimit`
89
- */
90
- quoteWhenGT: (amountIn: Amount<'nat'>, amountOutLimit: Amount<'nat'>) => Promise<PriceQuote>;
91
- /**
92
- * Resolve when a price quote of `amountIn` reaches or exceeds `amountOutLimit`
93
- */
94
- quoteWhenGTE: (amountIn: Amount<'nat'>, amountOutLimit: Amount<'nat'>) => Promise<PriceQuote>;
95
- /**
96
- * Resolve when a price quote of `amountIn` reaches or drops below
97
- * `amountOutLimit`
98
- */
99
- quoteWhenLTE: (amountIn: Amount, amountOutLimit: Amount) => Promise<PriceQuote>;
100
- /**
101
- * Resolve when the price quote of `amountIn` drops below `amountOutLimit`
102
- */
103
- quoteWhenLT: (amountIn: Amount, amountOutLimit: Amount) => Promise<PriceQuote>;
104
- /**
105
- * Resolve when a price quote of `amountIn` exceeds `amountOutLimit`
106
- */
107
- mutableQuoteWhenGT: (amountIn: Amount, amountOutLimit: Amount) => ERef<MutableQuote>;
108
- /**
109
- * Resolve when a price quote of `amountIn` reaches or exceeds
110
- * `amountOutLimit`
111
- */
112
- mutableQuoteWhenGTE: (amountIn: Amount, amountOutLimit: Amount) => ERef<MutableQuote>;
113
- /**
114
- * Resolve when a price quote of `amountIn` reaches or drops below
115
- * `amountOutLimit`
116
- */
117
- mutableQuoteWhenLTE: (amountIn: Amount, amountOutLimit: Amount) => ERef<MutableQuote>;
118
- /**
119
- * Resolve when the price quote of `amountIn` drops below `amountOutLimit`
120
- */
121
- mutableQuoteWhenLT: (amountIn: Amount, amountOutLimit: Amount) => ERef<MutableQuote>;
122
- };
123
- type PriceCalculator = (amount: Amount<'nat'>) => Amount<'nat'>;
124
- type PriceQuery = (calcAmountIn: PriceCalculator, calcAmountOut: PriceCalculator) => {
125
- amountIn: Amount<'nat'>;
126
- amountOut: Amount<'nat'>;
127
- timestamp?: import('@agoric/time/src/types').TimestampRecord;
128
- } | undefined;
129
- /**
130
- * A description of a single quote
131
- */
132
- type PriceLevel = {
133
- /**
134
- * The amount supplied to a trade
135
- */
136
- amountIn: Amount<'nat'>;
137
- /**
138
- * The quoted result of trading `amountIn`
139
- */
140
- amountOut: Amount<'nat'>;
141
- };
142
- //# sourceMappingURL=types-ambient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-ambient.d.ts","sourceRoot":"","sources":["types-ambient.js"],"names":[],"mappings":";;;;iBAIc,OAAO,KAAK,CAAC;;;;kBAEb,KAAK,QAAQ,KAAK,CAAC,CAAC;;;;;;uBAKrB,CAAC,gBAAgB,CAAC;;;;;;;;cAQjB,OAAO,KAAK,CAAC;;;;eAEb,OAAO,KAAK,CAAC;;;;WAEb,OAAO,wBAAwB,EAAE,YAAY;;;;eAE7C,OAAO,wBAAwB,EAAE,eAAe;;;;iBAEhD,GAAG;;qCAMN,UAAU,KACR,KAAK,UAAU,CAAC,GAAG,SAAS;uCAK9B,gBAAgB;;gCAKC,gBAAgB,KAAK,QAAQ,IAAI,CAAC;;;oBAKhD,cAAc;gBACd,mBAAmB;;;sBAKT,GAAG,KAAK,IAAI;4BACX,OAAO,KAAK,CAAC,aAAa,OAAO,KAAK,CAAC,KAAK,IAAI;gBAC3D,MAAM,KAAK,UAAU,CAAC;;;;;;;;;;8BAQZ,KAAK,YAAY,KAAK,KAAK,KAAK,OAAO,KAAK,CAAC,CAAC;;;;+BAG9C,KAAK,YACJ,KAAK,KACtB,KAAK,OAAO,wBAAwB,EAAE,YAAY,CAAC;;;;;;kCAGlC,OAAO,KAAK,CAAC,YACb,MAAM,KAAK,CAAC,KAClB,KAAK,SAAS,UAAU,CAAC,CAAC;;;;;4BAKpB,OAAO,wBAAwB,EAAE,SAAS,YAC1C,OAAO,KAAK,CAAC,YACb,MAAM,KAAK,CAAC,KAC7B,QAAQ,UAAU,CAAC;;;;2BAIF,OAAO,KAAK,CAAC,YACb,MAAM,KAAK,CAAC,KAC7B,QAAQ,UAAU,CAAC;;;;2BAGH,MAAM,KAAK,CAAC,aACV,OAAO,KAAK,CAAC,KAAK,QAAQ,UAAU,CAAC;;;;4BAGtC,OAAO,KAAK,CAAC,kBACP,OAAO,KAAK,CAAC,KACpC,QAAQ,UAAU,CAAC;;;;6BAGF,OAAO,KAAK,CAAC,kBACP,OAAO,KAAK,CAAC,KACpC,QAAQ,UAAU,CAAC;;;;;6BAGF,MAAM,kBACA,MAAM,KAC7B,QAAQ,UAAU,CAAC;;;;4BAIF,MAAM,kBACA,MAAM,KAC7B,QAAQ,UAAU,CAAC;;;;mCAGF,MAAM,kBACA,MAAM,KAC7B,KAAK,YAAY,CAAC;;;;;oCAGD,MAAM,kBACA,MAAM,KAC7B,KAAK,YAAY,CAAC;;;;;oCAID,MAAM,kBACA,MAAM,KAC7B,KAAK,YAAY,CAAC;;;;mCAID,MAAM,kBACA,MAAM,KAC7B,KAAK,YAAY,CAAC;;gCAKJ,OAAO,KAAK,CAAC,KAAK,OAAO,KAAK,CAAC;iCAK1C,eAAe,iBACf,eAAe,KACb;IAAE,QAAQ,EAAE,OAAO,KAAK,CAAC,CAAC;IAAC,SAAS,EAAE,OAAO,KAAK,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,wBAAwB,EAAE,eAAe,CAAA;CAAE,GAAG,SAAS;;;;;;;;cAO9H,OAAO,KAAK,CAAC;;;;eAEb,OAAO,KAAK,CAAC"}
@@ -1,160 +0,0 @@
1
- // @jessie-check
2
-
3
- /**
4
- * @typedef {object} PriceQuote
5
- * @property {Amount<'set'>} quoteAmount
6
- * Amount whose value is a PriceQuoteValue
7
- * @property {ERef<Payment<'set'>>} quotePayment
8
- * The `quoteAmount` wrapped as a payment
9
- */
10
-
11
- /**
12
- * @typedef {[PriceDescription]} PriceQuoteValue
13
- * A single-valued set of PriceDescriptions. This is the `value` in
14
- * PriceQuote.quoteAmount (`{ brand, value: PriceQuoteValue }`).
15
- */
16
-
17
- /**
18
- * @typedef {object} PriceDescription
19
- * A description of a single quote
20
- * @property {Amount<'nat'>} amountIn
21
- * The amount supplied to a trade
22
- * @property {Amount<'nat'>} amountOut
23
- * The quoted result of trading `amountIn`
24
- * @property {import('@agoric/time/src/types').TimerService} timer
25
- * The service that gave the `timestamp`
26
- * @property {import('@agoric/time/src/types').TimestampRecord} timestamp
27
- * A timestamp according to `timer` for the quote
28
- * @property {any} [conditions]
29
- * Additional conditions for the quote
30
- */
31
-
32
- /**
33
- * @callback PriceQuoteCreate
34
- * @param {PriceQuery} priceQuery
35
- * @returns {ERef<PriceQuote> | undefined}
36
- */
37
-
38
- /**
39
- * @callback PriceQuoteTrigger
40
- * @param {PriceQuoteCreate} createQuote
41
- */
42
-
43
- /**
44
- * @typedef {object} PriceAuthorityAdmin
45
- * @property {(createQuote: PriceQuoteCreate) => Promise<void>} fireTriggers
46
- */
47
-
48
- /**
49
- * @typedef {object} PriceAuthorityKit
50
- * @property {PriceAuthority} priceAuthority
51
- * @property {PriceAuthorityAdmin} adminFacet
52
- */
53
-
54
- /**
55
- * @typedef {object} MutableQuote
56
- * @property {(reason?: any) => void} cancel
57
- * @property {(amountIn: Amount<'nat'>, amountOut: Amount<'nat'>) => void} updateLevel
58
- * @property {() => ERef<PriceQuote>} getPromise
59
- */
60
-
61
- /**
62
- * @typedef {object} PriceAuthority
63
- * An object that mints PriceQuotes and handles
64
- * triggers and notifiers for changes in the price
65
- *
66
- * @property {(brandIn: Brand, brandOut: Brand) => ERef<Issuer<'set'>>} getQuoteIssuer
67
- * Get the ERTP issuer of PriceQuotes for a given brandIn/brandOut pair
68
- *
69
- * @property {(brandIn: Brand,
70
- * brandOut: Brand
71
- * ) => ERef<import('@agoric/time/src/types').TimerService>} getTimerService
72
- * Get the timer used in PriceQuotes for a given brandIn/brandOut pair
73
- *
74
- * @property {(amountIn: Amount<'nat'>,
75
- * brandOut: Brand<'nat'>
76
- * ) => ERef<Notifier<PriceQuote>>} makeQuoteNotifier
77
- * Be notified of the latest PriceQuotes for a given
78
- * `amountIn`. The rate at which these are issued may be very different between
79
- * `priceAuthorities`.
80
- *
81
- * @property {(deadline: import('@agoric/time/src/types').Timestamp,
82
- * amountIn: Amount<'nat'>,
83
- * brandOut: Brand<'nat'>
84
- * ) => Promise<PriceQuote>} quoteAtTime
85
- * Resolves after `deadline` passes on the
86
- * priceAuthority's timerService with the price quote of `amountIn` at that time
87
- *
88
- * @property {(amountIn: Amount<'nat'>,
89
- * brandOut: Brand<'nat'>
90
- * ) => Promise<PriceQuote>} quoteGiven
91
- * Get a quote corresponding to the specified amountIn
92
- *
93
- * @property {(brandIn: Brand<'nat'>,
94
- * amountOut: Amount<'nat'>) => Promise<PriceQuote>} quoteWanted
95
- * Get a quote corresponding to the specified amountOut
96
- *
97
- * @property {(amountIn: Amount<'nat'>,
98
- * amountOutLimit: Amount<'nat'>
99
- * ) => Promise<PriceQuote>} quoteWhenGT
100
- * Resolve when a price quote of `amountIn` exceeds `amountOutLimit`
101
- *
102
- * @property {(amountIn: Amount<'nat'>,
103
- * amountOutLimit: Amount<'nat'>
104
- * ) => Promise<PriceQuote>} quoteWhenGTE
105
- * Resolve when a price quote of `amountIn` reaches or exceeds `amountOutLimit`
106
- *
107
- * @property {(amountIn: Amount,
108
- * amountOutLimit: Amount
109
- * ) => Promise<PriceQuote>} quoteWhenLTE
110
- * Resolve when a price quote of `amountIn` reaches or drops below
111
- * `amountOutLimit`
112
- *
113
- * @property {(amountIn: Amount,
114
- * amountOutLimit: Amount
115
- * ) => Promise<PriceQuote>} quoteWhenLT
116
- * Resolve when the price quote of `amountIn` drops below `amountOutLimit`
117
- *
118
- * @property {(amountIn: Amount,
119
- * amountOutLimit: Amount
120
- * ) => ERef<MutableQuote>} mutableQuoteWhenGT
121
- * Resolve when a price quote of `amountIn` exceeds `amountOutLimit`
122
- *
123
- * @property {(amountIn: Amount,
124
- * amountOutLimit: Amount
125
- * ) => ERef<MutableQuote>} mutableQuoteWhenGTE
126
- * Resolve when a price quote of `amountIn` reaches or exceeds
127
- * `amountOutLimit`
128
- *
129
- * @property {(amountIn: Amount,
130
- * amountOutLimit: Amount
131
- * ) => ERef<MutableQuote>} mutableQuoteWhenLTE
132
- * Resolve when a price quote of `amountIn` reaches or drops below
133
- * `amountOutLimit`
134
- *
135
- * @property {(amountIn: Amount,
136
- * amountOutLimit: Amount
137
- * ) => ERef<MutableQuote>} mutableQuoteWhenLT
138
- * Resolve when the price quote of `amountIn` drops below `amountOutLimit`
139
- */
140
-
141
- /**
142
- * @typedef {(amount: Amount<'nat'>) => Amount<'nat'>} PriceCalculator
143
- */
144
-
145
- /**
146
- * @callback PriceQuery
147
- * @param {PriceCalculator} calcAmountIn
148
- * @param {PriceCalculator} calcAmountOut
149
- * @returns {{ amountIn: Amount<'nat'>, amountOut: Amount<'nat'>, timestamp?: import('@agoric/time/src/types').TimestampRecord } | undefined}
150
- */
151
-
152
- /**
153
- * @typedef {object} PriceLevel
154
- * A description of a single quote
155
- *
156
- * @property {Amount<'nat'>} amountIn
157
- * The amount supplied to a trade
158
- * @property {Amount<'nat'>} amountOut
159
- * The quoted result of trading `amountIn`
160
- */
File without changes