@agoric/inter-protocol 0.16.2-mainnet1B-dev-26244e8.0 → 0.16.2-orchestration-dev-096c4e8.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 (163) hide show
  1. package/package.json +37 -30
  2. package/scripts/build-bundles.js +5 -21
  3. package/src/auction/auctionBook.d.ts +83 -0
  4. package/src/auction/auctionBook.d.ts.map +1 -0
  5. package/src/auction/auctionBook.js +127 -98
  6. package/src/auction/auctioneer.d.ts +75 -0
  7. package/src/auction/auctioneer.d.ts.map +1 -0
  8. package/src/auction/auctioneer.js +56 -44
  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 +12 -11
  12. package/src/auction/params.d.ts +142 -0
  13. package/src/auction/params.d.ts.map +1 -0
  14. package/src/auction/params.js +5 -7
  15. package/src/auction/scheduleMath.d.ts +4 -0
  16. package/src/auction/scheduleMath.d.ts.map +1 -0
  17. package/src/auction/scheduleMath.js +14 -14
  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 +8 -7
  24. package/src/auction/util.d.ts +30 -0
  25. package/src/auction/util.d.ts.map +1 -0
  26. package/src/auction/util.js +4 -4
  27. package/src/clientSupport.d.ts +167 -0
  28. package/src/clientSupport.d.ts.map +1 -0
  29. package/src/clientSupport.js +154 -96
  30. package/src/collectFees.d.ts +2 -0
  31. package/src/collectFees.d.ts.map +1 -0
  32. package/src/contractSupport.d.ts +33 -0
  33. package/src/contractSupport.d.ts.map +1 -0
  34. package/src/contractSupport.js +5 -5
  35. package/src/econCommitteeCharter.d.ts +33 -0
  36. package/src/econCommitteeCharter.d.ts.map +1 -0
  37. package/src/econCommitteeCharter.js +18 -17
  38. package/src/feeDistributor.d.ts +212 -0
  39. package/src/feeDistributor.d.ts.map +1 -0
  40. package/src/feeDistributor.js +36 -35
  41. package/src/index.d.ts +2 -0
  42. package/src/index.d.ts.map +1 -0
  43. package/src/interest-math.d.ts +3 -0
  44. package/src/interest-math.d.ts.map +1 -0
  45. package/src/interest.d.ts +29 -0
  46. package/src/interest.d.ts.map +1 -0
  47. package/src/interest.js +22 -16
  48. package/src/price/README.md +13 -0
  49. package/src/price/fluxAggregatorContract.d.ts +67 -0
  50. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  51. package/src/price/fluxAggregatorContract.js +61 -54
  52. package/src/price/fluxAggregatorKit.d.ts +133 -0
  53. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  54. package/src/price/fluxAggregatorKit.js +51 -36
  55. package/src/price/priceOracleKit.d.ts +38 -0
  56. package/src/price/priceOracleKit.d.ts.map +1 -0
  57. package/src/price/priceOracleKit.js +11 -13
  58. package/src/price/roundsManager.d.ts +202 -0
  59. package/src/price/roundsManager.d.ts.map +1 -0
  60. package/src/price/roundsManager.js +77 -81
  61. package/src/proposals/addAssetToVault.d.ts +160 -0
  62. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  63. package/src/proposals/addAssetToVault.js +170 -36
  64. package/src/proposals/committee-proposal.d.ts +113 -0
  65. package/src/proposals/committee-proposal.d.ts.map +1 -0
  66. package/src/proposals/committee-proposal.js +25 -31
  67. package/src/proposals/core-proposal.d.ts +149 -0
  68. package/src/proposals/core-proposal.d.ts.map +1 -0
  69. package/src/proposals/core-proposal.js +7 -7
  70. package/src/proposals/econ-behaviors.d.ts +201 -0
  71. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  72. package/src/proposals/econ-behaviors.js +58 -34
  73. package/src/proposals/price-feed-proposal.d.ts +82 -0
  74. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  75. package/src/proposals/price-feed-proposal.js +72 -37
  76. package/src/proposals/startEconCommittee.d.ts +34 -0
  77. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  78. package/src/proposals/startEconCommittee.js +2 -2
  79. package/src/proposals/startPSM.d.ts +61 -0
  80. package/src/proposals/startPSM.d.ts.map +1 -0
  81. package/src/proposals/startPSM.js +32 -23
  82. package/src/proposals/utils.d.ts +17 -0
  83. package/src/proposals/utils.d.ts.map +1 -0
  84. package/src/proposals/utils.js +32 -7
  85. package/src/provisionPool.d.ts +165 -0
  86. package/src/provisionPool.d.ts.map +1 -0
  87. package/src/provisionPool.js +119 -0
  88. package/src/provisionPoolKit.d.ts +362 -0
  89. package/src/provisionPoolKit.d.ts.map +1 -0
  90. package/src/provisionPoolKit.js +461 -0
  91. package/src/psm/psm.d.ts +123 -0
  92. package/src/psm/psm.d.ts.map +1 -0
  93. package/src/psm/psm.js +69 -63
  94. package/src/psm/types.d.ts +2 -0
  95. package/src/psm/types.d.ts.map +1 -0
  96. package/src/psm/types.js +1 -1
  97. package/src/reserve/assetReserve.d.ts +44 -0
  98. package/src/reserve/assetReserve.d.ts.map +1 -0
  99. package/src/reserve/assetReserve.js +27 -18
  100. package/src/reserve/assetReserveKit.d.ts +69 -0
  101. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  102. package/src/reserve/assetReserveKit.js +14 -22
  103. package/src/reserve/params.d.ts +10 -0
  104. package/src/reserve/params.d.ts.map +1 -0
  105. package/src/tokens.d.ts +3 -0
  106. package/src/tokens.d.ts.map +1 -0
  107. package/src/tokens.js +5 -0
  108. package/src/vaultFactory/burn.d.ts +2 -0
  109. package/src/vaultFactory/burn.d.ts.map +1 -0
  110. package/src/vaultFactory/liquidation.d.ts +24 -0
  111. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  112. package/src/vaultFactory/liquidation.js +35 -22
  113. package/src/vaultFactory/math.d.ts +10 -0
  114. package/src/vaultFactory/math.d.ts.map +1 -0
  115. package/src/vaultFactory/math.js +8 -9
  116. package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
  117. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  118. package/src/vaultFactory/orderedVaultStore.js +8 -11
  119. package/src/vaultFactory/params.d.ts +159 -0
  120. package/src/vaultFactory/params.d.ts.map +1 -0
  121. package/src/vaultFactory/params.js +25 -19
  122. package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
  123. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  124. package/src/vaultFactory/prioritizedVaults.js +3 -3
  125. package/src/vaultFactory/proceeds.d.ts +34 -0
  126. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  127. package/src/vaultFactory/proceeds.js +24 -18
  128. package/src/vaultFactory/storeUtils.d.ts +25 -0
  129. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  130. package/src/vaultFactory/storeUtils.js +8 -12
  131. package/src/vaultFactory/type-imports.d.ts +2 -0
  132. package/src/vaultFactory/type-imports.d.ts.map +1 -0
  133. package/src/vaultFactory/type-imports.js +1 -1
  134. package/src/vaultFactory/types.d.ts +137 -0
  135. package/src/vaultFactory/types.d.ts.map +1 -0
  136. package/src/vaultFactory/types.js +47 -37
  137. package/src/vaultFactory/vault.d.ts +336 -0
  138. package/src/vaultFactory/vault.d.ts.map +1 -0
  139. package/src/vaultFactory/vault.js +89 -90
  140. package/src/vaultFactory/vaultDirector.d.ts +311 -0
  141. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  142. package/src/vaultFactory/vaultDirector.js +36 -45
  143. package/src/vaultFactory/vaultFactory.d.ts +162 -0
  144. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  145. package/src/vaultFactory/vaultFactory.js +33 -26
  146. package/src/vaultFactory/vaultHolder.d.ts +126 -0
  147. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  148. package/src/vaultFactory/vaultHolder.js +8 -13
  149. package/src/vaultFactory/vaultKit.d.ts +32 -0
  150. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  151. package/src/vaultFactory/vaultKit.js +3 -2
  152. package/src/vaultFactory/vaultManager.d.ts +357 -0
  153. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  154. package/src/vaultFactory/vaultManager.js +236 -145
  155. package/CHANGELOG.md +0 -1057
  156. package/scripts/add-collateral-core.js +0 -112
  157. package/scripts/deploy-contracts.js +0 -100
  158. package/scripts/init-core.js +0 -198
  159. package/scripts/invite-committee-core.js +0 -42
  160. package/scripts/manual-price-feed.js +0 -117
  161. package/scripts/price-feed-core.js +0 -104
  162. package/scripts/start-local-chain.sh +0 -84
  163. package/src/typeGuards.js +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/inter-protocol",
