@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,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '@agoric/governance/exported.js';
|
|
1
|
+
/// <reference types="@agoric/governance/exported" />
|
|
2
|
+
/// <reference types="@agoric/zoe/exported" />
|
|
5
3
|
|
|
4
|
+
import { Fail, q } from '@endo/errors';
|
|
5
|
+
import { E } from '@endo/eventual-send';
|
|
6
|
+
import { Far } from '@endo/marshal';
|
|
6
7
|
import { AmountMath, AmountShape, BrandShape, IssuerShape } from '@agoric/ertp';
|
|
7
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
GovernorFacetShape,
|
|
10
|
+
InvitationShape,
|
|
11
|
+
} from '@agoric/governance/src/typeGuards.js';
|
|
8
12
|
import { makeTracer } from '@agoric/internal';
|
|
9
13
|
import { M, mustMatch } from '@agoric/store';
|
|
10
14
|
import {
|
|
@@ -14,15 +18,12 @@ import {
|
|
|
14
18
|
} from '@agoric/vat-data';
|
|
15
19
|
import { assertKeywordName } from '@agoric/zoe/src/cleanProposal.js';
|
|
16
20
|
import {
|
|
17
|
-
atomicRearrange,
|
|
18
21
|
makeRecorderTopic,
|
|
19
22
|
provideEmptySeat,
|
|
20
23
|
SubscriberShape,
|
|
21
24
|
TopicsRecordShape,
|
|
22
25
|
unitAmount,
|
|
23
26
|
} from '@agoric/zoe/src/contractSupport/index.js';
|
|
24
|
-
import { E } from '@endo/eventual-send';
|
|
25
|
-
import { Far } from '@endo/marshal';
|
|
26
27
|
import { makeCollectFeesInvitation } from '../collectFees.js';
|
|
27
28
|
import {
|
|
28
29
|
setWakeupsForNextAuction,
|
|
@@ -38,51 +39,75 @@ import {
|
|
|
38
39
|
provideAndStartVaultManagerKits,
|
|
39
40
|
} from './vaultManager.js';
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
44
|
+
*/
|
|
42
45
|
|
|
43
46
|
const trace = makeTracer('VD', true);
|
|
44
47
|
|
|
45
48
|
/**
|
|
46
49
|
* @typedef {{
|
|
47
|
-
*
|
|
48
|
-
*
|
|
50
|
+
* collaterals: Brand[];
|
|
51
|
+
* rewardPoolAllocation: AmountKeywordRecord;
|
|
49
52
|
* }} MetricsNotification
|
|
50
53
|
*
|
|
51
|
-
* @typedef {Readonly<{
|
|
52
|
-
* }>} ImmutableState
|
|
53
54
|
*
|
|
54
|
-
* @typedef {{
|
|
55
|
-
*
|
|
55
|
+
* @typedef {Readonly<{}>} ImmutableState
|
|
56
|
+
*
|
|
57
|
+
* @typedef {{}} MutableState
|
|
56
58
|
*
|
|
57
59
|
* @typedef {ImmutableState & MutableState} State
|
|
58
60
|
*
|
|
59
61
|
* @typedef {{
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
62
|
+
* burnDebt: BurnDebt;
|
|
63
|
+
* getGovernedParams: (
|
|
64
|
+
* collateralBrand: Brand,
|
|
65
|
+
* ) => import('./vaultManager.js').GovernedParamGetters;
|
|
66
|
+
* mintAndTransfer: MintAndTransfer;
|
|
67
|
+
* getShortfallReporter: () => Promise<
|
|
68
|
+
* import('../reserve/assetReserve.js').ShortfallReporter
|
|
69
|
+
* >;
|
|
64
70
|
* }} FactoryPowersFacet
|
|
65
71
|
*
|
|
72
|
+
*
|
|
66
73
|
* @typedef {Readonly<{
|
|
67
74
|
* state: State;
|
|
68
75
|
* }>} MethodContext
|
|
69
76
|
*
|
|
70
|
-
* @typedef {import('@agoric/governance/src/contractGovernance/typedParamManager').TypedParamManager<
|
|
77
|
+
* @typedef {import('@agoric/governance/src/contractGovernance/typedParamManager.js').TypedParamManager<
|
|
78
|
+
* import('./params.js').VaultDirectorParams
|
|
79
|
+
* >} VaultDirectorParamManager
|
|
71
80
|
*/
|
|
72
81
|
|
|
73
82
|
const shortfallInvitationKey = 'shortfallInvitation';
|
|
74
83
|
|
|
84
|
+
// If one manager/token fails, we don't want that to block possible success for
|
|
85
|
+
// others, so we .catch() and log separately.
|
|
86
|
+
//
|
|
87
|
+
// exported for testing
|
|
88
|
+
export const makeAllManagersDo = (collateralManagers, vaultManagers) => {
|
|
89
|
+
/** @param {(vm: VaultManager) => void} fn */
|
|
90
|
+
return fn => {
|
|
91
|
+
for (const managerIndex of collateralManagers.values()) {
|
|
92
|
+
Promise.resolve(vaultManagers.get(managerIndex).self)
|
|
93
|
+
.then(vm => fn(vm))
|
|
94
|
+
.catch(e => trace('🚨ERROR: allManagersDo', e));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
75
99
|
/**
|
|
76
|
-
* @param {import('@agoric/
|
|
100
|
+
* @param {import('@agoric/swingset-liveslots').Baggage} baggage
|
|
77
101
|
* @param {import('./vaultFactory.js').VaultFactoryZCF} zcf
|
|
78
102
|
* @param {VaultDirectorParamManager} directorParamManager
|
|
79
|
-
* @param {ZCFMint<
|
|
80
|
-
* @param {ERef<import('@agoric/time
|
|
103
|
+
* @param {ZCFMint<'nat'>} debtMint
|
|
104
|
+
* @param {ERef<import('@agoric/time').TimerService>} timer
|
|
81
105
|
* @param {ERef<import('../auction/auctioneer.js').AuctioneerPublicFacet>} auctioneer
|
|
82
106
|
* @param {ERef<StorageNode>} storageNode
|
|
83
107
|
* @param {ERef<Marshaller>} marshaller
|
|
84
108
|
* @param {import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit} makeRecorderKit
|
|
85
109
|
* @param {import('@agoric/zoe/src/contractSupport/recorder.js').MakeERecorderKit} makeERecorderKit
|
|
110
|
+
* @param {Record<string, import('./params.js').VaultManagerParamOverrides>} managerParams
|
|
86
111
|
*/
|
|
87
112
|
const prepareVaultDirector = (
|
|
88
113
|
baggage,
|
|
@@ -95,6 +120,7 @@ const prepareVaultDirector = (
|
|
|
95
120
|
marshaller,
|
|
96
121
|
makeRecorderKit,
|
|
97
122
|
makeERecorderKit,
|
|
123
|
+
managerParams,
|
|
98
124
|
) => {
|
|
99
125
|
/** @type {import('../reserve/assetReserve.js').ShortfallReporter} */
|
|
100
126
|
let shortfallReporter;
|
|
@@ -113,22 +139,22 @@ const prepareVaultDirector = (
|
|
|
113
139
|
// Non-durable map because param managers aren't durable.
|
|
114
140
|
// In the event they're needed they can be reconstructed from contract terms and off-chain data.
|
|
115
141
|
/** a powerful object; can modify parameters */
|
|
116
|
-
const vaultParamManagers = provideVaultParamManagers(
|
|
142
|
+
const vaultParamManagers = provideVaultParamManagers(
|
|
143
|
+
baggage,
|
|
144
|
+
marshaller,
|
|
145
|
+
managerParams,
|
|
146
|
+
);
|
|
117
147
|
|
|
118
148
|
const metricsNode = E(storageNode).makeChildNode('metrics');
|
|
119
149
|
|
|
120
150
|
const metricsKit = makeERecorderKit(
|
|
121
151
|
metricsNode,
|
|
122
|
-
/** @type {
|
|
123
|
-
M.any()
|
|
124
|
-
),
|
|
152
|
+
/** @type {TypedPattern<MetricsNotification>} */ (M.any()),
|
|
125
153
|
);
|
|
126
154
|
|
|
127
155
|
const managersNode = E(storageNode).makeChildNode('managers');
|
|
128
156
|
|
|
129
|
-
/**
|
|
130
|
-
* @returns {MetricsNotification}
|
|
131
|
-
*/
|
|
157
|
+
/** @returns {MetricsNotification} */
|
|
132
158
|
const sampleMetrics = () => {
|
|
133
159
|
return harden({
|
|
134
160
|
collaterals: Array.from(collateralManagers.keys()),
|
|
@@ -141,6 +167,7 @@ const prepareVaultDirector = (
|
|
|
141
167
|
const oldInvitation = baggage.has(shortfallInvitationKey)
|
|
142
168
|
? baggage.get(shortfallInvitationKey)
|
|
143
169
|
: undefined;
|
|
170
|
+
|
|
144
171
|
const newInvitation = await directorParamManager.getInternalParamValue(
|
|
145
172
|
SHORTFALL_INVITATION_KEY,
|
|
146
173
|
);
|
|
@@ -188,22 +215,22 @@ const prepareVaultDirector = (
|
|
|
188
215
|
},
|
|
189
216
|
|
|
190
217
|
/**
|
|
191
|
-
* Let the manager add rewards to the rewardPoolSeat without
|
|
192
|
-
*
|
|
218
|
+
* Let the manager add rewards to the rewardPoolSeat without exposing the
|
|
219
|
+
* rewardPoolSeat to them.
|
|
193
220
|
*
|
|
194
221
|
* @type {MintAndTransfer}
|
|
195
222
|
*/
|
|
196
223
|
mintAndTransfer: (mintReceiver, toMint, fee, nonMintTransfers) => {
|
|
197
224
|
const kept = AmountMath.subtract(toMint, fee);
|
|
198
225
|
debtMint.mintGains(harden({ Minted: toMint }), mintSeat);
|
|
199
|
-
/** @type {
|
|
226
|
+
/** @type {TransferPart[]} */
|
|
200
227
|
const transfers = [
|
|
201
228
|
...nonMintTransfers,
|
|
202
229
|
[mintSeat, rewardPoolSeat, { Minted: fee }],
|
|
203
230
|
[mintSeat, mintReceiver, { Minted: kept }],
|
|
204
231
|
];
|
|
205
232
|
try {
|
|
206
|
-
atomicRearrange(
|
|
233
|
+
zcf.atomicRearrange(harden(transfers));
|
|
207
234
|
} catch (e) {
|
|
208
235
|
console.error('mintAndTransfer failed to rearrange', e);
|
|
209
236
|
// If the rearrange fails, burn the newly minted tokens.
|
|
@@ -250,12 +277,7 @@ const prepareVaultDirector = (
|
|
|
250
277
|
metrics: makeRecorderTopic('Vault Factory metrics', metricsKit),
|
|
251
278
|
});
|
|
252
279
|
|
|
253
|
-
const allManagersDo =
|
|
254
|
-
for (const managerIndex of collateralManagers.values()) {
|
|
255
|
-
const vm = vaultManagers.get(managerIndex).self;
|
|
256
|
-
fn(vm);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
280
|
+
const allManagersDo = makeAllManagersDo(collateralManagers, vaultManagers);
|
|
259
281
|
|
|
260
282
|
const makeWaker = (name, func) => {
|
|
261
283
|
return Far(name, {
|
|
@@ -263,9 +285,7 @@ const prepareVaultDirector = (
|
|
|
263
285
|
});
|
|
264
286
|
};
|
|
265
287
|
|
|
266
|
-
/**
|
|
267
|
-
* @returns {State}
|
|
268
|
-
*/
|
|
288
|
+
/** @returns {State} */
|
|
269
289
|
const initState = () => {
|
|
270
290
|
return {};
|
|
271
291
|
};
|
|
@@ -275,7 +295,7 @@ const prepareVaultDirector = (
|
|
|
275
295
|
*
|
|
276
296
|
* @param {import('./vaultFactory.js').VaultFactoryZCF} zcf
|
|
277
297
|
* @param {VaultDirectorParamManager} directorParamManager
|
|
278
|
-
* @param {ZCFMint<
|
|
298
|
+
* @param {ZCFMint<'nat'>} debtMint
|
|
279
299
|
*/
|
|
280
300
|
const makeVaultDirector = prepareExoClassKit(
|
|
281
301
|
baggage,
|
|
@@ -293,6 +313,7 @@ const prepareVaultDirector = (
|
|
|
293
313
|
makePriceLockWaker: M.call().returns(M.remotable('TimerWaker')),
|
|
294
314
|
makeLiquidationWaker: M.call().returns(M.remotable('TimerWaker')),
|
|
295
315
|
makeReschedulerWaker: M.call().returns(M.remotable('TimerWaker')),
|
|
316
|
+
setShortfallReporter: M.call(InvitationShape).returns(M.promise()),
|
|
296
317
|
}),
|
|
297
318
|
public: M.interface('public', {
|
|
298
319
|
getCollateralManager: M.call(BrandShape).returns(M.remotable()),
|
|
@@ -301,7 +322,7 @@ const prepareVaultDirector = (
|
|
|
301
322
|
SubscriberShape,
|
|
302
323
|
),
|
|
303
324
|
getElectorateSubscription: M.call().returns(SubscriberShape),
|
|
304
|
-
getGovernedParams: M.
|
|
325
|
+
getGovernedParams: M.callWhen({ collateralBrand: BrandShape }).returns(
|
|
305
326
|
M.record(),
|
|
306
327
|
),
|
|
307
328
|
getInvitationAmount: M.call(M.string()).returns(AmountShape),
|
|
@@ -330,9 +351,7 @@ const prepareVaultDirector = (
|
|
|
330
351
|
}
|
|
331
352
|
},
|
|
332
353
|
}),
|
|
333
|
-
/**
|
|
334
|
-
* @param {string} name
|
|
335
|
-
*/
|
|
354
|
+
/** @param {string} name */
|
|
336
355
|
getInvitation(name) {
|
|
337
356
|
return directorParamManager.getInternalParamValue(name);
|
|
338
357
|
},
|
|
@@ -378,9 +397,8 @@ const prepareVaultDirector = (
|
|
|
378
397
|
// zero-based index of the manager being made
|
|
379
398
|
const managerIndex = vaultManagers.length();
|
|
380
399
|
const managerId = `manager${managerIndex}`;
|
|
381
|
-
const managerStorageNode =
|
|
382
|
-
managerId
|
|
383
|
-
);
|
|
400
|
+
const managerStorageNode =
|
|
401
|
+
await E(managersNode).makeChildNode(managerId);
|
|
384
402
|
|
|
385
403
|
vaultParamManagers.addParamManager(
|
|
386
404
|
collateralBrand,
|
|
@@ -424,6 +442,7 @@ const prepareVaultDirector = (
|
|
|
424
442
|
|
|
425
443
|
makeLiquidationWaker() {
|
|
426
444
|
return makeWaker('liquidationWaker', _timestamp => {
|
|
445
|
+
// XXX floating promise
|
|
427
446
|
allManagersDo(vm => vm.liquidateVaults(auctioneer));
|
|
428
447
|
});
|
|
429
448
|
},
|
|
@@ -438,11 +457,15 @@ const prepareVaultDirector = (
|
|
|
438
457
|
allManagersDo(vm => vm.lockOraclePrices());
|
|
439
458
|
});
|
|
440
459
|
},
|
|
460
|
+
async setShortfallReporter(newInvitation) {
|
|
461
|
+
const zoe = zcf.getZoeService();
|
|
462
|
+
shortfallReporter = await E(
|
|
463
|
+
E(zoe).offer(newInvitation),
|
|
464
|
+
).getOfferResult();
|
|
465
|
+
},
|
|
441
466
|
},
|
|
442
467
|
public: {
|
|
443
|
-
/**
|
|
444
|
-
* @param {Brand} brandIn
|
|
445
|
-
*/
|
|
468
|
+
/** @param {Brand} brandIn */
|
|
446
469
|
getCollateralManager(brandIn) {
|
|
447
470
|
collateralManagers.has(brandIn) ||
|
|
448
471
|
Fail`Not a supported collateral type ${brandIn}`;
|
|
@@ -463,22 +486,21 @@ const prepareVaultDirector = (
|
|
|
463
486
|
getPublicTopics() {
|
|
464
487
|
return topics;
|
|
465
488
|
},
|
|
466
|
-
/**
|
|
467
|
-
* subscription for the paramManager for the vaultFactory's electorate
|
|
468
|
-
*/
|
|
489
|
+
/** subscription for the paramManager for the vaultFactory's electorate */
|
|
469
490
|
getElectorateSubscription() {
|
|
470
491
|
return directorParamManager.getSubscription();
|
|
471
492
|
},
|
|
472
493
|
/**
|
|
494
|
+
* Note this works only for a collateral manager. For the director use,
|
|
495
|
+
* `getElectorateSubscription`
|
|
496
|
+
*
|
|
473
497
|
* @param {{ collateralBrand: Brand }} selector
|
|
474
498
|
*/
|
|
475
499
|
getGovernedParams({ collateralBrand }) {
|
|
476
500
|
// TODO use named getters of TypedParamManager
|
|
477
501
|
return vaultParamManagers.get(collateralBrand).getParams();
|
|
478
502
|
},
|
|
479
|
-
/**
|
|
480
|
-
* @param {string} name
|
|
481
|
-
*/
|
|
503
|
+
/** @param {string} name */
|
|
482
504
|
getInvitationAmount(name) {
|
|
483
505
|
return directorParamManager.getInvitationAmount(name);
|
|
484
506
|
},
|
|
@@ -498,9 +520,7 @@ const prepareVaultDirector = (
|
|
|
498
520
|
rescheduleWaker,
|
|
499
521
|
);
|
|
500
522
|
},
|
|
501
|
-
/**
|
|
502
|
-
* Start non-durable processes (or restart if needed after vat restart)
|
|
503
|
-
*/
|
|
523
|
+
/** Start non-durable processes (or restart if needed after vat restart) */
|
|
504
524
|
async start() {
|
|
505
525
|
const { helper, machine } = this.facets;
|
|
506
526
|
|
|
@@ -525,7 +545,9 @@ harden(prepareVaultDirector);
|
|
|
525
545
|
/**
|
|
526
546
|
* Prepare the VaultDirector kind, get or make the singleton
|
|
527
547
|
*
|
|
528
|
-
* @type {(
|
|
548
|
+
* @type {(
|
|
549
|
+
* ...pvdArgs: Parameters<typeof prepareVaultDirector>
|
|
550
|
+
* ) => ReturnType<ReturnType<typeof prepareVaultDirector>>}
|
|
529
551
|
*/
|
|
530
552
|
export const provideDirector = (...args) => {
|
|
531
553
|
const makeVaultDirector = prepareVaultDirector(...args);
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {ZCF<
|
|
3
|
+
* GovernanceTerms<import('./params').VaultDirectorParams> & {
|
|
4
|
+
* priceAuthority: ERef<PriceAuthority>;
|
|
5
|
+
* reservePublicFacet: AssetReservePublicFacet;
|
|
6
|
+
* timerService: import('@agoric/time').TimerService;
|
|
7
|
+
* }
|
|
8
|
+
* >} VaultFactoryZCF
|
|
9
|
+
*/
|
|
10
|
+
/** @type {ContractMeta} */
|
|
11
|
+
export const meta: ContractMeta;
|
|
12
|
+
export function start(zcf: VaultFactoryZCF, privateArgs: {
|
|
13
|
+
feeMintAccess: FeeMintAccess;
|
|
14
|
+
initialPoserInvitation: Invitation;
|
|
15
|
+
initialShortfallInvitation: Invitation;
|
|
16
|
+
storageNode: ERef<StorageNode>;
|
|
17
|
+
marshaller: ERef<Marshaller>;
|
|
18
|
+
auctioneerInstance: Instance;
|
|
19
|
+
managerParams: Record<string, import("./params.js").VaultManagerParamOverrides>;
|
|
20
|
+
directorParamOverrides: [object];
|
|
21
|
+
}, baggage: import("@agoric/swingset-liveslots").Baggage): Promise<{
|
|
22
|
+
creatorFacet: import("@endo/exo").Guarded<{
|
|
23
|
+
getParamMgrRetriever: () => {
|
|
24
|
+
get: (paramPath?: VaultFactoryParamPath) => import("./vaultDirector.js").VaultDirectorParamManager | import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
|
|
25
|
+
DebtLimit: "amount";
|
|
26
|
+
InterestRate: "ratio";
|
|
27
|
+
LiquidationPadding: "ratio";
|
|
28
|
+
LiquidationMargin: "ratio";
|
|
29
|
+
LiquidationPenalty: "ratio";
|
|
30
|
+
MintFee: "ratio";
|
|
31
|
+
}>;
|
|
32
|
+
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
33
|
+
get: (paramPath?: VaultFactoryParamPath) => import("./vaultDirector.js").VaultDirectorParamManager | import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
|
|
34
|
+
DebtLimit: "amount";
|
|
35
|
+
InterestRate: "ratio";
|
|
36
|
+
LiquidationPadding: "ratio";
|
|
37
|
+
LiquidationMargin: "ratio";
|
|
38
|
+
LiquidationPenalty: "ratio";
|
|
39
|
+
MintFee: "ratio";
|
|
40
|
+
}>;
|
|
41
|
+
}>;
|
|
42
|
+
getInvitation(name: string): Promise<Invitation<unknown, undefined>>;
|
|
43
|
+
getLimitedCreatorFacet(): import("@endo/exo").Guarded<{
|
|
44
|
+
addVaultType(collateralIssuer: Issuer<"nat">, collateralKeyword: Keyword, initialParamValues: VaultManagerParamValues): Promise<import("@endo/exo").Guarded<{
|
|
45
|
+
getGovernedParams(): import("./vaultManager.js").GovernedParamGetters;
|
|
46
|
+
makeVaultKit(seat: ZCFSeat): Promise<{
|
|
47
|
+
publicSubscribers: {
|
|
48
|
+
vault: {
|
|
49
|
+
description: string;
|
|
50
|
+
subscriber: globalThis.Subscriber<VaultNotification>;
|
|
51
|
+
storagePath: Promise<string>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
55
|
+
AdjustBalances(): Promise<Invitation<string, undefined>>;
|
|
56
|
+
CloseVault(): Promise<Invitation<string, undefined>>;
|
|
57
|
+
TransferVault(): Promise<Invitation<any, undefined>>;
|
|
58
|
+
}>;
|
|
59
|
+
vault: import("@endo/exo").Guarded<{
|
|
60
|
+
getPublicTopics(): {
|
|
61
|
+
vault: {
|
|
62
|
+
description: string;
|
|
63
|
+
subscriber: globalThis.Subscriber<VaultNotification>;
|
|
64
|
+
storagePath: Promise<string>;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
68
|
+
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
69
|
+
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
70
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
71
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
72
|
+
getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
|
|
73
|
+
}>;
|
|
74
|
+
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
75
|
+
}>;
|
|
76
|
+
getCollateralQuote(): PriceQuote;
|
|
77
|
+
getPublicFacet(): import("@endo/exo").Guarded<{
|
|
78
|
+
makeVaultInvitation(): Promise<Invitation<{
|
|
79
|
+
publicSubscribers: {
|
|
80
|
+
vault: {
|
|
81
|
+
description: string;
|
|
82
|
+
subscriber: globalThis.Subscriber<VaultNotification>;
|
|
83
|
+
storagePath: Promise<string>;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
87
|
+
AdjustBalances(): Promise<Invitation<string, undefined>>;
|
|
88
|
+
CloseVault(): Promise<Invitation<string, undefined>>;
|
|
89
|
+
TransferVault(): Promise<Invitation<any, undefined>>;
|
|
90
|
+
}>;
|
|
91
|
+
vault: import("@endo/exo").Guarded<{
|
|
92
|
+
getPublicTopics(): {
|
|
93
|
+
vault: {
|
|
94
|
+
description: string;
|
|
95
|
+
subscriber: globalThis.Subscriber<VaultNotification>;
|
|
96
|
+
storagePath: Promise<string>;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
100
|
+
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
101
|
+
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
102
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
103
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
104
|
+
getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
|
|
105
|
+
}>;
|
|
106
|
+
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
107
|
+
}, undefined>>;
|
|
108
|
+
getQuotes(): import("@agoric/notifier").StoredNotifier<PriceQuote>;
|
|
109
|
+
getCompoundedInterest(): Ratio;
|
|
110
|
+
getPublicTopics(): {
|
|
111
|
+
asset: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./vaultManager.js").AssetState>;
|
|
112
|
+
metrics: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./vaultManager.js").MetricsNotification>;
|
|
113
|
+
};
|
|
114
|
+
}>;
|
|
115
|
+
lockOraclePrices(): PriceQuote;
|
|
116
|
+
liquidateVaults(auctionPF: ERef<AuctioneerPublicFacet>): Promise<void>;
|
|
117
|
+
}>>;
|
|
118
|
+
makeCollectFeesInvitation(): Promise<Invitation<string, undefined>>;
|
|
119
|
+
getRewardAllocation(): Allocation;
|
|
120
|
+
makeLiquidationWaker(): {
|
|
121
|
+
wake: (timestamp: any) => any;
|
|
122
|
+
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
123
|
+
wake: (timestamp: any) => any;
|
|
124
|
+
}>;
|
|
125
|
+
makeReschedulerWaker(): {
|
|
126
|
+
wake: (timestamp: any) => any;
|
|
127
|
+
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
128
|
+
wake: (timestamp: any) => any;
|
|
129
|
+
}>;
|
|
130
|
+
makePriceLockWaker(): {
|
|
131
|
+
wake: (timestamp: any) => any;
|
|
132
|
+
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
133
|
+
wake: (timestamp: any) => any;
|
|
134
|
+
}>;
|
|
135
|
+
setShortfallReporter(newInvitation: any): Promise<void>;
|
|
136
|
+
}>;
|
|
137
|
+
getGovernedApis(): ERef<GovernedApis>;
|
|
138
|
+
getGovernedApiNames(): never[];
|
|
139
|
+
setOfferFilter: (strings: any) => Promise<void>;
|
|
140
|
+
}>;
|
|
141
|
+
publicFacet: import("@endo/exo").Guarded<{
|
|
142
|
+
getCollateralManager(brandIn: Brand): import("@endo/exo").Guarded<{
|
|
143
|
+
makeVaultInvitation(): Promise<Invitation<{
|
|
144
|
+
publicSubscribers: {
|
|
145
|
+
vault: {
|
|
146
|
+
description: string;
|
|
147
|
+
subscriber: globalThis.Subscriber<VaultNotification>;
|
|
148
|
+
storagePath: Promise<string>;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
152
|
+
AdjustBalances(): Promise<Invitation<string, undefined>>;
|
|
153
|
+
CloseVault(): Promise<Invitation<string, undefined>>;
|
|
154
|
+
TransferVault(): Promise<Invitation<any, undefined>>;
|
|
155
|
+
}>;
|
|
156
|
+
vault: import("@endo/exo").Guarded<{
|
|
157
|
+
getPublicTopics(): {
|
|
158
|
+
vault: {
|
|
159
|
+
description: string;
|
|
160
|
+
subscriber: globalThis.Subscriber<VaultNotification>;
|
|
161
|
+
storagePath: Promise<string>;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
165
|
+
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
166
|
+
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
167
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
168
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
169
|
+
getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
|
|
170
|
+
}>;
|
|
171
|
+
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
172
|
+
}, undefined>>;
|
|
173
|
+
getQuotes(): import("@agoric/notifier").StoredNotifier<PriceQuote>;
|
|
174
|
+
getCompoundedInterest(): Ratio;
|
|
175
|
+
getPublicTopics(): {
|
|
176
|
+
asset: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./vaultManager.js").AssetState>;
|
|
177
|
+
metrics: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./vaultManager.js").MetricsNotification>;
|
|
178
|
+
};
|
|
179
|
+
}>;
|
|
180
|
+
getDebtIssuer(): globalThis.Issuer<"nat", import("@endo/patterns").Key>;
|
|
181
|
+
getSubscription({ collateralBrand }: {
|
|
182
|
+
collateralBrand: Brand;
|
|
183
|
+
}): globalThis.StoredSubscription<globalThis.GovernanceSubscriptionState>;
|
|
184
|
+
getPublicTopics(): {
|
|
185
|
+
metrics: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./vaultDirector.js").MetricsNotification>;
|
|
186
|
+
};
|
|
187
|
+
getElectorateSubscription(): globalThis.StoredSubscription<globalThis.GovernanceSubscriptionState>;
|
|
188
|
+
getGovernedParams({ collateralBrand }: {
|
|
189
|
+
collateralBrand: Brand;
|
|
190
|
+
}): globalThis.ERef<globalThis.ParamStateRecord>;
|
|
191
|
+
getInvitationAmount(name: string): import("@agoric/ertp").SetAmount<InvitationDetails>;
|
|
192
|
+
}>;
|
|
193
|
+
}>;
|
|
194
|
+
export type VaultFactoryZCF = ZCF<GovernanceTerms<import("./params").VaultDirectorParams> & {
|
|
195
|
+
priceAuthority: ERef<PriceAuthority>;
|
|
196
|
+
reservePublicFacet: AssetReservePublicFacet;
|
|
197
|
+
timerService: import("@agoric/time").TimerService;
|
|
198
|
+
}>;
|
|
199
|
+
export type VaultFactoryContract = ContractOf<typeof start>;
|
|
200
|
+
import type { PriceQuote } from '@agoric/zoe/tools/types.js';
|
|
201
|
+
import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
|
|
202
|
+
//# sourceMappingURL=vaultFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vaultFactory.d.ts","sourceRoot":"","sources":["vaultFactory.js"],"names":[],"mappings":"AAmCA;;;;;;;;GAQG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAerB;AAoBK,2BAhBI,eAAe,eACf;IACN,aAAa,EAAE,aAAa,CAAC;IAC7B,sBAAsB,EAAE,UAAU,CAAC;IACnC,0BAA0B,EAAE,UAAU,CAAC;IACvC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7B,kBAAkB,EAAE,QAAQ,CAAC;IAC7B,aAAa,EAAE,MAAM,CACzB,MAAY,EACZ,OAAa,aAAa,EAAE,0BAA0B,CACjD,CAAC;IACF,sBAAsB,EAAE,CAAC,MAAM,CAAC,CAAC;CAClC,WACO,OAAO,4BAA4B,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFtD;8BAhIY,GAAG,CACX,eAAe,CAAC,OAAO,UAAU,EAAE,mBAAmB,CAAC,GAAG;IACxD,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IACrC,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,YAAY,EAAE,OAAO,cAAc,EAAE,YAAY,CAAC;CACnD,CACF;mCA6HU,UAAU,CAAC,OAAO,KAAK,CAAC;gCAxIwD,4BAA4B;oCAA5B,4BAA4B"}
|