@agoric/inter-protocol 0.16.2-dev-6e5b422.0 → 0.16.2-dev-bd1190d.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 (112) hide show
  1. package/bundles/bundle-auctioneer-js-meta.json +116 -116
  2. package/bundles/bundle-econCommitteeCharter-js-meta.json +71 -71
  3. package/bundles/bundle-feeDistributor-js-meta.json +57 -57
  4. package/bundles/bundle-fluxAggregatorKit-js-meta.json +111 -111
  5. package/bundles/bundle-psm-js-meta.json +109 -109
  6. package/bundles/bundle-reserve-js-meta.json +108 -108
  7. package/bundles/bundle-scaledPriceAuthority-js-meta.json +84 -84
  8. package/bundles/bundle-vaultFactory-js-meta.json +133 -133
  9. package/package.json +19 -17
  10. package/src/auction/auctionBook.d.ts +80 -0
  11. package/src/auction/auctionBook.d.ts.map +1 -0
  12. package/src/auction/auctioneer.d.ts +75 -0
  13. package/src/auction/auctioneer.d.ts.map +1 -0
  14. package/src/auction/offerBook.d.ts +72 -0
  15. package/src/auction/offerBook.d.ts.map +1 -0
  16. package/src/auction/params.d.ts +142 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/scheduleMath.d.ts +4 -0
  19. package/src/auction/scheduleMath.d.ts.map +1 -0
  20. package/src/auction/scheduler.d.ts +49 -0
  21. package/src/auction/scheduler.d.ts.map +1 -0
  22. package/src/auction/sortedOffers.d.ts +8 -0
  23. package/src/auction/sortedOffers.d.ts.map +1 -0
  24. package/src/auction/util.d.ts +30 -0
  25. package/src/auction/util.d.ts.map +1 -0
  26. package/src/clientSupport.d.ts +129 -0
  27. package/src/clientSupport.d.ts.map +1 -0
  28. package/src/collectFees.d.ts +2 -0
  29. package/src/collectFees.d.ts.map +1 -0
  30. package/src/contractSupport.d.ts +33 -0
  31. package/src/contractSupport.d.ts.map +1 -0
  32. package/src/econCommitteeCharter.d.ts +45 -0
  33. package/src/econCommitteeCharter.d.ts.map +1 -0
  34. package/src/feeDistributor.d.ts +234 -0
  35. package/src/feeDistributor.d.ts.map +1 -0
  36. package/src/index.d.ts +2 -0
  37. package/src/index.d.ts.map +1 -0
  38. package/src/interest-math.d.ts +3 -0
  39. package/src/interest-math.d.ts.map +1 -0
  40. package/src/interest.d.ts +28 -0
  41. package/src/interest.d.ts.map +1 -0
  42. package/src/price/fluxAggregatorContract.d.ts +110 -0
  43. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  44. package/src/price/fluxAggregatorKit.d.ts +150 -0
  45. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  46. package/src/price/priceOracleKit.d.ts +58 -0
  47. package/src/price/priceOracleKit.d.ts.map +1 -0
  48. package/src/price/roundsManager.d.ts +348 -0
  49. package/src/price/roundsManager.d.ts.map +1 -0
  50. package/src/proposals/addAssetToVault.d.ts +155 -0
  51. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  52. package/src/proposals/committee-proposal.d.ts +121 -0
  53. package/src/proposals/committee-proposal.d.ts.map +1 -0
  54. package/src/proposals/core-proposal.d.ts +149 -0
  55. package/src/proposals/core-proposal.d.ts.map +1 -0
  56. package/src/proposals/econ-behaviors.d.ts +201 -0
  57. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  58. package/src/proposals/price-feed-proposal.d.ts +83 -0
  59. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  60. package/src/proposals/startEconCommittee.d.ts +34 -0
  61. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  62. package/src/proposals/startPSM.d.ts +61 -0
  63. package/src/proposals/startPSM.d.ts.map +1 -0
  64. package/src/proposals/startPSM.js +8 -7
  65. package/src/proposals/utils.d.ts +15 -0
  66. package/src/proposals/utils.d.ts.map +1 -0
  67. package/src/psm/psm.d.ts +193 -0
  68. package/src/psm/psm.d.ts.map +1 -0
  69. package/src/psm/types.d.ts +2 -0
  70. package/src/psm/types.d.ts.map +1 -0
  71. package/src/reserve/assetReserve.d.ts +42 -0
  72. package/src/reserve/assetReserve.d.ts.map +1 -0
  73. package/src/reserve/assetReserveKit.d.ts +126 -0
  74. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  75. package/src/reserve/params.d.ts +10 -0
  76. package/src/reserve/params.d.ts.map +1 -0
  77. package/src/tokens.d.ts +36 -0
  78. package/src/tokens.d.ts.map +1 -0
  79. package/src/typeGuards.d.ts +5 -0
  80. package/src/typeGuards.d.ts.map +1 -0
  81. package/src/vaultFactory/burn.d.ts +2 -0
  82. package/src/vaultFactory/burn.d.ts.map +1 -0
  83. package/src/vaultFactory/liquidation.d.ts +24 -0
  84. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  85. package/src/vaultFactory/math.d.ts +10 -0
  86. package/src/vaultFactory/math.d.ts.map +1 -0
  87. package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
  88. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  89. package/src/vaultFactory/params.d.ts +162 -0
  90. package/src/vaultFactory/params.d.ts.map +1 -0
  91. package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
  92. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  93. package/src/vaultFactory/proceeds.d.ts +34 -0
  94. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  95. package/src/vaultFactory/storeUtils.d.ts +29 -0
  96. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  97. package/src/vaultFactory/type-imports.d.ts +2 -0
  98. package/src/vaultFactory/type-imports.d.ts.map +1 -0
  99. package/src/vaultFactory/types.d.ts +132 -0
  100. package/src/vaultFactory/types.d.ts.map +1 -0
  101. package/src/vaultFactory/vault.d.ts +585 -0
  102. package/src/vaultFactory/vault.d.ts.map +1 -0
  103. package/src/vaultFactory/vaultDirector.d.ts +582 -0
  104. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  105. package/src/vaultFactory/vaultFactory.d.ts +159 -0
  106. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  107. package/src/vaultFactory/vaultHolder.d.ts +205 -0
  108. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  109. package/src/vaultFactory/vaultKit.d.ts +32 -0
  110. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  111. package/src/vaultFactory/vaultManager.d.ts +552 -0
  112. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