3
- "version": "0.16.2-mainnet1B-dev-26244e8.0+26244e8",
3
+ "version": "0.16.2-orchestration-dev-096c4e8.0+096c4e8",
4
4
  "description": "Core cryptoeconomy contracts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -10,13 +10,15 @@
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*' src/types.js",
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,40 +31,40 @@
29
31
  },
30
32
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
31
33
  "dependencies": {
32
- "@agoric/assert": "0.6.1-mainnet1B-dev-26244e8.0+26244e8",
33
- "@agoric/ertp": "0.16.3-mainnet1B-dev-26244e8.0+26244e8",
34
- "@agoric/governance": "0.10.4-mainnet1B-dev-26244e8.0+26244e8",
35
- "@agoric/internal": "0.4.0-mainnet1B-dev-26244e8.0+26244e8",
36
- "@agoric/notifier": "0.6.3-mainnet1B-dev-26244e8.0+26244e8",
37
- "@agoric/store": "0.9.3-mainnet1B-dev-26244e8.0+26244e8",
38
- "@agoric/time": "0.3.3-mainnet1B-dev-26244e8.0+26244e8",
39
- "@agoric/vat-data": "0.5.3-mainnet1B-dev-26244e8.0+26244e8",
40
- "@agoric/vats": "0.15.2-mainnet1B-dev-26244e8.0+26244e8",
41
- "@agoric/zoe": "0.26.3-mainnet1B-dev-26244e8.0+26244e8",
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
- "agoric": "0.21.2-mainnet1B-dev-26244e8.0+26244e8",
34
+ "@agoric/assert": "0.6.1-orchestration-dev-096c4e8.0+096c4e8",
35
+ "@agoric/ertp": "0.16.3-orchestration-dev-096c4e8.0+096c4e8",
36
+ "@agoric/governance": "0.10.4-orchestration-dev-096c4e8.0+096c4e8",
37
+ "@agoric/internal": "0.3.3-orchestration-dev-096c4e8.0+096c4e8",
38
+ "@agoric/notifier": "0.6.3-orchestration-dev-096c4e8.0+096c4e8",
39
+ "@agoric/store": "0.9.3-orchestration-dev-096c4e8.0+096c4e8",
40
+ "@agoric/time": "0.3.3-orchestration-dev-096c4e8.0+096c4e8",
41
+ "@agoric/vat-data": "0.5.3-orchestration-dev-096c4e8.0+096c4e8",
42
+ "@agoric/vats": "0.15.2-orchestration-dev-096c4e8.0+096c4e8",
43
+ "@agoric/zoe": "0.26.3-orchestration-dev-096c4e8.0+096c4e8",
44
+ "@endo/captp": "^4.0.4",
45
+ "@endo/eventual-send": "^1.1.2",
46
+ "@endo/far": "^1.0.4",
47
+ "@endo/marshal": "^1.3.0",
48
+ "@endo/nat": "^5.0.4",
49
+ "@endo/promise-kit": "^1.0.4",
48
50
  "jessie.js": "^0.3.2"
49
51
  },
