@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/package.json CHANGED
@@ -1,22 +1,24 @@
1
1
  {
2
2
  "name": "@agoric/inter-protocol",
3
- "version": "0.16.2-upgrade-14-dev-0169c7e.0+0169c7e",
3
+ "version": "0.16.2-upgrade-16-dev-8879538.0+8879538",
4
4
  "description": "Core cryptoeconomy contracts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "engines": {
8
- "node": ">=14.15.0"
8
+ "node": "^18.12 || ^20.9"
9
9
  },
10
10
  "scripts": {
11
11
  "build": "yarn build:bundles",
12
12
  "build:bundles": "node ./scripts/build-bundles.js",
13
+ "prepack": "tsc --build tsconfig.build.json",
14
+ "postpack": "git clean -f '*.d.ts*'",
13
15
  "test": "ava",
14
16
  "test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
15
17
  "test:xs": "exit 0",
16
18
  "lint-fix": "yarn lint:eslint --fix",
17
19
  "lint": "run-s --continue-on-error lint:*",
18
20
  "lint:eslint": "eslint .",
19
- "lint:types": "tsc -p jsconfig.json"
21
+ "lint:types": "tsc"
20
22
  },
21
23
  "repository": {
22
24
  "type": "git",
@@ -29,53 +31,58 @@
29
31
  },
30
32
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
31
33
  "dependencies": {
32
- "@agoric/assert": "0.6.1-upgrade-14-dev-0169c7e.0+0169c7e",
33
- "@agoric/ertp": "0.16.3-upgrade-14-dev-0169c7e.0+0169c7e",
34
- "@agoric/governance": "0.10.4-upgrade-14-dev-0169c7e.0+0169c7e",
35
- "@agoric/internal": "0.4.0-upgrade-14-dev-0169c7e.0+0169c7e",
36
- "@agoric/notifier": "0.6.3-upgrade-14-dev-0169c7e.0+0169c7e",
37
- "@agoric/store": "0.9.3-upgrade-14-dev-0169c7e.0+0169c7e",
38
- "@agoric/time": "0.3.3-upgrade-14-dev-0169c7e.0+0169c7e",
39
- "@agoric/vat-data": "0.5.3-upgrade-14-dev-0169c7e.0+0169c7e",
40
- "@agoric/vats": "0.15.2-upgrade-14-dev-0169c7e.0+0169c7e",
41
- "@agoric/zoe": "0.26.3-upgrade-14-dev-0169c7e.0+0169c7e",
42
- "@endo/captp": "3.1.1",
43
- "@endo/eventual-send": "0.17.2",
44
- "@endo/far": "0.2.18",
45
- "@endo/marshal": "0.8.5",
46
- "@endo/nat": "4.1.27",
47
- "jessie.js": "^0.3.2"
34
+ "@agoric/assert": "0.6.1-upgrade-16-dev-8879538.0+8879538",
35
+ "@agoric/ertp": "0.16.3-upgrade-16-dev-8879538.0+8879538",
36
+ "@agoric/governance": "0.10.4-upgrade-16-dev-8879538.0+8879538",
37
+ "@agoric/internal": "0.3.3-upgrade-16-dev-8879538.0+8879538",
38
+ "@agoric/notifier": "0.6.3-upgrade-16-dev-8879538.0+8879538",
39
+ "@agoric/store": "0.9.3-upgrade-16-dev-8879538.0+8879538",
40
+ "@agoric/time": "0.3.3-upgrade-16-dev-8879538.0+8879538",
41
+ "@agoric/vat-data": "0.5.3-upgrade-16-dev-8879538.0+8879538",
42
+ "@agoric/vats": "0.15.2-upgrade-16-dev-8879538.0+8879538",
43
+ "@agoric/zoe": "0.26.3-upgrade-16-dev-8879538.0+8879538",
44
+ "@endo/captp": "^4.2.0",
45
+ "@endo/eventual-send": "^1.2.2",
46
+ "@endo/far": "^1.1.2",
47
+ "@endo/marshal": "^1.5.0",
48
+ "@endo/nat": "^5.0.7",
49
+ "@endo/promise-kit": "^1.1.2",
50
+ "jessie.js": "^0.3.4"
48
51
  },
