@agoric/inter-protocol 0.17.0-u17.0 → 0.17.0-u18.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/package.json +26 -26
- package/src/auction/auctionBook.d.ts +2 -2
- package/src/auction/auctionBook.d.ts.map +1 -1
- package/src/auction/auctionBook.js +26 -33
- package/src/auction/auctionMath.d.ts +3 -3
- package/src/auction/auctioneer.d.ts +9 -9
- package/src/auction/auctioneer.d.ts.map +1 -1
- package/src/auction/offerBook.d.ts.map +1 -1
- package/src/auction/params.d.ts +2 -2
- package/src/auction/scheduler.d.ts +4 -3
- package/src/auction/scheduler.d.ts.map +1 -1
- package/src/auction/scheduler.js +1 -1
- package/src/auction/util.d.ts +6 -8
- package/src/auction/util.d.ts.map +1 -1
- package/src/auction/util.js +4 -3
- package/src/clientSupport.d.ts.map +1 -1
- package/src/econCommitteeCharter.d.ts +4 -3
- package/src/econCommitteeCharter.d.ts.map +1 -1
- package/src/econCommitteeCharter.js +1 -1
- package/src/feeDistributor.d.ts.map +1 -1
- package/src/interest.d.ts.map +1 -1
- package/src/price/fluxAggregatorContract.d.ts +2 -1
- package/src/price/fluxAggregatorContract.d.ts.map +1 -1
- package/src/price/fluxAggregatorContract.js +2 -0
- package/src/price/fluxAggregatorKit.d.ts +1 -1
- package/src/price/fluxAggregatorKit.d.ts.map +1 -1
- package/src/price/priceOracleKit.d.ts.map +1 -1
- package/src/price/roundsManager.d.ts +6 -6
- package/src/price/roundsManager.d.ts.map +1 -1
- package/src/price/roundsManager.js +53 -4
- package/src/proposals/add-auction.d.ts +24 -10
- package/src/proposals/add-auction.d.ts.map +1 -1
- package/src/proposals/add-auction.js +69 -38
- package/src/proposals/addAssetToVault.d.ts +14 -1
- package/src/proposals/addAssetToVault.d.ts.map +1 -1
- package/src/proposals/addAssetToVault.js +22 -3
- 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 +27 -27
- package/src/proposals/econ-behaviors.d.ts.map +1 -1
- package/src/proposals/price-feed-proposal.d.ts.map +1 -1
- package/src/proposals/price-feed-proposal.js +2 -1
- 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/upgrade-vaults.d.ts +16 -14
- package/src/proposals/upgrade-vaults.d.ts.map +1 -1
- package/src/proposals/upgrade-vaults.js +75 -91
- package/src/proposals/utils.d.ts +4 -2
- package/src/proposals/utils.d.ts.map +1 -1
- package/src/proposals/utils.js +10 -2
- package/src/provisionPool.d.ts +4 -8
- package/src/provisionPool.d.ts.map +1 -1
- package/src/provisionPoolKit.d.ts +10 -18
- package/src/provisionPoolKit.d.ts.map +1 -1
- package/src/psm/psm.d.ts +2 -2
- package/src/psm/psm.d.ts.map +1 -1
- package/src/reserve/assetReserve.d.ts.map +1 -1
- package/src/reserve/assetReserveKit.d.ts +1 -1
- package/src/reserve/assetReserveKit.d.ts.map +1 -1
- package/src/vaultFactory/liquidation.d.ts.map +1 -1
- package/src/vaultFactory/math.d.ts +4 -4
- package/src/vaultFactory/orderedVaultStore.d.ts +8 -8
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -1
- package/src/vaultFactory/params.d.ts +6 -6
- package/src/vaultFactory/params.d.ts.map +1 -1
- package/src/vaultFactory/prioritizedVaults.d.ts +17 -17
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -1
- package/src/vaultFactory/proceeds.d.ts.map +1 -1
- package/src/vaultFactory/storeUtils.d.ts +2 -2
- package/src/vaultFactory/storeUtils.d.ts.map +1 -1
- package/src/vaultFactory/types-ambient.d.ts.map +1 -1
- package/src/vaultFactory/vault.d.ts +30 -19
- package/src/vaultFactory/vault.d.ts.map +1 -1
- package/src/vaultFactory/vault.js +6 -5
- package/src/vaultFactory/vaultDirector.d.ts +18 -18
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -1
- package/src/vaultFactory/vaultFactory.d.ts +7 -7
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -1
- package/src/vaultFactory/vaultHolder.d.ts +6 -6
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -1
- package/src/vaultFactory/vaultKit.d.ts +2 -2
- package/src/vaultFactory/vaultManager.d.ts +18 -18
- package/src/vaultFactory/vaultManager.d.ts.map +1 -1
- package/src/vaultFactory/vaultManager.js +1 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { makeTracer } from '@agoric/internal';
|
|
2
|
+
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
|
|
3
|
+
import { E } from '@endo/far';
|
|
4
|
+
|
|
5
|
+
import { unitAmount } from '@agoric/zoe/src/contractSupport/priceQuote.js';
|
|
6
|
+
import {
|
|
7
|
+
oracleBrandFeedName,
|
|
8
|
+
reserveThenDeposit,
|
|
9
|
+
sanitizePathSegment,
|
|
10
|
+
} from './utils.js';
|
|
11
|
+
import { replaceScaledPriceAuthorities } from './replace-scaledPriceAuthorities.js';
|
|
12
|
+
|
|
13
|
+
const STORAGE_PATH = 'priceFeed';
|
|
14
|
+
|
|
15
|
+
/** @type {ChainlinkConfig} */
|
|
16
|
+
export const DEFAULT_CONTRACT_TERMS = {
|
|
17
|
+
maxSubmissionCount: 1000,
|
|
18
|
+
minSubmissionCount: 2,
|
|
19
|
+
restartDelay: 1n, // the number of rounds an Oracle has to wait before they can initiate another round
|
|
20
|
+
timeout: 10, // in seconds according to chainTimerService
|
|
21
|
+
minSubmissionValue: 1,
|
|
22
|
+
maxSubmissionValue: 2 ** 256,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @import {EconomyBootstrapPowers} from './econ-behaviors.js'; */
|
|
26
|
+
/** @import {ChainlinkConfig} from '@agoric/inter-protocol/src/price/fluxAggregatorKit.js'; */
|
|
27
|
+
/** @import {FluxStartFn} from '@agoric/inter-protocol/src/price/fluxAggregatorContract.js'; */
|
|
28
|
+
|
|
29
|
+
const trace = makeTracer('DeployPriceFeed', true);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {{
|
|
33
|
+
* oracleAddresses: string[];
|
|
34
|
+
* inBrandNames: string[];
|
|
35
|
+
* contractTerms?: Partial<ChainlinkConfig>;
|
|
36
|
+
* }} PriceFeedConfig
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {EconomyBootstrapPowers} powers
|
|
41
|
+
* @param {string} bundleID
|
|
42
|
+
*/
|
|
43
|
+
const installPriceAggregator = async (
|
|
44
|
+
{
|
|
45
|
+
consume: { zoe },
|
|
46
|
+
installation: {
|
|
47
|
+
produce: { priceAggregator },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
bundleID,
|
|
51
|
+
) => {
|
|
52
|
+
/** @type {Installation<FluxStartFn>} */
|
|
53
|
+
const installation = await E(zoe).installBundleID(bundleID);
|
|
54
|
+
priceAggregator.reset();
|
|
55
|
+
priceAggregator.resolve(installation);
|
|
56
|
+
trace('installed priceAggregator', bundleID.slice(0, 'b1-1234567'.length));
|
|
57
|
+
return installation;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Provide (find/create) inert brands (no mint or issuer) referred to by oracles
|
|
62
|
+
*
|
|
63
|
+
* @param {EconomyBootstrapPowers & NamedVatPowers} space
|
|
64
|
+
* @param {{ name: string; decimalPlaces: number }} opt
|
|
65
|
+
* @returns {Promise<Brand<'nat'>>}
|
|
66
|
+
*/
|
|
67
|
+
export const ensureOracleBrand = async (
|
|
68
|
+
{
|
|
69
|
+
namedVat: {
|
|
70
|
+
consume: { agoricNames },
|
|
71
|
+
},
|
|
72
|
+
oracleBrand: { produce: oracleBrandProduce },
|
|
73
|
+
},
|
|
74
|
+
{ name, decimalPlaces },
|
|
75
|
+
) => {
|
|
76
|
+
const brand = E(agoricNames).provideInertBrand(name, {
|
|
77
|
+
assetKind: 'nat',
|
|
78
|
+
decimalPlaces,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
oracleBrandProduce[name].reset();
|
|
82
|
+
oracleBrandProduce[name].resolve(brand);
|
|
83
|
+
return brand;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {EconomyBootstrapPowers} powers
|
|
88
|
+
* @param {{
|
|
89
|
+
* AGORIC_INSTANCE_NAME: string;
|
|
90
|
+
* contractTerms: import('@agoric/inter-protocol/src/price/fluxAggregatorKit.js').ChainlinkConfig;
|
|
91
|
+
* brandIn: Brand<'nat'>;
|
|
92
|
+
* brandOut: Brand<'nat'>;
|
|
93
|
+
* }} config
|
|
94
|
+
* @param {Installation<FluxStartFn>} installation
|
|
95
|
+
*/
|
|
96
|
+
const startPriceAggregatorInstance = async (
|
|
97
|
+
{
|
|
98
|
+
consume: {
|
|
99
|
+
board,
|
|
100
|
+
chainStorage,
|
|
101
|
+
chainTimerService,
|
|
102
|
+
econCharterKit,
|
|
103
|
+
highPrioritySendersManager,
|
|
104
|
+
namesByAddressAdmin,
|
|
105
|
+
startGovernedUpgradable,
|
|
106
|
+
},
|
|
107
|
+
instance: { produce: produceInstance },
|
|
108
|
+
},
|
|
109
|
+
{ AGORIC_INSTANCE_NAME, contractTerms, brandIn, brandOut },
|
|
110
|
+
installation,
|
|
111
|
+
) => {
|
|
112
|
+
trace('startPriceAggregatorInstance', AGORIC_INSTANCE_NAME);
|
|
113
|
+
const label = sanitizePathSegment(AGORIC_INSTANCE_NAME);
|
|
114
|
+
|
|
115
|
+
const feedsStorage = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
|
|
116
|
+
const storageNode = await E(feedsStorage).makeChildNode(label);
|
|
117
|
+
const marshaller = await E(board).getReadonlyMarshaller();
|
|
118
|
+
|
|
119
|
+
const terms = harden({
|
|
120
|
+
...contractTerms,
|
|
121
|
+
description: AGORIC_INSTANCE_NAME,
|
|
122
|
+
brandIn,
|
|
123
|
+
brandOut,
|
|
124
|
+
// XXX powerful TimerService, see #6003
|
|
125
|
+
timer: await chainTimerService,
|
|
126
|
+
unitAmountIn: await unitAmount(brandIn),
|
|
127
|
+
});
|
|
128
|
+
const privateArgs = {
|
|
129
|
+
highPrioritySendersManager: await highPrioritySendersManager,
|
|
130
|
+
marshaller,
|
|
131
|
+
namesByAddressAdmin,
|
|
132
|
+
storageNode,
|
|
133
|
+
};
|
|
134
|
+
const governedKit = await E(startGovernedUpgradable)({
|
|
135
|
+
governedParams: {},
|
|
136
|
+
privateArgs,
|
|
137
|
+
terms,
|
|
138
|
+
label,
|
|
139
|
+
// @ts-expect-error GovernableStartFn vs. fluxAggregatorContract.js start
|
|
140
|
+
installation,
|
|
141
|
+
});
|
|
142
|
+
produceInstance[AGORIC_INSTANCE_NAME].reset();
|
|
143
|
+
produceInstance[AGORIC_INSTANCE_NAME].resolve(governedKit.instance);
|
|
144
|
+
trace(
|
|
145
|
+
'new instance',
|
|
146
|
+
label,
|
|
147
|
+
{ terms, privateArgs, installation },
|
|
148
|
+
governedKit,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
await E(E.get(econCharterKit).creatorFacet).addInstance(
|
|
152
|
+
governedKit.instance,
|
|
153
|
+
governedKit.governorCreatorFacet,
|
|
154
|
+
AGORIC_INSTANCE_NAME,
|
|
155
|
+
);
|
|
156
|
+
trace('added', label, 'instance to econCharter');
|
|
157
|
+
|
|
158
|
+
/** @type {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<FluxStartFn>} */
|
|
159
|
+
// @ts-expect-error
|
|
160
|
+
const { instance, publicFacet, creatorFacet } = governedKit;
|
|
161
|
+
|
|
162
|
+
return harden({ instance, publicFacet, creatorFacet });
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Send invitations to oracle operators for a price feed.
|
|
167
|
+
*
|
|
168
|
+
* @param {EconomyBootstrapPowers} powers
|
|
169
|
+
* @param {{ oracleAddresses: string[]; AGORIC_INSTANCE_NAME: string }} config
|
|
170
|
+
* @param {any} creatorFacet
|
|
171
|
+
*/
|
|
172
|
+
const distributeInvitations = async (
|
|
173
|
+
{ consume: { namesByAddressAdmin } },
|
|
174
|
+
{ oracleAddresses, AGORIC_INSTANCE_NAME },
|
|
175
|
+
creatorFacet,
|
|
176
|
+
) => {
|
|
177
|
+
/** @param {string} addr */
|
|
178
|
+
const addOracle = async addr => {
|
|
179
|
+
const invitation = await E(creatorFacet).makeOracleInvitation(addr);
|
|
180
|
+
const debugName = `${AGORIC_INSTANCE_NAME} member ${addr}`;
|
|
181
|
+
await reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
|
|
182
|
+
invitation,
|
|
183
|
+
]).catch(err => console.error(`failed deposit to ${debugName}`, err));
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
trace('distributing invitations', oracleAddresses);
|
|
187
|
+
// This doesn't resolve until oracle operators create their smart wallets.
|
|
188
|
+
// Don't block completion on it.
|
|
189
|
+
void Promise.all(oracleAddresses.map(addOracle));
|
|
190
|
+
trace('createPriceFeed complete');
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @param {EconomyBootstrapPowers & NamedVatPowers} powers
|
|
195
|
+
* @param {{
|
|
196
|
+
* options: PriceFeedConfig & {
|
|
197
|
+
* priceAggregatorRef: { bundleID: string };
|
|
198
|
+
* scaledPARef: { bundleID: string };
|
|
199
|
+
* inBrandsDecimals?: number;
|
|
200
|
+
* contractTerms?: ChainlinkConfig;
|
|
201
|
+
* outBrandName?: string;
|
|
202
|
+
* outBrandDecimals?: number;
|
|
203
|
+
* };
|
|
204
|
+
* }} config
|
|
205
|
+
*/
|
|
206
|
+
export const deployPriceFeeds = async (powers, config) => {
|
|
207
|
+
const {
|
|
208
|
+
inBrandNames,
|
|
209
|
+
oracleAddresses,
|
|
210
|
+
contractTerms,
|
|
211
|
+
priceAggregatorRef,
|
|
212
|
+
scaledPARef,
|
|
213
|
+
inBrandsDecimals = 6,
|
|
214
|
+
outBrandName = 'USD',
|
|
215
|
+
outBrandDecimals = 6,
|
|
216
|
+
} = config.options;
|
|
217
|
+
await null;
|
|
218
|
+
|
|
219
|
+
const installation = await installPriceAggregator(
|
|
220
|
+
powers,
|
|
221
|
+
priceAggregatorRef.bundleID,
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
const { priceAuthorityAdmin, priceAuthority } = powers.consume;
|
|
225
|
+
|
|
226
|
+
trace({ oracleAddresses });
|
|
227
|
+
trace({ inBrandNames });
|
|
228
|
+
for (const inBrandName of inBrandNames) {
|
|
229
|
+
const AGORIC_INSTANCE_NAME = oracleBrandFeedName(inBrandName, outBrandName);
|
|
230
|
+
const brandIn = await ensureOracleBrand(powers, {
|
|
231
|
+
name: inBrandName,
|
|
232
|
+
decimalPlaces: inBrandsDecimals,
|
|
233
|
+
});
|
|
234
|
+
const brandOut = await ensureOracleBrand(powers, {
|
|
235
|
+
name: outBrandName,
|
|
236
|
+
decimalPlaces: outBrandDecimals,
|
|
237
|
+
});
|
|
238
|
+
const kit = await startPriceAggregatorInstance(
|
|
239
|
+
powers,
|
|
240
|
+
{
|
|
241
|
+
AGORIC_INSTANCE_NAME,
|
|
242
|
+
brandIn,
|
|
243
|
+
brandOut,
|
|
244
|
+
contractTerms: { ...DEFAULT_CONTRACT_TERMS, ...contractTerms },
|
|
245
|
+
},
|
|
246
|
+
installation,
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
const forceReplace = true;
|
|
250
|
+
await E(priceAuthorityAdmin).registerPriceAuthority(
|
|
251
|
+
E(kit.publicFacet).getPriceAuthority(),
|
|
252
|
+
brandIn,
|
|
253
|
+
brandOut,
|
|
254
|
+
forceReplace,
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
await distributeInvitations(
|
|
258
|
+
powers,
|
|
259
|
+
{ oracleAddresses, AGORIC_INSTANCE_NAME },
|
|
260
|
+
kit.creatorFacet,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// @ts-expect-error replaceScaledPriceAuthorities uses a subset of the powers.
|
|
265
|
+
await replaceScaledPriceAuthorities(powers, {
|
|
266
|
+
options: { scaledPARef },
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
trace('resolving priceAuthority8400');
|
|
270
|
+
// cf. #8400 QuotePayments storage leak
|
|
271
|
+
powers.produce.priceAuthority8400.resolve(priceAuthority);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const t = 'priceFeed';
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Thread price feed upgrade options through from builder to core-eval.
|
|
278
|
+
*
|
|
279
|
+
* @param {object} utils
|
|
280
|
+
* @param {any} utils.restoreRef
|
|
281
|
+
* @param {PriceFeedConfig & { priceAggregatorRef: any }} priceFeedOptions
|
|
282
|
+
*/
|
|
283
|
+
export const getManifestForPriceFeeds = async (
|
|
284
|
+
{ restoreRef: _restoreRef },
|
|
285
|
+
priceFeedOptions,
|
|
286
|
+
) => ({
|
|
287
|
+
manifest: {
|
|
288
|
+
[deployPriceFeeds.name]: {
|
|
289
|
+
namedVat: t,
|
|
290
|
+
consume: {
|
|
291
|
+
agoricNamesAdmin: t,
|
|
292
|
+
agoricNames: t,
|
|
293
|
+
board: t,
|
|
294
|
+
chainStorage: t,
|
|
295
|
+
chainTimerService: t,
|
|
296
|
+
contractKits: t,
|
|
297
|
+
econCharterKit: t,
|
|
298
|
+
highPrioritySendersManager: t,
|
|
299
|
+
instancePrivateArgs: t,
|
|
300
|
+
namesByAddressAdmin: t,
|
|
301
|
+
priceAuthority: t,
|
|
302
|
+
priceAuthorityAdmin: t,
|
|
303
|
+
startGovernedUpgradable: t,
|
|
304
|
+
startUpgradable: t,
|
|
305
|
+
zoe: t,
|
|
306
|
+
},
|
|
307
|
+
installation: { produce: { priceAggregator: t } },
|
|
308
|
+
instance: {
|
|
309
|
+
produce: t,
|
|
310
|
+
},
|
|
311
|
+
oracleBrand: { produce: t },
|
|
312
|
+
produce: { priceAuthority8400: t },
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
options: { ...priceFeedOptions },
|
|
316
|
+
});
|
|
@@ -43,15 +43,15 @@ export function setupVaultFactoryArguments(consume: EconomyBootstrapPowers["cons
|
|
|
43
43
|
governedParams: {
|
|
44
44
|
Electorate: {
|
|
45
45
|
type: "invitation";
|
|
46
|
-
value: import("@agoric/ertp
|
|
46
|
+
value: import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>;
|
|
47
47
|
};
|
|
48
48
|
MinInitialDebt: {
|
|
49
49
|
type: "amount";
|
|
50
|
-
value: import("@agoric/ertp
|
|
50
|
+
value: import("@agoric/ertp").NatAmount;
|
|
51
51
|
};
|
|
52
52
|
ShortfallInvitation: {
|
|
53
53
|
type: "invitation";
|
|
54
|
-
value: import("@agoric/ertp
|
|
54
|
+
value: import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>;
|
|
55
55
|
};
|
|
56
56
|
ReferencedUI: {
|
|
57
57
|
type: "string";
|
|
@@ -71,11 +71,11 @@ export function setupVaultFactoryArguments(consume: EconomyBootstrapPowers["cons
|
|
|
71
71
|
vaultFactoryPrivateArgs: {
|
|
72
72
|
auctioneerInstance: import("@agoric/internal/src/tagged.js").TagContainer<any> & import("@endo/pass-style").RemotableObject & Handle<"Instance">;
|
|
73
73
|
feeMintAccess: FeeMintAccess;
|
|
74
|
-
initialPoserInvitation: import("@endo/pass-style").RemotableObject & import("@agoric/ertp
|
|
74
|
+
initialPoserInvitation: import("@endo/pass-style").RemotableObject & import("@agoric/ertp").PaymentMethods<"set"> & {
|
|
75
75
|
[OfferReturn]?: unknown;
|
|
76
76
|
[OfferArgs]?: undefined;
|
|
77
77
|
};
|
|
78
|
-
initialShortfallInvitation: import("@endo/pass-style").RemotableObject & import("@agoric/ertp
|
|
78
|
+
initialShortfallInvitation: import("@endo/pass-style").RemotableObject & import("@agoric/ertp").PaymentMethods<"set"> & {
|
|
79
79
|
[OfferReturn]?: import("@endo/exo").Guarded<{
|
|
80
80
|
increaseLiquidationShortfall(shortfall: Amount<"nat">): void;
|
|
81
81
|
reduceLiquidationShortfall(reduction: Amount<"nat">): void;
|
|
@@ -164,8 +164,8 @@ export type VaultFactoryPublicFacet = Awaited<ReturnType<(zcf: VaultFactoryZCF,
|
|
|
164
164
|
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
165
165
|
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
166
166
|
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
167
|
-
getCollateralAmount(): import("@agoric/ertp
|
|
168
|
-
getCurrentDebt(): import("@agoric/ertp
|
|
167
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
168
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
169
169
|
getNormalizedDebt(): import("../vaultFactory/storeUtils.js").NormalizedDebt;
|
|
170
170
|
}>;
|
|
171
171
|
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
@@ -196,8 +196,8 @@ export type VaultFactoryPublicFacet = Awaited<ReturnType<(zcf: VaultFactoryZCF,
|
|
|
196
196
|
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
197
197
|
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
198
198
|
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
199
|
-
getCollateralAmount(): import("@agoric/ertp
|
|
200
|
-
getCurrentDebt(): import("@agoric/ertp
|
|
199
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
200
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
201
201
|
getNormalizedDebt(): import("../vaultFactory/storeUtils.js").NormalizedDebt;
|
|
202
202
|
}>;
|
|
203
203
|
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
@@ -261,8 +261,8 @@ export type VaultFactoryPublicFacet = Awaited<ReturnType<(zcf: VaultFactoryZCF,
|
|
|
261
261
|
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
262
262
|
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
263
263
|
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
264
|
-
getCollateralAmount(): import("@agoric/ertp
|
|
265
|
-
getCurrentDebt(): import("@agoric/ertp
|
|
264
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
265
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
266
266
|
getNormalizedDebt(): import("../vaultFactory/storeUtils.js").NormalizedDebt;
|
|
267
267
|
}>;
|
|
268
268
|
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
@@ -285,7 +285,7 @@ export type VaultFactoryPublicFacet = Awaited<ReturnType<(zcf: VaultFactoryZCF,
|
|
|
285
285
|
getGovernedParams({ collateralBrand }: {
|
|
286
286
|
collateralBrand: Brand;
|
|
287
287
|
}): globalThis.ERef<globalThis.ParamStateRecord>;
|
|
288
|
-
getInvitationAmount(name: string): import("@agoric/ertp
|
|
288
|
+
getInvitationAmount(name: string): import("@agoric/ertp").SetAmount<InvitationDetails>;
|
|
289
289
|
}>;
|
|
290
290
|
}>>>["publicFacet"];
|
|
291
291
|
export type PSMKit = {
|
|
@@ -306,14 +306,14 @@ export type AuctioneerKit = GovernanceFacetKit<(zcf: ZCF<GovernanceTerms<typeof
|
|
|
306
306
|
marshaller: Marshaller;
|
|
307
307
|
}, baggage: import("@agoric/vat-data").Baggage) => Promise<{
|
|
308
308
|
publicFacet: globalThis.GovernedPublicFacet<{
|
|
309
|
-
getElectorate: () => import("@agoric/
|
|
310
|
-
getStartFrequency: () =>
|
|
311
|
-
getClockStep: () =>
|
|
312
|
-
getStartingRate: () =>
|
|
313
|
-
getLowestRate: () =>
|
|
314
|
-
getDiscountStep: () =>
|
|
315
|
-
getAuctionStartDelay: () =>
|
|
316
|
-
getPriceLockPeriod: () =>
|
|
309
|
+
getElectorate: () => import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>;
|
|
310
|
+
getStartFrequency: () => RelativeTime;
|
|
311
|
+
getClockStep: () => RelativeTime;
|
|
312
|
+
getStartingRate: () => bigint;
|
|
313
|
+
getLowestRate: () => bigint;
|
|
314
|
+
getDiscountStep: () => bigint;
|
|
315
|
+
getAuctionStartDelay: () => RelativeTime;
|
|
316
|
+
getPriceLockPeriod: () => RelativeTime;
|
|
317
317
|
makeBidInvitation(collateralBrand: Brand<"nat">): Promise<Invitation<string, import("../auction/auctionBook.js").OfferSpec>>;
|
|
318
318
|
getSchedules(): {
|
|
319
319
|
liveAuctionSchedule: import("../auction/scheduler.js").Schedule | null;
|
|
@@ -406,8 +406,8 @@ export type EconomyBootstrapSpace = PromiseSpaceOf<{
|
|
|
406
406
|
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
407
407
|
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
408
408
|
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
409
|
-
getCollateralAmount(): import("@agoric/ertp
|
|
410
|
-
getCurrentDebt(): import("@agoric/ertp
|
|
409
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
410
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
411
411
|
getNormalizedDebt(): import("../vaultFactory/storeUtils.js").NormalizedDebt;
|
|
412
412
|
}>;
|
|
413
413
|
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
@@ -438,8 +438,8 @@ export type EconomyBootstrapSpace = PromiseSpaceOf<{
|
|
|
438
438
|
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
439
439
|
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
440
440
|
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
441
|
-
getCollateralAmount(): import("@agoric/ertp
|
|
442
|
-
getCurrentDebt(): import("@agoric/ertp
|
|
441
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
442
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
443
443
|
getNormalizedDebt(): import("../vaultFactory/storeUtils.js").NormalizedDebt;
|
|
444
444
|
}>;
|
|
445
445
|
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
@@ -503,8 +503,8 @@ export type EconomyBootstrapSpace = PromiseSpaceOf<{
|
|
|
503
503
|
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
504
504
|
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
505
505
|
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
506
|
-
getCollateralAmount(): import("@agoric/ertp
|
|
507
|
-
getCurrentDebt(): import("@agoric/ertp
|
|
506
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
507
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
508
508
|
getNormalizedDebt(): import("../vaultFactory/storeUtils.js").NormalizedDebt;
|
|
509
509
|
}>;
|
|
510
510
|
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
@@ -527,7 +527,7 @@ export type EconomyBootstrapSpace = PromiseSpaceOf<{
|
|
|
527
527
|
getGovernedParams({ collateralBrand }: {
|
|
528
528
|
collateralBrand: Brand;
|
|
529
529
|
}): globalThis.ERef<globalThis.ParamStateRecord>;
|
|
530
|
-
getInvitationAmount(name: string): import("@agoric/ertp
|
|
530
|
+
getInvitationAmount(name: string): import("@agoric/ertp").SetAmount<InvitationDetails>;
|
|
531
531
|
}>;
|
|
532
532
|
}>>;
|
|
533
533
|
auctioneerKit: AuctioneerKit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"econ-behaviors.d.ts","sourceRoot":"","sources":["econ-behaviors.js"],"names":[],"mappings":"AAgBA,qCAAsC;AACtC,sCAA0C;AAC1C,qCAAsD;AACtD,sCAAqD;AAwE9C,mcADK,sBAAsB;;;;;;;;;;;;;;;;;;;;;;KA+FjC;AAUM,oDAPI,sBAAsB,CAAC,SAAS,CAAC,kDAEzC;IAAgC,cAAc;IACtB,OAAO;;;CAE/B,8BAAQ,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EvB;AAUM,wSAPI,sBAAsB,UAE9B;IAAgC,cAAc;IACtB,OAAO;;;CAE/B,mBAAQ,MAAM,iBA6FhB;AAWM,wGALI,sBAAsB;;;;8BAuBhC;AAQM,mcAFI,sBAAsB,iBA0GhC;AAQM,+cAJI,sBAAsB,uBAE9B;IAAqB,aAAa,GAA1B,GAAG;CAAwB,iBA0HrC;sCAxmBa,OAAO,CAAC,UAAU;;;;;;;yCA2D2C,2BACpE;;mBAGW,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA/DL,CAAC,CAAC,aAAa,CAAC;;WAI3C,MAAM;SACN,QAAQ;iBACR,QAAQ;qBACR,OAAO,
|
|
1
|
+
{"version":3,"file":"econ-behaviors.d.ts","sourceRoot":"","sources":["econ-behaviors.js"],"names":[],"mappings":"AAgBA,qCAAsC;AACtC,sCAA0C;AAC1C,qCAAsD;AACtD,sCAAqD;AAwE9C,mcADK,sBAAsB;;;;;;;;;;;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AE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;oCAtBG,YAAY"}
|
|
@@ -227,7 +227,8 @@ export const createPriceFeed = async (
|
|
|
227
227
|
|
|
228
228
|
// being after the above awaits means that when this resolves, the consumer
|
|
229
229
|
// gets notified that the authority is in the registry and its instance is in
|
|
230
|
-
// agoricNames.
|
|
230
|
+
// agoricNames. reset() in case we're replacing an existing feed.
|
|
231
|
+
produceInstance[AGORIC_INSTANCE_NAME].reset();
|
|
231
232
|
produceInstance[AGORIC_INSTANCE_NAME].resolve(faKit.instance);
|
|
232
233
|
|
|
233
234
|
E(E.get(econCharterKit).creatorFacet).addInstance(
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function replaceScaledPriceAuthority(powers: BootstrapPowers, { options }: {
|
|
2
|
+
options: object;
|
|
3
|
+
}): Promise<void>;
|
|
4
|
+
export function replaceScaledPriceAuthorities(powers: ChainBootstrapSpace & BootstrapPowers, { options }: {
|
|
5
|
+
options: {
|
|
6
|
+
scaledPARef: {
|
|
7
|
+
bundleID: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
export function getManifestForReplaceScaledPriceAuthorities(_ign: any, upgradeSPAOptions: any): Promise<{
|
|
12
|
+
manifest: {
|
|
13
|
+
[x: string]: {
|
|
14
|
+
consume: {
|
|
15
|
+
agoricNames: string;
|
|
16
|
+
priceAuthority: string;
|
|
17
|
+
startUpgradable: string;
|
|
18
|
+
zoe: string;
|
|
19
|
+
agoricNamesAdmin: string;
|
|
20
|
+
contractKits: string;
|
|
21
|
+
priceAuthorityAdmin: string;
|
|
22
|
+
};
|
|
23
|
+
instance: {
|
|
24
|
+
produce: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
options: any;
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=replace-scaledPriceAuthorities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-scaledPriceAuthorities.d.ts","sourceRoot":"","sources":["replace-scaledPriceAuthorities.js"],"names":[],"mappings":"AAaO,oDAJI,eAAe,eAEvB;IAAuB,OAAO,EAAtB,MAAM;CAChB,iBAeA;AAUM,sDAHI,mBAAmB,GAAG,eAAe,eACrC;IAAE,OAAO,EAAE;QAAE,WAAW,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,iBA2D5D;AAGM;;;;;;;;;;;;;;;;;;GA0BL"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { makeTracer } from '@agoric/internal';
|
|
2
|
+
import { E } from '@endo/far';
|
|
3
|
+
|
|
4
|
+
import { startScaledPriceAuthority } from './addAssetToVault.js';
|
|
5
|
+
import { scaledPriceFeedName } from './utils.js';
|
|
6
|
+
|
|
7
|
+
const trace = makeTracer('replaceScaledPA', true);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {BootstrapPowers} powers
|
|
11
|
+
* @param {object} config
|
|
12
|
+
* @param {object} config.options
|
|
13
|
+
*/
|
|
14
|
+
export const replaceScaledPriceAuthority = async (powers, { options }) => {
|
|
15
|
+
const {
|
|
16
|
+
instance: { produce: produceInstance },
|
|
17
|
+
} = powers;
|
|
18
|
+
const { issuerName } = options.interchainAssetOptions;
|
|
19
|
+
|
|
20
|
+
const spaKit = await startScaledPriceAuthority(powers, { options });
|
|
21
|
+
|
|
22
|
+
const label = scaledPriceFeedName(issuerName);
|
|
23
|
+
produceInstance[label].reset();
|
|
24
|
+
|
|
25
|
+
// publish into agoricNames. This must stay after registerPriceAuthority,
|
|
26
|
+
// which is called by startScaledPriceAuthority()
|
|
27
|
+
produceInstance[label].resolve(spaKit.instance);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Look up the existing assets known to auctions, and replace the corresponding
|
|
32
|
+
* scaledPriceAuthorities. The existing contracts will be left behind to be
|
|
33
|
+
* cleaned up later.
|
|
34
|
+
*
|
|
35
|
+
* @param {ChainBootstrapSpace & BootstrapPowers} powers
|
|
36
|
+
* @param {{ options: { scaledPARef: { bundleID: string } } }} options
|
|
37
|
+
*/
|
|
38
|
+
export const replaceScaledPriceAuthorities = async (powers, { options }) => {
|
|
39
|
+
trace('start');
|
|
40
|
+
const {
|
|
41
|
+
consume: {
|
|
42
|
+
agoricNamesAdmin,
|
|
43
|
+
agoricNames,
|
|
44
|
+
contractKits: contractKitsP,
|
|
45
|
+
zoe,
|
|
46
|
+
},
|
|
47
|
+
} = powers;
|
|
48
|
+
|
|
49
|
+
const { scaledPARef } = options;
|
|
50
|
+
|
|
51
|
+
const installationsAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
|
|
52
|
+
const [spaInstallation, contractKits] = await Promise.all([
|
|
53
|
+
E(E(installationsAdmin).readonly()).lookup('scaledPriceAuthority'),
|
|
54
|
+
contractKitsP,
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
const bundleID = scaledPARef.bundleID;
|
|
58
|
+
if (scaledPARef && bundleID) {
|
|
59
|
+
await E.when(
|
|
60
|
+
E(zoe).installBundleID(bundleID),
|
|
61
|
+
installation =>
|
|
62
|
+
E(installationsAdmin).update('scaledPriceAuthority', installation),
|
|
63
|
+
err =>
|
|
64
|
+
console.error(
|
|
65
|
+
`🚨 failed to update scaledPriceAuthority installation`,
|
|
66
|
+
err,
|
|
67
|
+
),
|
|
68
|
+
);
|
|
69
|
+
trace('installed scaledPriceAuthority bundle', bundleID);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Ask Zoe for the installation for each kit's instance, and return all the
|
|
73
|
+
// kits where that matches the given installation.
|
|
74
|
+
async function maybeSPAKit(kit) {
|
|
75
|
+
const installation = await E(zoe).getInstallationForInstance(kit.instance);
|
|
76
|
+
return spaInstallation === installation ? [kit] : [];
|
|
77
|
+
}
|
|
78
|
+
const scaledPAKits = (
|
|
79
|
+
await Promise.all([...contractKits.values()].map(maybeSPAKit))
|
|
80
|
+
).flat();
|
|
81
|
+
|
|
82
|
+
const namedBrands = await E(E(agoricNames).lookup('brand')).entries();
|
|
83
|
+
|
|
84
|
+
for (const kitEntry of scaledPAKits) {
|
|
85
|
+
const { instance } = kitEntry;
|
|
86
|
+
const terms = await E(powers.consume.zoe).getTerms(instance);
|
|
87
|
+
const { brand } = terms.scaleIn.denominator;
|
|
88
|
+
const entry = namedBrands.find(([_k, v]) => v === brand);
|
|
89
|
+
assert(entry, 'unable to find issuerName for ', brand);
|
|
90
|
+
const issuerName = entry[0];
|
|
91
|
+
await replaceScaledPriceAuthority(powers, {
|
|
92
|
+
options: { interchainAssetOptions: { issuerName } },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const t = 'replaceScaledPriceAuthority';
|
|
98
|
+
export const getManifestForReplaceScaledPriceAuthorities = async (
|
|
99
|
+
_ign,
|
|
100
|
+
upgradeSPAOptions,
|
|
101
|
+
) => ({
|
|
102
|
+
manifest: {
|
|
103
|
+
[replaceScaledPriceAuthorities.name]: {
|
|
104
|
+
consume: {
|
|
105
|
+
// //// Widely known ////
|
|
106
|
+
agoricNames: t,
|
|
107
|
+
priceAuthority: t,
|
|
108
|
+
startUpgradable: t,
|
|
109
|
+
zoe: t,
|
|
110
|
+
|
|
111
|
+
// //// closely held, powerful ////
|
|
112
|
+
agoricNamesAdmin: t,
|
|
113
|
+
contractKits: t,
|
|
114
|
+
priceAuthorityAdmin: t,
|
|
115
|
+
},
|
|
116
|
+
instance: {
|
|
117
|
+
// This is a right to add/replace any instance. That we update only the
|
|
118
|
+
// relevant ones must be verified by inspection.
|
|
119
|
+
produce: t,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
options: { ...upgradeSPAOptions },
|
|
124
|
+
});
|