50
52
  "devDependencies": {
51
- "@agoric/deploy-script-support": "0.10.4-mainnet1B-dev-26244e8.0+26244e8",
52
- "@agoric/smart-wallet": "0.5.4-mainnet1B-dev-26244e8.0+26244e8",
53
- "@agoric/swingset-liveslots": "0.10.3-mainnet1B-dev-26244e8.0+26244e8",
54
- "@agoric/swingset-vat": "0.32.3-mainnet1B-dev-26244e8.0+26244e8",
55
- "@endo/bundle-source": "2.5.2-upstream-rollup",
56
- "@endo/init": "0.5.56",
57
- "@endo/promise-kit": "0.2.56",
58
- "@fast-check/ava": "^1.1.3",
59
- "ava": "^5.2.0",
53
+ "@agoric/smart-wallet": "0.5.4-orchestration-dev-096c4e8.0+096c4e8",
54
+ "@agoric/swingset-liveslots": "0.10.3-orchestration-dev-096c4e8.0+096c4e8",
55
+ "@agoric/swingset-vat": "0.32.3-orchestration-dev-096c4e8.0+096c4e8",
56
+ "@agoric/zone": "0.2.3-orchestration-dev-096c4e8.0+096c4e8",
57
+ "@endo/bundle-source": "^3.1.0",
58
+ "@endo/init": "^1.0.4",
59
+ "@endo/promise-kit": "^1.0.4",
60
+ "@fast-check/ava": "^1.1.5",
61
+ "ava": "^5.3.0",
60
62
  "c8": "^7.13.0",
61
63
  "deep-object-diff": "^1.1.9",
62
64
  "import-meta-resolve": "^2.2.1"
63
65
  },