49
52
  "devDependencies": {
50
- "@agoric/deploy-script-support": "0.10.4-upgrade-14-dev-0169c7e.0+0169c7e",
51
- "@agoric/smart-wallet": "0.5.4-upgrade-14-dev-0169c7e.0+0169c7e",
52
- "@agoric/swingset-liveslots": "0.10.3-upgrade-14-dev-0169c7e.0+0169c7e",
53
- "@agoric/swingset-vat": "0.32.3-upgrade-14-dev-0169c7e.0+0169c7e",
54
- "@endo/bundle-source": "2.5.2-upstream-rollup",
55
- "@endo/init": "0.5.56",
56
- "@endo/promise-kit": "0.2.56",
57
- "@fast-check/ava": "^1.1.3",
58
- "ava": "^5.2.0",
59
- "c8": "^7.13.0",
53
+ "@agoric/smart-wallet": "0.5.4-upgrade-16-dev-8879538.0+8879538",
54
+ "@agoric/swingset-liveslots": "0.10.3-upgrade-16-dev-8879538.0+8879538",
55
+ "@agoric/swingset-vat": "0.32.3-upgrade-16-dev-8879538.0+8879538",
56
+ "@agoric/zone": "0.2.3-upgrade-16-dev-8879538.0+8879538",
57
+ "@endo/bundle-source": "^3.2.3",
58
+ "@endo/init": "^1.1.2",
59
+ "@endo/promise-kit": "^1.1.2",
60
+ "@fast-check/ava": "^1.1.5",
61
+ "ava": "^5.3.0",
62
+ "c8": "^9.1.0",
60
63
  "deep-object-diff": "^1.1.9",
61
64
  "import-meta-resolve": "^2.2.1"
62
65
  },
63
66
  "files": [
64
- "scripts/",
67
+ "scripts",
65
68
  "src/",
66
- "exported.js",
67
69
  "NEWS.md"
68
70
  ],
69
71
  "ava": {
70
72
  "files": [
71
- "test/**/test-*.js"
73
+ "test/**/*.test.*"
74
+ ],
75
+ "require": [
76
+ "@endo/init/debug.js"
72
77
  ],
73
- "concurrency": 2,
74
78
  "workerThreads": false,
75
79
  "timeout": "10m"
76
80
  },
77
81
  "publishConfig": {
78
82
  "access": "public"
79
83
  },
80
- "gitHead": "0169c7e505099fdcfa8e4d1436e5d3b372f1c320"
84
+ "typeCoverage": {
85
+ "atLeast": 95.87
86
+ },
87
+ "gitHead": "8879538cd1d125a08346f02dd5701d0d70c90bb8"
81
88
  }
@@ -1,36 +1,20 @@
1
1
  #! /usr/bin/env node
2
2
  import '@endo/init';
3
- import {
4
- createBundles,
5
- extractProposalBundles,
6
- } from '@agoric/internal/src/node/createBundles.js';
7
- import url from 'url';
8
- import process from 'process';
9
-
10
- import { defaultProposalBuilder } from './init-core.js';
11
- import { defaultProposalBuilder as collateralProposalBuilder } from './add-collateral-core.js';
12
3
 
13
- process.env.INTERCHAIN_ISSUER_BOARD_ID =
14
- 'arbitrary value to prevent build error';
4
+ import { createBundles } from '@agoric/internal/src/node/createBundles.js';
5
+ import url from 'url';
15
6
 
16
7
  const dirname = url.fileURLToPath(new URL('.', import.meta.url));
17
- await extractProposalBundles(
18
- [
19
- ['.', defaultProposalBuilder],
20
- ['.', collateralProposalBuilder],
21
- ],
22
- dirname,
23
- );
24
8
 
