@agoric/inter-protocol 0.16.1 → 0.16.2-calypso-dev-84eb287.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 +41 -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 +135 -103
- package/src/auction/auctioneer.d.ts +69 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +63 -49
- 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 +17 -15
- package/src/auction/scheduler.d.ts +49 -0
- package/src/auction/scheduler.d.ts.map +1 -0
- package/src/auction/scheduler.js +51 -43
- package/src/auction/sortedOffers.d.ts +8 -0
- package/src/auction/sortedOffers.d.ts.map +1 -0
- package/src/auction/sortedOffers.js +9 -7
- package/src/auction/util.d.ts +32 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +6 -4
- package/src/clientSupport.d.ts +167 -0
- package/src/clientSupport.d.ts.map +1 -0
- package/src/clientSupport.js +154 -96
- 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 +14 -12
- package/src/econCommitteeCharter.d.ts +39 -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 +21 -16
- package/src/price/README.md +13 -0
- package/src/price/fluxAggregatorContract.d.ts +70 -0
- package/src/price/fluxAggregatorContract.d.ts.map +1 -0
- package/src/price/fluxAggregatorContract.js +62 -55
- package/src/price/fluxAggregatorKit.d.ts +103 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +50 -37
- package/src/price/priceOracleKit.d.ts +38 -0
- package/src/price/priceOracleKit.d.ts.map +1 -0
- package/src/price/priceOracleKit.js +11 -13
- package/src/price/roundsManager.d.ts +204 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +79 -82
- package/src/proposals/README.md +2 -3
- package/src/proposals/add-auction.d.ts +69 -0
- package/src/proposals/add-auction.d.ts.map +1 -0
- package/src/proposals/add-auction.js +180 -0
- package/src/proposals/addAssetToVault.d.ts +160 -0
- package/src/proposals/addAssetToVault.d.ts.map +1 -0
- package/src/proposals/addAssetToVault.js +172 -38
- 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/econ-behaviors.d.ts +539 -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 +108 -51
- 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 +38 -27
- 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 +35 -0
- package/src/proposals/upgrade-vaults.d.ts.map +1 -0
- package/src/proposals/upgrade-vaults.js +235 -0
- package/src/proposals/utils.d.ts +17 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +34 -7
- package/src/provisionPool.d.ts +167 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +122 -0
- package/src/provisionPoolKit.d.ts +367 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +522 -0
- package/src/psm/psm.d.ts +122 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +73 -69
- 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 +18 -24
- 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 +36 -22
- 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 +332 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +99 -93
- package/src/vaultFactory/vaultDirector.d.ts +340 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +63 -50
- package/src/vaultFactory/vaultFactory.d.ts +201 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +49 -32
- package/src/vaultFactory/vaultHolder.d.ts +126 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +10 -14
- 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 +249 -151
- package/CHANGELOG.md +0 -1033
- package/bundles/bundle-auctioneer-js-meta.json +0 -722
- package/bundles/bundle-auctioneer.js +0 -1
- package/bundles/bundle-econCommitteeCharter-js-meta.json +0 -514
- package/bundles/bundle-econCommitteeCharter.js +0 -1
- package/bundles/bundle-feeDistributor-js-meta.json +0 -458
- package/bundles/bundle-feeDistributor.js +0 -1
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +0 -674
- package/bundles/bundle-fluxAggregatorKit.js +0 -1
- package/bundles/bundle-psm-js-meta.json +0 -666
- package/bundles/bundle-psm.js +0 -1
- package/bundles/bundle-reserve-js-meta.json +0 -662
- package/bundles/bundle-reserve.js +0 -1
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +0 -542
- package/bundles/bundle-scaledPriceAuthority.js +0 -1
- package/bundles/bundle-vaultFactory-js-meta.json +0 -790
- package/bundles/bundle-vaultFactory.js +0 -1
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vaultManager.d.ts","sourceRoot":"","sources":["vaultManager.js"],"names":[],"mappings":"AAsFO,mCANM,CAAC,EACQ,CAAC,SAAT,GAAG,EAAG,yBACT,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WACpB,OAAO,4BAA4B,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,WACzD,CAAC,iBAqBX;AAwHM,gDATI,OAAO,4BAA4B,EAAE,OAAO,uDAC5C;IACV,GAAO,EAAE,OAAO,mBAAmB,EAAE,eAAe,CAAC;IACrD,UAAc,E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wBAA4B,EAAE,MAAM,CAAC;IACrC,sBAA0B,EAAE,MAAM,CAAC;IACnC,eAAmB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,mBAAuB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,SAAa,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,qBAAyB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,eAAmB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,oBAAwB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,qBAAyB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,sBAA0B,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1C,YAAgB,EAAE,MAAM,CAAC;IACzB,WAAe,EAAE,UAAU,GAAG,SAAS,CAAC;CACrC;8BA+jCU,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC;;;;;;;;2BAE/D,eAAe,CAAC,MAAM,CAAC;gCAMtB,eAAe,CAAC,YAAY,CAAC;oCAtqCT,iBAAiB;gCAvC0C,4BAA4B;kCAwCzF,cAAc"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
1
|
/**
|
|
3
2
|
* @file Vault Manager object manages vault-based debts for a collateral type.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
* - opening a new vault backed by the collateral
|
|
7
|
-
* - publishing metrics on the vault economy for that collateral
|
|
8
|
-
* - charging interest on all active vaults
|
|
9
|
-
* - liquidating active vaults that have exceeded the debt ratio
|
|
4
|
+
* The responsibilities include:
|
|
10
5
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
6
|
+
* - opening a new vault backed by the collateral
|
|
7
|
+
* - publishing metrics on the vault economy for that collateral
|
|
8
|
+
* - charging interest on all active vaults
|
|
9
|
+
* - liquidating active vaults that have exceeded the debt ratio
|
|
14
10
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* Once a vault is settled (liquidated or closed) it can still be used, traded,
|
|
12
|
+
* etc. but is no longer the concern of the manager. It can't be liquidated,
|
|
13
|
+
* have interest charged, or be counted in the metrics.
|
|
14
|
+
*
|
|
15
|
+
* Undercollateralized vaults can have their assets sent to the auctioneer to be
|
|
16
|
+
* liquidated. If the auction is unsuccessful, the liquidation may be
|
|
17
|
+
* reverted.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
/// <reference types="@agoric/zoe/exported" />
|
|
19
20
|
|
|
20
21
|
import {
|
|
21
22
|
AmountMath,
|
|
@@ -50,7 +51,6 @@ import {
|
|
|
50
51
|
} from '@agoric/zoe/src/contractSupport/index.js';
|
|
51
52
|
import { PriceQuoteShape, SeatShape } from '@agoric/zoe/src/typeGuards.js';
|
|
52
53
|
import { E } from '@endo/eventual-send';
|
|
53
|
-
import { AuctionPFShape } from '../auction/auctioneer.js';
|
|
54
54
|
import {
|
|
55
55
|
checkDebtLimit,
|
|
56
56
|
makeNatAmountShape,
|
|
@@ -62,117 +62,165 @@ import { calculateMinimumCollateralization, minimumPrice } from './math.js';
|
|
|
62
62
|
import { makePrioritizedVaults } from './prioritizedVaults.js';
|
|
63
63
|
import { Phase, prepareVault } from './vault.js';
|
|
64
64
|
import { calculateDistributionPlan } from './proceeds.js';
|
|
65
|
+
import { AuctionPFShape } from '../auction/auctioneer.js';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
69
|
+
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
70
|
+
*/
|
|
65
71
|
|
|
66
72
|
const { details: X, Fail, quote: q } = assert;
|
|
67
73
|
|
|
68
74
|
const trace = makeTracer('VM');
|
|
69
75
|
|
|
70
|
-
/**
|
|
71
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Watch a notifier that isn't expected to fail or finish unless the vat hosting
|
|
78
|
+
* the notifier is upgraded. This watcher supports that by providing a
|
|
79
|
+
* straightforward way to get a replacement if the notifier breaks.
|
|
80
|
+
*
|
|
81
|
+
* @template T notifier topic
|
|
82
|
+
* @template {any[]} [A=unknown[]] arbitrary arguments
|
|
83
|
+
* @param {ERef<LatestTopic<T>>} notifierP
|
|
84
|
+
* @param {import('@agoric/swingset-liveslots').PromiseWatcher<T, A>} watcher
|
|
85
|
+
* @param {A} args
|
|
86
|
+
*/
|
|
87
|
+
export const watchQuoteNotifier = async (notifierP, watcher, ...args) => {
|
|
88
|
+
await undefined;
|
|
89
|
+
|
|
90
|
+
let updateCount;
|
|
91
|
+
for (;;) {
|
|
92
|
+
let value;
|
|
93
|
+
try {
|
|
94
|
+
({ value, updateCount } = await E(notifierP).getUpdateSince(updateCount));
|
|
95
|
+
watcher.onFulfilled && watcher.onFulfilled(value, ...args);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
watcher.onRejected && watcher.onRejected(e, ...args);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (updateCount === undefined) {
|
|
101
|
+
watcher.onRejected &&
|
|
102
|
+
watcher.onRejected(Error('stream finished'), ...args);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** @import {NormalizedDebt} from './storeUtils.js' */
|
|
109
|
+
/** @import {RelativeTime} from '@agoric/time' */
|
|
72
110
|
|
|
73
111
|
// Metrics naming scheme: nouns are present values; past-participles are accumulative.
|
|
74
112
|
/**
|
|
75
113
|
* @typedef {object} MetricsNotification
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @property {number}
|
|
80
|
-
* @property {number}
|
|
81
|
-
* @property {Amount<'nat'>}
|
|
82
|
-
*
|
|
83
|
-
* @property {Amount<'nat'>}
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @property {Amount<'nat'>}
|
|
90
|
-
*
|
|
91
|
-
* @property {Amount<'nat'>}
|
|
92
|
-
*
|
|
93
|
-
* @property {
|
|
114
|
+
* @property {Ratio | null} lockedQuote priceQuote that will be used for
|
|
115
|
+
* liquidation. Non-null from priceLock time until liquidation has taken
|
|
116
|
+
* place.
|
|
117
|
+
* @property {number} numActiveVaults present count of vaults
|
|
118
|
+
* @property {number} numLiquidatingVaults present count of liquidating vaults
|
|
119
|
+
* @property {Amount<'nat'>} totalCollateral present sum of collateral across
|
|
120
|
+
* all vaults
|
|
121
|
+
* @property {Amount<'nat'>} totalDebt present sum of debt across all vaults
|
|
122
|
+
* @property {Amount<'nat'>} retainedCollateral collateral held as a result of
|
|
123
|
+
* not returning excess refunds to owners of vaults liquidated with
|
|
124
|
+
* shortfalls
|
|
125
|
+
* @property {Amount<'nat'>} liquidatingCollateral present sum of collateral in
|
|
126
|
+
* vaults sent for liquidation
|
|
127
|
+
* @property {Amount<'nat'>} liquidatingDebt present sum of debt in vaults sent
|
|
128
|
+
* for liquidation
|
|
129
|
+
* @property {Amount<'nat'>} totalCollateralSold running sum of collateral sold
|
|
130
|
+
* in liquidation
|
|
131
|
+
* @property {Amount<'nat'>} totalOverageReceived running sum of overages,
|
|
132
|
+
* central received greater than debt
|
|
133
|
+
* @property {Amount<'nat'>} totalProceedsReceived running sum of minted
|
|
134
|
+
* received from liquidation
|
|
135
|
+
* @property {Amount<'nat'>} totalShortfallReceived running sum of shortfalls,
|
|
136
|
+
* minted received less than debt
|
|
137
|
+
* @property {number} numLiquidationsCompleted running count of liquidated
|
|
138
|
+
* vaults
|
|
139
|
+
* @property {number} numLiquidationsAborted running count of vault liquidations
|
|
140
|
+
* that were reverted.
|
|
94
141
|
*/
|
|
95
142
|
|
|
96
143
|
/**
|
|
97
144
|
* @typedef {{
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
145
|
+
* compoundedInterest: Ratio;
|
|
146
|
+
* interestRate: Ratio;
|
|
147
|
+
* latestInterestUpdate: Timestamp;
|
|
101
148
|
* }} AssetState
|
|
102
149
|
*
|
|
150
|
+
*
|
|
103
151
|
* @typedef {{
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
152
|
+
* getChargingPeriod: () => RelativeTime;
|
|
153
|
+
* getRecordingPeriod: () => RelativeTime;
|
|
154
|
+
* getDebtLimit: () => Amount<'nat'>;
|
|
155
|
+
* getInterestRate: () => Ratio;
|
|
156
|
+
* getLiquidationPadding: () => Ratio;
|
|
157
|
+
* getLiquidationMargin: () => Ratio;
|
|
158
|
+
* getLiquidationPenalty: () => Ratio;
|
|
159
|
+
* getMintFee: () => Ratio;
|
|
160
|
+
* getMinInitialDebt: () => Amount<'nat'>;
|
|
113
161
|
* }} GovernedParamGetters
|
|
114
162
|
*/
|
|
115
163
|
|
|
116
164
|
/**
|
|
117
165
|
* @typedef {Readonly<{
|
|
118
|
-
* debtMint: ZCFMint<'nat'
|
|
119
|
-
* collateralBrand: Brand<'nat'
|
|
120
|
-
* collateralUnit: Amount<'nat'
|
|
121
|
-
* descriptionScope: string
|
|
122
|
-
* startTimeStamp: Timestamp
|
|
123
|
-
* storageNode: StorageNode
|
|
166
|
+
* debtMint: ZCFMint<'nat'>;
|
|
167
|
+
* collateralBrand: Brand<'nat'>;
|
|
168
|
+
* collateralUnit: Amount<'nat'>;
|
|
169
|
+
* descriptionScope: string;
|
|
170
|
+
* startTimeStamp: Timestamp;
|
|
171
|
+
* storageNode: StorageNode;
|
|
124
172
|
* }>} HeldParams
|
|
125
173
|
*/
|
|
126
174
|
|
|
127
175
|
/**
|
|
128
176
|
* @typedef {{
|
|
129
|
-
* assetTopicKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<AssetState
|
|
130
|
-
* debtBrand: Brand<'nat'
|
|
131
|
-
* liquidatingVaults: SetStore<Vault
|
|
132
|
-
* metricsTopicKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<MetricsNotification
|
|
133
|
-
* poolIncrementSeat: ZCFSeat
|
|
134
|
-
* retainedCollateralSeat: ZCFSeat
|
|
135
|
-
* unsettledVaults: MapStore<string, Vault
|
|
177
|
+
* assetTopicKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<AssetState>;
|
|
178
|
+
* debtBrand: Brand<'nat'>;
|
|
179
|
+
* liquidatingVaults: SetStore<Vault>;
|
|
180
|
+
* metricsTopicKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<MetricsNotification>;
|
|
181
|
+
* poolIncrementSeat: ZCFSeat;
|
|
182
|
+
* retainedCollateralSeat: ZCFSeat;
|
|
183
|
+
* unsettledVaults: MapStore<string, Vault>;
|
|
136
184
|
* }} ImmutableState
|
|
137
185
|
*/
|
|
138
186
|
|
|
139
187
|
/**
|
|
140
188
|
* @typedef {{
|
|
141
|
-
* compoundedInterest: Ratio
|
|
142
|
-
* latestInterestUpdate: Timestamp
|
|
143
|
-
* numLiquidationsCompleted: number
|
|
144
|
-
* numLiquidationsAborted: number
|
|
145
|
-
* totalCollateral: Amount<'nat'
|
|
146
|
-
* totalCollateralSold: Amount<'nat'
|
|
147
|
-
* totalDebt: Amount<'nat'
|
|
148
|
-
* liquidatingCollateral: Amount<'nat'
|
|
149
|
-
* liquidatingDebt: Amount<'nat'
|
|
150
|
-
* totalOverageReceived: Amount<'nat'
|
|
151
|
-
* totalProceedsReceived: Amount<'nat'
|
|
152
|
-
* totalShortfallReceived: Amount<'nat'
|
|
153
|
-
* vaultCounter: number
|
|
154
|
-
* lockedQuote: PriceQuote | undefined
|
|
189
|
+
* compoundedInterest: Ratio;
|
|
190
|
+
* latestInterestUpdate: Timestamp;
|
|
191
|
+
* numLiquidationsCompleted: number;
|
|
192
|
+
* numLiquidationsAborted: number;
|
|
193
|
+
* totalCollateral: Amount<'nat'>;
|
|
194
|
+
* totalCollateralSold: Amount<'nat'>;
|
|
195
|
+
* totalDebt: Amount<'nat'>;
|
|
196
|
+
* liquidatingCollateral: Amount<'nat'>;
|
|
197
|
+
* liquidatingDebt: Amount<'nat'>;
|
|
198
|
+
* totalOverageReceived: Amount<'nat'>;
|
|
199
|
+
* totalProceedsReceived: Amount<'nat'>;
|
|
200
|
+
* totalShortfallReceived: Amount<'nat'>;
|
|
201
|
+
* vaultCounter: number;
|
|
202
|
+
* lockedQuote: PriceQuote | undefined;
|
|
155
203
|
* }} MutableState
|
|
156
204
|
*/
|
|
157
205
|
|
|
158
206
|
/**
|
|
159
207
|
* @type {(brand: Brand) => {
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
208
|
+
* prioritizedVaults: ReturnType<typeof makePrioritizedVaults>;
|
|
209
|
+
* storedQuotesNotifier: import('@agoric/notifier').StoredNotifier<PriceQuote>;
|
|
210
|
+
* storedCollateralQuote: PriceQuote | null;
|
|
163
211
|
* }}
|
|
164
212
|
*/
|
|
165
213
|
// any b/c will be filled after start()
|
|
166
214
|
const collateralEphemera = makeEphemeraProvider(() => /** @type {any} */ ({}));
|
|
167
215
|
|
|
168
216
|
/**
|
|
169
|
-
* @param {import('@agoric/
|
|
217
|
+
* @param {import('@agoric/swingset-liveslots').Baggage} baggage
|
|
170
218
|
* @param {{
|
|
171
|
-
* zcf: import('./vaultFactory.js').VaultFactoryZCF
|
|
172
|
-
* marshaller: ERef<Marshaller
|
|
173
|
-
* makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit
|
|
174
|
-
* makeERecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeERecorderKit
|
|
175
|
-
* factoryPowers: import('./vaultDirector.js').FactoryPowersFacet
|
|
219
|
+
* zcf: import('./vaultFactory.js').VaultFactoryZCF;
|
|
220
|
+
* marshaller: ERef<Marshaller>;
|
|
221
|
+
* makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit;
|
|
222
|
+
* makeERecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeERecorderKit;
|
|
223
|
+
* factoryPowers: import('./vaultDirector.js').FactoryPowersFacet;
|
|
176
224
|
* }} powers
|
|
177
225
|
*/
|
|
178
226
|
export const prepareVaultManagerKit = (
|
|
@@ -203,8 +251,9 @@ export const prepareVaultManagerKit = (
|
|
|
203
251
|
poolIncrementSeat: zcf.makeEmptySeatKit().zcfSeat,
|
|
204
252
|
|
|
205
253
|
/**
|
|
206
|
-
* Vaults that have been sent for liquidation. When we get proceeds (or
|
|
207
|
-
* thereof) back from the liquidator, we will allocate them among the
|
|
254
|
+
* Vaults that have been sent for liquidation. When we get proceeds (or
|
|
255
|
+
* lack thereof) back from the liquidator, we will allocate them among the
|
|
256
|
+
* vaults.
|
|
208
257
|
*
|
|
209
258
|
* @type {SetStore<Vault>}
|
|
210
259
|
*/
|
|
@@ -292,7 +341,7 @@ export const prepareVaultManagerKit = (
|
|
|
292
341
|
getCollateralQuote: M.call().returns(PriceQuoteShape),
|
|
293
342
|
getPublicFacet: M.call().returns(M.remotable('publicFacet')),
|
|
294
343
|
lockOraclePrices: M.call().returns(PriceQuoteShape),
|
|
295
|
-
liquidateVaults: M.call(AuctionPFShape).returns(M.promise()),
|
|
344
|
+
liquidateVaults: M.call(M.eref(AuctionPFShape)).returns(M.promise()),
|
|
296
345
|
}),
|
|
297
346
|
},
|
|
298
347
|
initState,
|
|
@@ -339,19 +388,11 @@ export const prepareVaultManagerKit = (
|
|
|
339
388
|
|
|
340
389
|
// Some of these could go in closures but are kept on a facet anticipating future durability options.
|
|
341
390
|
helper: {
|
|
342
|
-
/**
|
|
343
|
-
* Start non-durable processes (or restart if needed after vat restart)
|
|
344
|
-
*/
|
|
391
|
+
/** Start non-durable processes (or restart if needed after vat restart) */
|
|
345
392
|
start() {
|
|
346
393
|
const { state, facets } = this;
|
|
347
394
|
trace(state.collateralBrand, 'helper.start()', state.vaultCounter);
|
|
348
|
-
const {
|
|
349
|
-
collateralBrand,
|
|
350
|
-
collateralUnit,
|
|
351
|
-
debtBrand,
|
|
352
|
-
storageNode,
|
|
353
|
-
unsettledVaults,
|
|
354
|
-
} = state;
|
|
395
|
+
const { collateralBrand, unsettledVaults } = state;
|
|
355
396
|
|
|
356
397
|
const ephemera = collateralEphemera(collateralBrand);
|
|
357
398
|
ephemera.prioritizedVaults = makePrioritizedVaults(unsettledVaults);
|
|
@@ -384,34 +425,53 @@ export const prepareVaultManagerKit = (
|
|
|
384
425
|
},
|
|
385
426
|
});
|
|
386
427
|
|
|
387
|
-
|
|
428
|
+
void facets.helper.observeQuoteNotifier();
|
|
429
|
+
|
|
430
|
+
trace('helper.start() done');
|
|
431
|
+
},
|
|
432
|
+
observeQuoteNotifier() {
|
|
433
|
+
const { state } = this;
|
|
434
|
+
|
|
435
|
+
const { collateralBrand, collateralUnit, debtBrand, storageNode } =
|
|
436
|
+
state;
|
|
437
|
+
const ephemera = collateralEphemera(collateralBrand);
|
|
438
|
+
|
|
388
439
|
const quoteNotifier = E(priceAuthority).makeQuoteNotifier(
|
|
389
440
|
collateralUnit,
|
|
390
441
|
debtBrand,
|
|
391
442
|
);
|
|
443
|
+
// @ts-expect-error XXX quotes
|
|
392
444
|
ephemera.storedQuotesNotifier = makeStoredNotifier(
|
|
445
|
+
// @ts-expect-error XXX quotes
|
|
393
446
|
quoteNotifier,
|
|
394
447
|
E(storageNode).makeChildNode('quotes'),
|
|
395
448
|
marshaller,
|
|
396
449
|
);
|
|
397
|
-
trace(
|
|
450
|
+
trace(
|
|
451
|
+
'helper.start() awaiting observe storedQuotesNotifier',
|
|
452
|
+
collateralBrand,
|
|
453
|
+
);
|
|
398
454
|
// NB: upon restart, there may not be a price for a while. If manager
|
|
399
|
-
// operations are permitted, ones
|
|
400
|
-
// throw. See https://github.com/Agoric/agoric-sdk/issues/4317
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
trace('vaultManager got new collateral quote', value);
|
|
455
|
+
// operations are permitted, ones that depend on price information
|
|
456
|
+
// will throw. See https://github.com/Agoric/agoric-sdk/issues/4317
|
|
457
|
+
const quoteWatcher = harden({
|
|
458
|
+
onFulfilled(value) {
|
|
404
459
|
ephemera.storedCollateralQuote = value;
|
|
405
460
|
},
|
|
406
|
-
|
|
407
|
-
|
|
461
|
+
onRejected() {
|
|
462
|
+
// NOTE: drastic action, if the quoteNotifier fails, we don't know
|
|
463
|
+
// the value of the asset, nor do we know how long we'll be in
|
|
464
|
+
// ignorance. Best choice is to disable actions that require
|
|
465
|
+
// prices and restart when we have a new price. If we restart the
|
|
466
|
+
// notifier immediately, we'll trigger an infinite loop, so try
|
|
467
|
+
// to restart each time we get a request.
|
|
468
|
+
|
|
469
|
+
ephemera.storedCollateralQuote = null;
|
|
408
470
|
},
|
|
409
471
|
});
|
|
410
|
-
|
|
472
|
+
void watchQuoteNotifier(quoteNotifier, quoteWatcher);
|
|
411
473
|
},
|
|
412
|
-
/**
|
|
413
|
-
* @param {Timestamp} updateTime
|
|
414
|
-
*/
|
|
474
|
+
/** @param {Timestamp} updateTime */
|
|
415
475
|
async chargeAllVaults(updateTime) {
|
|
416
476
|
const { state, facets } = this;
|
|
417
477
|
const { collateralBrand, debtMint, poolIncrementSeat } = state;
|
|
@@ -515,7 +575,6 @@ export const prepareVaultManagerKit = (
|
|
|
515
575
|
state.liquidatingDebt = AmountMath.add(state.liquidatingDebt, debt);
|
|
516
576
|
},
|
|
517
577
|
/**
|
|
518
|
-
*
|
|
519
578
|
* @param {Amount<'nat'>} debt
|
|
520
579
|
* @param {Amount<'nat'>} collateral
|
|
521
580
|
* @param {Amount<'nat'>} overage
|
|
@@ -598,14 +657,18 @@ export const prepareVaultManagerKit = (
|
|
|
598
657
|
},
|
|
599
658
|
|
|
600
659
|
/**
|
|
601
|
-
* This is designed to tolerate an incomplete plan, in case
|
|
602
|
-
* an error during its calculation.
|
|
603
|
-
*
|
|
660
|
+
* This is designed to tolerate an incomplete plan, in case
|
|
661
|
+
* calculateDistributionPlan encounters an error during its calculation.
|
|
662
|
+
* We don't have a way to induce such errors in CI so we've done so
|
|
663
|
+
* manually in dev and verified this function recovers as expected.
|
|
604
664
|
*
|
|
605
665
|
* @param {AmountKeywordRecord} proceeds
|
|
606
666
|
* @param {Amount<'nat'>} totalDebt
|
|
607
667
|
* @param {Pick<PriceQuote, 'quoteAmount'>} oraclePriceAtStart
|
|
608
|
-
* @param {MapStore<
|
|
668
|
+
* @param {MapStore<
|
|
669
|
+
* Vault,
|
|
670
|
+
* { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
|
|
671
|
+
* >} vaultData
|
|
609
672
|
* @param {Amount<'nat'>} totalCollateral
|
|
610
673
|
*/
|
|
611
674
|
planProceedsDistribution(
|
|
@@ -661,13 +724,14 @@ export const prepareVaultManagerKit = (
|
|
|
661
724
|
},
|
|
662
725
|
|
|
663
726
|
/**
|
|
664
|
-
* This is designed to tolerate an incomplete plan, in case
|
|
665
|
-
* an error during its calculation.
|
|
666
|
-
*
|
|
727
|
+
* This is designed to tolerate an incomplete plan, in case
|
|
728
|
+
* calculateDistributionPlan encounters an error during its calculation.
|
|
729
|
+
* We don't have a way to induce such errors in CI so we've done so
|
|
730
|
+
* manually in dev and verified this function recovers as expected.
|
|
667
731
|
*
|
|
668
732
|
* @param {object} obj
|
|
669
733
|
* @param {import('./proceeds.js').DistributionPlan} obj.plan
|
|
670
|
-
* @param {
|
|
734
|
+
* @param {Vault[]} obj.vaultsInPlan
|
|
671
735
|
* @param {ZCFSeat} obj.liqSeat
|
|
672
736
|
* @param {Amount<'nat'>} obj.totalCollateral
|
|
673
737
|
* @param {Amount<'nat'>} obj.totalDebt
|
|
@@ -687,7 +751,7 @@ export const prepareVaultManagerKit = (
|
|
|
687
751
|
if (plan.transfersToVault.length > 0) {
|
|
688
752
|
const transfers = plan.transfersToVault.map(
|
|
689
753
|
([vaultIndex, amounts]) =>
|
|
690
|
-
/** @type {
|
|
754
|
+
/** @type {TransferPart} */ ([
|
|
691
755
|
liqSeat,
|
|
692
756
|
vaultsInPlan[vaultIndex].getVaultSeat(),
|
|
693
757
|
amounts,
|
|
@@ -773,10 +837,15 @@ export const prepareVaultManagerKit = (
|
|
|
773
837
|
* @param {Amount<'nat'>} collateralAmount
|
|
774
838
|
*/
|
|
775
839
|
maxDebtFor(collateralAmount) {
|
|
776
|
-
const {
|
|
840
|
+
const { state, facets } = this;
|
|
841
|
+
const { collateralBrand } = state;
|
|
777
842
|
const { storedCollateralQuote } = collateralEphemera(collateralBrand);
|
|
778
|
-
if (!storedCollateralQuote)
|
|
779
|
-
|
|
843
|
+
if (!storedCollateralQuote) {
|
|
844
|
+
facets.helper.observeQuoteNotifier();
|
|
845
|
+
|
|
846
|
+
// it might take an arbitrary amount of time to get a new quote
|
|
847
|
+
throw Fail`maxDebtFor called before a collateral quote was available for ${collateralBrand}`;
|
|
848
|
+
}
|
|
780
849
|
// use the lower price to prevent vault adjustments that put them imminently underwater
|
|
781
850
|
const collateralPrice = minimumPrice(
|
|
782
851
|
storedCollateralQuote,
|
|
@@ -840,9 +909,7 @@ export const prepareVaultManagerKit = (
|
|
|
840
909
|
const { descriptionScope } = this.state;
|
|
841
910
|
return `${descriptionScope}: ${base}`;
|
|
842
911
|
},
|
|
843
|
-
/**
|
|
844
|
-
* coefficient on existing debt to calculate new debt
|
|
845
|
-
*/
|
|
912
|
+
/** coefficient on existing debt to calculate new debt */
|
|
846
913
|
getCompoundedInterest() {
|
|
847
914
|
return this.state.compoundedInterest;
|
|
848
915
|
},
|
|
@@ -852,7 +919,8 @@ export const prepareVaultManagerKit = (
|
|
|
852
919
|
* @param {NormalizedDebt} oldDebtNormalized
|
|
853
920
|
* @param {Amount<'nat'>} oldCollateral
|
|
854
921
|
* @param {VaultId} vaultId
|
|
855
|
-
* @param {import('./vault.js').VaultPhase} vaultPhase at the end of
|
|
922
|
+
* @param {import('./vault.js').VaultPhase} vaultPhase at the end of
|
|
923
|
+
* whatever change updated balances
|
|
856
924
|
* @param {Vault} vault
|
|
857
925
|
* @returns {void}
|
|
858
926
|
*/
|
|
@@ -937,9 +1005,7 @@ export const prepareVaultManagerKit = (
|
|
|
937
1005
|
return factoryPowers.getGovernedParams(collateralBrand);
|
|
938
1006
|
},
|
|
939
1007
|
|
|
940
|
-
/**
|
|
941
|
-
* @param {ZCFSeat} seat
|
|
942
|
-
*/
|
|
1008
|
+
/** @param {ZCFSeat} seat */
|
|
943
1009
|
async makeVaultKit(seat) {
|
|
944
1010
|
const {
|
|
945
1011
|
state,
|
|
@@ -963,7 +1029,6 @@ export const prepareVaultManagerKit = (
|
|
|
963
1029
|
|
|
964
1030
|
try {
|
|
965
1031
|
// TODO `await` is allowed until the above ordering is fixed
|
|
966
|
-
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
967
1032
|
const vaultKit = await vault.initVaultKit(seat, vaultStorageNode);
|
|
968
1033
|
// initVaultKit calls back to handleBalanceChange() which will add the
|
|
969
1034
|
// vault to prioritizedVaults
|
|
@@ -1017,11 +1082,17 @@ export const prepareVaultManagerKit = (
|
|
|
1017
1082
|
},
|
|
1018
1083
|
|
|
1019
1084
|
getCollateralQuote() {
|
|
1085
|
+
const { state, facets } = this;
|
|
1020
1086
|
const { storedCollateralQuote } = collateralEphemera(
|
|
1021
|
-
|
|
1087
|
+
state.collateralBrand,
|
|
1022
1088
|
);
|
|
1023
|
-
if (!storedCollateralQuote)
|
|
1089
|
+
if (!storedCollateralQuote) {
|
|
1090
|
+
facets.helper.observeQuoteNotifier();
|
|
1091
|
+
|
|
1092
|
+
// it might take an arbitrary amount of time to get a new quote
|
|
1024
1093
|
throw Fail`getCollateralQuote called before a collateral quote was available`;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1025
1096
|
return storedCollateralQuote;
|
|
1026
1097
|
},
|
|
1027
1098
|
|
|
@@ -1034,21 +1105,24 @@ export const prepareVaultManagerKit = (
|
|
|
1034
1105
|
const { storedCollateralQuote } = collateralEphemera(
|
|
1035
1106
|
state.collateralBrand,
|
|
1036
1107
|
);
|
|
1037
|
-
if (!storedCollateralQuote)
|
|
1038
|
-
|
|
1108
|
+
if (!storedCollateralQuote) {
|
|
1109
|
+
facets.helper.observeQuoteNotifier();
|
|
1110
|
+
|
|
1111
|
+
// it might take an arbitrary amount of time to get a new quote
|
|
1112
|
+
throw Fail`lockOraclePrices called before a collateral quote was available for ${state.collateralBrand}`;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1039
1115
|
trace(
|
|
1040
|
-
`
|
|
1116
|
+
`lockOraclePrices`,
|
|
1041
1117
|
getAmountIn(storedCollateralQuote),
|
|
1042
1118
|
getAmountOut(storedCollateralQuote),
|
|
1043
1119
|
);
|
|
1044
1120
|
|
|
1045
1121
|
state.lockedQuote = storedCollateralQuote;
|
|
1046
|
-
facets.helper.writeMetrics();
|
|
1122
|
+
void facets.helper.writeMetrics();
|
|
1047
1123
|
return storedCollateralQuote;
|
|
1048
1124
|
},
|
|
1049
|
-
/**
|
|
1050
|
-
* @param {AuctioneerPublicFacet} auctionPF
|
|
1051
|
-
*/
|
|
1125
|
+
/** @param {ERef<AuctioneerPublicFacet>} auctionPF */
|
|
1052
1126
|
async liquidateVaults(auctionPF) {
|
|
1053
1127
|
const { state, facets } = this;
|
|
1054
1128
|
const { self, helper } = facets;
|
|
@@ -1061,11 +1135,28 @@ export const prepareVaultManagerKit = (
|
|
|
1061
1135
|
} = state;
|
|
1062
1136
|
trace(collateralBrand, 'considering liquidation');
|
|
1063
1137
|
|
|
1138
|
+
if (!lockedQuote) {
|
|
1139
|
+
// By design, the first cycle of auction may call this before a quote is locked
|
|
1140
|
+
// because the schedule is global at the vaultDirector level, and if a manager
|
|
1141
|
+
// starts after the price lock time there's nothing to be done.
|
|
1142
|
+
// NB: this message should not log repeatedly.
|
|
1143
|
+
console.error(
|
|
1144
|
+
'Skipping liquidation because no quote is locked yet (may happen with new manager)',
|
|
1145
|
+
);
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
const { storedCollateralQuote: collateralQuoteBefore } =
|
|
1150
|
+
collateralEphemera(this.state.collateralBrand);
|
|
1151
|
+
if (!collateralQuoteBefore) {
|
|
1152
|
+
console.error(
|
|
1153
|
+
'Skipping liquidation because collateralQuote is missing',
|
|
1154
|
+
);
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1064
1158
|
const { prioritizedVaults } = collateralEphemera(collateralBrand);
|
|
1065
|
-
|
|
1066
|
-
lockedQuote ||
|
|
1067
|
-
Fail`Must have locked a quote before liquidating vaults.`;
|
|
1068
|
-
assert(lockedQuote); // redundant with previous line
|
|
1159
|
+
prioritizedVaults || Fail`prioritizedVaults missing from ephemera`;
|
|
1069
1160
|
|
|
1070
1161
|
const liqMargin = self.getGovernedParams().getLiquidationMargin();
|
|
1071
1162
|
|
|
@@ -1087,6 +1178,7 @@ export const prepareVaultManagerKit = (
|
|
|
1087
1178
|
state.lockedQuote = undefined;
|
|
1088
1179
|
|
|
1089
1180
|
if (vaultData.getSize() === 0) {
|
|
1181
|
+
void helper.writeMetrics();
|
|
1090
1182
|
return;
|
|
1091
1183
|
}
|
|
1092
1184
|
trace(
|
|
@@ -1126,7 +1218,10 @@ export const prepareVaultManagerKit = (
|
|
|
1126
1218
|
const { plan, vaultsInPlan } = helper.planProceedsDistribution(
|
|
1127
1219
|
proceeds,
|
|
1128
1220
|
totalDebt,
|
|
1129
|
-
|
|
1221
|
+
// If a quote was available at the start of liquidation, but is no
|
|
1222
|
+
// longer, using the earlier price is better than failing to
|
|
1223
|
+
// distribute proceeds
|
|
1224
|
+
storedCollateralQuote || collateralQuoteBefore,
|
|
1130
1225
|
vaultData,
|
|
1131
1226
|
totalCollateral,
|
|
1132
1227
|
);
|
|
@@ -1150,7 +1245,7 @@ export const prepareVaultManagerKit = (
|
|
|
1150
1245
|
liquidatingVaults.delete(vault);
|
|
1151
1246
|
}
|
|
1152
1247
|
|
|
1153
|
-
|
|
1248
|
+
void helper.writeMetrics();
|
|
1154
1249
|
},
|
|
1155
1250
|
},
|
|
1156
1251
|
},
|
|
@@ -1174,7 +1269,12 @@ export const prepareVaultManagerKit = (
|
|
|
1174
1269
|
},
|
|
1175
1270
|
);
|
|
1176
1271
|
|
|
1177
|
-
/**
|
|
1272
|
+
/**
|
|
1273
|
+
* @param {Omit<
|
|
1274
|
+
* Parameters<typeof makeVaultManagerKitInternal>[0],
|
|
1275
|
+
* 'metricsStorageNode'
|
|
1276
|
+
* >} externalParams
|
|
1277
|
+
*/
|
|
1178
1278
|
const makeVaultManagerKit = async externalParams => {
|
|
1179
1279
|
const metricsStorageNode = await E(
|
|
1180
1280
|
externalParams.storageNode,
|
|
@@ -1187,15 +1287,13 @@ export const prepareVaultManagerKit = (
|
|
|
1187
1287
|
return makeVaultManagerKit;
|
|
1188
1288
|
};
|
|
1189
1289
|
|
|
1290
|
+
/** @typedef {Awaited<ReturnType<ReturnType<typeof prepareVaultManagerKit>>>} VaultManagerKit */
|
|
1190
1291
|
/**
|
|
1191
|
-
* @typedef {
|
|
1192
|
-
|
|
1193
|
-
/**
|
|
1194
|
-
* @typedef {VaultManagerKit['self']} VaultManager
|
|
1195
|
-
* Each VaultManager manages a single collateral type.
|
|
1292
|
+
* @typedef {VaultManagerKit['self']} VaultManager Each VaultManager manages a
|
|
1293
|
+
* single collateral type.
|
|
1196
1294
|
*
|
|
1197
|
-
*
|
|
1198
|
-
*
|
|
1295
|
+
* It manages some number of outstanding debt positions, each called a Vault,
|
|
1296
|
+
* for which the collateral is provided in exchange for borrowed Minted.
|
|
1199
1297
|
*/
|
|
1200
1298
|
/** @typedef {VaultManagerKit['collateral']} CollateralManager */
|
|
1201
1299
|
|