64
66
  "files": [
65
- "scripts/",
67
+ "scripts",
66
68
  "src/",
67
69
  "exported.js",
68
70
  "NEWS.md"
@@ -71,12 +73,17 @@
71
73
  "files": [
72
74
  "test/**/test-*.js"
73
75
  ],
74
- "concurrency": 2,
76
+ "require": [
77
+ "@endo/init/debug.js"
78
+ ],
75
79
  "workerThreads": false,
76
80
  "timeout": "10m"
77
81
  },
78
82
  "publishConfig": {
79
83
  "access": "public"
80
84
  },
81
- "gitHead": "26244e821f1a83cd5868f0c7d54aa480c8c17e5e"
85
+ "typeCoverage": {
86
+ "atLeast": 95.77
87
+ },
88
+ "gitHead": "096c4e8fce80e9a509b0e1a30fda11736c4570e1"
82
89
  }
@@ -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,83 @@
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: Brand<"nat">, collateralBrand: Brand<"nat">, pAuthority: PriceAuthority, node: StorageNode) => import("@endo/exo/src/exo-makers.js").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?: Amount<"nat"> | 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(): 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 Baggage = import('@agoric/vat-data').Baggage;
46
+ export type BookDataNotification = {
47
+ /**
48
+ * identifies the priceAuthority and price
49
+ */
50
+ startPrice: Ratio | null;
51
+ /**
52
+ * the price at the current auction
53
+ * tier
54
+ */
55
+ currentPriceLevel: Ratio | null;
56
+ /**
57
+ * The proceeds the sellers
58
+ * were targeting to raise
59
+ */
60
+ startProceedsGoal: Amount<'nat'> | null;
61
+ /**
62
+ * The remainder of the
63
+ * proceeds the sellers were targeting to raise
64
+ */
65
+ remainingProceedsGoal: Amount<'nat'> | null;
66
+ /**
67
+ * The proceeds raised so
68
+ * far in the auction
69
+ */
70
+ proceedsRaised: Amount<'nat'> | undefined;
71
+ /**
72
+ * How much collateral was available
73
+ * for sale at the start. (If more is deposited later, it'll be added in.)
74
+ */
75
+ startCollateral: Amount<'nat'>;
76
+ /**
77
+ * The amount of collateral
78
+ * remaining
79
+ */
80
+ collateralAvailable: Amount<'nat'> | null;
81
+ };
82
+ export type AuctionBook = ReturnType<ReturnType<typeof prepareAuctionBook>>;
83
+ //# sourceMappingURL=auctionBook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auctionBook.d.ts","sourceRoot":"","sources":["auctionBook.js"],"names":[],"mappings":"AAyEO,6CAHI,MAAM,KAAK,CAAC,mBACZ,MAAM,KAAK,CAAC,oCAiBtB;AA0BM,4CAJI,OAAO,OACP,GAAG,mBACH,OAAO,6CAA6C,EAAE,eAAe;IA6YxE;;;;;;;;OAQG;2BAPQ,OAAO,KAAK,CAAC,cACb,OAAO;IA6ElB,yCAAyC;+BAAlB,KAAK,GAAK,IAAI;;;;;IA4GrC;;;;OAIG;wBAHQ,SAAS,QACT,OAAO,aACP,OAAO;;;;;;;;;;;GAyFzB;wBA5tBY;IACZ,MAAU,EAAE,OAAO,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;sBAuBQ,OAAO,kBAAkB,EAAE,OAAO;;;;;gBAIlC,KAAK,GAAG,IAAI;;;;;uBACZ,KAAK,GAAG,IAAI;;;;;uBAEZ,OAAO,KAAK,CAAC,GAAG,IAAI;;;;;2BAEpB,OAAO,KAAK,CAAC,GAAG,IAAI;;;;;oBAEpB,OAAO,KAAK,CAAC,GAAG,SAAS;;;;;qBAEzB,OAAO,KAAK,CAAC;;;;;yBAEb,OAAO,KAAK,CAAC,GAAG,IAAI;;0BA8qBpB,WAAW,WAAW,yBAAyB,CAAC,CAAC"}
@@ -2,7 +2,7 @@ import '@agoric/governance/exported.js';
2
2
  import '@agoric/zoe/exported.js';