@@ -0,0 +1,585 @@
1
+ export namespace Phase {
2
+ let ACTIVE: "active";
3
+ let LIQUIDATING: "liquidating";
4
+ let CLOSED: "closed";
5
+ let LIQUIDATED: "liquidated";
6
+ let TRANSFER: "transfer";
7
+ }
8
+ /**
9
+ * @typedef {Phase[keyof typeof Phase]} HolderPhase
10
+ *
11
+ * @typedef {object} VaultNotification
12
+ * @property {Amount<'nat'>} locked Amount of Collateral locked
13
+ * @property {{debt: Amount<'nat'>, stabilityFee: Ratio}} debtSnapshot 'debt' at the point the compounded stabilityFee was 'stabilityFee'
14
+ * @property {HolderPhase} vaultState
15
+ */
16
+ /**
17
+ * @typedef {object} VaultManager
18
+ * @property {() => Subscriber<import('./vaultManager').AssetState>} getAssetSubscriber
19
+ * @property {(collateralAmount: Amount) => Amount<'nat'>} maxDebtFor
20
+ * @property {() => Brand} getCollateralBrand
21
+ * @property {(base: string) => string} scopeDescription
22
+ * @property {() => Brand<'nat'>} getDebtBrand
23
+ * @property {MintAndTransfer} mintAndTransfer
24
+ * @property {(amount: Amount, seat: ZCFSeat) => void} burn
25
+ * @property {() => Ratio} getCompoundedStabilityFee
26
+ * @property {(oldDebt: import('./storeUtils.js').NormalizedDebt, oldCollateral: Amount<'nat'>, vaultId: VaultId, vaultPhase: VaultPhase, vault: Vault) => void} handleBalanceChange
27
+ * @property {() => import('./vaultManager.js').GovernedParamGetters} getGovernedParams
28
+ */
29
+ /**
30
+ * @typedef {Readonly<{
31
+ * idInManager: VaultId,
32
+ * manager: VaultManager,
33
+ * storageNode: StorageNode,
34
+ * vaultSeat: ZCFSeat,
35
+ * }>} ImmutableState
36
+ */
37
+ /**
38
+ * Snapshot is of the debt and compounded interest when the principal was last changed.
39
+ *
40
+ * @typedef {{
41
+ * stabilityFeeSnapshot: Ratio,
42
+ * phase: VaultPhase,
43
+ * debtSnapshot: Amount<'nat'>,
44
+ * outerUpdater: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification> | null,
45
+ * }} MutableState
46
+ */
47
+ export const VaultI: import("@endo/patterns").InterfaceGuard;
48
+ export function prepareVault(baggage: MapStore<string, unknown>, makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit, zcf: ZCF): (manager: VaultManager, idInManager: string, storageNode: StorageNode) => {
49
+ helper: {
50
+ collateralBrand(): Brand<AssetKind>;
51
+ debtBrand(): Brand<"nat">;
52
+ emptyCollateral(): Amount<"nat">;
53
+ emptyDebt(): Amount<"nat">;
54
+ /**
55
+ * @typedef {{ give: { Collateral: Amount<'nat'>, Minted: Amount<'nat'> }, want: { Collateral: Amount<'nat'>, Minted: Amount<'nat'> } }} FullProposal
56
+ */
57
+ /**
58
+ * @param {ProposalRecord} partial
59
+ * @returns {FullProposal}
60
+ */
61
+ fullProposal(partial: ProposalRecord): {
62
+ give: {
63
+ Collateral: Amount<'nat'>;
64
+ Minted: Amount<'nat'>;
65
+ };
66
+ want: {
67
+ Collateral: Amount<'nat'>;
68
+ Minted: Amount<'nat'>;
69
+ };
70
+ };
71
+ /**
72
+ * @param {VaultPhase} newPhase
73
+ */
74
+ assignPhase(newPhase: VaultPhase): void;
75
+ assertActive(): void;
76
+ assertCloseable(): void;
77
+ /**
78
+ * Called whenever the debt is paid or created through a transaction,
79
+ * but not for interest accrual.
80
+ *
81
+ * @param {Amount<'nat'>} newDebt - principal and all accrued interest
82
+ */
83
+ updateDebtSnapshot(newDebt: Amount<'nat'>): void;
84
+ /**
85
+ * Update the debt balance and propagate upwards to
86
+ * maintain aggregate debt and liquidation order.
87
+ *
88
+ * @param {NormalizedDebt} oldDebtNormalized - prior principal and all accrued interest, normalized to the launch of the vaultManager
89
+ * @param {Amount<'nat'>} oldCollateral - actual collateral
90
+ * @param {Amount<'nat'>} newDebtActual - actual principal and all accrued interest
91
+ */
92
+ updateDebtAccounting(oldDebtNormalized: NormalizedDebt, oldCollateral: Amount<'nat'>, newDebtActual: Amount<'nat'>): void;
93
+ /**
94
+ *
95
+ * @param {ZCFSeat} seat
96
+ */
97
+ getCollateralAllocated(seat: ZCFSeat): Amount<any>;
98
+ getMintedAllocated(seat: any): any;
99
+ assertVaultHoldsNoMinted(): void;
100
+ /**
101
+ *
102
+ * @param {Amount<'nat'>} collateralAmount
103
+ * @param {Amount<'nat'>} proposedDebt
104
+ */
105
+ assertSufficientCollateral(collateralAmount: Amount<'nat'>, proposedDebt: Amount<'nat'>): void;
106
+ /**
107
+ *
108
+ * @param {HolderPhase} newPhase
109
+ */
110
+ getStateSnapshot(newPhase: HolderPhase): {
111
+ debtSnapshot: {
112
+ debt: Amount<"nat">;
113
+ stabilityFee: Ratio;
114
+ };
115
+ locked: Amount<"nat">;
116
+ vaultState: HolderPhase;
117
+ };
118
+ /**
119
+ * call this whenever anything changes!
120
+ */
121
+ updateUiState(): void;
122
+ /**
123
+ * @param {ZCFSeat} seat
124
+ */
125
+ closeHook(seat: ZCFSeat): Promise<string>;
126
+ /**
127
+ * Calculate the fee, the amount to mint and the resulting debt.
128
+ * The give and the want together reflect a delta, where typically
129
+ * one is zero because they come from the gave/want of an offer
130
+ * proposal. If the `want` is zero, the `fee` will also be zero,
131
+ * so the simple math works.
132
+ *
133
+ * @param {Amount<'nat'>} currentDebt
134
+ * @param {Amount<'nat'>} giveAmount
135
+ * @param {Amount<'nat'>} wantAmount
136
+ */
137
+ debtFee(currentDebt: Amount<'nat'>, giveAmount: Amount<'nat'>, wantAmount: Amount<'nat'>): {
138
+ newDebt: Amount<"nat">;
139
+ toMint: Amount<"nat">;
140
+ fee: Amount<"nat">;
141
+ surplus: Amount<"nat">;
142
+ };
143
+ /**
144
+ * Adjust principal and collateral (atomically for offer safety)
145
+ *
146
+ * @param {ZCFSeat} clientSeat
147
+ * @returns {string} success message
148
+ */
149
+ adjustBalancesHook(clientSeat: ZCFSeat): string;
150
+ /**
151
+ *
152
+ * @param {ZCFSeat} clientSeat
153
+ * @param {FullProposal} fp
154
+ * @param {ReturnType<typeof calculateDebtCosts>} costs
155
+ * @param {object} accounting
156
+ * @param {NormalizedDebt} accounting.normalizedDebtPre
157
+ * @param {Amount<'nat'>} accounting.collateralPre
158
+ * @returns {string} success message
159
+ */
160
+ commitBalanceAdjustment(clientSeat: ZCFSeat, fp: {
161
+ give: {
162
+ Collateral: Amount<'nat'>;
163
+ Minted: Amount<'nat'>;
164
+ };
165
+ want: {
166
+ Collateral: Amount<'nat'>;
167
+ Minted: Amount<'nat'>;
168
+ };
169
+ }, { newDebt, fee, surplus, toMint }: ReturnType<typeof calculateDebtCosts>, { normalizedDebtPre, collateralPre }: {
170
+ normalizedDebtPre: NormalizedDebt;
171
+ collateralPre: Amount<'nat'>;
172
+ }): string;
173
+ /**
174
+ *
175
+ * @param {ZCFSeat} seat
176
+ * @returns {VaultKit}
177
+ */
178
+ makeTransferInvitationHook(seat: ZCFSeat): VaultKit;
179
+ };
180
+ self: {
181
+ getVaultSeat(): ZCFSeat;
182
+ /**
183
+ * @param {ZCFSeat} seat
184
+ * @param {StorageNode} storageNode
185
+ */
186
+ initVaultKit(seat: ZCFSeat, storageNode: StorageNode): Promise<{
187
+ publicSubscribers: {
188
+ vault: {
189
+ description: string;
190
+ subscriber: Subscriber<VaultNotification>;
191
+ storagePath: Promise<string>;
192
+ };
193
+ };
194
+ invitationMakers: {
195
+ AdjustBalances(): Promise<Invitation<R, A>>;
196
+ CloseVault(): Promise<Invitation<R, A>>;
197
+ TransferVault(): Promise<Invitation<R, A>>;
198
+ };
199
+ vault: {
200
+ getPublicTopics(): {
201
+ vault: {
202
+ description: string;
203
+ subscriber: Subscriber<VaultNotification>;
204
+ storagePath: Promise<string>;
205
+ };
206
+ };
207
+ makeAdjustBalancesInvitation(): Promise<Invitation<R, A>>;
208
+ makeCloseInvitation(): Promise<Invitation<R, A>>;
209
+ makeTransferInvitation(): Promise<Invitation<R, A>>;
210
+ getCollateralAmount(): Amount<"nat">;
211
+ getCurrentDebt(): Amount<"nat">;
212
+ /**
213
+ * @typedef {Readonly<{
214
+ * idInManager: VaultId,
215
+ * manager: VaultManager,
216
+ * storageNode: StorageNode,
217
+ * vaultSeat: ZCFSeat,
218
+ * }>} ImmutableState
219
+ */
220
+ /**
221
+ * Snapshot is of the debt and compounded interest when the principal was last changed.
222
+ *
223
+ * @typedef {{
224
+ * stabilityFeeSnapshot: Ratio,
225
+ * phase: VaultPhase,
226
+ * debtSnapshot: Amount<'nat'>,
227
+ * outerUpdater: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification> | null,
228
+ * }} MutableState
229
+ */
230
+ getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
231
+ };
232
+ vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
233
+ }>;
234
+ /**
235
+ * Called by manager at start of liquidation.
236
+ */
237
+ liquidating(): void;
238
+ /**
239
+ * Called by manager at end of liquidation, at which point all debts have been
240
+ * covered.
241
+ */
242
+ liquidated(): void;
243
+ /**
244
+ * Called by vaultManager when the auction wasn't able to sell the
245
+ * collateral. The liquidation fee was charged against the collateral,
246
+ * but the debt will be restored and the vault will be active again.
247
+ * Liquidation.md has details on the liquidation approach.
248
+ */
249
+ abortLiquidation(): string;
250
+ makeAdjustBalancesInvitation(): Promise<Invitation<R, A>>;
251
+ makeCloseInvitation(): Promise<Invitation<R, A>>;
252
+ /**
253
+ * @returns {Promise<Invitation>}
254
+ */
255
+ makeTransferInvitation(): Promise<Invitation>;
256
+ /**
257
+ *
258
+ * @returns {Amount<'nat'>}
259
+ */
260
+ getCollateralAmount(): Amount<'nat'>;
261
+ /**
262
+ * The actual current debt, including accrued interest.
263
+ *
264
+ * This looks like a simple getter but it does a lot of the heavy lifting for
265
+ * interest accrual. Rather than updating all records when interest accrues,
266
+ * the vault manager updates just its rolling compounded interest. Here we
267
+ * calculate what the current debt is given what's recorded in this vault and
268
+ * what interest has compounded since this vault record was written.
269
+ *
270
+ * @see getNormalizedDebt
271
+ *
272
+ * @returns {Amount<'nat'>}
273
+ */
274
+ getCurrentDebt(): Amount<'nat'>;
275
+ /**
276
+ * The normalization puts all debts on a common time-independent scale since
277
+ * the launch of this vault manager. This allows the manager to order vaults
278
+ * by their debt-to-collateral ratios without having to mutate the debts as
279
+ * the interest accrues.
280
+ *
281
+ * @see getActualDebAmount
282
+ *
283
+ * @returns {import('./storeUtils.js').NormalizedDebt} as if the vault was open at the launch of this manager, before any interest accrued
284
+ */
285
+ getNormalizedDebt(): import('./storeUtils.js').NormalizedDebt;
286
+ };
287
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
288
+ helper: {
289
+ collateralBrand(): Brand<AssetKind>;
290
+ debtBrand(): Brand<"nat">;
291
+ emptyCollateral(): Amount<"nat">;
292
+ emptyDebt(): Amount<"nat">;
293
+ /**
294
+ * @typedef {{ give: { Collateral: Amount<'nat'>, Minted: Amount<'nat'> }, want: { Collateral: Amount<'nat'>, Minted: Amount<'nat'> } }} FullProposal
295
+ */
296
+ /**
297
+ * @param {ProposalRecord} partial
298
+ * @returns {FullProposal}
299
+ */
300
+ fullProposal(partial: ProposalRecord): {
301
+ give: {
302
+ Collateral: Amount<'nat'>;
303
+ Minted: Amount<'nat'>;
304
+ };
305
+ want: {
306
+ Collateral: Amount<'nat'>;
307
+ Minted: Amount<'nat'>;
308
+ };
309
+ };
310
+ /**
311
+ * @param {VaultPhase} newPhase
312
+ */
313
+ assignPhase(newPhase: VaultPhase): void;
314
+ assertActive(): void;
315
+ assertCloseable(): void;
316
+ /**
317
+ * Called whenever the debt is paid or created through a transaction,
318
+ * but not for interest accrual.
319
+ *
320
+ * @param {Amount<'nat'>} newDebt - principal and all accrued interest
321
+ */
322
+ updateDebtSnapshot(newDebt: Amount<'nat'>): void;
323
+ /**
324
+ * Update the debt balance and propagate upwards to
325
+ * maintain aggregate debt and liquidation order.
326
+ *
327
+ * @param {NormalizedDebt} oldDebtNormalized - prior principal and all accrued interest, normalized to the launch of the vaultManager
328
+ * @param {Amount<'nat'>} oldCollateral - actual collateral
329
+ * @param {Amount<'nat'>} newDebtActual - actual principal and all accrued interest
330
+ */
331
+ updateDebtAccounting(oldDebtNormalized: NormalizedDebt, oldCollateral: Amount<'nat'>, newDebtActual: Amount<'nat'>): void;
332
+ /**
333
+ *
334
+ * @param {ZCFSeat} seat
335
+ */
336
+ getCollateralAllocated(seat: ZCFSeat): Amount<any>;
337
+ getMintedAllocated(seat: any): any;
338
+ assertVaultHoldsNoMinted(): void;
339
+ /**
340
+ *
341
+ * @param {Amount<'nat'>} collateralAmount
342
+ * @param {Amount<'nat'>} proposedDebt
343
+ */
344
+ assertSufficientCollateral(collateralAmount: Amount<'nat'>, proposedDebt: Amount<'nat'>): void;
345
+ /**
346
+ *
347
+ * @param {HolderPhase} newPhase
348
+ */
349
+ getStateSnapshot(newPhase: HolderPhase): {
350
+ debtSnapshot: {
351
+ debt: Amount<"nat">;
352
+ stabilityFee: Ratio;
353
+ };
354
+ locked: Amount<"nat">;
355
+ vaultState: HolderPhase;
356
+ };
357
+ /**
358
+ * call this whenever anything changes!
359
+ */
360
+ updateUiState(): void;
361
+ /**
362
+ * @param {ZCFSeat} seat
363
+ */
364
+ closeHook(seat: ZCFSeat): Promise<string>;
365
+ /**
366
+ * Calculate the fee, the amount to mint and the resulting debt.
367
+ * The give and the want together reflect a delta, where typically
368
+ * one is zero because they come from the gave/want of an offer
369
+ * proposal. If the `want` is zero, the `fee` will also be zero,
370
+ * so the simple math works.
371
+ *
372
+ * @param {Amount<'nat'>} currentDebt
373
+ * @param {Amount<'nat'>} giveAmount
374
+ * @param {Amount<'nat'>} wantAmount
375
+ */
376
+ debtFee(currentDebt: Amount<'nat'>, giveAmount: Amount<'nat'>, wantAmount: Amount<'nat'>): {
377
+ newDebt: Amount<"nat">;
378
+ toMint: Amount<"nat">;
379
+ fee: Amount<"nat">;
380
+ surplus: Amount<"nat">;
381
+ };
382
+ /**
383
+ * Adjust principal and collateral (atomically for offer safety)
384
+ *
385
+ * @param {ZCFSeat} clientSeat
386
+ * @returns {string} success message
387
+ */
388
+ adjustBalancesHook(clientSeat: ZCFSeat): string;
389
+ /**
390
+ *
391
+ * @param {ZCFSeat} clientSeat
392
+ * @param {FullProposal} fp
393
+ * @param {ReturnType<typeof calculateDebtCosts>} costs
394
+ * @param {object} accounting
395
+ * @param {NormalizedDebt} accounting.normalizedDebtPre
396
+ * @param {Amount<'nat'>} accounting.collateralPre
397
+ * @returns {string} success message
398
+ */
399
+ commitBalanceAdjustment(clientSeat: ZCFSeat, fp: {
400
+ give: {
401
+ Collateral: Amount<'nat'>;
402
+ Minted: Amount<'nat'>;
403
+ };
404
+ want: {
405
+ Collateral: Amount<'nat'>;
406
+ Minted: Amount<'nat'>;
407
+ };
408
+ }, { newDebt, fee, surplus, toMint }: ReturnType<typeof calculateDebtCosts>, { normalizedDebtPre, collateralPre }: {
409
+ normalizedDebtPre: NormalizedDebt;
410
+ collateralPre: Amount<'nat'>;
411
+ }): string;
412
+ /**
413
+ *
414
+ * @param {ZCFSeat} seat
415
+ * @returns {VaultKit}
416
+ */
417
+ makeTransferInvitationHook(seat: ZCFSeat): VaultKit;
418
+ };
419
+ self: {
420
+ getVaultSeat(): ZCFSeat;
421
+ /**
422
+ * @param {ZCFSeat} seat
423
+ * @param {StorageNode} storageNode
424
+ */
425
+ initVaultKit(seat: ZCFSeat, storageNode: StorageNode): Promise<{
426
+ publicSubscribers: {
427
+ vault: {
428
+ description: string;
429
+ subscriber: Subscriber<VaultNotification>;
430
+ storagePath: Promise<string>;
431
+ };
432
+ };
433
+ invitationMakers: {
434
+ AdjustBalances(): Promise<Invitation<R, A>>;
435
+ CloseVault(): Promise<Invitation<R, A>>;
436
+ TransferVault(): Promise<Invitation<R, A>>;
437
+ };
438
+ vault: {
439
+ getPublicTopics(): {
440
+ vault: {
441
+ description: string;
442
+ subscriber: Subscriber<VaultNotification>;
443
+ storagePath: Promise<string>;
444
+ };
445
+ };
446
+ makeAdjustBalancesInvitation(): Promise<Invitation<R, A>>;
447
+ makeCloseInvitation(): Promise<Invitation<R, A>>;
448
+ makeTransferInvitation(): Promise<Invitation<R, A>>;
449
+ getCollateralAmount(): Amount<"nat">;
450
+ getCurrentDebt(): Amount<"nat">;
451
+ /**
452
+ * @typedef {Readonly<{
453
+ * idInManager: VaultId,
454
+ * manager: VaultManager,
455
+ * storageNode: StorageNode,
456
+ * vaultSeat: ZCFSeat,
457
+ * }>} ImmutableState
458
+ */
459
+ /**
460
+ * Snapshot is of the debt and compounded interest when the principal was last changed.
461
+ *
462
+ * @typedef {{
463
+ * stabilityFeeSnapshot: Ratio,
464
+ * phase: VaultPhase,
465
+ * debtSnapshot: Amount<'nat'>,
466
+ * outerUpdater: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification> | null,
467
+ * }} MutableState
468
+ */
469
+ getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
470
+ };
471
+ vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
472
+ }>;
473
+ /**
474
+ * Called by manager at start of liquidation.
475
+ */
476
+ liquidating(): void;
477
+ /**
478
+ * Called by manager at end of liquidation, at which point all debts have been
479
+ * covered.
480
+ */
481
+ liquidated(): void;
482
+ /**
483
+ * Called by vaultManager when the auction wasn't able to sell the
484
+ * collateral. The liquidation fee was charged against the collateral,
485
+ * but the debt will be restored and the vault will be active again.
486
+ * Liquidation.md has details on the liquidation approach.
487
+ */
488
+ abortLiquidation(): string;
489
+ makeAdjustBalancesInvitation(): Promise<Invitation<R, A>>;
490
+ makeCloseInvitation(): Promise<Invitation<R, A>>;
491
+ /**
492
+ * @returns {Promise<Invitation>}
493
+ */
494
+ makeTransferInvitation(): Promise<Invitation>;
495
+ /**
496
+ *
497
+ * @returns {Amount<'nat'>}
498
+ */
499
+ getCollateralAmount(): Amount<'nat'>;
500
+ /**
501
+ * The actual current debt, including accrued interest.
502
+ *
503
+ * This looks like a simple getter but it does a lot of the heavy lifting for
504
+ * interest accrual. Rather than updating all records when interest accrues,
505
+ * the vault manager updates just its rolling compounded interest. Here we
506
+ * calculate what the current debt is given what's recorded in this vault and
507
+ * what interest has compounded since this vault record was written.
508
+ *
509
+ * @see getNormalizedDebt
510
+ *
511
+ * @returns {Amount<'nat'>}
512
+ */
513
+ getCurrentDebt(): Amount<'nat'>;
514
+ /**
515
+ * The normalization puts all debts on a common time-independent scale since
516
+ * the launch of this vault manager. This allows the manager to order vaults
517
+ * by their debt-to-collateral ratios without having to mutate the debts as
518
+ * the interest accrues.
519
+ *
520
+ * @see getActualDebAmount
521
+ *
522
+ * @returns {import('./storeUtils.js').NormalizedDebt} as if the vault was open at the launch of this manager, before any interest accrued
523
+ */
524
+ getNormalizedDebt(): import('./storeUtils.js').NormalizedDebt;
525
+ };
526
+ }>;
527
+ export type NormalizedDebt = import('./storeUtils.js').NormalizedDebt;
528
+ export type VaultPhase = {
529
+ readonly ACTIVE: "active";
530
+ readonly LIQUIDATING: "liquidating";
531
+ readonly CLOSED: "closed";
532
+ readonly LIQUIDATED: "liquidated";
533
+ readonly TRANSFER: "transfer";
534
+ }[keyof Omit<typeof Phase, 'TRANSFER'>];
535
+ export type HolderPhase = {
536
+ readonly ACTIVE: "active";
537
+ readonly LIQUIDATING: "liquidating";
538
+ readonly CLOSED: "closed";
539
+ readonly LIQUIDATED: "liquidated";
540
+ readonly TRANSFER: "transfer";
541
+ }[keyof typeof Phase];
542
+ export type VaultNotification = {
543
+ /**
544
+ * Amount of Collateral locked
545
+ */
546
+ locked: Amount<'nat'>;
547
+ /**
548
+ * 'debt' at the point the compounded stabilityFee was 'stabilityFee'
549
+ */
550
+ debtSnapshot: {
551
+ debt: Amount<'nat'>;
552
+ stabilityFee: Ratio;
553
+ };
554
+ vaultState: HolderPhase;
555
+ };
556
+ export type VaultManager = {
557
+ getAssetSubscriber: () => Subscriber<import('./vaultManager').AssetState>;
558
+ maxDebtFor: (collateralAmount: Amount) => Amount<'nat'>;
559
+ getCollateralBrand: () => Brand;
560
+ scopeDescription: (base: string) => string;
561
+ getDebtBrand: () => Brand<'nat'>;
562
+ mintAndTransfer: MintAndTransfer;
563
+ burn: (amount: Amount, seat: ZCFSeat) => void;
564
+ getCompoundedStabilityFee: () => Ratio;
565
+ handleBalanceChange: (oldDebt: import('./storeUtils.js').NormalizedDebt, oldCollateral: Amount<'nat'>, vaultId: VaultId, vaultPhase: VaultPhase, vault: Vault) => void;
566
+ getGovernedParams: () => import('./vaultManager.js').GovernedParamGetters;
567
+ };
568
+ export type ImmutableState = Readonly<{
569
+ idInManager: VaultId;
570
+ manager: VaultManager;
571
+ storageNode: StorageNode;
572
+ vaultSeat: ZCFSeat;
573
+ }>;
574
+ /**
575
+ * Snapshot is of the debt and compounded interest when the principal was last changed.
576
+ */
577
+ export type MutableState = {
578
+ stabilityFeeSnapshot: Ratio;
579
+ phase: VaultPhase;
580
+ debtSnapshot: Amount<'nat'>;
581
+ outerUpdater: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification> | null;
582
+ };
583
+ export type Vault = ReturnType<ReturnType<typeof prepareVault>>['self'];
584
+ import { calculateDebtCosts } from './math.js';
585
+ //# sourceMappingURL=vault.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["vault.js"],"names":[],"mappings":";;;;;;;AAqEA;;;;;;;GAOG;AAGH;;;;;;;;;;;;GAYG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AAEH,6DAYG;AAkBI,kFAHI,OAAO,6CAA6C,EAAE,eAAe,OACrE,GAAG;;;;;;QAuDN;;WAEG;QACH;;;WAGG;8BAFQ,cAAc;kBAHJ;gBAAE,UAAU,EAAE,OAAO,KAAK,CAAC,CAAC;gBAAC,MAAM,EAAE,OAAO,KAAK,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