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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +6 -6
  2. package/package.json +46 -39
  3. package/scripts/build-bundles.js +5 -21
  4. package/src/auction/auctionBook.d.ts +147 -0
  5. package/src/auction/auctionBook.d.ts.map +1 -0
  6. package/src/auction/auctionBook.js +182 -151
  7. package/src/auction/auctionMath.d.ts +17 -0
  8. package/src/auction/auctionMath.d.ts.map +1 -0
  9. package/src/auction/auctionMath.js +81 -0
  10. package/src/auction/auctioneer.d.ts +70 -0
  11. package/src/auction/auctioneer.d.ts.map +1 -0
  12. package/src/auction/auctioneer.js +72 -59
  13. package/src/auction/offerBook.d.ts +46 -0
  14. package/src/auction/offerBook.d.ts.map +1 -0
  15. package/src/auction/offerBook.js +17 -12
  16. package/src/auction/params.d.ts +145 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/params.js +11 -9
  19. package/src/auction/scheduleMath.d.ts +5 -0
  20. package/src/auction/scheduleMath.d.ts.map +1 -0
  21. package/src/auction/scheduleMath.js +18 -16
  22. package/src/auction/scheduler.d.ts +50 -0
  23. package/src/auction/scheduler.d.ts.map +1 -0
  24. package/src/auction/scheduler.js +53 -47
  25. package/src/auction/sortedOffers.d.ts +8 -0
  26. package/src/auction/sortedOffers.d.ts.map +1 -0
  27. package/src/auction/sortedOffers.js +10 -9
  28. package/src/auction/util.d.ts +31 -0
  29. package/src/auction/util.d.ts.map +1 -0
  30. package/src/auction/util.js +12 -6
  31. package/src/clientSupport.d.ts +168 -0
  32. package/src/clientSupport.d.ts.map +1 -0
  33. package/src/clientSupport.js +161 -98
  34. package/src/collectFees.d.ts +2 -0
  35. package/src/collectFees.d.ts.map +1 -0
  36. package/src/contractSupport.d.ts +28 -0
  37. package/src/contractSupport.d.ts.map +1 -0
  38. package/src/contractSupport.js +19 -13
  39. package/src/econCommitteeCharter.d.ts +43 -0
  40. package/src/econCommitteeCharter.d.ts.map +1 -0
  41. package/src/econCommitteeCharter.js +25 -20
  42. package/src/feeDistributor.d.ts +224 -0
  43. package/src/feeDistributor.d.ts.map +1 -0
  44. package/src/feeDistributor.js +41 -33
  45. package/src/index.d.ts +2 -0
  46. package/src/index.d.ts.map +1 -0
  47. package/src/index.js +1 -0
  48. package/src/interest-math.d.ts +4 -0
  49. package/src/interest-math.d.ts.map +1 -0
  50. package/src/interest-math.js +5 -1
  51. package/src/interest.d.ts +30 -0
  52. package/src/interest.d.ts.map +1 -0
  53. package/src/interest.js +25 -23
  54. package/src/price/README.md +14 -1
  55. package/src/price/fluxAggregatorContract.d.ts +71 -0
  56. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  57. package/src/price/fluxAggregatorContract.js +64 -55
  58. package/src/price/fluxAggregatorKit.d.ts +104 -0
  59. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  60. package/src/price/fluxAggregatorKit.js +55 -42
  61. package/src/price/priceOracleKit.d.ts +39 -0
  62. package/src/price/priceOracleKit.d.ts.map +1 -0
  63. package/src/price/priceOracleKit.js +17 -15
  64. package/src/price/roundsManager.d.ts +204 -0
  65. package/src/price/roundsManager.d.ts.map +1 -0
  66. package/src/price/roundsManager.js +132 -85
  67. package/src/proposals/README.md +2 -3
  68. package/src/proposals/add-auction.js +285 -0
  69. package/src/proposals/addAssetToVault.js +192 -40
  70. package/src/proposals/committee-proposal.js +25 -31
  71. package/src/proposals/core-proposal.js +9 -11
  72. package/src/proposals/deploy-price-feeds.js +341 -0
  73. package/src/proposals/econ-behaviors.js +84 -49
  74. package/src/proposals/price-feed-proposal.js +109 -51
  75. package/src/proposals/replace-fee-distributor.js +198 -0
  76. package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
  77. package/src/proposals/replaceElectorate.js +610 -0
  78. package/src/proposals/startEconCommittee.js +2 -2
  79. package/src/proposals/startPSM.js +44 -29
  80. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  81. package/src/proposals/upgrade-vaults.js +207 -0
  82. package/src/proposals/utils.d.ts +21 -0
  83. package/src/proposals/utils.d.ts.map +1 -0
  84. package/src/proposals/utils.js +66 -9
  85. package/src/proposals/withdraw-reserve-proposal.js +63 -0
  86. package/src/provisionPool.d.ts +69 -0
  87. package/src/provisionPool.d.ts.map +1 -0
  88. package/src/provisionPool.js +138 -0
  89. package/src/provisionPoolKit.d.ts +129 -0
  90. package/src/provisionPoolKit.d.ts.map +1 -0
  91. package/src/provisionPoolKit.js +608 -0
  92. package/src/psm/psm.d.ts +133 -0
  93. package/src/psm/psm.d.ts.map +1 -0
  94. package/src/psm/psm.js +85 -79
  95. package/src/psm/types-ambient.d.ts +2 -0
  96. package/src/psm/types-ambient.d.ts.map +1 -0
  97. package/src/psm/types-ambient.js +3 -0
  98. package/src/reserve/assetReserve.d.ts +58 -0
  99. package/src/reserve/assetReserve.d.ts.map +1 -0
  100. package/src/reserve/assetReserve.js +42 -34
  101. package/src/reserve/assetReserveKit.d.ts +103 -0
  102. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  103. package/src/reserve/assetReserveKit.js +134 -32
  104. package/src/reserve/params.d.ts +16 -0
  105. package/src/reserve/params.d.ts.map +1 -0
  106. package/src/reserve/params.js +8 -2
  107. package/src/tokens.d.ts +3 -0
  108. package/src/tokens.d.ts.map +1 -0
  109. package/src/tokens.js +5 -0
  110. package/src/vaultFactory/burn.d.ts +2 -0
  111. package/src/vaultFactory/burn.d.ts.map +1 -0
  112. package/src/vaultFactory/burn.js +1 -1
  113. package/src/vaultFactory/liquidation.d.ts +25 -0
  114. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  115. package/src/vaultFactory/liquidation.js +37 -24
  116. package/src/vaultFactory/math.d.ts +11 -0
  117. package/src/vaultFactory/math.d.ts.map +1 -0
  118. package/src/vaultFactory/math.js +11 -10
  119. package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
  120. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  121. package/src/vaultFactory/orderedVaultStore.js +9 -10
  122. package/src/vaultFactory/params.d.ts +143 -0
  123. package/src/vaultFactory/params.d.ts.map +1 -0
  124. package/src/vaultFactory/params.js +56 -25
  125. package/src/vaultFactory/prioritizedVaults.d.ts +280 -0
  126. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  127. package/src/vaultFactory/prioritizedVaults.js +7 -4
  128. package/src/vaultFactory/proceeds.d.ts +35 -0
  129. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  130. package/src/vaultFactory/proceeds.js +26 -18
  131. package/src/vaultFactory/storeUtils.d.ts +25 -0
  132. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  133. package/src/vaultFactory/storeUtils.js +10 -12
  134. package/src/vaultFactory/types-ambient.d.ts +137 -0
  135. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  136. package/src/vaultFactory/{types.js → types-ambient.js} +47 -44
  137. package/src/vaultFactory/vault.d.ts +344 -0
  138. package/src/vaultFactory/vault.d.ts.map +1 -0
  139. package/src/vaultFactory/vault.js +107 -100
  140. package/src/vaultFactory/vaultDirector.d.ts +347 -0
  141. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  142. package/src/vaultFactory/vaultDirector.js +94 -64
  143. package/src/vaultFactory/vaultFactory.d.ts +250 -0
  144. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  145. package/src/vaultFactory/vaultFactory.js +56 -33
  146. package/src/vaultFactory/vaultHolder.d.ts +170 -0
  147. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  148. package/src/vaultFactory/vaultHolder.js +14 -15
  149. package/src/vaultFactory/vaultKit.d.ts +33 -0
  150. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  151. package/src/vaultFactory/vaultKit.js +9 -4
  152. package/src/vaultFactory/vaultManager.d.ts +676 -0
  153. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  154. package/src/vaultFactory/vaultManager.js +286 -167
  155. package/CHANGELOG.md +0 -1041
  156. package/exported.js +0 -2
  157. package/scripts/add-collateral-core.js +0 -112
  158. package/scripts/deploy-contracts.js +0 -100
  159. package/scripts/init-core.js +0 -198
  160. package/scripts/invite-committee-core.js +0 -42
  161. package/scripts/manual-price-feed.js +0 -117
  162. package/scripts/price-feed-core.js +0 -104
  163. package/scripts/start-local-chain.sh +0 -84
  164. package/src/psm/types.js +0 -3
  165. package/src/typeGuards.js +0 -13
  166. package/src/vaultFactory/type-imports.js +0 -4
