@agoric/inter-protocol 0.16.1-dev-b020abe.0 → 0.16.1-dev-13050c2.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/bundles/bundle-auctioneer-js-meta.json +116 -116
- package/bundles/bundle-econCommitteeCharter-js-meta.json +73 -73
- package/bundles/bundle-feeDistributor-js-meta.json +57 -57
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +111 -111
- package/bundles/bundle-psm-js-meta.json +109 -109
- package/bundles/bundle-reserve-js-meta.json +113 -113
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +80 -80
- package/bundles/bundle-vaultFactory-js-meta.json +133 -133
- package/bundles/bundle-vaultFactory.js +1 -1
- package/package.json +18 -17
- package/scripts/add-STARS.js +43 -0
- package/src/proposals/addAssetToVault.js +14 -2
- package/src/proposals/price-feed-proposal.js +29 -14
- package/src/vaultFactory/vaultDirector.js +2 -0
- package/src/vaultFactory/vaultManager.js +15 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.16.1-dev-
|
|
3
|
+
"version": "0.16.1-dev-13050c2.0+13050c2",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "yarn build:bundles",
|
|
12
12
|
"build:bundles": "node ./scripts/build-bundles.js",
|
|
13
|
+
"build:add-STARS-proposal": "agoric run scripts/add-STARS.js",
|
|
13
14
|
"test": "ava",
|
|
14
15
|
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
|
|
15
16
|
"test:xs": "exit 0",
|
|
@@ -29,29 +30,29 @@
|
|
|
29
30
|
},
|
|
30
31
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@agoric/assert": "0.6.1-dev-
|
|
33
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
34
|
-
"@agoric/governance": "0.10.3-dev-
|
|
35
|
-
"@agoric/internal": "0.3.3-dev-
|
|
36
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
37
|
-
"@agoric/store": "0.9.3-dev-
|
|
38
|
-
"@agoric/time": "0.3.3-dev-
|
|
39
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
40
|
-
"@agoric/vats": "0.15.1-dev-
|
|
41
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
33
|
+
"@agoric/assert": "0.6.1-dev-13050c2.0+13050c2",
|
|
34
|
+
"@agoric/ertp": "0.16.3-dev-13050c2.0+13050c2",
|
|
35
|
+
"@agoric/governance": "0.10.3-dev-13050c2.0+13050c2",
|
|
36
|
+
"@agoric/internal": "0.3.3-dev-13050c2.0+13050c2",
|
|
37
|
+
"@agoric/notifier": "0.6.3-dev-13050c2.0+13050c2",
|
|
38
|
+
"@agoric/store": "0.9.3-dev-13050c2.0+13050c2",
|
|
39
|
+
"@agoric/time": "0.3.3-dev-13050c2.0+13050c2",
|
|
40
|
+
"@agoric/vat-data": "0.5.3-dev-13050c2.0+13050c2",
|
|
41
|
+
"@agoric/vats": "0.15.1-dev-13050c2.0+13050c2",
|
|
42
|
+
"@agoric/zoe": "0.26.3-dev-13050c2.0+13050c2",
|
|
42
43
|
"@endo/captp": "^3.1.1",
|
|
43
44
|
"@endo/eventual-send": "^0.17.2",
|
|
44
45
|
"@endo/far": "^0.2.18",
|
|
45
46
|
"@endo/marshal": "^0.8.5",
|
|
46
47
|
"@endo/nat": "^4.1.27",
|
|
47
|
-
"agoric": "0.21.1-dev-
|
|
48
|
+
"agoric": "0.21.1-dev-13050c2.0+13050c2",
|
|
48
49
|
"jessie.js": "^0.3.2"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@agoric/deploy-script-support": "0.10.3-dev-
|
|
52
|
-
"@agoric/smart-wallet": "0.5.3-dev-
|
|
53
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
54
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
52
|
+
"@agoric/deploy-script-support": "0.10.3-dev-13050c2.0+13050c2",
|
|
53
|
+
"@agoric/smart-wallet": "0.5.3-dev-13050c2.0+13050c2",
|
|
54
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-13050c2.0+13050c2",
|
|
55
|
+
"@agoric/swingset-vat": "0.32.3-dev-13050c2.0+13050c2",
|
|
55
56
|
"@endo/bundle-source": "^2.5.1",
|
|
56
57
|
"@endo/init": "^0.5.56",
|
|
57
58
|
"@endo/promise-kit": "^0.2.56",
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"publishConfig": {
|
|
80
81
|
"access": "public"
|
|
81
82
|
},
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "13050c28e9a154e188cff8f1d08c704a4c7ca26a"
|
|
83
84
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { makeHelpers } from '@agoric/deploy-script-support';
|
|
2
|
+
import { defaultProposalBuilder as vaultProposalBuilder } from './add-collateral-core.js';
|
|
3
|
+
import { defaultProposalBuilder as oraclesProposalBuilder } from './price-feed-core.js';
|
|
4
|
+
|
|
5
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
|
|
6
|
+
export const starsVaultProposalBuilder = async powers => {
|
|
7
|
+
return vaultProposalBuilder(powers, {
|
|
8
|
+
interchainAssetOptions: {
|
|
9
|
+
// Values for the Stargaze token on Osmosis
|
|
10
|
+
denom:
|
|
11
|
+
'ibc/987C17B11ABC2B20019178ACE62929FE9840202CE79498E29FE8E5CB02B7C0A4',
|
|
12
|
+
decimalPlaces: 6,
|
|
13
|
+
keyword: 'STARS',
|
|
14
|
+
oracleBrand: 'STARS',
|
|
15
|
+
proposedName: 'STARS',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
|
|
21
|
+
export const starsOraclesProposalBuilder = async powers => {
|
|
22
|
+
return oraclesProposalBuilder(powers, {
|
|
23
|
+
AGORIC_INSTANCE_NAME: `STARS-USD price feed`,
|
|
24
|
+
IN_BRAND_LOOKUP: ['agoricNames', 'oracleBrand', 'STARS'],
|
|
25
|
+
IN_BRAND_DECIMALS: 6,
|
|
26
|
+
OUT_BRAND_LOOKUP: ['agoricNames', 'oracleBrand', 'USD'],
|
|
27
|
+
OUT_BRAND_DECIMALS: 4,
|
|
28
|
+
oracleAddresses: [
|
|
29
|
+
// copied from decentral-main-vaults-config.json
|
|
30
|
+
'agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr',
|
|
31
|
+
'agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8',
|
|
32
|
+
'agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78',
|
|
33
|
+
'agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p',
|
|
34
|
+
'agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj',
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default async (homeP, endowments) => {
|
|
40
|
+
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
|
|
41
|
+
await writeCoreProposal('add-STARS', starsVaultProposalBuilder);
|
|
42
|
+
await writeCoreProposal('add-STARS-oracles', starsOraclesProposalBuilder);
|
|
43
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
3
|
import { AmountMath, AssetKind } from '@agoric/ertp';
|
|
4
|
-
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
|
|
5
4
|
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
6
5
|
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
7
|
-
import {
|
|
6
|
+
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
|
|
8
7
|
import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
|
|
8
|
+
import { E } from '@endo/far';
|
|
9
|
+
import { instanceNameFor } from './price-feed-proposal.js';
|
|
9
10
|
import { reserveThenGetNames } from './utils.js';
|
|
10
11
|
|
|
11
12
|
export * from './startPSM.js';
|
|
@@ -219,6 +220,7 @@ export const addAssetToVault = async (
|
|
|
219
220
|
brand: {
|
|
220
221
|
consume: { [Stable.symbol]: stableP },
|
|
221
222
|
},
|
|
223
|
+
instance: { consume: consumeInstance },
|
|
222
224
|
},
|
|
223
225
|
{
|
|
224
226
|
options: {
|
|
@@ -239,6 +241,11 @@ export const addAssetToVault = async (
|
|
|
239
241
|
[keyword],
|
|
240
242
|
);
|
|
241
243
|
|
|
244
|
+
const oracleInstanceName = instanceNameFor(oracleBrand, 'USD');
|
|
245
|
+
// don't add the collateral offering to vaultFactory until its price feed is available
|
|
246
|
+
// eslint-disable-next-line no-restricted-syntax -- allow this computed property
|
|
247
|
+
await consumeInstance[oracleInstanceName];
|
|
248
|
+
|
|
242
249
|
const stable = await stableP;
|
|
243
250
|
const vaultFactoryCreator = E.get(vaultFactoryKit).creatorFacet;
|
|
244
251
|
await E(vaultFactoryCreator).addVaultType(interchainIssuer, oracleBrand, {
|
|
@@ -321,6 +328,11 @@ export const getManifestForAddAssetToVault = (
|
|
|
321
328
|
brand: {
|
|
322
329
|
consume: { [Stable.symbol]: true },
|
|
323
330
|
},
|
|
331
|
+
instance: {
|
|
332
|
+
// allow any instance because the AGORIC_INSTANCE_NAME of
|
|
333
|
+
// priceFeedOptions cannot be known statically.
|
|
334
|
+
consume: true,
|
|
335
|
+
},
|
|
324
336
|
},
|
|
325
337
|
},
|
|
326
338
|
installations: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @ts-nocheck -- lots of type errors. low prio b/c proposals are like scripts
|
|
2
|
-
import {
|
|
2
|
+
import { makeTracer } from '@agoric/internal';
|
|
3
3
|
import {
|
|
4
|
-
makeStorageNodeChild,
|
|
5
4
|
assertPathSegment,
|
|
5
|
+
makeStorageNodeChild,
|
|
6
6
|
} from '@agoric/internal/src/lib-chainStorage.js';
|
|
7
|
-
import {
|
|
7
|
+
import { E } from '@endo/far';
|
|
8
8
|
|
|
9
9
|
import { unitAmount } from '@agoric/zoe/src/contractSupport/priceQuote.js';
|
|
10
10
|
import { reserveThenDeposit, reserveThenGetNames } from './utils.js';
|
|
@@ -18,6 +18,9 @@ const sanitizePathSegment = name => {
|
|
|
18
18
|
return candidate;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
export const instanceNameFor = (inBrandName, outBrandName) =>
|
|
22
|
+
`${inBrandName}-${outBrandName} price feed`;
|
|
23
|
+
|
|
21
24
|
/**
|
|
22
25
|
* @typedef {{
|
|
23
26
|
* brandIn?: ERef<Brand<'nat'> | undefined>,
|
|
@@ -95,6 +98,7 @@ export const createPriceFeed = async (
|
|
|
95
98
|
priceAuthorityAdmin,
|
|
96
99
|
startGovernedUpgradable,
|
|
97
100
|
},
|
|
101
|
+
instance: { produce: produceInstance },
|
|
98
102
|
},
|
|
99
103
|
{
|
|
100
104
|
options: {
|
|
@@ -160,11 +164,27 @@ export const createPriceFeed = async (
|
|
|
160
164
|
installation: priceAggregator,
|
|
161
165
|
});
|
|
162
166
|
|
|
163
|
-
|
|
167
|
+
// Publish price feed in home.priceAuthority.
|
|
168
|
+
const forceReplace = true;
|
|
169
|
+
// Make sure this PA is registered before sharing the instance in agoricNames,
|
|
170
|
+
// which allows contracts that depend on the registry value to wait for it and
|
|
171
|
+
// prevent a race.
|
|
172
|
+
await E(priceAuthorityAdmin).registerPriceAuthority(
|
|
173
|
+
E(faKit.publicFacet).getPriceAuthority(),
|
|
174
|
+
brandIn,
|
|
175
|
+
brandOut,
|
|
176
|
+
forceReplace,
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
await E(E(agoricNamesAdmin).lookupAdmin('instance'))
|
|
164
180
|
.update(AGORIC_INSTANCE_NAME, faKit.instance)
|
|
165
181
|
.catch(err =>
|
|
166
182
|
console.error(`🚨 failed to update ${AGORIC_INSTANCE_NAME}`, err),
|
|
167
183
|
);
|
|
184
|
+
// being after the above awaits means that when this resolves, the consumer
|
|
185
|
+
// gets notified that the authority is in the registry and its instance is in
|
|
186
|
+
// agoricNames.
|
|
187
|
+
produceInstance[AGORIC_INSTANCE_NAME].resolve(faKit.instance);
|
|
168
188
|
|
|
169
189
|
E(E.get(econCharterKit).creatorFacet).addInstance(
|
|
170
190
|
faKit.instance,
|
|
@@ -173,15 +193,6 @@ export const createPriceFeed = async (
|
|
|
173
193
|
);
|
|
174
194
|
trace('registered', AGORIC_INSTANCE_NAME, faKit.instance);
|
|
175
195
|
|
|
176
|
-
// Publish price feed in home.priceAuthority.
|
|
177
|
-
const forceReplace = true;
|
|
178
|
-
void E(priceAuthorityAdmin).registerPriceAuthority(
|
|
179
|
-
E(faKit.publicFacet).getPriceAuthority(),
|
|
180
|
-
brandIn,
|
|
181
|
-
brandOut,
|
|
182
|
-
forceReplace,
|
|
183
|
-
);
|
|
184
|
-
|
|
185
196
|
/**
|
|
186
197
|
* Initialize a new oracle and send an invitation to administer it.
|
|
187
198
|
*
|
|
@@ -231,6 +242,9 @@ export const getManifestForPriceFeed = async (
|
|
|
231
242
|
priceAuthorityAdmin: t,
|
|
232
243
|
startGovernedUpgradable: t,
|
|
233
244
|
},
|
|
245
|
+
instance: {
|
|
246
|
+
produce: t,
|
|
247
|
+
},
|
|
234
248
|
},
|
|
235
249
|
[ensureOracleBrands.name]: {
|
|
236
250
|
namedVat: {
|
|
@@ -242,6 +256,7 @@ export const getManifestForPriceFeed = async (
|
|
|
242
256
|
},
|
|
243
257
|
},
|
|
244
258
|
installations: {
|
|
259
|
+
// ??? will every eval of price-feed-proposal install priceAggregator ?
|
|
245
260
|
priceAggregator: restoreRef(priceFeedOptions.priceAggregatorRef),
|
|
246
261
|
},
|
|
247
262
|
options: {
|
|
@@ -302,7 +317,7 @@ export const startPriceFeeds = async (
|
|
|
302
317
|
{
|
|
303
318
|
options: {
|
|
304
319
|
priceFeedOptions: {
|
|
305
|
-
AGORIC_INSTANCE_NAME:
|
|
320
|
+
AGORIC_INSTANCE_NAME: instanceNameFor(inBrandName, outBrandName),
|
|
306
321
|
contractTerms: {
|
|
307
322
|
minSubmissionCount: 2,
|
|
308
323
|
minSubmissionValue: 1,
|
|
@@ -250,6 +250,7 @@ const prepareVaultDirector = (
|
|
|
250
250
|
metrics: makeRecorderTopic('Vault Factory metrics', metricsKit),
|
|
251
251
|
});
|
|
252
252
|
|
|
253
|
+
/** @param {(vm: VaultManager) => void} fn */
|
|
253
254
|
const allManagersDo = fn => {
|
|
254
255
|
for (const managerIndex of collateralManagers.values()) {
|
|
255
256
|
const vm = vaultManagers.get(managerIndex).self;
|
|
@@ -424,6 +425,7 @@ const prepareVaultDirector = (
|
|
|
424
425
|
|
|
425
426
|
makeLiquidationWaker() {
|
|
426
427
|
return makeWaker('liquidationWaker', _timestamp => {
|
|
428
|
+
// XXX floating promise
|
|
427
429
|
allManagersDo(vm => vm.liquidateVaults(auctioneer));
|
|
428
430
|
});
|
|
429
431
|
},
|
|
@@ -400,7 +400,7 @@ export const prepareVaultManagerKit = (
|
|
|
400
400
|
// throw. See https://github.com/Agoric/agoric-sdk/issues/4317
|
|
401
401
|
void observeNotifier(quoteNotifier, {
|
|
402
402
|
updateState(value) {
|
|
403
|
-
trace('
|
|
403
|
+
trace('storing new quote', value.quoteAmount.value);
|
|
404
404
|
ephemera.storedCollateralQuote = value;
|
|
405
405
|
},
|
|
406
406
|
fail(reason) {
|
|
@@ -1036,7 +1036,7 @@ export const prepareVaultManagerKit = (
|
|
|
1036
1036
|
if (!storedCollateralQuote)
|
|
1037
1037
|
throw Fail`lockOraclePrices called before a collateral quote was available`;
|
|
1038
1038
|
trace(
|
|
1039
|
-
`
|
|
1039
|
+
`lockOraclePrices`,
|
|
1040
1040
|
getAmountIn(storedCollateralQuote),
|
|
1041
1041
|
getAmountOut(storedCollateralQuote),
|
|
1042
1042
|
);
|
|
@@ -1046,7 +1046,7 @@ export const prepareVaultManagerKit = (
|
|
|
1046
1046
|
return storedCollateralQuote;
|
|
1047
1047
|
},
|
|
1048
1048
|
/**
|
|
1049
|
-
* @param {AuctioneerPublicFacet} auctionPF
|
|
1049
|
+
* @param {ERef<AuctioneerPublicFacet>} auctionPF
|
|
1050
1050
|
*/
|
|
1051
1051
|
async liquidateVaults(auctionPF) {
|
|
1052
1052
|
const { state, facets } = this;
|
|
@@ -1060,11 +1060,19 @@ export const prepareVaultManagerKit = (
|
|
|
1060
1060
|
} = state;
|
|
1061
1061
|
trace(collateralBrand, 'considering liquidation');
|
|
1062
1062
|
|
|
1063
|
+
if (!lockedQuote) {
|
|
1064
|
+
// By design, the first cycle of auction may call this before a quote is locked
|
|
1065
|
+
// because the schedule is global at the vaultDirector level, and if a manager
|
|
1066
|
+
// starts after the price lock time there's nothing to be done.
|
|
1067
|
+
// NB: this message should not log repeatedly.
|
|
1068
|
+
console.error(
|
|
1069
|
+
'Skipping liquidation because no quote is locked yet (may happen with new manager)',
|
|
1070
|
+
);
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1063
1074
|
const { prioritizedVaults } = collateralEphemera(collateralBrand);
|
|
1064
|
-
|
|
1065
|
-
lockedQuote ||
|
|
1066
|
-
Fail`Must have locked a quote before liquidating vaults.`;
|
|
1067
|
-
assert(lockedQuote); // redundant with previous line
|
|
1075
|
+
prioritizedVaults || Fail`prioritizedVaults missing from ephemera`;
|
|
1068
1076
|
|
|
1069
1077
|
const liqMargin = self.getGovernedParams().getLiquidationMargin();
|
|
1070
1078
|
|