3
3
  import '@agoric/zoe/src/contracts/exported.js';
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
 
@@ -34,34 +34,38 @@ const DEFAULT_DECIMALS = 9;
34
34
 
35
35
  /**
36
36
  * @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.
37
+ * auction. It holds the book, the capturedPrice, and the collateralSeat that
38
+ * has the allocation of assets for sale.
39
+ *
40
+ * The book contains orders for the collateral. It holds two kinds of orders:
39
41
  *
40
- * The book contains orders for the collateral. It holds two kinds of
41
- * orders:
42
42
  * - 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.
43
+ * - ScaledBids express the offer in terms of a discount (or markup) from the most
44
+ * recent oracle price.
45
45
  *
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.
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
51
+ * level.
51
52
  */
52
53
 
53
54
  const trace = makeTracer('AucBook', true);
54
55
 
55
56
  /**
56
57
  * @typedef {{
57
- * maxBuy: Amount<'nat'>
58
+ * maxBuy: Amount<'nat'>;
58
59
  * } & {
59
- * exitAfterBuy?: boolean,
60
- * } & ({
61
- * offerPrice: Ratio,
62
- * } | {
63
- * offerBidScaling: Ratio,
64
- * })} OfferSpec
60
+ * exitAfterBuy?: boolean;
61
+ * } & (
62
+ * | {
63
+ * offerPrice: Ratio;
64
+ * }
65
+ * | {
66
+ * offerBidScaling: Ratio;
67
+ * }
68
+ * )} OfferSpec
65
69
  */
66
70
  /**
67
71
  * @param {Brand<'nat'>} bidBrand
@@ -88,17 +92,19 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => {
88
92
 
89
93
  /**
90
94
  * @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
95
+ * @property {Ratio | null} startPrice identifies the priceAuthority and price
96
+ * @property {Ratio | null} currentPriceLevel the price at the current auction
97
+ * tier
98
+ * @property {Amount<'nat'> | null} startProceedsGoal The proceeds the sellers
99
+ * were targeting to raise
100
+ * @property {Amount<'nat'> | null} remainingProceedsGoal The remainder of the
101
+ * proceeds the sellers were targeting to raise
102
+ * @property {Amount<'nat'> | undefined} proceedsRaised The proceeds raised so
103
+ * far in the auction
104
+ * @property {Amount<'nat'>} startCollateral How much collateral was available
105
+ * for sale at the start. (If more is deposited later, it'll be added in.)
106
+ * @property {Amount<'nat'> | null} collateralAvailable The amount of collateral
107
+ * remaining
102
108
  */