@@ -0,0 +1,70 @@
1
+ export function distributeProportionalSharesWithLimits(unsoldCollateral: Amount<"nat">, proceeds: Amount<"nat">, deposits: {
2
+ seat: ZCFSeat;
3
+ amount: Amount<"nat">;
4
+ goal: Amount<"nat">;
5
+ }[], collateralSeat: ZCFSeat, bidHoldingSeat: ZCFSeat, collateralKeyword: string, reserveSeat: ZCFSeat, brand: Brand): globalThis.TransferPart[];
6
+ export function start(zcf: ZCF<GovernanceTerms<typeof auctioneerParamTypes> & {
7
+ timerService: import("@agoric/time").TimerService;
8
+ reservePublicFacet: AssetReservePublicFacet;
9
+ priceAuthority: PriceAuthority;
10
+ }>, privateArgs: {
11
+ initialPoserInvitation: Invitation;
12
+ storageNode: StorageNode;
13
+ marshaller: Marshaller;
14
+ }, baggage: Baggage): Promise<{
15
+ publicFacet: globalThis.GovernedPublicFacet<{
16
+ getElectorate: () => import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>;
17
+ getStartFrequency: () => RelativeTime;
18
+ getClockStep: () => RelativeTime;
19
+ getStartingRate: () => bigint;
20
+ getLowestRate: () => bigint;
21
+ getDiscountStep: () => bigint;
22
+ getAuctionStartDelay: () => RelativeTime;
23
+ getPriceLockPeriod: () => RelativeTime;
24
+ /** @param {Brand<'nat'>} collateralBrand */
25
+ makeBidInvitation(collateralBrand: Brand<"nat">): Promise<globalThis.Invitation<string, import("./auctionBook.js").OfferSpec>>;
26
+ getSchedules(): {
27
+ liveAuctionSchedule: import("./scheduler.js").Schedule | null;
28
+ nextAuctionSchedule: import("./scheduler.js").Schedule | null;
29
+ };
30
+ getScheduleUpdates(): globalThis.Subscriber<import("./scheduler.js").ScheduleNotification>;
31
+ getBookDataUpdates(brand: any): globalThis.Subscriber<import("./auctionBook.js").BookDataNotification>;
32
+ getPublicTopics(brand: any): {
33
+ bookData: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./auctionBook.js").BookDataNotification>;
34
+ } | {
35
+ schedule: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./scheduler.js").ScheduleNotification>;
36
+ };
37
+ makeDepositInvitation: () => Promise<globalThis.Invitation<string, {
38
+ goal: Amount<"nat">;
39
+ }>>;
40
+ }>;
41
+ creatorFacet: globalThis.GovernedCreatorFacet<{
42
+ /**
43
+ * @param {Issuer<'nat'>} issuer
44
+ * @param {Keyword} kwd
45
+ */
46
+ addBrand(issuer: Issuer<"nat">, kwd: Keyword): Promise<void>;
47
+ /** @returns {Promise<import('./scheduler.js').FullSchedule>} */
48
+ getSchedule(): Promise<import("./scheduler.js").FullSchedule>;
49
+ } & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
50
+ /**
51
+ * @param {Issuer<'nat'>} issuer
52
+ * @param {Keyword} kwd
53
+ */
54
+ addBrand(issuer: Issuer<"nat">, kwd: Keyword): Promise<void>;
55
+ /** @returns {Promise<import('./scheduler.js').FullSchedule>} */
56
+ getSchedule(): Promise<import("./scheduler.js").FullSchedule>;
57
+ }>>;
58
+ }>;
59
+ /** @typedef {ContractOf<typeof start>} AuctioneerContract */
60
+ /** @typedef {AuctioneerContract['publicFacet']} AuctioneerPublicFacet */
61
+ /** @typedef {AuctioneerContract['creatorFacet']} AuctioneerCreatorFacet */
62
+ export const AuctionPFShape: import("@endo/patterns").Matcher;
63
+ export type AuctioneerContract = ContractOf<typeof start>;
64
+ export type AuctioneerPublicFacet = AuctioneerContract["publicFacet"];
65
+ export type AuctioneerCreatorFacet = AuctioneerContract["creatorFacet"];
66
+ import { auctioneerParamTypes } from './params.js';
67
+ import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
68
+ import type { Baggage } from '@agoric/vat-data';
69
+ import type { ContractOf } from '@agoric/zoe/src/zoeService/utils.js';
70
+ //# sourceMappingURL=auctioneer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auctioneer.d.ts","sourceRoot":"","sources":["auctioneer.js"],"names":[],"mappings":"AAoLO,yEAXI,MAAM,CAAC,KAAK,CAAC,YACb,MAAM,CAAC,KAAK,CAAC,YACb;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;CAAE,EAAE,kBAC/D,OAAO,kBACP,OAAO,qBAEP,MAAM,eAEN,OAAO,SACP,KAAK,6BAgNf;AAiBM,2BAdI,GAAG,CACT,eAAe,CAAC,OAAO,oBAAoB,CAAC,GAAG;IAC7C,YAAY,EAAE,OAAO,cAAc,EAAE,YAAY,CAAC;IAClD,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,cAAc,EAAE,cAAc,CAAC;CAChC,CACF,eACO;IACN,sBAAsB,EAAE,UAAU,CAAC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;;;;;;;QAqOZ,4CAA4C;2CAAhC,KAAK,CAAC,KAAK,CAAC;;;;;;;;;;;;;kBApCT,MAAM,CAAC,KAAK,CAAC;;;;QAkG5B;;;WAGG;yBAFQ,MAAM,CAAC,KAAK,CAAC,OACb,OAAO;QAwBlB,gEAAgE;uBAAlD,OAAO,CAAC,OAAO,gBAAgB,EAAE,YAAY,CAAC;;QA1B5D;;;WAGG;yBAFQ,MAAM,CAAC,KAAK,CAAC,OACb,OAAO;QAwBlB,gEAAgE;uBAAlD,OAAO,CAAC,OAAO,gBAAgB,EAAE,YAAY,CAAC;;GAQjE;AAED,6DAA6D;AAC7D,yEAAyE;AACzE,2EAA2E;AAE3E,8DAAkE;iCAJpD,WAAW,OAAO,KAAK,CAAC;oCACxB,kBAAkB,CAAC,aAAa,CAAC;qCACjC,kBAAkB,CAAC,cAAc,CAAC;qCA1rBX,aAAa;oCAS2C,4BAA4B;6BAF/F,kBAAkB;gCACf,qCAAqC"}
@@ -1,16 +1,17 @@
1
- import '@agoric/governance/exported.js';
2
- import '@agoric/zoe/exported.js';
3
- import '@agoric/zoe/src/contracts/exported.js';
1
+ /// <reference types="@agoric/governance/exported" />
2
+ /// <reference types="@agoric/zoe/exported" />
4
3
 
