@agoric/inter-protocol 0.17.0 → 0.17.1-upgrade-23-dev-bd79330.0.bd79330
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/package.json +23 -27
- package/source-spec-registry.js +67 -0
- package/src/auction/util.d.ts +3 -1
- package/src/auction/util.d.ts.map +1 -1
- package/src/auction/util.js +1 -2
- package/src/clientSupport.d.ts +29 -73
- package/src/clientSupport.d.ts.map +1 -1
- package/src/clientSupport.js +25 -129
- package/src/collectFees.d.ts +4 -0
- package/src/collectFees.d.ts.map +1 -1
- package/src/collectFees.js +5 -2
- package/src/contractSupport.d.ts +10 -2
- package/src/contractSupport.d.ts.map +1 -1
- package/src/contractSupport.js +8 -3
- package/src/econCommitteeCharter.d.ts +19 -8
- package/src/econCommitteeCharter.d.ts.map +1 -1
- package/src/econCommitteeCharter.js +12 -12
- package/src/feeDistributor.d.ts +56 -52
- package/src/feeDistributor.d.ts.map +1 -1
- package/src/feeDistributor.js +5 -3
- package/src/index.js +0 -3
- package/src/interest-math.d.ts +1 -0
- package/src/interest-math.d.ts.map +1 -1
- package/src/interest-math.js +1 -2
- package/src/interest.d.ts +13 -1
- package/src/interest.d.ts.map +1 -1
- package/src/interest.js +6 -3
- package/src/price/fluxAggregatorContract.d.ts +38 -14
- package/src/price/fluxAggregatorContract.d.ts.map +1 -1
- package/src/price/fluxAggregatorContract.js +26 -12
- package/src/price/fluxAggregatorKit.d.ts +18 -8
- package/src/price/fluxAggregatorKit.d.ts.map +1 -1
- package/src/price/fluxAggregatorKit.js +22 -8
- package/src/price/priceOracleKit.d.ts +3 -1
- package/src/price/priceOracleKit.d.ts.map +1 -1
- package/src/price/priceOracleKit.js +3 -1
- package/src/price/roundsManager.d.ts +15 -8
- package/src/price/roundsManager.d.ts.map +1 -1
- package/src/price/roundsManager.js +9 -2
- package/src/proposals/addAssetToVault.js +17 -105
- package/src/proposals/committee-proposal.js +14 -14
- package/src/proposals/core-proposal.js +12 -37
- package/src/proposals/deploy-price-feeds.js +12 -5
- package/src/proposals/econ-behaviors.js +23 -154
- package/src/proposals/price-feed-proposal.js +14 -4
- package/src/proposals/replace-fee-distributor.js +8 -4
- package/src/proposals/replace-scaledPriceAuthorities.js +8 -2
- package/src/proposals/replaceElectorate.js +7 -1
- package/src/proposals/startEconCommittee.js +5 -1
- package/src/proposals/startPSM.js +15 -6
- package/src/proposals/upgrade-scaledPriceAuthorities.js +5 -0
- package/src/proposals/utils.d.ts +10 -4
- package/src/proposals/utils.d.ts.map +1 -1
- package/src/proposals/utils.js +16 -8
- package/src/proposals/withdraw-reserve-proposal.js +6 -1
- package/src/provisionPool.d.ts +36 -18
- package/src/provisionPool.d.ts.map +1 -1
- package/src/provisionPool.js +19 -12
- package/src/provisionPoolKit.d.ts +29 -77
- package/src/provisionPoolKit.d.ts.map +1 -1
- package/src/provisionPoolKit.js +33 -23
- package/src/psm/psm.d.ts +36 -24
- package/src/psm/psm.d.ts.map +1 -1
- package/src/psm/psm.js +19 -15
- package/src/reserve/assetReserve.d.ts +16 -6
- package/src/reserve/assetReserve.d.ts.map +1 -1
- package/src/reserve/assetReserve.js +17 -9
- package/src/reserve/assetReserveKit.d.ts +13 -10
- package/src/reserve/assetReserveKit.d.ts.map +1 -1
- package/src/reserve/assetReserveKit.js +7 -5
- package/src/reserve/params.d.ts +1 -1
- package/src/reserve/params.d.ts.map +1 -1
- package/src/reserve/params.js +1 -3
- package/src/vaultFactory/burn.d.ts +4 -1
- package/src/vaultFactory/burn.d.ts.map +1 -1
- package/src/vaultFactory/burn.js +5 -4
- package/src/vaultFactory/math.d.ts +2 -0
- package/src/vaultFactory/math.d.ts.map +1 -1
- package/src/vaultFactory/math.js +5 -3
- package/src/vaultFactory/orderedVaultStore.d.ts +36 -36
- package/src/vaultFactory/params.d.ts +37 -10
- package/src/vaultFactory/params.d.ts.map +1 -1
- package/src/vaultFactory/params.js +34 -13
- package/src/vaultFactory/prioritizedVaults.d.ts +98 -95
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -1
- package/src/vaultFactory/prioritizedVaults.js +3 -2
- package/src/vaultFactory/storeUtils.d.ts +8 -3
- package/src/vaultFactory/storeUtils.d.ts.map +1 -1
- package/src/vaultFactory/storeUtils.js +8 -4
- package/src/vaultFactory/{types-ambient.d.ts → types.d.ts} +40 -40
- package/src/vaultFactory/types.d.ts.map +1 -0
- package/src/vaultFactory/{types-ambient.js → types.js} +26 -25
- package/src/vaultFactory/vault.d.ts +51 -35
- package/src/vaultFactory/vault.d.ts.map +1 -1
- package/src/vaultFactory/vault.js +29 -17
- package/src/vaultFactory/vaultDirector.d.ts +102 -112
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -1
- package/src/vaultFactory/vaultDirector.js +40 -82
- package/src/vaultFactory/vaultFactory.d.ts +47 -95
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -1
- package/src/vaultFactory/vaultFactory.js +27 -27
- package/src/vaultFactory/vaultHolder.d.ts +62 -55
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -1
- package/src/vaultFactory/vaultHolder.js +10 -4
- package/src/vaultFactory/vaultKit.d.ts +15 -10
- package/src/vaultFactory/vaultKit.d.ts.map +1 -1
- package/src/vaultFactory/vaultKit.js +8 -7
- package/src/vaultFactory/vaultManager.d.ts +112 -262
- package/src/vaultFactory/vaultManager.d.ts.map +1 -1
- package/src/vaultFactory/vaultManager.js +42 -319
- package/NEWS.md +0 -0
- package/scripts/build-bundles.js +0 -22
- package/src/auction/auctionBook.d.ts +0 -147
- package/src/auction/auctionBook.d.ts.map +0 -1
- package/src/auction/auctionBook.js +0 -794
- package/src/auction/auctionMath.d.ts +0 -17
- package/src/auction/auctionMath.d.ts.map +0 -1
- package/src/auction/auctionMath.js +0 -81
- package/src/auction/auctioneer.d.ts +0 -70
- package/src/auction/auctioneer.d.ts.map +0 -1
- package/src/auction/auctioneer.js +0 -733
- package/src/auction/offerBook.d.ts +0 -46
- package/src/auction/offerBook.d.ts.map +0 -1
- package/src/auction/offerBook.js +0 -226
- package/src/auction/params.d.ts +0 -145
- package/src/auction/params.d.ts.map +0 -1
- package/src/auction/params.js +0 -176
- package/src/auction/scheduleMath.d.ts +0 -5
- package/src/auction/scheduleMath.d.ts.map +0 -1
- package/src/auction/scheduleMath.js +0 -169
- package/src/auction/scheduler.d.ts +0 -50
- package/src/auction/scheduler.d.ts.map +0 -1
- package/src/auction/scheduler.js +0 -376
- package/src/auction/sortedOffers.d.ts +0 -8
- package/src/auction/sortedOffers.d.ts.map +0 -1
- package/src/auction/sortedOffers.js +0 -137
- package/src/proposals/add-auction.js +0 -285
- package/src/proposals/upgrade-vaults.js +0 -207
- package/src/psm/types-ambient.d.ts +0 -2
- package/src/psm/types-ambient.d.ts.map +0 -1
- package/src/psm/types-ambient.js +0 -3
- package/src/vaultFactory/liquidation.d.ts +0 -25
- package/src/vaultFactory/liquidation.d.ts.map +0 -1
- package/src/vaultFactory/liquidation.js +0 -309
- package/src/vaultFactory/proceeds.d.ts +0 -35
- package/src/vaultFactory/proceeds.d.ts.map +0 -1
- package/src/vaultFactory/proceeds.js +0 -282
- package/src/vaultFactory/types-ambient.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vaultManager.d.ts","sourceRoot":"","sources":["vaultManager.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vaultManager.d.ts","sourceRoot":"","sources":["vaultManager.js"],"names":[],"mappings":"AAqGO,mCANM,CAAC,EACQ,CAAC,SAAT,GAAG,EAAG,yBACT,KAAK,YAAY,CAAC,CAAC,CAAC,WACpB,eAAe,CAAC,EAAE,CAAC,CAAC,WACpB,CAAC,iBAqBX;AAwHM,gDATI,OAAO,uDACP;IACN,GAAG,EAAE,eAAe,CAAC;IACrB,UAAU,EAAE,QAAQ,WAAW,CAAC,CAAC;IACjC,eAAe,EAAE,eAAe,CAAC;IACjC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,aAAa,EAAE,k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MtB,eAAe,CAAC,YAAY,CAAC;iCAz8BG,kBAAkB;0BAazC,aAAa;oCAfH,4BAA4B;6BAGnC,4BAA4B;qCACpB,mBAAmB;iCATvB,iDAAiD;6BAD7C,kBAAkB;qCAWlB,6CAA6C;sCAC5C,6CAA6C;wCAC3C,oBAAoB;6BATtB,aAAa;2BAexB,cAAc;4BADb,cAAc;+BAyCI,cAAc;iCAvC3B,0CAA0C;4BApBtC,kBAAkB;oCA0DlB,iBAAiB;gCArDtB,4BAA4B;oCAGX,kBAAkB;2BAMxC,cAAc;6BAVH,aAAa;6BAaL,YAAY;gCAD1B,YAAY;2BADjB,YAAY;kCA4CO,cAAc;iCApD3B,6CAA6C;8BALtC,eAAe;8BAAf,eAAe;6BAC1B,WAAW"}
|
|
@@ -16,10 +16,7 @@
|
|
|
16
16
|
* liquidated. If the auction is unsuccessful, the liquidation may be
|
|
17
17
|
* reverted.
|
|
18
18
|
*/
|
|
19
|
-
/// <reference types="@agoric/zoe/exported" />
|
|
20
19
|
|
|
21
|
-
import { X, Fail, q, makeError } from '@endo/errors';
|
|
22
|
-
import { E } from '@endo/eventual-send';
|
|
23
20
|
import {
|
|
24
21
|
AmountMath,
|
|
25
22
|
AmountShape,
|
|
@@ -27,6 +24,7 @@ import {
|
|
|
27
24
|
NotifierShape,
|
|
28
25
|
RatioShape,
|
|
29
26
|
} from '@agoric/ertp';
|
|
27
|
+
import { multiplyBy } from '@agoric/ertp/src/ratio.js';
|
|
30
28
|
import { makeTracer } from '@agoric/internal';
|
|
31
29
|
import { makeStoredNotifier, observeNotifier } from '@agoric/notifier';
|
|
32
30
|
import { appendToStoredArray } from '@agoric/store/src/stores/store-utils.js';
|
|
@@ -51,25 +49,41 @@ import {
|
|
|
51
49
|
TopicsRecordShape,
|
|
52
50
|
} from '@agoric/zoe/src/contractSupport/index.js';
|
|
53
51
|
import { PriceQuoteShape, SeatShape } from '@agoric/zoe/src/typeGuards.js';
|
|
54
|
-
import {
|
|
52
|
+
import { Fail, makeError, X } from '@endo/errors';
|
|
53
|
+
import { E } from '@endo/eventual-send';
|
|
55
54
|
import {
|
|
56
55
|
checkDebtLimit,
|
|
57
56
|
makeNatAmountShape,
|
|
58
57
|
quoteAsRatio,
|
|
59
58
|
} from '../contractSupport.js';
|
|
60
59
|
import { chargeInterest } from '../interest.js';
|
|
61
|
-
import { getLiquidatableVaults } from './liquidation.js';
|
|
62
60
|
import { calculateMinimumCollateralization, minimumPrice } from './math.js';
|
|
63
61
|
import { makePrioritizedVaults } from './prioritizedVaults.js';
|
|
64
62
|
import { Phase, prepareVault } from './vault.js';
|
|
65
|
-
import { calculateDistributionPlan } from './proceeds.js';
|
|
66
|
-
import { AuctionPFShape } from '../auction/auctioneer.js';
|
|
67
63
|
|
|
68
64
|
/**
|
|
65
|
+
* @import {ERemote, Remote} from '@agoric/internal';
|
|
66
|
+
* @import {EMarshaller} from '@agoric/internal/src/marshal/wrap-marshaller.js';
|
|
69
67
|
* @import {MapStore, SetStore} from '@agoric/store';
|
|
70
68
|
* @import {EReturn} from '@endo/far';
|
|
71
|
-
* @import {ZCFMint} from '@agoric/zoe';
|
|
69
|
+
* @import {ZCFMint, ZCFSeat} from '@agoric/zoe';
|
|
72
70
|
* @import {PriceQuote} from '@agoric/zoe/tools/types.js';
|
|
71
|
+
* @import {PromiseWatcher} from '@agoric/swingset-liveslots';
|
|
72
|
+
* @import {RecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
73
|
+
* @import {LatestTopic, StoredNotifier} from '@agoric/notifier';
|
|
74
|
+
* @import {Baggage} from '@agoric/swingset-liveslots';
|
|
75
|
+
* @import {VaultFactoryZCF} from './vaultFactory.js';
|
|
76
|
+
* @import {MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
77
|
+
* @import {MakeERecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
78
|
+
* @import {FactoryPowersFacet} from './vaultDirector.js';
|
|
79
|
+
* @import {Ratio} from '@agoric/ertp';
|
|
80
|
+
* @import {Vault} from './vault.js';
|
|
81
|
+
* @import {VaultPhase} from './vault.js';
|
|
82
|
+
* @import {MintAndTransfer, VaultId} from './types.js';
|
|
83
|
+
* @import {Amount} from '@agoric/ertp';
|
|
84
|
+
* @import {Brand} from '@agoric/ertp';
|
|
85
|
+
* @import {StorageNode} from '@agoric/internal/src/lib-chainStorage.js';
|
|
86
|
+
* @import {ERef} from '@agoric/vow';
|
|
73
87
|
*/
|
|
74
88
|
|
|
75
89
|
const trace = makeTracer('VM');
|
|
@@ -82,7 +96,7 @@ const trace = makeTracer('VM');
|
|
|
82
96
|
* @template T notifier topic
|
|
83
97
|
* @template {any[]} [A=unknown[]] arbitrary arguments
|
|
84
98
|
* @param {ERef<LatestTopic<T>>} notifierP
|
|
85
|
-
* @param {
|
|
99
|
+
* @param {PromiseWatcher<T, A>} watcher
|
|
86
100
|
* @param {A} args
|
|
87
101
|
*/
|
|
88
102
|
export const watchQuoteNotifier = async (notifierP, watcher, ...args) => {
|
|
@@ -107,7 +121,7 @@ export const watchQuoteNotifier = async (notifierP, watcher, ...args) => {
|
|
|
107
121
|
};
|
|
108
122
|
|
|
109
123
|
/** @import {NormalizedDebt} from './storeUtils.js' */
|
|
110
|
-
/** @import {RelativeTime} from '@agoric/time' */
|
|
124
|
+
/** @import {RelativeTime, Timestamp} from '@agoric/time' */
|
|
111
125
|
|
|
112
126
|
// Metrics naming scheme: nouns are present values; past-participles are accumulative.
|
|
113
127
|
/**
|
|
@@ -169,16 +183,16 @@ export const watchQuoteNotifier = async (notifierP, watcher, ...args) => {
|
|
|
169
183
|
* collateralUnit: Amount<'nat'>;
|
|
170
184
|
* descriptionScope: string;
|
|
171
185
|
* startTimeStamp: Timestamp;
|
|
172
|
-
* storageNode: StorageNode
|
|
186
|
+
* storageNode: Remote<StorageNode>;
|
|
173
187
|
* }>} HeldParams
|
|
174
188
|
*/
|
|
175
189
|
|
|
176
190
|
/**
|
|
177
191
|
* @typedef {{
|
|
178
|
-
* assetTopicKit:
|
|
192
|
+
* assetTopicKit: RecorderKit<AssetState>;
|
|
179
193
|
* debtBrand: Brand<'nat'>;
|
|
180
194
|
* liquidatingVaults: SetStore<Vault>;
|
|
181
|
-
* metricsTopicKit:
|
|
195
|
+
* metricsTopicKit: RecorderKit<MetricsNotification>;
|
|
182
196
|
* poolIncrementSeat: ZCFSeat;
|
|
183
197
|
* retainedCollateralSeat: ZCFSeat;
|
|
184
198
|
* unsettledVaults: MapStore<string, Vault>;
|
|
@@ -207,7 +221,7 @@ export const watchQuoteNotifier = async (notifierP, watcher, ...args) => {
|
|
|
207
221
|
/**
|
|
208
222
|
* @type {(brand: Brand) => {
|
|
209
223
|
* prioritizedVaults: ReturnType<typeof makePrioritizedVaults>;
|
|
210
|
-
* storedQuotesNotifier:
|
|
224
|
+
* storedQuotesNotifier: StoredNotifier<PriceQuote>;
|
|
211
225
|
* storedCollateralQuote: PriceQuote | null;
|
|
212
226
|
* }}
|
|
213
227
|
*/
|
|
@@ -215,13 +229,13 @@ export const watchQuoteNotifier = async (notifierP, watcher, ...args) => {
|
|
|
215
229
|
const collateralEphemera = makeEphemeraProvider(() => /** @type {any} */ ({}));
|
|
216
230
|
|
|
217
231
|
/**
|
|
218
|
-
* @param {
|
|
232
|
+
* @param {Baggage} baggage
|
|
219
233
|
* @param {{
|
|
220
|
-
* zcf:
|
|
221
|
-
* marshaller:
|
|
222
|
-
* makeRecorderKit:
|
|
223
|
-
* makeERecorderKit:
|
|
224
|
-
* factoryPowers:
|
|
234
|
+
* zcf: VaultFactoryZCF;
|
|
235
|
+
* marshaller: ERemote<EMarshaller>;
|
|
236
|
+
* makeRecorderKit: MakeRecorderKit;
|
|
237
|
+
* makeERecorderKit: MakeERecorderKit;
|
|
238
|
+
* factoryPowers: FactoryPowersFacet;
|
|
225
239
|
* }} powers
|
|
226
240
|
*/
|
|
227
241
|
export const prepareVaultManagerKit = (
|
|
@@ -234,7 +248,7 @@ export const prepareVaultManagerKit = (
|
|
|
234
248
|
const makeVault = prepareVault(baggage, makeRecorderKit, zcf);
|
|
235
249
|
|
|
236
250
|
/**
|
|
237
|
-
* @param {HeldParams & { metricsStorageNode: StorageNode }} params
|
|
251
|
+
* @param {HeldParams & { metricsStorageNode: Remote<StorageNode> }} params
|
|
238
252
|
* @returns {HeldParams & ImmutableState & MutableState}
|
|
239
253
|
*/
|
|
240
254
|
const initState = params => {
|
|
@@ -310,9 +324,9 @@ export const prepareVaultManagerKit = (
|
|
|
310
324
|
}),
|
|
311
325
|
helper: M.interface(
|
|
312
326
|
'helper',
|
|
313
|
-
// not exposed so
|
|
327
|
+
// not exposed so using `defaultGuards` is fine.
|
|
314
328
|
{},
|
|
315
|
-
{
|
|
329
|
+
{ defaultGuards: 'passable' },
|
|
316
330
|
),
|
|
317
331
|
manager: M.interface('manager', {
|
|
318
332
|
getGovernedParams: M.call().returns(M.remotable('governedParams')),
|
|
@@ -343,7 +357,6 @@ export const prepareVaultManagerKit = (
|
|
|
343
357
|
getCollateralQuote: M.call().returns(PriceQuoteShape),
|
|
344
358
|
getPublicFacet: M.call().returns(M.remotable('publicFacet')),
|
|
345
359
|
lockOraclePrices: M.call().returns(PriceQuoteShape),
|
|
346
|
-
liquidateVaults: M.call(M.eref(AuctionPFShape)).returns(M.promise()),
|
|
347
360
|
}),
|
|
348
361
|
},
|
|
349
362
|
initState,
|
|
@@ -675,173 +688,6 @@ export const prepareVaultManagerKit = (
|
|
|
675
688
|
|
|
676
689
|
return E(metricsTopicKit.recorder).write(payload);
|
|
677
690
|
},
|
|
678
|
-
|
|
679
|
-
/**
|
|
680
|
-
* This is designed to tolerate an incomplete plan, in case
|
|
681
|
-
* calculateDistributionPlan encounters an error during its calculation.
|
|
682
|
-
* We don't have a way to induce such errors in CI so we've done so
|
|
683
|
-
* manually in dev and verified this function recovers as expected.
|
|
684
|
-
*
|
|
685
|
-
* @param {AmountKeywordRecord} proceeds
|
|
686
|
-
* @param {Amount<'nat'>} totalDebt
|
|
687
|
-
* @param {Pick<PriceQuote, 'quoteAmount'>} oraclePriceAtStart
|
|
688
|
-
* @param {MapStore<
|
|
689
|
-
* Vault,
|
|
690
|
-
* { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
|
|
691
|
-
* >} vaultData
|
|
692
|
-
* @param {Amount<'nat'>} totalCollateral
|
|
693
|
-
*/
|
|
694
|
-
planProceedsDistribution(
|
|
695
|
-
proceeds,
|
|
696
|
-
totalDebt,
|
|
697
|
-
oraclePriceAtStart,
|
|
698
|
-
vaultData,
|
|
699
|
-
totalCollateral,
|
|
700
|
-
) {
|
|
701
|
-
const { state, facets } = this;
|
|
702
|
-
|
|
703
|
-
const { Collateral: collateralProceeds } = proceeds;
|
|
704
|
-
/** @type {Amount<'nat'>} */
|
|
705
|
-
const collateralSold = AmountMath.subtract(
|
|
706
|
-
totalCollateral,
|
|
707
|
-
collateralProceeds,
|
|
708
|
-
);
|
|
709
|
-
state.totalCollateralSold = AmountMath.add(
|
|
710
|
-
state.totalCollateralSold,
|
|
711
|
-
collateralSold,
|
|
712
|
-
);
|
|
713
|
-
|
|
714
|
-
const penaltyRate = facets.self
|
|
715
|
-
.getGovernedParams()
|
|
716
|
-
.getLiquidationPenalty();
|
|
717
|
-
const bestToWorst = [...vaultData.entries()].reverse();
|
|
718
|
-
|
|
719
|
-
// unzip the entry tuples
|
|
720
|
-
const vaultsInPlan = /** @type {Vault[]} */ ([]);
|
|
721
|
-
const vaultsBalances =
|
|
722
|
-
/** @type {import('./proceeds.js').VaultBalances[]} */ ([]);
|
|
723
|
-
for (const [vault, balances] of bestToWorst) {
|
|
724
|
-
vaultsInPlan.push(vault);
|
|
725
|
-
vaultsBalances.push({
|
|
726
|
-
collateral: balances.collateralAmount,
|
|
727
|
-
// if interest accrued during sale, the current debt will be higher
|
|
728
|
-
presaleDebt: balances.debtAmount,
|
|
729
|
-
currentDebt: vault.getCurrentDebt(),
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
harden(vaultsInPlan);
|
|
733
|
-
harden(vaultsBalances);
|
|
734
|
-
|
|
735
|
-
const plan = calculateDistributionPlan({
|
|
736
|
-
proceeds,
|
|
737
|
-
totalDebt,
|
|
738
|
-
totalCollateral,
|
|
739
|
-
oraclePriceAtStart: oraclePriceAtStart.quoteAmount.value[0],
|
|
740
|
-
vaultsBalances,
|
|
741
|
-
penaltyRate,
|
|
742
|
-
});
|
|
743
|
-
return { plan, vaultsInPlan };
|
|
744
|
-
},
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
* This is designed to tolerate an incomplete plan, in case
|
|
748
|
-
* calculateDistributionPlan encounters an error during its calculation.
|
|
749
|
-
* We don't have a way to induce such errors in CI so we've done so
|
|
750
|
-
* manually in dev and verified this function recovers as expected.
|
|
751
|
-
*
|
|
752
|
-
* @param {object} obj
|
|
753
|
-
* @param {import('./proceeds.js').DistributionPlan} obj.plan
|
|
754
|
-
* @param {Vault[]} obj.vaultsInPlan
|
|
755
|
-
* @param {ZCFSeat} obj.liqSeat
|
|
756
|
-
* @param {Amount<'nat'>} obj.totalCollateral
|
|
757
|
-
* @param {Amount<'nat'>} obj.totalDebt
|
|
758
|
-
* @returns {void}
|
|
759
|
-
*/
|
|
760
|
-
distributeProceeds({
|
|
761
|
-
plan,
|
|
762
|
-
vaultsInPlan,
|
|
763
|
-
liqSeat,
|
|
764
|
-
totalCollateral,
|
|
765
|
-
totalDebt,
|
|
766
|
-
}) {
|
|
767
|
-
const { state, facets } = this;
|
|
768
|
-
// Putting all the rearrangements after the loop ensures that errors
|
|
769
|
-
// in the calculations don't result in paying back some vaults and
|
|
770
|
-
// leaving others hanging.
|
|
771
|
-
if (plan.transfersToVault.length > 0) {
|
|
772
|
-
const transfers = plan.transfersToVault.map(
|
|
773
|
-
([vaultIndex, amounts]) =>
|
|
774
|
-
/** @type {TransferPart} */ ([
|
|
775
|
-
liqSeat,
|
|
776
|
-
vaultsInPlan[vaultIndex].getVaultSeat(),
|
|
777
|
-
amounts,
|
|
778
|
-
]),
|
|
779
|
-
);
|
|
780
|
-
zcf.atomicRearrange(harden(transfers));
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
const { prioritizedVaults } = collateralEphemera(
|
|
784
|
-
totalCollateral.brand,
|
|
785
|
-
);
|
|
786
|
-
state.numLiquidationsAborted += plan.vaultsToReinstate.length;
|
|
787
|
-
for (const vaultIndex of plan.vaultsToReinstate) {
|
|
788
|
-
const vault = vaultsInPlan[vaultIndex];
|
|
789
|
-
const vaultId = vault.abortLiquidation();
|
|
790
|
-
prioritizedVaults.addVault(vaultId, vault);
|
|
791
|
-
state.liquidatingVaults.delete(vault);
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
if (!AmountMath.isEmpty(plan.phantomDebt)) {
|
|
795
|
-
state.totalDebt = AmountMath.subtract(
|
|
796
|
-
state.totalDebt,
|
|
797
|
-
plan.phantomDebt,
|
|
798
|
-
);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
facets.helper.burnToCoverDebt(
|
|
802
|
-
plan.debtToBurn,
|
|
803
|
-
plan.mintedProceeds,
|
|
804
|
-
liqSeat,
|
|
805
|
-
);
|
|
806
|
-
if (!AmountMath.isEmpty(plan.mintedForReserve)) {
|
|
807
|
-
facets.helper.sendToReserve(
|
|
808
|
-
plan.mintedForReserve,
|
|
809
|
-
liqSeat,
|
|
810
|
-
'Minted',
|
|
811
|
-
);
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
// send all that's left in the seat
|
|
815
|
-
const collateralInLiqSeat = liqSeat.getCurrentAllocation().Collateral;
|
|
816
|
-
if (!AmountMath.isEmpty(collateralInLiqSeat)) {
|
|
817
|
-
facets.helper.sendToReserve(collateralInLiqSeat, liqSeat);
|
|
818
|
-
}
|
|
819
|
-
// if it didn't match what was expected, report
|
|
820
|
-
if (!AmountMath.isEqual(collateralInLiqSeat, plan.collatRemaining)) {
|
|
821
|
-
console.error(
|
|
822
|
-
`⚠️ Excess collateral remaining sent to reserve. Expected ${q(
|
|
823
|
-
plan.collatRemaining,
|
|
824
|
-
)}, sent ${q(collateralInLiqSeat)}`,
|
|
825
|
-
);
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
// 'totalCollateralSold' is only for this liquidation event
|
|
829
|
-
// 'state.totalCollateralSold' represents all active vaults
|
|
830
|
-
const actualCollateralSold = plan.actualCollateralSold;
|
|
831
|
-
state.totalCollateral = AmountMath.isEmpty(actualCollateralSold)
|
|
832
|
-
? AmountMath.subtract(state.totalCollateral, totalCollateral)
|
|
833
|
-
: AmountMath.subtract(state.totalCollateral, actualCollateralSold);
|
|
834
|
-
|
|
835
|
-
facets.helper.markDoneLiquidating(
|
|
836
|
-
totalDebt,
|
|
837
|
-
totalCollateral,
|
|
838
|
-
plan.overage,
|
|
839
|
-
plan.shortfallToReserve,
|
|
840
|
-
);
|
|
841
|
-
|
|
842
|
-
// liqSeat should be empty at this point, except that funds are sent
|
|
843
|
-
// asynchronously to the reserve.
|
|
844
|
-
},
|
|
845
691
|
},
|
|
846
692
|
|
|
847
693
|
manager: {
|
|
@@ -939,8 +785,8 @@ export const prepareVaultManagerKit = (
|
|
|
939
785
|
* @param {NormalizedDebt} oldDebtNormalized
|
|
940
786
|
* @param {Amount<'nat'>} oldCollateral
|
|
941
787
|
* @param {VaultId} vaultId
|
|
942
|
-
* @param {
|
|
943
|
-
*
|
|
788
|
+
* @param {VaultPhase} vaultPhase at the end of whatever change updated
|
|
789
|
+
* balances
|
|
944
790
|
* @param {Vault} vault
|
|
945
791
|
* @returns {void}
|
|
946
792
|
*/
|
|
@@ -1041,6 +887,7 @@ export const prepareVaultManagerKit = (
|
|
|
1041
887
|
const vaultId = String(state.vaultCounter);
|
|
1042
888
|
|
|
1043
889
|
// must be a presence to be stored in vault state
|
|
890
|
+
/** @type {Remote<StorageNode>} */
|
|
1044
891
|
const vaultStorageNode = await E(
|
|
1045
892
|
E(storageNode).makeChildNode(`vaults`),
|
|
1046
893
|
).makeChildNode(`vault${vaultId}`);
|
|
@@ -1143,131 +990,6 @@ export const prepareVaultManagerKit = (
|
|
|
1143
990
|
void facets.helper.writeMetrics();
|
|
1144
991
|
return storedCollateralQuote;
|
|
1145
992
|
},
|
|
1146
|
-
/** @param {ERef<AuctioneerPublicFacet>} auctionPF */
|
|
1147
|
-
async liquidateVaults(auctionPF) {
|
|
1148
|
-
const { state, facets } = this;
|
|
1149
|
-
const { self, helper } = facets;
|
|
1150
|
-
const {
|
|
1151
|
-
collateralBrand,
|
|
1152
|
-
compoundedInterest,
|
|
1153
|
-
debtBrand,
|
|
1154
|
-
liquidatingVaults,
|
|
1155
|
-
lockedQuote,
|
|
1156
|
-
} = state;
|
|
1157
|
-
trace(collateralBrand, 'considering liquidation');
|
|
1158
|
-
|
|
1159
|
-
if (!lockedQuote) {
|
|
1160
|
-
// By design, the first cycle of auction may call this before a quote is locked
|
|
1161
|
-
// because the schedule is global at the vaultDirector level, and if a manager
|
|
1162
|
-
// starts after the price lock time there's nothing to be done.
|
|
1163
|
-
// NB: this message should not log repeatedly.
|
|
1164
|
-
console.error(
|
|
1165
|
-
'Skipping liquidation because no quote is locked yet (may happen with new manager)',
|
|
1166
|
-
);
|
|
1167
|
-
return;
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
const { storedCollateralQuote: collateralQuoteBefore } =
|
|
1171
|
-
collateralEphemera(this.state.collateralBrand);
|
|
1172
|
-
if (!collateralQuoteBefore) {
|
|
1173
|
-
console.error(
|
|
1174
|
-
'Skipping liquidation because collateralQuote is missing',
|
|
1175
|
-
);
|
|
1176
|
-
return;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
const { prioritizedVaults } = collateralEphemera(collateralBrand);
|
|
1180
|
-
prioritizedVaults || Fail`prioritizedVaults missing from ephemera`;
|
|
1181
|
-
|
|
1182
|
-
const liqMargin = self.getGovernedParams().getLiquidationMargin();
|
|
1183
|
-
|
|
1184
|
-
// totals *among* vaults being liquidated
|
|
1185
|
-
const { totalDebt, totalCollateral, vaultData, liqSeat } =
|
|
1186
|
-
getLiquidatableVaults(
|
|
1187
|
-
zcf,
|
|
1188
|
-
{
|
|
1189
|
-
quote: lockedQuote,
|
|
1190
|
-
interest: compoundedInterest,
|
|
1191
|
-
margin: liqMargin,
|
|
1192
|
-
},
|
|
1193
|
-
prioritizedVaults,
|
|
1194
|
-
liquidatingVaults,
|
|
1195
|
-
debtBrand,
|
|
1196
|
-
collateralBrand,
|
|
1197
|
-
);
|
|
1198
|
-
// reset lockedQuote after we've used it for the liquidation decision
|
|
1199
|
-
state.lockedQuote = undefined;
|
|
1200
|
-
|
|
1201
|
-
if (vaultData.getSize() === 0) {
|
|
1202
|
-
void helper.writeMetrics();
|
|
1203
|
-
return;
|
|
1204
|
-
}
|
|
1205
|
-
trace(
|
|
1206
|
-
' Found vaults to liquidate',
|
|
1207
|
-
liquidatingVaults.getSize(),
|
|
1208
|
-
totalCollateral,
|
|
1209
|
-
);
|
|
1210
|
-
|
|
1211
|
-
helper.markLiquidating(totalDebt, totalCollateral);
|
|
1212
|
-
void helper.writeMetrics();
|
|
1213
|
-
|
|
1214
|
-
const { userSeatPromise, deposited } = await E.when(
|
|
1215
|
-
E(auctionPF).makeDepositInvitation(),
|
|
1216
|
-
depositInvitation =>
|
|
1217
|
-
offerTo(
|
|
1218
|
-
zcf,
|
|
1219
|
-
depositInvitation,
|
|
1220
|
-
harden({ Minted: 'Bid' }),
|
|
1221
|
-
harden({ give: { Collateral: totalCollateral } }),
|
|
1222
|
-
liqSeat,
|
|
1223
|
-
liqSeat,
|
|
1224
|
-
{ goal: totalDebt },
|
|
1225
|
-
),
|
|
1226
|
-
);
|
|
1227
|
-
|
|
1228
|
-
// This is expected to wait for the duration of the auction, which
|
|
1229
|
-
// is controlled by the auction parameters startFrequency, clockStep,
|
|
1230
|
-
// and the difference between startingRate and lowestRate.
|
|
1231
|
-
const [proceeds] = await Promise.all([deposited, userSeatPromise]);
|
|
1232
|
-
|
|
1233
|
-
const { storedCollateralQuote } = collateralEphemera(
|
|
1234
|
-
this.state.collateralBrand,
|
|
1235
|
-
);
|
|
1236
|
-
|
|
1237
|
-
trace(`LiqV after long wait`, proceeds);
|
|
1238
|
-
try {
|
|
1239
|
-
const { plan, vaultsInPlan } = helper.planProceedsDistribution(
|
|
1240
|
-
proceeds,
|
|
1241
|
-
totalDebt,
|
|
1242
|
-
// If a quote was available at the start of liquidation, but is no
|
|
1243
|
-
// longer, using the earlier price is better than failing to
|
|
1244
|
-
// distribute proceeds
|
|
1245
|
-
storedCollateralQuote || collateralQuoteBefore,
|
|
1246
|
-
vaultData,
|
|
1247
|
-
totalCollateral,
|
|
1248
|
-
);
|
|
1249
|
-
trace('PLAN', plan);
|
|
1250
|
-
// distributeProceeds may reconstitute vaults, removing them from liquidatingVaults
|
|
1251
|
-
helper.distributeProceeds({
|
|
1252
|
-
liqSeat,
|
|
1253
|
-
plan,
|
|
1254
|
-
totalCollateral,
|
|
1255
|
-
totalDebt,
|
|
1256
|
-
vaultsInPlan,
|
|
1257
|
-
});
|
|
1258
|
-
} catch (err) {
|
|
1259
|
-
console.error('🚨 Error distributing proceeds:', err);
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
// for all non-reconstituted vaults, transition to 'liquidated' state
|
|
1263
|
-
state.numLiquidationsCompleted += liquidatingVaults.getSize();
|
|
1264
|
-
for (const vault of liquidatingVaults.values()) {
|
|
1265
|
-
vault.liquidated();
|
|
1266
|
-
liquidatingVaults.delete(vault);
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
void helper.writeMetrics();
|
|
1270
|
-
},
|
|
1271
993
|
},
|
|
1272
994
|
},
|
|
1273
995
|
|
|
@@ -1297,6 +1019,7 @@ export const prepareVaultManagerKit = (
|
|
|
1297
1019
|
* >} externalParams
|
|
1298
1020
|
*/
|
|
1299
1021
|
const makeVaultManagerKit = async externalParams => {
|
|
1022
|
+
/** @type {Remote<StorageNode>} */
|
|
1300
1023
|
const metricsStorageNode = await E(
|
|
1301
1024
|
externalParams.storageNode,
|
|
1302
1025
|
).makeChildNode('metrics');
|
|
@@ -1321,7 +1044,7 @@ export const prepareVaultManagerKit = (
|
|
|
1321
1044
|
/**
|
|
1322
1045
|
* Support restarting kits from baggage and mutating the array holding them
|
|
1323
1046
|
*
|
|
1324
|
-
* @param {
|
|
1047
|
+
* @param {Baggage} baggage
|
|
1325
1048
|
*/
|
|
1326
1049
|
export const provideAndStartVaultManagerKits = baggage => {
|
|
1327
1050
|
trace('provideAndStartVaultManagerKits start');
|
package/NEWS.md
DELETED
|
File without changes
|
package/scripts/build-bundles.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
import '@endo/init';
|
|
3
|
-
|
|
4
|
-
import { createBundles } from '@agoric/internal/src/node/createBundles.js';
|
|
5
|
-
import url from 'url';
|
|
6
|
-
|
|
7
|
-
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
8
|
-
|
|
9
|
-
await createBundles(
|
|
10
|
-
[
|
|
11
|
-
['@agoric/inter-protocol/src/psm/psm.js', '../bundles/bundle-psm.js'],
|
|
12
|
-
[
|
|
13
|
-
'@agoric/inter-protocol/src/econCommitteeCharter.js',
|
|
14
|
-
'../bundles/bundle-econCommitteeCharter.js',
|
|
15
|
-
],
|
|
16
|
-
[
|
|
17
|
-
'@agoric/inter-protocol/src/price/fluxAggregatorContract.js',
|
|
18
|
-
'../bundles/bundle-fluxAggregatorKit.js',
|
|
19
|
-
],
|
|
20
|
-
],
|
|
21
|
-
dirname,
|
|
22
|
-
);
|