103
109
 
104
110
  /**
@@ -118,7 +124,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
118
124
  bidHoldingSeat: M.any(),
119
125
  bidAmountShape: M.any(),
120
126
  priceAuthority: M.any(),
121
- updatingOracleQuote: M.any(),
127
+ updatingOracleQuote: M.or(RatioShape, M.null()),
122
128
  bookDataKit: M.any(),
123
129
  priceBook: M.any(),
124
130
  scaledBidBook: M.any(),
@@ -141,11 +147,6 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
141
147
  */
142
148
  (bidBrand, collateralBrand, pAuthority, node) => {
143
149
  assertAllDefined({ bidBrand, collateralBrand, pAuthority });
144
- const zeroBid = makeEmpty(bidBrand);
145
- const zeroRatio = makeRatioFromAmounts(
146
- zeroBid,
147
- AmountMath.make(collateralBrand, 1n),
148
- );
149
150
 
150
151
  // these don't have to be durable, since we're currently assuming that upgrade
151
152
  // from a quiescent state is sufficient. When the auction is quiescent, there
@@ -182,7 +183,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
182
183
  bidAmountShape,
183
184
 
184
185
  priceAuthority: pAuthority,
185
- updatingOracleQuote: zeroRatio,
186
+ updatingOracleQuote: /** @type {Ratio | null} */ (null),
186
187
 
187
188
  bookDataKit,
188
189
 
@@ -231,8 +232,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
231
232
  {
232
233
  helper: {
233
234
  /**
234
- * remove the key from the appropriate book, indicated by whether the price
235
- * is defined.
235
+ * remove the key from the appropriate book, indicated by whether the
236
+ * price is defined.
236
237
  *
237
238
  * @param {string} key
238
239
  * @param {Ratio | undefined} price
@@ -247,8 +248,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
247
248
  },
248
249
 
249
250
  /**
250
- * Update the entry in the appropriate book, indicated by whether the price
251
- * is defined.
251
+ * Update the entry in the appropriate book, indicated by whether the
252
+ * price is defined.
252
253
  *
253
254
  * @param {string} key
254
255
  * @param {Amount} collateralSold
@@ -264,7 +265,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
264
265
  },
265
266
 
266
267
  /**
267
- * Settle with seat. The caller is responsible for updating the book, if any.
268
+ * Settle with seat. The caller is responsible for updating the book, if
269
+ * any.
268
270
  *
269
271
  * @param {ZCFSeat} seat
270
272
  * @param {Amount<'nat'>} collateralWanted
@@ -341,15 +343,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
341
343
  },
342
344
 
343
345
  /**
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.
346
+ * Accept an offer expressed as a price. If the auction is active,
347
+ * attempt to buy collateral. If any of the offer remains add it to the
348
+ * book.
346
349
  *
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]
350
+ * @param {ZCFSeat} seat
351
+ * @param {Ratio} price
352
+ * @param {Amount<'nat'>} maxBuy
353
+ * @param {object} opts
354
+ * @param {boolean} opts.trySettle
355
+ * @param {boolean} [opts.exitAfterBuy]
353
356
  */
354
357
  acceptPriceOffer(
355
358
  seat,
@@ -388,16 +391,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
388
391
  },
389
392
 
390
393
  /**
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.
394
+ * Accept an offer expressed as a discount (or markup). If the auction
395
+ * is active, attempt to buy collateral. If any of the offer remains add
396
+ * it to the book.
394
397
  *
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]
398
+ * @param {ZCFSeat} seat
399
+ * @param {Ratio} bidScaling
400
+ * @param {Amount<'nat'>} maxBuy
401
+ * @param {object} opts
402
+ * @param {boolean} opts.trySettle
403
+ * @param {boolean} [opts.exitAfterBuy]
401
404
  */
402
405
  acceptScaledBidOffer(
403
406
  seat,
@@ -460,16 +463,58 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
460
463
  });
461
464
  return state.bookDataKit.recorder.write(bookData);
462
465
  },
466
+ observeQuoteNotifier() {
467
+ const { state, facets } = this;
468
+ const { collateralBrand, bidBrand, priceAuthority } = state;
469
+
470
+ trace('observing');
471
+
472
+ void E.when(
473
+ E(collateralBrand).getDisplayInfo(),
474
+ ({ decimalPlaces = DEFAULT_DECIMALS }) => {
475
+ const quoteNotifier = E(priceAuthority).makeQuoteNotifier(
476
+ AmountMath.make(collateralBrand, 10n ** BigInt(decimalPlaces)),
477
+ bidBrand,
478
+ );
479
+ void observeNotifier(quoteNotifier, {
480
+ updateState: quote => {
481
+ trace(
482
+ `BOOK notifier ${priceFrom(quote).numerator.value}/${
483
+ priceFrom(quote).denominator.value
484
+ }`,
485
+ );
486
+ state.updatingOracleQuote = priceFrom(quote);
487
+ },
488
+ fail: reason => {
489
+ trace(
490
+ `Failure from quoteNotifier (${reason}) setting to null`,
491
+ );
492
+ // lack of quote will trigger restart
493
+ state.updatingOracleQuote = null;
494
+ },
495
+ finish: done => {
496
+ trace(
497
+ `quoteNotifier invoked finish(${done}). setting quote to null`,
498
+ );
499
+ // lack of quote will trigger restart
500
+ state.updatingOracleQuote = null;
501
+ },
502
+ });
503
+ },
504
+ );
505
+
506
+ void facets.helper.publishBookData();
507
+ },
463
508
  },