4
+ import { Fail, q } from '@endo/errors';
5
+ import { E } from '@endo/eventual-send';
6
+ import { Far } from '@endo/marshal';
5
7
  import { AmountMath, AmountShape, BrandShape } from '@agoric/ertp';
6
8
  import { handleParamGovernance } from '@agoric/governance';
7
- import { BASIS_POINTS, makeTracer } from '@agoric/internal';
9
+ import { makeTracer } from '@agoric/internal';
8
10
  import { prepareDurablePublishKit } from '@agoric/notifier';
9
11
  import { mustMatch } from '@agoric/store';
10
12
  import { appendToStoredArray } from '@agoric/store/src/stores/store-utils.js';
11
13
  import { M, provideDurableMapStore } from '@agoric/vat-data';
12
14
  import {
13
- atomicRearrange,
14
15
  ceilDivideBy,
15
16
  ceilMultiplyBy,
16
17
  defineERecorderKit,
@@ -26,8 +27,6 @@ import {
26
27
  offerTo,
27
28
  } from '@agoric/zoe/src/contractSupport/index.js';
28
29
  import { FullProposalShape } from '@agoric/zoe/src/typeGuards.js';
29
- import { E } from '@endo/eventual-send';
30
- import { Far } from '@endo/marshal';
31
30
 
32
31
  import { makeNatAmountShape } from '../contractSupport.js';
33
32
  import { makeOfferSpecShape, prepareAuctionBook } from './auctionBook.js';
@@ -35,19 +34,25 @@ import { auctioneerParamTypes } from './params.js';
35
34
  import { makeScheduler } from './scheduler.js';
36
35
  import { AuctionState } from './util.js';
37
36
 
38
- /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
37
+ /**
38
+ * @import {TypedPattern} from '@agoric/internal';
39
+ * @import {MapStore} from '@agoric/store';
40
+ * @import {Baggage} from '@agoric/vat-data';
41
+ * @import {ContractOf} from '@agoric/zoe/src/zoeService/utils.js';
42
+ * @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
43
+ */
44
+
45
+ const BASIS_POINTS = 10_000n;
39
46
 
40
- const { Fail, quote: q } = assert;
41
47
  const { add, multiply } = natSafeMath;
42
48
 
43
49
  const trace = makeTracer('Auction', true);
44
50
 
45
51
  /**
46
- * @file
47
- * In this file, 'Bid' is the name of the ERTP issuer used to purchase
48
- * collateral from various issuers. It's too confusing to also use Bid as a verb
49
- * or a description of amounts offered, so we've tried to find alternatives in
50
- * all those cases.
52
+ * @file In this file, 'Bid' is the name of the ERTP issuer used to purchase
53
+ * collateral from various issuers. It's too confusing to also use Bid as a
54
+ * verb or a description of amounts offered, so we've tried to find
55
+ * alternatives in all those cases.
51
56
  */
52
57
 
53
58
  const MINIMUM_BID_GIVE = 1n;
@@ -67,17 +72,19 @@ const makeBPRatio = (rate, bidBrand, collateralBrand = bidBrand) =>
67
72
  * The auction sold some amount of collateral, and raised a certain amount of
68
73
  * Bid. The excess collateral was returned as `unsoldCollateral`. The Bid amount
69
74
  * collected from the auction participants is `proceeds`.
75
+ *
70
76
  * Return a set of transfers for atomicRearrange() that distribute
71
77
  * `unsoldCollateral` and `proceeds` proportionally to each seat's deposited
72
78
  * amount. Any uneven split should be allocated to the reserve.
73
79
  *
74
80
  * @param {Amount} unsoldCollateral
75
81
  * @param {Amount} proceeds
76
- * @param {{seat: ZCFSeat, amount: Amount<'nat'>, goal: Amount<'nat'>}[]} deposits
82
+ * @param {{ seat: ZCFSeat; amount: Amount<'nat'>; goal: Amount<'nat'> }[]} deposits
77
83
  * @param {ZCFSeat} collateralSeat
78
- * @param {ZCFSeat} bidHoldingSeat seat with the Bid allocation to be distributed
84
+ * @param {ZCFSeat} bidHoldingSeat seat with the Bid allocation to be
85
+ * distributed
79
86
  * @param {string} collateralKeyword The Reserve will hold multiple collaterals,
80
- * so they need distinct keywords
87
+ * so they need distinct keywords
81
88
  * @param {ZCFSeat} reserveSeat
82
89
  * @param {Brand} brand
83
90
  */
@@ -97,7 +104,7 @@ const distributeProportionalShares = (
97
104
 
98
105
  const collShare = makeRatioFromAmounts(unsoldCollateral, totalCollDeposited);
99
106
  const currShare = makeRatioFromAmounts(proceeds, totalCollDeposited);
100
- /** @type {import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart[]} */
107
+ /** @type {TransferPart[]} */
101
108
  const transfers = [];
102
109
  let proceedsLeft = proceeds;
103
110
  let collateralLeft = unsoldCollateral;
@@ -132,6 +139,7 @@ const distributeProportionalShares = (
132
139
  * The auction sold some amount of collateral, and raised a certain amount of
133
140
  * Bid. The excess collateral was returned as `unsoldCollateral`. The Bid amount
134
141
  * collected from the auction participants is `proceeds`.
142
+ *
135
143
  * Return a set of transfers for atomicRearrange() that distribute
136
144
  * `unsoldCollateral` and `proceeds` proportionally to each seat's deposited
137
145
  * amount. Any uneven split should be allocated to the reserve.
@@ -140,32 +148,33 @@ const distributeProportionalShares = (
140
148
  * outside the contract below.
141
149
  *
142
150
  * Some or all of the depositors may have specified a goal amount.
143
- * * A if none did, return collateral and Bid prorated to deposits.
144
- * * B if proceeds < proceedsGoal everyone gets prorated amounts of both.
145
- * * C if proceeds matches proceedsGoal, everyone gets the Bid they
146
- * asked for, plus enough collateral to reach the same proportional payout.
147
- * If any depositor's goal amount exceeded their share of the total,
148
- * we'll fall back to the first approach.
149
- * * D if proceeds > proceedsGoal && all depositors specified a limit,
150
- * all depositors get their goal first, then we distribute the
151
- * remainder (collateral and Bid) to get the same proportional payout.
152
- * * E if proceeds > proceedsGoal && some depositors didn't specify a
153
- * limit, depositors who did will get their goal first, then we distribute
154
- * the remainder (collateral and Bid) to get the same proportional
155
- * payout. If any depositor's goal amount exceeded their share of the
156
- * total, we'll fall back as above.
157
- * Think of it this way: those who specified a limit want as much collateral
158
- * back as possible, consistent with raising a certain amount of Bid. Those
159
- * who didn't specify a limit are trying to sell collateral, and would prefer to
160
- * have as much as possible converted to Bid.
151
+ *
152
+ * - A if none did, return collateral and Bid prorated to deposits.
153
+ * - B if proceeds < proceedsGoal everyone gets prorated amounts of both.
154
+ * - C if proceeds matches proceedsGoal, everyone gets the Bid they asked for,
155
+ * plus enough collateral to reach the same proportional payout. If any
156
+ * depositor's goal amount exceeded their share of the total, we'll fall back
157
+ * to the first approach.
158
+ * - D if proceeds > proceedsGoal && all depositors specified a limit, all
159
+ * depositors get their goal first, then we distribute the remainder
160
+ * (collateral and Bid) to get the same proportional payout.
161
+ * - E if proceeds > proceedsGoal && some depositors didn't specify a limit,
162
+ * depositors who did will get their goal first, then we distribute the
163
+ * remainder (collateral and Bid) to get the same proportional payout. If any
164
+ * depositor's goal amount exceeded their share of the total, we'll fall back
165
+ * as above. Think of it this way: those who specified a limit want as much
166
+ * collateral back as possible, consistent with raising a certain amount of
167
+ * Bid. Those who didn't specify a limit are trying to sell collateral, and
168
+ * would prefer to have as much as possible converted to Bid.
161
169
  *
162
170
  * @param {Amount<'nat'>} unsoldCollateral
163
171
  * @param {Amount<'nat'>} proceeds
164
- * @param {{seat: ZCFSeat, amount: Amount<'nat'>, goal: Amount<'nat'>}[]} deposits
172
+ * @param {{ seat: ZCFSeat; amount: Amount<'nat'>; goal: Amount<'nat'> }[]} deposits
165
173
  * @param {ZCFSeat} collateralSeat
166
- * @param {ZCFSeat} bidHoldingSeat seat with the Bid allocation to be distributed
174
+ * @param {ZCFSeat} bidHoldingSeat seat with the Bid allocation to be
175
+ * distributed
167
176
  * @param {string} collateralKeyword The Reserve will hold multiple collaterals,
168
- * so they need distinct keywords
177
+ * so they need distinct keywords
169
178
  * @param {ZCFSeat} reserveSeat
170
179
  * @param {Brand} brand
171
180
  */
@@ -255,7 +264,7 @@ export const distributeProportionalSharesWithLimits = (
255
264
  // collateral to reach their share. Then see what's left, and allocate it
256
265
  // among the remaining depositors. Escape to distributeProportionalShares if
257
266
  // anything doesn't work.
258
- /** @type {import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart[]} */
267
+ /** @type {TransferPart[]} */
259
268
  const transfers = [];
260
269
  let proceedsLeft = proceeds;
261
270
  let collateralLeft = unsoldCollateral;
@@ -378,15 +387,17 @@ export const distributeProportionalSharesWithLimits = (
378
387
  };
379
388
 
380
389
  /**
381
- * @param {ZCF<GovernanceTerms<typeof auctioneerParamTypes> & {
382
- * timerService: import('@agoric/time/src/types').TimerService,
383
- * reservePublicFacet: AssetReservePublicFacet,
384
- * priceAuthority: PriceAuthority
385
- * }>} zcf
390
+ * @param {ZCF<
391
+ * GovernanceTerms<typeof auctioneerParamTypes> & {
392
+ * timerService: import('@agoric/time').TimerService;
393
+ * reservePublicFacet: AssetReservePublicFacet;
394
+ * priceAuthority: PriceAuthority;
395
+ * }
396
+ * >} zcf
386
397
  * @param {{
387
- * initialPoserInvitation: Invitation,
388
- * storageNode: StorageNode,
389
- * marshaller: Marshaller
398
+ * initialPoserInvitation: Invitation;
399
+ * storageNode: StorageNode;
400
+ * marshaller: Marshaller;
390
401
  * }} privateArgs
391
402
  * @param {Baggage} baggage
392
403
  */
@@ -399,7 +410,12 @@ export const start = async (zcf, privateArgs, baggage) => {
399
410
 
400
411
  /** @type {MapStore<Brand, import('./auctionBook.js').AuctionBook>} */
401
412
  const books = provideDurableMapStore(baggage, 'auctionBooks');
402
- /** @type {MapStore<Brand, Array<{ seat: ZCFSeat, amount: Amount<'nat'>, goal: Amount<'nat'>}>>} */
413
+ /**
414
+ * @type {MapStore<
415
+ * Brand,
416
+ * { seat: ZCFSeat; amount: Amount<'nat'>; goal: Amount<'nat'> }[]
417
+ * >}
418
+ */
403
419
  const deposits = provideDurableMapStore(baggage, 'deposits');
404
420
  /** @type {MapStore<Brand, Keyword>} */
405
421
  const brandToKeyword = provideDurableMapStore(baggage, 'brandToKeyword');
@@ -427,9 +443,9 @@ export const start = async (zcf, privateArgs, baggage) => {
427
443
  });
428
444
  const scheduleKit = makeERecorderKit(
429
445
  E(privateArgs.storageNode).makeChildNode('schedule'),
430
- /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<import('./scheduler.js').ScheduleNotification>} */ (
431
- M.any()
432
- ),
446
+ /**
447
+ * @type {TypedPattern<import('./scheduler.js').ScheduleNotification>}
448
+ */ (M.any()),
433
449
  );
434
450
 
435
451
  /**
@@ -477,8 +493,7 @@ export const start = async (zcf, privateArgs, baggage) => {
477
493
  // send it all to the one
478
494
  const liqSeat = depositsForBrand[0].seat;
479
495
 
480
- atomicRearrange(
481
- zcf,
496
+ zcf.atomicRearrange(
482
497
  harden([
483
498
  [collateralSeat, liqSeat, collateralSeat.getCurrentAllocation()],
484
499
  [bidHoldingSeat, liqSeat, bidHoldingSeat.getCurrentAllocation()],
@@ -501,7 +516,7 @@ export const start = async (zcf, privateArgs, baggage) => {
501
516
  reserveSeat,
502
517
  brand,
503
518
  );
504
- atomicRearrange(zcf, harden(transfers));
519
+ zcf.atomicRearrange(harden(transfers));
505
520
 
506
521
  for (const { seat } of depositsForBrand) {
507
522
  seat.exit();
@@ -573,12 +588,11 @@ export const start = async (zcf, privateArgs, baggage) => {
573
588
  },
574
589
  });
575
590
 
576
- // eslint-disable-next-line no-use-before-define
577
591
  const isActive = () => scheduler.getAuctionState() === AuctionState.ACTIVE;
578
592
 
579
593
  /**
580
594
  * @param {ZCFSeat} zcfSeat
581
- * @param {{ goal: Amount<'nat'>}} offerArgs
595
+ * @param {{ goal: Amount<'nat'> }} offerArgs
582
596
  */
583
597
  const depositOfferHandler = (zcfSeat, offerArgs) => {
584
598
  const goalMatcher = M.or(undefined, { goal: bidAmountShape });
@@ -640,7 +654,6 @@ export const start = async (zcf, privateArgs, baggage) => {
640
654
  );
641
655
  },
642
656
  getSchedules() {
643
- // eslint-disable-next-line no-use-before-define
644
657
  return scheduler.getSchedule();
645
658
  },
646
659
  getScheduleUpdates() {
@@ -678,7 +691,7 @@ export const start = async (zcf, privateArgs, baggage) => {
678
691
  const creatorFacet = makeFarGovernorFacet(
679
692
  Far('Auctioneer creatorFacet', {
680
693
  /**
681
- * @param {Issuer} issuer
694
+ * @param {Issuer<'nat'>} issuer
682
695
  * @param {Keyword} kwd
683
696
  */
684
697
  async addBrand(issuer, kwd) {
@@ -0,0 +1,46 @@
1
+ export function prepareScaledBidBook(baggage: Baggage): (bidScalingPattern: Pattern, collateralBrand: globalThis.Brand) => import("@endo/exo").Guarded<{
2
+ /**
3
+ * @param {ZCFSeat} seat
4
+ * @param {Ratio} bidScaling
5
+ * @param {Amount<'nat'>} wanted
6
+ * @param {boolean} exitAfterBuy
7
+ */
8
+ add(seat: ZCFSeat, bidScaling: Ratio, wanted: Amount<"nat">, exitAfterBuy: boolean): string;
9
+ /** @param {Ratio} bidScaling */
10
+ offersAbove(bidScaling: Ratio): [string, BidderRecord][];
11
+ hasOrders(): boolean;
12
+ delete(key: any): void;
13
+ updateReceived(key: any, sold: any): void;
14
+ exitAllSeats(): void;
15
+ }>;
16
+ export function preparePriceBook(baggage: Baggage): (priceRatioPattern: Pattern, collateralBrand: globalThis.Brand) => import("@endo/exo").Guarded<{
17
+ /**
18
+ * @param {ZCFSeat} seat
19
+ * @param {Ratio} price
20
+ * @param {Amount<'nat'>} wanted
21
+ * @param {boolean} exitAfterBuy
22
+ */
23
+ add(seat: ZCFSeat, price: Ratio, wanted: Amount<"nat">, exitAfterBuy: boolean): string;
24
+ offersAbove(price: any): [string, BidderRecord][];
25
+ hasOrders(): boolean;
26
+ delete(key: any): void;
27
+ updateReceived(key: any, sold: any): void;
28
+ exitAllSeats(): void;
29
+ }>;
30
+ export type BidderRecord = {
31
+ seat: ZCFSeat;
32
+ wanted: Amount<"nat">;
33
+ seqNum: NatValue;
34
+ received: Amount<"nat">;
35
+ } & {
36
+ exitAfterBuy: boolean;
37
+ } & ({
38
+ bidScaling: Pattern;
39
+ price: undefined;
40
+ } | {
41
+ bidScaling: undefined;
42
+ price: Ratio;
43
+ });
44
+ import type { Baggage } from '@agoric/vat-data';
45
+ import type { Pattern } from '@endo/patterns';
46
+ //# sourceMappingURL=offerBook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"offerBook.d.ts","sourceRoot":"","sources":["offerBook.js"],"names":[],"mappings":"AAsDO,8CAFI,OAAO;IAkBZ;;;;;OAKG;cAJQ,OAAO,cACP,KAAK,UACL,MAAM,CAAC,KAAK,CAAC,gBACb,OAAO;IAsBlB,gCAAgC;4BAApB,KAAK;;;;;GAqCpB;AAcI,0CAFI,OAAO;IAkBZ;;;;;OAKG;cAJQ,OAAO,SACP,KAAK,UACL,MAAM,CAAC,KAAK,CAAC,gBACb,OAAO;;;;;;GA0DrB;2BAnMU;IACR,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CACzB,GAAG;IAAE,YAAY,EAAE,OAAO,CAAA;CAAE,GAAG,CAC1B;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACzC;IAAE,UAAU,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAC1C;6BAtBoB,kBAAkB;6BACb,gBAAgB"}
@@ -12,7 +12,11 @@ import {
12
12
  toScaledRateOfferKey,
13
13
  } from './sortedOffers.js';
14
14
 
15
- /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
15
+ /**
16
+ * @import {MapStore} from '@agoric/store';
17
+ * @import {Baggage} from '@agoric/vat-data';
18
+ * @import {Key, Pattern} from '@endo/patterns';
19
+ */
16
20
 
17
21
  // multiple offers might be provided at the same time (since the time
18
22
  // granularity is limited to blocks), so we increment a sequenceNumber with each
@@ -25,12 +29,14 @@ const nextSequenceNumber = () => {
25
29
 
26
30
  /**
27
31
  * @typedef {{
28
- * seat: ZCFSeat,
29
- * wanted: Amount<'nat'>,
30
- * seqNum: NatValue,
31
- * received: Amount<'nat'>,
32
- * } & {exitAfterBuy: boolean} & ({ bidScaling: Pattern, price: undefined } | { bidScaling: undefined, price: Ratio})
33
- * } BidderRecord
32
+ * seat: ZCFSeat;
33
+ * wanted: Amount<'nat'>;
34
+ * seqNum: NatValue;
35
+ * received: Amount<'nat'>;
36
+ * } & { exitAfterBuy: boolean } & (
37
+ * | { bidScaling: Pattern; price: undefined }
38
+ * | { bidScaling: undefined; price: Ratio }
39
+ * )} BidderRecord
34
40
  */
35
41
 
36
42
  const ScaledBidBookStateShape = harden({
@@ -41,7 +47,8 @@ const ScaledBidBookStateShape = harden({
41
47
 
42
48
  /**
43
49
  * Prices in this book are expressed as percentage of the full oracle price
44
- * snapshot taken when the auction started. .4 is 60% off. 1.1 is 10% above par.
50
+ * snapshot taken when the auction started. .4 is 60% off. 1.1 is 10% above
51
+ * par.
45
52
  *
46
53
  * @param {Baggage} baggage
47
54
  */
@@ -51,7 +58,6 @@ export const prepareScaledBidBook = baggage =>
51
58
  'scaledBidBook',
52
59
  undefined,
53
60
  /**
54
- *
55
61
  * @param {Pattern} bidScalingPattern
56
62
  * @param {Brand} collateralBrand
57
63
  */
@@ -134,8 +140,8 @@ const PriceBookStateShape = harden({
134
140
  });
135
141
 
136
142
  /**
137
- * Prices in this book are actual prices expressed in terms of bid amount
138
- * and collateral amount.
143
+ * Prices in this book are actual prices expressed in terms of bid amount and
144
+ * collateral amount.
139
145
  *
140
146
  * @param {Baggage} baggage
141
147
  */
@@ -145,7 +151,6 @@ export const preparePriceBook = baggage =>
145
151
  'priceBook',
146
152
  undefined,
147
153
  /**
148
- *
149
154
  * @param {Pattern} priceRatioPattern
150
155
  * @param {Brand} collateralBrand
151
156
  */
@@ -0,0 +1,145 @@
1
+ /**
2
+ * @import {AsyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
3
+ * @import {SyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
4
+ * @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
5
+ */
6
+ export const InvitationShape: import("@endo/patterns").Matcher;
7
+ /**
8
+ * In seconds, how often to start an auction. The auction will start at
9
+ * AUCTION_START_DELAY seconds after a multiple of START_FREQUENCY, with the
10
+ * price at STARTING_RATE_BP. Every CLOCK_STEP, the price will be reduced by
11
+ * DISCOUNT_STEP_BP, as long as the rate is at or above LOWEST_RATE_BP, or until
12
+ * START_FREQUENCY has elapsed.
13
+ */
14
+ export const START_FREQUENCY: "StartFrequency";
15
+ /** in seconds, how often to reduce the price */
16
+ export const CLOCK_STEP: "ClockStep";
17
+ /** discount or markup for starting price in basis points. 9999 = 1bp discount */
18
+ export const STARTING_RATE_BP: "StartingRate";
19
+ /** A limit below which the price will not be discounted. */
20
+ export const LOWEST_RATE_BP: "LowestRate";
21
+ /** amount to reduce prices each time step in bp, as % of the start price */
22
+ export const DISCOUNT_STEP_BP: "DiscountStep";
23
+ /**
24
+ * VaultManagers liquidate vaults at a frequency configured by START_FREQUENCY.
25
+ * Auctions start this long after the hour to give vaults time to finish.
26
+ */
27
+ export const AUCTION_START_DELAY: "AuctionStartDelay";
28
+ export const PRICE_LOCK_PERIOD: "PriceLockPeriod";
29
+ export const auctioneerParamPattern: import("@endo/patterns").Matcher;
30
+ export namespace auctioneerParamTypes {
31
+ let Electorate: "invitation";
32
+ let StartFrequency: "relativeTime";
33
+ let ClockStep: "relativeTime";
34
+ let StartingRate: "nat";
35
+ let LowestRate: "nat";
36
+ let DiscountStep: "nat";
37
+ let AuctionStartDelay: "relativeTime";
38
+ let PriceLockPeriod: "relativeTime";
39
+ }
40
+ export function makeAuctioneerParams({ ElectorateInvitationAmount, StartFrequency, ClockStep, LowestRate, StartingRate, DiscountStep, AuctionStartDelay, PriceLockPeriod, TimerBrand, }: AuctionParams): {
41
+ Electorate: {
42
+ type: "invitation";
43
+ value: import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>;
44
+ };
45
+ StartFrequency: {
46
+ type: "relativeTime";
47
+ value: import("@agoric/time").RelativeTimeRecord;
48
+ };
49
+ ClockStep: {
50
+ type: "relativeTime";
51
+ value: import("@agoric/time").RelativeTimeRecord;
52
+ };
53
+ AuctionStartDelay: {
54
+ type: "relativeTime";
55
+ value: import("@agoric/time").RelativeTimeRecord;
56
+ };
57
+ PriceLockPeriod: {
58
+ type: "relativeTime";
59
+ value: import("@agoric/time").RelativeTimeRecord;
60
+ };
61
+ StartingRate: {
62
+ type: "nat";
63
+ value: bigint;
64
+ };
65
+ LowestRate: {
66
+ type: "nat";
67
+ value: bigint;
68
+ };
69
+ DiscountStep: {
70
+ type: "nat";
71
+ value: bigint;
72
+ };
73
+ };
74
+ export function makeAuctioneerParamManager(publisherKit: import("@agoric/notifier").StoredPublisherKit<GovernanceSubscriptionState>, zcf: ZCF, initial: AuctionParams): import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
75
+ Electorate: "invitation";
76
+ StartFrequency: "relativeTime";
77
+ ClockStep: "relativeTime";
78
+ StartingRate: "nat";
79
+ LowestRate: "nat";
80
+ DiscountStep: "nat";
81
+ AuctionStartDelay: "relativeTime";
82
+ PriceLockPeriod: "relativeTime";
83
+ }>;
84
+ export function makeGovernedTerms({ storageNode: _storageNode, marshaller: _marshaller }: {
85
+ storageNode: ERef<StorageNode>;
86
+ marshaller: ERef<Marshaller>;
87
+ }, timer: ERef<import("@agoric/time").TimerService>, priceAuthority: ERef<PriceAuthority>, reservePublicFacet: ERef<AssetReservePublicFacet>, params: AuctionParams): {
88
+ priceAuthority: globalThis.ERef<PriceAuthority>;
89
+ reservePublicFacet: globalThis.ERef<globalThis.GovernedPublicFacet<import("@endo/exo").Guarded<{
90
+ makeAddCollateralInvitation(): Promise<globalThis.Invitation<string, never>>;
91
+ getPublicTopics(): {
92
+ metrics: import("@agoric/zoe/src/contractSupport").PublicTopic<import("../reserve/assetReserveKit").MetricsNotification>;
93
+ };
94
+ }>>>;
95
+ timerService: globalThis.ERef<import("@agoric/time").TimerService>;
96
+ governedParams: {
97
+ Electorate: {
98
+ type: "invitation";
99
+ value: import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>;
100
+ };
101
+ StartFrequency: {
102
+ type: "relativeTime";
103
+ value: import("@agoric/time").RelativeTimeRecord;
104
+ };
105
+ ClockStep: {
106
+ type: "relativeTime";
107
+ value: import("@agoric/time").RelativeTimeRecord;
108
+ };
109
+ AuctionStartDelay: {
110
+ type: "relativeTime";
111
+ value: import("@agoric/time").RelativeTimeRecord;
112
+ };
113
+ PriceLockPeriod: {
114
+ type: "relativeTime";
115
+ value: import("@agoric/time").RelativeTimeRecord;
116
+ };
117
+ StartingRate: {
118
+ type: "nat";
119
+ value: bigint;
120
+ };
121
+ LowestRate: {
122
+ type: "nat";
123
+ value: bigint;
124
+ };
125
+ DiscountStep: {
126
+ type: "nat";
127
+ value: bigint;
128
+ };
129
+ };
130
+ };
131
+ export type AuctionParams = {
132
+ ElectorateInvitationAmount: Amount<"set">;
133
+ StartFrequency: RelativeTime;
134
+ ClockStep: RelativeTime;
135
+ StartingRate: bigint;
136
+ LowestRate: bigint;
137
+ DiscountStep: bigint;
138
+ AuctionStartDelay: RelativeTime;
139
+ PriceLockPeriod: RelativeTime;
140
+ TimerBrand: import("@agoric/time").TimerBrand;
141
+ };
142
+ export type AuctionParamRecord = ReturnType<typeof makeAuctioneerParams>;
143
+ export type AuctionParamManager = ReturnType<typeof makeAuctioneerParamManager>;
144
+ import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
145
+ //# sourceMappingURL=params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["params.js"],"names":[],"mappings":"AAQA;;;;GAIG;AAGH,+DAAyD;AAEzD;;;;;;GAMG;AACH,8BAA+B,gBAAgB,CAAC;AAChD,gDAAgD;AAChD,yBAA0B,WAAW,CAAC;AACtC,iFAAiF;AACjF,+BAAgC,cAAc,CAAC;AAC/C,4DAA4D;AAC5D,6BAA8B,YAAY,CAAC;AAC3C,4EAA4E;AAC5E,+BAAgC,cAAc,CAAC;AAC/C;;;GAGG;AACH,kCAAmC,mBAAmB,CAAC;AAIvD,gCAAiC,iBAAiB,CAAC;AAEnD,sEASG;;;;;;;;;;;AA2BI,yLADK,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCxB;AAQM,yDAJI,OAAO,kBAAkB,EAAE,kBAAkB,CAAC,2BAA2B,CAAC,OAC1E,GAAG,WACH,aAAa;;;;;;;;;GA0BvB;AAWM,0FANI;IAAE,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;CAAE,SAChE,IAAI,CAAC,OAAO,cAAc,EAAE,YAAY,CAAC,kBACzC,IAAI,CAAC,cAAc,CAAC,sBACpB,IAAI,CAAC,uBAAuB,CAAC,UAC7B,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBvB;;gCAzGa,MAAM,CAAC,KAAK,CAAC;oBACb,YAAY;eACZ,YAAY;kBACZ,MAAM;gBACN,MAAM;kBACN,MAAM;uBACN,YAAY;qBACZ,YAAY;gBACZ,OAAO,cAAc,EAAE,UAAU;;iCA0EjC,UAAU,CAAC,OAAO,oBAAoB,CAAC;kCA0BvC,UAAU,CAAC,OAAO,0BAA0B,CAAC;oCApKkC,4BAA4B"}