@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-3eb1a1d.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.
- package/README.md +6 -6
- package/package.json +42 -36
- package/scripts/build-bundles.js +5 -21
- package/src/auction/auctionBook.d.ts +147 -0
- package/src/auction/auctionBook.d.ts.map +1 -0
- package/src/auction/auctionBook.js +156 -150
- package/src/auction/auctionMath.d.ts +17 -0
- package/src/auction/auctionMath.d.ts.map +1 -0
- package/src/auction/auctionMath.js +81 -0
- package/src/auction/auctioneer.d.ts +69 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +70 -59
- package/src/auction/offerBook.d.ts +45 -0
- package/src/auction/offerBook.d.ts.map +1 -0
- package/src/auction/offerBook.js +13 -12
- package/src/auction/params.d.ts +144 -0
- package/src/auction/params.d.ts.map +1 -0
- package/src/auction/params.js +10 -9
- package/src/auction/scheduleMath.d.ts +5 -0
- package/src/auction/scheduleMath.d.ts.map +1 -0
- package/src/auction/scheduleMath.js +18 -16
- package/src/auction/scheduler.d.ts +50 -0
- package/src/auction/scheduler.d.ts.map +1 -0
- package/src/auction/scheduler.js +53 -47
- package/src/auction/sortedOffers.d.ts +8 -0
- package/src/auction/sortedOffers.d.ts.map +1 -0
- package/src/auction/sortedOffers.js +10 -9
- package/src/auction/util.d.ts +30 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +9 -6
- package/src/clientSupport.d.ts +167 -0
- package/src/clientSupport.d.ts.map +1 -0
- package/src/clientSupport.js +155 -97
- package/src/collectFees.d.ts +2 -0
- package/src/collectFees.d.ts.map +1 -0
- package/src/contractSupport.d.ts +28 -0
- package/src/contractSupport.d.ts.map +1 -0
- package/src/contractSupport.js +19 -13
- package/src/econCommitteeCharter.d.ts +40 -0
- package/src/econCommitteeCharter.d.ts.map +1 -0
- package/src/econCommitteeCharter.js +21 -20
- package/src/feeDistributor.d.ts +224 -0
- package/src/feeDistributor.d.ts.map +1 -0
- package/src/feeDistributor.js +37 -33
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +1 -0
- package/src/interest-math.d.ts +3 -0
- package/src/interest-math.d.ts.map +1 -0
- package/src/interest.d.ts +28 -0
- package/src/interest.d.ts.map +1 -0
- package/src/interest.js +23 -18
- package/src/price/README.md +13 -0
- package/src/price/fluxAggregatorContract.d.ts +71 -0
- package/src/price/fluxAggregatorContract.d.ts.map +1 -0
- package/src/price/fluxAggregatorContract.js +64 -55
- package/src/price/fluxAggregatorKit.d.ts +103 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +52 -40
- package/src/price/priceOracleKit.d.ts +38 -0
- package/src/price/priceOracleKit.d.ts.map +1 -0
- package/src/price/priceOracleKit.js +12 -14
- package/src/price/roundsManager.d.ts +204 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +131 -85
- package/src/proposals/README.md +2 -3
- package/src/proposals/add-auction.d.ts +109 -0
- package/src/proposals/add-auction.d.ts.map +1 -0
- package/src/proposals/add-auction.js +256 -0
- package/src/proposals/addAssetToVault.d.ts +173 -0
- package/src/proposals/addAssetToVault.d.ts.map +1 -0
- package/src/proposals/addAssetToVault.js +192 -40
- package/src/proposals/committee-proposal.d.ts +113 -0
- package/src/proposals/committee-proposal.d.ts.map +1 -0
- package/src/proposals/committee-proposal.js +25 -31
- package/src/proposals/core-proposal.d.ts +149 -0
- package/src/proposals/core-proposal.d.ts.map +1 -0
- package/src/proposals/core-proposal.js +9 -11
- package/src/proposals/deploy-price-feeds.d.ts +76 -0
- package/src/proposals/deploy-price-feeds.d.ts.map +1 -0
- package/src/proposals/deploy-price-feeds.js +316 -0
- package/src/proposals/econ-behaviors.d.ts +541 -0
- package/src/proposals/econ-behaviors.d.ts.map +1 -0
- package/src/proposals/econ-behaviors.js +64 -45
- package/src/proposals/price-feed-proposal.d.ts +84 -0
- package/src/proposals/price-feed-proposal.d.ts.map +1 -0
- package/src/proposals/price-feed-proposal.js +109 -51
- package/src/proposals/replace-fee-distributor.d.ts +48 -0
- package/src/proposals/replace-fee-distributor.d.ts.map +1 -0
- package/src/proposals/replace-fee-distributor.js +195 -0
- package/src/proposals/replace-scaledPriceAuthorities.d.ts +30 -0
- package/src/proposals/replace-scaledPriceAuthorities.d.ts.map +1 -0
- package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
- package/src/proposals/replaceElectorate.d.ts +55 -0
- package/src/proposals/replaceElectorate.d.ts.map +1 -0
- package/src/proposals/replaceElectorate.js +521 -0
- package/src/proposals/startEconCommittee.d.ts +34 -0
- package/src/proposals/startEconCommittee.d.ts.map +1 -0
- package/src/proposals/startEconCommittee.js +2 -2
- package/src/proposals/startPSM.d.ts +59 -0
- package/src/proposals/startPSM.d.ts.map +1 -0
- package/src/proposals/startPSM.js +44 -29
- package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
- package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
- package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
- package/src/proposals/upgrade-vaults.d.ts +41 -0
- package/src/proposals/upgrade-vaults.d.ts.map +1 -0
- package/src/proposals/upgrade-vaults.js +202 -0
- package/src/proposals/utils.d.ts +19 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +43 -9
- package/src/provisionPool.d.ts +163 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +122 -0
- package/src/provisionPoolKit.d.ts +359 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +522 -0
- package/src/psm/psm.d.ts +125 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +80 -79
- package/src/psm/types-ambient.d.ts +2 -0
- package/src/psm/types-ambient.d.ts.map +1 -0
- package/src/psm/types-ambient.js +3 -0
- package/src/reserve/assetReserve.d.ts +47 -0
- package/src/reserve/assetReserve.d.ts.map +1 -0
- package/src/reserve/assetReserve.js +28 -19
- package/src/reserve/assetReserveKit.d.ts +74 -0
- package/src/reserve/assetReserveKit.d.ts.map +1 -0
- package/src/reserve/assetReserveKit.js +24 -30
- package/src/reserve/params.d.ts +10 -0
- package/src/reserve/params.d.ts.map +1 -0
- package/src/tokens.d.ts +3 -0
- package/src/tokens.d.ts.map +1 -0
- package/src/tokens.js +5 -0
- package/src/vaultFactory/burn.d.ts +2 -0
- package/src/vaultFactory/burn.d.ts.map +1 -0
- package/src/vaultFactory/burn.js +1 -1
- package/src/vaultFactory/liquidation.d.ts +23 -0
- package/src/vaultFactory/liquidation.d.ts.map +1 -0
- package/src/vaultFactory/liquidation.js +37 -24
- package/src/vaultFactory/math.d.ts +11 -0
- package/src/vaultFactory/math.d.ts.map +1 -0
- package/src/vaultFactory/math.js +10 -9
- package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +8 -11
- package/src/vaultFactory/params.d.ts +140 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +52 -24
- package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
- package/src/vaultFactory/prioritizedVaults.js +4 -4
- package/src/vaultFactory/proceeds.d.ts +35 -0
- package/src/vaultFactory/proceeds.d.ts.map +1 -0
- package/src/vaultFactory/proceeds.js +26 -18
- package/src/vaultFactory/storeUtils.d.ts +25 -0
- package/src/vaultFactory/storeUtils.d.ts.map +1 -0
- package/src/vaultFactory/storeUtils.js +10 -12
- package/src/vaultFactory/types-ambient.d.ts +137 -0
- package/src/vaultFactory/types-ambient.d.ts.map +1 -0
- package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
- package/src/vaultFactory/vault.d.ts +343 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +105 -99
- package/src/vaultFactory/vaultDirector.d.ts +341 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +86 -64
- package/src/vaultFactory/vaultFactory.d.ts +202 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +52 -33
- package/src/vaultFactory/vaultHolder.d.ts +126 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +11 -16
- package/src/vaultFactory/vaultKit.d.ts +32 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +5 -4
- package/src/vaultFactory/vaultManager.d.ts +674 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +257 -158
- package/CHANGELOG.md +0 -1041
- package/exported.js +0 -2
- package/scripts/add-collateral-core.js +0 -112
- package/scripts/deploy-contracts.js +0 -100
- package/scripts/init-core.js +0 -198
- package/scripts/invite-committee-core.js +0 -42
- package/scripts/manual-price-feed.js +0 -117
- package/scripts/price-feed-core.js +0 -104
- package/scripts/start-local-chain.sh +0 -84
- package/src/psm/types.js +0 -3
- package/src/typeGuards.js +0 -13
- package/src/vaultFactory/type-imports.js +0 -4
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { q, Fail } from '@endo/errors';
|
|
1
2
|
import { AmountMath, AmountShape } from '@agoric/ertp';
|
|
2
|
-
import {
|
|
3
|
+
import { StorageNodeShape, makeTracer } from '@agoric/internal';
|
|
4
|
+
import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js';
|
|
3
5
|
import { M, prepareExoClassKit } from '@agoric/vat-data';
|
|
4
6
|
import { atomicTransfer } from '@agoric/zoe/src/contractSupport/index.js';
|
|
5
7
|
import { SeatShape } from '@agoric/zoe/src/typeGuards.js';
|
|
@@ -9,44 +11,49 @@ import {
|
|
|
9
11
|
makeNatAmountShape,
|
|
10
12
|
} from '../contractSupport.js';
|
|
11
13
|
import { calculateCurrentDebt, reverseInterest } from '../interest-math.js';
|
|
12
|
-
import { UnguardedHelperI } from '../typeGuards.js';
|
|
13
|
-
import { prepareVaultKit } from './vaultKit.js';
|
|
14
|
-
|
|
15
|
-
import '@agoric/zoe/exported.js';
|
|
16
14
|
import { calculateDebtCosts } from './math.js';
|
|
17
|
-
|
|
18
|
-
const { quote: q, Fail } = assert;
|
|
15
|
+
import { prepareVaultKit } from './vaultKit.js';
|
|
19
16
|
|
|
20
17
|
const trace = makeTracer('Vault', true);
|
|
21
18
|
|
|
22
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* @import {Brand} from '@agoric/ertp/src/types.js';
|
|
21
|
+
* @import {NormalizedDebt} from './storeUtils.js';
|
|
22
|
+
*/
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* @file This has most of the logic for a Vault, to borrow Minted against
|
|
25
|
+
* @file This has most of the logic for a Vault, to borrow Minted against
|
|
26
|
+
* collateral.
|
|
27
|
+
*
|
|
28
|
+
* The logic here is for Vault which is the majority of logic of vaults but the
|
|
29
|
+
* user view is the `vault` value contained in VaultKit.
|
|
26
30
|
*
|
|
27
|
-
*
|
|
28
|
-
* the user view is the `vault` value contained in VaultKit.
|
|
31
|
+
* A note on naming convention:
|
|
29
32
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
33
|
+
* - `Pre` is used as a postfix for any mutable value retrieved _before_ an
|
|
34
|
+
* `await`, to flag values that must used very carefully after the
|
|
35
|
+
* `await`
|
|
36
|
+
* - `new` is a prefix for values that describe the result of executing a
|
|
37
|
+
* transaction; e.g., `debt` is the value before the txn, and `newDebt`
|
|
38
|
+
* will be value if the txn completes.
|
|
39
|
+
* - the absence of one of these implies the opposite, so `newDebt` is the future
|
|
40
|
+
* value fo `debt`, as computed based on values after any `await`
|
|
38
41
|
*/
|
|
39
42
|
|
|
40
43
|
/**
|
|
41
44
|
* Constants for vault phase.
|
|
42
45
|
*
|
|
43
|
-
* ACTIVE
|
|
44
|
-
* LIQUIDATING
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* TRANSFER
|
|
48
|
-
*
|
|
49
|
-
*
|
|
46
|
+
* - ACTIVE - vault is in use and can be changed
|
|
47
|
+
* - LIQUIDATING - vault is being liquidated by the vault manager, and cannot be
|
|
48
|
+
* changed by the user. If liquidation fails, vaults may remain in this state.
|
|
49
|
+
* An upgrade to the contract might be able to recover them.
|
|
50
|
+
* - TRANSFER - vault is able to be transferred (payments and debits frozen until
|
|
51
|
+
* it has a new owner)
|
|
52
|
+
* - CLOSED - vault was closed by the user and all assets have been paid out
|
|
53
|
+
* - LIQUIDATED - vault was closed by the manager, with remaining assets paid to
|
|
54
|
+
* owner
|
|
55
|
+
*
|
|
56
|
+
* @enum {(typeof Phase)[keyof typeof Phase]}
|
|
50
57
|
*/
|
|
51
58
|
export const Phase = /** @type {const} */ ({
|
|
52
59
|
ACTIVE: 'active',
|
|
@@ -55,10 +62,11 @@ export const Phase = /** @type {const} */ ({
|
|
|
55
62
|
LIQUIDATED: 'liquidated',
|
|
56
63
|
TRANSFER: 'transfer',
|
|
57
64
|
});
|
|
65
|
+
harden(Phase);
|
|
58
66
|
|
|
59
67
|
/**
|
|
60
|
-
* @typedef {
|
|
61
|
-
* @type {{[K in VaultPhase]:
|
|
68
|
+
* @typedef {Exclude<Phase, 'transfer'>} VaultPhase
|
|
69
|
+
* @type {{ [K in VaultPhase]: VaultPhase[] }}
|
|
62
70
|
*/
|
|
63
71
|
const validTransitions = {
|
|
64
72
|
[Phase.ACTIVE]: [Phase.LIQUIDATING, Phase.CLOSED],
|
|
@@ -68,46 +76,54 @@ const validTransitions = {
|
|
|
68
76
|
};
|
|
69
77
|
|
|
70
78
|
/**
|
|
71
|
-
* @typedef {Phase[keyof typeof Phase]} HolderPhase
|
|
72
|
-
*
|
|
73
79
|
* @typedef {object} VaultNotification
|
|
74
80
|
* @property {Amount<'nat'>} locked Amount of Collateral locked
|
|
75
|
-
* @property {{debt: Amount<'nat'
|
|
76
|
-
*
|
|
81
|
+
* @property {{ debt: Amount<'nat'>; interest: Ratio }} debtSnapshot 'debt' at
|
|
82
|
+
* the point the compounded interest was 'interest'
|
|
83
|
+
* @property {Phase} vaultState
|
|
77
84
|
*/
|
|
78
85
|
|
|
79
86
|
// XXX masks typedef from types.js, but using that causes circular def problems
|
|
80
87
|
/**
|
|
81
88
|
* @typedef {object} VaultManager
|
|
82
|
-
* @property {() => Subscriber<import('./vaultManager').AssetState>} getAssetSubscriber
|
|
89
|
+
* @property {() => Subscriber<import('./vaultManager.js').AssetState>} getAssetSubscriber
|
|
83
90
|
* @property {(collateralAmount: Amount) => Amount<'nat'>} maxDebtFor
|
|
84
|
-
* @property {() => Brand} getCollateralBrand
|
|
91
|
+
* @property {() => Brand<'nat'>} getCollateralBrand
|
|
85
92
|
* @property {(base: string) => string} scopeDescription
|
|
86
93
|
* @property {() => Brand<'nat'>} getDebtBrand
|
|
87
94
|
* @property {MintAndTransfer} mintAndTransfer
|
|
88
95
|
* @property {(amount: Amount, seat: ZCFSeat) => void} burn
|
|
89
96
|
* @property {() => Ratio} getCompoundedInterest
|
|
90
|
-
* @property {(
|
|
97
|
+
* @property {(
|
|
98
|
+
* oldDebt: import('./storeUtils.js').NormalizedDebt,
|
|
99
|
+
* oldCollateral: Amount<'nat'>,
|
|
100
|
+
* vaultId: VaultId,
|
|
101
|
+
* vaultPhase: VaultPhase,
|
|
102
|
+
* vault: Vault,
|
|
103
|
+
* ) => void} handleBalanceChange
|
|
91
104
|
* @property {() => import('./vaultManager.js').GovernedParamGetters} getGovernedParams
|
|
92
105
|
*/
|
|
93
106
|
|
|
94
107
|
/**
|
|
95
108
|
* @typedef {Readonly<{
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
109
|
+
* idInManager: VaultId;
|
|
110
|
+
* manager: VaultManager;
|
|
111
|
+
* storageNode: StorageNode;
|
|
112
|
+
* vaultSeat: ZCFSeat;
|
|
100
113
|
* }>} ImmutableState
|
|
101
114
|
*/
|
|
102
115
|
|
|
103
116
|
/**
|
|
104
|
-
* Snapshot is of the debt and compounded interest when the principal was last
|
|
117
|
+
* Snapshot is of the debt and compounded interest when the principal was last
|
|
118
|
+
* changed.
|
|
105
119
|
*
|
|
106
120
|
* @typedef {{
|
|
107
|
-
* interestSnapshot: Ratio
|
|
108
|
-
* phase: VaultPhase
|
|
109
|
-
* debtSnapshot: Amount<'nat'
|
|
110
|
-
* outerUpdater:
|
|
121
|
+
* interestSnapshot: Ratio;
|
|
122
|
+
* phase: VaultPhase;
|
|
123
|
+
* debtSnapshot: Amount<'nat'>;
|
|
124
|
+
* outerUpdater:
|
|
125
|
+
* | import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification>
|
|
126
|
+
* | null;
|
|
111
127
|
* }} MutableState
|
|
112
128
|
*/
|
|
113
129
|
|
|
@@ -137,7 +153,7 @@ const VaultStateShape = harden({
|
|
|
137
153
|
});
|
|
138
154
|
|
|
139
155
|
/**
|
|
140
|
-
* @param {import('@agoric/
|
|
156
|
+
* @param {import('@agoric/swingset-liveslots').Baggage} baggage
|
|
141
157
|
* @param {import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit} makeRecorderKit
|
|
142
158
|
* @param {ZCF} zcf
|
|
143
159
|
*/
|
|
@@ -195,7 +211,10 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
195
211
|
return AmountMath.makeEmpty(this.facets.helper.debtBrand());
|
|
196
212
|
},
|
|
197
213
|
/**
|
|
198
|
-
* @typedef {{
|
|
214
|
+
* @typedef {{
|
|
215
|
+
* give: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
|
|
216
|
+
* want: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
|
|
217
|
+
* }} FullProposal
|
|
199
218
|
*/
|
|
200
219
|
/**
|
|
201
220
|
* @param {ProposalRecord} partial
|
|
@@ -220,9 +239,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
220
239
|
//#endregion
|
|
221
240
|
|
|
222
241
|
//#region Phase logic
|
|
223
|
-
/**
|
|
224
|
-
* @param {VaultPhase} newPhase
|
|
225
|
-
*/
|
|
242
|
+
/** @param {VaultPhase} newPhase */
|
|
226
243
|
assignPhase(newPhase) {
|
|
227
244
|
const { state } = this;
|
|
228
245
|
|
|
@@ -261,12 +278,14 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
261
278
|
},
|
|
262
279
|
|
|
263
280
|
/**
|
|
264
|
-
* Update the debt balance and propagate upwards to
|
|
265
|
-
*
|
|
281
|
+
* Update the debt balance and propagate upwards to maintain aggregate
|
|
282
|
+
* debt and liquidation order.
|
|
266
283
|
*
|
|
267
|
-
* @param {NormalizedDebt} oldDebtNormalized - prior principal and all
|
|
284
|
+
* @param {NormalizedDebt} oldDebtNormalized - prior principal and all
|
|
285
|
+
* accrued interest, normalized to the launch of the vaultManager
|
|
268
286
|
* @param {Amount<'nat'>} oldCollateral - actual collateral
|
|
269
|
-
* @param {Amount<'nat'>} newDebtActual - actual principal and all
|
|
287
|
+
* @param {Amount<'nat'>} newDebtActual - actual principal and all
|
|
288
|
+
* accrued interest
|
|
270
289
|
*/
|
|
271
290
|
updateDebtAccounting(oldDebtNormalized, oldCollateral, newDebtActual) {
|
|
272
291
|
const { state, facets } = this;
|
|
@@ -283,8 +302,8 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
283
302
|
},
|
|
284
303
|
|
|
285
304
|
/**
|
|
286
|
-
*
|
|
287
305
|
* @param {ZCFSeat} seat
|
|
306
|
+
* @returns {Amount<'nat'>}
|
|
288
307
|
*/
|
|
289
308
|
getCollateralAllocated(seat) {
|
|
290
309
|
return seat.getAmountAllocated(
|
|
@@ -292,6 +311,10 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
292
311
|
this.facets.helper.collateralBrand(),
|
|
293
312
|
);
|
|
294
313
|
},
|
|
314
|
+
/**
|
|
315
|
+
* @param {ZCFSeat} seat
|
|
316
|
+
* @returns {Amount<'nat'>}
|
|
317
|
+
*/
|
|
295
318
|
getMintedAllocated(seat) {
|
|
296
319
|
return seat.getAmountAllocated(
|
|
297
320
|
'Minted',
|
|
@@ -307,7 +330,6 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
307
330
|
},
|
|
308
331
|
|
|
309
332
|
/**
|
|
310
|
-
*
|
|
311
333
|
* @param {Amount<'nat'>} collateralAmount
|
|
312
334
|
* @param {Amount<'nat'>} proposedDebt
|
|
313
335
|
*/
|
|
@@ -320,10 +342,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
320
342
|
)} for ${q(collateralAmount)} collateral`;
|
|
321
343
|
},
|
|
322
344
|
|
|
323
|
-
/**
|
|
324
|
-
*
|
|
325
|
-
* @param {HolderPhase} newPhase
|
|
326
|
-
*/
|
|
345
|
+
/** @param {Phase} newPhase */
|
|
327
346
|
getStateSnapshot(newPhase) {
|
|
328
347
|
const { state, facets } = this;
|
|
329
348
|
|
|
@@ -338,9 +357,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
338
357
|
});
|
|
339
358
|
},
|
|
340
359
|
|
|
341
|
-
/**
|
|
342
|
-
* call this whenever anything changes!
|
|
343
|
-
*/
|
|
360
|
+
/** call this whenever anything changes! */
|
|
344
361
|
updateUiState() {
|
|
345
362
|
const { state, facets } = this;
|
|
346
363
|
const { outerUpdater } = state;
|
|
@@ -368,9 +385,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
368
385
|
}
|
|
369
386
|
},
|
|
370
387
|
|
|
371
|
-
/**
|
|
372
|
-
* @param {ZCFSeat} seat
|
|
373
|
-
*/
|
|
388
|
+
/** @param {ZCFSeat} seat */
|
|
374
389
|
async closeHook(seat) {
|
|
375
390
|
const { state, facets } = this;
|
|
376
391
|
|
|
@@ -440,11 +455,11 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
440
455
|
},
|
|
441
456
|
|
|
442
457
|
/**
|
|
443
|
-
* Calculate the fee, the amount to mint and the resulting debt.
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
458
|
+
* Calculate the fee, the amount to mint and the resulting debt. The
|
|
459
|
+
* give and the want together reflect a delta, where typically one is
|
|
460
|
+
* zero because they come from the gave/want of an offer proposal. If
|
|
461
|
+
* the `want` is zero, the `fee` will also be zero, so the simple math
|
|
462
|
+
* works.
|
|
448
463
|
*
|
|
449
464
|
* @param {Amount<'nat'>} currentDebt
|
|
450
465
|
* @param {Amount<'nat'>} giveAmount
|
|
@@ -522,7 +537,6 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
522
537
|
},
|
|
523
538
|
|
|
524
539
|
/**
|
|
525
|
-
*
|
|
526
540
|
* @param {ZCFSeat} clientSeat
|
|
527
541
|
* @param {FullProposal} fp
|
|
528
542
|
* @param {ReturnType<typeof calculateDebtCosts>} costs
|
|
@@ -543,7 +557,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
543
557
|
|
|
544
558
|
const giveMintedTaken = AmountMath.subtract(fp.give.Minted, surplus);
|
|
545
559
|
|
|
546
|
-
/** @type {
|
|
560
|
+
/** @type {TransferPart[]} */
|
|
547
561
|
const transfers = harden([
|
|
548
562
|
[clientSeat, vaultSeat, { Collateral: fp.give.Collateral }],
|
|
549
563
|
[vaultSeat, clientSeat, { Collateral: fp.want.Collateral }],
|
|
@@ -568,7 +582,6 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
568
582
|
},
|
|
569
583
|
|
|
570
584
|
/**
|
|
571
|
-
*
|
|
572
585
|
* @param {ZCFSeat} seat
|
|
573
586
|
* @returns {VaultKit}
|
|
574
587
|
*/
|
|
@@ -579,7 +592,6 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
579
592
|
helper.assertCloseable();
|
|
580
593
|
seat.exit();
|
|
581
594
|
|
|
582
|
-
// eslint-disable-next-line no-use-before-define
|
|
583
595
|
const vaultKit = makeVaultKit(self, state.storageNode);
|
|
584
596
|
state.outerUpdater = vaultKit.vaultUpdater;
|
|
585
597
|
helper.updateUiState();
|
|
@@ -669,9 +681,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
669
681
|
return vaultKit;
|
|
670
682
|
},
|
|
671
683
|
|
|
672
|
-
/**
|
|
673
|
-
* Called by manager at start of liquidation.
|
|
674
|
-
*/
|
|
684
|
+
/** Called by manager at start of liquidation. */
|
|
675
685
|
liquidating() {
|
|
676
686
|
const { facets } = this;
|
|
677
687
|
|
|
@@ -681,8 +691,8 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
681
691
|
},
|
|
682
692
|
|
|
683
693
|
/**
|
|
684
|
-
* Called by manager at end of liquidation, at which point all debts
|
|
685
|
-
* covered.
|
|
694
|
+
* Called by manager at end of liquidation, at which point all debts
|
|
695
|
+
* have been covered.
|
|
686
696
|
*/
|
|
687
697
|
liquidated() {
|
|
688
698
|
const { facets } = this;
|
|
@@ -774,9 +784,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
774
784
|
);
|
|
775
785
|
},
|
|
776
786
|
|
|
777
|
-
/**
|
|
778
|
-
* @returns {Promise<Invitation>}
|
|
779
|
-
*/
|
|
787
|
+
/** @returns {Promise<Invitation<VaultKit>>} */
|
|
780
788
|
makeTransferInvitation() {
|
|
781
789
|
const { state, facets } = this;
|
|
782
790
|
const { outerUpdater } = state;
|
|
@@ -808,10 +816,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
808
816
|
|
|
809
817
|
// for status/debugging
|
|
810
818
|
|
|
811
|
-
/**
|
|
812
|
-
*
|
|
813
|
-
* @returns {Amount<'nat'>}
|
|
814
|
-
*/
|
|
819
|
+
/** @returns {Amount<'nat'>} */
|
|
815
820
|
getCollateralAmount() {
|
|
816
821
|
const { state, facets } = this;
|
|
817
822
|
const { vaultSeat } = state;
|
|
@@ -825,15 +830,15 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
825
830
|
/**
|
|
826
831
|
* The actual current debt, including accrued interest.
|
|
827
832
|
*
|
|
828
|
-
* This looks like a simple getter but it does a lot of the heavy
|
|
829
|
-
* interest accrual. Rather than updating all records when
|
|
830
|
-
* the vault manager updates just its rolling
|
|
831
|
-
* calculate what the current debt is given
|
|
832
|
-
* what
|
|
833
|
-
*
|
|
834
|
-
* @see getNormalizedDebt
|
|
833
|
+
* This looks like a simple getter but it does a lot of the heavy
|
|
834
|
+
* lifting for interest accrual. Rather than updating all records when
|
|
835
|
+
* interest accrues, the vault manager updates just its rolling
|
|
836
|
+
* compounded interest. Here we calculate what the current debt is given
|
|
837
|
+
* what's recorded in this vault and what interest has compounded since
|
|
838
|
+
* this vault record was written.
|
|
835
839
|
*
|
|
836
840
|
* @returns {Amount<'nat'>}
|
|
841
|
+
* @see getNormalizedDebt
|
|
837
842
|
*/
|
|
838
843
|
getCurrentDebt() {
|
|
839
844
|
const { state } = this;
|
|
@@ -845,14 +850,15 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
|
|
|
845
850
|
},
|
|
846
851
|
|
|
847
852
|
/**
|
|
848
|
-
* The normalization puts all debts on a common time-independent scale
|
|
849
|
-
* the launch of this vault manager. This allows the manager to
|
|
850
|
-
* by their debt-to-collateral ratios without having to
|
|
851
|
-
* the interest accrues.
|
|
853
|
+
* The normalization puts all debts on a common time-independent scale
|
|
854
|
+
* since the launch of this vault manager. This allows the manager to
|
|
855
|
+
* order vaults by their debt-to-collateral ratios without having to
|
|
856
|
+
* mutate the debts as the interest accrues.
|
|
852
857
|
*
|
|
858
|
+
* @returns {import('./storeUtils.js').NormalizedDebt} as if the vault
|
|
859
|
+
* was open at the launch of this manager, before any interest
|
|
860
|
+
* accrued
|
|
853
861
|
* @see getActualDebAmount
|
|
854
|
-
*
|
|
855
|
-
* @returns {import('./storeUtils.js').NormalizedDebt} as if the vault was open at the launch of this manager, before any interest accrued
|
|
856
862
|
*/
|
|
857
863
|
getNormalizedDebt() {
|
|
858
864
|
const { state } = this;
|