464
509
  self: {
465
510
  /**
466
511
  * @param {Amount<'nat'>} assetAmount
467
512
  * @param {ZCFSeat} sourceSeat
468
513
  * @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.
514
+ * would like to raise. The auction is requested to not sell more
515
+ * collateral than required to raise that much. The auctioneer might
516
+ * sell more if there is more than one supplier of collateral, and
517
+ * they request inconsistent limits.
473
518
  */
474
519
  addAssets(assetAmount, sourceSeat, proceedsGoal) {
475
520
  const { state, facets } = this;
@@ -547,9 +592,12 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
547
592
 
548
593
  trace(this.state.collateralBrand, 'settleAtNewRate', reduction);
549
594
  const { capturedPriceForRound, priceBook, scaledBidBook } = state;
550
- capturedPriceForRound !== null ||
551
- Fail`price must be captured before auction starts`;
552
- assert(capturedPriceForRound);
595
+ if (!capturedPriceForRound) {
596
+ console.error(
597
+ `⚠️No price for ${this.state.collateralBrand}, skipping auction.`,
598
+ );
599
+ return;
600
+ }
553
601
 
554
602
  state.curAuctionPrice = multiplyRatios(
555
603
  reduction,
@@ -619,6 +667,12 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
619
667
  const { facets, state } = this;
620
668
 
621
669
  trace(`capturing oracle price `, state.updatingOracleQuote);
670
+ if (!state.updatingOracleQuote) {
671
+ // if the price has feed has died, try restarting it.
672
+ facets.helper.observeQuoteNotifier();
673
+ return;
674
+ }
675
+
622
676
  state.capturedPriceForRound = state.updatingOracleQuote;
623
677
  void facets.helper.publishBookData();
624
678
  },
@@ -718,43 +772,18 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
718
772
  finish: ({ state, facets }) => {
719
773
  const { collateralBrand, bidBrand, priceAuthority } = state;
720
774
  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();
775
+
776
+ facets.helper.observeQuoteNotifier();
752
777
  },
753
778
  stateShape: AuctionBookStateShape,
754
779
  },
755
780
  );
756
781
 
757
- /** @type {(...args: Parameters<typeof makeAuctionBookKit>) => ReturnType<typeof makeAuctionBookKit>['self']} */
782
+ /**
783
+ * @type {(
784
+ * ...args: Parameters<typeof makeAuctionBookKit>
785
+ * ) => ReturnType<typeof makeAuctionBookKit>['self']}
786
+ */
758
787
  const makeAuctionBook = (...args) => makeAuctionBookKit(...args).self;
759
788
  return makeAuctionBook;
760
789
  };