@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-fbe72e7.0.fbe72e7
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 +46 -39
- 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 +182 -151
- 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 +70 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +72 -59
- package/src/auction/offerBook.d.ts +46 -0
- package/src/auction/offerBook.d.ts.map +1 -0
- package/src/auction/offerBook.js +17 -12
- package/src/auction/params.d.ts +145 -0
- package/src/auction/params.d.ts.map +1 -0
- package/src/auction/params.js +11 -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 +31 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +12 -6
- package/src/clientSupport.d.ts +168 -0
- package/src/clientSupport.d.ts.map +1 -0
- package/src/clientSupport.js +161 -98
- 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 +43 -0
- package/src/econCommitteeCharter.d.ts.map +1 -0
- package/src/econCommitteeCharter.js +25 -20
- package/src/feeDistributor.d.ts +224 -0
- package/src/feeDistributor.d.ts.map +1 -0
- package/src/feeDistributor.js +41 -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 +4 -0
- package/src/interest-math.d.ts.map +1 -0
- package/src/interest-math.js +5 -1
- package/src/interest.d.ts +30 -0
- package/src/interest.d.ts.map +1 -0
- package/src/interest.js +25 -23
- package/src/price/README.md +14 -1
- 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 +104 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +55 -42
- package/src/price/priceOracleKit.d.ts +39 -0
- package/src/price/priceOracleKit.d.ts.map +1 -0
- package/src/price/priceOracleKit.js +17 -15
- package/src/price/roundsManager.d.ts +204 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +132 -85
- package/src/proposals/README.md +2 -3
- package/src/proposals/add-auction.js +285 -0
- package/src/proposals/addAssetToVault.js +192 -40
- package/src/proposals/committee-proposal.js +25 -31
- package/src/proposals/core-proposal.js +9 -11
- package/src/proposals/deploy-price-feeds.js +341 -0
- package/src/proposals/econ-behaviors.js +84 -49
- package/src/proposals/price-feed-proposal.js +109 -51
- package/src/proposals/replace-fee-distributor.js +198 -0
- package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
- package/src/proposals/replaceElectorate.js +610 -0
- package/src/proposals/startEconCommittee.js +2 -2
- package/src/proposals/startPSM.js +44 -29
- package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
- package/src/proposals/upgrade-vaults.js +207 -0
- package/src/proposals/utils.d.ts +21 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +66 -9
- package/src/proposals/withdraw-reserve-proposal.js +63 -0
- package/src/provisionPool.d.ts +69 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +138 -0
- package/src/provisionPoolKit.d.ts +129 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +608 -0
- package/src/psm/psm.d.ts +133 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +85 -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 +58 -0
- package/src/reserve/assetReserve.d.ts.map +1 -0
- package/src/reserve/assetReserve.js +42 -34
- package/src/reserve/assetReserveKit.d.ts +103 -0
- package/src/reserve/assetReserveKit.d.ts.map +1 -0
- package/src/reserve/assetReserveKit.js +134 -32
- package/src/reserve/params.d.ts +16 -0
- package/src/reserve/params.d.ts.map +1 -0
- package/src/reserve/params.js +8 -2
- 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 +25 -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 +11 -10
- package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +9 -10
- package/src/vaultFactory/params.d.ts +143 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +56 -25
- package/src/vaultFactory/prioritizedVaults.d.ts +280 -0
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
- package/src/vaultFactory/prioritizedVaults.js +7 -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} +47 -44
- package/src/vaultFactory/vault.d.ts +344 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +107 -100
- package/src/vaultFactory/vaultDirector.d.ts +347 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +94 -64
- package/src/vaultFactory/vaultFactory.d.ts +250 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +56 -33
- package/src/vaultFactory/vaultHolder.d.ts +170 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +14 -15
- package/src/vaultFactory/vaultKit.d.ts +33 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +9 -4
- package/src/vaultFactory/vaultManager.d.ts +676 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +286 -167
- 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
|
@@ -0,0 +1,341 @@
|
|
|
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
|
+
provideRetiredInstances,
|
|
9
|
+
reserveThenDeposit,
|
|
10
|
+
sanitizePathSegment,
|
|
11
|
+
} from './utils.js';
|
|
12
|
+
import { replaceScaledPriceAuthorities } from './replace-scaledPriceAuthorities.js';
|
|
13
|
+
|
|
14
|
+
const STORAGE_PATH = 'priceFeed';
|
|
15
|
+
|
|
16
|
+
/** @type {ChainlinkConfig} */
|
|
17
|
+
export const DEFAULT_CONTRACT_TERMS = {
|
|
18
|
+
maxSubmissionCount: 1000,
|
|
19
|
+
minSubmissionCount: 2,
|
|
20
|
+
restartDelay: 1n, // the number of rounds an Oracle has to wait before they can initiate another round
|
|
21
|
+
timeout: 10, // in seconds according to chainTimerService
|
|
22
|
+
minSubmissionValue: 1,
|
|
23
|
+
maxSubmissionValue: 2 ** 256,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** @import {EconomyBootstrapPowers} from './econ-behaviors.js'; */
|
|
27
|
+
/** @import {ChainlinkConfig} from '@agoric/inter-protocol/src/price/fluxAggregatorKit.js'; */
|
|
28
|
+
/** @import {FluxStartFn} from '@agoric/inter-protocol/src/price/fluxAggregatorContract.js'; */
|
|
29
|
+
|
|
30
|
+
const trace = makeTracer('DeployPriceFeed', true);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {{
|
|
34
|
+
* oracleAddresses: string[];
|
|
35
|
+
* inBrandNames: string[];
|
|
36
|
+
* contractTerms?: Partial<ChainlinkConfig>;
|
|
37
|
+
* }} PriceFeedConfig
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {EconomyBootstrapPowers} powers
|
|
42
|
+
* @param {string} bundleID
|
|
43
|
+
*/
|
|
44
|
+
const installPriceAggregator = async (
|
|
45
|
+
{
|
|
46
|
+
consume: { zoe },
|
|
47
|
+
installation: {
|
|
48
|
+
produce: { priceAggregator },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
bundleID,
|
|
52
|
+
) => {
|
|
53
|
+
/** @type {Installation<FluxStartFn>} */
|
|
54
|
+
const installation = await E(zoe).installBundleID(bundleID);
|
|
55
|
+
priceAggregator.reset();
|
|
56
|
+
priceAggregator.resolve(installation);
|
|
57
|
+
trace('installed priceAggregator', bundleID.slice(0, 'b1-1234567'.length));
|
|
58
|
+
return installation;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Provide (find/create) inert brands (no mint or issuer) referred to by oracles
|
|
63
|
+
*
|
|
64
|
+
* @param {EconomyBootstrapPowers & NamedVatPowers} space
|
|
65
|
+
* @param {{ name: string; decimalPlaces: number }} opt
|
|
66
|
+
* @returns {Promise<Brand<'nat'>>}
|
|
67
|
+
*/
|
|
68
|
+
export const ensureOracleBrand = async (
|
|
69
|
+
{
|
|
70
|
+
namedVat: {
|
|
71
|
+
consume: { agoricNames },
|
|
72
|
+
},
|
|
73
|
+
oracleBrand: { produce: oracleBrandProduce },
|
|
74
|
+
},
|
|
75
|
+
{ name, decimalPlaces },
|
|
76
|
+
) => {
|
|
77
|
+
const brand = E(agoricNames).provideInertBrand(name, {
|
|
78
|
+
assetKind: 'nat',
|
|
79
|
+
decimalPlaces,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
oracleBrandProduce[name].reset();
|
|
83
|
+
oracleBrandProduce[name].resolve(brand);
|
|
84
|
+
return brand;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {EconomyBootstrapPowers &
|
|
89
|
+
* PromiseSpaceOf<{ retiredContractInstances: MapStore<string, Instance> }>} powers
|
|
90
|
+
* @param {{
|
|
91
|
+
* AGORIC_INSTANCE_NAME: string;
|
|
92
|
+
* contractTerms: import('@agoric/inter-protocol/src/price/fluxAggregatorKit.js').ChainlinkConfig;
|
|
93
|
+
* brandIn: Brand<'nat'>;
|
|
94
|
+
* brandOut: Brand<'nat'>;
|
|
95
|
+
* }} config
|
|
96
|
+
* @param {Installation<FluxStartFn>} installation
|
|
97
|
+
*/
|
|
98
|
+
const startPriceAggregatorInstance = async (
|
|
99
|
+
{
|
|
100
|
+
consume: {
|
|
101
|
+
agoricNames,
|
|
102
|
+
board,
|
|
103
|
+
chainStorage,
|
|
104
|
+
chainTimerService,
|
|
105
|
+
econCharterKit,
|
|
106
|
+
highPrioritySendersManager,
|
|
107
|
+
namesByAddressAdmin,
|
|
108
|
+
startGovernedUpgradable,
|
|
109
|
+
retiredContractInstances: retiredContractInstancesP,
|
|
110
|
+
},
|
|
111
|
+
instance: { produce: produceInstance },
|
|
112
|
+
produce: { retiredContractInstances: produceRetiredInstances },
|
|
113
|
+
},
|
|
114
|
+
{ AGORIC_INSTANCE_NAME, contractTerms, brandIn, brandOut },
|
|
115
|
+
installation,
|
|
116
|
+
) => {
|
|
117
|
+
trace('startPriceAggregatorInstance', AGORIC_INSTANCE_NAME);
|
|
118
|
+
const label = sanitizePathSegment(AGORIC_INSTANCE_NAME);
|
|
119
|
+
|
|
120
|
+
const feedsStorage = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
|
|
121
|
+
const storageNode = await E(feedsStorage).makeChildNode(label);
|
|
122
|
+
const marshaller = await E(board).getReadonlyMarshaller();
|
|
123
|
+
|
|
124
|
+
const terms = harden({
|
|
125
|
+
...contractTerms,
|
|
126
|
+
description: AGORIC_INSTANCE_NAME,
|
|
127
|
+
brandIn,
|
|
128
|
+
brandOut,
|
|
129
|
+
// XXX powerful TimerService, see #6003
|
|
130
|
+
timer: await chainTimerService,
|
|
131
|
+
unitAmountIn: await unitAmount(brandIn),
|
|
132
|
+
});
|
|
133
|
+
const privateArgs = {
|
|
134
|
+
highPrioritySendersManager: await highPrioritySendersManager,
|
|
135
|
+
marshaller,
|
|
136
|
+
namesByAddressAdmin,
|
|
137
|
+
storageNode,
|
|
138
|
+
};
|
|
139
|
+
const governedKit = await E(startGovernedUpgradable)({
|
|
140
|
+
governedParams: {},
|
|
141
|
+
privateArgs,
|
|
142
|
+
terms,
|
|
143
|
+
label,
|
|
144
|
+
// @ts-expect-error GovernableStartFn vs. fluxAggregatorContract.js start
|
|
145
|
+
installation,
|
|
146
|
+
});
|
|
147
|
+
const retiredContractInstances = await provideRetiredInstances(
|
|
148
|
+
retiredContractInstancesP,
|
|
149
|
+
produceRetiredInstances,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// save the instance so we can manage it later
|
|
153
|
+
const retiringInstance = await E(agoricNames).lookup(
|
|
154
|
+
'instance',
|
|
155
|
+
AGORIC_INSTANCE_NAME,
|
|
156
|
+
);
|
|
157
|
+
const boardID = await E(board).getId(retiringInstance);
|
|
158
|
+
retiredContractInstances.init(
|
|
159
|
+
`priceFeed-${AGORIC_INSTANCE_NAME}-${boardID}`,
|
|
160
|
+
retiringInstance,
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
produceInstance[AGORIC_INSTANCE_NAME].reset();
|
|
164
|
+
produceInstance[AGORIC_INSTANCE_NAME].resolve(governedKit.instance);
|
|
165
|
+
trace(
|
|
166
|
+
'new instance',
|
|
167
|
+
label,
|
|
168
|
+
{ terms, privateArgs, installation },
|
|
169
|
+
governedKit,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
await E(E.get(econCharterKit).creatorFacet).addInstance(
|
|
173
|
+
governedKit.instance,
|
|
174
|
+
governedKit.governorCreatorFacet,
|
|
175
|
+
AGORIC_INSTANCE_NAME,
|
|
176
|
+
);
|
|
177
|
+
trace('added', label, 'instance to econCharter');
|
|
178
|
+
|
|
179
|
+
/** @type {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<FluxStartFn>} */
|
|
180
|
+
// @ts-expect-error
|
|
181
|
+
const { instance, publicFacet, creatorFacet } = governedKit;
|
|
182
|
+
|
|
183
|
+
return harden({ instance, publicFacet, creatorFacet });
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Send invitations to oracle operators for a price feed.
|
|
188
|
+
*
|
|
189
|
+
* @param {EconomyBootstrapPowers} powers
|
|
190
|
+
* @param {{ oracleAddresses: string[]; AGORIC_INSTANCE_NAME: string }} config
|
|
191
|
+
* @param {any} creatorFacet
|
|
192
|
+
*/
|
|
193
|
+
const distributeInvitations = async (
|
|
194
|
+
{ consume: { namesByAddressAdmin } },
|
|
195
|
+
{ oracleAddresses, AGORIC_INSTANCE_NAME },
|
|
196
|
+
creatorFacet,
|
|
197
|
+
) => {
|
|
198
|
+
/** @param {string} addr */
|
|
199
|
+
const addOracle = async addr => {
|
|
200
|
+
const invitation = await E(creatorFacet).makeOracleInvitation(addr);
|
|
201
|
+
const debugName = `${AGORIC_INSTANCE_NAME} member ${addr}`;
|
|
202
|
+
await reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
|
|
203
|
+
invitation,
|
|
204
|
+
]).catch(err => console.error(`failed deposit to ${debugName}`, err));
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
trace('distributing invitations', oracleAddresses);
|
|
208
|
+
// This doesn't resolve until oracle operators create their smart wallets.
|
|
209
|
+
// Don't block completion on it.
|
|
210
|
+
void Promise.all(oracleAddresses.map(addOracle));
|
|
211
|
+
trace('createPriceFeed complete');
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @param {EconomyBootstrapPowers &
|
|
216
|
+
* NamedVatPowers &
|
|
217
|
+
* PromiseSpaceOf<{ retiredContractInstances: MapStore<string, Instance> }>} powers
|
|
218
|
+
* @param {{
|
|
219
|
+
* options: PriceFeedConfig & {
|
|
220
|
+
* priceAggregatorRef: { bundleID: string };
|
|
221
|
+
* scaledPARef: { bundleID: string };
|
|
222
|
+
* inBrandsDecimals?: number;
|
|
223
|
+
* contractTerms?: ChainlinkConfig;
|
|
224
|
+
* outBrandName?: string;
|
|
225
|
+
* outBrandDecimals?: number;
|
|
226
|
+
* };
|
|
227
|
+
* }} config
|
|
228
|
+
*/
|
|
229
|
+
export const deployPriceFeeds = async (powers, config) => {
|
|
230
|
+
const {
|
|
231
|
+
inBrandNames,
|
|
232
|
+
oracleAddresses,
|
|
233
|
+
contractTerms,
|
|
234
|
+
priceAggregatorRef,
|
|
235
|
+
scaledPARef,
|
|
236
|
+
inBrandsDecimals = 6,
|
|
237
|
+
outBrandName = 'USD',
|
|
238
|
+
outBrandDecimals = 6,
|
|
239
|
+
} = config.options;
|
|
240
|
+
await null;
|
|
241
|
+
|
|
242
|
+
const installation = await installPriceAggregator(
|
|
243
|
+
powers,
|
|
244
|
+
priceAggregatorRef.bundleID,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
const { priceAuthorityAdmin, priceAuthority } = powers.consume;
|
|
248
|
+
|
|
249
|
+
trace({ oracleAddresses });
|
|
250
|
+
trace({ inBrandNames });
|
|
251
|
+
for (const inBrandName of inBrandNames) {
|
|
252
|
+
const AGORIC_INSTANCE_NAME = oracleBrandFeedName(inBrandName, outBrandName);
|
|
253
|
+
const brandIn = await ensureOracleBrand(powers, {
|
|
254
|
+
name: inBrandName,
|
|
255
|
+
decimalPlaces: inBrandsDecimals,
|
|
256
|
+
});
|
|
257
|
+
const brandOut = await ensureOracleBrand(powers, {
|
|
258
|
+
name: outBrandName,
|
|
259
|
+
decimalPlaces: outBrandDecimals,
|
|
260
|
+
});
|
|
261
|
+
const kit = await startPriceAggregatorInstance(
|
|
262
|
+
powers,
|
|
263
|
+
{
|
|
264
|
+
AGORIC_INSTANCE_NAME,
|
|
265
|
+
brandIn,
|
|
266
|
+
brandOut,
|
|
267
|
+
contractTerms: { ...DEFAULT_CONTRACT_TERMS, ...contractTerms },
|
|
268
|
+
},
|
|
269
|
+
installation,
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const forceReplace = true;
|
|
273
|
+
await E(priceAuthorityAdmin).registerPriceAuthority(
|
|
274
|
+
E(kit.publicFacet).getPriceAuthority(),
|
|
275
|
+
brandIn,
|
|
276
|
+
brandOut,
|
|
277
|
+
forceReplace,
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
await distributeInvitations(
|
|
281
|
+
powers,
|
|
282
|
+
{ oracleAddresses, AGORIC_INSTANCE_NAME },
|
|
283
|
+
kit.creatorFacet,
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// @ts-expect-error replaceScaledPriceAuthorities uses a subset of the powers.
|
|
288
|
+
await replaceScaledPriceAuthorities(powers, {
|
|
289
|
+
options: { scaledPARef },
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
trace('resolving priceAuthority8400');
|
|
293
|
+
// cf. #8400 QuotePayments storage leak
|
|
294
|
+
powers.produce.priceAuthority8400.resolve(priceAuthority);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const t = 'priceFeed';
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Thread price feed upgrade options through from builder to core-eval.
|
|
301
|
+
*
|
|
302
|
+
* @param {object} utils
|
|
303
|
+
* @param {any} utils.restoreRef
|
|
304
|
+
* @param {PriceFeedConfig & { priceAggregatorRef: any }} priceFeedOptions
|
|
305
|
+
*/
|
|
306
|
+
export const getManifestForPriceFeeds = async (
|
|
307
|
+
{ restoreRef: _restoreRef },
|
|
308
|
+
priceFeedOptions,
|
|
309
|
+
) => ({
|
|
310
|
+
manifest: {
|
|
311
|
+
[deployPriceFeeds.name]: {
|
|
312
|
+
namedVat: t,
|
|
313
|
+
consume: {
|
|
314
|
+
agoricNamesAdmin: t,
|
|
315
|
+
agoricNames: t,
|
|
316
|
+
board: t,
|
|
317
|
+
chainStorage: t,
|
|
318
|
+
chainTimerService: t,
|
|
319
|
+
contractKits: t,
|
|
320
|
+
econCharterKit: t,
|
|
321
|
+
highPrioritySendersManager: t,
|
|
322
|
+
instancePrivateArgs: t,
|
|
323
|
+
namesByAddressAdmin: t,
|
|
324
|
+
priceAuthority: t,
|
|
325
|
+
priceAuthorityAdmin: t,
|
|
326
|
+
retiredContractInstances: t,
|
|
327
|
+
startGovernedUpgradable: t,
|
|
328
|
+
startUpgradable: t,
|
|
329
|
+
zoe: t,
|
|
330
|
+
},
|
|
331
|
+
installation: { produce: { priceAggregator: t } },
|
|
332
|
+
instance: {
|
|
333
|
+
produce: t,
|
|
334
|
+
consume: t,
|
|
335
|
+
},
|
|
336
|
+
oracleBrand: { produce: t },
|
|
337
|
+
produce: { priceAuthority8400: t, retiredContractInstances: t },
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
options: { ...priceFeedOptions },
|
|
341
|
+
});
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
-
import '../../exported.js';
|
|
4
|
-
|
|
5
3
|
import { AmountMath } from '@agoric/ertp';
|
|
6
|
-
import '@agoric/governance/exported.js';
|
|
7
4
|
import { deeplyFulfilledObject, makeTracer } from '@agoric/internal';
|
|
8
5
|
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
|
|
9
|
-
import '@agoric/vats/exported.js';
|
|
10
|
-
import '@agoric/vats/src/core/types.js';
|
|
11
|
-
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
12
6
|
import { E } from '@endo/far';
|
|
13
7
|
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
8
|
+
import { Stable } from '@agoric/internal/src/tokens.js';
|
|
14
9
|
import { makeGovernedTerms as makeGovernedATerms } from '../auction/params.js';
|
|
15
10
|
import { makeReserveTerms } from '../reserve/params.js';
|
|
16
11
|
import { makeGovernedTerms as makeGovernedVFTerms } from '../vaultFactory/params.js';
|
|
17
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @import {GovernorCreatorFacet, GovernanceFacetKit, GovernorStartedInstallationKit} from '@agoric/governance/src/types.js';
|
|
15
|
+
* @import {StartedInstanceKit} from '@agoric/zoe/src/zoeService/utils.js';
|
|
16
|
+
* @import {AdminFacet} from '@agoric/zoe';
|
|
17
|
+
* @import {MapStore, SetStore} from '@agoric/store';
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// Duplicated from vaultFactory/types-ambient.js to solve a CI problem.
|
|
21
|
+
// Not worth refactoring to DRY because vaultFactory is going away.
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {object} InterestTiming
|
|
24
|
+
* @property {import('@agoric/time').RelativeTime} chargingPeriod in seconds
|
|
25
|
+
* @property {import('@agoric/time').RelativeTime} recordingPeriod in seconds
|
|
26
|
+
*/
|
|
27
|
+
|
|
18
28
|
const trace = makeTracer('RunEconBehaviors', true);
|
|
19
29
|
|
|
20
30
|
export const SECONDS_PER_MINUTE = 60n;
|
|
@@ -22,54 +32,75 @@ export const SECONDS_PER_HOUR = 60n * 60n;
|
|
|
22
32
|
export const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
|
|
23
33
|
export const SECONDS_PER_WEEK = 7n * SECONDS_PER_DAY;
|
|
24
34
|
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
* @typedef {import('../auction/auctioneer.js').AuctioneerPublicFacet} AuctioneerPublicFacet
|
|
28
|
-
* @typedef {import('../auction/auctioneer.js').AuctioneerCreatorFacet} AuctioneerCreatorFacet
|
|
29
|
-
*/
|
|
35
|
+
/** @import {start as VFStart} from '../vaultFactory/vaultFactory.js' */
|
|
36
|
+
/** @typedef {Awaited<ReturnType<VFStart>>['publicFacet']} VaultFactoryPublicFacet */
|
|
30
37
|
|
|
31
38
|
/**
|
|
32
39
|
* @typedef {object} PSMKit
|
|
33
40
|
* @property {string} label
|
|
34
|
-
* @property {Instance} psm
|
|
35
|
-
* @property {Instance
|
|
36
|
-
*
|
|
37
|
-
*
|
|
41
|
+
* @property {Instance<import('../psm/psm.js').start>} psm
|
|
42
|
+
* @property {Instance<
|
|
43
|
+
* import('../../../governance/src/contractGovernor.js').start
|
|
44
|
+
* >} psmGovernor
|
|
45
|
+
* @property {Awaited<
|
|
46
|
+
* ReturnType<
|
|
47
|
+
* Awaited<
|
|
48
|
+
* ReturnType<import('../psm/psm.js')['start']>
|
|
49
|
+
* >['creatorFacet']['getLimitedCreatorFacet']
|
|
50
|
+
* >
|
|
51
|
+
* >} psmCreatorFacet
|
|
52
|
+
* @property {GovernorCreatorFacet<import('../../src/psm/psm.js')['start']>} psmGovernorCreatorFacet
|
|
38
53
|
* @property {AdminFacet} psmAdminFacet
|
|
39
54
|
*/
|
|
40
55
|
|
|
41
|
-
/**
|
|
42
|
-
* @typedef {GovernanceFacetKit<import('../auction/auctioneer.js').start>} AuctioneerKit
|
|
43
|
-
*/
|
|
56
|
+
/** @typedef {GovernanceFacetKit<import('../auction/auctioneer.js').start>} AuctioneerKit */
|
|
44
57
|
|
|
45
58
|
/**
|
|
46
|
-
* @typedef {
|
|
47
|
-
*
|
|
59
|
+
* @typedef {WellKnownSpaces & ChainBootstrapSpace & EconomyBootstrapSpace} EconomyBootstrapPowers
|
|
60
|
+
*
|
|
61
|
+
*
|
|
48
62
|
* @typedef {PromiseSpaceOf<{
|
|
49
|
-
* economicCommitteeKit: CommitteeStartResult
|
|
50
|
-
* economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet
|
|
51
|
-
* feeDistributorKit: StartedInstanceKit<
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
63
|
+
* economicCommitteeKit: CommitteeStartResult;
|
|
64
|
+
* economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet;
|
|
65
|
+
* feeDistributorKit: StartedInstanceKit<
|
|
66
|
+
* typeof import('../feeDistributor.js').start
|
|
67
|
+
* >;
|
|
68
|
+
* periodicFeeCollectors: MapStore<
|
|
69
|
+
* number,
|
|
70
|
+
* import('../feeDistributor.js').PeriodicFeeCollector
|
|
71
|
+
* >;
|
|
72
|
+
* psmKit: MapStore<Brand, PSMKit>;
|
|
73
|
+
* anchorBalancePayments: MapStore<Brand, Payment<'nat'>>;
|
|
74
|
+
* econCharterKit: EconCharterStartResult;
|
|
75
|
+
* reserveKit: GovernanceFacetKit<
|
|
76
|
+
* import('../reserve/assetReserve.js')['start']
|
|
77
|
+
* >;
|
|
78
|
+
* vaultFactoryKit: GovernanceFacetKit<VFStart>;
|
|
79
|
+
* auctioneerKit: AuctioneerKit;
|
|
80
|
+
* newAuctioneerKit: AuctioneerKit | undefined;
|
|
81
|
+
* minInitialDebt: NatValue;
|
|
60
82
|
* }>} EconomyBootstrapSpace
|
|
61
83
|
*/
|
|
62
84
|
|
|
63
|
-
/**
|
|
64
|
-
|
|
85
|
+
/**
|
|
86
|
+
* @typedef {StartedInstanceKit<
|
|
87
|
+
* import('../econCommitteeCharter.js')['start']
|
|
88
|
+
* >} EconCharterStartResult
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {StartedInstanceKit<
|
|
92
|
+
* import('@agoric/governance/src/committee.js')['start']
|
|
93
|
+
* >} CommitteeStartResult
|
|
94
|
+
*/
|
|
65
95
|
|
|
66
96
|
/**
|
|
67
97
|
* @file A collection of productions, each of which declares inputs and outputs.
|
|
68
|
-
*
|
|
98
|
+
* Each function is passed a set of powers for reading from and writing to the
|
|
99
|
+
* vat config.
|
|
69
100
|
*
|
|
70
|
-
*
|
|
101
|
+
* Each of the things they produce they're responsible for resolving or setting.
|
|
71
102
|
*
|
|
72
|
-
*
|
|
103
|
+
* In production called by @agoric/vats to bootstrap.
|
|
73
104
|
*/
|
|
74
105
|
|
|
75
106
|
/** @param {EconomyBootstrapPowers} powers */
|
|
@@ -141,9 +172,10 @@ export const setupReserve = async ({
|
|
|
141
172
|
'reserve.governor',
|
|
142
173
|
);
|
|
143
174
|
|
|
144
|
-
const [creatorFacet, publicFacet, instance] = await Promise.all([
|
|
175
|
+
const [creatorFacet, publicFacet, adminFacet, instance] = await Promise.all([
|
|
145
176
|
E(g.creatorFacet).getCreatorFacet(),
|
|
146
177
|
E(g.creatorFacet).getPublicFacet(),
|
|
178
|
+
E(g.creatorFacet).getAdminFacet(),
|
|
147
179
|
E(g.publicFacet).getGovernedContract(),
|
|
148
180
|
]);
|
|
149
181
|
|
|
@@ -153,7 +185,7 @@ export const setupReserve = async ({
|
|
|
153
185
|
instance,
|
|
154
186
|
publicFacet,
|
|
155
187
|
creatorFacet,
|
|
156
|
-
adminFacet
|
|
188
|
+
adminFacet,
|
|
157
189
|
|
|
158
190
|
governor: g.instance,
|
|
159
191
|
governorCreatorFacet: g.creatorFacet,
|
|
@@ -214,14 +246,14 @@ export const setupVaultFactoryArguments = async (
|
|
|
214
246
|
initialShortfallInvitation,
|
|
215
247
|
shortfallInvitationAmount,
|
|
216
248
|
feeMintAccess,
|
|
217
|
-
|
|
249
|
+
auctioneerInstance,
|
|
218
250
|
] = await Promise.all([
|
|
219
251
|
poserInvitationP,
|
|
220
252
|
E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
|
|
221
253
|
shortfallInvitationP,
|
|
222
254
|
E(E(zoe).getInvitationIssuer()).getAmountOf(shortfallInvitationP),
|
|
223
255
|
feeMintAccessP,
|
|
224
|
-
E.get(auctioneerKit).
|
|
256
|
+
E.get(auctioneerKit).instance,
|
|
225
257
|
]);
|
|
226
258
|
|
|
227
259
|
const reservePublicFacet = await E.get(reserveKit).publicFacet;
|
|
@@ -230,7 +262,6 @@ export const setupVaultFactoryArguments = async (
|
|
|
230
262
|
|
|
231
263
|
const vaultFactoryTerms = makeGovernedVFTerms({
|
|
232
264
|
priceAuthority,
|
|
233
|
-
auctioneerPublicFacet,
|
|
234
265
|
reservePublicFacet,
|
|
235
266
|
interestTiming,
|
|
236
267
|
timer: chainTimerService,
|
|
@@ -242,6 +273,7 @@ export const setupVaultFactoryArguments = async (
|
|
|
242
273
|
});
|
|
243
274
|
|
|
244
275
|
const vaultFactoryPrivateArgs = {
|
|
276
|
+
auctioneerInstance,
|
|
245
277
|
feeMintAccess,
|
|
246
278
|
initialPoserInvitation,
|
|
247
279
|
initialShortfallInvitation,
|
|
@@ -301,7 +333,11 @@ export const startVaultFactory = async (
|
|
|
301
333
|
}),
|
|
302
334
|
);
|
|
303
335
|
|
|
304
|
-
/**
|
|
336
|
+
/**
|
|
337
|
+
* @type {GovernorStartedInstallationKit<
|
|
338
|
+
* typeof vaultFactoryInstallation
|
|
339
|
+
* >}
|
|
340
|
+
*/
|
|
305
341
|
const g = await E(consume.zoe).startInstance(
|
|
306
342
|
contractGovernorInstallation,
|
|
307
343
|
undefined,
|
|
@@ -350,8 +386,8 @@ export const startVaultFactory = async (
|
|
|
350
386
|
};
|
|
351
387
|
|
|
352
388
|
/**
|
|
353
|
-
* Grant access to the VaultFactory creatorFacet
|
|
354
|
-
*
|
|
389
|
+
* Grant access to the VaultFactory creatorFacet to up to one user based on
|
|
390
|
+
* address.
|
|
355
391
|
*
|
|
356
392
|
* @param {EconomyBootstrapPowers} powers
|
|
357
393
|
* @param {object} [root0]
|
|
@@ -436,19 +472,18 @@ export const startRewardDistributor = async ({
|
|
|
436
472
|
});
|
|
437
473
|
|
|
438
474
|
/**
|
|
439
|
-
* @type {
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
* }
|
|
475
|
+
* @type {StartedInstanceKit<
|
|
476
|
+
* typeof import('@agoric/inter-protocol/src/feeDistributor.js').start
|
|
477
|
+
* >}
|
|
443
478
|
*/
|
|
444
479
|
const instanceKit = await E(zoe).startInstance(
|
|
445
480
|
feeDistributor,
|
|
446
481
|
{ Fee: centralIssuer },
|
|
482
|
+
// @ts-expect-error XXX
|
|
447
483
|
feeDistributorTerms,
|
|
448
484
|
undefined,
|
|
449
485
|
'feeDistributor',
|
|
450
486
|
);
|
|
451
|
-
/** @type {ERef<import('../feeDistributor.js').FeeDestination>} */
|
|
452
487
|
await E(instanceKit.creatorFacet).setDestinations({
|
|
453
488
|
...(rewardDistributorDepositFacet && {
|
|
454
489
|
RewardDistributor: E(
|