25
9
  await createBundles(
26
10
  [
27
- ['../src/psm/psm.js', '../bundles/bundle-psm.js'],
11
+ ['@agoric/inter-protocol/src/psm/psm.js', '../bundles/bundle-psm.js'],
28
12
  [
29
- '../src/econCommitteeCharter.js',
13
+ '@agoric/inter-protocol/src/econCommitteeCharter.js',
30
14
  '../bundles/bundle-econCommitteeCharter.js',
31
15
  ],
32
16
  [
33
- '../src/price/fluxAggregatorContract.js',
17
+ '@agoric/inter-protocol/src/price/fluxAggregatorContract.js',
34
18
  '../bundles/bundle-fluxAggregatorKit.js',
35
19
  ],
36
20
  ],
@@ -0,0 +1,84 @@
1
+ export function makeOfferSpecShape(bidBrand: Brand<"nat">, collateralBrand: Brand<"nat">): import("@endo/patterns").Matcher;
2
+ export function prepareAuctionBook(baggage: Baggage, zcf: ZCF, makeRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").MakeRecorderKit): (bidBrand: globalThis.Brand<"nat">, collateralBrand: globalThis.Brand<"nat">, pAuthority: PriceAuthority, node: globalThis.StorageNode) => import("@endo/exo").Guarded<{
3
+ /**
4
+ * @param {Amount<'nat'>} assetAmount
5
+ * @param {ZCFSeat} sourceSeat
6
+ * @param {Amount<'nat'>} [proceedsGoal] an amount that the depositor
7
+ * would like to raise. The auction is requested to not sell more
8
+ * collateral than required to raise that much. The auctioneer might
9
+ * sell more if there is more than one supplier of collateral, and
10
+ * they request inconsistent limits.
11
+ */
12
+ addAssets(assetAmount: Amount<"nat">, sourceSeat: ZCFSeat, proceedsGoal?: import("@agoric/ertp/src/types.js").NatAmount | undefined): void;
13
+ /** @type {(reduction: Ratio) => void} */
14
+ settleAtNewRate(reduction: Ratio): void;
15
+ getCurrentPrice(): Ratio | null;
16
+ hasOrders(): boolean;
17
+ captureOraclePriceForRound(): void;
18
+ setStartingRate(rate: any): void;
19
+ /**
20
+ * @param {OfferSpec} offerSpec
21
+ * @param {ZCFSeat} seat
22
+ * @param {boolean} trySettle
23
+ */
24
+ addOffer(offerSpec: OfferSpec, seat: ZCFSeat, trySettle: boolean): void;
25
+ getSeats(): {
26
+ collateralSeat: ZCFSeat;
27
+ bidHoldingSeat: ZCFSeat;
28
+ };
29
+ exitAllSeats(): void;
30
+ endAuction(): void;
31
+ getDataUpdates(): globalThis.Subscriber<BookDataNotification>;
32
+ getPublicTopics(): {
33
+ bookData: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<BookDataNotification>;
34
+ };
35
+ }>;
36
+ export type OfferSpec = {
37
+ maxBuy: Amount<"nat">;
38
+ } & {
39
+ exitAfterBuy?: boolean;
40
+ } & ({
41
+ offerPrice: Ratio;
42
+ } | {
43
+ offerBidScaling: Ratio;
44
+ });
45
+ export type BookDataNotification = {
46
+ /**
47
+ * identifies the priceAuthority and price
48
+ */
49
+ startPrice: Ratio | null;
50
+ /**
51
+ * the price at the current auction
52
+ * tier
53
+ */
54
+ currentPriceLevel: Ratio | null;
55
+ /**
56
+ * The proceeds the sellers
57
+ * were targeting to raise
58
+ */
59
+ startProceedsGoal: Amount<"nat"> | null;
60
+ /**
61
+ * The remainder of the
62
+ * proceeds the sellers were targeting to raise
63
+ */
64
+ remainingProceedsGoal: Amount<"nat"> | null;
65
+ /**
66
+ * The proceeds raised so
67
+ * far in the auction
68
+ */
69
+ proceedsRaised: Amount<"nat"> | undefined;
70
+ /**
71
+ * How much collateral was available
72
+ * for sale at the start. (If more is deposited later, it'll be added in.)
73
+ */
74
+ startCollateral: Amount<"nat">;
75
+ /**
76
+ * The amount of collateral
77
+ * remaining
78
+ */
79
+ collateralAvailable: Amount<"nat"> | null;
80
+ };
81
+ export type AuctionBook = ReturnType<ReturnType<typeof prepareAuctionBook>>;
82
+ import type { Baggage } from '@agoric/vat-data';
83
+ import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
84
+ //# sourceMappingURL=auctionBook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auctionBook.d.ts","sourceRoot":"","sources":["auctionBook.js"],"names":[],"mappings":"AA8EO,6CAHI,KAAK,CAAC,KAAK,CAAC,mBACZ,KAAK,CAAC,KAAK,CAAC,oCAiBtB;AAwBM,0DAHI,GAAG,mBACH,OAAO,6CAA6C,EAAE,eAAe;IA6YxE;;;;;;;;OAQG;2BAPQ,MAAM,CAAC,KAAK,CAAC,cACb,OAAO;IA6ElB,yCAAyC;+BAAlB,KAAK,GAAK,IAAI;;;;;IA4GrC;;;;OAIG;wBAHQ,SAAS,QACT,OAAO,aACP,OAAO;;;;;;;;;;;GAyFzB;wBA1tBY;IACZ,MAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CACvB,GAAG;IACN,YAAgB,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,CACE;IACR,UAAoB,EAAE,KAAK,CAAC;CACnB,GACD;IACR,eAAyB,EAAE,KAAK,CAAC;CACxB,CACJ;;;;;gBAyBQ,KAAK,GAAG,IAAI;;;;;uBACZ,KAAK,GAAG,IAAI;;;;;uBAEZ,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;;;;2BAEpB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;;;;oBAEpB,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;;;;;qBAEzB,MAAM,CAAC,KAAK,CAAC;;;;;yBAEb,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;0BA8qBpB,UAAU,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;6BA5vBrC,kBAAkB;oCACiD,4BAA4B"}
@@ -1,8 +1,8 @@
1
- import '@agoric/governance/exported.js';
2
- import '@agoric/zoe/exported.js';
3
- import '@agoric/zoe/src/contracts/exported.js';
1
+ /// <reference types="@agoric/internal/exported" />
2
+ /// <reference types="@agoric/governance/exported" />
3
+ /// <reference types="@agoric/zoe/exported" />
4
4
 
5
- import { AmountMath } from '@agoric/ertp';
5
+ import { AmountMath, RatioShape } from '@agoric/ertp';
6
6
  import { mustMatch } from '@agoric/store';
7
7
  import { M, prepareExoClassKit } from '@agoric/vat-data';
8
8
 
@@ -27,6 +27,11 @@ import {
27
27
  priceFrom,
28
28
  } from './util.js';
29
29
 
30
+ /**
31
+ * @import {Baggage} from '@agoric/vat-data';
32
+ * @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
33
+ */
34
+
30
35
  const { Fail } = assert;
31
36
  const { makeEmpty } = AmountMath;
32
37
 
@@ -34,34 +39,38 @@ const DEFAULT_DECIMALS = 9;
34
39
 
35
40
  /**
36
41
  * @file The book represents the collateral-specific state of an ongoing
37
- * auction. It holds the book, the capturedPrice, and the collateralSeat that has
38
- * the allocation of assets for sale.
42
+ * auction. It holds the book, the capturedPrice, and the collateralSeat that
43
+ * has the allocation of assets for sale.
44
+ *
45
+ * The book contains orders for the collateral. It holds two kinds of orders:
39
46
  *
40
- * The book contains orders for the collateral. It holds two kinds of
41
- * orders:
42
47
  * - Prices express the bidding offer in terms of a Bid amount
43
- * - ScaledBids express the offer in terms of a discount (or markup) from the
44
- * most recent oracle price.
48
+ * - ScaledBids express the offer in terms of a discount (or markup) from the most
49
+ * recent oracle price.
45
50
  *
46
- * Offers can be added in three ways. 1) When the auction is not active, prices
47
- * are automatically added to the appropriate collection. When the auction is
48
- * active, 2) if a new offer is at or above the current price, it will be
49
- * settled immediately; 2) If the offer is below the current price, it will be
50
- * added in the appropriate place and settled when the price reaches that level.
51
+ * Offers can be added in three ways. 1) When the auction is not active, prices
52
+ * are automatically added to the appropriate collection. When the auction is
53
+ * active, 2) if a new offer is at or above the current price, it will be
54
+ * settled immediately; 2) If the offer is below the current price, it will be
55
+ * added in the appropriate place and settled when the price reaches that
56
+ * level.
51
57
  */
52
58
 
53
59
  const trace = makeTracer('AucBook', true);
54
60
 
55
61
  /**
56
62
  * @typedef {{
57
- * maxBuy: Amount<'nat'>
63
+ * maxBuy: Amount<'nat'>;
58
64
  * } & {
59
- * exitAfterBuy?: boolean,
60
- * } & ({
61
- * offerPrice: Ratio,
62
- * } | {
63
- * offerBidScaling: Ratio,
64
- * })} OfferSpec
65
+ * exitAfterBuy?: boolean;
66
+ * } & (
67
+ * | {
68
+ * offerPrice: Ratio;
69
+ * }
70
+ * | {
71
+ * offerBidScaling: Ratio;
72
+ * }
73
+ * )} OfferSpec
65
74
  */
66
75
  /**
67
76
  * @param {Brand<'nat'>} bidBrand
@@ -84,21 +93,21 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => {
84
93
  );
85
94
  };
86
95
 
87
- /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
88
-
89
96
  /**
90
97
  * @typedef {object} BookDataNotification
91
- *
92
- * @property {Ratio | null} startPrice identifies the priceAuthority and price
93
- * @property {Ratio | null} currentPriceLevel the price at the current auction tier
94
- * @property {Amount<'nat'> | null} startProceedsGoal The proceeds the sellers were targeting to raise
95
- * @property {Amount<'nat'> | null} remainingProceedsGoal The remainder of
96
- * the proceeds the sellers were targeting to raise
97
- * @property {Amount<'nat'> | undefined} proceedsRaised The proceeds raised so far in the auction
98
- * @property {Amount<'nat'>} startCollateral How much collateral was
99
- * available for sale at the start. (If more is deposited later, it'll be
100
- * added in.)
101
- * @property {Amount<'nat'> | null} collateralAvailable The amount of collateral remaining
98
+ * @property {Ratio | null} startPrice identifies the priceAuthority and price
99
+ * @property {Ratio | null} currentPriceLevel the price at the current auction
100
+ * tier
101
+ * @property {Amount<'nat'> | null} startProceedsGoal The proceeds the sellers
102
+ * were targeting to raise
103
+ * @property {Amount<'nat'> | null} remainingProceedsGoal The remainder of the
104
+ * proceeds the sellers were targeting to raise
105
+ * @property {Amount<'nat'> | undefined} proceedsRaised The proceeds raised so
106
+ * far in the auction
107
+ * @property {Amount<'nat'>} startCollateral How much collateral was available
108
+ * for sale at the start. (If more is deposited later, it'll be added in.)
109
+ * @property {Amount<'nat'> | null} collateralAvailable The amount of collateral
110
+ * remaining
102
111
  */
103
112
 
104
113
  /**
@@ -118,7 +127,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
118
127
  bidHoldingSeat: M.any(),
119
128
  bidAmountShape: M.any(),
120
129
  priceAuthority: M.any(),
121
- updatingOracleQuote: M.any(),
130
+ updatingOracleQuote: M.or(RatioShape, M.null()),
122
131
  bookDataKit: M.any(),
123
132
  priceBook: M.any(),
124
133
  scaledBidBook: M.any(),
@@ -141,11 +150,6 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
141
150
  */
142
151
  (bidBrand, collateralBrand, pAuthority, node) => {
143
152
  assertAllDefined({ bidBrand, collateralBrand, pAuthority });
144
- const zeroBid = makeEmpty(bidBrand);
145
- const zeroRatio = makeRatioFromAmounts(
146
- zeroBid,
147
- AmountMath.make(collateralBrand, 1n),
148
- );
149
153
 
150
154
  // these don't have to be durable, since we're currently assuming that upgrade
151
155
  // from a quiescent state is sufficient. When the auction is quiescent, there
@@ -182,7 +186,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
182
186
  bidAmountShape,
183
187
 
184
188
  priceAuthority: pAuthority,
185
- updatingOracleQuote: zeroRatio,
189
+ updatingOracleQuote: /** @type {Ratio | null} */ (null),
186
190
 
187
191
  bookDataKit,
188
192
 
@@ -231,8 +235,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
231
235
  {
232
236
  helper: {
233
237
  /**
234
- * remove the key from the appropriate book, indicated by whether the price
235
- * is defined.
238
+ * remove the key from the appropriate book, indicated by whether the
239
+ * price is defined.
236
240
  *
237
241
  * @param {string} key
238
242
  * @param {Ratio | undefined} price
@@ -247,8 +251,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
247
251
  },
248
252
 
249
253
  /**
250
- * Update the entry in the appropriate book, indicated by whether the price
251
- * is defined.
254
+ * Update the entry in the appropriate book, indicated by whether the
255
+ * price is defined.
252
256
  *
253
257
  * @param {string} key
254
258
  * @param {Amount} collateralSold
@@ -264,7 +268,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
264
268
  },
265
269
 
266
270
  /**
267
- * Settle with seat. The caller is responsible for updating the book, if any.
271
+ * Settle with seat. The caller is responsible for updating the book, if
272
+ * any.
268
273
  *
269
274
  * @param {ZCFSeat} seat
270
275
  * @param {Amount<'nat'>} collateralWanted
@@ -341,15 +346,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
341
346
  },
342
347
 
343
348
  /**
344
- * Accept an offer expressed as a price. If the auction is active, attempt to
345
- * buy collateral. If any of the offer remains add it to the book.
349
+ * Accept an offer expressed as a price. If the auction is active,
350
+ * attempt to buy collateral. If any of the offer remains add it to the
351
+ * book.
346
352
  *
347
- * @param {ZCFSeat} seat
348
- * @param {Ratio} price
349
- * @param {Amount<'nat'>} maxBuy
350
- * @param {object} opts
351
- * @param {boolean} opts.trySettle
352
- * @param {boolean} [opts.exitAfterBuy]
353
+ * @param {ZCFSeat} seat
354
+ * @param {Ratio} price
355
+ * @param {Amount<'nat'>} maxBuy
356
+ * @param {object} opts
357
+ * @param {boolean} opts.trySettle
358
+ * @param {boolean} [opts.exitAfterBuy]
353
359
  */
354
360
  acceptPriceOffer(
355
361
  seat,
@@ -388,16 +394,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
388
394
  },
389
395
 
390
396
  /**
391
- * Accept an offer expressed as a discount (or markup). If the auction is
392
- * active, attempt to buy collateral. If any of the offer remains add it to
393
- * the book.
397
+ * Accept an offer expressed as a discount (or markup). If the auction
398
+ * is active, attempt to buy collateral. If any of the offer remains add
399
+ * it to the book.
394
400
  *
395
- * @param {ZCFSeat} seat
396
- * @param {Ratio} bidScaling
397
- * @param {Amount<'nat'>} maxBuy
398
- * @param {object} opts
399
- * @param {boolean} opts.trySettle
400
- * @param {boolean} [opts.exitAfterBuy]
401
+ * @param {ZCFSeat} seat
402
+ * @param {Ratio} bidScaling
403
+ * @param {Amount<'nat'>} maxBuy
404
+ * @param {object} opts
405
+ * @param {boolean} opts.trySettle
406
+ * @param {boolean} [opts.exitAfterBuy]
401
407
  */
402
408
  acceptScaledBidOffer(
403
409
  seat,
@@ -460,16 +466,58 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
460
466
  });
461
467
  return state.bookDataKit.recorder.write(bookData);
462
468
  },
469
+ observeQuoteNotifier() {
470
+ const { state, facets } = this;
471
+ const { collateralBrand, bidBrand, priceAuthority } = state;
472
+
473
+ trace('observing');
474
+
475
+ void E.when(
476
+ E(collateralBrand).getDisplayInfo(),
477
+ ({ decimalPlaces = DEFAULT_DECIMALS }) => {
478
+ const quoteNotifier = E(priceAuthority).makeQuoteNotifier(
479
+ AmountMath.make(collateralBrand, 10n ** BigInt(decimalPlaces)),
480
+ bidBrand,
481
+ );
482
+ void observeNotifier(quoteNotifier, {
483
+ updateState: quote => {
484
+ trace(
485
+ `BOOK notifier ${priceFrom(quote).numerator.value}/${
486
+ priceFrom(quote).denominator.value
487
+ }`,
488
+ );
489
+ state.updatingOracleQuote = priceFrom(quote);
490
+ },
491
+ fail: reason => {
492
+ trace(
493
+ `Failure from quoteNotifier (${reason}) setting to null`,
494
+ );
495
+ // lack of quote will trigger restart
496
+ state.updatingOracleQuote = null;
497
+ },
498
+ finish: done => {
499
+ trace(
500
+ `quoteNotifier invoked finish(${done}). setting quote to null`,
501
+ );
502
+ // lack of quote will trigger restart
503
+ state.updatingOracleQuote = null;
504
+ },
505
+ });
506
+ },
507
+ );
508
+
509
+ void facets.helper.publishBookData();
510
+ },
463
511
  },
464
512
  self: {
465
513
  /**
466
514
  * @param {Amount<'nat'>} assetAmount
467
515
  * @param {ZCFSeat} sourceSeat
468
516
  * @param {Amount<'nat'>} [proceedsGoal] an amount that the depositor
469
- * would like to raise. The auction is requested to not sell more
470
- * collateral than required to raise that much. The auctioneer might
471
- * sell more if there is more than one supplier of collateral, and
472
- * they request inconsistent limits.
517
+ * would like to raise. The auction is requested to not sell more
518
+ * collateral than required to raise that much. The auctioneer might
519
+ * sell more if there is more than one supplier of collateral, and
520
+ * they request inconsistent limits.
473
521
  */
474
522
  addAssets(assetAmount, sourceSeat, proceedsGoal) {
475
523
  const { state, facets } = this;
@@ -547,9 +595,12 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
547
595
 
548
596
  trace(this.state.collateralBrand, 'settleAtNewRate', reduction);
549
597
  const { capturedPriceForRound, priceBook, scaledBidBook } = state;
550
- capturedPriceForRound !== null ||
551
- Fail`price must be captured before auction starts`;
552
- assert(capturedPriceForRound);
598
+ if (!capturedPriceForRound) {
599
+ console.error(
600
+ `⚠️No price for ${this.state.collateralBrand}, skipping auction.`,
601
+ );
602
+ return;
603
+ }
553
604
 
554
605
  state.curAuctionPrice = multiplyRatios(
555
606
  reduction,
@@ -619,6 +670,12 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
619
670
  const { facets, state } = this;
620
671
 
621
672
  trace(`capturing oracle price `, state.updatingOracleQuote);
673
+ if (!state.updatingOracleQuote) {
674
+ // if the price has feed has died, try restarting it.
675
+ facets.helper.observeQuoteNotifier();
676
+ return;
677
+ }
678
+
622
679
  state.capturedPriceForRound = state.updatingOracleQuote;
623
680
  void facets.helper.publishBookData();
624
681
  },
@@ -718,43 +775,18 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
718
775
  finish: ({ state, facets }) => {
719
776
  const { collateralBrand, bidBrand, priceAuthority } = state;
720
777
  assertAllDefined({ collateralBrand, bidBrand, priceAuthority });
721
- void E.when(
722
- E(collateralBrand).getDisplayInfo(),
723
- ({ decimalPlaces = DEFAULT_DECIMALS }) => {
724
- // TODO(#6946) use this to keep a current price that can be published in state.
725
- const quoteNotifier = E(priceAuthority).makeQuoteNotifier(
726
- AmountMath.make(collateralBrand, 10n ** BigInt(decimalPlaces)),
727
- bidBrand,
728
- );
729
- void observeNotifier(quoteNotifier, {
730
- updateState: quote => {
731
- trace(
732
- `BOOK notifier ${priceFrom(quote).numerator.value}/${
733
- priceFrom(quote).denominator.value
734
- }`,
735
- );
736
- state.updatingOracleQuote = priceFrom(quote);
737
- },
738
- fail: reason => {
739
- throw Error(
740
- `auction observer of ${collateralBrand} failed: ${reason}`,
741
- );
742
- },
743
- finish: done => {
744
- throw Error(
745
- `auction observer for ${collateralBrand} died: ${done}`,
746
- );
747
- },
748
- });
749
- },
750
- );
751
- void facets.helper.publishBookData();
778
+
779
+ facets.helper.observeQuoteNotifier();
752
780
  },
753
781
  stateShape: AuctionBookStateShape,
754
782
  },
755
783
  );
756
784
 
757
- /** @type {(...args: Parameters<typeof makeAuctionBookKit>) => ReturnType<typeof makeAuctionBookKit>['self']} */
785
+ /**
786
+ * @type {(
787
+ * ...args: Parameters<typeof makeAuctionBookKit>
788
+ * ) => ReturnType<typeof makeAuctionBookKit>['self']}
789
+ */
758
790
  const makeAuctionBook = (...args) => makeAuctionBookKit(...args).self;
759
791
  return makeAuctionBook;
760
792
  };